代码如下:
const String keys = "{c camera | 0 | use video stream from camera (device index starting from 0) }"
"{fn file_name | | use video file as input }"
"{m method | mog2 | method: background subtraction algorithm ('knn', 'mog2')}"
"{h help | | show help message}";
CommandLineParser parser(argc, argv, keys);
parser.about("This sample demonstrates background segmentation.");
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
问题是parser.about的作用是什么?
以及下面的if语句有没有实际意义?因为将其删除后并不影响后续代码的正常运行
谢谢
这东西看起来跟命令行解析器有关,about应该是help信息的一部分。下面的if表示,如果该程序支持help指令,会在指定help选项时输出帮助信息。如果你不在主程序调用时送入help参数,这段代码应该是不会被调用的。(多数程序会或多或少给出帮助文档,不然的话接手的维护者会看不懂。)
OpenCV也有官方文档:https://docs.opencv.org/
可以在官方文档里找到函数的具体用法。