opencv读取视频

来源:互联网 发布:手机论坛软件 编辑:程序博客网 时间:2024/05/16 13:43

1.CommandLineParser类


 const char* args = {

        "{ m | useMouse  | true | how to choose object to track}"
        "{ v | videoName | color.avi | the video to track}"
        "{ t | featureType | 3 | 0 -- HUE 1 -- SATURATION_HUE 2 -- LBP_HUE 3 -- LBP_SATURATION_HUE}"
    };

    CommandLineParser parser(argc, argv, args);//代替命令行,可以直接运行,不需要输入参数了
    bool isUseMouse = parser.get<bool>("useMouse");

    Rect trackWindow;

    string videoName;
    if(isUseMouse)
        videoName = parser.get<string>("videoName");
    else
    {
        /*
         * read config parameters from file
         */
        string configFile = "config.yaml";
        readXML(configFile, videoName, trackWindow);
    }


在OPENCV中CommandLineParser parser(argc, argv, args)的使用可以代替命令行的输入,更为详细的解析在

opencv源码解析之(5):CommandLineParser类的简单理解


2.视频的读取

 VideoCapture video;
    video.open(videoName);
    if(!video.isOpened()){
        cerr << "open " << videoName << " error" << endl;
        cerr << "current parameters : " << endl;
        parser.printParams();
        return -1;
    }

要用的的dll和lib库有:opencv_imgproc2410d.lib,opencv_video2410d.lib,opencv_core2410d.lib,opencv_highgui2410d.lib

一定要加入opencv_ffmpeg2410.dll


0 0
原创粉丝点击