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
85f301ab
Commit
85f301ab
authored
Nov 24, 2010
by
Gary Bradski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
described
parent
541f4fc9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
connected_components.cpp
samples/cpp/connected_components.cpp
+21
-4
No files found.
samples/cpp/connected_components.cpp
View file @
85f301ab
#include "cv.h"
#include "cv.h"
#include "highgui.h"
#include "highgui.h"
#include <iostream>
using
namespace
cv
;
using
namespace
cv
;
Mat
img
;
Mat
img
;
int
threshval
=
100
;
int
threshval
=
100
;
void
help
()
{
cout
<<
"Program to demonstrate 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
*
)
void
on_trackbar
(
int
,
void
*
)
{
{
Mat
bw
=
threshval
<
128
?
(
img
<
threshval
)
:
(
img
>
threshval
);
Mat
bw
=
threshval
<
128
?
(
img
<
threshval
)
:
(
img
>
threshval
);
...
@@ -34,9 +47,13 @@ void on_trackbar(int, void*)
...
@@ -34,9 +47,13 @@ void on_trackbar(int, void*)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
// the first command line parameter must be file name of binary
// the first command line parameter
// (black-n-white) image
if
(
argc
!=
2
)
if
(
!
(
img
=
imread
(
argc
==
2
?
argv
[
1
]
:
"stuff.jpg"
,
0
)).
data
)
{
help
();
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
;
return
-
1
;
namedWindow
(
"Image"
,
1
);
namedWindow
(
"Image"
,
1
);
...
...
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