Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
a2769e15
Commit
a2769e15
authored
Nov 09, 2017
by
Hamdi Sahloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CVV - Replace getopt with CommandLineParser
parent
bccbec79
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
cvv_demo.cpp
modules/cvv/samples/cvv_demo.cpp
+13
-18
No files found.
modules/cvv/samples/cvv_demo.cpp
View file @
a2769e15
// system includes
#include <getopt.h>
#include <iostream>
// library includes
...
...
@@ -16,6 +15,7 @@
#include <opencv2/cvv/dmatch.hpp>
#include <opencv2/cvv/final_show.hpp>
using
namespace
std
;
using
namespace
cv
;
template
<
class
T
>
std
::
string
toString
(
const
T
&
p_arg
)
...
...
@@ -42,30 +42,24 @@ main(int argc, char** argv)
{
cv
::
Size
*
resolution
=
nullptr
;
// parse options
const
char
*
optstring
=
"hr:"
;
int
opt
;
while
((
opt
=
getopt
(
argc
,
argv
,
optstring
))
!=
-
1
)
{
switch
(
opt
)
{
case
'h'
:
// parser keys
const
char
*
keys
=
"{ help h usage ? | | show this message }"
"{ resolution r |0x0| resolution to width and height in the format WxH }"
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
res
(
parser
.
get
<
string
>
(
"resolution"
));
if
(
parser
.
has
(
"help"
))
{
usage
();
return
0
;
break
;
case
'r'
:
{
}
if
(
res
!=
"0x0"
)
{
char
dummych
;
resolution
=
new
cv
::
Size
();
if
(
sscanf
(
optarg
,
"%d%c%d"
,
&
resolution
->
width
,
&
dummych
,
&
resolution
->
height
)
!=
3
)
{
printf
(
"%s not a valid resolution
\n
"
,
optarg
)
;
if
(
sscanf
(
res
.
c_str
()
,
"%d%c%d"
,
&
resolution
->
width
,
&
dummych
,
&
resolution
->
height
)
!=
3
)
{
cout
<<
res
<<
" not a valid resolution"
<<
endl
;
return
1
;
}
}
break
;
default
:
/* '?' */
usage
();
return
2
;
}
}
// setup video capture
cv
::
VideoCapture
capture
(
0
);
...
...
@@ -78,6 +72,7 @@ main(int argc, char** argv)
printf
(
"Setting resolution to %dx%d
\n
"
,
resolution
->
width
,
resolution
->
height
);
capture
.
set
(
CV_CAP_PROP_FRAME_WIDTH
,
resolution
->
width
);
capture
.
set
(
CV_CAP_PROP_FRAME_HEIGHT
,
resolution
->
height
);
delete
resolution
;
}
...
...
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