- YUV420 -> Mat 可用于转换接受到的YUV视频源到OpenCV可以识别的数据
Mat myuv( Frame_Height + Frame_Height / 2, Frame_Width, CV_8UC1, (unsigned char *) YUV420_Image_Buffer);
cvtColor(myuv, mgMat, CV_YUV420p2RGB);
- Mat -> YUV420 可用于OpenCV处理完视频信号后返回
cvtColor(mgMat, myuv,CV_RGB2YUV_I420); //CV_RGB2YUV_YV12, CV_RGB2YUV 会产生不同的效果,可以多尝试几个,看那个效果是正确的
memcpy( YUV420_Image_Buffer, myuv.data, Frame_Width * Frame_Height * ( 3 / 2 ) * sizeof(unsigned char) );