From 59250e8288c3298e1d4a4b4ec3b23e381d2b5f20 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 27 Apr 2014 19:22:29 +0200 Subject: [PATCH] cv::findContours: Check if type of output data structure is right to store contours (vector>). --- modules/imgproc/src/contours.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp index 797f8c56c..4c77dd285 100644 --- a/modules/imgproc/src/contours.cpp +++ b/modules/imgproc/src/contours.cpp @@ -1703,6 +1703,10 @@ cvFindContours( void* img, CvMemStorage* storage, void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours, OutputArray _hierarchy, int mode, int method, Point offset ) { + // Sanity check: output must be of type vector> + CV_Assert( _contours.kind() == _InputArray::STD_VECTOR_VECTOR && + _contours.channels() == 2 && _contours.depth() == CV_32S ); + Mat image = _image.getMat(); MemStorage storage(cvCreateMemStorage()); CvMat _cimage = image;