# Revision history [back]

### Problem creating Mat from camera buffers

heHey 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.

### Problem creating Mat from camera buffers

heHey 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?

### Problem creating Mat from camera buffersbuffers (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?