Merge pull request #1545 from alalek:ocl_test_fix_rng
This commit is contained in:
commit
ec409a436d
@ -80,12 +80,14 @@ PARAM_TEST_CASE(Lut, int, int, bool, bool)
|
||||
cv::Mat dst_roi;
|
||||
|
||||
// ocl dst mat for testing
|
||||
cv::ocl::oclMat gsrc_whole;
|
||||
cv::ocl::oclMat glut_whole;
|
||||
cv::ocl::oclMat gdst_whole;
|
||||
|
||||
// ocl mat with roi
|
||||
cv::ocl::oclMat gsrc;
|
||||
cv::ocl::oclMat glut;
|
||||
cv::ocl::oclMat gdst;
|
||||
cv::ocl::oclMat gsrc_roi;
|
||||
cv::ocl::oclMat glut_roi;
|
||||
cv::ocl::oclMat gdst_roi;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
@ -93,66 +95,34 @@ PARAM_TEST_CASE(Lut, int, int, bool, bool)
|
||||
cn = GET_PARAM(1);
|
||||
same_cn = GET_PARAM(2);
|
||||
use_roi = GET_PARAM(3);
|
||||
|
||||
const int src_type = CV_MAKE_TYPE(CV_8U, cn);
|
||||
const int lut_type = CV_MAKE_TYPE(lut_depth, same_cn ? cn : 1);
|
||||
const int dst_type = CV_MAKE_TYPE(lut_depth, cn);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), src_type, 0, 256, false);
|
||||
lut = randomMat(rng, use_roi ? randomSize(260, 300) : Size(256, 1), lut_type, 5, 16, false);
|
||||
dst = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), dst_type, 5, 16, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
// set up roi
|
||||
int roicols, roirows;
|
||||
int srcx, srcy;
|
||||
int lutx, luty;
|
||||
int dstx, dsty;
|
||||
const int src_type = CV_MAKE_TYPE(CV_8U, cn);
|
||||
const int lut_type = CV_MAKE_TYPE(lut_depth, same_cn ? cn : 1);
|
||||
const int dst_type = CV_MAKE_TYPE(lut_depth, cn);
|
||||
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
Size roiSize = randomSize(1, MAX_VALUE);
|
||||
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(src, src_roi, roiSize, srcBorder, src_type, 0, 256);
|
||||
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
Size lutRoiSize = Size(256, 1);
|
||||
Border lutBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(lut, lut_roi, lutRoiSize, lutBorder, lut_type, 5, 16);
|
||||
|
||||
srcx = rng.uniform(0, src.cols - roicols);
|
||||
srcy = rng.uniform(0, src.rows - roirows);
|
||||
lutx = rng.uniform(0, lut.cols - 256);
|
||||
luty = rng.uniform(0, lut.rows - 1);
|
||||
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(dst, dst_roi, roiSize, dstBorder, dst_type, 5, 16);
|
||||
|
||||
dstx = rng.uniform(0, dst.cols - roicols);
|
||||
dsty = rng.uniform(0, dst.rows - roirows);
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = src.cols;
|
||||
roirows = src.rows;
|
||||
srcx = srcy = 0;
|
||||
lutx = luty = 0;
|
||||
dstx = dsty = 0;
|
||||
}
|
||||
|
||||
src_roi = src(Rect(srcx, srcy, roicols, roirows));
|
||||
lut_roi = lut(Rect(lutx, luty, 256, 1));
|
||||
dst_roi = dst(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
gsrc = src_roi;
|
||||
glut = lut_roi;
|
||||
generateOclMat(gsrc_whole, gsrc_roi, src, roiSize, srcBorder);
|
||||
generateOclMat(glut_whole, glut_roi, lut, lutRoiSize, lutBorder);
|
||||
generateOclMat(gdst_whole, gdst_roi, dst, roiSize, dstBorder);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.)
|
||||
{
|
||||
EXPECT_MAT_NEAR(dst, Mat(gdst_whole), threshold);
|
||||
EXPECT_MAT_NEAR(dst_roi, Mat(gdst), threshold);
|
||||
EXPECT_MAT_NEAR(dst_roi, Mat(gdst_roi), threshold);
|
||||
}
|
||||
};
|
||||
|
||||
@ -163,7 +133,7 @@ TEST_P(Lut, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::LUT(src_roi, lut_roi, dst_roi);
|
||||
cv::ocl::LUT(gsrc, glut, gdst);
|
||||
cv::ocl::LUT(gsrc_roi, glut_roi, gdst_roi);
|
||||
|
||||
Near();
|
||||
}
|
||||
@ -183,50 +153,34 @@ PARAM_TEST_CASE(ArithmTestBase, int, int, bool)
|
||||
cv::Mat src2;
|
||||
cv::Mat mask;
|
||||
cv::Mat dst1;
|
||||
cv::Mat dst2; // for two outputs
|
||||
|
||||
// set up roi
|
||||
int roicols, roirows;
|
||||
int src1x, src1y;
|
||||
int src2x, src2y;
|
||||
int dst1x, dst1y;
|
||||
int dst2x, dst2y;
|
||||
int maskx, masky;
|
||||
cv::Mat dst2;
|
||||
|
||||
// src mat with roi
|
||||
cv::Mat src1_roi;
|
||||
cv::Mat src2_roi;
|
||||
cv::Mat mask_roi;
|
||||
cv::Mat dst1_roi;
|
||||
cv::Mat dst2_roi; // for two outputs
|
||||
cv::Mat dst2_roi;
|
||||
|
||||
// ocl dst mat for testing
|
||||
cv::ocl::oclMat gsrc1_whole;
|
||||
cv::ocl::oclMat gsrc2_whole;
|
||||
cv::ocl::oclMat gdst1_whole;
|
||||
cv::ocl::oclMat gdst2_whole; // for two outputs
|
||||
cv::ocl::oclMat gdst2_whole;
|
||||
cv::ocl::oclMat gmask_whole;
|
||||
|
||||
// ocl mat with roi
|
||||
cv::ocl::oclMat gsrc1;
|
||||
cv::ocl::oclMat gsrc2;
|
||||
cv::ocl::oclMat gdst1;
|
||||
cv::ocl::oclMat gdst2; // for two outputs
|
||||
cv::ocl::oclMat gmask;
|
||||
cv::ocl::oclMat gsrc1_roi;
|
||||
cv::ocl::oclMat gsrc2_roi;
|
||||
cv::ocl::oclMat gdst1_roi;
|
||||
cv::ocl::oclMat gdst2_roi;
|
||||
cv::ocl::oclMat gmask_roi;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
depth = GET_PARAM(0);
|
||||
cn = GET_PARAM(1);
|
||||
use_roi = GET_PARAM(2);
|
||||
const int type = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
src1 = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 2, 11, false);
|
||||
src2 = randomMat(rng, !use_roi ? src1.size() : randomSize(MIN_VALUE, MAX_VALUE), type, -1540, 1740, false);
|
||||
dst1 = randomMat(rng, !use_roi ? src1.size() : randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
dst2 = randomMat(rng, !use_roi ? src1.size() : randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
mask = randomMat(rng, !use_roi ? src1.size() : randomSize(MIN_VALUE, MAX_VALUE), CV_8UC1, 0, 2, false);
|
||||
|
||||
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
||||
|
||||
val = cv::Scalar(rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0),
|
||||
rng.uniform(-100.0, 100.0), rng.uniform(-100.0, 100.0));
|
||||
@ -234,65 +188,43 @@ PARAM_TEST_CASE(ArithmTestBase, int, int, bool)
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
const int type = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
Size roiSize = randomSize(1, MAX_VALUE);
|
||||
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(src1, src1_roi, roiSize, srcBorder, type, 2, 11);
|
||||
|
||||
src1x = rng.uniform(0, src1.cols - roicols);
|
||||
src1y = rng.uniform(0, src1.rows - roirows);
|
||||
src2x = rng.uniform(0, src2.cols - roicols);
|
||||
src2y = rng.uniform(0, src2.rows - roirows);
|
||||
Border src2Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(src2, src2_roi, roiSize, src2Border, type, -1540, 1740);
|
||||
|
||||
dst1x = rng.uniform(0, dst1.cols - roicols);
|
||||
dst1y = rng.uniform(0, dst1.rows - roirows);
|
||||
dst2x = rng.uniform(0, dst2.cols - roicols);
|
||||
dst2y = rng.uniform(0, dst2.rows - roirows);
|
||||
Border dst1Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(dst1, dst1_roi, roiSize, dst1Border, type, 5, 16);
|
||||
|
||||
maskx = rng.uniform(0, mask.cols - roicols);
|
||||
masky = rng.uniform(0, mask.rows - roirows);
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = src1.cols;
|
||||
roirows = src1.rows;
|
||||
src1x = src1y = 0;
|
||||
src2x = src2y = 0;
|
||||
dst1x = dst1y = 0;
|
||||
dst2x = dst2y = 0;
|
||||
maskx = masky = 0;
|
||||
}
|
||||
Border dst2Border = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(dst2, dst2_roi, roiSize, dst2Border, type, 5, 16);
|
||||
|
||||
src1_roi = src1(Rect(src1x, src1y, roicols, roirows));
|
||||
src2_roi = src2(Rect(src2x, src2y, roicols, roirows));
|
||||
mask_roi = mask(Rect(maskx, masky, roicols, roirows));
|
||||
dst1_roi = dst1(Rect(dst1x, dst1y, roicols, roirows));
|
||||
dst2_roi = dst2(Rect(dst2x, dst2y, roicols, roirows));
|
||||
Border maskBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(mask, mask_roi, roiSize, maskBorder, CV_8UC1, 0, 2);
|
||||
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
||||
|
||||
gdst1_whole = dst1;
|
||||
gdst1 = gdst1_whole(Rect(dst1x, dst1y, roicols, roirows));
|
||||
|
||||
gdst2_whole = dst2;
|
||||
gdst2 = gdst2_whole(Rect(dst2x, dst2y, roicols, roirows));
|
||||
|
||||
gsrc1 = src1_roi;
|
||||
gsrc2 = src2_roi;
|
||||
gmask = mask_roi;
|
||||
generateOclMat(gsrc1_whole, gsrc1_roi, src1, roiSize, srcBorder);
|
||||
generateOclMat(gsrc2_whole, gsrc2_roi, src2, roiSize, src2Border);
|
||||
generateOclMat(gdst1_whole, gdst1_roi, dst1, roiSize, dst1Border);
|
||||
generateOclMat(gdst2_whole, gdst2_roi, dst2, roiSize, dst2Border);
|
||||
generateOclMat(gmask_whole, gmask_roi, mask, roiSize, maskBorder);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.)
|
||||
{
|
||||
EXPECT_MAT_NEAR(dst1, Mat(gdst1_whole), threshold);
|
||||
EXPECT_MAT_NEAR(dst1_roi, Mat(gdst1), threshold);
|
||||
EXPECT_MAT_NEAR(dst1_roi, Mat(gdst1_roi), threshold);
|
||||
}
|
||||
|
||||
void Near1(double threshold = 0.)
|
||||
{
|
||||
EXPECT_MAT_NEAR(dst2, Mat(gdst2_whole), threshold);
|
||||
EXPECT_MAT_NEAR(dst2_roi, Mat(gdst2), threshold);
|
||||
EXPECT_MAT_NEAR(dst2_roi, Mat(gdst2_roi), threshold);
|
||||
}
|
||||
};
|
||||
|
||||
@ -307,7 +239,7 @@ TEST_P(Exp, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::exp(src1_roi, dst1_roi);
|
||||
cv::ocl::exp(gsrc1, gdst1);
|
||||
cv::ocl::exp(gsrc1_roi, gdst1_roi);
|
||||
|
||||
Near(2);
|
||||
}
|
||||
@ -324,7 +256,7 @@ TEST_P(Log, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::log(src1_roi, dst1_roi);
|
||||
cv::ocl::log(gsrc1, gdst1);
|
||||
cv::ocl::log(gsrc1_roi, gdst1_roi);
|
||||
Near(1);
|
||||
}
|
||||
}
|
||||
@ -340,7 +272,7 @@ TEST_P(Add, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::add(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::add(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::add(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -352,7 +284,7 @@ TEST_P(Add, Mat_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::add(src1_roi, src2_roi, dst1_roi, mask_roi);
|
||||
cv::ocl::add(gsrc1, gsrc2, gdst1, gmask);
|
||||
cv::ocl::add(gsrc1_roi, gsrc2_roi, gdst1_roi, gmask_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -364,7 +296,7 @@ TEST_P(Add, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::add(src1_roi, val, dst1_roi);
|
||||
cv::ocl::add(gsrc1, val, gdst1);
|
||||
cv::ocl::add(gsrc1_roi, val, gdst1_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -376,7 +308,7 @@ TEST_P(Add, Scalar_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::add(src1_roi, val, dst1_roi, mask_roi);
|
||||
cv::ocl::add(gsrc1, val, gdst1, gmask);
|
||||
cv::ocl::add(gsrc1_roi, val, gdst1_roi, gmask_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -392,7 +324,7 @@ TEST_P(Sub, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::subtract(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::subtract(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::subtract(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
|
||||
Near(0);
|
||||
}
|
||||
@ -405,7 +337,7 @@ TEST_P(Sub, Mat_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::subtract(src1_roi, src2_roi, dst1_roi, mask_roi);
|
||||
cv::ocl::subtract(gsrc1, gsrc2, gdst1, gmask);
|
||||
cv::ocl::subtract(gsrc1_roi, gsrc2_roi, gdst1_roi, gmask_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -417,7 +349,7 @@ TEST_P(Sub, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::subtract(src1_roi, val, dst1_roi);
|
||||
cv::ocl::subtract(gsrc1, val, gdst1);
|
||||
cv::ocl::subtract(gsrc1_roi, val, gdst1_roi);
|
||||
|
||||
Near(1e-5);
|
||||
}
|
||||
@ -430,7 +362,7 @@ TEST_P(Sub, Scalar_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::subtract(src1_roi, val, dst1_roi, mask_roi);
|
||||
cv::ocl::subtract(gsrc1, val, gdst1, gmask);
|
||||
cv::ocl::subtract(gsrc1_roi, val, gdst1_roi, gmask_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -446,7 +378,7 @@ TEST_P(Mul, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::multiply(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::multiply(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::multiply(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -458,9 +390,9 @@ TEST_P(Mul, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::multiply(val[0], src1_roi, dst1_roi);
|
||||
cv::ocl::multiply(val[0], gsrc1, gdst1);
|
||||
cv::ocl::multiply(val[0], gsrc1_roi, gdst1_roi);
|
||||
|
||||
Near(gdst1.depth() >= CV_32F ? 1e-3 : 1);
|
||||
Near(gdst1_roi.depth() >= CV_32F ? 1e-3 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,9 +403,9 @@ TEST_P(Mul, Mat_Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::multiply(src1_roi, src2_roi, dst1_roi, val[0]);
|
||||
cv::ocl::multiply(gsrc1, gsrc2, gdst1, val[0]);
|
||||
cv::ocl::multiply(gsrc1_roi, gsrc2_roi, gdst1_roi, val[0]);
|
||||
|
||||
Near(gdst1.depth() >= CV_32F ? 1e-3 : 1);
|
||||
Near(gdst1_roi.depth() >= CV_32F ? 1e-3 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,7 +420,7 @@ TEST_P(Div, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::divide(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::divide(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::divide(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(1);
|
||||
}
|
||||
}
|
||||
@ -500,9 +432,9 @@ TEST_P(Div, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::divide(val[0], src1_roi, dst1_roi);
|
||||
cv::ocl::divide(val[0], gsrc1, gdst1);
|
||||
cv::ocl::divide(val[0], gsrc1_roi, gdst1_roi);
|
||||
|
||||
Near(gdst1.depth() >= CV_32F ? 1e-3 : 1);
|
||||
Near(gdst1_roi.depth() >= CV_32F ? 1e-3 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,9 +445,9 @@ TEST_P(Div, Mat_Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::divide(src1_roi, src2_roi, dst1_roi, val[0]);
|
||||
cv::ocl::divide(gsrc1, gsrc2, gdst1, val[0]);
|
||||
cv::ocl::divide(gsrc1_roi, gsrc2_roi, gdst1_roi, val[0]);
|
||||
|
||||
Near(gdst1.depth() >= CV_32F ? 1e-3 : 1);
|
||||
Near(gdst1_roi.depth() >= CV_32F ? 1e-3 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,7 +462,7 @@ TEST_P(Absdiff, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::absdiff(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::absdiff(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::absdiff(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -542,7 +474,7 @@ TEST_P(Absdiff, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::absdiff(src1_roi, val, dst1_roi);
|
||||
cv::ocl::absdiff(gsrc1, val, gdst1);
|
||||
cv::ocl::absdiff(gsrc1_roi, val, gdst1_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -558,7 +490,7 @@ TEST_P(CartToPolar, angleInDegree)
|
||||
random_roi();
|
||||
|
||||
cv::cartToPolar(src1_roi, src2_roi, dst1_roi, dst2_roi, true);
|
||||
cv::ocl::cartToPolar(gsrc1, gsrc2, gdst1, gdst2, true);
|
||||
cv::ocl::cartToPolar(gsrc1_roi, gsrc2_roi, gdst1_roi, gdst2_roi, true);
|
||||
Near(.5);
|
||||
Near1(.5);
|
||||
}
|
||||
@ -571,7 +503,7 @@ TEST_P(CartToPolar, angleInRadians)
|
||||
random_roi();
|
||||
|
||||
cv::cartToPolar(src1_roi, src2_roi, dst1_roi, dst2_roi);
|
||||
cv::ocl::cartToPolar(gsrc1, gsrc2, gdst1, gdst2);
|
||||
cv::ocl::cartToPolar(gsrc1_roi, gsrc2_roi, gdst1_roi, gdst2_roi);
|
||||
Near(.5);
|
||||
Near1(.5);
|
||||
}
|
||||
@ -588,7 +520,7 @@ TEST_P(PolarToCart, angleInDegree)
|
||||
random_roi();
|
||||
|
||||
cv::polarToCart(src1_roi, src2_roi, dst1_roi, dst2_roi, true);
|
||||
cv::ocl::polarToCart(gsrc1, gsrc2, gdst1, gdst2, true);
|
||||
cv::ocl::polarToCart(gsrc1_roi, gsrc2_roi, gdst1_roi, gdst2_roi, true);
|
||||
|
||||
Near(.5);
|
||||
Near1(.5);
|
||||
@ -602,7 +534,7 @@ TEST_P(PolarToCart, angleInRadians)
|
||||
random_roi();
|
||||
|
||||
cv::polarToCart(src1_roi, src2_roi, dst1_roi, dst2_roi);
|
||||
cv::ocl::polarToCart(gsrc1, gsrc2, gdst1, gdst2);
|
||||
cv::ocl::polarToCart(gsrc1_roi, gsrc2_roi, gdst1_roi, gdst2_roi);
|
||||
|
||||
Near(.5);
|
||||
Near1(.5);
|
||||
@ -620,7 +552,7 @@ TEST_P(Magnitude, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::magnitude(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::magnitude(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::magnitude(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(depth == CV_64F ? 1e-5 : 1e-2);
|
||||
}
|
||||
}
|
||||
@ -636,7 +568,7 @@ TEST_P(Transpose, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::transpose(src1_roi, dst1_roi);
|
||||
cv::ocl::transpose(gsrc1, gdst1);
|
||||
cv::ocl::transpose(gsrc1_roi, gdst1_roi);
|
||||
|
||||
Near(1e-5);
|
||||
}
|
||||
@ -644,35 +576,23 @@ TEST_P(Transpose, Mat)
|
||||
|
||||
TEST_P(Transpose, SquareInplace)
|
||||
{
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
int value = randomInt(MIN_VALUE, MAX_VALUE);
|
||||
src1 = randomMat(rng, Size(value, value), CV_MAKE_TYPE(depth, cn), 5, 16, false);
|
||||
|
||||
if (use_roi)
|
||||
{
|
||||
roirows = roicols = randomInt(1, src1.cols);
|
||||
|
||||
src1x = randomInt(0, src1.cols - roicols);
|
||||
src1y = randomInt(0, src1.rows - roirows);
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = roirows = src1.cols;
|
||||
src1x = src1y = 0;
|
||||
}
|
||||
|
||||
Rect r(src1x, src1y, roicols, roirows);
|
||||
src1_roi = src1(r);
|
||||
gdst1_whole = src1;
|
||||
gdst1 = gdst1_whole(r);
|
||||
const int type = CV_MAKE_TYPE(depth, cn);
|
||||
|
||||
for (int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
cv::transpose(src1_roi, src1_roi);
|
||||
cv::ocl::transpose(gdst1, gdst1);
|
||||
Size roiSize = randomSize(1, MAX_VALUE);
|
||||
roiSize.height = roiSize.width; // make it square
|
||||
|
||||
EXPECT_MAT_NEAR(src1, Mat(gdst1_whole), 0.0);
|
||||
EXPECT_MAT_NEAR(src1_roi, Mat(gdst1), 0.0);
|
||||
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
|
||||
randomSubMat(src1, src1_roi, roiSize, srcBorder, type, 5, 16);
|
||||
|
||||
generateOclMat(gsrc1_whole, gsrc1_roi, src1, roiSize, srcBorder);
|
||||
|
||||
cv::transpose(src1_roi, src1_roi);
|
||||
cv::ocl::transpose(gsrc1_roi, gsrc1_roi);
|
||||
|
||||
EXPECT_MAT_NEAR(src1, Mat(gsrc1_whole), 0.0);
|
||||
EXPECT_MAT_NEAR(src1_roi, Mat(gsrc1_roi), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -687,7 +607,7 @@ TEST_P(Flip, X)
|
||||
random_roi();
|
||||
|
||||
cv::flip(src1_roi, dst1_roi, 0);
|
||||
cv::ocl::flip(gsrc1, gdst1, 0);
|
||||
cv::ocl::flip(gsrc1_roi, gdst1_roi, 0);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -699,7 +619,7 @@ TEST_P(Flip, Y)
|
||||
random_roi();
|
||||
|
||||
cv::flip(src1_roi, dst1_roi, 1);
|
||||
cv::ocl::flip(gsrc1, gdst1, 1);
|
||||
cv::ocl::flip(gsrc1_roi, gdst1_roi, 1);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -711,7 +631,7 @@ TEST_P(Flip, BOTH)
|
||||
random_roi();
|
||||
|
||||
cv::flip(src1_roi, dst1_roi, -1);
|
||||
cv::ocl::flip(gsrc1, gdst1, -1);
|
||||
cv::ocl::flip(gsrc1_roi, gdst1_roi, -1);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -739,12 +659,12 @@ TEST_P(MinMax, MAT)
|
||||
{
|
||||
signed char val = src1_roi.at<signed char>(i, j);
|
||||
if (val < minVal) minVal = val;
|
||||
else if (val > maxVal) maxVal = val;
|
||||
if (val > maxVal) maxVal = val;
|
||||
}
|
||||
}
|
||||
|
||||
double minVal_, maxVal_;
|
||||
cv::ocl::minMax(gsrc1, &minVal_, &maxVal_);
|
||||
cv::ocl::minMax(gsrc1_roi, &minVal_, &maxVal_);
|
||||
|
||||
EXPECT_DOUBLE_EQ(minVal_, minVal);
|
||||
EXPECT_DOUBLE_EQ(maxVal_, maxVal);
|
||||
@ -777,7 +697,7 @@ TEST_P(MinMax, MASK)
|
||||
}
|
||||
|
||||
double minVal_, maxVal_;
|
||||
cv::ocl::minMax(gsrc1, &minVal_, &maxVal_, gmask);
|
||||
cv::ocl::minMax(gsrc1_roi, &minVal_, &maxVal_, gmask_roi);
|
||||
|
||||
EXPECT_DOUBLE_EQ(minVal, minVal_);
|
||||
EXPECT_DOUBLE_EQ(maxVal, maxVal_);
|
||||
@ -825,7 +745,7 @@ TEST_P(MinMaxLoc, MAT)
|
||||
|
||||
double minVal_, maxVal_;
|
||||
cv::Point minLoc_, maxLoc_;
|
||||
cv::ocl::minMaxLoc(gsrc1, &minVal_, &maxVal_, &minLoc_, &maxLoc_, cv::ocl::oclMat());
|
||||
cv::ocl::minMaxLoc(gsrc1_roi, &minVal_, &maxVal_, &minLoc_, &maxLoc_, cv::ocl::oclMat());
|
||||
|
||||
double error0 = 0., error1 = 0., minlocVal = 0., minlocVal_ = 0., maxlocVal = 0., maxlocVal_ = 0.;
|
||||
if (depth == 0)
|
||||
@ -938,7 +858,7 @@ TEST_P(MinMaxLoc, MASK)
|
||||
|
||||
double minVal_, maxVal_;
|
||||
cv::Point minLoc_, maxLoc_;
|
||||
cv::ocl::minMaxLoc(gsrc1, &minVal_, &maxVal_, &minLoc_, &maxLoc_, gmask);
|
||||
cv::ocl::minMaxLoc(gsrc1_roi, &minVal_, &maxVal_, &minLoc_, &maxLoc_, gmask_roi);
|
||||
|
||||
double error0 = 0., error1 = 0., minlocVal = 0., minlocVal_ = 0., maxlocVal = 0., maxlocVal_ = 0.;
|
||||
if (minLoc_.x == -1 || minLoc_.y == -1 || maxLoc_.x == -1 || maxLoc_.y == -1) continue;
|
||||
@ -1027,7 +947,7 @@ TEST_P(Sum, MAT)
|
||||
random_roi();
|
||||
|
||||
Scalar cpures = cv::sum(src1_roi);
|
||||
Scalar gpures = cv::ocl::sum(gsrc1);
|
||||
Scalar gpures = cv::ocl::sum(gsrc1_roi);
|
||||
|
||||
// check results
|
||||
EXPECT_NEAR(cpures[0], gpures[0], 0.1);
|
||||
@ -1085,7 +1005,7 @@ TEST_P(SqrSum, MAT)
|
||||
CV_Assert(func != 0);
|
||||
|
||||
Scalar cpures = func(src1_roi);
|
||||
Scalar gpures = cv::ocl::sqrSum(gsrc1);
|
||||
Scalar gpures = cv::ocl::sqrSum(gsrc1_roi);
|
||||
|
||||
// check results
|
||||
EXPECT_NEAR(cpures[0], gpures[0], 1.0);
|
||||
@ -1141,7 +1061,7 @@ TEST_P(AbsSum, MAT)
|
||||
CV_Assert(func != 0);
|
||||
|
||||
Scalar cpures = func(src1_roi);
|
||||
Scalar gpures = cv::ocl::absSum(gsrc1);
|
||||
Scalar gpures = cv::ocl::absSum(gsrc1_roi);
|
||||
|
||||
// check results
|
||||
EXPECT_NEAR(cpures[0], gpures[0], 0.1);
|
||||
@ -1161,7 +1081,7 @@ TEST_P(CountNonZero, MAT)
|
||||
{
|
||||
random_roi();
|
||||
int cpures = cv::countNonZero(src1_roi);
|
||||
int gpures = cv::ocl::countNonZero(gsrc1);
|
||||
int gpures = cv::ocl::countNonZero(gsrc1_roi);
|
||||
|
||||
EXPECT_DOUBLE_EQ((double)cpures, (double)gpures);
|
||||
}
|
||||
@ -1177,7 +1097,7 @@ TEST_P(Phase, angleInDegrees)
|
||||
{
|
||||
random_roi();
|
||||
cv::phase(src1_roi, src2_roi, dst1_roi, true);
|
||||
cv::ocl::phase(gsrc1, gsrc2, gdst1, true);
|
||||
cv::ocl::phase(gsrc1_roi, gsrc2_roi, gdst1_roi, true);
|
||||
|
||||
Near(1e-2);
|
||||
}
|
||||
@ -1189,7 +1109,7 @@ TEST_P(Phase, angleInRadians)
|
||||
{
|
||||
random_roi();
|
||||
cv::phase(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::phase(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::phase(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
|
||||
Near(1e-2);
|
||||
}
|
||||
@ -1206,7 +1126,7 @@ TEST_P(Bitwise_and, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_and(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::bitwise_and(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::bitwise_and(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -1218,7 +1138,7 @@ TEST_P(Bitwise_and, Mat_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_and(src1_roi, src2_roi, dst1_roi, mask_roi);
|
||||
cv::ocl::bitwise_and(gsrc1, gsrc2, gdst1, gmask);
|
||||
cv::ocl::bitwise_and(gsrc1_roi, gsrc2_roi, gdst1_roi, gmask_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -1230,7 +1150,7 @@ TEST_P(Bitwise_and, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_and(src1_roi, val, dst1_roi);
|
||||
cv::ocl::bitwise_and(gsrc1, val, gdst1);
|
||||
cv::ocl::bitwise_and(gsrc1_roi, val, gdst1_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -1242,7 +1162,7 @@ TEST_P(Bitwise_and, Scalar_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_and(src1_roi, val, dst1_roi, mask_roi);
|
||||
cv::ocl::bitwise_and(gsrc1, val, gdst1, gmask);
|
||||
cv::ocl::bitwise_and(gsrc1_roi, val, gdst1_roi, gmask_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -1258,7 +1178,7 @@ TEST_P(Bitwise_or, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_or(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::bitwise_or(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::bitwise_or(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -1270,7 +1190,7 @@ TEST_P(Bitwise_or, Mat_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_or(src1_roi, src2_roi, dst1_roi, mask_roi);
|
||||
cv::ocl::bitwise_or(gsrc1, gsrc2, gdst1, gmask);
|
||||
cv::ocl::bitwise_or(gsrc1_roi, gsrc2_roi, gdst1_roi, gmask_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -1282,7 +1202,7 @@ TEST_P(Bitwise_or, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_or(src1_roi, val, dst1_roi);
|
||||
cv::ocl::bitwise_or(gsrc1, val, gdst1);
|
||||
cv::ocl::bitwise_or(gsrc1_roi, val, gdst1_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -1294,7 +1214,7 @@ TEST_P(Bitwise_or, Scalar_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_or(src1_roi, val, dst1_roi, mask_roi);
|
||||
cv::ocl::bitwise_or(gsrc1, val, gdst1, gmask);
|
||||
cv::ocl::bitwise_or(gsrc1_roi, val, gdst1_roi, gmask_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -1310,7 +1230,7 @@ TEST_P(Bitwise_xor, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_xor(src1_roi, src2_roi, dst1_roi);
|
||||
cv::ocl::bitwise_xor(gsrc1, gsrc2, gdst1);
|
||||
cv::ocl::bitwise_xor(gsrc1_roi, gsrc2_roi, gdst1_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -1322,7 +1242,7 @@ TEST_P(Bitwise_xor, Mat_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_xor(src1_roi, src2_roi, dst1_roi, mask_roi);
|
||||
cv::ocl::bitwise_xor(gsrc1, gsrc2, gdst1, gmask);
|
||||
cv::ocl::bitwise_xor(gsrc1_roi, gsrc2_roi, gdst1_roi, gmask_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -1334,7 +1254,7 @@ TEST_P(Bitwise_xor, Scalar)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_xor(src1_roi, val, dst1_roi);
|
||||
cv::ocl::bitwise_xor(gsrc1, val, gdst1);
|
||||
cv::ocl::bitwise_xor(gsrc1_roi, val, gdst1_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -1346,7 +1266,7 @@ TEST_P(Bitwise_xor, Scalar_Mask)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_xor(src1_roi, val, dst1_roi, mask_roi);
|
||||
cv::ocl::bitwise_xor(gsrc1, val, gdst1, gmask);
|
||||
cv::ocl::bitwise_xor(gsrc1_roi, val, gdst1_roi, gmask_roi);
|
||||
Near(1e-5);
|
||||
}
|
||||
}
|
||||
@ -1362,7 +1282,7 @@ TEST_P(Bitwise_not, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::bitwise_not(src1_roi, dst1_roi);
|
||||
cv::ocl::bitwise_not(gsrc1, gdst1);
|
||||
cv::ocl::bitwise_not(gsrc1_roi, gdst1_roi);
|
||||
Near(0);
|
||||
}
|
||||
}
|
||||
@ -1382,7 +1302,7 @@ TEST_P(Compare, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::compare(src1_roi, src2_roi, dst1_roi, cmp_codes[i]);
|
||||
cv::ocl::compare(gsrc1, gsrc2, gdst1, cmp_codes[i]);
|
||||
cv::ocl::compare(gsrc1_roi, gsrc2_roi, gdst1_roi, cmp_codes[i]);
|
||||
|
||||
Near(0);
|
||||
}
|
||||
@ -1399,7 +1319,7 @@ TEST_P(Pow, Mat)
|
||||
random_roi();
|
||||
double p = 4.5;
|
||||
cv::pow(src1_roi, p, dst1_roi);
|
||||
cv::ocl::pow(gsrc1, p, gdst1);
|
||||
cv::ocl::pow(gsrc1_roi, p, gdst1_roi);
|
||||
Near(1);
|
||||
}
|
||||
}
|
||||
@ -1417,7 +1337,7 @@ TEST_P(AddWeighted, Mat)
|
||||
const double alpha = 2.0, beta = 1.0, gama = 3.0;
|
||||
|
||||
cv::addWeighted(src1_roi, alpha, src2_roi, beta, gama, dst1_roi);
|
||||
cv::ocl::addWeighted(gsrc1, alpha, gsrc2, beta, gama, gdst1);
|
||||
cv::ocl::addWeighted(gsrc1_roi, alpha, gsrc2_roi, beta, gama, gdst1_roi);
|
||||
|
||||
Near(1e-5);
|
||||
}
|
||||
@ -1434,7 +1354,7 @@ TEST_P(SetIdentity, Mat)
|
||||
random_roi();
|
||||
|
||||
cv::setIdentity(dst1_roi, val);
|
||||
cv::ocl::setIdentity(gdst1, val);
|
||||
cv::ocl::setIdentity(gdst1_roi, val);
|
||||
|
||||
Near(0);
|
||||
}
|
||||
@ -1454,7 +1374,7 @@ TEST_P(MeanStdDev, Mat)
|
||||
Scalar gpu_mean, gpu_stddev;
|
||||
|
||||
cv::meanStdDev(src1_roi, cpu_mean, cpu_stddev);
|
||||
cv::ocl::meanStdDev(gsrc1, gpu_mean, gpu_stddev);
|
||||
cv::ocl::meanStdDev(gsrc1_roi, gpu_mean, gpu_stddev);
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
@ -1480,7 +1400,7 @@ TEST_P(Norm, NORM_INF)
|
||||
type |= NORM_RELATIVE;
|
||||
|
||||
const double cpuRes = cv::norm(src1_roi, src2_roi, type);
|
||||
const double gpuRes = cv::ocl::norm(gsrc1, gsrc2, type);
|
||||
const double gpuRes = cv::ocl::norm(gsrc1_roi, gsrc2_roi, type);
|
||||
|
||||
EXPECT_NEAR(cpuRes, gpuRes, 0.1);
|
||||
}
|
||||
@ -1498,7 +1418,7 @@ TEST_P(Norm, NORM_L1)
|
||||
type |= NORM_RELATIVE;
|
||||
|
||||
const double cpuRes = cv::norm(src1_roi, src2_roi, type);
|
||||
const double gpuRes = cv::ocl::norm(gsrc1, gsrc2, type);
|
||||
const double gpuRes = cv::ocl::norm(gsrc1_roi, gsrc2_roi, type);
|
||||
|
||||
EXPECT_NEAR(cpuRes, gpuRes, 0.1);
|
||||
}
|
||||
@ -1516,7 +1436,7 @@ TEST_P(Norm, NORM_L2)
|
||||
type |= NORM_RELATIVE;
|
||||
|
||||
const double cpuRes = cv::norm(src1_roi, src2_roi, type);
|
||||
const double gpuRes = cv::ocl::norm(gsrc1, gsrc2, type);
|
||||
const double gpuRes = cv::ocl::norm(gsrc1_roi, gsrc2_roi, type);
|
||||
|
||||
EXPECT_NEAR(cpuRes, gpuRes, 0.1);
|
||||
}
|
||||
|
@ -85,9 +85,7 @@ PARAM_TEST_CASE(mog, UseGray, LearningRate, bool)
|
||||
virtual void SetUp()
|
||||
{
|
||||
useGray = GET_PARAM(0);
|
||||
|
||||
learningRate = GET_PARAM(1);
|
||||
|
||||
useRoi = GET_PARAM(2);
|
||||
}
|
||||
};
|
||||
@ -103,7 +101,7 @@ TEST_P(mog, Update)
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
cv::ocl::MOG mog;
|
||||
cv::ocl::oclMat foreground = createMat_ocl(frame.size(), CV_8UC1, useRoi);
|
||||
cv::ocl::oclMat foreground = createMat_ocl(rng, frame.size(), CV_8UC1, useRoi);
|
||||
|
||||
cv::BackgroundSubtractorMOG mog_gold;
|
||||
cv::Mat foreground_gold;
|
||||
@ -120,7 +118,7 @@ TEST_P(mog, Update)
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
mog(loadMat_ocl(frame, useRoi), foreground, (float)learningRate);
|
||||
mog(loadMat_ocl(rng, frame, useRoi), foreground, (float)learningRate);
|
||||
|
||||
mog_gold(frame, foreground_gold, learningRate);
|
||||
|
||||
@ -165,7 +163,7 @@ TEST_P(mog2, Update)
|
||||
|
||||
cv::ocl::MOG2 mog2;
|
||||
mog2.bShadowDetection = detectShadow;
|
||||
cv::ocl::oclMat foreground = createMat_ocl(frame.size(), CV_8UC1, useRoi);
|
||||
cv::ocl::oclMat foreground = createMat_ocl(rng, frame.size(), CV_8UC1, useRoi);
|
||||
|
||||
cv::BackgroundSubtractorMOG2 mog2_gold;
|
||||
mog2_gold.set("detectShadows", detectShadow);
|
||||
@ -183,7 +181,7 @@ TEST_P(mog2, Update)
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
mog2(loadMat_ocl(frame, useRoi), foreground);
|
||||
mog2(loadMat_ocl(rng, frame, useRoi), foreground);
|
||||
|
||||
mog2_gold(frame, foreground_gold);
|
||||
|
||||
@ -218,12 +216,12 @@ TEST_P(mog2, getBackgroundImage)
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
mog2(loadMat_ocl(frame, useRoi), foreground);
|
||||
mog2(loadMat_ocl(rng, frame, useRoi), foreground);
|
||||
|
||||
mog2_gold(frame, foreground_gold);
|
||||
}
|
||||
|
||||
cv::ocl::oclMat background = createMat_ocl(frame.size(), frame.type(), useRoi);
|
||||
cv::ocl::oclMat background = createMat_ocl(rng, frame.size(), frame.type(), useRoi);
|
||||
mog2.getBackgroundImage(background);
|
||||
|
||||
cv::Mat background_gold;
|
||||
|
@ -72,8 +72,6 @@ namespace
|
||||
queryDescCount = 300; // must be even number because we split train data in some cases in two
|
||||
countFactor = 4; // do not change it
|
||||
|
||||
cv::RNG &rng = cvtest::TS::ptr()->get_rng();
|
||||
|
||||
cv::Mat queryBuf, trainBuf;
|
||||
|
||||
// Generate query descriptors randomly.
|
||||
|
@ -46,10 +46,10 @@
|
||||
#include "test_precomp.hpp"
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cv;
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
PARAM_TEST_CASE(StereoMatchBM, int, int)
|
||||
{
|
||||
int n_disp;
|
||||
|
@ -91,7 +91,6 @@ PARAM_TEST_CASE(FilterTestBase,
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(2, mat1.cols);
|
||||
roirows = rng.uniform(2, mat1.rows);
|
||||
src1x = rng.uniform(0, mat1.cols - roicols);
|
||||
@ -201,7 +200,6 @@ struct ErodeDilate : FilterTestBase
|
||||
type = GET_PARAM(0);
|
||||
iterations = GET_PARAM(3);
|
||||
Init(type);
|
||||
// rng.fill(kernel, cv::RNG::UNIFORM, cv::Scalar::all(0), cv::Scalar::all(3));
|
||||
kernel = randomMat(Size(3, 3), CV_8UC1, 0, 3);
|
||||
}
|
||||
|
||||
@ -304,7 +302,6 @@ struct GaussianBlur : FilterTestBase
|
||||
ksize = GET_PARAM(1);
|
||||
bordertype = GET_PARAM(3);
|
||||
Init(type);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
sigma1 = rng.uniform(0.1, 1.0);
|
||||
sigma2 = rng.uniform(0.1, 1.0);
|
||||
}
|
||||
@ -368,7 +365,6 @@ struct Bilateral : FilterTestBase
|
||||
ksize = GET_PARAM(1);
|
||||
bordertype = GET_PARAM(3);
|
||||
Init(type);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
sigmacolor = rng.uniform(20, 100);
|
||||
sigmaspace = rng.uniform(10, 40);
|
||||
}
|
||||
|
@ -351,33 +351,32 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
|
||||
type3 = GET_PARAM(2);
|
||||
type4 = GET_PARAM(3);
|
||||
type5 = GET_PARAM(4);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
double min = 1, max = 20;
|
||||
|
||||
if(type1 != nulltype)
|
||||
{
|
||||
mat1 = randomMat(rng, size, type1, min, max, false);
|
||||
mat1 = randomMat(size, type1, min, max, false);
|
||||
clmat1 = mat1;
|
||||
}
|
||||
if(type2 != nulltype)
|
||||
{
|
||||
mat2 = randomMat(rng, size, type2, min, max, false);
|
||||
mat2 = randomMat(size, type2, min, max, false);
|
||||
clmat2 = mat2;
|
||||
}
|
||||
if(type3 != nulltype)
|
||||
{
|
||||
dst = randomMat(rng, size, type3, min, max, false);
|
||||
dst = randomMat(size, type3, min, max, false);
|
||||
cldst = dst;
|
||||
}
|
||||
if(type4 != nulltype)
|
||||
{
|
||||
dst1 = randomMat(rng, size, type4, min, max, false);
|
||||
dst1 = randomMat(size, type4, min, max, false);
|
||||
cldst1 = dst1;
|
||||
}
|
||||
if(type5 != nulltype)
|
||||
{
|
||||
mask = randomMat(rng, size, CV_8UC1, 0, 2, false);
|
||||
mask = randomMat(size, CV_8UC1, 0, 2, false);
|
||||
cv::threshold(mask, mask, 0.5, 255., type5);
|
||||
clmask = mask;
|
||||
}
|
||||
@ -388,7 +387,6 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat1.cols);
|
||||
roirows = rng.uniform(1, mat1.rows);
|
||||
src1x = rng.uniform(0, mat1.cols - roicols);
|
||||
@ -482,7 +480,6 @@ struct CopyMakeBorder : ImgprocTestBase {};
|
||||
TEST_P(CopyMakeBorder, Mat)
|
||||
{
|
||||
int bordertype[] = {cv::BORDER_CONSTANT, cv::BORDER_REPLICATE, cv::BORDER_REFLECT, cv::BORDER_WRAP, cv::BORDER_REFLECT_101};
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
int top = rng.uniform(0, 10);
|
||||
int bottom = rng.uniform(0, 10);
|
||||
int left = rng.uniform(0, 10);
|
||||
@ -646,22 +643,17 @@ PARAM_TEST_CASE(WarpTestBase, MatType, int)
|
||||
virtual void SetUp()
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
//dsize = GET_PARAM(1);
|
||||
interpolation = GET_PARAM(1);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
size = cv::Size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src_roicols = rng.uniform(1, mat1.cols);
|
||||
src_roirows = rng.uniform(1, mat1.rows);
|
||||
dst_roicols = rng.uniform(1, dst.cols);
|
||||
@ -810,23 +802,22 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
interpolation = GET_PARAM(3);
|
||||
bordertype = GET_PARAM(4);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size srcSize = cv::Size(MWIDTH, MHEIGHT);
|
||||
cv::Size map1Size = cv::Size(MWIDTH, MHEIGHT);
|
||||
double min = 5, max = 16;
|
||||
|
||||
if(srcType != nulltype)
|
||||
{
|
||||
src = randomMat(rng, srcSize, srcType, min, max, false);
|
||||
src = randomMat(srcSize, srcType, min, max, false);
|
||||
}
|
||||
if((map1Type == CV_16SC2 && map2Type == nulltype) || (map1Type == CV_32FC2 && map2Type == nulltype))
|
||||
{
|
||||
map1 = randomMat(rng, map1Size, map1Type, min, max, false);
|
||||
map1 = randomMat(map1Size, map1Type, min, max, false);
|
||||
}
|
||||
else if (map1Type == CV_32FC1 && map2Type == CV_32FC1)
|
||||
{
|
||||
map1 = randomMat(rng, map1Size, map1Type, min, max, false);
|
||||
map2 = randomMat(rng, map1Size, map1Type, min, max, false);
|
||||
map1 = randomMat(map1Size, map1Type, min, max, false);
|
||||
map2 = randomMat(map1Size, map1Type, min, max, false);
|
||||
}
|
||||
|
||||
else
|
||||
@ -835,7 +826,7 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
return;
|
||||
}
|
||||
|
||||
dst = randomMat(rng, map1Size, srcType, min, max, false);
|
||||
dst = randomMat(map1Size, srcType, min, max, false);
|
||||
switch (src.channels())
|
||||
{
|
||||
case 1:
|
||||
@ -855,8 +846,6 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
}
|
||||
void random_roi()
|
||||
{
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
dst_roicols = rng.uniform(1, dst.cols);
|
||||
dst_roirows = rng.uniform(1, dst.rows);
|
||||
|
||||
@ -966,8 +955,6 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
|
||||
fy = GET_PARAM(3);
|
||||
interpolation = GET_PARAM(4);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
if(dsize == cv::Size() && !(fx > 0 && fy > 0))
|
||||
@ -982,8 +969,8 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
|
||||
dsize.height = (int)(size.height * fy);
|
||||
}
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, dsize, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(dsize, type, 5, 16, false);
|
||||
|
||||
}
|
||||
|
||||
@ -991,7 +978,6 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src_roicols = rng.uniform(1, mat1.cols);
|
||||
src_roirows = rng.uniform(1, mat1.rows);
|
||||
dst_roicols = (int)(src_roicols * fx);
|
||||
@ -1082,18 +1068,16 @@ PARAM_TEST_CASE(Threshold, MatType, ThreshOp)
|
||||
type = GET_PARAM(0);
|
||||
threshOp = GET_PARAM(1);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat1.cols);
|
||||
roirows = rng.uniform(1, mat1.rows);
|
||||
src1x = rng.uniform(0, mat1.cols - roicols);
|
||||
@ -1179,22 +1163,18 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria)
|
||||
sr = GET_PARAM(3);
|
||||
crit = GET_PARAM(4);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
// MWIDTH=256, MHEIGHT=256. defined in utility.hpp
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
|
||||
src = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
dstCoor = randomMat(rng, size, typeCoor, 5, 16, false);
|
||||
src = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
dstCoor = randomMat(size, typeCoor, 5, 16, false);
|
||||
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
//randomize ROI
|
||||
roicols = rng.uniform(1, src.cols);
|
||||
roirows = rng.uniform(1, src.rows);
|
||||
@ -1307,18 +1287,15 @@ PARAM_TEST_CASE(histTestBase, MatType, MatType)
|
||||
{
|
||||
type_src = GET_PARAM(0);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
|
||||
src = randomMat(rng, size, type_src, 0, 256, false);
|
||||
src = randomMat(size, type_src, 0, 256, false);
|
||||
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
//randomize ROI
|
||||
roicols = rng.uniform(1, src.cols);
|
||||
roirows = rng.uniform(1, src.rows);
|
||||
@ -1372,8 +1349,7 @@ PARAM_TEST_CASE(CLAHE, cv::Size, double)
|
||||
gridSize = GET_PARAM(0);
|
||||
clipLimit = GET_PARAM(1);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src = randomMat(rng, cv::Size(MWIDTH, MHEIGHT), CV_8UC1, 0, 256, false);
|
||||
src = randomMat(cv::Size(MWIDTH, MHEIGHT), CV_8UC1, 0, 256, false);
|
||||
g_src.upload(src);
|
||||
}
|
||||
};
|
||||
@ -1425,19 +1401,15 @@ PARAM_TEST_CASE(ConvolveTestBase, MatType, bool)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
mat2 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
dst1 = randomMat(rng, size, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
mat2 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
dst1 = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
void random_roi()
|
||||
{
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
roicols = rng.uniform(1, mat1.cols);
|
||||
@ -1542,7 +1514,7 @@ PARAM_TEST_CASE(ColumnSum, cv::Size)
|
||||
|
||||
TEST_P(ColumnSum, Accuracy)
|
||||
{
|
||||
cv::Mat src = randomMat(size, CV_32FC1);
|
||||
cv::Mat src = randomMat(size, CV_32FC1, 0, 255);
|
||||
cv::ocl::oclMat d_dst;
|
||||
cv::ocl::oclMat d_src(src);
|
||||
|
||||
|
@ -69,8 +69,6 @@ TEST_P(Kalman, Accuracy)
|
||||
const double max_init = 1;
|
||||
const double max_noise = 0.1;
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
Mat sample_mat(Dim, 1, CV_32F), temp_mat;
|
||||
oclMat Sample(Dim, 1, CV_32F);
|
||||
oclMat Temp(Dim, 1, CV_32F);
|
||||
@ -78,7 +76,7 @@ TEST_P(Kalman, Accuracy)
|
||||
|
||||
Size size(Sample.cols, Sample.rows);
|
||||
|
||||
sample_mat = randomMat(rng, size, Sample.type(), -max_init, max_init, false);
|
||||
sample_mat = randomMat(size, Sample.type(), -max_init, max_init, false);
|
||||
Sample.upload(sample_mat);
|
||||
|
||||
//ocl start
|
||||
@ -120,7 +118,7 @@ TEST_P(Kalman, Accuracy)
|
||||
cv::gemm(kalman_filter_cpu.transitionMatrix, sample_mat, 1, cv::Mat(), 0, Temp_cpu);
|
||||
|
||||
Size size1(Temp.cols, Temp.rows);
|
||||
Mat temp = randomMat(rng, size1, Temp.type(), 0, 0xffff, false);
|
||||
Mat temp = randomMat(size1, Temp.type(), 0, 0xffff, false);
|
||||
|
||||
|
||||
cv::multiply(2, temp, temp);
|
||||
|
@ -66,12 +66,11 @@ PARAM_TEST_CASE(Kmeans, int, int, int)
|
||||
|
||||
Mat labels, centers;
|
||||
ocl::oclMat d_labels, d_centers;
|
||||
cv::RNG rng ;
|
||||
virtual void SetUp(){
|
||||
virtual void SetUp()
|
||||
{
|
||||
K = GET_PARAM(0);
|
||||
type = GET_PARAM(1);
|
||||
flags = GET_PARAM(2);
|
||||
rng = TS::ptr()->get_rng();
|
||||
|
||||
// MWIDTH=256, MHEIGHT=256. defined in utility.hpp
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
@ -92,7 +91,7 @@ PARAM_TEST_CASE(Kmeans, int, int, int)
|
||||
{
|
||||
Mat cur_row_header = src.row(row_idx + 1 + j);
|
||||
center_row_header.copyTo(cur_row_header);
|
||||
Mat tmpmat = randomMat(rng, cur_row_header.size(), cur_row_header.type(), -200, 200, false);
|
||||
Mat tmpmat = randomMat(cur_row_header.size(), cur_row_header.type(), -200, 200, false);
|
||||
cur_row_header += tmpmat;
|
||||
}
|
||||
row_idx += 1 + max_neighbour;
|
||||
|
@ -72,8 +72,8 @@ PARAM_TEST_CASE(MatchTemplate8U, cv::Size, TemplateSize, Channels, TemplateMetho
|
||||
|
||||
TEST_P(MatchTemplate8U, Accuracy)
|
||||
{
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn));
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn), 0, 255);
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn), 0, 255);
|
||||
|
||||
cv::ocl::oclMat dst, ocl_image(image), ocl_templ(templ);
|
||||
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
|
||||
@ -105,8 +105,8 @@ PARAM_TEST_CASE(MatchTemplate32F, cv::Size, TemplateSize, Channels, TemplateMeth
|
||||
|
||||
TEST_P(MatchTemplate32F, Accuracy)
|
||||
{
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn), 0, 255);
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn), 0, 255);
|
||||
|
||||
cv::ocl::oclMat dst, ocl_image(image), ocl_templ(templ);
|
||||
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
|
||||
|
@ -90,10 +90,8 @@ PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType, int, bool)
|
||||
|
||||
use_roi = GET_PARAM(3);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
mat = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), src_type, 5, 136, false);
|
||||
dst = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : mat.size(), dst_type, 5, 136, false);
|
||||
mat = randomMat(randomSize(MIN_VALUE, MAX_VALUE), src_type, 5, 136, false);
|
||||
dst = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : mat.size(), dst_type, 5, 136, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
@ -101,7 +99,6 @@ PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
srcx = rng.uniform(0, mat.cols - roicols);
|
||||
@ -178,11 +175,9 @@ PARAM_TEST_CASE(CopyToTestBase, MatType, int, bool)
|
||||
int type = CV_MAKETYPE(GET_PARAM(0), GET_PARAM(1));
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
dst = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), type, 5, 16, false);
|
||||
mask = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
src = randomMat(randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
dst = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), type, 5, 16, false);
|
||||
mask = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
|
||||
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
||||
}
|
||||
@ -192,7 +187,6 @@ PARAM_TEST_CASE(CopyToTestBase, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
srcx = rng.uniform(0, src.cols - roicols);
|
||||
@ -295,11 +289,10 @@ PARAM_TEST_CASE(SetToTestBase, MatType, int, bool)
|
||||
channels = GET_PARAM(1);
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
mask = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
src = randomMat(randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
mask = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
|
||||
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
||||
val = cv::Scalar(rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0),
|
||||
@ -311,7 +304,6 @@ PARAM_TEST_CASE(SetToTestBase, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
srcx = rng.uniform(0, src.cols - roicols);
|
||||
@ -401,8 +393,7 @@ PARAM_TEST_CASE(convertC3C4, MatType, bool)
|
||||
use_roi = GET_PARAM(1);
|
||||
int type = CV_MAKE_TYPE(depth, 3);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src = randomMat(rng, randomSize(1, MAX_VALUE), type, 0, 40, false);
|
||||
src = randomMat(randomSize(1, MAX_VALUE), type, 0, 40, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
@ -410,7 +401,6 @@ PARAM_TEST_CASE(convertC3C4, MatType, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, src.cols);
|
||||
roirows = rng.uniform(1, src.rows);
|
||||
srcx = rng.uniform(0, src.cols - roicols);
|
||||
|
@ -50,10 +50,9 @@ using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
///////K-NEAREST NEIGHBOR//////////////////////////
|
||||
static void genTrainData(Mat& trainData, int trainDataRow, int trainDataCol,
|
||||
static void genTrainData(cv::RNG& rng, Mat& trainData, int trainDataRow, int trainDataCol,
|
||||
Mat& trainLabel = Mat().setTo(Scalar::all(0)), int nClasses = 0)
|
||||
{
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(trainDataCol, trainDataRow);
|
||||
trainData = randomMat(rng, size, CV_32FC1, 1.0, 1000.0, false);
|
||||
if(nClasses != 0)
|
||||
@ -85,10 +84,10 @@ TEST_P(KNN, Accuracy)
|
||||
{
|
||||
Mat trainData, trainLabels;
|
||||
const int trainDataRow = 500;
|
||||
genTrainData(trainData, trainDataRow, trainDataCol, trainLabels, nClass);
|
||||
genTrainData(rng, trainData, trainDataRow, trainDataCol, trainLabels, nClass);
|
||||
|
||||
Mat testData, testLabels;
|
||||
genTrainData(testData, testDataRow, trainDataCol);
|
||||
genTrainData(rng, testData, testDataRow, trainDataCol);
|
||||
|
||||
KNearestNeighbour knn_ocl;
|
||||
CvKNearest knn_cpu;
|
||||
@ -130,7 +129,6 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
int svm_type;
|
||||
Mat src, labels, samples, labels_predict;
|
||||
int K;
|
||||
cv::RNG rng ;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
@ -138,7 +136,6 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
kernel_type = GET_PARAM(0);
|
||||
svm_type = GET_PARAM(1);
|
||||
K = GET_PARAM(2);
|
||||
rng = TS::ptr()->get_rng();
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
src.create(size, CV_32FC1);
|
||||
labels.create(1, size.height, CV_32SC1);
|
||||
@ -160,7 +157,7 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
{
|
||||
Mat cur_row_header = src.row(row_idx + 1 + j);
|
||||
center_row_header.copyTo(cur_row_header);
|
||||
Mat tmpmat = randomMat(rng, cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
Mat tmpmat = randomMat(cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
cur_row_header += tmpmat;
|
||||
labels.at<int>(0, row_idx + 1 + j) = i;
|
||||
}
|
||||
@ -187,7 +184,7 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
{
|
||||
Mat cur_row_header = samples.row(row_idx + 1 + j);
|
||||
center_row_header.copyTo(cur_row_header);
|
||||
Mat tmpmat = randomMat(rng, cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
Mat tmpmat = randomMat(cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
cur_row_header += tmpmat;
|
||||
labels_predict.at<int>(0, row_idx + 1 + j) = i;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
extern string workdir;
|
||||
|
||||
PARAM_TEST_CASE(MomentsTest, MatType, bool)
|
||||
{
|
||||
int type;
|
||||
@ -20,9 +20,8 @@ PARAM_TEST_CASE(MomentsTest, MatType, bool)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
test_contours = GET_PARAM(1);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(10*MWIDTH, 10*MHEIGHT);
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
|
||||
void Compare(Moments& cpu, Moments& gpu)
|
||||
@ -39,7 +38,6 @@ PARAM_TEST_CASE(MomentsTest, MatType, bool)
|
||||
TEST_P(MomentsTest, Mat)
|
||||
{
|
||||
bool binaryImage = 0;
|
||||
SetUp();
|
||||
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
|
@ -51,8 +51,6 @@ using namespace cv;
|
||||
using namespace testing;
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
extern string workdir;
|
||||
|
||||
///////////////////// HOG /////////////////////////////
|
||||
PARAM_TEST_CASE(HOG, Size, int)
|
||||
{
|
||||
|
@ -54,9 +54,6 @@ using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
extern string workdir;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// GoodFeaturesToTrack
|
||||
namespace
|
||||
@ -153,9 +150,8 @@ TEST_P(TVL1, Accuracy)
|
||||
ASSERT_FALSE(frame1.empty());
|
||||
|
||||
cv::ocl::OpticalFlowDual_TVL1_OCL d_alg;
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Mat flowx = randomMat(rng, frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::Mat flowy = randomMat(rng, frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::Mat flowx = randomMat(frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::Mat flowy = randomMat(frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::ocl::oclMat d_flowx(flowx), d_flowy(flowy);
|
||||
d_alg(oclMat(frame0), oclMat(frame1), d_flowx, d_flowy);
|
||||
|
||||
|
@ -73,4 +73,6 @@
|
||||
#include "utility.hpp"
|
||||
//#include "add_test_info.h"
|
||||
|
||||
using namespace cvtest;
|
||||
|
||||
#endif
|
||||
|
@ -79,7 +79,7 @@ TEST_P(PyrDown, Mat)
|
||||
for (int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
Size size(MWIDTH, MHEIGHT);
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels));
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels), 0, 255);
|
||||
oclMat gsrc(src);
|
||||
|
||||
pyrDown(src, dst_cpu);
|
||||
@ -102,7 +102,7 @@ TEST_P(PyrUp, Accuracy)
|
||||
for (int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
Size size(MWIDTH, MHEIGHT);
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels));
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels), 0, 255);
|
||||
oclMat gsrc(src);
|
||||
|
||||
pyrUp(src, dst_cpu);
|
||||
|
@ -90,12 +90,11 @@ PARAM_TEST_CASE(MergeTestBase, MatType, int, bool)
|
||||
channels = GET_PARAM(1);
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
for (int i = 0; i < channels; ++i)
|
||||
mat[i] = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
mat[i] = randomMat(size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst = randomMat(size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
@ -103,7 +102,6 @@ PARAM_TEST_CASE(MergeTestBase, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat[0].cols);
|
||||
roirows = rng.uniform(1, mat[0].rows);
|
||||
|
||||
@ -191,19 +189,17 @@ PARAM_TEST_CASE(SplitTestBase, MatType, int, bool)
|
||||
channels = GET_PARAM(1);
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
mat = randomMat(size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
for (int i = 0; i < channels; ++i)
|
||||
dst[i] = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false); }
|
||||
dst[i] = randomMat(size, CV_MAKETYPE(type, 1), 5, 16, false); }
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
if (use_roi)
|
||||
{
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat.cols);
|
||||
roirows = rng.uniform(1, mat.rows);
|
||||
srcx = rng.uniform(0, mat.cols - roicols);
|
||||
|
@ -46,7 +46,7 @@ using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
using namespace cvtest;
|
||||
|
||||
|
||||
namespace cvtest {
|
||||
//std::string generateVarList(int first,...)
|
||||
//{
|
||||
// vector<std::string> varname;
|
||||
@ -73,41 +73,14 @@ using namespace cvtest;
|
||||
// return ss.str();
|
||||
//};
|
||||
|
||||
int randomInt(int minVal, int maxVal)
|
||||
{
|
||||
RNG &rng = TS::ptr()->get_rng();
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
double randomDouble(double minVal, double maxVal)
|
||||
{
|
||||
RNG &rng = TS::ptr()->get_rng();
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
Size randomSize(int minVal, int maxVal)
|
||||
{
|
||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
||||
}
|
||||
|
||||
Scalar randomScalar(double minVal, double maxVal)
|
||||
{
|
||||
return Scalar(randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal));
|
||||
}
|
||||
|
||||
Mat randomMat(Size size, int type, double minVal, double maxVal)
|
||||
{
|
||||
return randomMat(TS::ptr()->get_rng(), size, type, minVal, maxVal, false);
|
||||
}
|
||||
|
||||
cv::ocl::oclMat createMat_ocl(Size size, int type, bool useRoi)
|
||||
cv::ocl::oclMat createMat_ocl(cv::RNG& rng, Size size, int type, bool useRoi)
|
||||
{
|
||||
Size size0 = size;
|
||||
|
||||
if (useRoi)
|
||||
{
|
||||
size0.width += randomInt(5, 15);
|
||||
size0.height += randomInt(5, 15);
|
||||
size0.width += rng.uniform(5, 15);
|
||||
size0.height += rng.uniform(5, 15);
|
||||
}
|
||||
|
||||
cv::ocl::oclMat d_m(size0, type);
|
||||
@ -118,11 +91,11 @@ cv::ocl::oclMat createMat_ocl(Size size, int type, bool useRoi)
|
||||
return d_m;
|
||||
}
|
||||
|
||||
cv::ocl::oclMat loadMat_ocl(const Mat& m, bool useRoi)
|
||||
cv::ocl::oclMat loadMat_ocl(cv::RNG& rng, const Mat& m, bool useRoi)
|
||||
{
|
||||
CV_Assert(m.type() == CV_8UC1 || m.type() == CV_8UC3);
|
||||
cv::ocl::oclMat d_m;
|
||||
d_m = createMat_ocl(m.size(), m.type(), useRoi);
|
||||
d_m = createMat_ocl(rng, m.size(), m.type(), useRoi);
|
||||
|
||||
Size ls;
|
||||
Point pt;
|
||||
@ -138,38 +111,6 @@ cv::ocl::oclMat loadMat_ocl(const Mat& m, bool useRoi)
|
||||
m_ocl.copyTo(d_m);
|
||||
return d_m;
|
||||
}
|
||||
/*
|
||||
void showDiff(InputArray gold_, InputArray actual_, double eps)
|
||||
{
|
||||
Mat gold;
|
||||
if (gold_.kind() == _InputArray::MAT)
|
||||
gold = gold_.getMat();
|
||||
else
|
||||
gold_.getGpuMat().download(gold);
|
||||
|
||||
Mat actual;
|
||||
if (actual_.kind() == _InputArray::MAT)
|
||||
actual = actual_.getMat();
|
||||
else
|
||||
actual_.getGpuMat().download(actual);
|
||||
|
||||
Mat diff;
|
||||
absdiff(gold, actual, diff);
|
||||
threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY);
|
||||
|
||||
namedWindow("gold", WINDOW_NORMAL);
|
||||
namedWindow("actual", WINDOW_NORMAL);
|
||||
namedWindow("diff", WINDOW_NORMAL);
|
||||
|
||||
imshow("gold", gold);
|
||||
imshow("actual", actual);
|
||||
imshow("diff", diff);
|
||||
|
||||
waitKey();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
|
||||
{
|
||||
@ -289,3 +230,5 @@ double checkRectSimilarity(Size sz, std::vector<Rect>& ob1, std::vector<Rect>& o
|
||||
}
|
||||
return final_test_result;
|
||||
}
|
||||
|
||||
} // namespace cvtest
|
||||
|
@ -42,7 +42,7 @@
|
||||
#ifndef __OPENCV_TEST_UTILITY_HPP__
|
||||
#define __OPENCV_TEST_UTILITY_HPP__
|
||||
|
||||
#define LOOP_TIMES 1
|
||||
#define LOOP_TIMES 10
|
||||
|
||||
#define MWIDTH 256
|
||||
#define MHEIGHT 256
|
||||
@ -50,16 +50,12 @@
|
||||
#define MIN_VALUE 171
|
||||
#define MAX_VALUE 357
|
||||
|
||||
//#define RANDOMROI
|
||||
int randomInt(int minVal, int maxVal);
|
||||
double randomDouble(double minVal, double maxVal);
|
||||
//std::string generateVarList(int first,...);
|
||||
std::string generateVarList(int &p1, int &p2);
|
||||
cv::Size randomSize(int minVal, int maxVal);
|
||||
cv::Scalar randomScalar(double minVal, double maxVal);
|
||||
cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0);
|
||||
namespace cvtest {
|
||||
|
||||
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||
//void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||
|
||||
cv::ocl::oclMat createMat_ocl(cv::RNG& rng, Size size, int type, bool useRoi);
|
||||
cv::ocl::oclMat loadMat_ocl(cv::RNG& rng, const Mat& m, bool useRoi);
|
||||
|
||||
// This function test if gpu_rst matches cpu_rst.
|
||||
// If the two vectors are not equal, it will return the difference in vector size
|
||||
@ -76,10 +72,6 @@ double checkNorm(const cv::Mat &m);
|
||||
double checkNorm(const cv::Mat &m1, const cv::Mat &m2);
|
||||
double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
|
||||
|
||||
//oclMat create
|
||||
cv::ocl::oclMat createMat_ocl(cv::Size size, int type, bool useRoi = false);
|
||||
cv::ocl::oclMat loadMat_ocl(const cv::Mat& m, bool useRoi = false);
|
||||
|
||||
#define EXPECT_MAT_NORM(mat, eps) \
|
||||
{ \
|
||||
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
|
||||
@ -99,13 +91,6 @@ cv::ocl::oclMat loadMat_ocl(const cv::Mat& m, bool useRoi = false);
|
||||
EXPECT_LE(checkSimilarity(cv::Mat(mat1), cv::Mat(mat2)), eps); \
|
||||
}
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace ocl
|
||||
{
|
||||
// void PrintTo(const DeviceInfo& info, std::ostream* os);
|
||||
}
|
||||
}
|
||||
|
||||
using perf::MatDepth;
|
||||
using perf::MatType;
|
||||
@ -132,80 +117,106 @@ private:
|
||||
|
||||
void PrintTo(const Inverse &useRoi, std::ostream *os);
|
||||
|
||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
|
||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
|
||||
#define OCL_RNG_SEED 123456
|
||||
|
||||
CV_ENUM(CmpCode, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
|
||||
CV_ENUM(NormCode, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
|
||||
CV_ENUM(ReduceOp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
|
||||
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
|
||||
CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
|
||||
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC)
|
||||
CV_ENUM(Border, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
|
||||
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
|
||||
template <typename T>
|
||||
struct TSTestWithParam : public ::testing::TestWithParam<T>
|
||||
{
|
||||
cv::RNG rng;
|
||||
|
||||
CV_FLAGS(GemmFlags, GEMM_1_T, GEMM_2_T, GEMM_3_T);
|
||||
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
|
||||
CV_FLAGS(DftFlags, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
|
||||
TSTestWithParam()
|
||||
{
|
||||
rng = cv::RNG(OCL_RNG_SEED);
|
||||
}
|
||||
|
||||
void run_perf_test();
|
||||
int randomInt(int minVal, int maxVal)
|
||||
{
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
||||
double randomDouble(double minVal, double maxVal)
|
||||
{
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
double randomDoubleLog(double minVal, double maxVal)
|
||||
{
|
||||
double logMin = log((double)minVal + 1);
|
||||
double logMax = log((double)maxVal + 1);
|
||||
double pow = rng.uniform(logMin, logMax);
|
||||
double v = exp(pow) - 1;
|
||||
CV_Assert(v >= minVal && (v < maxVal || (v == minVal && v == maxVal)));
|
||||
return v;
|
||||
}
|
||||
|
||||
Size randomSize(int minVal, int maxVal)
|
||||
{
|
||||
#if 1
|
||||
return cv::Size((int)randomDoubleLog(minVal, maxVal), (int)randomDoubleLog(minVal, maxVal));
|
||||
#else
|
||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
||||
#endif
|
||||
}
|
||||
|
||||
Size randomSize(int minValX, int maxValX, int minValY, int maxValY)
|
||||
{
|
||||
#if 1
|
||||
return cv::Size(randomDoubleLog(minValX, maxValX), randomDoubleLog(minValY, maxValY));
|
||||
#else
|
||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
||||
#endif
|
||||
}
|
||||
|
||||
Scalar randomScalar(double minVal, double maxVal)
|
||||
{
|
||||
return Scalar(randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal));
|
||||
}
|
||||
|
||||
Mat randomMat(Size size, int type, double minVal, double maxVal, bool useRoi = false)
|
||||
{
|
||||
RNG dataRng(rng.next());
|
||||
return cvtest::randomMat(dataRng, size, type, minVal, maxVal, useRoi);
|
||||
}
|
||||
|
||||
struct Border
|
||||
{
|
||||
int top, bot, lef, rig;
|
||||
};
|
||||
|
||||
Border randomBorder(int minValue = 0, int maxValue = MAX_VALUE)
|
||||
{
|
||||
Border border = {
|
||||
(int)randomDoubleLog(minValue, maxValue),
|
||||
(int)randomDoubleLog(minValue, maxValue),
|
||||
(int)randomDoubleLog(minValue, maxValue),
|
||||
(int)randomDoubleLog(minValue, maxValue)
|
||||
};
|
||||
return border;
|
||||
}
|
||||
|
||||
void randomSubMat(Mat& whole, Mat& subMat, const Size& roiSize, const Border& border, int type, double minVal, double maxVal)
|
||||
{
|
||||
Size wholeSize = Size(roiSize.width + border.lef + border.rig, roiSize.height + border.top + border.bot);
|
||||
whole = randomMat(wholeSize, type, minVal, maxVal, false);
|
||||
subMat = whole(Rect(border.lef, border.top, roiSize.width, roiSize.height));
|
||||
}
|
||||
|
||||
void generateOclMat(cv::ocl::oclMat& whole, cv::ocl::oclMat& subMat, const Mat& wholeMat, const Size& roiSize, const Border& border)
|
||||
{
|
||||
whole = wholeMat;
|
||||
subMat = whole(Rect(border.lef, border.top, roiSize.width, roiSize.height));
|
||||
}
|
||||
};
|
||||
|
||||
#define PARAM_TEST_CASE(name, ...) struct name : public TSTestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
||||
|
||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
||||
|
||||
#define ALL_DEVICES testing::ValuesIn(devices())
|
||||
#define DEVICES(feature) testing::ValuesIn(devices(feature))
|
||||
|
||||
#define ALL_TYPES testing::ValuesIn(all_types())
|
||||
#define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end))
|
||||
|
||||
#define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113), cv::Size(1300, 1300))
|
||||
|
||||
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
|
||||
|
||||
#ifndef ALL_DEPTH
|
||||
#define ALL_DEPTH testing::Values(MatDepth(CV_8U), MatDepth(CV_8S), MatDepth(CV_16U), MatDepth(CV_16S), MatDepth(CV_32S), MatDepth(CV_32F), MatDepth(CV_64F))
|
||||
#endif
|
||||
#define REPEAT 1000
|
||||
#define COUNT_U 0 // count the uploading execution time for ocl mat structures
|
||||
#define COUNT_D 0
|
||||
// the following macro section tests the target function (kernel) performance
|
||||
// upload is the code snippet for converting cv::mat to cv::ocl::oclMat
|
||||
// downloading is the code snippet for converting cv::ocl::oclMat back to cv::mat
|
||||
// change COUNT_U and COUNT_D to take downloading and uploading time into account
|
||||
#define P_TEST_FULL( upload, kernel_call, download ) \
|
||||
{ \
|
||||
std::cout<< "\n" #kernel_call "\n----------------------"; \
|
||||
{upload;} \
|
||||
R_TEST( kernel_call, 2 ); \
|
||||
double t = (double)cvGetTickCount(); \
|
||||
R_T( { \
|
||||
if( COUNT_U ) {upload;} \
|
||||
kernel_call; \
|
||||
if( COUNT_D ) {download;} \
|
||||
} ); \
|
||||
t = (double)cvGetTickCount() - t; \
|
||||
std::cout << "runtime is " << t/((double)cvGetTickFrequency()* 1000.) << "ms" << std::endl; \
|
||||
}
|
||||
|
||||
#define R_T2( test ) \
|
||||
{ \
|
||||
std::cout<< "\n" #test "\n----------------------"; \
|
||||
R_TEST( test, 15 ) \
|
||||
clock_t st = clock(); \
|
||||
R_T( test ) \
|
||||
std::cout<< clock() - st << "ms\n"; \
|
||||
}
|
||||
#define R_T( test ) \
|
||||
R_TEST( test, REPEAT )
|
||||
#define R_TEST( test, repeat ) \
|
||||
try{ \
|
||||
for( int i = 0; i < repeat; i ++ ) { test; } \
|
||||
} catch( ... ) { std::cout << "||||| Exception catched! |||||\n"; return; }
|
||||
|
||||
//////// Utility
|
||||
|
||||
#define IMAGE_CHANNELS testing::Values(Channels(1), Channels(3), Channels(4))
|
||||
#ifndef IMPLEMENT_PARAM_CLASS
|
||||
#define IMPLEMENT_PARAM_CLASS(name, type) \
|
||||
@ -225,4 +236,22 @@ void run_perf_test();
|
||||
IMPLEMENT_PARAM_CLASS(Channels, int)
|
||||
#endif // IMPLEMENT_PARAM_CLASS
|
||||
|
||||
} // namespace cvtest
|
||||
|
||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
|
||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
|
||||
|
||||
CV_ENUM(CmpCode, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
|
||||
CV_ENUM(NormCode, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
|
||||
CV_ENUM(ReduceOp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
|
||||
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
|
||||
CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
|
||||
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC)
|
||||
CV_ENUM(Border, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
|
||||
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
|
||||
|
||||
CV_FLAGS(GemmFlags, GEMM_1_T, GEMM_2_T, GEMM_3_T);
|
||||
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
|
||||
CV_FLAGS(DftFlags, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
|
||||
|
||||
#endif // __OPENCV_TEST_UTILITY_HPP__
|
||||
|
Loading…
Reference in New Issue
Block a user