欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Opencv实现yuv420P格式的读取

最编程 2024-08-15 15:50:30
...
	FILE *fs = NULL;
	int iRet  = fopen_s(&fs,"test_yuv420p_320x180.yuv", "rb");
	if (0 != iRet)
	{
		return;
	}
	unsigned char pSrc[320 * 90 * 3] = { 0 };
	int iLen = fread(pSrc, 1, 320 * 90 * 3, fs);

	int pixel_h = 180;
	int pixel_w = 320;

	Mat         yuv;
	Mat         m_color;

	yuv.create(pixel_h * 3 / 2, pixel_w, CV_8UC1);
	memcpy(yuv.data, pSrc, pixel_w * pixel_h * 3 / 2 * sizeof(unsigned char));

	cvtColor(yuv, m_color, cv::COLOR_YUV2RGB_I420);

	imshow("image", m_color);
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.