Commit 1f4f50b9 authored by Vladislav Sovrasov's avatar Vladislav Sovrasov

findContours: integrate workaroung to allow contours detection on image border

parent 2038434c
...@@ -1878,13 +1878,14 @@ void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours, ...@@ -1878,13 +1878,14 @@ void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours,
CV_Assert(_contours.empty() || (_contours.channels() == 2 && _contours.depth() == CV_32S)); 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()); MemStorage storage(cvCreateMemStorage());
CvMat _cimage = image; CvMat _cimage = image;
CvSeq* _ccontours = 0; CvSeq* _ccontours = 0;
if( _hierarchy.needed() ) if( _hierarchy.needed() )
_hierarchy.clear(); _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 ) if( !_ccontours )
{ {
_contours.clear(); _contours.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment