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