openCV 播放视频文件

#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"

using namespace std;
using namespace cv;

int main(int argc, char **argv)
{
    cvNamedWindow("WIND0", CV_WINDOW_AUTOSIZE);
    CvCapture* capture = cvCreateFileCapture(argv[1]);
    IplImage* frame;

    while(1) 
    {
        frame = cvQueryFrame(capture);
        if (!frame) break;
        cvShowImage("WIND0", frame);
        char c = cvWaitKey(33);
        if (c == 'c') break;
    }

    cvReleaseCapture(&capture);
    cvDestroyWindow("WIND0");


    return 0;
}
cmake_minimum_required(VERSION 2.8)

project(playvideo)

find_package(OpenCV REQUIRED)

add_executable(playvideo main.cpp)

target_link_libraries(playvideo ${OpenCV_LIBS})

你可能感兴趣的:(opencv)