Ask Your Question

ImageProcessing_MF's profile - activity

2019-09-10 14:35:21 -0600 marked best answer Placing UYVY data in a Mat, C++

Hi,

may this question is not new, but i did not found an answer via google or in this forum.

I have image data in UYVY form (according to fourcc), Like here: http://fourcc.org/pixel-format/yuv-uyvy

For instance: Image width: 100, image height 300. So the data has 200 columns (as it is stored in UYVY it is two times the image width ) and 300 rows of uint8_t values.

So far so simple.

All i want is to get that data in a Mat within C++

What i tried (and this is, i assume, naive)

Let´s say data is the pointer to the data i already have.

Mat frame = Mat(300, 100, CV_8UC2, data); 
imshow("frame", frame);

But i am getting Memory faults.

Do i have to declare the Mat with ... (300,200, ...) as it is UYVY data. I guess not ! ? Also: CV_8UC2 should be correct for UYVY data, right ?

What i am doing wrong ?

Does the Mat somehow need to know, that it is UYVY data? Yes ! But how ? Declaring CV_8UC2 while creating the Mat object (like in the code above) does obviously only create the space, but the mat and so imshow do not know in which order (format) the image data is stored.

My data (and so the pointer) is correct, i checked that. Maybe the problem is, that Mat does store the data not as uint8_t, but as ... whatever --- larger than a byte. that would also be a reason, why i get memory faults.

My problem formulated in one sentence is: How can i get uint8_t data in UYVY order in a Mat?

Thanks a lot for your help in advance.

Best regards

Markus

2019-09-10 14:35:20 -0600 received badge  Self-Learner (source)
2019-09-10 14:30:12 -0600 answered a question Placing UYVY data in a Mat, C++

Hello, thanks for your answer. Splitting and working with cvtColorTwoPlane like suggested crashes. But finally your sug

2019-09-08 01:57:29 -0600 received badge  Student (source)
2019-09-07 13:47:30 -0600 asked a question Placing UYVY data in a Mat, C++

Placing UYVY data in a Mat, C++ Hi, may this question is not new, but i did not found an answer via google or in this f