fixed http://code.opencv.org/issues/3828, added test. thanks to berak for the patch

This commit is contained in:
Vadim Pisarevsky
2015-04-29 13:12:53 +03:00
parent 0746ec7035
commit d8f360316d
2 changed files with 15 additions and 0 deletions

View File

@@ -3826,6 +3826,11 @@ void cv::findNonZero( InputArray _src, OutputArray _idx )
Mat src = _src.getMat();
CV_Assert( src.type() == CV_8UC1 );
int n = countNonZero(src);
if( n == 0 )
{
_idx.release();
return;
}
if( _idx.kind() == _InputArray::MAT && !_idx.getMatRef().isContinuous() )
_idx.release();
_idx.create(n, 1, CV_32SC2);