Ask Your Question

Revision history [back]

Opencv throws an exception (problem is not with UYVY) :

Mat x(200, 100, CV_8UC2, Scalar(0));
imshow("test", x);
waitKey();

Exception is

OpenCV(4.1.1-dev) Error: Unspecified error (> Invalid number of channels in input image:
'VScn::contains(scn)'
where
'scn' is 2
) in __cdecl cv::impl::`anonymous-namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0x62372b14::Set<3,4,-1>,struct cv::impl::A0x62372b14::Set<0,2,5>,2>::CvtHelper(const class cv::debug_build_guard::_InputArray &,const class cv::debug_build_guard::_OutputArray &,int), file g:\lib\opencv\modules\imgproc\src\color.simd_helpers.hpp, line 92

May be you should try cvtColorTwoPlane :

Mat frame = Mat(300, 100, CV_8UC2, data),dst; 
vector<Mat> p;

split(frame,p);
cvtColorTwoPlane(p[0],p[1],dst,COLOR_YUV2BGR_NV12);

I cannot test this code. I haven't got any image in UYVY format