user1592380
user1592380

Reputation: 36215

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?

Upvotes: 7

Views: 16174

Answers (1)

Aman Agarwal
Aman Agarwal

Reputation: 643

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

Upvotes: 21

Related Questions