-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
dstChannels does not cover all color codes #20465
Description
Same issue as #18878.
Missing color codes in the dstChannels function leads to less-performant cvtColor implementations being used.
opencv/modules/imgproc/src/color.hpp
Line 92 in 70d5c88
| inline int dstChannels(int code) |
For example, I'm trying to convert OpenCL UMats and let OpenCV auto detect the number of channels like so:
cvtColor(src, dst, Lab2BGR, 0)
However, dstChannels doesn't recognize that specific color code so it forwards a dcn arg value of 0. This stops the OpenCL implementation because it fails a precondition check inside oclCvtColorLab2BGR when constructing the OclHelper.
opencv/modules/imgproc/src/color.hpp
Line 229 in 70d5c88
| CV_Check(dcn, VDcn::contains(dcn), "Invalid number of channels in output image"); |
when that check fails,
cvtColor falls through to a HAL implementation.
I'm specifically raising this issue because Lab2BGR is not currently handled (should return 3), but dstChannels should be audited to verify it covers as many color codes as possible.
The workaround for now is to explicitly set the dcn when calling cvtColor based on the color code's destination format.