fixed gpu::filter2D border interpolation for CV_32FC1 type
added additional tests for gpu filters fixed gpu features2D tests
This commit is contained in:
parent
c1a6cb6221
commit
059cef57e6
@ -1661,7 +1661,7 @@ public:
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
explicit ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f, int nLevels = 3, int edgeThreshold = 31,
|
||||
explicit ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f, int nLevels = 8, int edgeThreshold = 31,
|
||||
int firstLevel = 0, int WTA_K = 2, int scoreType = 0, int patchSize = 31);
|
||||
|
||||
//! Compute the ORB features on an image
|
||||
|
@ -911,27 +911,28 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
__constant__ float c_filter2DKernel[FILTER2D_MAX_KERNEL_SIZE * FILTER2D_MAX_KERNEL_SIZE];
|
||||
|
||||
texture<float, cudaTextureType2D, cudaReadModeElementType> filter2DTex(0, cudaFilterModePoint, cudaAddressModeBorder);
|
||||
texture<float, cudaTextureType2D, cudaReadModeElementType> filter2DTex(0, cudaFilterModePoint, cudaAddressModeClamp);
|
||||
|
||||
__global__ void filter2D(int ofsX, int ofsY, DevMem2Df dst, const int kWidth, const int kHeight, const int anchorX, const int anchorY)
|
||||
__global__ void filter2D(int ofsX, int ofsY, PtrStepf dst, const int kWidth, const int kHeight, const int anchorX, const int anchorY, const BrdReflect101<float> brd)
|
||||
{
|
||||
const int x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
const int y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
|
||||
if (x >= dst.cols || y >= dst.rows)
|
||||
if (x > brd.last_col || y > brd.last_row)
|
||||
return;
|
||||
|
||||
float res = 0;
|
||||
|
||||
const int baseX = ofsX + x - anchorX;
|
||||
const int baseY = ofsY + y - anchorY;
|
||||
|
||||
int kInd = 0;
|
||||
|
||||
for (int i = 0; i < kHeight; ++i)
|
||||
{
|
||||
for (int j = 0; j < kWidth; ++j)
|
||||
res += tex2D(filter2DTex, baseX + j, baseY + i) * c_filter2DKernel[kInd++];
|
||||
{
|
||||
const int srcX = ofsX + brd.idx_col(x - anchorX + j);
|
||||
const int srcY = ofsY + brd.idx_row(y - anchorY + i);
|
||||
|
||||
res += tex2D(filter2DTex, srcX, srcY) * c_filter2DKernel[kInd++];
|
||||
}
|
||||
}
|
||||
|
||||
dst.ptr(y)[x] = res;
|
||||
@ -946,7 +947,9 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
bindTexture(&filter2DTex, src);
|
||||
|
||||
filter2D<<<grid, block, 0, stream>>>(ofsX, ofsY, dst, kWidth, kHeight, anchorX, anchorY);
|
||||
BrdReflect101<float> brd(dst.rows, dst.cols);
|
||||
|
||||
filter2D<<<grid, block, 0, stream>>>(ofsX, ofsY, dst, kWidth, kHeight, anchorX, anchorY, brd);
|
||||
cudaSafeCall(cudaGetLastError());
|
||||
|
||||
if (stream == 0)
|
||||
|
@ -238,7 +238,7 @@ namespace
|
||||
cv::gpu::SURF_GPU::SURF_GPU()
|
||||
{
|
||||
hessianThreshold = 100;
|
||||
extended = 1;
|
||||
extended = true;
|
||||
nOctaves = 4;
|
||||
nOctaveLayers = 2;
|
||||
keypointsRatio = 0.01f;
|
||||
|
@ -41,20 +41,13 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// BlockMatching
|
||||
// StereoBM
|
||||
|
||||
struct StereoBlockMatching : TestWithParam<cv::gpu::DeviceInfo>
|
||||
struct StereoBM : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::Mat img_l;
|
||||
cv::Mat img_r;
|
||||
cv::Mat img_template;
|
||||
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
virtual void SetUp()
|
||||
@ -62,44 +55,34 @@ struct StereoBlockMatching : TestWithParam<cv::gpu::DeviceInfo>
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
img_l = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
img_r = readImage("stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
img_template = readImage("stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(img_l.empty());
|
||||
ASSERT_FALSE(img_r.empty());
|
||||
ASSERT_FALSE(img_template.empty());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(StereoBlockMatching, Regression)
|
||||
TEST_P(StereoBM, Regression)
|
||||
{
|
||||
cv::Mat disp;
|
||||
cv::Mat left_image = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
|
||||
cv::Mat right_image = readImage("stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
|
||||
cv::Mat disp_gold = readImage("stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(left_image.empty());
|
||||
ASSERT_FALSE(right_image.empty());
|
||||
ASSERT_FALSE(disp_gold.empty());
|
||||
|
||||
cv::gpu::GpuMat dev_disp;
|
||||
cv::gpu::StereoBM_GPU bm(0, 128, 19);
|
||||
cv::gpu::GpuMat disp;
|
||||
|
||||
bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), dev_disp);
|
||||
bm(loadMat(left_image), loadMat(right_image), disp);
|
||||
|
||||
dev_disp.download(disp);
|
||||
|
||||
disp.convertTo(disp, img_template.type());
|
||||
|
||||
EXPECT_MAT_NEAR(img_template, disp, 0.0);
|
||||
EXPECT_MAT_NEAR(disp_gold, disp, 0.0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBlockMatching, ALL_DEVICES);
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBM, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// BeliefPropagation
|
||||
// StereoBeliefPropagation
|
||||
|
||||
struct StereoBeliefPropagation : TestWithParam<cv::gpu::DeviceInfo>
|
||||
struct StereoBeliefPropagation : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::Mat img_l;
|
||||
cv::Mat img_r;
|
||||
cv::Mat img_template;
|
||||
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
virtual void SetUp()
|
||||
@ -107,44 +90,37 @@ struct StereoBeliefPropagation : TestWithParam<cv::gpu::DeviceInfo>
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
img_l = readImage("stereobp/aloe-L.png");
|
||||
img_r = readImage("stereobp/aloe-R.png");
|
||||
img_template = readImage("stereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(img_l.empty());
|
||||
ASSERT_FALSE(img_r.empty());
|
||||
ASSERT_FALSE(img_template.empty());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(StereoBeliefPropagation, Regression)
|
||||
{
|
||||
cv::Mat disp;
|
||||
cv::Mat left_image = readImage("stereobp/aloe-L.png");
|
||||
cv::Mat right_image = readImage("stereobp/aloe-R.png");
|
||||
cv::Mat disp_gold = readImage("stereobp/aloe-disp.png", cv::IMREAD_GRAYSCALE);
|
||||
|
||||
cv::gpu::GpuMat dev_disp;
|
||||
cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
|
||||
ASSERT_FALSE(left_image.empty());
|
||||
ASSERT_FALSE(right_image.empty());
|
||||
ASSERT_FALSE(disp_gold.empty());
|
||||
|
||||
bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), dev_disp);
|
||||
cv::gpu::StereoBeliefPropagation bp(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
|
||||
cv::gpu::GpuMat disp;
|
||||
|
||||
dev_disp.download(disp);
|
||||
bp(loadMat(left_image), loadMat(right_image), disp);
|
||||
|
||||
disp.convertTo(disp, img_template.type());
|
||||
cv::Mat h_disp(disp);
|
||||
h_disp.convertTo(h_disp, disp_gold.depth());
|
||||
|
||||
EXPECT_MAT_NEAR(img_template, disp, 0.0);
|
||||
EXPECT_MAT_NEAR(disp_gold, h_disp, 0.0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES);
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBeliefPropagation, ALL_DEVICES);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ConstantSpaceBP
|
||||
// StereoConstantSpaceBP
|
||||
|
||||
struct StereoConstantSpaceBP : TestWithParam<cv::gpu::DeviceInfo>
|
||||
struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::Mat img_l;
|
||||
cv::Mat img_r;
|
||||
cv::Mat img_template;
|
||||
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
virtual void SetUp()
|
||||
@ -152,207 +128,177 @@ struct StereoConstantSpaceBP : TestWithParam<cv::gpu::DeviceInfo>
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
img_l = readImage("csstereobp/aloe-L.png");
|
||||
img_r = readImage("csstereobp/aloe-R.png");
|
||||
|
||||
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
||||
img_template = readImage("csstereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
else
|
||||
img_template = readImage("csstereobp/aloe-disp_CC1X.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
|
||||
ASSERT_FALSE(img_l.empty());
|
||||
ASSERT_FALSE(img_r.empty());
|
||||
ASSERT_FALSE(img_template.empty());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(StereoConstantSpaceBP, Regression)
|
||||
{
|
||||
cv::Mat disp;
|
||||
cv::Mat left_image = readImage("csstereobp/aloe-L.png");
|
||||
cv::Mat right_image = readImage("csstereobp/aloe-R.png");
|
||||
|
||||
cv::gpu::GpuMat dev_disp;
|
||||
cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
|
||||
cv::Mat disp_gold;
|
||||
|
||||
bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), dev_disp);
|
||||
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
||||
disp_gold = readImage("csstereobp/aloe-disp.png", cv::IMREAD_GRAYSCALE);
|
||||
else
|
||||
disp_gold = readImage("csstereobp/aloe-disp_CC1X.png", cv::IMREAD_GRAYSCALE);
|
||||
|
||||
dev_disp.download(disp);
|
||||
ASSERT_FALSE(left_image.empty());
|
||||
ASSERT_FALSE(right_image.empty());
|
||||
ASSERT_FALSE(disp_gold.empty());
|
||||
|
||||
disp.convertTo(disp, img_template.type());
|
||||
cv::gpu::StereoConstantSpaceBP csbp(128, 16, 4, 4);
|
||||
cv::gpu::GpuMat disp;
|
||||
|
||||
EXPECT_MAT_NEAR(img_template, disp, 1.0);
|
||||
csbp(loadMat(left_image), loadMat(right_image), disp);
|
||||
|
||||
cv::Mat h_disp(disp);
|
||||
h_disp.convertTo(h_disp, disp_gold.depth());
|
||||
|
||||
EXPECT_MAT_NEAR(disp_gold, h_disp, 1.0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// projectPoints
|
||||
|
||||
struct ProjectPoints : TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
cv::Mat src;
|
||||
cv::Mat rvec;
|
||||
cv::Mat tvec;
|
||||
cv::Mat camera_mat;
|
||||
|
||||
std::vector<cv::Point2f> dst_gold;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
|
||||
|
||||
src = cvtest::randomMat(rng, cv::Size(1000, 1), CV_32FC3, 0, 10, false);
|
||||
rvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);
|
||||
tvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);
|
||||
camera_mat = cvtest::randomMat(rng, cv::Size(3, 3), CV_32F, 0, 1, false);
|
||||
camera_mat.at<float>(0, 1) = 0.f;
|
||||
camera_mat.at<float>(1, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 1) = 0.f;
|
||||
|
||||
cv::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), dst_gold);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ProjectPoints, Accuracy)
|
||||
{
|
||||
cv::Mat dst;
|
||||
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::projectPoints(cv::gpu::GpuMat(src), rvec, tvec, camera_mat, cv::Mat(), d_dst);
|
||||
|
||||
d_dst.download(dst);
|
||||
|
||||
ASSERT_EQ(dst_gold.size(), static_cast<size_t>(dst.cols));
|
||||
ASSERT_EQ(1, dst.rows);
|
||||
ASSERT_EQ(CV_32FC2, dst.type());
|
||||
|
||||
for (size_t i = 0; i < dst_gold.size(); ++i)
|
||||
{
|
||||
cv::Point2f res_gold = dst_gold[i];
|
||||
cv::Point2f res_actual = dst.at<cv::Point2f>(0, i);
|
||||
cv::Point2f err = res_actual - res_gold;
|
||||
|
||||
ASSERT_LE(err.dot(err) / res_gold.dot(res_gold), 1e-3f);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, ALL_DEVICES);
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// transformPoints
|
||||
|
||||
struct TransformPoints : TestWithParam<cv::gpu::DeviceInfo>
|
||||
struct TransformPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
cv::Mat src;
|
||||
cv::Mat rvec;
|
||||
cv::Mat tvec;
|
||||
cv::Mat rot;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
|
||||
|
||||
src = cvtest::randomMat(rng, cv::Size(1000, 1), CV_32FC3, 0, 10, false);
|
||||
rvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);
|
||||
tvec = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);
|
||||
|
||||
cv::Rodrigues(rvec, rot);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(TransformPoints, Accuracy)
|
||||
{
|
||||
cv::Mat dst;
|
||||
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
|
||||
cv::Mat rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||
cv::Mat tvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||
|
||||
cv::gpu::GpuMat d_dst;
|
||||
|
||||
cv::gpu::transformPoints(cv::gpu::GpuMat(src), rvec, tvec, d_dst);
|
||||
|
||||
d_dst.download(dst);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::transformPoints(loadMat(src), rvec, tvec, dst);
|
||||
|
||||
ASSERT_EQ(src.size(), dst.size());
|
||||
ASSERT_EQ(src.type(), dst.type());
|
||||
|
||||
for (int i = 0; i < dst.cols; ++i)
|
||||
cv::Mat h_dst(dst);
|
||||
|
||||
cv::Mat rot;
|
||||
cv::Rodrigues(rvec, rot);
|
||||
|
||||
for (int i = 0; i < h_dst.cols; ++i)
|
||||
{
|
||||
cv::Point3f res = h_dst.at<cv::Point3f>(0, i);
|
||||
|
||||
cv::Point3f p = src.at<cv::Point3f>(0, i);
|
||||
cv::Point3f res_gold(
|
||||
rot.at<float>(0, 0) * p.x + rot.at<float>(0, 1) * p.y + rot.at<float>(0, 2) * p.z + tvec.at<float>(0, 0),
|
||||
rot.at<float>(1, 0) * p.x + rot.at<float>(1, 1) * p.y + rot.at<float>(1, 2) * p.z + tvec.at<float>(0, 1),
|
||||
rot.at<float>(2, 0) * p.x + rot.at<float>(2, 1) * p.y + rot.at<float>(2, 2) * p.z + tvec.at<float>(0, 2));
|
||||
cv::Point3f res_actual = dst.at<cv::Point3f>(0, i);
|
||||
cv::Point3f err = res_actual - res_gold;
|
||||
|
||||
ASSERT_LE(err.dot(err) / res_gold.dot(res_gold), 1e-3f);
|
||||
ASSERT_POINT3_NEAR(res_gold, res, 1e-5);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, ALL_DEVICES);
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, TransformPoints, ALL_DEVICES);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// solvePnPRansac
|
||||
// ProjectPoints
|
||||
|
||||
struct SolvePnPRansac : TestWithParam<cv::gpu::DeviceInfo>
|
||||
struct ProjectPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
static const int num_points = 5000;
|
||||
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
cv::Mat object;
|
||||
cv::Mat camera_mat;
|
||||
std::vector<cv::Point2f> image_vec;
|
||||
|
||||
cv::Mat rvec_gold;
|
||||
cv::Mat tvec_gold;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
|
||||
|
||||
object = cvtest::randomMat(rng, cv::Size(num_points, 1), CV_32FC3, 0, 100, false);
|
||||
camera_mat = cvtest::randomMat(rng, cv::Size(3, 3), CV_32F, 0.5, 1, false);
|
||||
TEST_P(ProjectPoints, Accuracy)
|
||||
{
|
||||
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
|
||||
cv::Mat rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||
cv::Mat tvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||
cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1);
|
||||
camera_mat.at<float>(0, 1) = 0.f;
|
||||
camera_mat.at<float>(1, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 1) = 0.f;
|
||||
|
||||
rvec_gold = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);
|
||||
tvec_gold = cvtest::randomMat(rng, cv::Size(3, 1), CV_32F, 0, 1, false);
|
||||
cv::gpu::GpuMat dst;
|
||||
cv::gpu::projectPoints(loadMat(src), rvec, tvec, camera_mat, cv::Mat(), dst);
|
||||
|
||||
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), image_vec);
|
||||
ASSERT_EQ(1, dst.rows);
|
||||
ASSERT_EQ(MatType(CV_32FC2), MatType(dst.type()));
|
||||
|
||||
std::vector<cv::Point2f> dst_gold;
|
||||
cv::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), dst_gold);
|
||||
|
||||
ASSERT_EQ(dst_gold.size(), static_cast<size_t>(dst.cols));
|
||||
|
||||
cv::Mat h_dst(dst);
|
||||
|
||||
for (size_t i = 0; i < dst_gold.size(); ++i)
|
||||
{
|
||||
cv::Point2f res = h_dst.at<cv::Point2f>(0, i);
|
||||
cv::Point2f res_gold = dst_gold[i];
|
||||
|
||||
ASSERT_LE(cv::norm(res_gold - res) / cv::norm(res_gold), 1e-3f);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, ProjectPoints, ALL_DEVICES);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SolvePnPRansac
|
||||
|
||||
struct SolvePnPRansac : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(SolvePnPRansac, Accuracy)
|
||||
{
|
||||
cv::Mat object = randomMat(cv::Size(5000, 1), CV_32FC3, 0, 100);
|
||||
cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1);
|
||||
camera_mat.at<float>(0, 1) = 0.f;
|
||||
camera_mat.at<float>(1, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 1) = 0.f;
|
||||
|
||||
std::vector<cv::Point2f> image_vec;
|
||||
cv::Mat rvec_gold;
|
||||
cv::Mat tvec_gold;
|
||||
rvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||
tvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), image_vec);
|
||||
|
||||
cv::Mat rvec, tvec;
|
||||
std::vector<int> inliers;
|
||||
cv::gpu::solvePnPRansac(object, cv::Mat(1, image_vec.size(), CV_32FC2, &image_vec[0]),
|
||||
camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)),
|
||||
rvec, tvec, false, 200, 2.f, 100, &inliers);
|
||||
|
||||
cv::gpu::solvePnPRansac(object, cv::Mat(1, image_vec.size(), CV_32FC2, &image_vec[0]), camera_mat,
|
||||
cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), rvec, tvec, false, 200, 2.f, 100, &inliers);
|
||||
|
||||
ASSERT_LE(cv::norm(rvec - rvec_gold), 1e-3f);
|
||||
ASSERT_LE(cv::norm(tvec - tvec_gold), 1e-3f);
|
||||
ASSERT_LE(cv::norm(rvec - rvec_gold), 1e-3);
|
||||
ASSERT_LE(cv::norm(tvec - tvec_gold), 1e-3);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, ALL_DEVICES);
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, SolvePnPRansac, ALL_DEVICES);
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
} // namespace
|
||||
|
@ -41,9 +41,11 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
namespace {
|
||||
|
||||
PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, int, Border, UseRoi)
|
||||
IMPLEMENT_PARAM_CLASS(Border, int)
|
||||
|
||||
PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, Border, BorderType, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -82,9 +84,17 @@ TEST_P(CopyMakeBorder, Accuracy)
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
|
||||
testing::Values(1, 10, 50),
|
||||
testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_CONSTANT), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),
|
||||
testing::Values(MatType(CV_8UC1),
|
||||
MatType(CV_8UC3),
|
||||
MatType(CV_8UC4),
|
||||
MatType(CV_16UC1),
|
||||
MatType(CV_16UC3),
|
||||
MatType(CV_16UC4),
|
||||
MatType(CV_32FC1),
|
||||
MatType(CV_32FC3),
|
||||
MatType(CV_32FC4)),
|
||||
testing::Values(Border(1), Border(10), Border(50)),
|
||||
ALL_BORDER_TYPES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
} // namespace
|
||||
|
@ -41,10 +41,12 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Add_Array
|
||||
|
||||
PARAM_TEST_CASE(Add_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, int, UseRoi)
|
||||
PARAM_TEST_CASE(Add_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, Channels, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -90,7 +92,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Add_Array, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
DEPTH_PAIRS,
|
||||
testing::Values(1, 2, 3, 4),
|
||||
ALL_CHANNELS,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -139,7 +141,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Add_Scalar, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Subtract_Array
|
||||
|
||||
PARAM_TEST_CASE(Subtract_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, int, UseRoi)
|
||||
PARAM_TEST_CASE(Subtract_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, Channels, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -185,7 +187,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Subtract_Array, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
DEPTH_PAIRS,
|
||||
testing::Values(1, 2, 3, 4),
|
||||
ALL_CHANNELS,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -234,7 +236,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Subtract_Scalar, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Multiply_Array
|
||||
|
||||
PARAM_TEST_CASE(Multiply_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, int, UseRoi)
|
||||
PARAM_TEST_CASE(Multiply_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, Channels, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -279,7 +281,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Multiply_Array, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
DEPTH_PAIRS,
|
||||
testing::Values(1, 2, 3, 4),
|
||||
ALL_CHANNELS,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -425,7 +427,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Multiply_Scalar, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Divide_Array
|
||||
|
||||
PARAM_TEST_CASE(Divide_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, int, UseRoi)
|
||||
PARAM_TEST_CASE(Divide_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDepth, MatDepth>, Channels, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -470,7 +472,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Divide_Array, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
DEPTH_PAIRS,
|
||||
testing::Values(1, 2, 3, 4),
|
||||
ALL_CHANNELS,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -794,8 +796,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Sqr, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Sqrt
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T> void sqrtImpl(const cv::Mat& src, cv::Mat& dst)
|
||||
{
|
||||
dst.create(src.size(), src.type());
|
||||
@ -819,7 +819,6 @@ namespace
|
||||
|
||||
funcs[src.depth()](src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(Sqrt, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
||||
{
|
||||
@ -864,8 +863,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Sqrt, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Log
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T> void logImpl(const cv::Mat& src, cv::Mat& dst)
|
||||
{
|
||||
dst.create(src.size(), src.type());
|
||||
@ -889,7 +886,6 @@ namespace
|
||||
|
||||
funcs[src.depth()](src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(Log, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
||||
{
|
||||
@ -974,6 +970,9 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Exp, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// compare
|
||||
|
||||
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
|
||||
#define ALL_CMP_CODES testing::Values(CmpCode(cv::CMP_EQ), CmpCode(cv::CMP_NE), CmpCode(cv::CMP_GT), CmpCode(cv::CMP_GE), CmpCode(cv::CMP_LT), CmpCode(cv::CMP_LE))
|
||||
|
||||
PARAM_TEST_CASE(Compare, cv::gpu::DeviceInfo, cv::Size, MatDepth, CmpCode, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
@ -1088,7 +1087,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Bitwise_Array, testing::Combine(
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Bitwise_Scalar
|
||||
|
||||
PARAM_TEST_CASE(Bitwise_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, int)
|
||||
PARAM_TEST_CASE(Bitwise_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -1150,13 +1149,11 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Bitwise_Scalar, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32S)),
|
||||
testing::Values(1, 3, 4)));
|
||||
IMAGE_CHANNELS));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// RShift
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T> void rhiftImpl(const cv::Mat& src, cv::Scalar_<int> val, cv::Mat& dst)
|
||||
{
|
||||
const int cn = src.channels();
|
||||
@ -1184,9 +1181,8 @@ namespace
|
||||
|
||||
funcs[src.depth()](src, val, dst);
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(RShift, cv::gpu::DeviceInfo, cv::Size, MatDepth, int, UseRoi)
|
||||
PARAM_TEST_CASE(RShift, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -1229,14 +1225,12 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, RShift, testing::Combine(
|
||||
MatDepth(CV_16U),
|
||||
MatDepth(CV_16S),
|
||||
MatDepth(CV_32S)),
|
||||
testing::Values(1, 3, 4),
|
||||
IMAGE_CHANNELS,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// LShift
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T> void lhiftImpl(const cv::Mat& src, cv::Scalar_<int> val, cv::Mat& dst)
|
||||
{
|
||||
const int cn = src.channels();
|
||||
@ -1264,9 +1258,8 @@ namespace
|
||||
|
||||
funcs[src.depth()](src, val, dst);
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(LShift, cv::gpu::DeviceInfo, cv::Size, MatDepth, int, UseRoi)
|
||||
PARAM_TEST_CASE(LShift, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -1305,7 +1298,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, LShift, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32S)),
|
||||
testing::Values(1, 3, 4),
|
||||
IMAGE_CHANNELS,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -1411,7 +1404,7 @@ PARAM_TEST_CASE(Pow, cv::gpu::DeviceInfo, cv::Size, MatDepth, UseRoi)
|
||||
|
||||
TEST_P(Pow, Accuracy)
|
||||
{
|
||||
cv::Mat src = randomMat(size, depth, 0.0, 100.0);
|
||||
cv::Mat src = randomMat(size, depth, 0.0, 10.0);
|
||||
double power = randomDouble(2.0, 4.0);
|
||||
|
||||
if (src.depth() < CV_32F)
|
||||
@ -1423,7 +1416,7 @@ TEST_P(Pow, Accuracy)
|
||||
cv::Mat dst_gold;
|
||||
cv::pow(src, power, dst_gold);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth < CV_32F ? 0.0 : 1e-6);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth < CV_32F ? 0.0 : 1e-1);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Core, Pow, testing::Combine(
|
||||
@ -1486,6 +1479,9 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, AddWeighted, testing::Combine(
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// GEMM
|
||||
|
||||
CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T);
|
||||
#define ALL_GEMM_FLAGS testing::Values(GemmFlags(0), GemmFlags(cv::GEMM_1_T), GemmFlags(cv::GEMM_2_T), GemmFlags(cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T))
|
||||
|
||||
PARAM_TEST_CASE(GEMM, cv::gpu::DeviceInfo, cv::Size, MatType, GemmFlags, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
@ -1579,6 +1575,10 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Transpose, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Flip
|
||||
|
||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
|
||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
|
||||
#define ALL_FLIP_CODES testing::Values(FlipCode(FLIP_BOTH), FlipCode(FLIP_X), FlipCode(FLIP_Y))
|
||||
|
||||
PARAM_TEST_CASE(Flip, cv::gpu::DeviceInfo, cv::Size, MatType, FlipCode, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
@ -1772,7 +1772,9 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Magnitude, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Phase
|
||||
|
||||
PARAM_TEST_CASE(Phase, cv::gpu::DeviceInfo, cv::Size, bool, UseRoi)
|
||||
IMPLEMENT_PARAM_CLASS(AngleInDegrees, bool)
|
||||
|
||||
PARAM_TEST_CASE(Phase, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -1807,13 +1809,13 @@ TEST_P(Phase, Accuracy)
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Core, Phase, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Bool(),
|
||||
testing::Values(AngleInDegrees(false), AngleInDegrees(true)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// CartToPolar
|
||||
|
||||
PARAM_TEST_CASE(CartToPolar, cv::gpu::DeviceInfo, cv::Size, bool, UseRoi)
|
||||
PARAM_TEST_CASE(CartToPolar, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -1851,13 +1853,13 @@ TEST_P(CartToPolar, Accuracy)
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Core, CartToPolar, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Bool(),
|
||||
testing::Values(AngleInDegrees(false), AngleInDegrees(true)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// polarToCart
|
||||
|
||||
PARAM_TEST_CASE(PolarToCart, cv::gpu::DeviceInfo, cv::Size, bool, UseRoi)
|
||||
PARAM_TEST_CASE(PolarToCart, cv::gpu::DeviceInfo, cv::Size, AngleInDegrees, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -1895,7 +1897,7 @@ TEST_P(PolarToCart, Accuracy)
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Core, PolarToCart, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
testing::Bool(),
|
||||
testing::Values(AngleInDegrees(false), AngleInDegrees(true)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -2026,8 +2028,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, NormDiff, testing::Combine(
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Sum
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T>
|
||||
cv::Scalar absSumImpl(const cv::Mat& src)
|
||||
{
|
||||
@ -2104,7 +2104,6 @@ namespace
|
||||
|
||||
return funcs[src.depth()](src);
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(Sum, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
||||
{
|
||||
@ -2164,57 +2163,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Sum, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MinMax
|
||||
|
||||
namespace
|
||||
{
|
||||
void minMaxLocGold(const cv::Mat& src, double* minVal_, double* maxVal_ = 0, cv::Point* minLoc_ = 0, cv::Point* maxLoc_ = 0, const cv::Mat& mask = cv::Mat())
|
||||
{
|
||||
if (src.depth() != CV_8S)
|
||||
{
|
||||
cv::minMaxLoc(src, minVal_, maxVal_, minLoc_, maxLoc_, mask);
|
||||
return;
|
||||
}
|
||||
|
||||
// OpenCV's minMaxLoc doesn't support CV_8S type
|
||||
double minVal = std::numeric_limits<double>::max();
|
||||
cv::Point minLoc(-1, -1);
|
||||
|
||||
double maxVal = -std::numeric_limits<double>::max();
|
||||
cv::Point maxLoc(-1, -1);
|
||||
|
||||
for (int y = 0; y < src.rows; ++y)
|
||||
{
|
||||
const schar* src_row = src.ptr<signed char>(y);
|
||||
const uchar* mask_row = mask.empty() ? 0 : mask.ptr<unsigned char>(y);
|
||||
|
||||
for (int x = 0; x < src.cols; ++x)
|
||||
{
|
||||
if (!mask_row || mask_row[x])
|
||||
{
|
||||
schar val = src_row[x];
|
||||
|
||||
if (val < minVal)
|
||||
{
|
||||
minVal = val;
|
||||
minLoc = cv::Point(x, y);
|
||||
}
|
||||
|
||||
if (val > maxVal)
|
||||
{
|
||||
maxVal = val;
|
||||
maxLoc = cv::Point(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minVal_) *minVal_ = minVal;
|
||||
if (maxVal_) *maxVal_ = maxVal;
|
||||
|
||||
if (minLoc_) *minLoc_ = minLoc;
|
||||
if (maxLoc_) *maxLoc_ = maxLoc;
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(MinMax, cv::gpu::DeviceInfo, cv::Size, MatDepth, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
@ -2278,8 +2226,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, MinMax, testing::Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MinMaxLoc
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T>
|
||||
void expectEqualImpl(const cv::Mat& src, cv::Point loc_gold, cv::Point loc)
|
||||
{
|
||||
@ -2303,7 +2249,6 @@ namespace
|
||||
|
||||
funcs[src.depth()](src, loc_gold, loc);
|
||||
}
|
||||
}
|
||||
|
||||
PARAM_TEST_CASE(MinMaxLoc, cv::gpu::DeviceInfo, cv::Size, MatDepth, UseRoi)
|
||||
{
|
||||
@ -2420,7 +2365,10 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, CountNonZero, testing::Combine(
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Reduce
|
||||
|
||||
PARAM_TEST_CASE(Reduce, cv::gpu::DeviceInfo, cv::Size, MatDepth, int, ReduceCode, UseRoi)
|
||||
CV_ENUM(ReduceCode, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
|
||||
#define ALL_REDUCE_CODES testing::Values(ReduceCode(CV_REDUCE_SUM), ReduceCode(CV_REDUCE_AVG), ReduceCode(CV_REDUCE_MAX), ReduceCode(CV_REDUCE_MIN))
|
||||
|
||||
PARAM_TEST_CASE(Reduce, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, ReduceCode, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -2448,6 +2396,7 @@ PARAM_TEST_CASE(Reduce, cv::gpu::DeviceInfo, cv::Size, MatDepth, int, ReduceCode
|
||||
dst_depth = (reduceOp == CV_REDUCE_MAX || reduceOp == CV_REDUCE_MIN) ? depth : CV_32F;
|
||||
dst_type = CV_MAKE_TYPE(dst_depth, channels);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TEST_P(Reduce, Rows)
|
||||
@ -2486,6 +2435,8 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Reduce, testing::Combine(
|
||||
MatDepth(CV_16U),
|
||||
MatDepth(CV_16S),
|
||||
MatDepth(CV_32F)),
|
||||
testing::Values(1, 2, 3, 4),
|
||||
ALL_CHANNELS,
|
||||
ALL_REDUCE_CODES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
} // namespace
|
||||
|
@ -41,12 +41,74 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
namespace {
|
||||
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
bool keyPointsEquals(const cv::KeyPoint& p1, const cv::KeyPoint& p2)
|
||||
{
|
||||
const double maxPtDif = 1.0;
|
||||
const double maxSizeDif = 1.0;
|
||||
const double maxAngleDif = 2.0;
|
||||
const double maxResponseDif = 0.1;
|
||||
|
||||
int getValidMatchesCount(const std::vector<cv::KeyPoint>& keypoints1, const std::vector<cv::KeyPoint>& keypoints2, const std::vector<cv::DMatch>& matches)
|
||||
double dist = cv::norm(p1.pt - p2.pt);
|
||||
|
||||
if (dist < maxPtDif &&
|
||||
fabs(p1.size - p2.size) < maxSizeDif &&
|
||||
abs(p1.angle - p2.angle) < maxAngleDif &&
|
||||
abs(p1.response - p2.response) < maxResponseDif &&
|
||||
p1.octave == p2.octave &&
|
||||
p1.class_id == p2.class_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
struct KeyPointLess : std::binary_function<cv::KeyPoint, cv::KeyPoint, bool>
|
||||
{
|
||||
bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
||||
{
|
||||
return kp1.pt.y < kp2.pt.y || (kp1.pt.y == kp2.pt.y && kp1.pt.x < kp2.pt.x);
|
||||
}
|
||||
};
|
||||
|
||||
testing::AssertionResult assertKeyPointsEquals(const char* gold_expr, const char* actual_expr, std::vector<cv::KeyPoint>& gold, std::vector<cv::KeyPoint>& actual)
|
||||
{
|
||||
if (gold.size() != actual.size())
|
||||
{
|
||||
return testing::AssertionFailure() << "KeyPoints size mistmach\n"
|
||||
<< "\"" << gold_expr << "\" : " << gold.size() << "\n"
|
||||
<< "\"" << actual_expr << "\" : " << actual.size();
|
||||
}
|
||||
|
||||
std::sort(actual.begin(), actual.end(), KeyPointLess());
|
||||
std::sort(gold.begin(), gold.end(), KeyPointLess());
|
||||
|
||||
for (size_t i; i < gold.size(); ++i)
|
||||
{
|
||||
const cv::KeyPoint& p1 = gold[i];
|
||||
const cv::KeyPoint& p2 = actual[i];
|
||||
|
||||
if (!keyPointsEquals(p1, p2))
|
||||
{
|
||||
return testing::AssertionFailure() << "KeyPoints differ at " << i << "\n"
|
||||
<< "\"" << gold_expr << "\" vs \"" << actual_expr << "\" : \n"
|
||||
<< "pt : " << testing::PrintToString(p1.pt) << " vs " << testing::PrintToString(p2.pt) << "\n"
|
||||
<< "size : " << p1.size << " vs " << p2.size << "\n"
|
||||
<< "angle : " << p1.angle << " vs " << p2.angle << "\n"
|
||||
<< "response : " << p1.response << " vs " << p2.response << "\n"
|
||||
<< "octave : " << p1.octave << " vs " << p2.octave << "\n"
|
||||
<< "class_id : " << p1.class_id << " vs " << p2.class_id;
|
||||
}
|
||||
}
|
||||
|
||||
return ::testing::AssertionSuccess();
|
||||
}
|
||||
|
||||
#define ASSERT_KEYPOINTS_EQ(gold, actual) EXPECT_PRED_FORMAT2(assertKeyPointsEquals, gold, actual);
|
||||
|
||||
int getMatchedPointsCount(const std::vector<cv::KeyPoint>& keypoints1, const std::vector<cv::KeyPoint>& keypoints2, const std::vector<cv::DMatch>& matches)
|
||||
{
|
||||
int validCount = 0;
|
||||
|
||||
@ -57,23 +119,9 @@ int getValidMatchesCount(const std::vector<cv::KeyPoint>& keypoints1, const std:
|
||||
const cv::KeyPoint& p1 = keypoints1[m.queryIdx];
|
||||
const cv::KeyPoint& p2 = keypoints2[m.trainIdx];
|
||||
|
||||
const float maxPtDif = 1.f;
|
||||
const float maxSizeDif = 1.f;
|
||||
const float maxAngleDif = 2.f;
|
||||
const float maxResponseDif = 0.1f;
|
||||
|
||||
float dist = (float) cv::norm(p1.pt - p2.pt);
|
||||
|
||||
if (dist < maxPtDif &&
|
||||
fabs(p1.size - p2.size) < maxSizeDif &&
|
||||
abs(p1.angle - p2.angle) < maxAngleDif &&
|
||||
abs(p1.response - p2.response) < maxResponseDif &&
|
||||
p1.octave == p2.octave &&
|
||||
p1.class_id == p2.class_id)
|
||||
{
|
||||
if (keyPointsEquals(p1, p2))
|
||||
++validCount;
|
||||
}
|
||||
}
|
||||
|
||||
return validCount;
|
||||
}
|
||||
@ -81,78 +129,280 @@ int getValidMatchesCount(const std::vector<cv::KeyPoint>& keypoints1, const std:
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SURF
|
||||
|
||||
struct SURF : TestWithParam<cv::gpu::DeviceInfo>
|
||||
IMPLEMENT_PARAM_CLASS(SURF_HessianThreshold, double)
|
||||
IMPLEMENT_PARAM_CLASS(SURF_Octaves, int)
|
||||
IMPLEMENT_PARAM_CLASS(SURF_OctaveLayers, int)
|
||||
IMPLEMENT_PARAM_CLASS(SURF_Extended, bool)
|
||||
IMPLEMENT_PARAM_CLASS(SURF_Upright, bool)
|
||||
|
||||
PARAM_TEST_CASE(SURF, cv::gpu::DeviceInfo, SURF_HessianThreshold, SURF_Octaves, SURF_OctaveLayers, SURF_Extended, SURF_Upright)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
cv::Mat image;
|
||||
cv::Mat mask;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints_gold;
|
||||
std::vector<float> descriptors_gold;
|
||||
double hessianThreshold;
|
||||
int nOctaves;
|
||||
int nOctaveLayers;
|
||||
bool extended;
|
||||
bool upright;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GetParam();
|
||||
devInfo = GET_PARAM(0);
|
||||
hessianThreshold = GET_PARAM(1);
|
||||
nOctaves = GET_PARAM(2);
|
||||
nOctaveLayers = GET_PARAM(3);
|
||||
extended = GET_PARAM(4);
|
||||
upright = GET_PARAM(5);
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
mask = cv::Mat(image.size(), CV_8UC1, cv::Scalar::all(1));
|
||||
mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));
|
||||
|
||||
cv::SURF fdetector_gold;
|
||||
fdetector_gold.extended = false;
|
||||
fdetector_gold(image, mask, keypoints_gold, descriptors_gold);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(SURF, EmptyDataTest)
|
||||
TEST_P(SURF, Detector)
|
||||
{
|
||||
cv::gpu::SURF_GPU fdetector;
|
||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
cv::gpu::SURF_GPU surf;
|
||||
surf.hessianThreshold = hessianThreshold;
|
||||
surf.nOctaves = nOctaves;
|
||||
surf.nOctaveLayers = nOctaveLayers;
|
||||
surf.extended = extended;
|
||||
surf.upright = upright;
|
||||
surf.keypointsRatio = 0.05f;
|
||||
|
||||
cv::gpu::GpuMat image;
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
std::vector<float> descriptors;
|
||||
surf(loadMat(image), cv::gpu::GpuMat(), keypoints);
|
||||
|
||||
fdetector(image, cv::gpu::GpuMat(), keypoints, descriptors);
|
||||
cv::SURF surf_gold;
|
||||
surf_gold.hessianThreshold = hessianThreshold;
|
||||
surf_gold.nOctaves = nOctaves;
|
||||
surf_gold.nOctaveLayers = nOctaveLayers;
|
||||
surf_gold.extended = extended;
|
||||
surf_gold.upright = upright;
|
||||
|
||||
EXPECT_TRUE(keypoints.empty());
|
||||
EXPECT_TRUE(descriptors.empty());
|
||||
std::vector<cv::KeyPoint> keypoints_gold;
|
||||
surf_gold(image, cv::noArray(), keypoints_gold);
|
||||
|
||||
ASSERT_KEYPOINTS_EQ(keypoints_gold, keypoints);
|
||||
}
|
||||
|
||||
TEST_P(SURF, Accuracy)
|
||||
TEST_P(SURF, Detector_Masked)
|
||||
{
|
||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
cv::Mat mask(image.size(), CV_8UC1, cv::Scalar::all(1));
|
||||
mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));
|
||||
|
||||
cv::gpu::SURF_GPU surf;
|
||||
surf.hessianThreshold = hessianThreshold;
|
||||
surf.nOctaves = nOctaves;
|
||||
surf.nOctaveLayers = nOctaveLayers;
|
||||
surf.extended = extended;
|
||||
surf.upright = upright;
|
||||
surf.keypointsRatio = 0.05f;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
surf(loadMat(image), loadMat(mask), keypoints);
|
||||
|
||||
cv::gpu::GpuMat dev_descriptors;
|
||||
cv::gpu::SURF_GPU fdetector; fdetector.extended = false;
|
||||
cv::SURF surf_gold;
|
||||
surf_gold.hessianThreshold = hessianThreshold;
|
||||
surf_gold.nOctaves = nOctaves;
|
||||
surf_gold.nOctaveLayers = nOctaveLayers;
|
||||
surf_gold.extended = extended;
|
||||
surf_gold.upright = upright;
|
||||
|
||||
fdetector(loadMat(image), loadMat(mask), keypoints, dev_descriptors);
|
||||
std::vector<cv::KeyPoint> keypoints_gold;
|
||||
surf_gold(image, mask, keypoints_gold);
|
||||
|
||||
dev_descriptors.download(descriptors);
|
||||
ASSERT_KEYPOINTS_EQ(keypoints_gold, keypoints);
|
||||
}
|
||||
|
||||
TEST_P(SURF, Descriptor)
|
||||
{
|
||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
cv::gpu::SURF_GPU surf;
|
||||
surf.hessianThreshold = hessianThreshold;
|
||||
surf.nOctaves = nOctaves;
|
||||
surf.nOctaveLayers = nOctaveLayers;
|
||||
surf.extended = extended;
|
||||
surf.upright = upright;
|
||||
surf.keypointsRatio = 0.05f;
|
||||
|
||||
cv::SURF surf_gold;
|
||||
surf_gold.hessianThreshold = hessianThreshold;
|
||||
surf_gold.nOctaves = nOctaves;
|
||||
surf_gold.nOctaveLayers = nOctaveLayers;
|
||||
surf_gold.extended = extended;
|
||||
surf_gold.upright = upright;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
surf_gold(image, cv::noArray(), keypoints);
|
||||
|
||||
cv::gpu::GpuMat descriptors;
|
||||
surf(loadMat(image), cv::gpu::GpuMat(), keypoints, descriptors, true);
|
||||
|
||||
cv::Mat descriptors_gold;
|
||||
surf_gold(image, cv::noArray(), keypoints, descriptors_gold, true);
|
||||
|
||||
cv::BFMatcher matcher(cv::NORM_L2);
|
||||
std::vector<cv::DMatch> matches;
|
||||
matcher.match(descriptors_gold, cv::Mat(descriptors), matches);
|
||||
|
||||
matcher.match(cv::Mat(static_cast<int>(keypoints_gold.size()), 64, CV_32FC1, &descriptors_gold[0]), descriptors, matches);
|
||||
int matchedCount = getMatchedPointsCount(keypoints, keypoints, matches);
|
||||
double matchedRatio = static_cast<double>(matchedCount) / keypoints.size();
|
||||
|
||||
int validCount = getValidMatchesCount(keypoints_gold, keypoints, matches);
|
||||
|
||||
double validRatio = (double) validCount / matches.size();
|
||||
|
||||
EXPECT_GT(validRatio, 0.5);
|
||||
EXPECT_GT(matchedRatio, 0.35);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Features2D, SURF, DEVICES(cv::gpu::GLOBAL_ATOMICS));
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Features2D, SURF, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values(SURF_HessianThreshold(100.0), SURF_HessianThreshold(500.0), SURF_HessianThreshold(1000.0)),
|
||||
testing::Values(SURF_Octaves(3), SURF_Octaves(4)),
|
||||
testing::Values(SURF_OctaveLayers(2), SURF_OctaveLayers(3)),
|
||||
testing::Values(SURF_Extended(false), SURF_Extended(true)),
|
||||
testing::Values(SURF_Upright(false), SURF_Upright(true))));
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FAST
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(FAST_Threshold, int)
|
||||
IMPLEMENT_PARAM_CLASS(FAST_NonmaxSupression, bool)
|
||||
|
||||
PARAM_TEST_CASE(FAST, cv::gpu::DeviceInfo, FAST_Threshold, FAST_NonmaxSupression)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
int threshold;
|
||||
bool nonmaxSupression;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GET_PARAM(0);
|
||||
threshold = GET_PARAM(1);
|
||||
nonmaxSupression = GET_PARAM(2);
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(FAST, Accuracy)
|
||||
{
|
||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
cv::gpu::FAST_GPU fast(threshold);
|
||||
fast.nonmaxSupression = nonmaxSupression;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
fast(loadMat(image), cv::gpu::GpuMat(), keypoints);
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints_gold;
|
||||
cv::FAST(image, keypoints_gold, threshold, nonmaxSupression);
|
||||
|
||||
ASSERT_KEYPOINTS_EQ(keypoints_gold, keypoints);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Features2D, FAST, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values(FAST_Threshold(25), FAST_Threshold(50)),
|
||||
testing::Values(FAST_NonmaxSupression(false), FAST_NonmaxSupression(true))));
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ORB
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(ORB_FeaturesCount, int)
|
||||
IMPLEMENT_PARAM_CLASS(ORB_ScaleFactor, float)
|
||||
IMPLEMENT_PARAM_CLASS(ORB_LevelsCount, int)
|
||||
IMPLEMENT_PARAM_CLASS(ORB_EdgeThreshold, int)
|
||||
IMPLEMENT_PARAM_CLASS(ORB_firstLevel, int)
|
||||
IMPLEMENT_PARAM_CLASS(ORB_WTA_K, int)
|
||||
IMPLEMENT_PARAM_CLASS(ORB_PatchSize, int)
|
||||
IMPLEMENT_PARAM_CLASS(ORB_BlurForDescriptor, bool)
|
||||
|
||||
CV_ENUM(ORB_ScoreType, cv::ORB::HARRIS_SCORE, cv::ORB::FAST_SCORE)
|
||||
|
||||
PARAM_TEST_CASE(ORB, cv::gpu::DeviceInfo, ORB_FeaturesCount, ORB_ScaleFactor, ORB_LevelsCount, ORB_EdgeThreshold, ORB_firstLevel, ORB_WTA_K, ORB_ScoreType, ORB_PatchSize, ORB_BlurForDescriptor)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
int nFeatures;
|
||||
float scaleFactor;
|
||||
int nLevels;
|
||||
int edgeThreshold;
|
||||
int firstLevel;
|
||||
int WTA_K;
|
||||
int scoreType;
|
||||
int patchSize;
|
||||
bool blurForDescriptor;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GET_PARAM(0);
|
||||
nFeatures = GET_PARAM(1);
|
||||
scaleFactor = GET_PARAM(2);
|
||||
nLevels = GET_PARAM(3);
|
||||
edgeThreshold = GET_PARAM(4);
|
||||
firstLevel = GET_PARAM(5);
|
||||
WTA_K = GET_PARAM(6);
|
||||
scoreType = GET_PARAM(7);
|
||||
patchSize = GET_PARAM(8);
|
||||
blurForDescriptor = GET_PARAM(9);
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ORB, Accuracy)
|
||||
{
|
||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
cv::Mat mask(image.size(), CV_8UC1, cv::Scalar::all(1));
|
||||
mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));
|
||||
|
||||
cv::gpu::ORB_GPU orb(nFeatures, scaleFactor, nLevels, edgeThreshold, firstLevel, WTA_K, scoreType, patchSize);
|
||||
orb.blurForDescriptor = blurForDescriptor;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::gpu::GpuMat descriptors;
|
||||
orb(loadMat(image), loadMat(mask), keypoints, descriptors);
|
||||
|
||||
cv::ORB orb_gold(nFeatures, scaleFactor, nLevels, edgeThreshold, firstLevel, WTA_K, scoreType, patchSize);
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints_gold;
|
||||
cv::Mat descriptors_gold;
|
||||
orb_gold(image, mask, keypoints_gold, descriptors_gold);
|
||||
|
||||
cv::BFMatcher matcher(cv::NORM_HAMMING);
|
||||
std::vector<cv::DMatch> matches;
|
||||
matcher.match(descriptors_gold, cv::Mat(descriptors), matches);
|
||||
|
||||
int matchedCount = getMatchedPointsCount(keypoints_gold, keypoints, matches);
|
||||
double matchedRatio = static_cast<double>(matchedCount) / keypoints.size();
|
||||
|
||||
EXPECT_GT(matchedRatio, 0.35);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Features2D, ORB, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
testing::Values(ORB_FeaturesCount(1000)),
|
||||
testing::Values(ORB_ScaleFactor(1.2f)),
|
||||
testing::Values(ORB_LevelsCount(4), ORB_LevelsCount(8)),
|
||||
testing::Values(ORB_EdgeThreshold(31)),
|
||||
testing::Values(ORB_firstLevel(0), ORB_firstLevel(2)),
|
||||
testing::Values(ORB_WTA_K(2), ORB_WTA_K(3), ORB_WTA_K(4)),
|
||||
testing::Values(ORB_ScoreType(cv::ORB::HARRIS_SCORE)),
|
||||
testing::Values(ORB_PatchSize(31), ORB_PatchSize(29)),
|
||||
testing::Values(ORB_BlurForDescriptor(false), ORB_BlurForDescriptor(true))));
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BruteForceMatcher
|
||||
|
||||
PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, DistType, int)
|
||||
CV_ENUM(DistType, cv::gpu::BruteForceMatcher_GPU_base::L1Dist, cv::gpu::BruteForceMatcher_GPU_base::L2Dist, cv::gpu::BruteForceMatcher_GPU_base::HammingDist)
|
||||
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
|
||||
|
||||
PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, DistType, DescriptorSize)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::gpu::BruteForceMatcher_GPU_base::DistType distType;
|
||||
@ -212,10 +462,9 @@ PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, DistType, int)
|
||||
|
||||
TEST_P(BruteForceMatcher, Match)
|
||||
{
|
||||
std::vector<cv::DMatch> matches;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
std::vector<cv::DMatch> matches;
|
||||
matcher.match(loadMat(query), loadMat(train), matches);
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
@ -234,10 +483,6 @@ TEST_P(BruteForceMatcher, Match)
|
||||
|
||||
TEST_P(BruteForceMatcher, MatchAdd)
|
||||
{
|
||||
std::vector<cv::DMatch> matches;
|
||||
|
||||
bool isMaskSupported;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
@ -255,18 +500,17 @@ TEST_P(BruteForceMatcher, MatchAdd)
|
||||
masks[mi].col(di * countFactor).setTo(cv::Scalar::all(0));
|
||||
}
|
||||
|
||||
std::vector<cv::DMatch> matches;
|
||||
matcher.match(cv::gpu::GpuMat(query), matches, masks);
|
||||
|
||||
isMaskSupported = matcher.isMaskSupported();
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
|
||||
int badCount = 0;
|
||||
int shift = matcher.isMaskSupported() ? 1 : 0;
|
||||
for (size_t i = 0; i < matches.size(); i++)
|
||||
{
|
||||
cv::DMatch match = matches[i];
|
||||
int shift = isMaskSupported ? 1 : 0;
|
||||
{
|
||||
|
||||
if ((int)i < queryDescCount / 2)
|
||||
{
|
||||
if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + shift) || (match.imgIdx != 0))
|
||||
@ -278,7 +522,6 @@ TEST_P(BruteForceMatcher, MatchAdd)
|
||||
badCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, badCount);
|
||||
}
|
||||
@ -287,9 +530,9 @@ TEST_P(BruteForceMatcher, KnnMatch2)
|
||||
{
|
||||
const int knn = 2;
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
matcher.knnMatch(loadMat(query), loadMat(train), matches, knn);
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
@ -317,11 +560,11 @@ TEST_P(BruteForceMatcher, KnnMatch2)
|
||||
|
||||
TEST_P(BruteForceMatcher, KnnMatch3)
|
||||
{
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
const int knn = 3;
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
matcher.knnMatch(loadMat(query), loadMat(train), matches, knn);
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
@ -350,9 +593,6 @@ TEST_P(BruteForceMatcher, KnnMatch3)
|
||||
TEST_P(BruteForceMatcher, KnnMatchAdd2)
|
||||
{
|
||||
const int knn = 2;
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
bool isMaskSupported;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
@ -371,14 +611,14 @@ TEST_P(BruteForceMatcher, KnnMatchAdd2)
|
||||
masks[mi].col(di * countFactor).setTo(cv::Scalar::all(0));
|
||||
}
|
||||
|
||||
matcher.knnMatch(cv::gpu::GpuMat(query), matches, knn, masks);
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
isMaskSupported = matcher.isMaskSupported();
|
||||
matcher.knnMatch(cv::gpu::GpuMat(query), matches, knn, masks);
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
|
||||
int badCount = 0;
|
||||
int shift = isMaskSupported ? 1 : 0;
|
||||
int shift = matcher.isMaskSupported() ? 1 : 0;
|
||||
for (size_t i = 0; i < matches.size(); i++)
|
||||
{
|
||||
if ((int)matches[i].size() != knn)
|
||||
@ -412,9 +652,6 @@ TEST_P(BruteForceMatcher, KnnMatchAdd2)
|
||||
TEST_P(BruteForceMatcher, KnnMatchAdd3)
|
||||
{
|
||||
const int knn = 3;
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
bool isMaskSupported;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
@ -433,14 +670,13 @@ TEST_P(BruteForceMatcher, KnnMatchAdd3)
|
||||
masks[mi].col(di * countFactor).setTo(cv::Scalar::all(0));
|
||||
}
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
matcher.knnMatch(cv::gpu::GpuMat(query), matches, knn, masks);
|
||||
|
||||
isMaskSupported = matcher.isMaskSupported();
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
|
||||
int badCount = 0;
|
||||
int shift = isMaskSupported ? 1 : 0;
|
||||
int shift = matcher.isMaskSupported() ? 1 : 0;
|
||||
for (size_t i = 0; i < matches.size(); i++)
|
||||
{
|
||||
if ((int)matches[i].size() != knn)
|
||||
@ -473,16 +709,11 @@ TEST_P(BruteForceMatcher, KnnMatchAdd3)
|
||||
|
||||
TEST_P(BruteForceMatcher, RadiusMatch)
|
||||
{
|
||||
if (!supportFeature(devInfo, cv::gpu::SHARED_ATOMICS))
|
||||
return;
|
||||
|
||||
const float radius = 1.f / countFactor;
|
||||
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
matcher.radiusMatch(loadMat(query), loadMat(train), matches, radius);
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
@ -505,16 +736,9 @@ TEST_P(BruteForceMatcher, RadiusMatch)
|
||||
|
||||
TEST_P(BruteForceMatcher, RadiusMatchAdd)
|
||||
{
|
||||
if (!supportFeature(devInfo, cv::gpu::SHARED_ATOMICS))
|
||||
return;
|
||||
|
||||
int n = 3;
|
||||
const int n = 3;
|
||||
const float radius = 1.f / countFactor * n;
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
|
||||
bool isMaskSupported;
|
||||
|
||||
cv::gpu::BruteForceMatcher_GPU_base matcher(distType);
|
||||
|
||||
cv::gpu::GpuMat d_train(train);
|
||||
@ -532,15 +756,14 @@ TEST_P(BruteForceMatcher, RadiusMatchAdd)
|
||||
masks[mi].col(di * countFactor).setTo(cv::Scalar::all(0));
|
||||
}
|
||||
|
||||
std::vector< std::vector<cv::DMatch> > matches;
|
||||
matcher.radiusMatch(cv::gpu::GpuMat(query), matches, radius, masks);
|
||||
|
||||
isMaskSupported = matcher.isMaskSupported();
|
||||
|
||||
ASSERT_EQ(static_cast<size_t>(queryDescCount), matches.size());
|
||||
|
||||
int badCount = 0;
|
||||
int shift = isMaskSupported ? 1 : 0;
|
||||
int needMatchCount = isMaskSupported ? n-1 : n;
|
||||
int shift = matcher.isMaskSupported() ? 1 : 0;
|
||||
int needMatchCount = matcher.isMaskSupported() ? n-1 : n;
|
||||
for (size_t i = 0; i < matches.size(); i++)
|
||||
{
|
||||
if ((int)matches[i].size() != needMatchCount)
|
||||
@ -571,141 +794,9 @@ TEST_P(BruteForceMatcher, RadiusMatchAdd)
|
||||
ASSERT_EQ(0, badCount);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher, Combine(
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Features2D, BruteForceMatcher, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
Values(cv::gpu::BruteForceMatcher_GPU_base::L1Dist, cv::gpu::BruteForceMatcher_GPU_base::L2Dist),
|
||||
Values(57, 64, 83, 128, 179, 256, 304)));
|
||||
testing::Values(DistType(cv::gpu::BruteForceMatcher_GPU_base::L1Dist), DistType(cv::gpu::BruteForceMatcher_GPU_base::L2Dist)),
|
||||
testing::Values(DescriptorSize(57), DescriptorSize(64), DescriptorSize(83), DescriptorSize(128), DescriptorSize(179), DescriptorSize(256), DescriptorSize(304))));
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FAST
|
||||
|
||||
struct FAST : TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
cv::Mat image;
|
||||
|
||||
int threshold;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints_gold;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
threshold = 30;
|
||||
|
||||
cv::FAST(image, keypoints_gold, threshold);
|
||||
}
|
||||
};
|
||||
|
||||
struct HashEq
|
||||
{
|
||||
size_t hash;
|
||||
inline HashEq(size_t hash_) : hash(hash_) {}
|
||||
inline bool operator ()(const cv::KeyPoint& kp) const
|
||||
{
|
||||
return kp.hash() == hash;
|
||||
}
|
||||
};
|
||||
|
||||
struct KeyPointCompare
|
||||
{
|
||||
inline bool operator ()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
||||
{
|
||||
return kp1.pt.y < kp2.pt.y || (kp1.pt.y == kp2.pt.y && kp1.pt.x < kp2.pt.x);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(FAST, Accuracy)
|
||||
{
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
|
||||
cv::gpu::FAST_GPU fastGPU(threshold);
|
||||
|
||||
fastGPU(cv::gpu::GpuMat(image), cv::gpu::GpuMat(), keypoints);
|
||||
|
||||
ASSERT_EQ(keypoints.size(), keypoints_gold.size());
|
||||
|
||||
std::sort(keypoints.begin(), keypoints.end(), KeyPointCompare());
|
||||
|
||||
for (size_t i = 0; i < keypoints_gold.size(); ++i)
|
||||
{
|
||||
const cv::KeyPoint& kp1 = keypoints[i];
|
||||
const cv::KeyPoint& kp2 = keypoints_gold[i];
|
||||
|
||||
size_t h1 = kp1.hash();
|
||||
size_t h2 = kp2.hash();
|
||||
|
||||
ASSERT_EQ(h1, h2);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Features2D, FAST, DEVICES(cv::gpu::GLOBAL_ATOMICS));
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ORB
|
||||
|
||||
struct ORB : TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
||||
cv::Mat image;
|
||||
cv::Mat mask;
|
||||
|
||||
int npoints;
|
||||
|
||||
std::vector<cv::KeyPoint> keypoints_gold;
|
||||
cv::Mat descriptors_gold;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
devInfo = GetParam();
|
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
||||
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
mask = cv::Mat(image.size(), CV_8UC1, cv::Scalar::all(1));
|
||||
mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));
|
||||
|
||||
npoints = 1000;
|
||||
|
||||
cv::ORB orbCPU(npoints);
|
||||
|
||||
orbCPU(image, mask, keypoints_gold, descriptors_gold);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ORB, Accuracy)
|
||||
{
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
|
||||
cv::gpu::ORB_GPU orbGPU(npoints);
|
||||
cv::gpu::GpuMat d_descriptors;
|
||||
|
||||
orbGPU(cv::gpu::GpuMat(image), cv::gpu::GpuMat(mask), keypoints, d_descriptors);
|
||||
|
||||
d_descriptors.download(descriptors);
|
||||
|
||||
cv::BFMatcher matcher(cv::NORM_HAMMING);
|
||||
std::vector<cv::DMatch> matches;
|
||||
|
||||
matcher.match(descriptors_gold, descriptors, matches);
|
||||
|
||||
int count = getValidMatchesCount(keypoints_gold, keypoints, matches);
|
||||
double ratio = (double) count / matches.size();
|
||||
|
||||
ASSERT_GE(ratio, 0.65);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Features2D, ORB, DEVICES(cv::gpu::GLOBAL_ATOMICS));
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
} // namespace
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2198,7 +2198,7 @@ INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, ALL_DEVICES);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cornerHarris
|
||||
|
||||
PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, Border, int, int)
|
||||
PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderType, int, int)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
int type;
|
||||
@ -2257,7 +2257,7 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, Combine(
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cornerMinEigen
|
||||
|
||||
PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, Border, int, int)
|
||||
PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, BorderType, int, int)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
int type;
|
||||
@ -2572,6 +2572,8 @@ INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, Combine(
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// matchTemplate
|
||||
|
||||
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
|
||||
|
||||
PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, int, TemplateMethod)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
@ -2776,6 +2778,8 @@ INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_CCOEF_NORMED, Combine(
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// MulSpectrums
|
||||
|
||||
CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
|
||||
|
||||
PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, DftFlags)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
@ -109,7 +109,7 @@ namespace
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Test
|
||||
|
||||
PARAM_TEST_CASE(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Border, UseRoi)
|
||||
PARAM_TEST_CASE(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderType, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -171,7 +171,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Remap, testing::Combine(
|
||||
DIFFERENT_SIZES,
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
|
||||
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
|
||||
testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_CONSTANT), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),
|
||||
testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_CONSTANT), BorderType(cv::BORDER_REFLECT), BorderType(cv::BORDER_WRAP)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
|
@ -43,6 +43,9 @@
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
|
||||
#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV))
|
||||
|
||||
PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
@ -175,7 +175,7 @@ namespace
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Test
|
||||
|
||||
PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Interpolation, Border, UseRoi)
|
||||
PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Interpolation, BorderType, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -225,7 +225,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpAffine, testing::Combine(
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
|
||||
DIRECT_INVERSE,
|
||||
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
|
||||
testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),
|
||||
testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_REFLECT), BorderType(cv::BORDER_WRAP)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
@ -175,7 +175,7 @@ namespace
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Test
|
||||
|
||||
PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Interpolation, Border, UseRoi)
|
||||
PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Interpolation, BorderType, UseRoi)
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
cv::Size size;
|
||||
@ -225,7 +225,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpPerspective, testing::Combine(
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
|
||||
DIRECT_INVERSE,
|
||||
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
|
||||
testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),
|
||||
testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_REFLECT), BorderType(cv::BORDER_WRAP)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
@ -47,6 +47,9 @@ using namespace cv::gpu;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// random generators
|
||||
|
||||
int randomInt(int minVal, int maxVal)
|
||||
{
|
||||
RNG& rng = TS::ptr()->get_rng();
|
||||
@ -74,6 +77,9 @@ Mat randomMat(Size size, int type, double minVal, double maxVal)
|
||||
return randomMat(TS::ptr()->get_rng(), size, type, minVal, maxVal, false);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// GpuMat create
|
||||
|
||||
cv::gpu::GpuMat createMat(cv::Size size, int type, bool useRoi)
|
||||
{
|
||||
Size size0 = size;
|
||||
@ -99,6 +105,30 @@ GpuMat loadMat(const Mat& m, bool useRoi)
|
||||
return d_m;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Image load
|
||||
|
||||
Mat readImage(const string& fileName, int flags)
|
||||
{
|
||||
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
|
||||
}
|
||||
|
||||
Mat readImageType(const string& fname, int type)
|
||||
{
|
||||
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
|
||||
if (CV_MAT_CN(type) == 4)
|
||||
{
|
||||
Mat temp;
|
||||
cvtColor(src, temp, cv::COLOR_BGR2BGRA);
|
||||
swap(src, temp);
|
||||
}
|
||||
src.convertTo(src, CV_MAT_DEPTH(type));
|
||||
return src;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Gpu devices
|
||||
|
||||
bool supportFeature(const DeviceInfo& info, FeatureSet feature)
|
||||
{
|
||||
return TargetArchs::builtWith(feature) && info.supports(feature);
|
||||
@ -150,6 +180,170 @@ vector<DeviceInfo> devices(FeatureSet feature)
|
||||
return devs_filtered;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Additional assertion
|
||||
|
||||
Mat getMat(InputArray arr)
|
||||
{
|
||||
if (arr.kind() == _InputArray::GPU_MAT)
|
||||
{
|
||||
Mat m;
|
||||
arr.getGpuMat().download(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
return arr.getMat();
|
||||
}
|
||||
|
||||
double checkNorm(InputArray m1, const InputArray m2)
|
||||
{
|
||||
return norm(getMat(m1), getMat(m2), NORM_INF);
|
||||
}
|
||||
|
||||
void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minLoc_, Point* maxLoc_, const Mat& mask)
|
||||
{
|
||||
if (src.depth() != CV_8S)
|
||||
{
|
||||
minMaxLoc(src, minVal_, maxVal_, minLoc_, maxLoc_, mask);
|
||||
return;
|
||||
}
|
||||
|
||||
// OpenCV's minMaxLoc doesn't support CV_8S type
|
||||
double minVal = numeric_limits<double>::max();
|
||||
Point minLoc(-1, -1);
|
||||
|
||||
double maxVal = -numeric_limits<double>::max();
|
||||
Point maxLoc(-1, -1);
|
||||
|
||||
for (int y = 0; y < src.rows; ++y)
|
||||
{
|
||||
const schar* src_row = src.ptr<signed char>(y);
|
||||
const uchar* mask_row = mask.empty() ? 0 : mask.ptr<unsigned char>(y);
|
||||
|
||||
for (int x = 0; x < src.cols; ++x)
|
||||
{
|
||||
if (!mask_row || mask_row[x])
|
||||
{
|
||||
schar val = src_row[x];
|
||||
|
||||
if (val < minVal)
|
||||
{
|
||||
minVal = val;
|
||||
minLoc = cv::Point(x, y);
|
||||
}
|
||||
|
||||
if (val > maxVal)
|
||||
{
|
||||
maxVal = val;
|
||||
maxLoc = cv::Point(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minVal_) *minVal_ = minVal;
|
||||
if (maxVal_) *maxVal_ = maxVal;
|
||||
|
||||
if (minLoc_) *minLoc_ = minLoc;
|
||||
if (maxLoc_) *maxLoc_ = maxLoc;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T, typename OutT> string printMatValImpl(const Mat& m, Point p)
|
||||
{
|
||||
const int cn = m.channels();
|
||||
|
||||
ostringstream ostr;
|
||||
ostr << "(";
|
||||
|
||||
p.x /= cn;
|
||||
|
||||
ostr << static_cast<OutT>(m.at<T>(p.y, p.x * cn));
|
||||
for (int c = 1; c < m.channels(); ++c)
|
||||
{
|
||||
ostr << ", " << static_cast<OutT>(m.at<T>(p.y, p.x * cn + c));
|
||||
}
|
||||
ostr << ")";
|
||||
|
||||
return ostr.str();
|
||||
}
|
||||
|
||||
string printMatVal(const Mat& m, Point p)
|
||||
{
|
||||
typedef string (*func_t)(const Mat& m, Point p);
|
||||
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
printMatValImpl<uchar, int>, printMatValImpl<schar, int>, printMatValImpl<ushort, int>, printMatValImpl<short, int>,
|
||||
printMatValImpl<int, int>, printMatValImpl<float, float>, printMatValImpl<double, double>
|
||||
};
|
||||
|
||||
return funcs[m.depth()](m, p);
|
||||
}
|
||||
}
|
||||
|
||||
testing::AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, cv::InputArray m1_, cv::InputArray m2_, double eps)
|
||||
{
|
||||
Mat m1 = getMat(m1_);
|
||||
Mat m2 = getMat(m2_);
|
||||
|
||||
if (m1.size() != m2.size())
|
||||
{
|
||||
return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \""
|
||||
<< expr1 << "\" [" << PrintToString(m1.size()) << "] vs \""
|
||||
<< expr2 << "\" [" << PrintToString(m2.size()) << "]";
|
||||
}
|
||||
|
||||
if (m1.type() != m2.type())
|
||||
{
|
||||
return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \""
|
||||
<< expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \""
|
||||
<< expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]";
|
||||
}
|
||||
|
||||
Mat diff;
|
||||
absdiff(m1.reshape(1), m2.reshape(1), diff);
|
||||
|
||||
double maxVal = 0.0;
|
||||
Point maxLoc;
|
||||
minMaxLocGold(diff, 0, &maxVal, 0, &maxLoc);
|
||||
|
||||
if (maxVal > eps)
|
||||
{
|
||||
return AssertionFailure() << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2
|
||||
<< "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")"
|
||||
<< ", which exceeds \"" << eps_expr << "\", where \""
|
||||
<< expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \""
|
||||
<< expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \""
|
||||
<< eps_expr << "\" evaluates to " << eps;
|
||||
}
|
||||
|
||||
return AssertionSuccess();
|
||||
}
|
||||
|
||||
double checkSimilarity(InputArray m1, InputArray m2)
|
||||
{
|
||||
Mat diff;
|
||||
matchTemplate(getMat(m1), getMat(m2), diff, CV_TM_CCORR_NORMED);
|
||||
return std::abs(diff.at<float>(0, 0) - 1.f);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Helper structs for value-parameterized tests
|
||||
|
||||
vector<MatDepth> depths(int depth_start, int depth_end)
|
||||
{
|
||||
vector<MatDepth> v;
|
||||
|
||||
v.reserve((depth_end - depth_start + 1));
|
||||
|
||||
for (int depth = depth_start; depth <= depth_end; ++depth)
|
||||
v.push_back(depth);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
|
||||
{
|
||||
vector<MatType> v;
|
||||
@ -174,37 +368,25 @@ const vector<MatType>& all_types()
|
||||
return v;
|
||||
}
|
||||
|
||||
Mat readImage(const string& fileName, int flags)
|
||||
void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
|
||||
{
|
||||
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
|
||||
(*os) << info.name();
|
||||
}
|
||||
|
||||
Mat readImageType(const string& fname, int type)
|
||||
void PrintTo(const UseRoi& useRoi, std::ostream* os)
|
||||
{
|
||||
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
|
||||
if (CV_MAT_CN(type) == 4)
|
||||
{
|
||||
Mat temp;
|
||||
cvtColor(src, temp, cv::COLOR_BGR2BGRA);
|
||||
swap(src, temp);
|
||||
}
|
||||
src.convertTo(src, CV_MAT_DEPTH(type));
|
||||
return src;
|
||||
if (useRoi)
|
||||
(*os) << "sub matrix";
|
||||
else
|
||||
(*os) << "whole matrix";
|
||||
}
|
||||
|
||||
namespace
|
||||
void PrintTo(const Inverse& inverse, std::ostream* os)
|
||||
{
|
||||
Mat getMat(InputArray arr)
|
||||
{
|
||||
if (arr.kind() == _InputArray::GPU_MAT)
|
||||
{
|
||||
Mat m;
|
||||
arr.getGpuMat().download(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
return arr.getMat();
|
||||
}
|
||||
if (inverse)
|
||||
(*os) << "inverse";
|
||||
else
|
||||
(*os) << "direct";
|
||||
}
|
||||
|
||||
void showDiff(InputArray gold_, InputArray actual_, double eps)
|
||||
@ -226,36 +408,3 @@ void showDiff(InputArray gold_, InputArray actual_, double eps)
|
||||
|
||||
waitKey();
|
||||
}
|
||||
|
||||
double checkNorm(InputArray m1, const InputArray m2)
|
||||
{
|
||||
return norm(getMat(m1), getMat(m2), NORM_INF);
|
||||
}
|
||||
|
||||
double checkSimilarity(InputArray m1, InputArray m2)
|
||||
{
|
||||
Mat diff;
|
||||
matchTemplate(getMat(m1), getMat(m2), diff, CV_TM_CCORR_NORMED);
|
||||
return std::abs(diff.at<float>(0, 0) - 1.f);
|
||||
}
|
||||
|
||||
void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
|
||||
{
|
||||
(*os) << info.name();
|
||||
}
|
||||
|
||||
void PrintTo(const UseRoi& useRoi, std::ostream* os)
|
||||
{
|
||||
if (useRoi)
|
||||
(*os) << "sub matrix";
|
||||
else
|
||||
(*os) << "whole matrix";
|
||||
}
|
||||
|
||||
void PrintTo(const Inverse& inverse, std::ostream* os)
|
||||
{
|
||||
if (inverse)
|
||||
(*os) << "inverse";
|
||||
else
|
||||
(*os) << "direct";
|
||||
}
|
||||
|
@ -42,37 +42,66 @@
|
||||
#ifndef __OPENCV_TEST_UTILITY_HPP__
|
||||
#define __OPENCV_TEST_UTILITY_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// random generators
|
||||
|
||||
int randomInt(int minVal, int maxVal);
|
||||
double randomDouble(double minVal, double maxVal);
|
||||
cv::Size randomSize(int minVal, int maxVal);
|
||||
cv::Scalar randomScalar(double minVal, double maxVal);
|
||||
cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// GpuMat create
|
||||
|
||||
cv::gpu::GpuMat createMat(cv::Size size, int type, bool useRoi = false);
|
||||
cv::gpu::GpuMat loadMat(const cv::Mat& m, bool useRoi = false);
|
||||
|
||||
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Image load
|
||||
|
||||
//! read image from testdata folder
|
||||
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
|
||||
|
||||
//! read image from testdata folder and convert it to specified type
|
||||
cv::Mat readImageType(const std::string& fname, int type);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Gpu devices
|
||||
|
||||
//! return true if device supports specified feature and gpu module was built with support the feature.
|
||||
bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
|
||||
|
||||
//! return all devices compatible with current gpu module build.
|
||||
const std::vector<cv::gpu::DeviceInfo>& devices();
|
||||
|
||||
//! return all devices compatible with current gpu module build which support specified feature.
|
||||
std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature);
|
||||
|
||||
//! read image from testdata folder.
|
||||
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
|
||||
cv::Mat readImageType(const std::string& fname, int type);
|
||||
#define ALL_DEVICES testing::ValuesIn(devices())
|
||||
#define DEVICES(feature) testing::ValuesIn(devices(feature))
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Additional assertion
|
||||
|
||||
cv::Mat getMat(cv::InputArray arr);
|
||||
|
||||
double checkNorm(cv::InputArray m1, cv::InputArray m2);
|
||||
|
||||
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
|
||||
{ \
|
||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
||||
EXPECT_LE(checkNorm(mat1, mat2), eps); \
|
||||
}
|
||||
void minMaxLocGold(const cv::Mat& src, double* minVal_, double* maxVal_ = 0, cv::Point* minLoc_ = 0, cv::Point* maxLoc_ = 0, const cv::Mat& mask = cv::Mat());
|
||||
|
||||
testing::AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, cv::InputArray m1, cv::InputArray m2, double eps);
|
||||
|
||||
#define EXPECT_MAT_NEAR(m1, m2, eps) EXPECT_PRED_FORMAT3(assertMatNear, m1, m2, eps)
|
||||
#define ASSERT_MAT_NEAR(m1, m2, eps) ASSERT_PRED_FORMAT3(assertMatNear, m1, m2, eps)
|
||||
|
||||
#define EXPECT_SCALAR_NEAR(s1, s2, eps) \
|
||||
{ \
|
||||
@ -81,6 +110,37 @@ double checkNorm(cv::InputArray m1, cv::InputArray m2);
|
||||
EXPECT_NEAR(s1[2], s2[2], eps); \
|
||||
EXPECT_NEAR(s1[3], s2[3], eps); \
|
||||
}
|
||||
#define ASSERT_SCALAR_NEAR(s1, s2, eps) \
|
||||
{ \
|
||||
ASSERT_NEAR(s1[0], s2[0], eps); \
|
||||
ASSERT_NEAR(s1[1], s2[1], eps); \
|
||||
ASSERT_NEAR(s1[2], s2[2], eps); \
|
||||
ASSERT_NEAR(s1[3], s2[3], eps); \
|
||||
}
|
||||
|
||||
#define EXPECT_POINT2_NEAR(p1, p2, eps) \
|
||||
{ \
|
||||
EXPECT_NEAR(p1.x, p2.x, eps); \
|
||||
EXPECT_NEAR(p1.y, p2.y, eps); \
|
||||
}
|
||||
#define ASSERT_POINT2_NEAR(p1, p2, eps) \
|
||||
{ \
|
||||
ASSERT_NEAR(p1.x, p2.x, eps); \
|
||||
ASSERT_NEAR(p1.y, p2.y, eps); \
|
||||
}
|
||||
|
||||
#define EXPECT_POINT3_NEAR(p1, p2, eps) \
|
||||
{ \
|
||||
EXPECT_NEAR(p1.x, p2.x, eps); \
|
||||
EXPECT_NEAR(p1.y, p2.y, eps); \
|
||||
EXPECT_NEAR(p1.z, p2.z, eps); \
|
||||
}
|
||||
#define ASSERT_POINT3_NEAR(p1, p2, eps) \
|
||||
{ \
|
||||
ASSERT_NEAR(p1.x, p2.x, eps); \
|
||||
ASSERT_NEAR(p1.y, p2.y, eps); \
|
||||
ASSERT_NEAR(p1.z, p2.z, eps); \
|
||||
}
|
||||
|
||||
double checkSimilarity(cv::InputArray m1, cv::InputArray m2);
|
||||
|
||||
@ -90,94 +150,35 @@ double checkSimilarity(cv::InputArray m1, cv::InputArray m2);
|
||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
||||
EXPECT_LE(checkSimilarity(mat1, mat2), eps); \
|
||||
}
|
||||
#define ASSERT_MAT_SIMILAR(mat1, mat2, eps) \
|
||||
{ \
|
||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
||||
ASSERT_LE(checkSimilarity(mat1, mat2), eps); \
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Helper structs for value-parameterized tests
|
||||
|
||||
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
||||
|
||||
namespace cv { namespace gpu
|
||||
{
|
||||
void PrintTo(const DeviceInfo& info, std::ostream* os);
|
||||
}}
|
||||
|
||||
using perf::MatDepth;
|
||||
using perf::MatType;
|
||||
|
||||
//! return vector with types from specified range.
|
||||
std::vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end);
|
||||
|
||||
//! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).
|
||||
const std::vector<MatType>& all_types();
|
||||
|
||||
class UseRoi
|
||||
{
|
||||
public:
|
||||
inline UseRoi(bool val = false) : val_(val) {}
|
||||
|
||||
inline operator bool() const { return val_; }
|
||||
|
||||
private:
|
||||
bool val_;
|
||||
};
|
||||
void PrintTo(const UseRoi& useRoi, std::ostream* os);
|
||||
#define WHOLE testing::Values(UseRoi(false))
|
||||
#define SUBMAT testing::Values(UseRoi(true))
|
||||
#define WHOLE_SUBMAT testing::Values(UseRoi(false), UseRoi(true))
|
||||
|
||||
class Inverse
|
||||
{
|
||||
public:
|
||||
inline Inverse(bool val = false) : val_(val) {}
|
||||
|
||||
inline operator bool() const { return val_; }
|
||||
|
||||
private:
|
||||
bool val_;
|
||||
};
|
||||
void PrintTo(const Inverse& useRoi, std::ostream* os);
|
||||
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
|
||||
|
||||
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
|
||||
#define ALL_CMP_CODES testing::Values(CmpCode(cv::CMP_EQ), CmpCode(cv::CMP_NE), CmpCode(cv::CMP_GT), CmpCode(cv::CMP_GE), CmpCode(cv::CMP_LT), CmpCode(cv::CMP_LE))
|
||||
|
||||
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX)
|
||||
|
||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
|
||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
|
||||
#define ALL_FLIP_CODES testing::Values(FlipCode(FLIP_BOTH), FlipCode(FLIP_X), FlipCode(FLIP_Y))
|
||||
|
||||
CV_ENUM(ReduceCode, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
|
||||
#define ALL_REDUCE_CODES testing::Values(ReduceCode(CV_REDUCE_SUM), ReduceCode(CV_REDUCE_AVG), ReduceCode(CV_REDUCE_MAX), ReduceCode(CV_REDUCE_MIN))
|
||||
|
||||
CV_FLAGS(GemmFlags, 0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T);
|
||||
#define ALL_GEMM_FLAGS testing::Values(GemmFlags(0), GemmFlags(cv::GEMM_1_T), GemmFlags(cv::GEMM_2_T), GemmFlags(cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_3_T), GemmFlags(cv::GEMM_1_T | cv::GEMM_2_T | cv::GEMM_3_T))
|
||||
|
||||
CV_ENUM(DistType, cv::gpu::BruteForceMatcher_GPU_base::L1Dist, cv::gpu::BruteForceMatcher_GPU_base::L2Dist)
|
||||
|
||||
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
|
||||
|
||||
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
|
||||
#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV))
|
||||
|
||||
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC)
|
||||
|
||||
CV_ENUM(Border, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
|
||||
|
||||
CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WARP_INVERSE_MAP)
|
||||
|
||||
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
|
||||
|
||||
CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
|
||||
|
||||
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
||||
|
||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
||||
|
||||
#define ALL_DEVICES testing::ValuesIn(devices())
|
||||
#define DEVICES(feature) testing::ValuesIn(devices(feature))
|
||||
|
||||
#define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113))
|
||||
|
||||
#define ALL_DEPTH testing::Values(MatDepth(CV_8U), MatDepth(CV_8S), MatDepth(CV_16U), MatDepth(CV_16S), MatDepth(CV_32S), MatDepth(CV_32F), MatDepth(CV_64F))
|
||||
#define ALL_TYPES testing::ValuesIn(all_types())
|
||||
#define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end))
|
||||
// Depth
|
||||
|
||||
using perf::MatDepth;
|
||||
|
||||
//! return vector with depths from specified range.
|
||||
std::vector<MatDepth> depths(int depth_start, int depth_end);
|
||||
|
||||
#define ALL_DEPTH testing::Values(MatDepth(CV_8U), MatDepth(CV_8S), MatDepth(CV_16U), MatDepth(CV_16S), MatDepth(CV_32S), MatDepth(CV_32F), MatDepth(CV_64F))
|
||||
#define DEPTHS(depth_start, depth_end) testing::ValuesIn(depths(depth_start, depth_end))
|
||||
#define DEPTH_PAIRS testing::Values(std::make_pair(MatDepth(CV_8U), MatDepth(CV_8U)), \
|
||||
std::make_pair(MatDepth(CV_8U), MatDepth(CV_16U)), \
|
||||
std::make_pair(MatDepth(CV_8U), MatDepth(CV_16S)), \
|
||||
@ -204,4 +205,88 @@ CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX
|
||||
\
|
||||
std::make_pair(MatDepth(CV_64F), MatDepth(CV_64F)))
|
||||
|
||||
// Type
|
||||
|
||||
using perf::MatType;
|
||||
|
||||
//! return vector with types from specified range.
|
||||
std::vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end);
|
||||
|
||||
//! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).
|
||||
const std::vector<MatType>& all_types();
|
||||
|
||||
#define ALL_TYPES testing::ValuesIn(all_types())
|
||||
#define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end))
|
||||
|
||||
// ROI
|
||||
|
||||
class UseRoi
|
||||
{
|
||||
public:
|
||||
inline UseRoi(bool val = false) : val_(val) {}
|
||||
|
||||
inline operator bool() const { return val_; }
|
||||
|
||||
private:
|
||||
bool val_;
|
||||
};
|
||||
|
||||
void PrintTo(const UseRoi& useRoi, std::ostream* os);
|
||||
|
||||
#define WHOLE testing::Values(UseRoi(false))
|
||||
#define SUBMAT testing::Values(UseRoi(true))
|
||||
#define WHOLE_SUBMAT testing::Values(UseRoi(false), UseRoi(true))
|
||||
|
||||
// Direct/Inverse
|
||||
|
||||
class Inverse
|
||||
{
|
||||
public:
|
||||
inline Inverse(bool val = false) : val_(val) {}
|
||||
|
||||
inline operator bool() const { return val_; }
|
||||
|
||||
private:
|
||||
bool val_;
|
||||
};
|
||||
void PrintTo(const Inverse& useRoi, std::ostream* os);
|
||||
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
|
||||
|
||||
// Param class
|
||||
|
||||
#define IMPLEMENT_PARAM_CLASS(name, type) \
|
||||
class name \
|
||||
{ \
|
||||
public: \
|
||||
name ( type arg = type ()) : val_(arg) {} \
|
||||
operator type () const {return val_;} \
|
||||
private: \
|
||||
type val_; \
|
||||
}; \
|
||||
inline void PrintTo( name param, std::ostream* os) \
|
||||
{ \
|
||||
*os << #name << "(" << static_cast< type >(param) << ")"; \
|
||||
}
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(Channels, int)
|
||||
|
||||
#define ALL_CHANNELS testing::Values(Channels(1), Channels(2), Channels(3), Channels(4))
|
||||
#define IMAGE_CHANNELS testing::Values(Channels(1), Channels(3), Channels(4))
|
||||
|
||||
// Flags and enums
|
||||
|
||||
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX)
|
||||
|
||||
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC)
|
||||
|
||||
CV_ENUM(BorderType, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
|
||||
#define ALL_BORDER_TYPES testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_CONSTANT), BorderType(cv::BORDER_REFLECT), BorderType(cv::BORDER_WRAP))
|
||||
|
||||
CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WARP_INVERSE_MAP)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Other
|
||||
|
||||
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||
|
||||
#endif // __OPENCV_TEST_UTILITY_HPP__
|
||||
|
Loading…
x
Reference in New Issue
Block a user