c - 如何将帧复制到帧

标签 c opencv

一个变量怎么能在一帧到另一帧的那种复制,就不是内存管理问题了

例如:

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..

请帮忙。

最佳答案

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

关于c - 如何将帧复制到帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11442141/

相关文章:

opencv - 在应用 Canny 边缘检测之前预处理图像

opencv - 使用 Unity3D 解决 PnP

python - OpenCV 错误 : the function is not implemented

c++ - 如何找到字符串的所有排列?

c++ - 在 C/C++ 中同时与 Openssl epoll 服务器通信到多个客户端

opencv - 如何使用非自由模块安装 OpenCV 3.1?

python - Python-如何根据其值裁剪图像?

c - 如何将 POSIX 系统调用 fork() 和 wait() 移植到 Visual Studio 2010 Express?

c - 以英文显示整数上每个数字的程序不适用于以 "0"开头的整数

c - makefile 实用程序不会抛出错误