opencv读取本地视频

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>

using namespace cv;

int main( )
{
    VideoCapture cap("/path/to/Videos/华农兄弟:兄弟俩去摘野果.mp4");
    if(!cap.isOpened())
    {
        return -1;
    }
    Mat frame;
    
    //循环读取显示视频的每一帧
    while(1)
    {
        cap>>frame; 
        if(frame.empty()) break;
        imshow("当前视频",frame);
        if(waitKey(30) >=0)
            break;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/MoonShapedPool/article/details/83097104