OpenCV 包含的错误

Error with OpenCV Includes

本文关键字:错误 包含 OpenCV      更新时间:2023-10-16

>请参阅下面的勾选答案:)错误 1 错误 C2065:"捕获":未声明的标识符

将VS2013 Express与OpenCV结合使用较旧的代码示例已经奏效,但我无法让这个示例:

#include <opencv2corecore.hpp>
#include <opencv2highguihighgui.hpp>
using namespace cv;
int main()
{
    Mat frame = cvQueryFrame(capture);
    imshow("Video", frame);
}

我不得不改变"opencv2/core/core.hpp"#include <opencv2corecore.hpp>,它得到了那个位。但是我已经尝试过包括高贵,但我无法"capture"工作?有什么想法吗?x64 调试,并使用 x64 库...

捕获部分是旧C-API的遗留物。

试试这个:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
using namespace cv;
int main()
{
    VideoCapture cap(0);
    while( cap.isOpened() )
    {
        Mat frame;
        if ( ! cap.read(frame) )
            break;
        imshow("lalala",frame);
        int k = waitKey(10);
        if ( k==27 )
            break;
    }
    return 0;
}
当然,

当您尚未声明变量capture时,它将如何工作?可能你想做这样的事情:

#include <opencv2corecore.hpp>
#include <opencv2highguihighgui.hpp>
using namespace cv;
int main()
{
    CvCapture* capture = cvCreateFileCapture("path to video file");
    Mat frame = cvQueryFrame(capture);
    imshow("Video", frame);
    waitKey();
    cvReleaseCapture(&capture);
}