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

Mat and imread memory management

$
0
0
Hey there, I am looking for the "best practice" to save a lot of images of type cv::Mat in the cache. Is it okay if I just push_back them in a vector< Mat > and get back as soon as I need them? Reason for my question is, that I tried to load ~150 images (300 Mb) with imread and after 100 the system starts to slow down extremely. After having a look at the monitoring I noticed that the RAM of 5 GB is getting trashed until it breaks down. Code snippet for my image reading below: cout << "Start reading image inputs..." << endl; vector imagesArg; for (int i = 1; i < argc; i++) { Mat img = imread(argv[i]); if (argc == 1){ cout << "Not enough image data." << endl; } if (img.empty()) { cout << "Can't read image " << argv[i] << "." << endl; return 1; } imagesArg.push_back(img); img.release(); } cout << "Finished reading " << imagesArg.size() << " images." << endl; Thanks in advance for an answer! Lax

Viewing all articles
Browse latest Browse all 19555

Trending Articles