Ask Your Question
1

How to create a Mat for 32 bit ARGB image

asked 2013-02-22 03:23:47 -0600

samir22 gravatar image

updated 2013-02-22 08:04:36 -0600

Andrey Pavlenko gravatar image

Hello,

I have a parallel thread running here about my troubles with using camera buffers to initialize a Mat. That thread has gotten all mixed up so I am creating a fresh thread to ask only one question.

How can 32 bit ARGB buffers be used to initialize a Mat. I found some references to using the BitmapToMat function but that appears to be available only under Android.

I am on a platform without an official port of OpenCV so a lot of OS level work (reading and writing images) is being done by hand.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-02-22 08:02:54 -0600

Andrey Pavlenko gravatar image

I assume your camera provides frame as an uchar* buff where A,R,G,B values of type uchar for one pixel are placed sequentially. Then the Mat initialization should look something like this:

int w, h;     // picture width and height
ucnar* buff;  // w*h*4 bytes, no strides between image lines
// ...
Mat m(h, w, CV_8UC4, buff);
edit flag offensive delete link more

Comments

I cannot initialize with the buffer data directly because there is no guarantee that the data will remain in the buffer. So I'm copying it using memcpy and ptr()

samir22 gravatar imagesamir22 ( 2013-02-24 03:59:13 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-02-22 03:23:47 -0600

Seen: 4,405 times

Last updated: Feb 22 '13