[英]How to Read raw (YUV 4:2:2) format Image data from the memory
I am trying to read the raw YUV 4:2:2 (720p) data from the Read buffer, I mapped the physical address of the Read buffer to the virtual address. 我试图从Read缓冲区读取原始YUV 4:2:2(720p)数据,我将Read缓冲区的物理地址映射到虚拟地址。
mem is a pointer which is pointing to Read buffer base address. mem是一个指向Read buffer base address的指针。 I tried with below below-mentioned code but it is returning the empty image, please can anybody help me to read the Raw YUV 4:2:2 format image data from the memory.
我尝试使用下面提到的代码,但它返回空图像,请任何人帮我阅读内存中的Raw YUV 4:2:2格式图像数据。
I have tried below-mentioned code, but i is returning empty image 我试过下面提到的代码,但我正在返回空图像
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();
The Raw YUV 4:2:2 image has a size = 2 * height * width. Raw YUV 4:2:2图像的尺寸= 2 *高度*宽度。 And You need to create:
你需要创建:
cv::Mat img(2 * height, width, CV_8UC1, mem, sizeOfRowInBytes);
The Y channel will be in first height*sizeOfRowInBytes bytes. Y通道将位于第一个高度* sizeOfRowInBytes字节中。 And after will be UV channels:
以后将是UV通道:
half of row with U and half with V; U的一半和V的一半;
half of row with U and half with V; U的一半和V的一半;
... ...
Height. 高度。 half of row with U and half with V.
U的一半和V的一半。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.