From 1f4f50b9dc2e4713abb6a5dee5dc4d0e8a766685 Mon Sep 17 00:00:00 2001 From: Vladislav Sovrasov Date: Tue, 18 Oct 2016 14:16:14 +0300 Subject: [PATCH] findContours: integrate workaroung to allow contours detection on image border --- modules/imgproc/src/contours.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp index d59c5a17df..427cd050b1 100644 --- a/modules/imgproc/src/contours.cpp +++ b/modules/imgproc/src/contours.cpp @@ -1878,13 +1878,14 @@ void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours, CV_Assert(_contours.empty() || (_contours.channels() == 2 && _contours.depth() == CV_32S)); - Mat image = _image.getMat(); + Mat image; + copyMakeBorder(_image, image, 1, 1, 1, 1, BORDER_CONSTANT, Scalar(0)); MemStorage storage(cvCreateMemStorage()); CvMat _cimage = image; CvSeq* _ccontours = 0; if( _hierarchy.needed() ) _hierarchy.clear(); - cvFindContours(&_cimage, storage, &_ccontours, sizeof(CvContour), mode, method, offset); + cvFindContours(&_cimage, storage, &_ccontours, sizeof(CvContour), mode, method, offset + Point(-1, -1)); if( !_ccontours ) { _contours.clear();