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
34df4ae0
Commit
34df4ae0
authored
Oct 19, 2016
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a regression test, fix documentation
parent
1f4f50b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
+26
-14
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+8
-12
test_contours.cpp
modules/imgproc/test/test_contours.cpp
+18
-2
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
34df4ae0
...
...
@@ -3732,21 +3732,17 @@ CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labe
/** @brief Finds contours in a binary image.
The function retrieves contours from the binary image using the algorithm @cite Suzuki85 . The contours
are a useful tool for shape analysis and object detection and recognition. See squares.c in the
are a useful tool for shape analysis and object detection and recognition. See squares.c
pp
in the
OpenCV sample directory.
@note Source image is modified by this function. Also, the function does not take into account
1-pixel border of the image (it's filled with 0's and used for neighbor analysis in the algorithm),
therefore the contours touching the image border will be clipped.
@param image Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero
pixels remain 0's, so the image is treated as binary . You can use c
ompare , inRange ,
threshold ,
adaptiveThreshold , Canny
, and others to create a binary image out of a grayscale or color one.
The function modifies the image while extracting the contours. If mode equals to RETR_CCOMP
or RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1)
.
@param contours Detected contours. Each contour is stored as a vector of points
.
@param hierarchy Optional output vector, containing information about the image topology. It has
as many elements as the number of contours. For each i-th contour contours[i]
, the elements
pixels remain 0's, so the image is treated as binary . You can use c
v::compare, cv::inRange, cv::
threshold ,
cv::adaptiveThreshold, cv::Canny
, and others to create a binary image out of a grayscale or color one.
If mode equals to cv::RETR_CCOMP or cv::RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1).
@param contours Detected contours. Each contour is stored as a vector of points (e.g
.
std::vector<std::vector<cv::Point> >)
.
@param hierarchy Optional output vector
(e.g. std::vector<cv::Vec4i>)
, containing information about the image topology. It has
as many elements as the number of contours. For each i-th contour contours[i], the elements
hierarchy[i][0] , hiearchy[i][1] , hiearchy[i][2] , and hiearchy[i][3] are set to 0-based indices
in contours of the next and previous contours at the same hierarchical level, the first child
contour and the parent contour, respectively. If for the contour i there are no next, previous,
...
...
modules/imgproc/test/test_contours.cpp
View file @
34df4ae0
...
...
@@ -483,10 +483,26 @@ TEST(Imgproc_FindContours, hilbert)
img
.
setTo
(
Scalar
::
all
(
0
));
drawContours
(
img
,
contours
,
0
,
Scalar
::
all
(
255
),
1
);
//imshow("hilbert", img);
//waitKey();
ASSERT_EQ
(
1
,
(
int
)
contours
.
size
());
ASSERT_EQ
(
9832
,
(
int
)
contours
[
0
].
size
());
}
TEST
(
Imgproc_FindContours
,
border
)
{
Mat
img
;
copyMakeBorder
(
Mat
::
zeros
(
8
,
10
,
CV_8U
),
img
,
1
,
1
,
1
,
1
,
BORDER_CONSTANT
,
Scalar
(
1
));
std
::
vector
<
std
::
vector
<
cv
::
Point
>
>
contours
;
findContours
(
img
,
contours
,
RETR_LIST
,
CHAIN_APPROX_NONE
);
Mat
img_draw_contours
=
Mat
::
zeros
(
img
.
size
(),
CV_8U
);
for
(
size_t
cpt
=
0
;
cpt
<
contours
.
size
();
cpt
++
)
{
drawContours
(
img_draw_contours
,
contours
,
static_cast
<
int
>
(
cpt
),
cv
::
Scalar
(
255
));
}
ASSERT_TRUE
(
norm
(
img
-
img_draw_contours
,
NORM_INF
)
==
0.0
);
}
/* End of file. */
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