如果是把YUV灰度图(只有Y分量)转化为Mat
1 cv::Mat cv_img; 2 cv::Mat cv_yuv(height, width, CV_8UC1, pFrame);//pFrame为YUV数据地址 3 cv_img = cv::Mat(height, width, CV_LOAD_IMAGE_COLOR); 4 cv::cvtColor(cv_yuv, cv_img, COLOR_GRAY2BGR);
如果是把YUV彩色图转化为Mat
1 1 cv::Mat cv_img; 2 2 cv::Mat cv_yuv(height + height/2, width, CV_8UC1, pFrame);//pFrame为YUV数据地址,另外这里就是用 CV_8UC1非 CV_8UC3. 3 3 cv_img = cv::Mat(height, width, CV_8UC3); 4 4 cv::cvtColor(cv_yuv, cv_img, COLOR_YUV2BGR_I420);