Ask Your Question

samir22's profile - activity

2019-05-25 01:49:26 -0600 received badge  Notable Question (source)
2017-06-30 06:47:04 -0600 received badge  Popular Question (source)
2016-06-01 08:59:01 -0600 received badge  Popular Question (source)
2013-02-24 03:59:13 -0600 commented answer How to create a Mat for 32 bit ARGB image

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()

2013-02-22 05:12:27 -0600 commented question Problem creating Mat from camera buffers (edited)

@berak, I tried using cvtColor but it kept segfaulting. Please see the update to my question.

2013-02-22 03:23:47 -0600 asked a question How to create a Mat for 32 bit ARGB 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.

2013-02-22 01:09:17 -0600 commented question Problem creating Mat from camera buffers (edited)

Hey @sammy what is an srsc? Can you also see the update I've made, if that gives any clue?

The camera buffer that is coming in is 32 bit ARGB data. I thought OpenCV worked with RGB? The camera buffer can also come in in NV12. What would be better to handle?

2013-02-22 01:06:33 -0600 received badge  Editor (source)
2013-02-21 22:22:14 -0600 received badge  Student (source)
2013-02-21 20:50:56 -0600 asked a question Problem creating Mat from camera buffers (edited)

Latest update

So I've made a few changes and would like to list them and the results.

The camera buffer is in 32 bit ARGB. I changed the type in the Mat initialization to CV_32FC4. When I call

cv::blur(src,dest,Size(5,5));

I am seeing a red screen - lending me to believe the ARGB format is not working with the Mat.

So I guess the question boils down to, how do I format ARGB to work with OpenCV Mat?

Original question

Hey guys,

So I'm creating a Mat from camera buffers that I'm receiving like so:

cv::Mat src = cv::Mat(cv::Size(img_height, img_width),CV_8UC4);
memcpy(src.ptr(), (void*) img_buffer,img_height * img_width * 4);

This works fine.

But when I try to do any operation on this, I get weird output.

For example,

cv::blur(src,src,Size(5,5));

results in the expected output (blurred) but divided into 5 "columns".

Similarly, if I try

cv::blur(src,src,Size(3,3));

I get 3 such columns.

Same with other operations - Gaussian blur, erode etc

Only other operation I have tested that works fine without a problem is clone().

Can anyone hazard a guess as to why this might be happening?

I'm working on a device which does not have a proper port of OpenCV so all OS related tasks(reading and writing images) are being done by hand.

=====UPDATE======

So I've been experimenting a little.

I can make calls such as

cv::medianBlur(inter,dest,3);

and there is output (albeit distorted as described above). But when I do something like

cv::cvtColor(inter, dest, COLOR_RGBA2RGB);

I'm getting segfault errors. Is there a fundamental difference in how these functions work that may be indicative of the problem?