CommandLindParser 不适用于负参数(双精度)
为了使用 OpenCV (C++) 解析命令行参数,我定义了 keyString,如下所示:
const String keyStrings = "{@filepath | lena.jpg | input image}"
"{@commandCode | color2BW | command code}"
"{@alpha | 1.0 | alpha}"
"{@beta | 1.0 | beta}";
CommandLineParser parser(argc, argv, keyStrings);
当我得到 alpha, beta 时,如下所示:
double alpha = parser.get<double>("@alpha");
double beta = parser.get<double>("@beta");
如果有人将 alpha 或 beta 值作为负数传递,那么 alpha, beta 将收到 1.0 作为其值。价值观。我不知道如何解决它。
To parse the command line arguments with OpenCV (C++) I have defined the keyString like that:
const String keyStrings = "{@filepath | lena.jpg | input image}"
"{@commandCode | color2BW | command code}"
"{@alpha | 1.0 | alpha}"
"{@beta | 1.0 | beta}";
CommandLineParser parser(argc, argv, keyStrings);
When I get the alpha, beta like this:
double alpha = parser.get<double>("@alpha");
double beta = parser.get<double>("@beta");
If someone pass the alpha or beta values as a negative number, alpha, beta will received 1.0 as its values. I don't know how to fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
,这是一个错误(应该报告)
我认为 您可以通过使用命名参数而不是位置(以
@
为前缀)参数来解决这个问题,例如:并像这样使用它:
i'd think, this is a bug (which should be reported)
however you can work around it by using named arguments instead of positional (prefixed with
@
) ones, like:and use it like: