Fix Python 2 bindings for findContours
The sanity check prevents Python 2 from calling findContours, because the Python 2 bindings pass an empty matrix for `_contours`. If `_contours` is not empty, the channel and depth check should determine whether the matrix is of the correct type and size. Note: the Python 2 bindings passes a matrix of type `STD_VECTOR_MAT` to parameters of the type `OutputArrayOfArrays`.
This commit is contained in:
parent
7da0e37ba8
commit
d25770ee76
@ -1704,8 +1704,10 @@ void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours,
|
|||||||
OutputArray _hierarchy, int mode, int method, Point offset )
|
OutputArray _hierarchy, int mode, int method, Point offset )
|
||||||
{
|
{
|
||||||
// Sanity check: output must be of type vector<vector<Point>>
|
// Sanity check: output must be of type vector<vector<Point>>
|
||||||
CV_Assert( _contours.kind() == _InputArray::STD_VECTOR_VECTOR &&
|
CV_Assert((_contours.kind() == _InputArray::STD_VECTOR_VECTOR || _contours.kind() == _InputArray::STD_VECTOR_MAT ||
|
||||||
_contours.channels() == 2 && _contours.depth() == CV_32S );
|
_contours.kind() == _InputArray::STD_VECTOR_UMAT));
|
||||||
|
|
||||||
|
CV_Assert(_contours.empty() || (_contours.channels() == 2 && _contours.depth() == CV_32S));
|
||||||
|
|
||||||
Mat image = _image.getMat();
|
Mat image = _image.getMat();
|
||||||
MemStorage storage(cvCreateMemStorage());
|
MemStorage storage(cvCreateMemStorage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user