both tests by picture and rand mat
This commit is contained in:
parent
e34a7caabc
commit
4b71921526
@ -13,6 +13,7 @@
|
|||||||
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
|
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
|
||||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2013-2014, Itseez, Inc, all rights reserved.
|
||||||
// Third party copyrights are property of their respective owners.
|
// Third party copyrights are property of their respective owners.
|
||||||
//
|
//
|
||||||
// @Authors
|
// @Authors
|
||||||
@ -144,6 +145,36 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
|
|||||||
|
|
||||||
scale = randomDouble(0.1, 1);
|
scale = randomDouble(0.1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void test_by_pict()
|
||||||
|
{
|
||||||
|
Mat frame1 = readImage("optflow/RubberWhale1.png", IMREAD_GRAYSCALE);
|
||||||
|
|
||||||
|
UMat usrc;
|
||||||
|
frame1.copyTo(usrc);
|
||||||
|
int histSize = randomInt(3, 29);
|
||||||
|
float hue_range[] = { 0, 180 };
|
||||||
|
const float* ranges = { hue_range };
|
||||||
|
|
||||||
|
//compute histogram
|
||||||
|
calcHist(&frame1, 1, 0, Mat(), hist, 1, &histSize, &ranges, true, false);
|
||||||
|
normalize(hist, hist, 0, 255, NORM_MINMAX, -1, Mat());
|
||||||
|
|
||||||
|
Mat dst;
|
||||||
|
UMat udst, src, uhist;
|
||||||
|
hist.copyTo(uhist);
|
||||||
|
std::vector<UMat> uims;
|
||||||
|
uims.push_back(usrc);
|
||||||
|
std::vector<float> urngs;
|
||||||
|
urngs.push_back(0);
|
||||||
|
urngs.push_back(180);
|
||||||
|
std::vector<int> chs;
|
||||||
|
chs.push_back(0);
|
||||||
|
|
||||||
|
OCL_OFF(calcBackProject(&frame1, 1, 0, hist, dst, &ranges, 1, true));
|
||||||
|
OCL_ON(calcBackProject(uims, chs, uhist, udst, urngs, 1.0));
|
||||||
|
EXPECT_MAT_NEAR(dst, udst, 0.0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////// CalcBackProject //////////////////////////////////////////////
|
//////////////////////////////// CalcBackProject //////////////////////////////////////////////
|
||||||
@ -157,7 +188,14 @@ OCL_TEST_P(CalcBackProject, Mat)
|
|||||||
OCL_OFF(cv::calcBackProject(images_roi, channels, hist_roi, dst_roi, ranges, scale));
|
OCL_OFF(cv::calcBackProject(images_roi, channels, hist_roi, dst_roi, ranges, scale));
|
||||||
OCL_ON(cv::calcBackProject(uimages_roi, channels, uhist_roi, udst_roi, ranges, scale));
|
OCL_ON(cv::calcBackProject(uimages_roi, channels, uhist_roi, udst_roi, ranges, scale));
|
||||||
|
|
||||||
OCL_EXPECT_MATS_NEAR(dst, 0.0);
|
Size dstSize = dst_roi.size();
|
||||||
|
int nDiffs = (int)(0.03f*dstSize.height*dstSize.width);
|
||||||
|
|
||||||
|
//check if the dst mats are the same except 3% difference
|
||||||
|
EXPECT_MAT_N_DIFF(dst_roi, udst_roi, nDiffs);
|
||||||
|
|
||||||
|
//check in addition on given image
|
||||||
|
test_by_pict();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,17 @@ do \
|
|||||||
<< "Size: " << mat1.size() << std::endl; \
|
<< "Size: " << mat1.size() << std::endl; \
|
||||||
} while ((void)0, 0)
|
} while ((void)0, 0)
|
||||||
|
|
||||||
|
#define EXPECT_MAT_N_DIFF(mat1, mat2, num) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
ASSERT_EQ(mat1.type(), mat2.type()); \
|
||||||
|
ASSERT_EQ(mat1.size(), mat2.size()); \
|
||||||
|
Mat diff; \
|
||||||
|
absdiff(mat1, mat2, diff); \
|
||||||
|
EXPECT_LE(countNonZero(diff.reshape(1)), num) \
|
||||||
|
<< "Size: " << mat1.size() << std::endl; \
|
||||||
|
} while ((void)0, 0)
|
||||||
|
|
||||||
#define OCL_EXPECT_MATS_NEAR(name, eps) \
|
#define OCL_EXPECT_MATS_NEAR(name, eps) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
Loading…
Reference in New Issue
Block a user