mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 22:00:25 +08:00
This commit is contained in:
parent
726efee4d2
commit
b28d13430c
@ -2587,6 +2587,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);
|
||||
|
@ -1810,3 +1810,13 @@ TEST(MinMaxLoc, Mat_IntMax_Without_Mask)
|
||||
ASSERT_EQ(Point(0, 0), minLoc);
|
||||
ASSERT_EQ(Point(0, 0), maxLoc);
|
||||
}
|
||||
|
||||
|
||||
TEST(Core_FindNonZero, singular)
|
||||
{
|
||||
Mat img(10, 10, CV_8U, Scalar::all(0));
|
||||
vector<Point> pts, pts2(10);
|
||||
findNonZero(img, pts);
|
||||
findNonZero(img, pts2);
|
||||
ASSERT_TRUE(pts.empty() && pts2.empty());
|
||||
}
|
Loading…
Reference in New Issue
Block a user