OpenCv,内存不足错误

时间:2013-03-03 14:37:41

标签: c++ opencv computer-vision

我在Opencv中创建了此代码,大约900帧后出现此错误:

OpenCV Error: Insufficient memory (Failed to allocate 921600 bytes) in function, file ..\..\..\..\ocv\opencv\src\cxcore\cxalloc.cpp, line 52

但我已经初始化了一次变量。 这是代码:

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 );
     }
}

2 个答案:

答案 0 :(得分:1)

您不断使用cvCreateImage创建新图像,而不使用,更重要的是,不在任何地方发布它们。

只需删除此行(除了吃掉你的记忆之外它什么都不做):

image = cvCreateImage ( cvSize ( 640,480 ) , 8, 3 );

答案 1 :(得分:0)

您需要在某个时候致电cvReleaseImage

相关问题