add new version of CommandLineParser. add empty docs
This commit is contained in:
parent
6a112aa87a
commit
54a202b3d5
101
modules/core/doc/command_line_parser.rst
Normal file
101
modules/core/doc/command_line_parser.rst
Normal file
@ -0,0 +1,101 @@
|
||||
Command Line Parser
|
||||
===================
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
CommandLineParser
|
||||
--------
|
||||
.. ocv:class:: CommandLineParser
|
||||
|
||||
The CommandLineParser class is designed for command line arguments parsing
|
||||
|
||||
|
||||
.. ocv:function:: CommandLineParser::CommandLineParser(int argc, const char * const argv[], const std::string keys)
|
||||
|
||||
:param argc:
|
||||
:param argv:
|
||||
:param keys:
|
||||
|
||||
.. ocv:function:: T CommandLineParser::get<T>(const std::string& name, bool space_delete = true)
|
||||
|
||||
:param name:
|
||||
:param space_delete:
|
||||
|
||||
.. ocv:function:: T CommandLineParser::get<T>(int index, bool space_delete = true)
|
||||
|
||||
:param index:
|
||||
:param space_delete:
|
||||
|
||||
.. ocv:function:: bool CommandLineParser::has(const std::string& name)
|
||||
|
||||
:param name:
|
||||
|
||||
.. ocv:function:: bool CommandLineParser::check()
|
||||
|
||||
|
||||
.. ocv:function:: void CommandLineParser::about(std::string message)
|
||||
|
||||
:param message:
|
||||
|
||||
.. ocv:function:: void CommandLineParser::printMessage()
|
||||
|
||||
.. ocv:function:: void CommandLineParser::printErrors()
|
||||
|
||||
.. ocv:function:: std::string CommandLineParser::getPathToApplication()
|
||||
|
||||
|
||||
The sample below demonstrates how to use CommandLineParser:
|
||||
|
||||
::
|
||||
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
parser.about("Application name v1.0.0");
|
||||
|
||||
if (parser.has("help"))
|
||||
{
|
||||
parser.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int N = parser.get<int>("N");
|
||||
double fps = parser.get<double>parser("fps");
|
||||
std::string path = parser.get<std::string>("path");
|
||||
|
||||
use_time_stamp = parserer.has("timestamp");
|
||||
|
||||
std::string img1 = parser.get<string>(1);
|
||||
std::string img2 = parser.get<string>(2);
|
||||
|
||||
int repeat = parser.get<int>(3);
|
||||
|
||||
if (!parser.check())
|
||||
{
|
||||
parser.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Syntax:
|
||||
|
||||
::
|
||||
|
||||
const std::string keys =
|
||||
"{help h usage ? | | print this message }"
|
||||
"{@image1 | | image1 for compare }"
|
||||
"{@image2 | | image2 for compare }"
|
||||
"{@repeat |1 | number }"
|
||||
"{path |. | path to file }"
|
||||
"{fps | -1.0 | fps for output video }"
|
||||
"{N count |100 | count of objects }"
|
||||
"{ts timestamp | | use time stamp }"
|
||||
;
|
||||
|
||||
Use:
|
||||
|
||||
::
|
||||
|
||||
# ./app -N=200 1.png 2.jpg 19 -ts
|
||||
|
||||
# ./app -fps=aaa
|
||||
ERRORS:
|
||||
Exception: can not convert: [aaa] to [double]
|
||||
|
@ -6,6 +6,7 @@ core. The Core Functionality
|
||||
:maxdepth: 2
|
||||
|
||||
basic_structures
|
||||
command_line_parser
|
||||
old_basic_structures
|
||||
dynamic_structures
|
||||
operations_on_arrays
|
||||
|
@ -4505,113 +4505,143 @@ template<> struct ParamType<Algorithm>
|
||||
enum { type = Param::ALGORITHM };
|
||||
};
|
||||
|
||||
// The CommandLineParser class is designed for command line arguments parsing
|
||||
|
||||
class CV_EXPORTS CommandLineParserParams
|
||||
{
|
||||
public:
|
||||
std::string help_message;
|
||||
std::string def_value;
|
||||
std::vector<std::string> keys;
|
||||
int number;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::string get_type_name() { return "UNKNOW"; }
|
||||
|
||||
bool cmp_params(const CommandLineParserParams & p1, const CommandLineParserParams & p2);
|
||||
|
||||
template<typename T>
|
||||
T from_str(const std::string & str)
|
||||
{
|
||||
T value;
|
||||
std::stringstream ss(str);
|
||||
ss >> value;
|
||||
|
||||
if (ss.fail())
|
||||
{
|
||||
std::string err_msg =
|
||||
std::string("can not convert: [")
|
||||
+ str
|
||||
+ std::string("] to [")
|
||||
+ get_type_name<T>()
|
||||
+ std::string("]");
|
||||
|
||||
CV_Error(CV_StsBadArg, err_msg);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
template<> std::string from_str(const std::string & str);
|
||||
|
||||
template<typename T>
|
||||
std::string to_str(T value)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << value;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/*!
|
||||
"\nThe CommandLineParser class is designed for command line arguments parsing\n"
|
||||
"Keys map: \n"
|
||||
"Before you start to work with CommandLineParser you have to create a map for keys.\n"
|
||||
" It will look like this\n"
|
||||
" const char* keys =\n"
|
||||
" {\n"
|
||||
" { s| string| 123asd |string parameter}\n"
|
||||
" { d| digit | 100 |digit parameter }\n"
|
||||
" { c|noCamera|false |without camera }\n"
|
||||
" { 1| |some text|help }\n"
|
||||
" { 2| |333 |another help }\n"
|
||||
" };\n"
|
||||
"Usage syntax: \n"
|
||||
" \"{\" - start of parameter string.\n"
|
||||
" \"}\" - end of parameter string\n"
|
||||
" \"|\" - separator between short name, full name, default value and help\n"
|
||||
"Supported syntax: \n"
|
||||
" --key1=arg1 <If a key with '--' must has an argument\n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"<If the key with '--' doesn't have any argument, it means that it is a bool key>\n"
|
||||
" -key2=arg2 <If a key with '-' must has an argument \n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"If the key with '-' doesn't have any argument, it means that it is a bool key\n"
|
||||
" key3 <This key can't has any parameter> \n"
|
||||
"Usage: \n"
|
||||
" Imagine that the input parameters are next:\n"
|
||||
" -s=string_value --digit=250 --noCamera lena.jpg 10000\n"
|
||||
" CommandLineParser parser(argc, argv, keys) - create a parser object\n"
|
||||
" parser.get<string>(\"s\" or \"string\") will return you first parameter value\n"
|
||||
" parser.get<string>(\"s\", false or \"string\", false) will return you first parameter value\n"
|
||||
" without spaces in end and begin\n"
|
||||
" parser.get<int>(\"d\" or \"digit\") will return you second parameter value.\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types>\n"
|
||||
" parser.get<bool>(\"c\" or \"noCamera\") will return you true .\n"
|
||||
" If you enter this key in commandline>\n"
|
||||
" It return you false otherwise.\n"
|
||||
" parser.get<string>(\"1\") will return you the first argument without parameter (lena.jpg) \n"
|
||||
" parser.get<int>(\"2\") will return you the second argument without parameter (10000)\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types \n"
|
||||
*/
|
||||
class CV_EXPORTS CommandLineParser
|
||||
{
|
||||
public:
|
||||
CommandLineParser(int argc, const char * const argv[], const std::string keys);
|
||||
|
||||
//! the default constructor
|
||||
CommandLineParser(int argc, const char* const argv[], const char* key_map);
|
||||
std::string getPathToApplication();
|
||||
|
||||
//! get parameter, you can choose: delete spaces in end and begin or not
|
||||
template<typename _Tp>
|
||||
_Tp get(const std::string& name, bool space_delete=true)
|
||||
{
|
||||
if (!has(name))
|
||||
template <typename T>
|
||||
T get(const std::string& name, bool space_delete = true)
|
||||
{
|
||||
return _Tp();
|
||||
try
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < data[i].keys.size(); j++)
|
||||
{
|
||||
if (name.compare(data[i].keys[j]) == 0)
|
||||
{
|
||||
std::string v = data[i].def_value;
|
||||
if (space_delete == true) v = cat_string(v);
|
||||
return from_str<T>(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
error = true;
|
||||
error_message += "Unknown parametes " + name + "\n";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
error = true;
|
||||
error_message += "Exception: " + std::string(e.what()) + "\n";
|
||||
}
|
||||
return T();
|
||||
}
|
||||
std::string str = getString(name);
|
||||
return analyzeValue<_Tp>(str, space_delete);
|
||||
}
|
||||
|
||||
//! print short name, full name, current value and help for all params
|
||||
void printParams();
|
||||
template <typename T>
|
||||
T get(int index, bool space_delete = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
if (data[i].number == index - 1)
|
||||
{
|
||||
std::string v = data[i].def_value;
|
||||
if (space_delete == true) v = cat_string(v);
|
||||
return from_str<T>(v);
|
||||
}
|
||||
}
|
||||
error = true;
|
||||
error_message += "Unknown parametes #" + to_str<int>(index) + "\n";
|
||||
}
|
||||
catch(std::exception & e)
|
||||
{
|
||||
error = true;
|
||||
error_message += "Exception: " + std::string(e.what()) + "\n";
|
||||
}
|
||||
return T();
|
||||
}
|
||||
|
||||
bool has(const std::string& name);
|
||||
|
||||
bool check();
|
||||
|
||||
void about(std::string message);
|
||||
|
||||
void printMessage();
|
||||
void printErrors();
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::vector<std::string> > data;
|
||||
std::string getString(const std::string& name);
|
||||
bool error;
|
||||
std::string error_message;
|
||||
std::string about_message;
|
||||
|
||||
bool has(const std::string& keys);
|
||||
std::string path_to_app;
|
||||
std::string app_name;
|
||||
|
||||
template<typename _Tp>
|
||||
_Tp analyzeValue(const std::string& str, bool space_delete=false);
|
||||
std::vector<CommandLineParserParams> data;
|
||||
|
||||
template<typename _Tp>
|
||||
static _Tp getData(const std::string& str)
|
||||
{
|
||||
_Tp res;
|
||||
std::stringstream s1(str);
|
||||
s1 >> res;
|
||||
return res;
|
||||
}
|
||||
std::vector<std::string> split_range_string(std::string str, char fs, char ss);
|
||||
std::vector<std::string> split_string(std::string str, char symbol = ' ', bool create_empty_item = false);
|
||||
std::string cat_string(std::string str);
|
||||
|
||||
template<typename _Tp>
|
||||
_Tp fromStringNumber(const std::string& str);//the default conversion function for numbers
|
||||
void apply_params(std::string key, std::string value);
|
||||
void apply_params(int i, std::string value);
|
||||
|
||||
};
|
||||
void sort_params();
|
||||
|
||||
template<> CV_EXPORTS
|
||||
bool CommandLineParser::get<bool>(const std::string& name, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
int CommandLineParser::analyzeValue<int>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
float CommandLineParser::analyzeValue<float>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
double CommandLineParser::analyzeValue<double>(const std::string& str, bool space_delete);
|
||||
};
|
||||
|
||||
/////////////////////////////// Parallel Primitives //////////////////////////////////
|
||||
|
||||
|
@ -1,384 +0,0 @@
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
namespace {
|
||||
#if 0
|
||||
static void helpParser()
|
||||
{
|
||||
printf("\nThe CommandLineParser class is designed for command line arguments parsing\n"
|
||||
"Keys map: \n"
|
||||
"Before you start to work with CommandLineParser you have to create a map for keys.\n"
|
||||
" It will look like this\n"
|
||||
" const char* keys =\n"
|
||||
" {\n"
|
||||
" { s| string| 123asd |string parameter}\n"
|
||||
" { d| digit | 100 |digit parameter }\n"
|
||||
" { c|noCamera|false |without camera }\n"
|
||||
" { 1| |some text|help }\n"
|
||||
" { 2| |333 |another help }\n"
|
||||
" };\n"
|
||||
"Usage syntax: \n"
|
||||
" \"{\" - start of parameter string.\n"
|
||||
" \"}\" - end of parameter string\n"
|
||||
" \"|\" - separator between short name, full name, default value and help\n"
|
||||
"Supported syntax: \n"
|
||||
" --key1=arg1 <If a key with '--' must has an argument\n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"<If the key with '--' doesn't have any argument, it means that it is a bool key>\n"
|
||||
" -key2=arg2 <If a key with '-' must has an argument \n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"If the key with '-' doesn't have any argument, it means that it is a bool key\n"
|
||||
" key3 <This key can't has any parameter> \n"
|
||||
"Usage: \n"
|
||||
" Imagine that the input parameters are next:\n"
|
||||
" -s=string_value --digit=250 --noCamera lena.jpg 10000\n"
|
||||
" CommandLineParser parser(argc, argv, keys) - create a parser object\n"
|
||||
" parser.get<string>(\"s\" or \"string\") will return you first parameter value\n"
|
||||
" parser.get<string>(\"s\", false or \"string\", false) will return you first parameter value\n"
|
||||
" without spaces in end and begin\n"
|
||||
" parser.get<int>(\"d\" or \"digit\") will return you second parameter value.\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types>\n"
|
||||
" parser.get<bool>(\"c\" or \"noCamera\") will return you true .\n"
|
||||
" If you enter this key in commandline>\n"
|
||||
" It return you false otherwise.\n"
|
||||
" parser.get<string>(\"1\") will return you the first argument without parameter (lena.jpg) \n"
|
||||
" parser.get<int>(\"2\") will return you the second argument without parameter (10000)\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types \n"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<string> split_string(const string& str, const string& delimiters)
|
||||
{
|
||||
vector<string> res;
|
||||
|
||||
string split_str = str;
|
||||
size_t pos_delim = split_str.find(delimiters);
|
||||
|
||||
while ( pos_delim != string::npos)
|
||||
{
|
||||
if (pos_delim == 0)
|
||||
{
|
||||
res.push_back("");
|
||||
split_str.erase(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.push_back(split_str.substr(0, pos_delim));
|
||||
split_str.erase(0, pos_delim + 1);
|
||||
}
|
||||
|
||||
pos_delim = split_str.find(delimiters);
|
||||
}
|
||||
|
||||
res.push_back(split_str);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
string del_space(string name)
|
||||
{
|
||||
while ((name.find_first_of(' ') == 0) && (name.length() > 0))
|
||||
name.erase(0, 1);
|
||||
|
||||
while ((name.find_last_of(' ') == (name.length() - 1)) && (name.length() > 0))
|
||||
name.erase(name.end() - 1, name.end());
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const char* keys)
|
||||
{
|
||||
std::string keys_buffer;
|
||||
std::string values_buffer;
|
||||
std::string buffer;
|
||||
std::string curName;
|
||||
std::vector<string> keysVector;
|
||||
std::vector<string> paramVector;
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
size_t flagPosition;
|
||||
int currentIndex = 1;
|
||||
//bool isFound = false;
|
||||
bool withNoKey = false;
|
||||
bool hasValueThroughEq = false;
|
||||
|
||||
keys_buffer = keys;
|
||||
while (!keys_buffer.empty())
|
||||
{
|
||||
|
||||
flagPosition = keys_buffer.find_first_of('}');
|
||||
flagPosition++;
|
||||
buffer = keys_buffer.substr(0, flagPosition);
|
||||
keys_buffer.erase(0, flagPosition);
|
||||
|
||||
flagPosition = buffer.find('{');
|
||||
if (flagPosition != buffer.npos)
|
||||
buffer.erase(flagPosition, (flagPosition + 1));
|
||||
|
||||
flagPosition = buffer.find('}');
|
||||
if (flagPosition != buffer.npos)
|
||||
buffer.erase(flagPosition);
|
||||
|
||||
paramVector = split_string(buffer, "|");
|
||||
while (paramVector.size() < 4) paramVector.push_back("");
|
||||
|
||||
buffer = paramVector[0];
|
||||
buffer += '|' + paramVector[1];
|
||||
|
||||
//if (buffer == "") CV_ERROR(CV_StsBadArg, "In CommandLineParser need set short and full name");
|
||||
|
||||
paramVector.erase(paramVector.begin(), paramVector.begin() + 2);
|
||||
data[buffer] = paramVector;
|
||||
}
|
||||
|
||||
buffer.clear();
|
||||
keys_buffer.clear();
|
||||
paramVector.clear();
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (!argv[i])
|
||||
break;
|
||||
curName = argv[i];
|
||||
if (curName.find('-') == 0 && ((curName[1] < '0') || (curName[1] > '9')))
|
||||
{
|
||||
while (curName.find('-') == 0)
|
||||
curName.erase(curName.begin(), (curName.begin() + 1));
|
||||
}
|
||||
else
|
||||
withNoKey = true;
|
||||
if (curName.find('=') != curName.npos)
|
||||
{
|
||||
hasValueThroughEq = true;
|
||||
buffer = curName;
|
||||
curName.erase(curName.find('='));
|
||||
buffer.erase(0, (buffer.find('=') + 1));
|
||||
}
|
||||
|
||||
values_buffer = del_space(values_buffer);
|
||||
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
keys_buffer = it->first;
|
||||
keysVector = split_string(keys_buffer, "|");
|
||||
|
||||
for (size_t j = 0; j < keysVector.size(); j++) keysVector[j] = del_space(keysVector[j]);
|
||||
|
||||
values_buffer = it->second[0];
|
||||
if (((curName == keysVector[0]) || (curName == keysVector[1])) && hasValueThroughEq)
|
||||
{
|
||||
it->second[0] = buffer;
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasValueThroughEq && ((curName == keysVector[0]) || (curName == keysVector[1]))
|
||||
&& (
|
||||
values_buffer.find("false") != values_buffer.npos ||
|
||||
values_buffer == ""
|
||||
))
|
||||
{
|
||||
it->second[0] = "true";
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasValueThroughEq && (values_buffer.find("false") == values_buffer.npos) &&
|
||||
((curName == keysVector[0]) || (curName == keysVector[1])))
|
||||
{
|
||||
it->second[0] = argv[++i];
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (withNoKey)
|
||||
{
|
||||
std::string noKeyStr = it->first;
|
||||
if(atoi(noKeyStr.c_str()) == currentIndex)
|
||||
{
|
||||
it->second[0] = curName;
|
||||
currentIndex++;
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
withNoKey = false;
|
||||
hasValueThroughEq = false;
|
||||
//isFound = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CommandLineParser::has(const std::string& keys)
|
||||
{
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
std::vector<string> keysVector;
|
||||
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
keysVector = split_string(it->first, "|");
|
||||
for (size_t i = 0; i < keysVector.size(); i++) keysVector[i] = del_space(keysVector[i]);
|
||||
|
||||
if (keysVector.size() == 1) keysVector.push_back("");
|
||||
|
||||
if ((del_space(keys).compare(keysVector[0]) == 0) ||
|
||||
(del_space(keys).compare(keysVector[1]) == 0))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string CommandLineParser::getString(const std::string& keys)
|
||||
{
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
std::vector<string> valueVector;
|
||||
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
valueVector = split_string(it->first, "|");
|
||||
for (size_t i = 0; i < valueVector.size(); i++) valueVector[i] = del_space(valueVector[i]);
|
||||
|
||||
if (valueVector.size() == 1) valueVector.push_back("");
|
||||
|
||||
if ((del_space(keys).compare(valueVector[0]) == 0) ||
|
||||
(del_space(keys).compare(valueVector[1]) == 0))
|
||||
return it->second[0];
|
||||
}
|
||||
return string();
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
_Tp CommandLineParser::fromStringNumber(const std::string& str)//the default conversion function for numbers
|
||||
{
|
||||
return getData<_Tp>(str);
|
||||
}
|
||||
|
||||
void CommandLineParser::printParams()
|
||||
{
|
||||
int col_p = 30;
|
||||
int col_d = 50;
|
||||
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
std::vector<string> keysVector;
|
||||
std::string buf;
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
keysVector = split_string(it->first, "|");
|
||||
for (size_t i = 0; i < keysVector.size(); i++) keysVector[i] = del_space(keysVector[i]);
|
||||
|
||||
cout << " ";
|
||||
buf = "";
|
||||
if (keysVector[0] != "")
|
||||
{
|
||||
buf = "-" + keysVector[0];
|
||||
if (keysVector[1] != "") buf += ", --" + keysVector[1];
|
||||
}
|
||||
else if (keysVector[1] != "") buf += "--" + keysVector[1];
|
||||
if (del_space(it->second[0]) != "") buf += "=[" + del_space(it->second[0]) + "]";
|
||||
|
||||
cout << setw(col_p-2) << left << buf;
|
||||
|
||||
if ((int)buf.length() > col_p-2)
|
||||
{
|
||||
cout << endl << " ";
|
||||
cout << setw(col_p-2) << left << " ";
|
||||
}
|
||||
|
||||
buf = "";
|
||||
if (del_space(it->second[1]) != "") buf += del_space(it->second[1]);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
bool tr = ((int)buf.length() > col_d-2) ? true: false;
|
||||
std::string::size_type pos = 0;
|
||||
|
||||
if (tr)
|
||||
{
|
||||
pos = buf.find_first_of(' ');
|
||||
for(;;)
|
||||
{
|
||||
if (buf.find_first_of(' ', pos + 1 ) < (std::string::size_type)(col_d-2) &&
|
||||
buf.find_first_of(' ', pos + 1 ) != std::string::npos)
|
||||
pos = buf.find_first_of(' ', pos + 1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
cout << setw(col_d-2) << left << buf.substr(0, pos) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << setw(col_d-2) << left << buf<< endl;
|
||||
break;
|
||||
}
|
||||
|
||||
buf.erase(0, pos);
|
||||
cout << " ";
|
||||
cout << setw(col_p-2) << left << " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
bool CommandLineParser::get<bool>(const std::string& name, bool space_delete)
|
||||
{
|
||||
std::string str_buf = getString(name);
|
||||
|
||||
if (space_delete && str_buf != "")
|
||||
{
|
||||
str_buf = del_space(str_buf);
|
||||
}
|
||||
|
||||
if (str_buf == "true")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
template<>
|
||||
std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete)
|
||||
{
|
||||
if (space_delete)
|
||||
{
|
||||
return del_space(str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
template<>
|
||||
int CommandLineParser::analyzeValue<int>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<int>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<unsigned int>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<uint64>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
float CommandLineParser::analyzeValue<float>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<float>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
double CommandLineParser::analyzeValue<double>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<double>(str);
|
||||
}
|
406
modules/core/src/command_line_parser.cpp
Normal file
406
modules/core/src/command_line_parser.cpp
Normal file
@ -0,0 +1,406 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
bool cmp_params(const CommandLineParserParams & p1, const CommandLineParserParams & p2)
|
||||
{
|
||||
if (p1.number > p2.number)
|
||||
return false;
|
||||
|
||||
if (p1.number == -1 && p2.number == -1)
|
||||
{
|
||||
if (p1.keys[0].compare(p2.keys[0]) > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, const char * const argv[], const std::string keys)
|
||||
{
|
||||
// path to application
|
||||
size_t pos_s = std::string(argv[0]).find_last_of("/\\");
|
||||
if (pos_s == std::string::npos)
|
||||
{
|
||||
path_to_app = "";
|
||||
app_name = std::string(argv[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
path_to_app = std::string(argv[0]).substr(0, pos_s);
|
||||
app_name = std::string(argv[0]).substr(pos_s + 1, std::string(argv[0]).length() - pos_s);
|
||||
}
|
||||
|
||||
error = false;
|
||||
error_message = "";
|
||||
|
||||
// parse keys
|
||||
std::vector<std::string> k = split_range_string(keys, '{', '}');
|
||||
|
||||
int jj = 0;
|
||||
for (size_t i = 0; i < k.size(); i++)
|
||||
{
|
||||
std::vector<std::string> l = split_string(k[i], '|', true);
|
||||
CommandLineParserParams p;
|
||||
p.keys = split_string(l[0]);
|
||||
p.def_value = l[1];
|
||||
p.help_message = cat_string(l[2]);
|
||||
p.number = -1;
|
||||
if (p.keys[0][0] == '@')
|
||||
{
|
||||
p.number = jj;
|
||||
jj++;
|
||||
}
|
||||
|
||||
data.push_back(p);
|
||||
}
|
||||
|
||||
// parse argv
|
||||
jj = 0;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
std::string s = std::string(argv[i]);
|
||||
|
||||
if (s.find('=') != std::string::npos && s.find('=') < s.length())
|
||||
{
|
||||
std::vector<std::string> k_v = split_string(s, '=', true);
|
||||
for (int h = 0; h < 2; h++)
|
||||
{
|
||||
if (k_v[0][0] == '-')
|
||||
k_v[0] = k_v[0].substr(1, k_v[0].length() -1);
|
||||
}
|
||||
apply_params(k_v[0], k_v[1]);
|
||||
}
|
||||
else if (s.length() > 1 && s[0] == '-')
|
||||
{
|
||||
for (int h = 0; h < 2; h++)
|
||||
{
|
||||
if (s[0] == '-')
|
||||
s = s.substr(1, s.length() - 1);
|
||||
}
|
||||
apply_params(s, "true");
|
||||
}
|
||||
else if (s[0] != '-')
|
||||
{
|
||||
apply_params(jj, s);
|
||||
jj++;
|
||||
}
|
||||
}
|
||||
|
||||
sort_params();
|
||||
}
|
||||
|
||||
void CommandLineParser::about(std::string message)
|
||||
{
|
||||
about_message = message;
|
||||
}
|
||||
|
||||
void CommandLineParser::apply_params(std::string key, std::string value)
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
for (size_t k = 0; k < data[i].keys.size(); k++)
|
||||
{
|
||||
if (key.compare(data[i].keys[k]) == 0)
|
||||
{
|
||||
data[i].def_value = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::apply_params(int i, std::string value)
|
||||
{
|
||||
for (size_t j = 0; j < data.size(); j++)
|
||||
{
|
||||
if (data[j].number == i)
|
||||
{
|
||||
data[j].def_value = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::sort_params()
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
sort(data[i].keys.begin(), data[i].keys.end());
|
||||
}
|
||||
|
||||
sort (data.begin(), data.end(), cmp_params);
|
||||
}
|
||||
|
||||
std::string CommandLineParser::cat_string(std::string str)
|
||||
{
|
||||
while (!str.empty() && str[0] == ' ')
|
||||
{
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
||||
while (!str.empty() && str[str.length() - 1] == ' ')
|
||||
{
|
||||
str = str.substr(0, str.length() - 1);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string CommandLineParser::getPathToApplication()
|
||||
{
|
||||
return path_to_app;
|
||||
}
|
||||
|
||||
bool CommandLineParser::has(const std::string& name)
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < data[i].keys.size(); j++)
|
||||
{
|
||||
if (name.compare(data[i].keys[j]) == 0 && std::string("true").compare(data[i].def_value) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CommandLineParser::check()
|
||||
{
|
||||
return error == false;
|
||||
}
|
||||
|
||||
void CommandLineParser::printErrors()
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
std::cout << std::endl << "ERRORS:" << std::endl << error_message << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::printMessage()
|
||||
{
|
||||
if (about_message != "")
|
||||
std::cout << about_message << std::endl;
|
||||
|
||||
std::cout << "Usage: " << app_name << " [params] ";
|
||||
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
if (data[i].number > -1)
|
||||
{
|
||||
std::string name = data[i].keys[0].substr(1, data[i].keys[0].length() - 1);
|
||||
std::cout << name << " ";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << std::endl;
|
||||
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
if (data[i].number == -1)
|
||||
{
|
||||
std::cout << "\t";
|
||||
for (size_t j = 0; j < data[i].keys.size(); j++)
|
||||
{
|
||||
std::string k = data[i].keys[j];
|
||||
if (k.length() > 1)
|
||||
{
|
||||
std::cout << "--";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "-";
|
||||
}
|
||||
std::cout << k;
|
||||
|
||||
if (j != data[i].keys.size() - 1)
|
||||
{
|
||||
std::cout << ", ";
|
||||
}
|
||||
}
|
||||
std::string dv = cat_string(data[i].def_value);
|
||||
if (dv.compare("") != 0)
|
||||
{
|
||||
std::cout << " (value:" << dv << ")";
|
||||
}
|
||||
std::cout << std::endl << "\t\t" << data[i].help_message << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
if (data[i].number != -1)
|
||||
{
|
||||
std::cout << "\t";
|
||||
std::string k = data[i].keys[0];
|
||||
k = k.substr(1, k.length() - 1);
|
||||
|
||||
std::cout << k;
|
||||
|
||||
std::string dv = cat_string(data[i].def_value);
|
||||
if (dv.compare("") != 0)
|
||||
{
|
||||
std::cout << " (value:" << dv << ")";
|
||||
}
|
||||
std::cout << std::endl << "\t\t" << data[i].help_message << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> CommandLineParser::split_range_string(std::string str, char fs, char ss)
|
||||
{
|
||||
std::vector<std::string> vec;
|
||||
std::string word = "";
|
||||
bool begin = false;
|
||||
|
||||
while (!str.empty())
|
||||
{
|
||||
if (str[0] == fs)
|
||||
{
|
||||
if (begin == true)
|
||||
{
|
||||
CV_Error(CV_StsParseError,
|
||||
std::string("error in split_range_string(")
|
||||
+ str
|
||||
+ std::string(", ")
|
||||
+ std::string(1, fs)
|
||||
+ std::string(", ")
|
||||
+ std::string(1, ss)
|
||||
+ std::string(")")
|
||||
);
|
||||
}
|
||||
begin = true;
|
||||
word = "";
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
||||
if (str[0] == ss)
|
||||
{
|
||||
if (begin == false)
|
||||
{
|
||||
CV_Error(CV_StsParseError,
|
||||
std::string("error in split_range_string(")
|
||||
+ str
|
||||
+ std::string(", ")
|
||||
+ std::string(1, fs)
|
||||
+ std::string(", ")
|
||||
+ std::string(1, ss)
|
||||
+ std::string(")")
|
||||
);
|
||||
}
|
||||
begin = false;
|
||||
vec.push_back(word);
|
||||
}
|
||||
|
||||
if (begin == true)
|
||||
{
|
||||
word += str[0];
|
||||
}
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
||||
if (begin == true)
|
||||
{
|
||||
CV_Error(CV_StsParseError,
|
||||
std::string("error in split_range_string(")
|
||||
+ str
|
||||
+ std::string(", ")
|
||||
+ std::string(1, fs)
|
||||
+ std::string(", ")
|
||||
+ std::string(1, ss)
|
||||
+ std::string(")")
|
||||
);
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::vector<std::string> CommandLineParser::split_string(std::string str, char symbol, bool create_empty_item)
|
||||
{
|
||||
std::vector<std::string> vec;
|
||||
std::string word = "";
|
||||
|
||||
while (!str.empty())
|
||||
{
|
||||
if (str[0] == symbol)
|
||||
{
|
||||
if (!word.empty() || create_empty_item)
|
||||
{
|
||||
vec.push_back(word);
|
||||
word = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
word += str[0];
|
||||
}
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
||||
if (word != "" || create_empty_item)
|
||||
{
|
||||
vec.push_back(word);
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
#undef clp_get
|
||||
#define clp_get(T) template<> T CommandLineParser::get<T>(const std::string& name, bool space_delete);
|
||||
|
||||
clp_get(int)
|
||||
clp_get(unsigned int)
|
||||
clp_get(long)
|
||||
clp_get(unsigned long)
|
||||
clp_get(long long)
|
||||
clp_get(unsigned long long)
|
||||
clp_get(size_t)
|
||||
clp_get(float)
|
||||
clp_get(double)
|
||||
clp_get(uint64)
|
||||
clp_get(int64)
|
||||
clp_get(std::string)
|
||||
|
||||
#undef clp_from_str
|
||||
#define clp_from_str(T) template<> T from_str<T>(const std::string & str);
|
||||
|
||||
clp_from_str(int)
|
||||
clp_from_str(unsigned int)
|
||||
clp_from_str(long)
|
||||
clp_from_str(unsigned long)
|
||||
clp_from_str(long long)
|
||||
clp_from_str(unsigned long long)
|
||||
clp_from_str(size_t)
|
||||
clp_from_str(uint64)
|
||||
clp_from_str(int64)
|
||||
clp_from_str(float)
|
||||
clp_from_str(double)
|
||||
|
||||
template<>
|
||||
std::string from_str(const std::string & str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
#undef clp_type_name
|
||||
#define clp_type_name(type, name) template<> std::string get_type_name<type>() { return std::string(name);}
|
||||
|
||||
clp_type_name(int, "int")
|
||||
clp_type_name(unsigned int, "unsigned int")
|
||||
clp_type_name(long, "long")
|
||||
clp_type_name(long long, "long long")
|
||||
clp_type_name(unsigned long long, "unsigned long long")
|
||||
clp_type_name(size_t, "size_t")
|
||||
clp_type_name(float, "float")
|
||||
clp_type_name(double, "double")
|
||||
|
||||
}
|
@ -73,20 +73,32 @@ void printCudaInfo()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CommandLineParser cmd(argc, (const char**) argv,
|
||||
"{ print_info_only | print_info_only | false | Print information about system and exit }"
|
||||
"{ device | device | 0 | Device on which tests will be executed }"
|
||||
"{ cpu | cpu | false | Run tests on cpu }"
|
||||
);
|
||||
const std::string keys =
|
||||
"{ h help ? | | Print help}"
|
||||
"{ i info | | Print information about system and exit }"
|
||||
"{ device | 0 | Device on which tests will be executed }"
|
||||
"{ cpu | | Run tests on cpu }"
|
||||
;
|
||||
|
||||
CommandLineParser cmd(argc, (const char**) argv, keys);
|
||||
|
||||
if (cmd.has("help"))
|
||||
{
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
printOsInfo();
|
||||
printCudaInfo();
|
||||
|
||||
if (cmd.get<bool>("print_info_only"))
|
||||
|
||||
if (cmd.has("info"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
bool cpu = cmd.get<bool>("cpu");
|
||||
bool cpu = cmd.has("cpu");
|
||||
#ifndef HAVE_CUDA
|
||||
cpu = true;
|
||||
#endif
|
||||
|
@ -118,17 +118,28 @@ int main(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandLineParser cmd(argc, (const char**)argv,
|
||||
"{ print_info_only | print_info_only | false | Print information about system and exit }"
|
||||
"{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }"
|
||||
"{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"
|
||||
);
|
||||
const std::string keys =
|
||||
"{ h help ? | | Print help}"
|
||||
"{ i info | | Print information about system and exit }"
|
||||
"{ device | -1 | Device on which tests will be executed (-1 means all devices) }"
|
||||
"{ nvtest_output_level | compact | NVidia test verbosity level (none, compact, full) }"
|
||||
;
|
||||
|
||||
CommandLineParser cmd(argc, (const char**)argv, keys);
|
||||
|
||||
if (cmd.has("help"))
|
||||
{
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
printOsInfo();
|
||||
printCudaInfo();
|
||||
|
||||
if (cmd.get<bool>("print_info_only"))
|
||||
if (cmd.has("info"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
if (device < 0)
|
||||
|
@ -10,24 +10,23 @@ int64 TestBase::timeLimitDefault = 0;
|
||||
unsigned int TestBase::iterationsLimitDefault = (unsigned int)(-1);
|
||||
int64 TestBase::_timeadjustment = 0;
|
||||
|
||||
const char *command_line_keys =
|
||||
{
|
||||
"{ |perf_max_outliers |8 |percent of allowed outliers}"
|
||||
"{ |perf_min_samples |10 |minimal required numer of samples}"
|
||||
"{ |perf_force_samples |100 |force set maximum number of samples for all tests}"
|
||||
"{ |perf_seed |809564 |seed for random numbers generator}"
|
||||
"{ |perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
|
||||
"{ |perf_write_sanity |false |allow to create new records for sanity checks}"
|
||||
const std::string command_line_keys =
|
||||
"{ perf_max_outliers |8 |percent of allowed outliers}"
|
||||
"{ perf_min_samples |10 |minimal required numer of samples}"
|
||||
"{ perf_force_samples |100 |force set maximum number of samples for all tests}"
|
||||
"{ perf_seed |809564 |seed for random numbers generator}"
|
||||
"{ perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
|
||||
"{ perf_write_sanity | |allow to create new records for sanity checks}"
|
||||
#ifdef ANDROID
|
||||
"{ |perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
|
||||
"{ |perf_affinity_mask |0 |set affinity mask for the main thread}"
|
||||
"{ |perf_log_power_checkpoints |false |additional xml logging for power measurement}"
|
||||
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
|
||||
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
|
||||
"{ perf_log_power_checkpoints | |additional xml logging for power measurement}"
|
||||
#else
|
||||
"{ |perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
|
||||
"{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
|
||||
#endif
|
||||
"{ |perf_max_deviation |1.0 |}"
|
||||
"{h |help |false |}"
|
||||
};
|
||||
"{ perf_max_deviation |1.0 |}"
|
||||
"{ help h | |print help info}"
|
||||
;
|
||||
|
||||
static double param_max_outliers;
|
||||
static double param_max_deviation;
|
||||
@ -526,23 +525,28 @@ performance_metrics::performance_metrics()
|
||||
void TestBase::Init(int argc, const char* const argv[])
|
||||
{
|
||||
cv::CommandLineParser args(argc, argv, command_line_keys);
|
||||
param_max_outliers = std::min(100., std::max(0., args.get<double>("perf_max_outliers")));
|
||||
param_min_samples = std::max(1u, args.get<unsigned int>("perf_min_samples"));
|
||||
if (args.has("help"))
|
||||
{
|
||||
args.printMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
param_max_outliers = std::min(100., std::max(0., args.get<double>("perf_max_outliers")));
|
||||
param_min_samples = std::max(1u, args.get<unsigned int>("perf_min_samples"));
|
||||
param_max_deviation = std::max(0., args.get<double>("perf_max_deviation"));
|
||||
param_seed = args.get<uint64>("perf_seed");
|
||||
param_time_limit = std::max(0., args.get<double>("perf_time_limit"));
|
||||
param_seed = args.get<unsigned long long>("perf_seed");
|
||||
param_time_limit = std::max(0., args.get<double>("perf_time_limit"));
|
||||
param_force_samples = args.get<unsigned int>("perf_force_samples");
|
||||
param_write_sanity = args.get<bool>("perf_write_sanity");
|
||||
param_write_sanity = args.has("perf_write_sanity");
|
||||
param_tbb_nthreads = args.get<int>("perf_tbb_nthreads");
|
||||
#ifdef ANDROID
|
||||
param_affinity_mask = args.get<int>("perf_affinity_mask");
|
||||
log_power_checkpoints = args.get<bool>("perf_log_power_checkpoints");
|
||||
param_affinity_mask = args.get<int>("perf_affinity_mask");
|
||||
log_power_checkpoints = args.has("perf_log_power_checkpoints");
|
||||
#endif
|
||||
|
||||
if (args.get<bool>("help"))
|
||||
if (!args.check())
|
||||
{
|
||||
args.printParams();
|
||||
printf("\n\n");
|
||||
args.printErrors();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,9 @@ static void help()
|
||||
//
|
||||
const char *keys =
|
||||
{
|
||||
"{nf|nframes |300 |frames number}"
|
||||
"{c |camera |false |use the camera or not}"
|
||||
"{mf|movie_file|tree.avi |used movie video file}"
|
||||
"{nf nframes |300 |frames number}"
|
||||
"{c camera |false |use the camera or not}"
|
||||
"{mf movie_file|tree.avi |used movie video file}"
|
||||
};
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
@ -82,7 +82,7 @@ int main(int argc, const char** argv)
|
||||
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
int nframesToLearnBG = parser.get<int>("nf");
|
||||
bool useCamera = parser.get<bool>("c");
|
||||
bool useCamera = parser.has("c");
|
||||
string filename = parser.get<string>("mf");
|
||||
IplImage* rawImage = 0, *yuvImage = 0; //yuvImage is for codebook method
|
||||
IplImage *ImaskCodeBook = 0,*ImaskCodeBookCC = 0;
|
||||
|
@ -18,8 +18,8 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{c |camera |true | use camera or not}"
|
||||
"{fn|file_name|tree.avi | movie file }"
|
||||
"{c camera | | use camera or not}"
|
||||
"{fn file_name|tree.avi | movie file }"
|
||||
};
|
||||
|
||||
//this is a sample for foreground detection functions
|
||||
@ -28,7 +28,7 @@ int main(int argc, const char** argv)
|
||||
help();
|
||||
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
bool useCamera = parser.get<bool>("camera");
|
||||
bool useCamera = parser.has("camera");
|
||||
string file = parser.get<string>("file_name");
|
||||
VideoCapture cap;
|
||||
bool update_bg_model = true;
|
||||
@ -37,7 +37,8 @@ int main(int argc, const char** argv)
|
||||
cap.open(0);
|
||||
else
|
||||
cap.open(file.c_str());
|
||||
parser.printParams();
|
||||
|
||||
parser.printMessage();
|
||||
|
||||
if( !cap.isOpened() )
|
||||
{
|
||||
|
@ -53,8 +53,8 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| |box.png |the first image}"
|
||||
"{2| |box_in_scene.png|the second image}"
|
||||
"{@first_image | box.png | the first image}"
|
||||
"{@second_image | box_in_scene.png | the second image}"
|
||||
};
|
||||
|
||||
int main(int argc, const char ** argv)
|
||||
@ -62,8 +62,8 @@ int main(int argc, const char ** argv)
|
||||
|
||||
help();
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
string im1_name = parser.get<string>("1");
|
||||
string im2_name = parser.get<string>("2");
|
||||
string im1_name = parser.get<string>(1);
|
||||
string im2_name = parser.get<string>(2);
|
||||
|
||||
Mat im1 = imread(im1_name, CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat im2 = imread(im2_name, CV_LOAD_IMAGE_GRAYSCALE);
|
||||
@ -72,7 +72,7 @@ int main(int argc, const char ** argv)
|
||||
{
|
||||
cout << "could not open one of the images..." << endl;
|
||||
cout << "the cmd parameters have next current value: " << endl;
|
||||
parser.printParams();
|
||||
parser.printMessage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| | 0 | camera number}"
|
||||
"{@camera_number| 0 | camera number}"
|
||||
};
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
@ -77,7 +77,7 @@ int main( int argc, const char** argv )
|
||||
float hranges[] = {0,180};
|
||||
const float* phranges = hranges;
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
int camNum = parser.get<int>("1");
|
||||
int camNum = parser.get<int>(1);
|
||||
|
||||
cap.open(camNum);
|
||||
|
||||
@ -86,7 +86,7 @@ int main( int argc, const char** argv )
|
||||
help();
|
||||
cout << "***Could not initialize capturing...***\n";
|
||||
cout << "Current parameter's value: \n";
|
||||
parser.printParams();
|
||||
parser.printMessage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| |logo_in_clutter.png|image edge map }"
|
||||
"{2| |logo.png |template edge map}"
|
||||
"{@logo1 |logo_in_clutter.png |image edge map }"
|
||||
"{@logo2 |logo.png |template edge map}"
|
||||
};
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
@ -29,8 +29,8 @@ int main( int argc, const char** argv )
|
||||
help();
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
|
||||
string image = parser.get<string>("1");
|
||||
string templ = parser.get<string>("2");
|
||||
string image = parser.get<string>(1);
|
||||
string templ = parser.get<string>(2);
|
||||
Mat img = imread(image.c_str(), 0);
|
||||
Mat tpl = imread(templ.c_str(), 0);
|
||||
|
||||
|
@ -45,14 +45,14 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| |stuff.jpg|image for converting to a grayscale}"
|
||||
"{@image |stuff.jpg|image for converting to a grayscale}"
|
||||
};
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
{
|
||||
help();
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
string inputImage = parser.get<string>("1");
|
||||
string inputImage = parser.get<string>(1);
|
||||
img = imread(inputImage.c_str(), 0);
|
||||
|
||||
if(img.empty())
|
||||
|
@ -62,7 +62,7 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| |baboon.jpg|input image file}"
|
||||
"{@image|baboon.jpg|input image file}"
|
||||
};
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
@ -70,7 +70,7 @@ int main( int argc, const char** argv )
|
||||
help();
|
||||
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
string inputImage = parser.get<string>("1");
|
||||
string inputImage = parser.get<string>(1);
|
||||
|
||||
// Load the source image. HighGUI use.
|
||||
image = imread( inputImage, 0 );
|
||||
|
@ -17,14 +17,14 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| |lena.jpg|input image file}"
|
||||
"{@image|lena.jpg|input image file}"
|
||||
};
|
||||
|
||||
int main(int argc, const char ** argv)
|
||||
{
|
||||
help();
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
string filename = parser.get<string>("1");
|
||||
string filename = parser.get<string>(1);
|
||||
|
||||
Mat img = imread(filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
if( img.empty() )
|
||||
|
@ -104,14 +104,14 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| |stuff.jpg|input image file}"
|
||||
"{@image |stuff.jpg|input image file}"
|
||||
};
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
{
|
||||
help();
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
string filename = parser.get<string>("1");
|
||||
string filename = parser.get<string>(1);
|
||||
gray = imread(filename.c_str(), 0);
|
||||
if(gray.empty())
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ static void help()
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{1| |fruits.jpg|input image name}"
|
||||
"{@image |fruits.jpg|input image name}"
|
||||
};
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
@ -39,7 +39,7 @@ int main( int argc, const char** argv )
|
||||
help();
|
||||
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
string filename = parser.get<string>("1");
|
||||
string filename = parser.get<string>(1);
|
||||
|
||||
image = imread(filename, 1);
|
||||
if(image.empty())
|
||||
|
@ -3,19 +3,23 @@
|
||||
|
||||
const char* keys =
|
||||
{
|
||||
"{ b |build |false | print complete build info }"
|
||||
"{ h |help |false | print this help }"
|
||||
"{ b build | | print complete build info }"
|
||||
"{ h help | | print this help }"
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
cv::CommandLineParser parser(argc, argv, keys);
|
||||
|
||||
if (parser.get<bool>("help"))
|
||||
if (parser.has("help"))
|
||||
{
|
||||
parser.printParams();
|
||||
parser.printMessage();
|
||||
}
|
||||
else if (parser.get<bool>("build"))
|
||||
else if (!parser.check())
|
||||
{
|
||||
parser.printErrors();
|
||||
}
|
||||
else if (parser.has("build"))
|
||||
{
|
||||
std::cout << cv::getBuildInformation() << std::endl;
|
||||
}
|
||||
@ -25,4 +29,4 @@ int main(int argc, const char* argv[])
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -64,20 +64,19 @@ static void openGlDrawCallback(void* userdata)
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
const char* keys =
|
||||
"{ l | left | | left image file name }"
|
||||
"{ r | right | | right image file name }"
|
||||
"{ i | intrinsic | | intrinsic camera parameters file name }"
|
||||
"{ e | extrinsic | | extrinsic camera parameters file name }"
|
||||
"{ d | ndisp | 256 | number of disparities }"
|
||||
"{ s | scale | 1.0 | scale factor for point cloud }"
|
||||
"{ h | help | false | print help message }";
|
||||
"{ l left | | left image file name }"
|
||||
"{ r right | | right image file name }"
|
||||
"{ i intrinsic | | intrinsic camera parameters file name }"
|
||||
"{ e extrinsic | | extrinsic camera parameters file name }"
|
||||
"{ d ndisp | 256 | number of disparities }"
|
||||
"{ s scale | 1.0 | scale factor for point cloud }"
|
||||
"{ h help | | print help message }";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
if (cmd.has("help"))
|
||||
{
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -88,11 +87,18 @@ int main(int argc, const char* argv[])
|
||||
int ndisp = cmd.get<int>("ndisp");
|
||||
double scale = cmd.get<double>("scale");
|
||||
|
||||
if (!cmd.check())
|
||||
{
|
||||
cmd.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (left.empty() || right.empty())
|
||||
{
|
||||
cout << "Missed input images" << endl;
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -100,7 +106,7 @@ int main(int argc, const char* argv[])
|
||||
{
|
||||
cout << "Boss camera parameters must be specified" << endl;
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -281,56 +281,56 @@ int main(int argc, const char **argv)
|
||||
try
|
||||
{
|
||||
const char *keys =
|
||||
"{ 1 | | | | }"
|
||||
"{ m | model | affine | }"
|
||||
"{ lp | lin-prog-motion-est | no | }"
|
||||
"{ | subset | auto | }"
|
||||
"{ | thresh | auto | }"
|
||||
"{ | outlier-ratio | 0.5 | }"
|
||||
"{ | min-inlier-ratio | 0.1 | }"
|
||||
"{ | nkps | 1000 | }"
|
||||
"{ | extra-kps | 0 | }"
|
||||
"{ | local-outlier-rejection | no | }"
|
||||
"{ sm | save-motions | no | }"
|
||||
"{ lm | load-motions | no | }"
|
||||
"{ r | radius | 15 | }"
|
||||
"{ | stdev | auto | }"
|
||||
"{ lps | lin-prog-stab | no | }"
|
||||
"{ | lps-trim-ratio | auto | }"
|
||||
"{ | lps-w1 | 1 | }"
|
||||
"{ | lps-w2 | 10 | }"
|
||||
"{ | lps-w3 | 100 | }"
|
||||
"{ | lps-w4 | 100 | }"
|
||||
"{ | deblur | no | }"
|
||||
"{ | deblur-sens | 0.1 | }"
|
||||
"{ et | est-trim | yes | }"
|
||||
"{ t | trim-ratio | 0.1 | }"
|
||||
"{ ic | incl-constr | no | }"
|
||||
"{ bm | border-mode | replicate | }"
|
||||
"{ | mosaic | no | }"
|
||||
"{ ms | mosaic-stdev | 10.0 | }"
|
||||
"{ mi | motion-inpaint | no | }"
|
||||
"{ | mi-dist-thresh | 5.0 | }"
|
||||
"{ ci | color-inpaint | no | }"
|
||||
"{ | ci-radius | 2 | }"
|
||||
"{ ws | wobble-suppress | no | }"
|
||||
"{ | ws-period | 30 | }"
|
||||
"{ | ws-model | homography | }"
|
||||
"{ | ws-subset | auto | }"
|
||||
"{ | ws-thresh | auto | }"
|
||||
"{ | ws-outlier-ratio | 0.5 | }"
|
||||
"{ | ws-min-inlier-ratio | 0.1 | }"
|
||||
"{ | ws-nkps | 1000 | }"
|
||||
"{ | ws-extra-kps | 0 | }"
|
||||
"{ | ws-local-outlier-rejection | no | }"
|
||||
"{ | ws-lp | no | }"
|
||||
"{ sm2 | save-motions2 | no | }"
|
||||
"{ lm2 | load-motions2 | no | }"
|
||||
"{ gpu | | no }"
|
||||
"{ o | output | stabilized.avi | }"
|
||||
"{ | fps | auto | }"
|
||||
"{ q | quiet | false | }"
|
||||
"{ h | help | false | }";
|
||||
"{ @1 | | }"
|
||||
"{ m model | affine | }"
|
||||
"{ lp lin-prog-motion-est | no | }"
|
||||
"{ subset | auto | }"
|
||||
"{ thresh | auto | }"
|
||||
"{ outlier-ratio | 0.5 | }"
|
||||
"{ min-inlier-ratio | 0.1 | }"
|
||||
"{ nkps | 1000 | }"
|
||||
"{ extra-kps | 0 | }"
|
||||
"{ local-outlier-rejection | no | }"
|
||||
"{ sm save-motions | no | }"
|
||||
"{ lm load-motions | no | }"
|
||||
"{ r radius | 15 | }"
|
||||
"{ stdev | auto | }"
|
||||
"{ lps lin-prog-stab | no | }"
|
||||
"{ lps-trim-ratio | auto | }"
|
||||
"{ lps-w1 | 1 | }"
|
||||
"{ lps-w2 | 10 | }"
|
||||
"{ lps-w3 | 100 | }"
|
||||
"{ lps-w4 | 100 | }"
|
||||
"{ deblur | no | }"
|
||||
"{ deblur-sens | 0.1 | }"
|
||||
"{ et est-trim | yes | }"
|
||||
"{ t trim-ratio | 0.1 | }"
|
||||
"{ ic incl-constr | no | }"
|
||||
"{ bm border-mode | replicate | }"
|
||||
"{ mosaic | no | }"
|
||||
"{ ms mosaic-stdev | 10.0 | }"
|
||||
"{ mi motion-inpaint | no | }"
|
||||
"{ mi-dist-thresh | 5.0 | }"
|
||||
"{ ci color-inpaint | no | }"
|
||||
"{ ci-radius | 2 | }"
|
||||
"{ ws wobble-suppress | no | }"
|
||||
"{ ws-period | 30 | }"
|
||||
"{ ws-model | homography | }"
|
||||
"{ ws-subset | auto | }"
|
||||
"{ ws-thresh | auto | }"
|
||||
"{ ws-outlier-ratio | 0.5 | }"
|
||||
"{ ws-min-inlier-ratio | 0.1 | }"
|
||||
"{ ws-nkps | 1000 | }"
|
||||
"{ ws-extra-kps | 0 | }"
|
||||
"{ ws-local-outlier-rejection | no | }"
|
||||
"{ ws-lp | no | }"
|
||||
"{ sm2 save-motions2 | no | }"
|
||||
"{ lm2 load-motions2 | no | }"
|
||||
"{ gpu | no | }"
|
||||
"{ o output | stabilized.avi | }"
|
||||
"{ fps | auto | }"
|
||||
"{ q quiet | | }"
|
||||
"{ h help | | }";
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
// parse command arguments
|
||||
|
@ -21,20 +21,19 @@ enum Method
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
cv::CommandLineParser cmd(argc, argv,
|
||||
"{ c | camera | false | use camera }"
|
||||
"{ f | file | 768x576.avi | input video file }"
|
||||
"{ m | method | mog | method (fgd, mog, mog2, vibe, gmg) }"
|
||||
"{ h | help | false | print help message }");
|
||||
"{ c camera | | use camera }"
|
||||
"{ f file | 768x576.avi | input video file }"
|
||||
"{ m method | mog | method (fgd, mog, mog2, vibe, gmg) }"
|
||||
"{ h help | | print help message }");
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
if (cmd.has("help") || !cmd.check())
|
||||
{
|
||||
cout << "Usage : bgfg_segm [options]" << endl;
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
cmd.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool useCamera = cmd.get<bool>("camera");
|
||||
bool useCamera = cmd.has("camera");
|
||||
string file = cmd.get<string>("file");
|
||||
string method = cmd.get<string>("method");
|
||||
|
||||
|
@ -25,24 +25,23 @@ int main(int argc, const char* argv[])
|
||||
try
|
||||
{
|
||||
const char* keys =
|
||||
"{ h | help | false | print help message }"
|
||||
"{ l | left | | specify left image }"
|
||||
"{ r | right | | specify right image }"
|
||||
"{ s | scale | 0.8 | set pyramid scale factor }"
|
||||
"{ a | alpha | 0.197 | set alpha }"
|
||||
"{ g | gamma | 50.0 | set gamma }"
|
||||
"{ i | inner | 10 | set number of inner iterations }"
|
||||
"{ o | outer | 77 | set number of outer iterations }"
|
||||
"{ si | solver | 10 | set number of basic solver iterations }"
|
||||
"{ t | time_step | 0.1 | set frame interpolation time step }";
|
||||
"{ h help | | print help message }"
|
||||
"{ l left | | specify left image }"
|
||||
"{ r right | | specify right image }"
|
||||
"{ s scale | 0.8 | set pyramid scale factor }"
|
||||
"{ a alpha | 0.197 | set alpha }"
|
||||
"{ g gamma | 50.0 | set gamma }"
|
||||
"{ i inner | 10 | set number of inner iterations }"
|
||||
"{ o outer | 77 | set number of outer iterations }"
|
||||
"{ si solver | 10 | set number of basic solver iterations }"
|
||||
"{ t time_step | 0.1 | set frame interpolation time step }";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
if (cmd.has("help") || !cmd.check())
|
||||
{
|
||||
cout << "Usage: brox_optical_flow [options]" << endl;
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
cmd.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -43,19 +43,19 @@ static void colorizeFlow(const Mat &u, const Mat &v, Mat &dst)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CommandLineParser cmd(argc, argv,
|
||||
"{ l | left | | specify left image }"
|
||||
"{ r | right | | specify right image }"
|
||||
"{ h | help | false | print help message }");
|
||||
"{ l left | | specify left image }"
|
||||
"{ r right | | specify right image }"
|
||||
"{ h help | | print help message }");
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
cmd.about("Farneback's optical flow sample.");
|
||||
if (cmd.has("help") || !cmd.check())
|
||||
{
|
||||
cout << "Farneback's optical flow sample.\n\n"
|
||||
<< "Usage: farneback_optical_flow_gpu [arguments]\n\n"
|
||||
<< "Arguments:\n";
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
cmd.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
string pathL = cmd.get<string>("left");
|
||||
string pathR = cmd.get<string>("right");
|
||||
if (pathL.empty()) cout << "Specify left image path\n";
|
||||
|
@ -165,22 +165,23 @@ int main(int argc, const char* argv[])
|
||||
redirectError(cvErrorCallback);
|
||||
|
||||
const char* keys =
|
||||
"{ h | help | false | print help message }"
|
||||
"{ f | filter | | filter for test }"
|
||||
"{ w | workdir | | set working directory }"
|
||||
"{ l | list | false | show all tests }"
|
||||
"{ d | device | 0 | device id }"
|
||||
"{ i | iters | 10 | iteration count }";
|
||||
"{ h help | | print help message }"
|
||||
"{ f filter | | filter for test }"
|
||||
"{ w workdir | | set working directory }"
|
||||
"{ l list | | show all tests }"
|
||||
"{ d device | 0 | device id }"
|
||||
"{ i iters | 10 | iteration count }";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
if (cmd.has("help") || !cmd.check())
|
||||
{
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
cmd.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
if (device < 0 || device >= num_devices)
|
||||
{
|
||||
@ -198,7 +199,7 @@ int main(int argc, const char* argv[])
|
||||
|
||||
string filter = cmd.get<string>("filter");
|
||||
string workdir = cmd.get<string>("workdir");
|
||||
bool list = cmd.get<bool>("list");
|
||||
bool list = cmd.has("list");
|
||||
int iters = cmd.get<int>("iters");
|
||||
|
||||
if (!filter.empty())
|
||||
|
@ -152,23 +152,22 @@ static void getFlowField(const Mat& u, const Mat& v, Mat& flowField)
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
const char* keys =
|
||||
"{ h | help | false | print help message }"
|
||||
"{ l | left | | specify left image }"
|
||||
"{ r | right | | specify right image }"
|
||||
"{ gray | gray | false | use grayscale sources [PyrLK Sparse] }"
|
||||
"{ win_size | win_size | 21 | specify windows size [PyrLK] }"
|
||||
"{ max_level | max_level | 3 | specify max level [PyrLK] }"
|
||||
"{ iters | iters | 30 | specify iterations count [PyrLK] }"
|
||||
"{ points | points | 4000 | specify points count [GoodFeatureToTrack] }"
|
||||
"{ min_dist | min_dist | 0 | specify minimal distance between points [GoodFeatureToTrack] }";
|
||||
"{ h help | | print help message }"
|
||||
"{ l left | | specify left image }"
|
||||
"{ r right | | specify right image }"
|
||||
"{ gray | | use grayscale sources [PyrLK Sparse] }"
|
||||
"{ win_size | 21 | specify windows size [PyrLK] }"
|
||||
"{ max_level | 3 | specify max level [PyrLK] }"
|
||||
"{ iters | 30 | specify iterations count [PyrLK] }"
|
||||
"{ points | 4000 | specify points count [GoodFeatureToTrack] }"
|
||||
"{ min_dist | 0 | specify minimal distance between points [GoodFeatureToTrack] }";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
if (cmd.has("help") || !cmd.check())
|
||||
{
|
||||
cout << "Usage: pyrlk_optical_flow [options]" << endl;
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
cmd.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -181,7 +180,7 @@ int main(int argc, const char* argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool useGray = cmd.get<bool>("gray");
|
||||
bool useGray = cmd.has("gray");
|
||||
int winSize = cmd.get<int>("win_size");
|
||||
int maxLevel = cmd.get<int>("max_level");
|
||||
int iters = cmd.get<int>("iters");
|
||||
|
Loading…
x
Reference in New Issue
Block a user