Commit 54a202b3 authored by AoD314's avatar AoD314

add new version of CommandLineParser. add empty docs

parent 6a112aa8
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
/*!
"\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
class CV_EXPORTS CommandLineParserParams
{
public:
std::string help_message;
std::string def_value;
std::vector<std::string> keys;
int number;
};
//! the default constructor
CommandLineParser(int argc, const char* const argv[], const char* key_map);
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;
//! 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 (ss.fail())
{
if (!has(name))
{
return _Tp();
}
std::string str = getString(name);
return analyzeValue<_Tp>(str, space_delete);
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);
}
//! print short name, full name, current value and help for all params
void printParams();
return value;
}
protected:
std::map<std::string, std::vector<std::string> > data;
std::string getString(const std::string& name);
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();
}
bool has(const std::string& keys);
class CV_EXPORTS CommandLineParser
{
public:
CommandLineParser(int argc, const char * const argv[], const std::string keys);
template<typename _Tp>
_Tp analyzeValue(const std::string& str, bool space_delete=false);
std::string getPathToApplication();
template<typename _Tp>
static _Tp getData(const std::string& str)
{
_Tp res;
std::stringstream s1(str);
s1 >> res;
return res;
}
template <typename T>
T get(const std::string& name, bool space_delete = true)
{
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();
}
template<typename _Tp>
_Tp fromStringNumber(const std::string& str);//the default conversion function for numbers
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);
template<> CV_EXPORTS
bool CommandLineParser::get<bool>(const std::string& name, bool space_delete);
bool check();
template<> CV_EXPORTS
std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete);
void about(std::string message);
template<> CV_EXPORTS
int CommandLineParser::analyzeValue<int>(const std::string& str, bool space_delete);
void printMessage();
void printErrors();
protected:
bool error;
std::string error_message;
std::string about_message;
template<> CV_EXPORTS
unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool space_delete);
std::string path_to_app;
std::string app_name;
template<> CV_EXPORTS
uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool space_delete);
std::vector<CommandLineParserParams> data;
template<> CV_EXPORTS
float CommandLineParser::analyzeValue<float>(const std::string& str, bool space_delete);
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<> CV_EXPORTS
double CommandLineParser::analyzeValue<double>(const std::string& str, bool space_delete);
void apply_params(std::string key, std::string value);
void apply_params(int i, std::string value);
void sort_params();
};
/////////////////////////////// Parallel Primitives //////////////////////////////////
......
This diff is collapsed.
This diff is collapsed.
......@@ -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;
}
\ No newline at end of file
}
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment