Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

OpenCV Mat was overwritten unexpectedly when initializing another Mat

$
0
0
Test 1: BITMAP* input; //bitmap containing image data Mat _image(height, width, CV_8UC4, input); //convert Bitmap to Mat imwrite("0.jpg",_image); //write out the original input image Mat image = imread("0.jpg"); //read it back to a new Mat imwrite("1.jpg",image); //checkpoint 1 Mat image_remapped(Size(width, height), image.type(), Scalar(0,0,0,255)); //initialize another Mat imwrite("2.jpg",image); //checkpoint 2 Both 1.jpg and 2.jpg were the same as input. It does make sense. However, there should be something wrong with the Test 2. ---------- Test 2: BITMAP* input; //bitmap containing image data Mat image(height, width, CV_8UC4, input); //convert Bitmap to Mat imwrite("1.jpg",image); //checkpoint 1 Mat image_remapped(Size(width, height), image.type(), Scalar(0,0,0,255)); //initialize another Mat imwrite("2.jpg",image); //checkpoint 2 The output 1.jpg was the same as input image, 2.jpg was total black. I'm confused by the case 2. Why the `Mat image` was overwritten by the new `Mat image_remapped`?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>