opencv录制视频并保存视频

#include 
#include 

using namespace cv;

void main()
{
    VideoCapture capture(0);
    VideoWriter writer("VideoTest.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25.0, Size(640, 480));
    Mat frame;

    while (capture.isOpened())
    {
        capture >> frame;
        writer << frame;
        imshow("video", frame);
        if (cvWaitKey(20) == 27)
        {
            break;
        }
    }
}

你可能感兴趣的:(c++,opencv,qt)