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
1f9171d1
Commit
1f9171d1
authored
Nov 24, 2010
by
Gary Bradski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find and drawContours doc
parent
85f301ab
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
contours2.cpp
samples/cpp/contours2.cpp
+21
-4
No files found.
samples/cpp/contours2.cpp
View file @
1f9171d1
#include "cv.h"
#include "cv.h"
#include "highgui.h"
#include "highgui.h"
#include <math.h>
#include <math.h>
#include <iostream>
using
namespace
cv
;
using
namespace
cv
;
void
help
()
{
cout
<<
"This program illustrates the use of findContours and drawContours
\n
"
<<
"The original image is put up along with the image of drawn contours
\n
"
<<
"Usage:
\n
"
<<
"./contours2
\n
"
<<
"
\n
A trackbar is put up which controls the contour level from -3 to 3
\n
"
<<
endl
;
}
const
int
w
=
500
;
const
int
w
=
500
;
int
levels
=
3
;
int
levels
=
3
;
...
@@ -20,10 +32,15 @@ void on_trackbar(int, void*)
...
@@ -20,10 +32,15 @@ void on_trackbar(int, void*)
imshow
(
"contours"
,
cnt_img
);
imshow
(
"contours"
,
cnt_img
);
}
}
int
main
(
int
,
char
**
)
int
main
(
int
argc
,
char
**
argv
)
{
{
Mat
img
=
Mat
::
zeros
(
w
,
w
,
CV_8UC1
);
Mat
img
=
Mat
::
zeros
(
w
,
w
,
CV_8UC1
);
if
(
argc
>
1
)
{
help
();
return
-
1
;
}
//Draw 6 faces
for
(
int
i
=
0
;
i
<
6
;
i
++
)
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
{
int
dx
=
(
i
%
2
)
*
250
-
30
;
int
dx
=
(
i
%
2
)
*
250
-
30
;
...
@@ -55,10 +72,10 @@ int main( int, char** )
...
@@ -55,10 +72,10 @@ int main( int, char** )
ellipse
(
img
,
Point
(
dx
+
27
,
dy
+
100
),
Size
(
20
,
35
),
0
,
0
,
360
,
white
,
-
1
,
8
,
0
);
ellipse
(
img
,
Point
(
dx
+
27
,
dy
+
100
),
Size
(
20
,
35
),
0
,
0
,
360
,
white
,
-
1
,
8
,
0
);
ellipse
(
img
,
Point
(
dx
+
273
,
dy
+
100
),
Size
(
20
,
35
),
0
,
0
,
360
,
white
,
-
1
,
8
,
0
);
ellipse
(
img
,
Point
(
dx
+
273
,
dy
+
100
),
Size
(
20
,
35
),
0
,
0
,
360
,
white
,
-
1
,
8
,
0
);
}
}
//show the faces
namedWindow
(
"image"
,
1
);
namedWindow
(
"image"
,
1
);
imshow
(
"image"
,
img
);
imshow
(
"image"
,
img
);
//Extract the contours so that
vector
<
vector
<
Point
>
>
contours0
;
vector
<
vector
<
Point
>
>
contours0
;
findContours
(
img
,
contours0
,
hierarchy
,
RETR_TREE
,
CHAIN_APPROX_SIMPLE
);
findContours
(
img
,
contours0
,
hierarchy
,
RETR_TREE
,
CHAIN_APPROX_SIMPLE
);
...
...
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