2011-06-29 12:14:16 +02:00
|
|
|
/*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 "test_precomp.hpp"
|
|
|
|
|
|
|
|
#ifdef HAVE_CUDA
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
using namespace cvtest;
|
|
|
|
using namespace testing;
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// threshold
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, MatType, ThreshOp, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
|
|
|
int threshOp;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
double maxVal;
|
|
|
|
double thresh;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
threshOp = GET_PARAM(2);
|
|
|
|
useRoi = GET_PARAM(3);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 127.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
maxVal = rng.uniform(20.0, 127.0);
|
|
|
|
thresh = rng.uniform(0.0, maxVal);
|
|
|
|
|
|
|
|
cv::threshold(src, dst_gold, thresh, maxVal, threshOp);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(Threshold, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::threshold(loadMat(src, useRoi), gpuRes, thresh, maxVal, threshOp);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_32FC1),
|
|
|
|
Values((int)cv::THRESH_BINARY, (int)cv::THRESH_BINARY_INV, (int)cv::THRESH_TRUNC, (int)cv::THRESH_TOZERO, (int)cv::THRESH_TOZERO_INV),
|
|
|
|
USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// resize
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Resize, cv::gpu::DeviceInfo, MatType, Interpolation, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
|
|
|
int interpolation;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::Mat dst_gold_up;
|
|
|
|
cv::Mat dst_gold_down;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
interpolation = GET_PARAM(2);
|
|
|
|
useRoi = GET_PARAM(3);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, CV_MAT_DEPTH(type) == CV_32F ? 1.0 : 255.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::resize(src, dst_gold_up, cv::Size(), 2.0, 2.0, interpolation);
|
|
|
|
cv::resize(src, dst_gold_down, cv::Size(), 0.5, 0.5, interpolation);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
TEST_P(Resize, Up)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
|
|
|
cv::gpu::resize(loadMat(src, useRoi), gpuRes, cv::Size(), 2.0, 2.0, interpolation);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
EXPECT_MAT_SIMILAR(dst_gold_up, dst, 0.21);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(Resize, Down)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::GpuMat gpuRes;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::resize(loadMat(src, useRoi), gpuRes, cv::Size(), 0.5, 0.5, interpolation);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
gpuRes.download(dst);
|
2011-06-29 12:14:16 +02:00
|
|
|
);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
EXPECT_MAT_SIMILAR(dst_gold_down, dst, 0.22);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Resize, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
|
|
|
Values((int)cv::INTER_NEAREST, (int)cv::INTER_LINEAR, (int)cv::INTER_CUBIC),
|
|
|
|
USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2011-08-10 14:05:24 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// remap
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Remap, cv::gpu::DeviceInfo, MatType, Interpolation, Border, UseRoi)
|
2011-08-10 14:05:24 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2011-08-31 13:42:54 +02:00
|
|
|
int interpolation;
|
|
|
|
int borderType;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-08-10 14:05:24 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
cv::Mat xmap;
|
|
|
|
cv::Mat ymap;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
interpolation = GET_PARAM(2);
|
|
|
|
borderType = GET_PARAM(3);
|
|
|
|
useRoi = GET_PARAM(4);
|
2011-08-10 14:05:24 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-08-10 14:05:24 +02:00
|
|
|
|
2011-08-31 13:42:54 +02:00
|
|
|
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
|
2011-08-10 14:05:24 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 256.0, false);
|
2011-08-31 13:42:54 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
xmap = randomMat(rng, size, CV_32FC1, -20.0, src.cols + 20, false);
|
|
|
|
ymap = randomMat(rng, size, CV_32FC1, -20.0, src.rows + 20, false);
|
2011-08-10 14:05:24 +02:00
|
|
|
|
2011-08-31 15:21:14 +02:00
|
|
|
cv::remap(src, dst_gold, xmap, ymap, interpolation, borderType);
|
2011-08-10 14:05:24 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(Remap, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::remap(loadMat(src, useRoi), gpuRes, loadMat(xmap, useRoi), loadMat(ymap, useRoi), interpolation, borderType);
|
2011-08-10 14:05:24 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-09-06 09:01:23 +02:00
|
|
|
EXPECT_MAT_SIMILAR(dst_gold, dst, 1e-1);
|
2011-08-10 14:05:24 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Remap, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
|
|
|
Values((int)cv::INTER_NEAREST, (int)cv::INTER_LINEAR, (int)cv::INTER_CUBIC),
|
|
|
|
Values((int)cv::BORDER_REFLECT101, (int)cv::BORDER_REPLICATE, (int)cv::BORDER_CONSTANT, (int)cv::BORDER_REFLECT, (int)cv::BORDER_WRAP),
|
|
|
|
USE_ROI));
|
2011-08-10 14:05:24 +02:00
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// copyMakeBorder
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, MatType, Border, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2011-09-21 09:02:45 +02:00
|
|
|
int borderType;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
int top;
|
|
|
|
int botton;
|
|
|
|
int left;
|
|
|
|
int right;
|
|
|
|
cv::Scalar val;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
borderType = GET_PARAM(2);
|
|
|
|
useRoi = GET_PARAM(3);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 127.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
top = rng.uniform(1, 10);
|
|
|
|
botton = rng.uniform(1, 10);
|
|
|
|
left = rng.uniform(1, 10);
|
|
|
|
right = rng.uniform(1, 10);
|
|
|
|
val = cv::Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
|
|
|
|
|
2011-09-21 09:02:45 +02:00
|
|
|
cv::copyMakeBorder(src, dst_gold, top, botton, left, right, borderType, val);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(CopyMakeBorder, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::copyMakeBorder(loadMat(src, useRoi), gpuRes, top, botton, left, right, borderType, val);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
|
|
|
Values((int)cv::BORDER_REFLECT101, (int)cv::BORDER_REPLICATE, (int)cv::BORDER_CONSTANT, (int)cv::BORDER_REFLECT, (int)cv::BORDER_WRAP),
|
|
|
|
USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// warpAffine & warpPerspective
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, MatType, WarpFlags)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
int flags;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
cv::Mat M;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
flags = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 127.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
static double reflect[2][3] = { {-1, 0, 0},
|
|
|
|
{ 0, -1, 0}};
|
|
|
|
reflect[0][2] = size.width;
|
|
|
|
reflect[1][2] = size.height;
|
|
|
|
M = cv::Mat(2, 3, CV_64F, (void*)reflect);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::warpAffine(src, dst_gold, M, src.size(), flags);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(WarpAffine, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::warpAffine(loadMat(src), gpuRes, M, src.size(), flags);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
// Check inner parts (ignoring 1 pixel width border)
|
|
|
|
cv::Mat dst_gold_roi = dst_gold.rowRange(1, dst_gold.rows - 1).colRange(1, dst_gold.cols - 1);
|
|
|
|
cv::Mat dst_roi = dst.rowRange(1, dst.rows - 1).colRange(1, dst.cols - 1);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold_roi, dst_roi, 1e-3);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
|
|
|
Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC,
|
|
|
|
(int) (cv::INTER_NEAREST | cv::WARP_INVERSE_MAP), (int) (cv::INTER_LINEAR | cv::WARP_INVERSE_MAP),
|
|
|
|
(int) (cv::INTER_CUBIC | cv::WARP_INVERSE_MAP))));
|
|
|
|
|
|
|
|
PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, MatType, WarpFlags)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
int flags;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
cv::Mat M;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
flags = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 127.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
static double reflect[3][3] = { { -1, 0, 0},
|
|
|
|
{ 0, -1, 0},
|
|
|
|
{ 0, 0, 1}};
|
|
|
|
reflect[0][2] = size.width;
|
|
|
|
reflect[1][2] = size.height;
|
|
|
|
M = cv::Mat(3, 3, CV_64F, (void*)reflect);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::warpPerspective(src, dst_gold, M, src.size(), flags);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(WarpPerspective, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::warpPerspective(loadMat(src), gpuRes, M, src.size(), flags);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
// Check inner parts (ignoring 1 pixel width border)
|
|
|
|
cv::Mat dst_gold_roi = dst_gold.rowRange(1, dst_gold.rows - 1).colRange(1, dst_gold.cols - 1);
|
|
|
|
cv::Mat dst_roi = dst.rowRange(1, dst.rows - 1).colRange(1, dst.cols - 1);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold_roi, dst_roi, 1e-3);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
|
|
|
Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC,
|
|
|
|
(int) (cv::INTER_NEAREST | cv::WARP_INVERSE_MAP), (int) (cv::INTER_LINEAR | cv::WARP_INVERSE_MAP),
|
|
|
|
(int) (cv::INTER_CUBIC | cv::WARP_INVERSE_MAP))));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// integral
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Integral, cv::gpu::DeviceInfo, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
useRoi = GET_PARAM(1);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, CV_8UC1, 0.0, 255.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::integral(src, dst_gold, CV_32S);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(Integral, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::integral(loadMat(src, useRoi), gpuRes);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Integral, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cvtColor
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(CvtColor, cv::gpu::DeviceInfo, MatType, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-08-09 08:25:01 +02:00
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat img;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
useRoi = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
|
|
|
cv::Mat imgBase = readImage("stereobm/aloe-L.png");
|
|
|
|
ASSERT_FALSE(imgBase.empty());
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
imgBase.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2RGB)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2RGBA)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2RGBA);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2RGBA);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
TEST_P(CvtColor, BGR2BGRA)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
TEST_P(CvtColor, BGRA2RGB)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGRA2BGR)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGRA2RGBA)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2RGBA);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2RGBA);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2GRAY)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2GRAY)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, GRAY2BGR)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, GRAY2BGRA)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGRA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGRA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGRA2GRAY)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGBA2GRAY)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2BGR565)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2BGR565)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5652BGR)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5652RGB)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGRA2BGR565)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGBA2BGR565)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5652BGRA)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652BGRA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652BGRA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5652RGBA)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652RGBA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652RGBA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, GRAY2BGR565)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5652GRAY)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2BGR555)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2BGR555)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5552BGR)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5552RGB)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGRA2BGR555)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGBA2BGR555)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5552BGRA)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552BGRA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552BGRA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5552RGBA)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552RGBA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552RGBA, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, GRAY2BGR555)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR5552GRAY)
|
|
|
|
{
|
|
|
|
if (type != CV_8U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552GRAY);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2XYZ)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2XYZ)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, BGR2XYZ4)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGRA2XYZ4)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
TEST_P(CvtColor, XYZ2BGR)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, XYZ2RGB)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, XYZ42BGR)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, XYZ42BGRA)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2YCrCb)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2YCrCb)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2YCrCb4)
|
|
|
|
{
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGBA2YCrCb4)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, YCrCb2BGR)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, YCrCb2RGB)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, YCrCb42RGB)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, YCrCb42RGBA)
|
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2HSV)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2HSV)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2HSV4)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGBA2HSV4)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, BGR2HLS)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2HLS)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGB2HLS4)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, RGBA2HLS4)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, HSV2BGR)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, HSV2RGB)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, HSV42BGR)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, HSV42BGRA)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, HLS2BGR)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, HLS2RGB)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(CvtColor, HLS42RGB)
|
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-08-17 15:46:36 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HLS42RGBA)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-08-17 15:46:36 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, BGR2HSV_FULL)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HSV_FULL);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HSV_FULL);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-08-17 15:46:36 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGB2HSV_FULL)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGB2HSV4_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL, 4);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGBA2HSV4_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL, 4);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, BGR2HLS_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-17 15:46:36 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat src = img;
|
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGB2HLS_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-17 15:46:36 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGB2HLS4_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-17 15:46:36 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL, 4);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGBA2HLS4_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-17 15:46:36 +02:00
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL, 4);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HSV2BGR_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HSV2RGB_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HSV42RGB_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HSV42RGBA_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL, 4);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HLS2BGR_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2BGR_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2BGR_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HLS2RGB_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HLS42RGB_FULL)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, HLS42RGBA_FULL)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
|
|
|
if (type == CV_16U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, BGR2YUV)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat src = img;
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YUV);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YUV);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
2011-08-17 15:46:36 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGB2YUV)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YUV);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YUV);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
2011-08-17 15:46:36 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, YUV2BGR)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, YUV42BGR)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
2011-08-17 15:46:36 +02:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, YUV42BGRA)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR, 4);
|
2011-08-22 13:07:52 +02:00
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(src, channels);
|
|
|
|
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
|
|
|
|
cv::merge(channels, 4, src);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR, 4);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, YUV2RGB)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_RGB2YUV);
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_YUV2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2RGB);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, BGR2YUV4)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
2011-08-22 13:07:52 +02:00
|
|
|
cv::Mat src = img;
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YUV);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YUV, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
|
|
|
}
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
TEST_P(CvtColor, RGBA2YUV4)
|
2011-08-17 15:46:36 +02:00
|
|
|
{
|
|
|
|
cv::Mat src;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
2011-08-17 15:46:36 +02:00
|
|
|
cv::Mat dst_gold;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YUV);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuRes;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YUV, 4);
|
2011-08-17 15:46:36 +02:00
|
|
|
|
|
|
|
gpuRes.download(dst);
|
|
|
|
);
|
|
|
|
|
2011-08-22 13:07:52 +02:00
|
|
|
ASSERT_EQ(4, dst.channels());
|
|
|
|
|
|
|
|
cv::Mat channels[4];
|
|
|
|
cv::split(dst, channels);
|
|
|
|
cv::merge(channels, 3, dst);
|
|
|
|
|
2011-08-17 15:46:36 +02:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8U, CV_16U, CV_32F),
|
|
|
|
USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// histograms
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
struct HistEven : TestWithParam<cv::gpu::DeviceInfo>
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::Mat hsv;
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
int hbins;
|
|
|
|
float hranges[2];
|
|
|
|
|
|
|
|
cv::Mat hist_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
devInfo = GetParam();
|
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::Mat img = readImage("stereobm/aloe-L.png");
|
|
|
|
ASSERT_FALSE(img.empty());
|
|
|
|
|
|
|
|
cv::cvtColor(img, hsv, CV_BGR2HSV);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
hbins = 30;
|
|
|
|
|
|
|
|
hranges[0] = 0;
|
|
|
|
hranges[1] = 180;
|
|
|
|
|
|
|
|
int histSize[] = {hbins};
|
|
|
|
const float* ranges[] = {hranges};
|
|
|
|
|
|
|
|
cv::MatND histnd;
|
|
|
|
|
|
|
|
int channels[] = {0};
|
|
|
|
cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges);
|
|
|
|
|
|
|
|
hist_gold = histnd;
|
|
|
|
hist_gold = hist_gold.t();
|
|
|
|
hist_gold.convertTo(hist_gold, CV_32S);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-08-01 15:15:37 +02:00
|
|
|
TEST_P(HistEven, Accuracy)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::Mat hist;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
std::vector<cv::gpu::GpuMat> srcs;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::split(loadMat(hsv), srcs);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::GpuMat gpuHist;
|
|
|
|
|
|
|
|
cv::gpu::histEven(srcs[0], gpuHist, hbins, (int)hranges[0], (int)hranges[1]);
|
|
|
|
|
|
|
|
gpuHist.download(hist);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, HistEven, ALL_DEVICES);
|
2011-08-01 15:15:37 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
struct CalcHist : TestWithParam<cv::gpu::DeviceInfo>
|
2011-08-01 15:15:37 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
cv::Mat hist_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
devInfo = GetParam();
|
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-08-01 15:15:37 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, CV_8UC1, 0, 255, false);
|
2011-08-01 15:15:37 +02:00
|
|
|
|
|
|
|
hist_gold.create(1, 256, CV_32SC1);
|
|
|
|
hist_gold.setTo(cv::Scalar::all(0));
|
|
|
|
|
|
|
|
int* hist = hist_gold.ptr<int>();
|
|
|
|
for (int y = 0; y < src.rows; ++y)
|
|
|
|
{
|
|
|
|
const uchar* src_row = src.ptr(y);
|
|
|
|
|
|
|
|
for (int x = 0; x < src.cols; ++x)
|
|
|
|
++hist[src_row[x]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(CalcHist, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat hist;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuHist;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::calcHist(loadMat(src), gpuHist);
|
2011-08-01 15:15:37 +02:00
|
|
|
|
|
|
|
gpuHist.download(hist);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, ALL_DEVICES);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
struct EqualizeHist : TestWithParam<cv::gpu::DeviceInfo>
|
2011-08-02 10:33:27 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
devInfo = GetParam();
|
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-08-02 10:33:27 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, CV_8UC1, 0, 255, false);
|
2011-08-02 10:33:27 +02:00
|
|
|
|
|
|
|
cv::equalizeHist(src, dst_gold);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(EqualizeHist, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpuDst;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::equalizeHist(loadMat(src), gpuDst);
|
2011-08-02 10:33:27 +02:00
|
|
|
|
|
|
|
gpuDst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 3.0);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, ALL_DEVICES);
|
2011-08-02 10:33:27 +02:00
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cornerHarris
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, Border)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
int borderType;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat src;
|
|
|
|
int blockSize;
|
|
|
|
int apertureSize;
|
|
|
|
double k;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
borderType = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
|
|
|
|
ASSERT_FALSE(img.empty());
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
|
|
|
|
|
|
|
|
blockSize = 1 + rng.next() % 5;
|
|
|
|
apertureSize = 1 + 2 * (rng.next() % 4);
|
|
|
|
k = rng.uniform(0.1, 0.9);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(CornerHarris, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cornerHarris(loadMat(src), dev_dst, blockSize, apertureSize, k, borderType);
|
2011-06-29 12:14:16 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
2012-01-23 08:14:45 +01:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_32FC1),
|
2012-01-23 08:14:45 +01:00
|
|
|
Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT)));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cornerMinEigen
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, Border)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
int borderType;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat src;
|
|
|
|
int blockSize;
|
|
|
|
int apertureSize;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
borderType = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
|
|
|
|
ASSERT_FALSE(img.empty());
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
|
|
|
|
|
|
|
|
blockSize = 1 + rng.next() % 5;
|
|
|
|
apertureSize = 1 + 2 * (rng.next() % 4);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(CornerMinEigen, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::cornerMinEigenVal(loadMat(src), dev_dst, blockSize, apertureSize, borderType);
|
2011-06-29 12:14:16 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
2012-01-23 08:14:45 +01:00
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigen, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(CV_8UC1, CV_32FC1),
|
2012-01-23 08:14:45 +01:00
|
|
|
Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT)));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// ColumnSum
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
struct ColumnSum : TestWithParam<cv::gpu::DeviceInfo>
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
devInfo = GetParam();
|
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, CV_32F, 0.0, 1.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(ColumnSum, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::columnSum(loadMat(src), dev_dst);
|
2011-06-29 12:14:16 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
for (int j = 0; j < src.cols; ++j)
|
|
|
|
{
|
|
|
|
float gold = src.at<float>(0, j);
|
|
|
|
float res = dst.at<float>(0, j);
|
|
|
|
ASSERT_NEAR(res, gold, 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 1; i < src.rows; ++i)
|
|
|
|
{
|
|
|
|
for (int j = 0; j < src.cols; ++j)
|
|
|
|
{
|
|
|
|
float gold = src.at<float>(i, j) += src.at<float>(i - 1, j);
|
|
|
|
float res = dst.at<float>(i, j);
|
|
|
|
ASSERT_NEAR(res, gold, 0.5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, ALL_DEVICES);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// Norm
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Norm, cv::gpu::DeviceInfo, MatType, NormCode, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
int normType;
|
|
|
|
bool useRoi;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
|
|
|
|
double gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
normType = GET_PARAM(2);
|
|
|
|
useRoi = GET_PARAM(3);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 10.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
gold = cv::norm(src, normType);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(Norm, Accuracy)
|
|
|
|
{
|
|
|
|
double res;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
2012-01-10 12:11:58 +01:00
|
|
|
res = cv::gpu::norm(loadMat(src, useRoi), normType);
|
2011-06-29 12:14:16 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_NEAR(res, gold, 0.5);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Norm, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
TYPES(CV_8U, CV_32F, 1, 1),
|
|
|
|
Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2),
|
|
|
|
USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// reprojectImageTo3D
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(ReprojectImageTo3D, cv::gpu::DeviceInfo, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat disp;
|
|
|
|
cv::Mat Q;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
useRoi = GET_PARAM(1);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 500), rng.uniform(100, 500));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
disp = randomMat(rng, size, CV_8UC1, 5.0, 30.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
Q = randomMat(rng, cv::Size(4, 4), CV_32FC1, 0.1, 1.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::reprojectImageTo3D(disp, dst_gold, Q, false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(ReprojectImageTo3D, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat gpures;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), gpures, Q);
|
2011-06-29 12:14:16 +02:00
|
|
|
gpures.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(dst_gold.size(), dst.size());
|
|
|
|
|
|
|
|
for (int y = 0; y < dst_gold.rows; ++y)
|
|
|
|
{
|
|
|
|
const cv::Vec3f* cpu_row = dst_gold.ptr<cv::Vec3f>(y);
|
|
|
|
const cv::Vec4f* gpu_row = dst.ptr<cv::Vec4f>(y);
|
|
|
|
|
|
|
|
for (int x = 0; x < dst_gold.cols; ++x)
|
|
|
|
{
|
|
|
|
cv::Vec3f gold = cpu_row[x];
|
|
|
|
cv::Vec4f res = gpu_row[x];
|
|
|
|
|
|
|
|
ASSERT_NEAR(res[0], gold[0], 1e-5);
|
|
|
|
ASSERT_NEAR(res[1], gold[1], 1e-5);
|
|
|
|
ASSERT_NEAR(res[2], gold[2], 1e-5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, Combine(ALL_DEVICES, USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// meanShift
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
struct MeanShift : TestWithParam<cv::gpu::DeviceInfo>
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::Mat rgba;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
int spatialRad;
|
|
|
|
int colorRad;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
devInfo = GetParam();
|
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::Mat img = readImage("meanshift/cones.png");
|
|
|
|
ASSERT_FALSE(img.empty());
|
|
|
|
|
|
|
|
cv::cvtColor(img, rgba, CV_BGR2BGRA);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
spatialRad = 30;
|
|
|
|
colorRad = 30;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
img_template = readImage("meanshift/con_result_CC1X.png");
|
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
ASSERT_FALSE(img_template.empty());
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::meanShiftFiltering(loadMat(rgba), dev_dst, spatialRad, colorRad);
|
2011-06-29 12:14:16 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(CV_8UC4, dst.type());
|
|
|
|
|
|
|
|
cv::Mat result;
|
|
|
|
cv::cvtColor(dst, result, CV_BGRA2BGR);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(img_template, result, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(MeanShift, Proc)
|
|
|
|
{
|
|
|
|
cv::Mat spmap_template;
|
|
|
|
cv::FileStorage fs;
|
|
|
|
|
|
|
|
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
|
|
|
fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);
|
|
|
|
else
|
|
|
|
fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);
|
|
|
|
|
|
|
|
ASSERT_TRUE(fs.isOpened());
|
|
|
|
|
|
|
|
fs["spmap"] >> spmap_template;
|
|
|
|
|
|
|
|
ASSERT_TRUE(!rgba.empty() && !spmap_template.empty());
|
|
|
|
|
|
|
|
cv::Mat rmap_filtered;
|
|
|
|
cv::Mat rmap;
|
|
|
|
cv::Mat spmap;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_rmap_filtered;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::meanShiftFiltering(loadMat(rgba), d_rmap_filtered, spatialRad, colorRad);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::GpuMat d_rmap;
|
|
|
|
cv::gpu::GpuMat d_spmap;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::meanShiftProc(loadMat(rgba), d_rmap, d_spmap, spatialRad, colorRad);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
d_rmap_filtered.download(rmap_filtered);
|
|
|
|
d_rmap.download(rmap);
|
|
|
|
d_spmap.download(spmap);
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT_EQ(CV_8UC4, rmap.type());
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0);
|
|
|
|
EXPECT_MAT_NEAR(spmap_template, spmap, 0.0);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MeanShift, ALL_DEVICES);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, int)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int minsize;
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::Mat rgba;
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
minsize = GET_PARAM(1);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::Mat img = readImage("meanshift/cones.png");
|
|
|
|
ASSERT_FALSE(img.empty());
|
|
|
|
|
|
|
|
cv::cvtColor(img, rgba, CV_BGR2BGRA);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
std::ostringstream path;
|
|
|
|
path << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;
|
|
|
|
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
|
|
|
path << ".png";
|
|
|
|
else
|
|
|
|
path << "_CC1X.png";
|
|
|
|
|
|
|
|
dst_gold = readImage(path.str());
|
2011-08-09 08:25:01 +02:00
|
|
|
ASSERT_FALSE(dst_gold.empty());
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(MeanShiftSegmentation, Regression)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::meanShiftSegmentation(loadMat(rgba), dst, 10, 10, minsize);
|
2011-06-29 12:14:16 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
cv::Mat dst_rgb;
|
|
|
|
cv::cvtColor(dst, dst_rgb, CV_BGRA2BGR);
|
|
|
|
|
2011-06-29 13:14:03 +02:00
|
|
|
EXPECT_MAT_SIMILAR(dst_gold, dst_rgb, 1e-3);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(0, 4, 20, 84, 340, 1364)));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// matchTemplate
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, int, TemplateMethod)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int cn;
|
|
|
|
int method;
|
|
|
|
|
|
|
|
int n, m, h, w;
|
|
|
|
cv::Mat image, templ;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
cn = GET_PARAM(1);
|
|
|
|
method = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
n = rng.uniform(30, 100);
|
|
|
|
m = rng.uniform(30, 100);
|
|
|
|
h = rng.uniform(5, n - 1);
|
|
|
|
w = rng.uniform(5, m - 1);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
image = randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);
|
|
|
|
templ = randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::matchTemplate(image, templ, dst_gold, method);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(MatchTemplate8U, Regression)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dev_dst, method);
|
2011-06-29 12:14:16 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 5 * h * w * 1e-4);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate8U, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
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)));
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(MatchTemplate32F, cv::gpu::DeviceInfo, int, TemplateMethod)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int cn;
|
|
|
|
int method;
|
|
|
|
|
|
|
|
int n, m, h, w;
|
|
|
|
cv::Mat image, templ;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
cn = GET_PARAM(1);
|
|
|
|
method = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
n = rng.uniform(30, 100);
|
|
|
|
m = rng.uniform(30, 100);
|
|
|
|
h = rng.uniform(5, n - 1);
|
|
|
|
w = rng.uniform(5, m - 1);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
image = randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);
|
|
|
|
templ = randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::matchTemplate(image, templ, dst_gold, method);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(MatchTemplate32F, Regression)
|
|
|
|
{
|
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dev_dst, method);
|
2011-06-29 12:14:16 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.25 * h * w * 1e-4);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate32F, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Range(1, 5),
|
|
|
|
Values((int) cv::TM_SQDIFF, (int) cv::TM_CCORR)));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
|
|
|
|
PARAM_TEST_CASE(MatchTemplateBlackSource, cv::gpu::DeviceInfo, TemplateMethod)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int method;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
method = GET_PARAM(1);
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-08-29 10:06:45 +02:00
|
|
|
TEST_P(MatchTemplateBlackSource, Accuracy)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2011-08-29 10:06:45 +02:00
|
|
|
cv::Mat image = readImage("matchtemplate/black.png");
|
|
|
|
ASSERT_FALSE(image.empty());
|
|
|
|
|
|
|
|
cv::Mat pattern = readImage("matchtemplate/cat.png");
|
|
|
|
ASSERT_FALSE(pattern.empty());
|
|
|
|
|
|
|
|
cv::Point maxLocGold = cv::Point(284, 12);
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), dev_dst, method);
|
2011-06-29 12:14:16 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
double maxValue;
|
|
|
|
cv::Point maxLoc;
|
|
|
|
cv::minMaxLoc(dst, NULL, &maxValue, NULL, &maxLoc);
|
|
|
|
|
|
|
|
ASSERT_EQ(maxLocGold, maxLoc);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplateBlackSource, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values((int) cv::TM_CCOEFF_NORMED, (int) cv::TM_CCORR_NORMED)));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2011-08-29 10:06:45 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(MatchTemplate_CCOEF_NORMED, cv::gpu::DeviceInfo, std::pair<std::string, std::string>)
|
2011-08-29 10:06:45 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
2011-08-29 13:31:52 +02:00
|
|
|
std::string imageName;
|
|
|
|
std::string patternName;
|
|
|
|
|
2011-08-29 10:06:45 +02:00
|
|
|
cv::Mat image, pattern;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
imageName = GET_PARAM(1).first;
|
|
|
|
patternName = GET_PARAM(1).second;
|
2011-08-29 10:06:45 +02:00
|
|
|
|
2011-08-29 13:31:52 +02:00
|
|
|
image = readImage(imageName);
|
2011-08-29 10:06:45 +02:00
|
|
|
ASSERT_FALSE(image.empty());
|
|
|
|
|
2011-08-29 13:31:52 +02:00
|
|
|
pattern = readImage(patternName);
|
2011-08-29 10:06:45 +02:00
|
|
|
ASSERT_FALSE(pattern.empty());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(MatchTemplate_CCOEF_NORMED, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat dstGold;
|
|
|
|
cv::matchTemplate(image, pattern, dstGold, CV_TM_CCOEFF_NORMED);
|
2011-10-13 15:02:41 +02:00
|
|
|
double minValGold, maxValGold;
|
2011-08-29 10:06:45 +02:00
|
|
|
cv::Point minLocGold, maxLocGold;
|
2011-10-13 15:02:41 +02:00
|
|
|
cv::minMaxLoc(dstGold, &minValGold, &maxValGold, &minLocGold, &maxLocGold);
|
2011-08-29 10:06:45 +02:00
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), dev_dst, CV_TM_CCOEFF_NORMED);
|
2011-08-29 10:06:45 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
cv::Point minLoc, maxLoc;
|
|
|
|
double minVal, maxVal;
|
|
|
|
cv::minMaxLoc(dst, &minVal, &maxVal, &minLoc, &maxLoc);
|
|
|
|
|
|
|
|
ASSERT_EQ(minLocGold, minLoc);
|
|
|
|
ASSERT_EQ(maxLocGold, maxLoc);
|
|
|
|
ASSERT_LE(maxVal, 1.);
|
|
|
|
ASSERT_GE(minVal, -1.);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_CCOEF_NORMED, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(std::make_pair(std::string("matchtemplate/source-0.png"), std::string("matchtemplate/target-0.png")))));
|
2011-08-29 10:06:45 +02:00
|
|
|
|
2011-10-13 15:02:41 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(MatchTemplate_CCOEF_NORMED_NoThrow, cv::gpu::DeviceInfo, std::pair<std::string, std::string>)
|
2011-10-13 15:02:41 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
std::string imageName;
|
|
|
|
std::string patternName;
|
|
|
|
|
|
|
|
cv::Mat image, pattern;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
imageName = GET_PARAM(1).first;
|
|
|
|
patternName = GET_PARAM(1).second;
|
2011-10-13 15:02:41 +02:00
|
|
|
|
|
|
|
image = readImage(imageName);
|
|
|
|
ASSERT_FALSE(image.empty());
|
|
|
|
|
|
|
|
pattern = readImage(patternName);
|
|
|
|
ASSERT_FALSE(pattern.empty());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(MatchTemplate_CCOEF_NORMED_NoThrow, NoThrow)
|
|
|
|
{
|
|
|
|
cv::Mat dstGold;
|
|
|
|
cv::matchTemplate(image, pattern, dstGold, CV_TM_CCOEFF_NORMED);
|
|
|
|
double minValGold, maxValGold;
|
|
|
|
cv::Point minLocGold, maxLocGold;
|
|
|
|
cv::minMaxLoc(dstGold, &minValGold, &maxValGold, &minLocGold, &maxLocGold);
|
|
|
|
|
|
|
|
cv::Mat dst;
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat dev_dst;
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), dev_dst, CV_TM_CCOEFF_NORMED);
|
2011-10-13 15:02:41 +02:00
|
|
|
dev_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_CCOEF_NORMED_NoThrow, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(std::make_pair(std::string("matchtemplate/source-1.png"), std::string("matchtemplate/target-1.png")))));
|
2011-08-29 10:06:45 +02:00
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// MulSpectrums
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, DftFlags)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
cv::Mat a, b;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
flag = GET_PARAM(1);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
a = randomMat(rng, cv::Size(rng.uniform(100, 200), rng.uniform(100, 200)), CV_32FC2, 0.0, 10.0, false);
|
|
|
|
b = randomMat(rng, a.size(), CV_32FC2, 0.0, 10.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(MulSpectrums, Simple)
|
|
|
|
{
|
|
|
|
cv::Mat c_gold;
|
|
|
|
cv::mulSpectrums(a, b, c_gold, flag, false);
|
|
|
|
|
|
|
|
cv::Mat c;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_c;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::mulSpectrums(loadMat(a), loadMat(b), d_c, flag, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
d_c.download(c);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(c_gold, c, 1e-4);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(MulSpectrums, Scaled)
|
|
|
|
{
|
|
|
|
float scale = 1.f / a.size().area();
|
|
|
|
|
|
|
|
cv::Mat c_gold;
|
|
|
|
cv::mulSpectrums(a, b, c_gold, flag, false);
|
|
|
|
c_gold.convertTo(c_gold, c_gold.type(), scale);
|
|
|
|
|
|
|
|
cv::Mat c;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_c;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::mulAndScaleSpectrums(loadMat(a), loadMat(b), d_c, flag, scale, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
d_c.download(c);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(c_gold, c, 1e-4);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(0, (int) cv::DFT_ROWS)));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Dft
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
struct Dft : TestWithParam<cv::gpu::DeviceInfo>
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
devInfo = GetParam();
|
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
SCOPED_TRACE(hint);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::Mat a = randomMat(rng, cv::Size(cols, rows), CV_32FC2, 0.0, 10.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::Mat b_gold;
|
|
|
|
cv::dft(a, b_gold, flags);
|
|
|
|
|
|
|
|
cv::gpu::GpuMat d_b;
|
|
|
|
cv::gpu::GpuMat d_b_data;
|
|
|
|
if (inplace)
|
|
|
|
{
|
|
|
|
d_b_data.create(1, a.size().area(), CV_32FC2);
|
|
|
|
d_b = cv::gpu::GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
|
|
|
|
}
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), flags);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
|
|
|
|
ASSERT_EQ(CV_32F, d_b.depth());
|
|
|
|
ASSERT_EQ(2, d_b.channels());
|
2011-11-09 14:13:52 +01:00
|
|
|
EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), rows * cols * 1e-4);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(Dft, C2C)
|
|
|
|
{
|
|
|
|
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
|
|
|
|
|
|
|
|
int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
bool inplace = i != 0;
|
|
|
|
|
|
|
|
testC2C("no flags", cols, rows, 0, inplace);
|
|
|
|
testC2C("no flags 0 1", cols, rows + 1, 0, inplace);
|
|
|
|
testC2C("no flags 1 0", cols, rows + 1, 0, inplace);
|
|
|
|
testC2C("no flags 1 1", cols + 1, rows, 0, inplace);
|
|
|
|
testC2C("DFT_INVERSE", cols, rows, cv::DFT_INVERSE, inplace);
|
|
|
|
testC2C("DFT_ROWS", cols, rows, cv::DFT_ROWS, inplace);
|
|
|
|
testC2C("single col", 1, rows, 0, inplace);
|
|
|
|
testC2C("single row", cols, 1, 0, inplace);
|
|
|
|
testC2C("single col inversed", 1, rows, cv::DFT_INVERSE, inplace);
|
|
|
|
testC2C("single row inversed", cols, 1, cv::DFT_INVERSE, inplace);
|
|
|
|
testC2C("single row DFT_ROWS", cols, 1, cv::DFT_ROWS, inplace);
|
|
|
|
testC2C("size 1 2", 1, 2, 0, inplace);
|
|
|
|
testC2C("size 2 1", 2, 1, 0, inplace);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
SCOPED_TRACE(hint);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::Mat a = randomMat(rng, cv::Size(cols, rows), CV_32FC1, 0.0, 10.0, false);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::GpuMat d_b, d_c;
|
|
|
|
cv::gpu::GpuMat d_b_data, d_c_data;
|
|
|
|
if (inplace)
|
|
|
|
{
|
|
|
|
if (a.cols == 1)
|
|
|
|
{
|
|
|
|
d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);
|
|
|
|
d_b = cv::gpu::GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);
|
|
|
|
d_b = cv::gpu::GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());
|
|
|
|
}
|
|
|
|
d_c_data.create(1, a.size().area(), CV_32F);
|
|
|
|
d_c = cv::gpu::GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), 0);
|
2011-06-29 12:14:16 +02:00
|
|
|
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());
|
|
|
|
ASSERT_EQ(1, d_c.channels());
|
|
|
|
|
|
|
|
cv::Mat c(d_c);
|
|
|
|
EXPECT_MAT_NEAR(a, c, rows * cols * 1e-5);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(Dft, R2CThenC2R)
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
testR2CThenC2R("sanity", cols, rows, false);
|
|
|
|
testR2CThenC2R("sanity 0 1", cols, rows + 1, false);
|
|
|
|
testR2CThenC2R("sanity 1 0", cols + 1, rows, false);
|
|
|
|
testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, false);
|
|
|
|
testR2CThenC2R("single col", 1, rows, false);
|
|
|
|
testR2CThenC2R("single col 1", 1, rows + 1, false);
|
|
|
|
testR2CThenC2R("single row", cols, 1, false);
|
|
|
|
testR2CThenC2R("single row 1", cols + 1, 1, false);
|
|
|
|
|
|
|
|
testR2CThenC2R("sanity", cols, rows, true);
|
|
|
|
testR2CThenC2R("sanity 0 1", cols, rows + 1, true);
|
|
|
|
testR2CThenC2R("sanity 1 0", cols + 1, rows, true);
|
|
|
|
testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);
|
|
|
|
testR2CThenC2R("single row", cols, 1, true);
|
|
|
|
testR2CThenC2R("single row 1", cols + 1, 1, true);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Dft, ALL_DEVICES);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// blend
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
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)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
result_gold.create(img1.size(), img1.type());
|
|
|
|
|
|
|
|
int cn = img1.channels();
|
|
|
|
|
|
|
|
for (int y = 0; y < img1.rows; ++y)
|
|
|
|
{
|
|
|
|
const float* weights1_row = weights1.ptr<float>(y);
|
|
|
|
const float* weights2_row = weights2.ptr<float>(y);
|
|
|
|
const T* img1_row = img1.ptr<T>(y);
|
|
|
|
const T* img2_row = img2.ptr<T>(y);
|
|
|
|
T* result_gold_row = result_gold.ptr<T>(y);
|
2012-01-10 12:11:58 +01:00
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
for (int x = 0; x < img1.cols * cn; ++x)
|
|
|
|
{
|
|
|
|
float w1 = weights1_row[x / cn];
|
|
|
|
float w2 = weights2_row[x / cn];
|
|
|
|
result_gold_row[x] = static_cast<T>((img1_row[x] * w1 + img2_row[x] * w2) / (w1 + w2 + 1e-5f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Blend, cv::gpu::DeviceInfo, MatType, UseRoi)
|
2011-06-29 12:14:16 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
cv::Size size;
|
|
|
|
cv::Mat img1;
|
|
|
|
cv::Mat img2;
|
|
|
|
cv::Mat weights1;
|
|
|
|
cv::Mat weights2;
|
|
|
|
|
|
|
|
cv::Mat result_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
useRoi = GET_PARAM(2);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
size = cv::Size(200 + randInt(rng) % 1000, 200 + randInt(rng) % 1000);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
int depth = CV_MAT_DEPTH(type);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
img1 = randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);
|
|
|
|
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);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
if (depth == CV_8U)
|
|
|
|
blendLinearGold<uchar>(img1, img2, weights1, weights2, result_gold);
|
|
|
|
else
|
|
|
|
blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(Blend, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat result;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_result;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::blendLinear(loadMat(img1, useRoi), loadMat(img2, useRoi), loadMat(weights1, useRoi), loadMat(weights2, useRoi), d_result);
|
2011-06-29 12:14:16 +02:00
|
|
|
|
|
|
|
d_result.download(result);
|
|
|
|
);
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.0 : 1e-5);
|
2011-06-29 12:14:16 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Blend, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
|
|
|
USE_ROI));
|
2011-06-29 12:14:16 +02:00
|
|
|
|
2011-07-01 07:37:20 +02:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// pyrDown
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, MatType, UseRoi)
|
2011-08-09 08:25:01 +02:00
|
|
|
{
|
2011-07-01 07:37:20 +02:00
|
|
|
cv::gpu::DeviceInfo devInfo;
|
2011-08-24 13:16:42 +02:00
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-08-09 08:25:01 +02:00
|
|
|
|
2011-08-24 13:16:42 +02:00
|
|
|
cv::Size size;
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::Mat src;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
2011-07-01 07:37:20 +02:00
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
useRoi = GET_PARAM(2);
|
2011-08-24 13:16:42 +02:00
|
|
|
|
2011-07-01 07:37:20 +02:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-08-24 13:16:42 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-08-24 13:16:42 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 255.0, false);
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::pyrDown(src, dst_gold);
|
2011-07-01 07:37:20 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(PyrDown, Accuracy)
|
2012-01-10 12:11:58 +01:00
|
|
|
{
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::Mat dst;
|
2011-07-01 07:37:20 +02:00
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_dst;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::pyrDown(loadMat(src, useRoi), d_dst);
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
d_dst.download(dst);
|
|
|
|
);
|
2011-07-01 07:37:20 +02:00
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
ASSERT_EQ(dst_gold.cols, dst.cols);
|
|
|
|
ASSERT_EQ(dst_gold.rows, dst.rows);
|
|
|
|
ASSERT_EQ(dst_gold.type(), dst.type());
|
2011-08-24 13:16:42 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
double err = crossCorr(dst_gold, dst) / (cv::norm(dst_gold, cv::NORM_L2) * cv::norm(dst, cv::NORM_L2));
|
2011-07-01 07:37:20 +02:00
|
|
|
ASSERT_NEAR(err, 1., 1e-2);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
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),
|
|
|
|
USE_ROI));
|
2011-07-01 07:37:20 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// pyrUp
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(PyrUp, cv::gpu::DeviceInfo, MatType, UseRoi)
|
2011-08-09 08:25:01 +02:00
|
|
|
{
|
2011-07-01 07:37:20 +02:00
|
|
|
cv::gpu::DeviceInfo devInfo;
|
2011-08-24 13:16:42 +02:00
|
|
|
int type;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-08-09 08:25:01 +02:00
|
|
|
|
2011-08-24 13:16:42 +02:00
|
|
|
cv::Size size;
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::Mat src;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
2011-07-01 07:37:20 +02:00
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
type = GET_PARAM(1);
|
|
|
|
useRoi = GET_PARAM(2);
|
2011-08-24 13:16:42 +02:00
|
|
|
|
2011-07-01 07:37:20 +02:00
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-08-09 08:25:01 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-08-24 13:16:42 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, type, 0.0, 255.0, false);
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::pyrUp(src, dst_gold);
|
2011-07-01 07:37:20 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(PyrUp, Accuracy)
|
2012-01-10 12:11:58 +01:00
|
|
|
{
|
2011-08-09 08:25:01 +02:00
|
|
|
cv::Mat dst;
|
2011-07-01 07:37:20 +02:00
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_dst;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::pyrUp(loadMat(src, useRoi), d_dst);
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
d_dst.download(dst);
|
|
|
|
);
|
2011-07-01 07:37:20 +02:00
|
|
|
|
2011-08-09 08:25:01 +02:00
|
|
|
ASSERT_EQ(dst_gold.cols, dst.cols);
|
|
|
|
ASSERT_EQ(dst_gold.rows, dst.rows);
|
|
|
|
ASSERT_EQ(dst_gold.type(), dst.type());
|
2011-07-01 07:37:20 +02:00
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
double err = cvtest::crossCorr(dst_gold, dst) / (cv::norm(dst_gold, cv::NORM_L2) * cv::norm(dst, cv::NORM_L2));
|
2011-07-01 07:37:20 +02:00
|
|
|
ASSERT_NEAR(err, 1., 1e-2);
|
|
|
|
}
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
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),
|
|
|
|
USE_ROI));
|
2011-07-01 07:37:20 +02:00
|
|
|
|
2011-08-08 10:53:55 +02:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// Canny
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, int, bool, UseRoi)
|
2011-08-08 10:53:55 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int apperture_size;
|
|
|
|
bool L2gradient;
|
2012-01-10 12:11:58 +01:00
|
|
|
bool useRoi;
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
cv::Mat img;
|
2011-08-08 10:53:55 +02:00
|
|
|
|
|
|
|
double low_thresh;
|
|
|
|
double high_thresh;
|
|
|
|
|
|
|
|
cv::Mat edges_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
apperture_size = GET_PARAM(1);
|
|
|
|
L2gradient = GET_PARAM(2);
|
|
|
|
useRoi = GET_PARAM(3);
|
2011-08-08 10:53:55 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
2011-08-09 08:25:01 +02:00
|
|
|
|
|
|
|
img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
|
|
|
|
ASSERT_FALSE(img.empty());
|
2011-08-08 10:53:55 +02:00
|
|
|
|
|
|
|
low_thresh = 50.0;
|
|
|
|
high_thresh = 100.0;
|
|
|
|
|
|
|
|
cv::Canny(img, edges_gold, low_thresh, high_thresh, apperture_size, L2gradient);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(Canny, Accuracy)
|
|
|
|
{
|
|
|
|
cv::Mat edges;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_edges;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::Canny(loadMat(img, useRoi), d_edges, low_thresh, high_thresh, apperture_size, L2gradient);
|
2011-08-08 10:53:55 +02:00
|
|
|
|
|
|
|
d_edges.download(edges);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_SIMILAR(edges_gold, edges, 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(
|
2012-01-10 12:11:58 +01:00
|
|
|
DEVICES(cv::gpu::SHARED_ATOMICS),
|
|
|
|
Values(3, 5),
|
|
|
|
Values(false, true),
|
|
|
|
USE_ROI));
|
2011-08-08 10:53:55 +02:00
|
|
|
|
2011-10-10 13:58:47 +02:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// convolve
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, int)
|
2011-10-10 13:58:47 +02:00
|
|
|
{
|
|
|
|
cv::gpu::DeviceInfo devInfo;
|
|
|
|
int ksize;
|
|
|
|
|
|
|
|
cv::Size size;
|
|
|
|
cv::Mat src;
|
|
|
|
cv::Mat kernel;
|
|
|
|
|
|
|
|
cv::Mat dst_gold;
|
|
|
|
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
2012-01-10 12:11:58 +01:00
|
|
|
devInfo = GET_PARAM(0);
|
|
|
|
ksize = GET_PARAM(1);
|
2011-10-10 13:58:47 +02:00
|
|
|
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID());
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::RNG& rng = TS::ptr()->get_rng();
|
2011-10-10 13:58:47 +02:00
|
|
|
|
|
|
|
size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
src = randomMat(rng, size, CV_32FC1, 0.0, 255.0, false);
|
|
|
|
kernel = randomMat(rng, cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0, false);
|
2011-10-10 13:58:47 +02:00
|
|
|
|
|
|
|
cv::filter2D(src, dst_gold, CV_32F, kernel, cv::Point(-1, -1), 0, cv::BORDER_REPLICATE);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(Convolve, Accuracy)
|
2012-01-10 12:11:58 +01:00
|
|
|
{
|
2011-10-10 13:58:47 +02:00
|
|
|
cv::Mat dst;
|
|
|
|
|
|
|
|
ASSERT_NO_THROW(
|
|
|
|
cv::gpu::GpuMat d_dst;
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
cv::gpu::convolve(loadMat(src), loadMat(kernel), d_dst);
|
|
|
|
|
2011-10-10 13:58:47 +02:00
|
|
|
d_dst.download(dst);
|
|
|
|
);
|
|
|
|
|
|
|
|
EXPECT_MAT_NEAR(dst, dst_gold, 1e-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-10 12:11:58 +01:00
|
|
|
INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, Combine(
|
|
|
|
ALL_DEVICES,
|
|
|
|
Values(3, 5, 7, 9, 11)));
|
2011-10-10 13:58:47 +02:00
|
|
|
|
2011-06-29 12:14:16 +02:00
|
|
|
#endif // HAVE_CUDA
|