是否有人遇到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中执行转换吗?
答案 0 :(得分:8)
在Python中,COLOR_BGR2YCrCb
称为 COLOR_BGR2YCR_CB
。
看build/modules/python/pyopencv_generated_const_reg.h
透露:
97: PUBLISH2(COLOR_BGR2YCR_CB,cv::COLOR_BGR2YCrCb);