in my programm I have function that takes the image from camera and should pack all data in OpenCV Mat
structure. From the camera I get width, height and unsigned char*
to the image buffer. My Question is how I can create Mat from this data, if I have global Mat variable. The type for Mat structure I took CV_8UC1.
Mat image_;
function takePhoto() {
unsigned int width = getWidthOfPhoto();
unsinged int height = getHeightOfPhoto();
unsinged char* dataBuffer = getBufferOfPhoto();
Mat image(Size(width, height), CV_8UC1, dataBuffer, Mat::AUTO_STEP);
printf("width: %u\n", image.size().width);
printf("height: %u\n", image.size().height);
image_.create(Size(image.size().width, image.size().height), CV_8UC1);
image_ = image.clone();
printf("width: %u\n", image_.size().width);
printf("height: %u\n", image_.size().height);
}
When I test my program, I get right width
and height
of image
, but width
and height
of my global Mat image_
is 0
. How I can put the data in my global Mat
varible correctly?
Thank you.