c++ - Reduce memory consumption -


i'm using code analyze webcam frames:

int main() {     videocapture cap(0); // open default camera     if (!cap.isopened())  // check if succeeded         return -1;     cap.set(cv_cap_prop_fps, 15);      std::vector<cv::mat> images(9000);     (framenumb = 0; framenumb < 9000; ++framenumb)      {         images[framenumb].create(480, 640, cv_8uc3);     }     (framenumb = 0; framenumb < 9000; ++framenumb)     {         mat frame;         cap >> frame;         if (frame.empty()) break; // end of video stream         if (waitkey(1) == 27) break; // stop capturing pressing esc          frame.copyto(images[framenumb]);         imshow("webcam", images[framenumb]);     }     //we can process captured frames 

however, leads insufficient memory error:

opencv error: insufficient memory (failed allocate xyz bytes) in unknown function, file  ..\..\opecv\modules\core\src\alloc.cpp line 52. 

is there way me avoid this? lot in advanced!

edit: constructive feedback everyone! guess can change approach problem. tried accomplish take average of every 15 frames. example: 9000 frames, have 600 average pictures. thus, created vector of 9000 images , use counter achieve that.this code used later:

for (int = 0; < 600; i++)             {                 mat avgimg(480, 640, cv_32fc3, scalar());                 (framenumb = 15 * i; framenumb < (15 * i) + 15; ++framenumb)                 {                     cv::accumulate(images[framenumb], avgimg);                 }                 //stacking every 15 images single image                 avgimg = avgimg / 15;                 avgimg.convertto(avgimg, cv_8uc3);                 char filename[80];                 sprintf(filename, "c:/avgpics/test_%d.jpeg", framenumb);                 imwrite(filename, avgimg); 

so there way me specify opencv take average of every 15 images without having use 9000-image vector?

compile 64 bits. 8 gb not excessive, 32 bits programs limited 4gb @ best. (i assume have sufficient ram - @ least 12 gb total). opencv supports 64 bits.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -