Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4906

Camera board • Extracting Chroma Data From Luminance Mat Object

$
0
0
Long story short, I'm using Libcamera and a IMX219 from ArduCam and I'm trying to get the chroma data from the YUV420 frame.

I've done the following so far:
1) Set the pixel format to YUV420

Code:

 streamConfig.pixelFormat = formats::YUV420; // Results in grayscale w/o striations 
2) Set the resolution to 1280 x 720

Code:

streamConfig.size.width = 1280;streamConfig.size.height = 720;
3) Gain access to the frame buffer and was able to use OpenCV to store/display the luminance data and the color somewhat with the code below.

Multiplying the cfg.size.height * 3/2 came from this post : viewtopic.php?t=340757

Code:

Image *img = mappedBuffers_[buffer].get();uint8_t *ptr = (uint8_t *)img->data(0).data();cv::Mat luminanceData = cv::Mat(cfg.size.height * 3 / 2, cfg.size.width, CV_8U, ptr, cfg.stride);cv::Mat rgb;cv::cvtColor(luminanceData, rgb, cv::COLOR_YUV420p2RGB);cv::namedWindow("luminanceData", cv::WINDOW_AUTOSIZE);cv::imshow("luminanceData", luminanceData);cv::moveWindow("luminanceData", 0, 100);cv::namedWindow("COLOR_YUV420p2RGB", cv::WINDOW_AUTOSIZE);cv::imshow("COLOR_YUV420p2RGB", rgb);cv::moveWindow("COLOR_YUV420p2RGB", 400, 100);cv::waitKey(1);
Screenshot 2024-08-07 114428.jpg

I'm confident that the image displayed in the 'COLOR_YUV420p2RGB" window isn't correct, but I'm horribly confused and lost on how exactly I'm supposed to extract the chroma/color data from the YUV420 frame

Statistics: Posted by Digital1O1 — Wed Aug 07, 2024 6:13 pm



Viewing all articles
Browse latest Browse all 4906

Trending Articles