OpenCV cv::Mat causing potential memory leak with std::vector
As it stands right now im trying to save an entire list of images in the
form of cv::Mats inside of a vector for later processing. Right now I have
something that looks like this:
do
{
image = readimage();
cv::Mat mat = cv::Mat((length, width, CV_8UC4, image))
cv::Mat temp = mat.clone();
saved_images.push_back();
mat.release();
temp.release();
freeimagememory(image);
}
while(hasimage);
This actually works. For exceptionally small lists of images it will store
them just fine. However as I get to large amounts of images the program
consistently crashes saying Abort() was called, and upon inspection it
says it's throwing a cv::exception.
Does anyone know why this is? I've thought about changing the vector to a
vector of pointers to cv::Mats in order to save space (cloning seems
expensive) but I'm not sure how well that will work.
Can anyone help?
No comments:
Post a Comment