How are cv::Mat objects treated by OpenCV?

asked 2015-03-27 10:07:47 -0600

Potato gravatar image

Are cv::Mat objects treated as pointers?

My code basically loops through and reads images from a vector of cv::Mat, applies the getParvo fucntion of the Retina class and stores it in a temporary cv::Mat, and the pushes back this temporary cv::Mat to another vector of images.

I found some unusual behavior with the cv::Mat. If my temporary cv::Mat WAS NOT declared inside the loop, then only the parvo of last image of the original image vector was pushed to the new vector. I had to declare it inside the loop, so that it goes out of scope and is recreated at the next iteration. I was able to solve the problem but could not understand why it was happening. Is it because cv::Mat objects are treated as pointers? or is it some other reason?

edit retag flag offensive close merge delete


this might need a little code snippet ;)

berak gravatar imageberak ( 2015-03-27 10:15:43 -0600 )edit