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; }