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
6a4d881a
Commit
6a4d881a
authored
Dec 09, 2012
by
Jason Newton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use vector instead of non-standard stack allocation. also correct program argument borkage
parent
00bdca76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
connected_components.cpp
samples/cpp/connected_components.cpp
+3
-3
No files found.
samples/cpp/connected_components.cpp
View file @
6a4d881a
...
@@ -13,7 +13,7 @@ static void on_trackbar(int, void*)
...
@@ -13,7 +13,7 @@ static void on_trackbar(int, void*)
Mat
bw
=
threshval
<
128
?
(
img
<
threshval
)
:
(
img
>
threshval
);
Mat
bw
=
threshval
<
128
?
(
img
<
threshval
)
:
(
img
>
threshval
);
Mat
labelImage
(
img
.
size
(),
CV_32S
);
Mat
labelImage
(
img
.
size
(),
CV_32S
);
int
nLabels
=
connectedComponents
(
bw
,
labelImage
,
8
);
int
nLabels
=
connectedComponents
(
bw
,
labelImage
,
8
);
Vec3b
colors
[
nLabels
]
;
std
::
vector
<
Vec3b
>
colors
(
nLabels
)
;
colors
[
0
]
=
Vec3b
(
0
,
0
,
0
);
//background
colors
[
0
]
=
Vec3b
(
0
,
0
,
0
);
//background
for
(
int
label
=
1
;
label
<
nLabels
;
++
label
){
for
(
int
label
=
1
;
label
<
nLabels
;
++
label
){
colors
[
label
]
=
Vec3b
(
(
rand
()
&
255
),
(
rand
()
&
255
),
(
rand
()
&
255
)
);
colors
[
label
]
=
Vec3b
(
(
rand
()
&
255
),
(
rand
()
&
255
),
(
rand
()
&
255
)
);
...
@@ -41,14 +41,14 @@ static void help()
...
@@ -41,14 +41,14 @@ static void help()
const
char
*
keys
=
const
char
*
keys
=
{
{
"{@image
|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
>
(
"@image"
);
img
=
imread
(
inputImage
.
c_str
(),
0
);
img
=
imread
(
inputImage
.
c_str
(),
0
);
if
(
img
.
empty
())
if
(
img
.
empty
())
...
...
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