I receive an image as binary in web.data()
and decode it with cv2.imdecode
. The result is an image. I can succefully run some blob detection on it no problem. Getting width and height however turned out to be a problem. Here's the code I'm using (found here and here) with the error messages I get. Neither of the two suggested ways of doing this works, why is that?
imageDecoded = cv2.imdecode(np.frombuffer(web.data(), dtype='uint8'), cv2.CV_LOAD_IMAGE_GRAYSCALE)
# https://stackoverflow.com/questions/13033278/image-size-python-opencv
height, width = cv.GetSize(imageDecoded) # <class 'cv2.error'> Array should be CvMat or IplImage
# https://stackoverflow.com/questions/32971241/how-to-get-image-width-and-height-in-opencv
height, width, channels = imageDecoded.shape # <type 'exceptions.AttributeError'> 'NoneType' object has no attribute 'shape'