I am trying to save a part of an image inside a bounding box as follow:
digit = thresh[x:x+w,y:y+h]
cv2.imwrite(str(c)+'.png',digit)
But I got following error.
error: OpenCV(4.1.2) /io/opencv/modules/imgcodecs/src/loadsave.cpp:715: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
Need your assistance.
digit. Useprint()for this. You could also checkx,y,w,h- maybewand/orhis zero.digitis empty. I don't knwo if you have something more between these two lines but maybe you assign new empty array todigitbefore write. Only you know all your code and only you can useprint()directly beforeimwriteto check what you have indigitcv2.imwrite('img.png', np.array([]))then you get the same error - because array is empty. If you add at least one value to array - ie.np.array([1])- then it works without error.