如何读取原始(YUV 4:2:2)格式图像数据来自内存

问题描述 投票:0回答:1

我试图从Read缓冲区读取原始YUV 4:2:2(720p)数据,我将Read缓冲区的物理地址映射到虚拟地址。

mem是一个指向Read buffer base address的指针。我尝试使用下面提到的代码,但它返回空图像,请任何人帮我阅读内存中的Raw YUV 4:2:2格式图像数据。

我试过下面提到的代码,但我正在返回空图像

cv::Mat img(1,1280 , numCols,CV_8U1, mem);
//mem -> mem is a pointer to Read buffer which have raw YUV 4:2:2 image data .
//len-> Frame resolution (1280 * 720 * 3) (720p)
if (img.empty())
{
cout << "Image is not loaded" << endl;
return 0;
} 
cv::imshow("img",img);  
cv::waitKey();
c++ opencv opencv3.0 opencv3.1
1个回答
0
投票

Raw YUV 4:2:2图像的尺寸= 2 *高度*宽度。你需要创建:

cv::Mat img(2 * height, width, CV_8UC1, mem, sizeOfRowInBytes);

Y通道将位于第一个高度* sizeOfRowInBytes字节中。以后将是UV通道:

  1. U的一半和V的一半;
  2. U的一半和V的一半;

...

高度。 U的一半和V的一半。

© www.soinside.com 2019 - 2024. All rights reserved.