Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
54a202b3
Commit
54a202b3
authored
Sep 07, 2012
by
AoD314
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new version of CommandLineParser. add empty docs
parent
6a112aa8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
438 additions
and
270 deletions
+438
-270
command_line_parser.rst
modules/core/doc/command_line_parser.rst
+101
-0
core.rst
modules/core/doc/core.rst
+1
-0
core.hpp
modules/core/include/opencv2/core/core.hpp
+114
-84
cmdparser.cpp
modules/core/src/cmdparser.cpp
+0
-0
command_line_parser.cpp
modules/core/src/command_line_parser.cpp
+0
-0
main.cpp
modules/gpu/perf/main.cpp
+19
-7
main.cpp
modules/gpu/test/main.cpp
+17
-6
ts_perf.cpp
modules/ts/src/ts_perf.cpp
+25
-21
bgfg_codebook.cpp
samples/c/bgfg_codebook.cpp
+4
-4
bgfg_segm.cpp
samples/cpp/bgfg_segm.cpp
+5
-4
brief_match_test.cpp
samples/cpp/brief_match_test.cpp
+5
-5
camshiftdemo.cpp
samples/cpp/camshiftdemo.cpp
+3
-3
chamfer.cpp
samples/cpp/chamfer.cpp
+4
-4
connected_components.cpp
samples/cpp/connected_components.cpp
+2
-2
demhist.cpp
samples/cpp/demhist.cpp
+2
-2
dft.cpp
samples/cpp/dft.cpp
+2
-2
distrans.cpp
samples/cpp/distrans.cpp
+2
-2
edge.cpp
samples/cpp/edge.cpp
+2
-2
opencv_version.cpp
samples/cpp/opencv_version.cpp
+9
-5
point_cloud.cpp
samples/cpp/point_cloud.cpp
+18
-12
videostab.cpp
samples/cpp/videostab.cpp
+50
-50
bgfg_segm.cpp
samples/gpu/bgfg_segm.cpp
+8
-9
brox_optical_flow.cpp
samples/gpu/brox_optical_flow.cpp
+13
-14
farneback_optical_flow.cpp
samples/gpu/farneback_optical_flow.cpp
+8
-8
performance.cpp
samples/gpu/performance/performance.cpp
+11
-10
pyrlk_optical_flow.cpp
samples/gpu/pyrlk_optical_flow.cpp
+13
-14
No files found.
modules/core/doc/command_line_parser.rst
0 → 100644
View file @
54a202b3
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]
modules/core/doc/core.rst
View file @
54a202b3
...
@@ -6,6 +6,7 @@ core. The Core Functionality
...
@@ -6,6 +6,7 @@ core. The Core Functionality
:maxdepth: 2
:maxdepth: 2
basic_structures
basic_structures
command_line_parser
old_basic_structures
old_basic_structures
dynamic_structures
dynamic_structures
operations_on_arrays
operations_on_arrays
...
...
modules/core/include/opencv2/core/core.hpp
View file @
54a202b3
...
@@ -4505,113 +4505,143 @@ template<> struct ParamType<Algorithm>
...
@@ -4505,113 +4505,143 @@ template<> struct ParamType<Algorithm>
enum
{
type
=
Param
::
ALGORITHM
};
enum
{
type
=
Param
::
ALGORITHM
};
};
};
// The CommandLineParser class is designed for command line arguments parsing
/*!
class
CV_EXPORTS
CommandLineParserParams
"\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
:
public
:
std
::
string
help_message
;
std
::
string
def_value
;
std
::
vector
<
std
::
string
>
keys
;
int
number
;
};
//! the default constructor
template
<
typename
T
>
CommandLineParser
(
int
argc
,
const
char
*
const
argv
[],
const
char
*
key_map
);
std
::
string
get_type_name
()
{
return
"UNKNOW"
;
}
//! get parameter, you can choose: delete spaces in end and begin or not
bool
cmp_params
(
const
CommandLineParserParams
&
p1
,
const
CommandLineParserParams
&
p2
);
template
<
typename
_Tp
>
_Tp
get
(
const
std
::
string
&
name
,
bool
space_delete
=
true
)
template
<
typename
T
>
{
T
from_str
(
const
std
::
string
&
str
)
if
(
!
has
(
name
))
{
T
value
;
std
::
stringstream
ss
(
str
);
ss
>>
value
;
if
(
ss
.
fail
())
{
{
return
_Tp
();
std
::
string
err_msg
=
}
std
::
string
(
"can not convert: ["
)
std
::
string
str
=
getString
(
name
);
+
str
return
analyzeValue
<
_Tp
>
(
str
,
space_delete
);
+
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
return
value
;
void
printParams
();
}
template
<>
std
::
string
from_str
(
const
std
::
string
&
str
);
protected
:
template
<
typename
T
>
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>
>
data
;
std
::
string
to_str
(
T
value
)
std
::
string
getString
(
const
std
::
string
&
name
);
{
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
);
std
::
string
getPathToApplication
();
template
<
typename
_Tp
>
template
<
typename
T
>
_Tp
analyzeValue
(
const
std
::
string
&
str
,
bool
space_delete
=
false
);
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
>
template
<
typename
T
>
static
_Tp
getData
(
const
std
::
string
&
str
)
T
get
(
int
index
,
bool
space_delete
=
true
)
{
try
{
for
(
size_t
i
=
0
;
i
<
data
.
size
();
i
++
)
{
{
_Tp
res
;
if
(
data
[
i
].
number
==
index
-
1
)
std
::
stringstream
s1
(
str
);
{
s1
>>
res
;
std
::
string
v
=
data
[
i
].
def_value
;
return
res
;
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
();
}
}
template
<
typename
_Tp
>
bool
has
(
const
std
::
string
&
name
);
_Tp
fromStringNumber
(
const
std
::
string
&
str
);
//the default conversion function for numbers
};
bool
check
();
void
about
(
std
::
string
message
);
template
<>
CV_EXPORTS
void
printMessage
();
bool
CommandLineParser
::
get
<
bool
>
(
const
std
::
string
&
name
,
bool
space_delete
);
void
printErrors
(
);
template
<>
CV_EXPORTS
protected
:
std
::
string
CommandLineParser
::
analyzeValue
<
std
::
string
>
(
const
std
::
string
&
str
,
bool
space_delete
);
bool
error
;
std
::
string
error_message
;
std
::
string
about_message
;
template
<>
CV_EXPORTS
std
::
string
path_to_app
;
int
CommandLineParser
::
analyzeValue
<
int
>
(
const
std
::
string
&
str
,
bool
space_delete
)
;
std
::
string
app_name
;
template
<>
CV_EXPORTS
std
::
vector
<
CommandLineParserParams
>
data
;
unsigned
int
CommandLineParser
::
analyzeValue
<
unsigned
int
>
(
const
std
::
string
&
str
,
bool
space_delete
);
template
<>
CV_EXPORTS
std
::
vector
<
std
::
string
>
split_range_string
(
std
::
string
str
,
char
fs
,
char
ss
);
uint64
CommandLineParser
::
analyzeValue
<
uint64
>
(
const
std
::
string
&
str
,
bool
space_delete
);
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
void
apply_params
(
std
::
string
key
,
std
::
string
value
);
float
CommandLineParser
::
analyzeValue
<
float
>
(
const
std
::
string
&
str
,
bool
space_delet
e
);
void
apply_params
(
int
i
,
std
::
string
valu
e
);
template
<>
CV_EXPORTS
void
sort_params
();
double
CommandLineParser
::
analyzeValue
<
double
>
(
const
std
::
string
&
str
,
bool
space_delete
);
};
/////////////////////////////// Parallel Primitives //////////////////////////////////
/////////////////////////////// Parallel Primitives //////////////////////////////////
...
...
modules/core/src/cmdparser.cpp
deleted
100644 → 0
View file @
6a112aa8
This diff is collapsed.
Click to expand it.
modules/core/src/command_line_parser.cpp
0 → 100644
View file @
54a202b3
This diff is collapsed.
Click to expand it.
modules/gpu/perf/main.cpp
View file @
54a202b3
...
@@ -73,20 +73,32 @@ void printCudaInfo()
...
@@ -73,20 +73,32 @@ void printCudaInfo()
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
CommandLineParser
cmd
(
argc
,
(
const
char
**
)
argv
,
const
std
::
string
keys
=
"{ print_info_only | print_info_only | false | Print information about system and exit }"
"{ h help ? | | Print help}"
"{ device | device | 0 | Device on which tests will be executed }"
"{ i info | | Print information about system and exit }"
"{ cpu | cpu | false | Run tests on cpu }"
"{ 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
();
printOsInfo
();
printCudaInfo
();
printCudaInfo
();
if
(
cmd
.
get
<
bool
>
(
"print_info_only"
))
if
(
cmd
.
has
(
"info"
))
{
return
0
;
return
0
;
}
int
device
=
cmd
.
get
<
int
>
(
"device"
);
int
device
=
cmd
.
get
<
int
>
(
"device"
);
bool
cpu
=
cmd
.
get
<
bool
>
(
"cpu"
);
bool
cpu
=
cmd
.
has
(
"cpu"
);
#ifndef HAVE_CUDA
#ifndef HAVE_CUDA
cpu
=
true
;
cpu
=
true
;
#endif
#endif
...
...
modules/gpu/test/main.cpp
View file @
54a202b3
...
@@ -118,17 +118,28 @@ int main(int argc, char** argv)
...
@@ -118,17 +118,28 @@ int main(int argc, char** argv)
{
{
try
try
{
{
CommandLineParser
cmd
(
argc
,
(
const
char
**
)
argv
,
const
std
::
string
keys
=
"{ print_info_only | print_info_only | false | Print information about system and exit }"
"{ h help ? | | Print help}"
"{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }"
"{ i info | | Print information about system and exit }"
"{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"
"{ 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
();
printOsInfo
();
printCudaInfo
();
printCudaInfo
();
if
(
cmd
.
get
<
bool
>
(
"print_info_only"
))
if
(
cmd
.
has
(
"info"
))
{
return
0
;
return
0
;
}
int
device
=
cmd
.
get
<
int
>
(
"device"
);
int
device
=
cmd
.
get
<
int
>
(
"device"
);
if
(
device
<
0
)
if
(
device
<
0
)
...
...
modules/ts/src/ts_perf.cpp
View file @
54a202b3
...
@@ -10,24 +10,23 @@ int64 TestBase::timeLimitDefault = 0;
...
@@ -10,24 +10,23 @@ int64 TestBase::timeLimitDefault = 0;
unsigned
int
TestBase
::
iterationsLimitDefault
=
(
unsigned
int
)(
-
1
);
unsigned
int
TestBase
::
iterationsLimitDefault
=
(
unsigned
int
)(
-
1
);
int64
TestBase
::
_timeadjustment
=
0
;
int64
TestBase
::
_timeadjustment
=
0
;
const
char
*
command_line_keys
=
const
std
::
string
command_line_keys
=
{
"{ perf_max_outliers |8 |percent of allowed outliers}"
"{ |perf_max_outliers |8 |percent of allowed outliers}"
"{ perf_min_samples |10 |minimal required numer of samples}"
"{ |perf_min_samples |10 |minimal required numer of samples}"
"{ perf_force_samples |100 |force set maximum number of samples for all tests}"
"{ |perf_force_samples |100 |force set maximum number of samples for all tests}"
"{ perf_seed |809564 |seed for random numbers generator}"
"{ |perf_seed |809564 |seed for random numbers generator}"
"{ perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
"{ |perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
"{ perf_write_sanity | |allow to create new records for sanity checks}"
"{ |perf_write_sanity |false |allow to create new records for sanity checks}"
#ifdef ANDROID
#ifdef ANDROID
"{
|
perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
"{ 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_affinity_mask |0 |set affinity mask for the main thread}"
"{
|perf_log_power_checkpoints |false
|additional xml logging for power measurement}"
"{
perf_log_power_checkpoints |
|additional xml logging for power measurement}"
#else
#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
#endif
"{
|
perf_max_deviation |1.0 |}"
"{ perf_max_deviation |1.0 |}"
"{
h |help |false |
}"
"{
help h | |print help info
}"
}
;
;
static
double
param_max_outliers
;
static
double
param_max_outliers
;
static
double
param_max_deviation
;
static
double
param_max_deviation
;
...
@@ -526,23 +525,28 @@ performance_metrics::performance_metrics()
...
@@ -526,23 +525,28 @@ performance_metrics::performance_metrics()
void
TestBase
::
Init
(
int
argc
,
const
char
*
const
argv
[])
void
TestBase
::
Init
(
int
argc
,
const
char
*
const
argv
[])
{
{
cv
::
CommandLineParser
args
(
argc
,
argv
,
command_line_keys
);
cv
::
CommandLineParser
args
(
argc
,
argv
,
command_line_keys
);
if
(
args
.
has
(
"help"
))
{
args
.
printMessage
();
return
;
}
param_max_outliers
=
std
::
min
(
100.
,
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_max_outliers"
)));
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_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_max_deviation
=
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_max_deviation"
));
param_seed
=
args
.
get
<
uint64
>
(
"perf_seed"
);
param_seed
=
args
.
get
<
unsigned
long
long
>
(
"perf_seed"
);
param_time_limit
=
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_time_limit"
));
param_time_limit
=
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_time_limit"
));
param_force_samples
=
args
.
get
<
unsigned
int
>
(
"perf_force_samples"
);
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"
);
param_tbb_nthreads
=
args
.
get
<
int
>
(
"perf_tbb_nthreads"
);
#ifdef ANDROID
#ifdef ANDROID
param_affinity_mask
=
args
.
get
<
int
>
(
"perf_affinity_mask"
);
param_affinity_mask
=
args
.
get
<
int
>
(
"perf_affinity_mask"
);
log_power_checkpoints
=
args
.
get
<
bool
>
(
"perf_log_power_checkpoints"
);
log_power_checkpoints
=
args
.
has
(
"perf_log_power_checkpoints"
);
#endif
#endif
if
(
args
.
get
<
bool
>
(
"help"
))
if
(
!
args
.
check
(
))
{
{
args
.
printParams
();
args
.
printErrors
();
printf
(
"
\n\n
"
);
return
;
return
;
}
}
...
...
samples/c/bgfg_codebook.cpp
View file @
54a202b3
...
@@ -72,9 +72,9 @@ static void help()
...
@@ -72,9 +72,9 @@ static void help()
//
//
const
char
*
keys
=
const
char
*
keys
=
{
{
"{nf
|
nframes |300 |frames number}"
"{nf
nframes |300 |frames number}"
"{c
|
camera |false |use the camera or not}"
"{c
camera |false |use the camera or not}"
"{mf
|
movie_file|tree.avi |used movie video file}"
"{mf
movie_file|tree.avi |used movie video file}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
...
@@ -82,7 +82,7 @@ int main(int argc, const char** argv)
...
@@ -82,7 +82,7 @@ int main(int argc, const char** argv)
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
int
nframesToLearnBG
=
parser
.
get
<
int
>
(
"nf"
);
int
nframesToLearnBG
=
parser
.
get
<
int
>
(
"nf"
);
bool
useCamera
=
parser
.
get
<
bool
>
(
"c"
);
bool
useCamera
=
parser
.
has
(
"c"
);
string
filename
=
parser
.
get
<
string
>
(
"mf"
);
string
filename
=
parser
.
get
<
string
>
(
"mf"
);
IplImage
*
rawImage
=
0
,
*
yuvImage
=
0
;
//yuvImage is for codebook method
IplImage
*
rawImage
=
0
,
*
yuvImage
=
0
;
//yuvImage is for codebook method
IplImage
*
ImaskCodeBook
=
0
,
*
ImaskCodeBookCC
=
0
;
IplImage
*
ImaskCodeBook
=
0
,
*
ImaskCodeBookCC
=
0
;
...
...
samples/cpp/bgfg_segm.cpp
View file @
54a202b3
...
@@ -18,8 +18,8 @@ static void help()
...
@@ -18,8 +18,8 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{c |camera |true
| use camera or not}"
"{c camera |
| use camera or not}"
"{fn|file_name|tree.avi | movie file
}"
"{fn file_name|tree.avi | movie file
}"
};
};
//this is a sample for foreground detection functions
//this is a sample for foreground detection functions
...
@@ -28,7 +28,7 @@ int main(int argc, const char** argv)
...
@@ -28,7 +28,7 @@ int main(int argc, const char** argv)
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
bool
useCamera
=
parser
.
get
<
bool
>
(
"camera"
);
bool
useCamera
=
parser
.
has
(
"camera"
);
string
file
=
parser
.
get
<
string
>
(
"file_name"
);
string
file
=
parser
.
get
<
string
>
(
"file_name"
);
VideoCapture
cap
;
VideoCapture
cap
;
bool
update_bg_model
=
true
;
bool
update_bg_model
=
true
;
...
@@ -37,7 +37,8 @@ int main(int argc, const char** argv)
...
@@ -37,7 +37,8 @@ int main(int argc, const char** argv)
cap
.
open
(
0
);
cap
.
open
(
0
);
else
else
cap
.
open
(
file
.
c_str
());
cap
.
open
(
file
.
c_str
());
parser
.
printParams
();
parser
.
printMessage
();
if
(
!
cap
.
isOpened
()
)
if
(
!
cap
.
isOpened
()
)
{
{
...
...
samples/cpp/brief_match_test.cpp
View file @
54a202b3
...
@@ -53,8 +53,8 @@ static void help()
...
@@ -53,8 +53,8 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{1| |box.png |
the first image}"
"{@first_image | box.png |
the first image}"
"{2| |box_in_scene.png|
the second image}"
"{@second_image | box_in_scene.png |
the second image}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
...
@@ -62,8 +62,8 @@ int main(int argc, const char ** argv)
...
@@ -62,8 +62,8 @@ int main(int argc, const char ** argv)
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
im1_name
=
parser
.
get
<
string
>
(
"1"
);
string
im1_name
=
parser
.
get
<
string
>
(
1
);
string
im2_name
=
parser
.
get
<
string
>
(
"2"
);
string
im2_name
=
parser
.
get
<
string
>
(
2
);
Mat
im1
=
imread
(
im1_name
,
CV_LOAD_IMAGE_GRAYSCALE
);
Mat
im1
=
imread
(
im1_name
,
CV_LOAD_IMAGE_GRAYSCALE
);
Mat
im2
=
imread
(
im2_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)
...
@@ -72,7 +72,7 @@ int main(int argc, const char ** argv)
{
{
cout
<<
"could not open one of the images..."
<<
endl
;
cout
<<
"could not open one of the images..."
<<
endl
;
cout
<<
"the cmd parameters have next current value: "
<<
endl
;
cout
<<
"the cmd parameters have next current value: "
<<
endl
;
parser
.
printParams
();
parser
.
printMessage
();
return
1
;
return
1
;
}
}
...
...
samples/cpp/camshiftdemo.cpp
View file @
54a202b3
...
@@ -64,7 +64,7 @@ static void help()
...
@@ -64,7 +64,7 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{
1|
| 0 | camera number}"
"{
@camera_number
| 0 | camera number}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
...
@@ -77,7 +77,7 @@ int main( int argc, const char** argv )
...
@@ -77,7 +77,7 @@ int main( int argc, const char** argv )
float
hranges
[]
=
{
0
,
180
};
float
hranges
[]
=
{
0
,
180
};
const
float
*
phranges
=
hranges
;
const
float
*
phranges
=
hranges
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
int
camNum
=
parser
.
get
<
int
>
(
"1"
);
int
camNum
=
parser
.
get
<
int
>
(
1
);
cap
.
open
(
camNum
);
cap
.
open
(
camNum
);
...
@@ -86,7 +86,7 @@ int main( int argc, const char** argv )
...
@@ -86,7 +86,7 @@ int main( int argc, const char** argv )
help
();
help
();
cout
<<
"***Could not initialize capturing...***
\n
"
;
cout
<<
"***Could not initialize capturing...***
\n
"
;
cout
<<
"Current parameter's value:
\n
"
;
cout
<<
"Current parameter's value:
\n
"
;
parser
.
print
Params
();
parser
.
print
Message
();
return
-
1
;
return
-
1
;
}
}
...
...
samples/cpp/chamfer.cpp
View file @
54a202b3
...
@@ -19,8 +19,8 @@ static void help()
...
@@ -19,8 +19,8 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{
1| |logo_in_clutter.png
|image edge map }"
"{
@logo1 |logo_in_clutter.png
|image edge map }"
"{
2| |logo.png
|template edge map}"
"{
@logo2 |logo.png
|template edge map}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
...
@@ -29,8 +29,8 @@ int main( int argc, const char** argv )
...
@@ -29,8 +29,8 @@ int main( int argc, const char** argv )
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
image
=
parser
.
get
<
string
>
(
"1"
);
string
image
=
parser
.
get
<
string
>
(
1
);
string
templ
=
parser
.
get
<
string
>
(
"2"
);
string
templ
=
parser
.
get
<
string
>
(
2
);
Mat
img
=
imread
(
image
.
c_str
(),
0
);
Mat
img
=
imread
(
image
.
c_str
(),
0
);
Mat
tpl
=
imread
(
templ
.
c_str
(),
0
);
Mat
tpl
=
imread
(
templ
.
c_str
(),
0
);
...
...
samples/cpp/connected_components.cpp
View file @
54a202b3
...
@@ -45,14 +45,14 @@ static void help()
...
@@ -45,14 +45,14 @@ static void help()
const
char
*
keys
=
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
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
inputImage
=
parser
.
get
<
string
>
(
"1"
);
string
inputImage
=
parser
.
get
<
string
>
(
1
);
img
=
imread
(
inputImage
.
c_str
(),
0
);
img
=
imread
(
inputImage
.
c_str
(),
0
);
if
(
img
.
empty
())
if
(
img
.
empty
())
...
...
samples/cpp/demhist.cpp
View file @
54a202b3
...
@@ -62,7 +62,7 @@ static void help()
...
@@ -62,7 +62,7 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{
1|
|baboon.jpg|input image file}"
"{
@image
|baboon.jpg|input image file}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
...
@@ -70,7 +70,7 @@ int main( int argc, const char** argv )
...
@@ -70,7 +70,7 @@ int main( int argc, const char** argv )
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
inputImage
=
parser
.
get
<
string
>
(
"1"
);
string
inputImage
=
parser
.
get
<
string
>
(
1
);
// Load the source image. HighGUI use.
// Load the source image. HighGUI use.
image
=
imread
(
inputImage
,
0
);
image
=
imread
(
inputImage
,
0
);
...
...
samples/cpp/dft.cpp
View file @
54a202b3
...
@@ -17,14 +17,14 @@ static void help()
...
@@ -17,14 +17,14 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{
1|
|lena.jpg|input image file}"
"{
@image
|lena.jpg|input image file}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
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
);
Mat
img
=
imread
(
filename
.
c_str
(),
CV_LOAD_IMAGE_GRAYSCALE
);
if
(
img
.
empty
()
)
if
(
img
.
empty
()
)
...
...
samples/cpp/distrans.cpp
View file @
54a202b3
...
@@ -104,14 +104,14 @@ static void help()
...
@@ -104,14 +104,14 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{
1|
|stuff.jpg|input image file}"
"{
@image
|stuff.jpg|input image file}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
filename
=
parser
.
get
<
string
>
(
"1"
);
string
filename
=
parser
.
get
<
string
>
(
1
);
gray
=
imread
(
filename
.
c_str
(),
0
);
gray
=
imread
(
filename
.
c_str
(),
0
);
if
(
gray
.
empty
())
if
(
gray
.
empty
())
{
{
...
...
samples/cpp/edge.cpp
View file @
54a202b3
...
@@ -31,7 +31,7 @@ static void help()
...
@@ -31,7 +31,7 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{
1|
|fruits.jpg|input image name}"
"{
@image
|fruits.jpg|input image name}"
};
};
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
...
@@ -39,7 +39,7 @@ int main( int argc, const char** argv )
...
@@ -39,7 +39,7 @@ int main( int argc, const char** argv )
help
();
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
filename
=
parser
.
get
<
string
>
(
"1"
);
string
filename
=
parser
.
get
<
string
>
(
1
);
image
=
imread
(
filename
,
1
);
image
=
imread
(
filename
,
1
);
if
(
image
.
empty
())
if
(
image
.
empty
())
...
...
samples/cpp/opencv_version.cpp
View file @
54a202b3
...
@@ -3,19 +3,23 @@
...
@@ -3,19 +3,23 @@
const
char
*
keys
=
const
char
*
keys
=
{
{
"{ b
|build |false
| print complete build info }"
"{ b
build |
| print complete build info }"
"{ h
|help |false
| print this help }"
"{ h
help |
| print this help }"
};
};
int
main
(
int
argc
,
const
char
*
argv
[])
int
main
(
int
argc
,
const
char
*
argv
[])
{
{
cv
::
CommandLineParser
parser
(
argc
,
argv
,
keys
);
cv
::
CommandLineParser
parser
(
argc
,
argv
,
keys
);
if
(
parser
.
get
<
bool
>
(
"help"
))
if
(
parser
.
has
(
"help"
))
{
{
parser
.
print
Params
();
parser
.
print
Message
();
}
}
else
if
(
parser
.
get
<
bool
>
(
"build"
))
else
if
(
!
parser
.
check
())
{
parser
.
printErrors
();
}
else
if
(
parser
.
has
(
"build"
))
{
{
std
::
cout
<<
cv
::
getBuildInformation
()
<<
std
::
endl
;
std
::
cout
<<
cv
::
getBuildInformation
()
<<
std
::
endl
;
}
}
...
...
samples/cpp/point_cloud.cpp
View file @
54a202b3
...
@@ -64,20 +64,19 @@ static void openGlDrawCallback(void* userdata)
...
@@ -64,20 +64,19 @@ static void openGlDrawCallback(void* userdata)
int
main
(
int
argc
,
const
char
*
argv
[])
int
main
(
int
argc
,
const
char
*
argv
[])
{
{
const
char
*
keys
=
const
char
*
keys
=
"{ l
|
left | | left image file name }"
"{ l left | | left image file name }"
"{ r
|
right | | right image file name }"
"{ r right | | right image file name }"
"{ i
|
intrinsic | | intrinsic camera parameters file name }"
"{ i intrinsic | | intrinsic camera parameters file name }"
"{ e
|
extrinsic | | extrinsic camera parameters file name }"
"{ e extrinsic | | extrinsic camera parameters file name }"
"{ d
|
ndisp | 256 | number of disparities }"
"{ d ndisp | 256 | number of disparities }"
"{ s
|
scale | 1.0 | scale factor for point cloud }"
"{ s scale | 1.0 | scale factor for point cloud }"
"{ h
| help | false
| print help message }"
;
"{ h
help |
| print help message }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
if
(
cmd
.
has
(
"help"
))
{
{
cout
<<
"Avaible options:"
<<
endl
;
cmd
.
printMessage
();
cmd
.
printParams
();
return
0
;
return
0
;
}
}
...
@@ -88,11 +87,18 @@ int main(int argc, const char* argv[])
...
@@ -88,11 +87,18 @@ int main(int argc, const char* argv[])
int
ndisp
=
cmd
.
get
<
int
>
(
"ndisp"
);
int
ndisp
=
cmd
.
get
<
int
>
(
"ndisp"
);
double
scale
=
cmd
.
get
<
double
>
(
"scale"
);
double
scale
=
cmd
.
get
<
double
>
(
"scale"
);
if
(
!
cmd
.
check
())
{
cmd
.
printErrors
();
return
0
;
}
if
(
left
.
empty
()
||
right
.
empty
())
if
(
left
.
empty
()
||
right
.
empty
())
{
{
cout
<<
"Missed input images"
<<
endl
;
cout
<<
"Missed input images"
<<
endl
;
cout
<<
"Avaible options:"
<<
endl
;
cout
<<
"Avaible options:"
<<
endl
;
cmd
.
print
Params
();
cmd
.
print
Message
();
return
0
;
return
0
;
}
}
...
@@ -100,7 +106,7 @@ int main(int argc, const char* argv[])
...
@@ -100,7 +106,7 @@ int main(int argc, const char* argv[])
{
{
cout
<<
"Boss camera parameters must be specified"
<<
endl
;
cout
<<
"Boss camera parameters must be specified"
<<
endl
;
cout
<<
"Avaible options:"
<<
endl
;
cout
<<
"Avaible options:"
<<
endl
;
cmd
.
print
Params
();
cmd
.
print
Message
();
return
0
;
return
0
;
}
}
...
...
samples/cpp/videostab.cpp
View file @
54a202b3
...
@@ -281,56 +281,56 @@ int main(int argc, const char **argv)
...
@@ -281,56 +281,56 @@ int main(int argc, const char **argv)
try
try
{
{
const
char
*
keys
=
const
char
*
keys
=
"{
1 | | |
| }"
"{
@1 |
| }"
"{ m
| model | affine
| }"
"{ m
model | affine
| }"
"{ lp
| lin-prog-motion-est | no
| }"
"{ lp
lin-prog-motion-est | no
| }"
"{
| subset | auto
| }"
"{
subset | auto
| }"
"{
| thresh
| auto | }"
"{
thresh
| auto | }"
"{
| outlier-ratio
| 0.5 | }"
"{
outlier-ratio
| 0.5 | }"
"{
| min-inlier-ratio
| 0.1 | }"
"{
min-inlier-ratio
| 0.1 | }"
"{
| nkps
| 1000 | }"
"{
nkps
| 1000 | }"
"{
| extra-kps
| 0 | }"
"{
extra-kps
| 0 | }"
"{
|
local-outlier-rejection | no | }"
"{ local-outlier-rejection | no | }"
"{ sm
| save-motions
| no | }"
"{ sm
save-motions
| no | }"
"{ lm
| load-motions
| no | }"
"{ lm
load-motions
| no | }"
"{ r
| radius
| 15 | }"
"{ r
radius
| 15 | }"
"{
| stdev
| auto | }"
"{
stdev
| auto | }"
"{ lps
| lin-prog-stab
| no | }"
"{ lps
lin-prog-stab
| no | }"
"{
| lps-trim-ratio
| auto | }"
"{
lps-trim-ratio
| auto | }"
"{
| lps-w1
| 1 | }"
"{
lps-w1
| 1 | }"
"{
| lps-w2
| 10 | }"
"{
lps-w2
| 10 | }"
"{
| lps-w3
| 100 | }"
"{
lps-w3
| 100 | }"
"{
| lps-w4
| 100 | }"
"{
lps-w4
| 100 | }"
"{
| deblur
| no | }"
"{
deblur
| no | }"
"{
| deblur-sens
| 0.1 | }"
"{
deblur-sens
| 0.1 | }"
"{ et
| est-trim
| yes | }"
"{ et
est-trim
| yes | }"
"{ t
| trim-ratio
| 0.1 | }"
"{ t
trim-ratio
| 0.1 | }"
"{ ic
| incl-constr
| no | }"
"{ ic
incl-constr
| no | }"
"{ bm
| border-mode
| replicate | }"
"{ bm
border-mode
| replicate | }"
"{
| mosaic
| no | }"
"{
mosaic
| no | }"
"{ ms
| mosaic-stdev
| 10.0 | }"
"{ ms
mosaic-stdev
| 10.0 | }"
"{ mi
| motion-inpaint
| no | }"
"{ mi
motion-inpaint
| no | }"
"{
| mi-dist-thresh
| 5.0 | }"
"{
mi-dist-thresh
| 5.0 | }"
"{ ci
| color-inpaint
| no | }"
"{ ci
color-inpaint
| no | }"
"{
| ci-radius
| 2 | }"
"{
ci-radius
| 2 | }"
"{ ws
| wobble-suppress
| no | }"
"{ ws
wobble-suppress
| no | }"
"{
| ws-period
| 30 | }"
"{
ws-period
| 30 | }"
"{
| ws-model
| homography | }"
"{
ws-model
| homography | }"
"{
| ws-subset
| auto | }"
"{
ws-subset
| auto | }"
"{
| ws-thresh
| auto | }"
"{
ws-thresh
| auto | }"
"{
| ws-outlier-ratio
| 0.5 | }"
"{
ws-outlier-ratio
| 0.5 | }"
"{
| ws-min-inlier-ratio
| 0.1 | }"
"{
ws-min-inlier-ratio
| 0.1 | }"
"{
| ws-nkps
| 1000 | }"
"{
ws-nkps
| 1000 | }"
"{
| ws-extra-kps
| 0 | }"
"{
ws-extra-kps
| 0 | }"
"{
|
ws-local-outlier-rejection | no | }"
"{ ws-local-outlier-rejection | no | }"
"{
| ws-lp
| no | }"
"{
ws-lp
| no | }"
"{ sm2
| save-motions2
| no | }"
"{ sm2
save-motions2
| no | }"
"{ lm2
| load-motions2
| no | }"
"{ lm2
load-motions2
| no | }"
"{ gpu
| | no
}"
"{ gpu
| no |
}"
"{ o
| output
| stabilized.avi | }"
"{ o
output
| stabilized.avi | }"
"{
| fps
| auto | }"
"{
fps
| auto | }"
"{ q
| quiet | false
| }"
"{ q
quiet |
| }"
"{ h
| help | false
| }"
;
"{ h
help |
| }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
// parse command arguments
// parse command arguments
...
...
samples/gpu/bgfg_segm.cpp
View file @
54a202b3
...
@@ -21,20 +21,19 @@ enum Method
...
@@ -21,20 +21,19 @@ enum Method
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
cv
::
CommandLineParser
cmd
(
argc
,
argv
,
cv
::
CommandLineParser
cmd
(
argc
,
argv
,
"{ c
| camera | false
| use camera }"
"{ c
camera |
| use camera }"
"{ f
|
file | 768x576.avi | input video file }"
"{ f file | 768x576.avi | input video file }"
"{ m
|
method | mog | method (fgd, mog, mog2, vibe, gmg) }"
"{ m method | mog | method (fgd, mog, mog2, vibe, gmg) }"
"{ h
| help | false
| print help message }"
);
"{ h
help |
| print help message }"
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
if
(
cmd
.
has
(
"help"
)
||
!
cmd
.
check
(
))
{
{
cout
<<
"Usage : bgfg_segm [options]"
<<
endl
;
cmd
.
printMessage
();
cout
<<
"Avaible options:"
<<
endl
;
cmd
.
printErrors
();
cmd
.
printParams
();
return
0
;
return
0
;
}
}
bool
useCamera
=
cmd
.
get
<
bool
>
(
"camera"
);
bool
useCamera
=
cmd
.
has
(
"camera"
);
string
file
=
cmd
.
get
<
string
>
(
"file"
);
string
file
=
cmd
.
get
<
string
>
(
"file"
);
string
method
=
cmd
.
get
<
string
>
(
"method"
);
string
method
=
cmd
.
get
<
string
>
(
"method"
);
...
...
samples/gpu/brox_optical_flow.cpp
View file @
54a202b3
...
@@ -25,24 +25,23 @@ int main(int argc, const char* argv[])
...
@@ -25,24 +25,23 @@ int main(int argc, const char* argv[])
try
try
{
{
const
char
*
keys
=
const
char
*
keys
=
"{ h
| help | false
| print help message }"
"{ h
help |
| print help message }"
"{ l
|
left | | specify left image }"
"{ l left | | specify left image }"
"{ r
|
right | | specify right image }"
"{ r right | | specify right image }"
"{ s
|
scale | 0.8 | set pyramid scale factor }"
"{ s scale | 0.8 | set pyramid scale factor }"
"{ a
|
alpha | 0.197 | set alpha }"
"{ a alpha | 0.197 | set alpha }"
"{ g
|
gamma | 50.0 | set gamma }"
"{ g gamma | 50.0 | set gamma }"
"{ i
|
inner | 10 | set number of inner iterations }"
"{ i inner | 10 | set number of inner iterations }"
"{ o
|
outer | 77 | set number of outer iterations }"
"{ o outer | 77 | set number of outer iterations }"
"{ si
|
solver | 10 | set number of basic solver iterations }"
"{ si solver | 10 | set number of basic solver iterations }"
"{ t
|
time_step | 0.1 | set frame interpolation time step }"
;
"{ t time_step | 0.1 | set frame interpolation time step }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
if
(
cmd
.
has
(
"help"
)
||
!
cmd
.
check
(
))
{
{
cout
<<
"Usage: brox_optical_flow [options]"
<<
endl
;
cmd
.
printMessage
();
cout
<<
"Avaible options:"
<<
endl
;
cmd
.
printErrors
();
cmd
.
printParams
();
return
0
;
return
0
;
}
}
...
...
samples/gpu/farneback_optical_flow.cpp
View file @
54a202b3
...
@@ -43,19 +43,19 @@ static void colorizeFlow(const Mat &u, const Mat &v, Mat &dst)
...
@@ -43,19 +43,19 @@ static void colorizeFlow(const Mat &u, const Mat &v, Mat &dst)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
CommandLineParser
cmd
(
argc
,
argv
,
CommandLineParser
cmd
(
argc
,
argv
,
"{ l
| left
| | specify left image }"
"{ l
left
| | specify left image }"
"{ r
|
right | | specify right image }"
"{ r right | | specify right image }"
"{ h
| help | false
| print help message }"
);
"{ 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
"
cmd
.
printMessage
();
<<
"Usage: farneback_optical_flow_gpu [arguments]
\n\n
"
cmd
.
printErrors
();
<<
"Arguments:
\n
"
;
cmd
.
printParams
();
return
0
;
return
0
;
}
}
string
pathL
=
cmd
.
get
<
string
>
(
"left"
);
string
pathL
=
cmd
.
get
<
string
>
(
"left"
);
string
pathR
=
cmd
.
get
<
string
>
(
"right"
);
string
pathR
=
cmd
.
get
<
string
>
(
"right"
);
if
(
pathL
.
empty
())
cout
<<
"Specify left image path
\n
"
;
if
(
pathL
.
empty
())
cout
<<
"Specify left image path
\n
"
;
...
...
samples/gpu/performance/performance.cpp
View file @
54a202b3
...
@@ -165,22 +165,23 @@ int main(int argc, const char* argv[])
...
@@ -165,22 +165,23 @@ int main(int argc, const char* argv[])
redirectError
(
cvErrorCallback
);
redirectError
(
cvErrorCallback
);
const
char
*
keys
=
const
char
*
keys
=
"{ h
| help | false
| print help message }"
"{ h
help |
| print help message }"
"{ f
|
filter | | filter for test }"
"{ f filter | | filter for test }"
"{ w
|
workdir | | set working directory }"
"{ w workdir | | set working directory }"
"{ l
| list | false
| show all tests }"
"{ l
list |
| show all tests }"
"{ d
|
device | 0 | device id }"
"{ d device | 0 | device id }"
"{ i
|
iters | 10 | iteration count }"
;
"{ i iters | 10 | iteration count }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
if
(
cmd
.
has
(
"help"
)
||
!
cmd
.
check
(
))
{
{
c
out
<<
"Avaible options:"
<<
endl
;
c
md
.
printMessage
()
;
cmd
.
print
Param
s
();
cmd
.
print
Error
s
();
return
0
;
return
0
;
}
}
int
device
=
cmd
.
get
<
int
>
(
"device"
);
int
device
=
cmd
.
get
<
int
>
(
"device"
);
if
(
device
<
0
||
device
>=
num_devices
)
if
(
device
<
0
||
device
>=
num_devices
)
{
{
...
@@ -198,7 +199,7 @@ int main(int argc, const char* argv[])
...
@@ -198,7 +199,7 @@ int main(int argc, const char* argv[])
string
filter
=
cmd
.
get
<
string
>
(
"filter"
);
string
filter
=
cmd
.
get
<
string
>
(
"filter"
);
string
workdir
=
cmd
.
get
<
string
>
(
"workdir"
);
string
workdir
=
cmd
.
get
<
string
>
(
"workdir"
);
bool
list
=
cmd
.
get
<
bool
>
(
"list"
);
bool
list
=
cmd
.
has
(
"list"
);
int
iters
=
cmd
.
get
<
int
>
(
"iters"
);
int
iters
=
cmd
.
get
<
int
>
(
"iters"
);
if
(
!
filter
.
empty
())
if
(
!
filter
.
empty
())
...
...
samples/gpu/pyrlk_optical_flow.cpp
View file @
54a202b3
...
@@ -152,23 +152,22 @@ static void getFlowField(const Mat& u, const Mat& v, Mat& flowField)
...
@@ -152,23 +152,22 @@ static void getFlowField(const Mat& u, const Mat& v, Mat& flowField)
int
main
(
int
argc
,
const
char
*
argv
[])
int
main
(
int
argc
,
const
char
*
argv
[])
{
{
const
char
*
keys
=
const
char
*
keys
=
"{ h
| help | false
| print help message }"
"{ h
help |
| print help message }"
"{ l
| left
| | specify left image }"
"{ l
left
| | specify left image }"
"{ r
| right
| | specify right image }"
"{ r
right
| | specify right image }"
"{ gray
| gray | false
| use grayscale sources [PyrLK Sparse] }"
"{ gray
|
| use grayscale sources [PyrLK Sparse] }"
"{ win_size
| win_size
| 21 | specify windows size [PyrLK] }"
"{ win_size
| 21 | specify windows size [PyrLK] }"
"{ max_level
| max_level
| 3 | specify max level [PyrLK] }"
"{ max_level
| 3 | specify max level [PyrLK] }"
"{ iters
| iters
| 30 | specify iterations count [PyrLK] }"
"{ iters | 30 | specify iterations count [PyrLK] }"
"{ points
| points
| 4000 | specify points count [GoodFeatureToTrack] }"
"{ points | 4000 | specify points count [GoodFeatureToTrack] }"
"{ min_dist
| min_dist
| 0 | specify minimal distance between points [GoodFeatureToTrack] }"
;
"{ min_dist
| 0 | specify minimal distance between points [GoodFeatureToTrack] }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
if
(
cmd
.
has
(
"help"
)
||
!
cmd
.
check
(
))
{
{
cout
<<
"Usage: pyrlk_optical_flow [options]"
<<
endl
;
cmd
.
printMessage
();
cout
<<
"Avaible options:"
<<
endl
;
cmd
.
printErrors
();
cmd
.
printParams
();
return
0
;
return
0
;
}
}
...
@@ -181,7 +180,7 @@ int main(int argc, const char* argv[])
...
@@ -181,7 +180,7 @@ int main(int argc, const char* argv[])
return
-
1
;
return
-
1
;
}
}
bool
useGray
=
cmd
.
get
<
bool
>
(
"gray"
);
bool
useGray
=
cmd
.
has
(
"gray"
);
int
winSize
=
cmd
.
get
<
int
>
(
"win_size"
);
int
winSize
=
cmd
.
get
<
int
>
(
"win_size"
);
int
maxLevel
=
cmd
.
get
<
int
>
(
"max_level"
);
int
maxLevel
=
cmd
.
get
<
int
>
(
"max_level"
);
int
iters
=
cmd
.
get
<
int
>
(
"iters"
);
int
iters
=
cmd
.
get
<
int
>
(
"iters"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment