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
24279c2c
Commit
24279c2c
authored
Aug 10, 2011
by
itsyplen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated sample using new cmd parser
parent
49fb4ecb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
connected_components.cpp
samples/cpp/connected_components.cpp
+22
-19
No files found.
samples/cpp/connected_components.cpp
View file @
24279c2c
...
...
@@ -8,19 +8,6 @@ using namespace std;
Mat
img
;
int
threshval
=
100
;
void
help
()
{
cout
<<
"
\n
This program demonstrates connected components and use of the trackbar
\n
"
<<
"
\n
"
<<
"Usage: ./connected_components <image>
\n
"
<<
"
\n
"
<<
"The image is converted to grayscale and displayed, another image has a trackbar
\n
"
<<
"that controls thresholding and thereby the extracted contours which are drawn in color
\n
"
<<
endl
;
}
void
on_trackbar
(
int
,
void
*
)
{
Mat
bw
=
threshval
<
128
?
(
img
<
threshval
)
:
(
img
>
threshval
);
...
...
@@ -47,16 +34,32 @@ void on_trackbar(int, void*)
imshow
(
"Connected Components"
,
dst
);
}
int
main
(
int
argc
,
char
**
argv
)
void
help
()
{
printf
(
"
\n
This program demonstrates connected components and use of the trackbar
\n
"
"Usage:
\n
"
" ./connected_components <image(stuff.jpg as default)>
\n
"
"The image is converted to grayscale and displayed, another image has a trackbar
\n
"
"that controls thresholding and thereby the extracted contours which are drawn in color
\n
"
);
}
const
char
*
keys
=
{
"{1| |stuff.jpg|image for converting to a grayscale}"
};
int
main
(
int
argc
,
const
char
**
argv
)
{
// the first command line parameter
if
(
argc
!=
2
)
{
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
inputImage
=
parser
.
get
<
string
>
(
"1"
);
img
=
imread
(
inputImage
.
c_str
(),
0
);
if
(
img
.
empty
())
{
printf
(
"Could not read input image file: %s
\n
"
,
inputImage
.
c_str
());
return
-
1
;
}
if
(
!
(
img
=
imread
(
argc
==
2
?
argv
[
1
]
:
"stuff.jpg"
,
0
)).
data
)
//The ending 0 in imread converts the image to grayscale.
return
-
1
;
namedWindow
(
"Image"
,
1
);
imshow
(
"Image"
,
img
);
...
...
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