fixed gpu::pyrUp (now it matches cpu analog)

fixed several warnings
This commit is contained in:
Vladislav Vinogradov
2012-03-19 09:27:06 +00:00
parent 484fe1d598
commit 6397fa5b38
11 changed files with 648 additions and 597 deletions

View File

@@ -54,38 +54,38 @@ struct StereoBlockMatching : TestWithParam<cv::gpu::DeviceInfo>
cv::Mat img_l;
cv::Mat img_r;
cv::Mat img_template;
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
img_l = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
img_r = readImage("stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);
img_template = readImage("stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
}
};
TEST_P(StereoBlockMatching, Regression)
{
TEST_P(StereoBlockMatching, Regression)
{
cv::Mat disp;
cv::gpu::GpuMat dev_disp;
cv::gpu::StereoBM_GPU bm(0, 128, 19);
bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), dev_disp);
dev_disp.download(disp);
disp.convertTo(disp, img_template.type());
EXPECT_MAT_NEAR(img_template, disp, 0.0);
}
@@ -99,26 +99,26 @@ struct StereoBeliefPropagation : TestWithParam<cv::gpu::DeviceInfo>
cv::Mat img_l;
cv::Mat img_r;
cv::Mat img_template;
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
img_l = readImage("stereobp/aloe-L.png");
img_r = readImage("stereobp/aloe-R.png");
img_template = readImage("stereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
}
};
TEST_P(StereoBeliefPropagation, Regression)
TEST_P(StereoBeliefPropagation, Regression)
{
cv::Mat disp;
@@ -126,11 +126,11 @@ TEST_P(StereoBeliefPropagation, Regression)
cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), dev_disp);
dev_disp.download(disp);
disp.convertTo(disp, img_template.type());
EXPECT_MAT_NEAR(img_template, disp, 0.0);
}
@@ -144,15 +144,15 @@ struct StereoConstantSpaceBP : TestWithParam<cv::gpu::DeviceInfo>
cv::Mat img_l;
cv::Mat img_r;
cv::Mat img_template;
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
img_l = readImage("csstereobp/aloe-L.png");
img_r = readImage("csstereobp/aloe-R.png");
@@ -160,14 +160,14 @@ struct StereoConstantSpaceBP : TestWithParam<cv::gpu::DeviceInfo>
img_template = readImage("csstereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
else
img_template = readImage("csstereobp/aloe-disp_CC1X.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
ASSERT_FALSE(img_template.empty());
}
};
TEST_P(StereoConstantSpaceBP, Regression)
TEST_P(StereoConstantSpaceBP, Regression)
{
cv::Mat disp;
@@ -175,11 +175,11 @@ TEST_P(StereoConstantSpaceBP, Regression)
cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), dev_disp);
dev_disp.download(disp);
disp.convertTo(disp, img_template.type());
EXPECT_MAT_NEAR(img_template, disp, 1.0);
}
@@ -191,12 +191,12 @@ INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
struct ProjectPoints : TestWithParam<cv::gpu::DeviceInfo>
{
cv::gpu::DeviceInfo devInfo;
cv::Mat src;
cv::Mat rvec;
cv::Mat tvec;
cv::Mat camera_mat;
std::vector<cv::Point2f> dst_gold;
virtual void SetUp()
@@ -220,17 +220,17 @@ struct ProjectPoints : TestWithParam<cv::gpu::DeviceInfo>
}
};
TEST_P(ProjectPoints, Accuracy)
TEST_P(ProjectPoints, Accuracy)
{
cv::Mat dst;
cv::gpu::GpuMat d_dst;
cv::gpu::projectPoints(cv::gpu::GpuMat(src), rvec, tvec, camera_mat, cv::Mat(), d_dst);
d_dst.download(dst);
ASSERT_EQ(dst_gold.size(), dst.cols);
ASSERT_EQ(dst_gold.size(), static_cast<size_t>(dst.cols));
ASSERT_EQ(1, dst.rows);
ASSERT_EQ(CV_32FC2, dst.type());
@@ -257,7 +257,7 @@ struct TransformPoints : TestWithParam<cv::gpu::DeviceInfo>
cv::Mat rvec;
cv::Mat tvec;
cv::Mat rot;
virtual void SetUp()
{
devInfo = GetParam();
@@ -283,7 +283,7 @@ TEST_P(TransformPoints, Accuracy)
cv::gpu::transformPoints(cv::gpu::GpuMat(src), rvec, tvec, d_dst);
d_dst.download(dst);
ASSERT_EQ(src.size(), dst.size());
ASSERT_EQ(src.type(), dst.type());
@@ -318,7 +318,7 @@ struct SolvePnPRansac : TestWithParam<cv::gpu::DeviceInfo>
cv::Mat rvec_gold;
cv::Mat tvec_gold;
virtual void SetUp()
{
devInfo = GetParam();
@@ -346,7 +346,7 @@ TEST_P(SolvePnPRansac, Accuracy)
cv::Mat rvec, tvec;
std::vector<int> inliers;
cv::gpu::solvePnPRansac(object, cv::Mat(1, image_vec.size(), CV_32FC2, &image_vec[0]), camera_mat,
cv::gpu::solvePnPRansac(object, cv::Mat(1, image_vec.size(), CV_32FC2, &image_vec[0]), camera_mat,
cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), rvec, tvec, false, 200, 2.f, 100, &inliers);
ASSERT_LE(cv::norm(rvec - rvec_gold), 1e-3f);

View File

@@ -90,7 +90,7 @@ struct SURF : TestWithParam<cv::gpu::DeviceInfo>
std::vector<cv::KeyPoint> keypoints_gold;
std::vector<float> descriptors_gold;
virtual void SetUp()
{
devInfo = GetParam();
@@ -157,20 +157,20 @@ PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, DistType, int)
cv::gpu::DeviceInfo devInfo;
cv::gpu::BruteForceMatcher_GPU_base::DistType distType;
int dim;
int queryDescCount;
int countFactor;
cv::Mat query, train;
virtual void SetUp()
virtual void SetUp()
{
devInfo = GET_PARAM(0);
distType = (cv::gpu::BruteForceMatcher_GPU_base::DistType)(int)GET_PARAM(1);
dim = GET_PARAM(2);
cv::gpu::setDevice(devInfo.deviceID());
queryDescCount = 300; // must be even number because we split train data in some cases in two
countFactor = 4; // do not change it
@@ -218,7 +218,7 @@ TEST_P(BruteForceMatcher, Match)
matcher.match(loadMat(query), loadMat(train), matches);
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
for (size_t i = 0; i < matches.size(); i++)
@@ -259,7 +259,7 @@ TEST_P(BruteForceMatcher, MatchAdd)
isMaskSupported = matcher.isMaskSupported();
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
for (size_t i = 0; i < matches.size(); i++)
@@ -292,7 +292,7 @@ TEST_P(BruteForceMatcher, KnnMatch2)
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
matcher.knnMatch(loadMat(query), loadMat(train), matches, knn);
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
for (size_t i = 0; i < matches.size(); i++)
@@ -324,7 +324,7 @@ TEST_P(BruteForceMatcher, KnnMatch3)
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
matcher.knnMatch(loadMat(query), loadMat(train), matches, knn);
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
for (size_t i = 0; i < matches.size(); i++)
@@ -375,7 +375,7 @@ TEST_P(BruteForceMatcher, KnnMatchAdd2)
isMaskSupported = matcher.isMaskSupported();
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
int shift = isMaskSupported ? 1 : 0;
@@ -437,7 +437,7 @@ TEST_P(BruteForceMatcher, KnnMatchAdd3)
isMaskSupported = matcher.isMaskSupported();
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
int shift = isMaskSupported ? 1 : 0;
@@ -485,7 +485,7 @@ TEST_P(BruteForceMatcher, RadiusMatch)
matcher.radiusMatch(loadMat(query), loadMat(train), matches, radius);
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
for (size_t i = 0; i < matches.size(); i++)
@@ -536,7 +536,7 @@ TEST_P(BruteForceMatcher, RadiusMatchAdd)
isMaskSupported = matcher.isMaskSupported();
ASSERT_EQ(queryDescCount, matches.size());
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
int badCount = 0;
int shift = isMaskSupported ? 1 : 0;
@@ -588,17 +588,16 @@ struct FAST : TestWithParam<cv::gpu::DeviceInfo>
int threshold;
std::vector<cv::KeyPoint> keypoints_gold;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(image.empty());
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
threshold = 30;
cv::FAST(image, keypoints_gold, threshold);
@@ -630,7 +629,7 @@ TEST_P(FAST, Accuracy)
cv::gpu::FAST_GPU fastGPU(threshold);
fastGPU(cv::gpu::GpuMat(image), cv::gpu::GpuMat(), keypoints);
ASSERT_EQ(keypoints.size(), keypoints_gold.size());
std::sort(keypoints.begin(), keypoints.end(), KeyPointCompare());
@@ -663,16 +662,16 @@ struct ORB : TestWithParam<cv::gpu::DeviceInfo>
std::vector<cv::KeyPoint> keypoints_gold;
cv::Mat descriptors_gold;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(image.empty());
ASSERT_FALSE(image.empty());
mask = cv::Mat(image.size(), CV_8UC1, cv::Scalar::all(1));
mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));

View File

@@ -58,7 +58,7 @@ PARAM_TEST_CASE(Integral, cv::gpu::DeviceInfo, UseRoi)
cv::Mat src;
cv::Mat dst_gold;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
@@ -70,9 +70,9 @@ PARAM_TEST_CASE(Integral, cv::gpu::DeviceInfo, UseRoi)
size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
src = randomMat(rng, size, CV_8UC1, 0.0, 255.0, false);
src = randomMat(rng, size, CV_8UC1, 0.0, 255.0, false);
cv::integral(src, dst_gold, CV_32S);
cv::integral(src, dst_gold, CV_32S);
}
};
@@ -90,7 +90,7 @@ TEST_P(Integral, Accuracy)
}
INSTANTIATE_TEST_CASE_P(ImgProc, Integral, Combine(
ALL_DEVICES,
ALL_DEVICES,
WHOLE_SUBMAT));
///////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -101,9 +101,9 @@ PARAM_TEST_CASE(CvtColor, cv::gpu::DeviceInfo, MatType, UseRoi)
cv::gpu::DeviceInfo devInfo;
int type;
bool useRoi;
cv::Mat img;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
@@ -111,7 +111,7 @@ PARAM_TEST_CASE(CvtColor, cv::gpu::DeviceInfo, MatType, UseRoi)
useRoi = GET_PARAM(2);
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat imgBase = readImage("stereobm/aloe-L.png");
ASSERT_FALSE(imgBase.empty());
@@ -1998,7 +1998,7 @@ TEST_P(CvtColor, RGBA2YUV4)
}
INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, Combine(
ALL_DEVICES,
ALL_DEVICES,
Values(CV_8U, CV_16U, CV_32F),
WHOLE_SUBMAT));
@@ -2009,18 +2009,18 @@ PARAM_TEST_CASE(SwapChannels, cv::gpu::DeviceInfo, UseRoi)
{
cv::gpu::DeviceInfo devInfo;
bool useRoi;
cv::Mat img;
cv::Mat dst_gold;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
useRoi = GET_PARAM(1);
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat imgBase = readImage("stereobm/aloe-L.png");
ASSERT_FALSE(imgBase.empty());
@@ -2051,23 +2051,23 @@ INSTANTIATE_TEST_CASE_P(ImgProc, SwapChannels, Combine(ALL_DEVICES, WHOLE_SUBMAT
struct HistEven : TestWithParam<cv::gpu::DeviceInfo>
{
cv::gpu::DeviceInfo devInfo;
cv::Mat hsv;
int hbins;
float hranges[2];
cv::Mat hist_gold;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage("stereobm/aloe-L.png");
ASSERT_FALSE(img.empty());
cv::cvtColor(img, hsv, CV_BGR2HSV);
hbins = 30;
@@ -2092,7 +2092,7 @@ struct HistEven : TestWithParam<cv::gpu::DeviceInfo>
TEST_P(HistEven, Accuracy)
{
cv::Mat hist;
std::vector<cv::gpu::GpuMat> srcs;
cv::gpu::split(loadMat(hsv), srcs);
@@ -2114,7 +2114,7 @@ struct CalcHist : TestWithParam<cv::gpu::DeviceInfo>
cv::Size size;
cv::Mat src;
cv::Mat hist_gold;
virtual void SetUp()
{
devInfo = GetParam();
@@ -2124,7 +2124,7 @@ struct CalcHist : TestWithParam<cv::gpu::DeviceInfo>
cv::RNG& rng = TS::ptr()->get_rng();
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
src = randomMat(rng, size, CV_8UC1, 0, 255, false);
hist_gold.create(1, 256, CV_32SC1);
@@ -2144,7 +2144,7 @@ struct CalcHist : TestWithParam<cv::gpu::DeviceInfo>
TEST_P(CalcHist, Accuracy)
{
cv::Mat hist;
cv::gpu::GpuMat gpuHist;
cv::gpu::calcHist(loadMat(src), gpuHist);
@@ -2163,7 +2163,7 @@ struct EqualizeHist : TestWithParam<cv::gpu::DeviceInfo>
cv::Size size;
cv::Mat src;
cv::Mat dst_gold;
virtual void SetUp()
{
devInfo = GetParam();
@@ -2173,7 +2173,7 @@ struct EqualizeHist : TestWithParam<cv::gpu::DeviceInfo>
cv::RNG& rng = TS::ptr()->get_rng();
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
src = randomMat(rng, size, CV_8UC1, 0, 255, false);
cv::equalizeHist(src, dst_gold);
@@ -2183,7 +2183,7 @@ struct EqualizeHist : TestWithParam<cv::gpu::DeviceInfo>
TEST_P(EqualizeHist, Accuracy)
{
cv::Mat dst;
cv::gpu::GpuMat gpuDst;
cv::gpu::equalizeHist(loadMat(src), gpuDst);
@@ -2217,7 +2217,7 @@ PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, Border, int, int)
type = GET_PARAM(1);
borderType = GET_PARAM(2);
blockSize = GET_PARAM(3);
apertureSize = GET_PARAM(4);
apertureSize = GET_PARAM(4);
cv::gpu::setDevice(devInfo.deviceID());
@@ -2248,8 +2248,8 @@ TEST_P(CornerHarris, Accuracy)
}
INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, Combine(
ALL_DEVICES,
Values(CV_8UC1, CV_32FC1),
ALL_DEVICES,
Values(CV_8UC1, CV_32FC1),
Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT),
Values(3, 5, 7),
Values(0, 3, 5, 7)));
@@ -2268,19 +2268,17 @@ PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, Border, int, int)
cv::Mat src;
cv::Mat dst_gold;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
type = GET_PARAM(1);
borderType = GET_PARAM(2);
blockSize = GET_PARAM(3);
apertureSize = GET_PARAM(4);
apertureSize = GET_PARAM(4);
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = TS::ptr()->get_rng();
cv::Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img.empty());
@@ -2304,8 +2302,8 @@ TEST_P(CornerMinEigen, Accuracy)
}
INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigen, Combine(
ALL_DEVICES,
Values(CV_8UC1, CV_32FC1),
ALL_DEVICES,
Values(CV_8UC1, CV_32FC1),
Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT),
Values(3, 5, 7),
Values(0, 3, 5, 7)));
@@ -2325,7 +2323,7 @@ struct ColumnSum : TestWithParam<cv::gpu::DeviceInfo>
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = TS::ptr()->get_rng();
size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));
@@ -2337,7 +2335,7 @@ struct ColumnSum : TestWithParam<cv::gpu::DeviceInfo>
TEST_P(ColumnSum, Accuracy)
{
cv::Mat dst;
cv::gpu::GpuMat dev_dst;
cv::gpu::columnSum(loadMat(src), dev_dst);
@@ -2387,7 +2385,7 @@ PARAM_TEST_CASE(Norm, cv::gpu::DeviceInfo, MatType, NormCode, UseRoi)
useRoi = GET_PARAM(3);
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = TS::ptr()->get_rng();
size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));
@@ -2406,7 +2404,7 @@ TEST_P(Norm, Accuracy)
}
INSTANTIATE_TEST_CASE_P(ImgProc, Norm, Combine(
ALL_DEVICES,
ALL_DEVICES,
TYPES(CV_8U, CV_32F, 1, 1),
Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2),
WHOLE_SUBMAT));
@@ -2431,7 +2429,7 @@ PARAM_TEST_CASE(ReprojectImageTo3D, cv::gpu::DeviceInfo, UseRoi)
useRoi = GET_PARAM(1);
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = TS::ptr()->get_rng();
size = cv::Size(rng.uniform(100, 500), rng.uniform(100, 500));
@@ -2481,7 +2479,7 @@ INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, Combine(ALL_DEVICES, WHOLE_
struct MeanShift : TestWithParam<cv::gpu::DeviceInfo>
{
cv::gpu::DeviceInfo devInfo;
cv::Mat rgba;
int spatialRad;
@@ -2492,10 +2490,10 @@ struct MeanShift : TestWithParam<cv::gpu::DeviceInfo>
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage("meanshift/cones.png");
ASSERT_FALSE(img.empty());
cv::cvtColor(img, rgba, CV_BGR2BGRA);
spatialRad = 30;
@@ -2506,7 +2504,7 @@ struct MeanShift : TestWithParam<cv::gpu::DeviceInfo>
TEST_P(MeanShift, Filtering)
{
cv::Mat img_template;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
img_template = readImage("meanshift/con_result.png");
else
@@ -2562,8 +2560,8 @@ TEST_P(MeanShift, Proc)
d_spmap.download(spmap);
ASSERT_EQ(CV_8UC4, rmap.type());
EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0);
EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0);
EXPECT_MAT_NEAR(spmap_template, spmap, 0.0);
}
@@ -2573,7 +2571,7 @@ PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, int)
{
cv::gpu::DeviceInfo devInfo;
int minsize;
cv::Mat rgba;
cv::Mat dst_gold;
@@ -2584,10 +2582,10 @@ PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, int)
minsize = GET_PARAM(1);
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage("meanshift/cones.png");
ASSERT_FALSE(img.empty());
cv::cvtColor(img, rgba, CV_BGR2BGRA);
std::ostringstream path;
@@ -2669,7 +2667,7 @@ TEST_P(MatchTemplate8U, Regression)
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate8U, Combine(
ALL_DEVICES,
Range(1, 5),
Range(1, 5),
Values((int)cv::TM_SQDIFF, (int) cv::TM_SQDIFF_NORMED, (int) cv::TM_CCORR, (int) cv::TM_CCORR_NORMED, (int) cv::TM_CCOEFF, (int) cv::TM_CCOEFF_NORMED)));
@@ -2720,8 +2718,8 @@ TEST_P(MatchTemplate32F, Regression)
}
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate32F, Combine(
ALL_DEVICES,
Range(1, 5),
ALL_DEVICES,
Range(1, 5),
Values((int) cv::TM_SQDIFF, (int) cv::TM_CCORR)));
@@ -2830,9 +2828,9 @@ PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, DftFlags)
cv::gpu::DeviceInfo devInfo;
int flag;
cv::Mat a, b;
cv::Mat a, b;
virtual void SetUp()
virtual void SetUp()
{
devInfo = GET_PARAM(0);
flag = GET_PARAM(1);
@@ -2850,7 +2848,7 @@ TEST_P(MulSpectrums, Simple)
{
cv::Mat c_gold;
cv::mulSpectrums(a, b, c_gold, flag, false);
cv::Mat c;
cv::gpu::GpuMat d_c;
@@ -2882,7 +2880,7 @@ TEST_P(MulSpectrums, Scaled)
}
INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, Combine(
ALL_DEVICES,
ALL_DEVICES,
Values(0, (int) cv::DFT_ROWS)));
////////////////////////////////////////////////////////////////////////////
@@ -2892,7 +2890,7 @@ struct Dft : TestWithParam<cv::gpu::DeviceInfo>
{
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
virtual void SetUp()
{
devInfo = GetParam();
@@ -2956,7 +2954,7 @@ TEST_P(Dft, C2C)
void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
{
SCOPED_TRACE(hint);
cv::RNG& rng = TS::ptr()->get_rng();
cv::Mat a = randomMat(rng, cv::Size(cols, rows), CV_32FC1, 0.0, 10.0, false);
@@ -2981,7 +2979,7 @@ void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), 0);
cv::gpu::dft(d_b, d_c, cv::Size(cols, rows), cv::DFT_REAL_OUTPUT | cv::DFT_SCALE);
EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
EXPECT_TRUE(!inplace || d_c.ptr() == d_c_data.ptr());
ASSERT_EQ(CV_32F, d_c.depth());
@@ -3019,7 +3017,7 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Dft, ALL_DEVICES);
////////////////////////////////////////////////////////////////////////////
// blend
template <typename T>
template <typename T>
void blendLinearGold(const cv::Mat& img1, const cv::Mat& img2, const cv::Mat& weights1, const cv::Mat& weights2, cv::Mat& result_gold)
{
result_gold.create(img1.size(), img1.type());
@@ -3057,7 +3055,7 @@ PARAM_TEST_CASE(Blend, cv::gpu::DeviceInfo, MatType, UseRoi)
cv::Mat result_gold;
virtual void SetUp()
virtual void SetUp()
{
devInfo = GET_PARAM(0);
type = GET_PARAM(1);
@@ -3075,7 +3073,7 @@ PARAM_TEST_CASE(Blend, cv::gpu::DeviceInfo, MatType, UseRoi)
img2 = randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);
weights1 = randomMat(rng, size, CV_32F, 0, 1, false);
weights2 = randomMat(rng, size, CV_32F, 0, 1, false);
if (depth == CV_8U)
blendLinearGold<uchar>(img1, img2, weights1, weights2, result_gold);
else
@@ -3101,105 +3099,6 @@ INSTANTIATE_TEST_CASE_P(ImgProc, Blend, Combine(
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
WHOLE_SUBMAT));
////////////////////////////////////////////////////////
// pyrDown
PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, MatType, UseRoi)
{
cv::gpu::DeviceInfo devInfo;
int type;
bool useRoi;
cv::Mat src;
cv::Mat dst_gold;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
type = GET_PARAM(1);
useRoi = GET_PARAM(2);
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = TS::ptr()->get_rng();
cv::Size size(rng.uniform(100, 200), rng.uniform(100, 200));
src = randomMat(rng, size, type, 0.0, 255.0, false);
cv::pyrDown(src, dst_gold);
}
};
TEST_P(PyrDown, Accuracy)
{
cv::Mat dst;
cv::gpu::GpuMat d_dst;
cv::gpu::pyrDown(loadMat(src, useRoi), d_dst);
d_dst.download(dst);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
}
INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, Combine(
ALL_DEVICES,
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),
WHOLE_SUBMAT));
////////////////////////////////////////////////////////
// pyrUp
PARAM_TEST_CASE(PyrUp, cv::gpu::DeviceInfo, MatType, UseRoi)
{
cv::gpu::DeviceInfo devInfo;
int type;
bool useRoi;
cv::Mat src;
cv::Mat dst_gold;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
type = GET_PARAM(1);
useRoi = GET_PARAM(2);
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = TS::ptr()->get_rng();
cv::Size size(rng.uniform(200, 400), rng.uniform(200, 400));
src = randomMat(rng, size, type, 0.0, 255.0, false);
cv::pyrUp(src, dst_gold);
}
};
TEST_P(PyrUp, Accuracy)
{
cv::Mat dst;
cv::gpu::GpuMat d_dst;
cv::gpu::pyrUp(loadMat(src, useRoi), d_dst, cv::BORDER_REFLECT);
d_dst.download(dst);
// results differs only on border left and top border due different border extrapolation type
EXPECT_MAT_NEAR(dst_gold(cv::Range(1, dst_gold.rows), cv::Range(1, dst_gold.cols)), dst(cv::Range(1, dst_gold.rows), cv::Range(1, dst_gold.cols)), src.depth() == CV_32F ? 1e-4 : 1.0);
}
INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, Combine(
ALL_DEVICES,
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),
WHOLE_SUBMAT));
////////////////////////////////////////////////////////
// Canny
@@ -3209,7 +3108,7 @@ PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, int, bool, UseRoi)
int apperture_size;
bool L2gradient;
bool useRoi;
cv::Mat img;
double low_thresh;
@@ -3217,7 +3116,7 @@ PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, int, bool, UseRoi)
cv::Mat edges_gold;
virtual void SetUp()
virtual void SetUp()
{
devInfo = GET_PARAM(0);
apperture_size = GET_PARAM(1);
@@ -3225,13 +3124,13 @@ PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, int, bool, UseRoi)
useRoi = GET_PARAM(3);
cv::gpu::setDevice(devInfo.deviceID());
img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img.empty());
ASSERT_FALSE(img.empty());
low_thresh = 50.0;
high_thresh = 100.0;
cv::Canny(img, edges_gold, low_thresh, high_thresh, apperture_size, L2gradient);
}
};
@@ -3301,14 +3200,14 @@ namespace
}
PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, int, bool)
{
{
cv::gpu::DeviceInfo devInfo;
int ksize;
bool ccorr;
cv::Mat src;
cv::Mat kernel;
cv::Mat dst_gold;
virtual void SetUp()
@@ -3318,14 +3217,14 @@ PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, int, bool)
ccorr = GET_PARAM(2);
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = TS::ptr()->get_rng();
cv::Size size(rng.uniform(200, 400), rng.uniform(200, 400));
src = randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);
kernel = randomMat(rng, cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0, false);
convolveDFT(src, kernel, dst_gold, ccorr);
}
};
@@ -3345,7 +3244,7 @@ TEST_P(Convolve, Accuracy)
INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, Combine(
ALL_DEVICES,
ALL_DEVICES,
Values(3, 7, 11, 17, 19, 23, 45),
Bool()));

View File

@@ -0,0 +1,126 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#ifdef HAVE_CUDA
////////////////////////////////////////////////////////
// pyrDown
PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
{
cv::gpu::DeviceInfo devInfo;
cv::Size size;
int type;
bool useRoi;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
size = GET_PARAM(1);
type = GET_PARAM(2);
useRoi = GET_PARAM(3);
cv::gpu::setDevice(devInfo.deviceID());
}
};
TEST_P(PyrDown, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(cv::Size((size.width + 1) / 2, (size.height + 1) / 2), type, useRoi);
cv::gpu::pyrDown(loadMat(src, useRoi), dst);
cv::Mat dst_gold;
cv::pyrDown(src, dst_gold);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrDown, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
WHOLE_SUBMAT));
////////////////////////////////////////////////////////
// pyrUp
PARAM_TEST_CASE(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
{
cv::gpu::DeviceInfo devInfo;
cv::Size size;
int type;
bool useRoi;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
size = GET_PARAM(1);
type = GET_PARAM(2);
useRoi = GET_PARAM(3);
cv::gpu::setDevice(devInfo.deviceID());
}
};
TEST_P(PyrUp, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(cv::Size(size.width * 2, size.height * 2), type, useRoi);
cv::gpu::pyrUp(loadMat(src, useRoi), dst);
cv::Mat dst_gold;
cv::pyrUp(src, dst_gold);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrUp, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
WHOLE_SUBMAT));
#endif // HAVE_CUDA

View File

@@ -88,7 +88,7 @@ double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2);
EXPECT_LE(checkSimilarity(cv::Mat(mat1), cv::Mat(mat2)), eps); \
}
namespace cv { namespace gpu
namespace cv { namespace gpu
{
void PrintTo(const DeviceInfo& info, std::ostream* os);
}}
@@ -167,6 +167,8 @@ CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX
#define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113))
#define WHOLE testing::Values(UseRoi(false))
#define SUBMAT testing::Values(UseRoi(true))
#define WHOLE_SUBMAT testing::Values(UseRoi(false), UseRoi(true))
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))