opencv yuvNV21转RGB

 

void yuv420Torgb()
{
FILE *fp = fopen("D:\\1.yuv","rb");
int width = 4032;
int height = 3000;
uchar *yuvdata = new uchar[height * 3 / 2 * width * sizeof(uchar)];
fread(yuvdata, height * 3 / 2, width, fp);
Mat yuvimg(height * 3 / 2, width, CV_8UC1, yuvdata);
Mat rgbimg(height, width, CV_8UC3);
cvtColor(yuvimg, rgbimg, COLOR_YUV2BGR_NV21);
namedWindow("src", 0);
imshow("src", rgbimg);
waitKey(0);
fclose(fp);
delete[] yuvdata;
}

 

posted on 2019-08-08 16:12  Maddock  阅读(4283)  评论(0编辑  收藏  举报

导航