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
49fb4ecb
Commit
49fb4ecb
authored
Aug 10, 2011
by
itsyplen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated samples using new cmd parser
parent
c9ed7fee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
45 deletions
+57
-45
camshiftdemo.cpp
samples/cpp/camshiftdemo.cpp
+31
-28
chamfer.cpp
samples/cpp/chamfer.cpp
+26
-17
No files found.
samples/cpp/camshiftdemo.cpp
View file @
49fb4ecb
...
...
@@ -8,24 +8,6 @@
using
namespace
cv
;
using
namespace
std
;
void
help
()
{
cout
<<
"
\n
This is a demo that shows mean-shift based tracking
\n
"
<<
"You select a color objects such as your face and it tracks it.
\n
"
<<
"This reads from video camera (0 by default, or the camera number the user enters
\n
"
<<
"Call:
\n
"
<<
"
\n
./camshiftdemo [camera number]"
<<
"
\n
"
<<
endl
;
cout
<<
"
\n\n
Hot keys:
\n
"
"
\t
ESC - quit the program
\n
"
"
\t
c - stop the tracking
\n
"
"
\t
b - switch to/from backprojection view
\n
"
"
\t
h - show/hide object histogram
\n
"
"
\t
p - pause video
\n
"
"To initialize tracking, select the object with mouse
\n
"
<<
endl
;
}
Mat
image
;
bool
backprojMode
=
false
;
...
...
@@ -63,31 +45,52 @@ void onMouse( int event, int x, int y, int, void* )
}
}
void
help
()
{
printf
(
"
\n
This is a demo that shows mean-shift based tracking
\n
"
"You select a color objects such as your face and it tracks it.
\n
"
"This reads from video camera (0 by default, or the camera number the user enters
\n
"
"Usage:
\n
"
" ./camshiftdemo [camera number]
\n
"
);
printf
(
"
\n\n
Hot keys:
\n
"
"
\t
ESC - quit the program
\n
"
"
\t
c - stop the tracking
\n
"
"
\t
b - switch to/from backprojection view
\n
"
"
\t
h - show/hide object histogram
\n
"
"
\t
p - pause video
\n
"
"To initialize tracking, select the object with mouse
\n
"
);
}
const
char
*
keys
=
{
"{1| | 0 | camera number}"
};
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
c
onst
c
har
**
argv
)
{
help
();
VideoCapture
cap
;
Rect
trackWindow
;
RotatedRect
trackBox
;
int
hsize
=
16
;
float
hranges
[]
=
{
0
,
180
};
const
float
*
phranges
=
hranges
;
if
(
argc
==
1
||
(
argc
==
2
&&
strlen
(
argv
[
1
])
==
1
&&
isdigit
(
argv
[
1
][
0
])))
cap
.
open
(
argc
==
2
?
argv
[
1
][
0
]
-
'0'
:
0
);
else
if
(
argc
==
2
)
cap
.
open
(
argv
[
1
]);
CommandLineParser
parser
(
argc
,
argv
,
keys
);
int
camNum
=
parser
.
get
<
int
>
(
"1"
);
cap
.
open
(
camNum
);
if
(
!
cap
.
isOpened
()
)
{
help
();
cout
<<
"***Could not initialize capturing...***
\n
"
;
return
0
;
printf
(
"***Could not initialize capturing...***
\n
"
);
printf
(
"Current parameter's value:
\n
"
);
parser
.
printParams
();
return
-
1
;
}
help
();
namedWindow
(
"Histogram"
,
0
);
namedWindow
(
"CamShift Demo"
,
0
);
setMouseCallback
(
"CamShift Demo"
,
onMouse
,
0
);
...
...
samples/cpp/chamfer.cpp
View file @
49fb4ecb
...
...
@@ -2,36 +2,45 @@
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
void
help
()
{
cout
<<
"
\n
This program demonstrates Chamfer matching -- computing a distance between an
\n
"
printf
(
"
\n
This program demonstrates Chamfer matching -- computing a distance between an
\n
"
"edge template and a query edge image.
\n
"
"Usage:
\n
"
"Usage:
\n
"
"./chamfer <image edge map> <template edge map>,"
" By default the inputs are logo_in_clutter.png logo.png
\n
"
<<
endl
;
" By default the inputs are logo_in_clutter.png logo.png
\n
"
);
return
;
}
const
char
*
keys
=
{
"{1| |logo_in_clutter.png|image edge map }"
"{2| |logo.png |template edge map}"
};
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
c
onst
c
har
**
argv
)
{
if
(
argc
!=
3
)
{
help
();
return
0
;
}
Mat
img
=
imread
(
argc
==
3
?
argv
[
1
]
:
"logo_in_clutter.png"
,
0
);
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
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
);
if
(
img
.
empty
()
||
tpl
.
empty
())
{
printf
(
"Could not read image file %s or %s
\n
"
,
image
.
c_str
(),
templ
.
c_str
());
return
-
1
;
}
Mat
cimg
;
cvtColor
(
img
,
cimg
,
CV_GRAY2BGR
);
Mat
tpl
=
imread
(
argc
==
3
?
argv
[
2
]
:
"logo.png"
,
0
);
// if the image and the template are not edge maps but normal grayscale images,
// you might want to uncomment the lines below to produce the maps. You can also
...
...
@@ -45,8 +54,8 @@ int main( int argc, char** argv )
int
best
=
chamerMatching
(
img
,
tpl
,
results
,
costs
);
if
(
best
<
0
)
{
cout
<<
"matching not found
\n
"
;
return
0
;
printf
(
"matching not found
\n
"
)
;
return
-
1
;
}
size_t
i
,
n
=
results
[
best
].
size
();
...
...
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