cv2和BGR2YCrCb不兼容Python绑定

时间:2012-06-11 14:41:20

标签: python opencv image-processing

是否有人遇到OpenCV 2.4问题并将图像转换为YCrCb色彩空间?我正在使用Python绑定,我似乎无法找到用于转换BGR2YCrCb的任何定义。以下是我一直在尝试的一些事情:

>>> 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'
>>>

有人知道如何在cv2中执行转换吗?

1 个答案:

答案 0 :(得分:8)

在Python中,COLOR_BGR2YCrCb称为 COLOR_BGR2YCR_CB

build/modules/python/pyopencv_generated_const_reg.h透露:

97: PUBLISH2(COLOR_BGR2YCR_CB,cv::COLOR_BGR2YCrCb);