Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cv2 and BGR2YCrCb not working with Python bindings

Is anybody having problems with OpenCV 2.4 and converting images to the YCrCb color space? I am using the Python bindings and I can't seem to find whatever definition is used to convert BGR2YCrCb. Here are some things that I have been trying:

>>> import cv2
>>> cv2.COLOR_BGR2GRAY # works fine
6L
>>> cv2.COLOR_BGR2HSV # works fine
40L
>>> cv2.COLOR_BGR2YCrCb # now the trouble starts
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'COLOR_BGR2YCrCb'
>>> cv2.COLOR_BGR2YCC
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'COLOR_BGR2YCC'
>>>

Does anybody know how to perform the conversion in cv2?

like image 541
Adrian Rosebrock Avatar asked Jun 11 '12 14:06

Adrian Rosebrock


1 Answers

In Python, COLOR_BGR2YCrCb is called COLOR_BGR2YCR_CB.

Looking at build/modules/python/pyopencv_generated_const_reg.h revealed:

97: PUBLISH2(COLOR_BGR2YCR_CB,cv::COLOR_BGR2YCrCb);
like image 132
karlphillip Avatar answered Sep 22 '22 17:09

karlphillip