Pergunta

See the ticked answer below :) Error 1 error C2065: 'capture' : undeclared identifier

Using VS2013 Express with OpenCV Older code examples have worked, but I cant get this one to:

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

I had to change "opencv2/core/core.hpp" To #include <opencv2\core\core.hpp>, and It got that bit. but I've tried including highgui but I cant get "capture" to work? Any ideas? x64 on Debug, and using x64 libs...

Foi útil?

Solução

that capture part is a leftover from the old c-api.

try this instead:

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

Outras dicas

Of course how will it work when you haven't declared the variable capture? Probably you want to do something like this:

#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
using namespace cv;
int main()
{
    CvCapture* capture = cvCreateFileCapture("path to video file");
    Mat frame = cvQueryFrame(capture);
    imshow("Video", frame);
    waitKey();
    cvReleaseCapture(&capture);
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top