Reputation: 665
I created this code in Opencv and after about 900 frames, this error appears:
OpenCV Error: Insufficient memory (Failed to allocate 921600 bytes) in function, file ..\..\..\..\ocv\opencv\src\cxcore\cxalloc.cpp, line 52
but I have initialized the variables once. Here is the code:
int _tmain(int argc, _TCHAR* argv[])
{
IplImage * image;
CvCapture * capture = cvCaptureFromCAM ( 0 );
while ( 1 ){
image = cvCreateImage ( cvSize ( 640,480 ) , 8, 3 );
image = cvQueryFrame ( capture );
cvShowImage ( "test", image );
cvWaitKey ( 10 );
}
}
Upvotes: 1
Views: 2558
Reputation: 26730
You're constantly creating new images with cvCreateImage
without using and, more importantly, without releasing them anywhere.
Just remove this line (it does not do anything other than eat up your memory):
image = cvCreateImage ( cvSize ( 640,480 ) , 8, 3 );
Upvotes: 1