-1

一个帧中的变量如何才能到另一帧它是那种不是内存管理问题的副本

例如 :

iplimage *frame = NULL;
iplimage *Temp_frame = NULL;

while(1) {
frame = cvQueryFrame( capture );

if( !frame ) break;

    Temp_frame=cvcloneimage(frame);

    cvreleaseImage(&Temp_frame);

    cvreleaseImage(&frame);
}

错误:

打开 cv.exe 中 0x75b39673 处未处理的异常:Microsoft C++ 异常:内存位置 0x0015f250 处的 cv::Exception..

请帮忙。

4

1 回答 1

1
iplimage *frame = NULL;
iplimage *Temp_frame = NULL;

while(1) 
{
    frame = cvQueryFrame(capture);    
    if (!frame) 
        break;

    if (!Temp_frame) // creates Temp_frame only once
        Temp_frame = cvCreateImage(cvGetSize(frame), frame->depth, frame->nChannels);    

    cvCopy(frame , Temp_frame, NULL);

    // DO NOT RELEASE the return of cvQueryFrame()!
    // I believe that's what crashing your application.
    //cvreleaseImage(&frame);
}

// Since the size of "frame" won't change, there's no need to to create/release 
// Temp_frame on every iteration of the loop. So we release it at the end:
cvReleaseImage(&Temp_frame);
于 2012-07-12T13:08:49.983 回答