Reputation: 35928
I am reading an image from a string like this. I know the image is in GrayScale.
nparr = np.fromstring(image_string, np.uint8)
roi = cv2.imdecode(nparr,cv2.IMREAD_GRAYSCALE)
But I am getting an error when I get the shape
of the image
h,w,d = roi.shape #gives error
The error I get is:
h, w, d = roi.shape
ValueError: need more than 2 values to unpack
If I change cv2.IMREAD_GRAYSCALE
to cv2.IMREAD_COLOR
then I don't get the error but I believe doing this changes my image slightly because I get different results when I do further processing on it.
Upvotes: 1
Views: 11274
Reputation: 306
roi.shape
has only two values.
nparr = np.fromstring(image_string, np.uint8)
roi = cv2.imdecode(nparr, cv2.IMREAD_GRAYSCALE)
h, w = roi.shape
Upvotes: 1