Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'cv2.cv2' has no attribute 'CV_LOAD_IMAGE_COLOR'

I have the following jpeg as a bytecode string:

jpg = 'b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xfe\x00>CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality\n\xff\xdb\x00C\x00\x08\x06\x06\x07

I want to load this into OpenCV.

I tried:

import numpy as np

# CV2
nparr = np.fromstring(jpg , np.uint8)
img_np = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR )  # cv2.IMREAD_COLOR in OpenCV 3.1

I'm getting:

AttributeError: module 'cv2.cv2' has no attribute 'CV_LOAD_IMAGE_COLOR'

How can I get this working?

like image 988
user1592380 Avatar asked May 22 '18 20:05

user1592380


1 Answers

You may try cv2.IMREAD_COLOR if using OpenCv 3.1. It worked for me.

like image 182
Aman Agarwal Avatar answered Sep 17 '22 13:09

Aman Agarwal