diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp index 1e44d2e62..d99901b1b 100644 --- a/modules/core/include/opencv2/core/utility.hpp +++ b/modules/core/include/opencv2/core/utility.hpp @@ -607,6 +607,10 @@ For example: } @endcode +Note that there are no default values for `help` and `timestamp` so we can check their presence using the `has()` method. +Arguments with default values are considered to be always present. Use the `get()` method in these cases to check their +actual value instead. + ### Usage For the described keys: diff --git a/modules/core/src/command_line_parser.cpp b/modules/core/src/command_line_parser.cpp index 0c50391f5..a7c1edc69 100644 --- a/modules/core/src/command_line_parser.cpp +++ b/modules/core/src/command_line_parser.cpp @@ -334,9 +334,9 @@ bool CommandLineParser::has(const String& name) const { for (size_t j = 0; j < impl->data[i].keys.size(); j++) { - if (name.compare(impl->data[i].keys[j]) == 0 && String("true").compare(impl->data[i].def_value) == 0) + if (name == impl->data[i].keys[j]) { - return true; + return !impl->cat_string(impl->data[i].def_value).empty(); } } }