mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
* a part of https://github.com/opencv/opencv/pull/11364 by Tetragramm. Rewritten and extended findNonZero & PSNR to support more types, not just 8u. * fixed compile & doxygen warnings * fixed small bug in findNonZero test
This commit is contained in:
@@ -1847,13 +1847,54 @@ INSTANTIATE_TEST_CASE_P(Arithm, SubtractOutputMatNotEmpty, testing::Combine(
|
||||
testing::Values(-1, CV_16S, CV_32S, CV_32F),
|
||||
testing::Bool()));
|
||||
|
||||
TEST(Core_FindNonZero, singular)
|
||||
TEST(Core_FindNonZero, regression)
|
||||
{
|
||||
Mat img(10, 10, CV_8U, Scalar::all(0));
|
||||
vector<Point> pts, pts2(10);
|
||||
vector<Point> pts, pts2(5);
|
||||
findNonZero(img, pts);
|
||||
findNonZero(img, pts2);
|
||||
ASSERT_TRUE(pts.empty() && pts2.empty());
|
||||
|
||||
RNG rng((uint64)-1);
|
||||
size_t nz = 0;
|
||||
for( int i = 0; i < 10; i++ )
|
||||
{
|
||||
int idx = rng.uniform(0, img.rows*img.cols);
|
||||
if( !img.data[idx] ) nz++;
|
||||
img.data[idx] = (uchar)rng.uniform(1, 256);
|
||||
}
|
||||
findNonZero(img, pts);
|
||||
ASSERT_TRUE(pts.size() == nz);
|
||||
|
||||
img.convertTo( img, CV_8S );
|
||||
pts.clear();
|
||||
findNonZero(img, pts);
|
||||
ASSERT_TRUE(pts.size() == nz);
|
||||
|
||||
img.convertTo( img, CV_16U );
|
||||
pts.resize(pts.size()*2);
|
||||
findNonZero(img, pts);
|
||||
ASSERT_TRUE(pts.size() == nz);
|
||||
|
||||
img.convertTo( img, CV_16S );
|
||||
pts.resize(pts.size()*3);
|
||||
findNonZero(img, pts);
|
||||
ASSERT_TRUE(pts.size() == nz);
|
||||
|
||||
img.convertTo( img, CV_32S );
|
||||
pts.resize(pts.size()*4);
|
||||
findNonZero(img, pts);
|
||||
ASSERT_TRUE(pts.size() == nz);
|
||||
|
||||
img.convertTo( img, CV_32F );
|
||||
pts.resize(pts.size()*5);
|
||||
findNonZero(img, pts);
|
||||
ASSERT_TRUE(pts.size() == nz);
|
||||
|
||||
img.convertTo( img, CV_64F );
|
||||
pts.clear();
|
||||
findNonZero(img, pts);
|
||||
ASSERT_TRUE(pts.size() == nz);
|
||||
}
|
||||
|
||||
TEST(Core_BoolVector, support)
|
||||
|
||||
Reference in New Issue
Block a user