added GPU_TEST_P macros
This commit is contained in:
parent
4ba33fa1ed
commit
1a76242d99
@ -276,6 +276,8 @@ static void devNullOutput(const std::string& msg)
|
|||||||
(void)msg;
|
(void)msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)
|
bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)
|
||||||
{
|
{
|
||||||
path = test_data_path.c_str();
|
path = test_data_path.c_str();
|
||||||
@ -292,8 +294,6 @@ bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel
|
|||||||
return testListerII.invoke();
|
return testListerII.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)
|
bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)
|
||||||
{
|
{
|
||||||
path = test_data_path;
|
path = test_data_path;
|
||||||
|
405
modules/gpu/test/test_bgfg.cpp
Normal file
405
modules/gpu/test/test_bgfg.cpp
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Intel License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "test_precomp.hpp"
|
||||||
|
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// FGDStatModel
|
||||||
|
|
||||||
|
namespace cv
|
||||||
|
{
|
||||||
|
template<> void Ptr<CvBGStatModel>::delete_obj()
|
||||||
|
{
|
||||||
|
cvReleaseBGStatModel(&obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(FGDStatModel, cv::gpu::DeviceInfo, std::string, Channels)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
std::string inputFile;
|
||||||
|
int out_cn;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
|
||||||
|
inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1);
|
||||||
|
|
||||||
|
out_cn = GET_PARAM(2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(FGDStatModel, Update)
|
||||||
|
{
|
||||||
|
cv::VideoCapture cap(inputFile);
|
||||||
|
ASSERT_TRUE(cap.isOpened());
|
||||||
|
|
||||||
|
cv::Mat frame;
|
||||||
|
cap >> frame;
|
||||||
|
ASSERT_FALSE(frame.empty());
|
||||||
|
|
||||||
|
IplImage ipl_frame = frame;
|
||||||
|
cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_frame(frame);
|
||||||
|
cv::gpu::FGDStatModel d_model(out_cn);
|
||||||
|
d_model.create(d_frame);
|
||||||
|
|
||||||
|
cv::Mat h_background;
|
||||||
|
cv::Mat h_foreground;
|
||||||
|
cv::Mat h_background3;
|
||||||
|
|
||||||
|
cv::Mat backgroundDiff;
|
||||||
|
cv::Mat foregroundDiff;
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; ++i)
|
||||||
|
{
|
||||||
|
cap >> frame;
|
||||||
|
ASSERT_FALSE(frame.empty());
|
||||||
|
|
||||||
|
ipl_frame = frame;
|
||||||
|
int gold_count = cvUpdateBGStatModel(&ipl_frame, model);
|
||||||
|
|
||||||
|
d_frame.upload(frame);
|
||||||
|
|
||||||
|
int count = d_model.update(d_frame);
|
||||||
|
|
||||||
|
ASSERT_EQ(gold_count, count);
|
||||||
|
|
||||||
|
cv::Mat gold_background(model->background);
|
||||||
|
cv::Mat gold_foreground(model->foreground);
|
||||||
|
|
||||||
|
if (out_cn == 3)
|
||||||
|
d_model.background.download(h_background3);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d_model.background.download(h_background);
|
||||||
|
cv::cvtColor(h_background, h_background3, cv::COLOR_BGRA2BGR);
|
||||||
|
}
|
||||||
|
d_model.foreground.download(h_foreground);
|
||||||
|
|
||||||
|
ASSERT_MAT_NEAR(gold_background, h_background3, 1.0);
|
||||||
|
ASSERT_MAT_NEAR(gold_foreground, h_foreground, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, FGDStatModel, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
testing::Values(std::string("768x576.avi")),
|
||||||
|
testing::Values(Channels(3), Channels(4))));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MOG
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(UseGray, bool)
|
||||||
|
IMPLEMENT_PARAM_CLASS(LearningRate, double)
|
||||||
|
}
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(MOG, cv::gpu::DeviceInfo, std::string, UseGray, LearningRate, UseRoi)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
std::string inputFile;
|
||||||
|
bool useGray;
|
||||||
|
double learningRate;
|
||||||
|
bool useRoi;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
|
||||||
|
inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1);
|
||||||
|
|
||||||
|
useGray = GET_PARAM(2);
|
||||||
|
|
||||||
|
learningRate = GET_PARAM(3);
|
||||||
|
|
||||||
|
useRoi = GET_PARAM(4);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(MOG, Update)
|
||||||
|
{
|
||||||
|
cv::VideoCapture cap(inputFile);
|
||||||
|
ASSERT_TRUE(cap.isOpened());
|
||||||
|
|
||||||
|
cv::Mat frame;
|
||||||
|
cap >> frame;
|
||||||
|
ASSERT_FALSE(frame.empty());
|
||||||
|
|
||||||
|
cv::gpu::MOG_GPU mog;
|
||||||
|
cv::gpu::GpuMat foreground = createMat(frame.size(), CV_8UC1, useRoi);
|
||||||
|
|
||||||
|
cv::BackgroundSubtractorMOG mog_gold;
|
||||||
|
cv::Mat foreground_gold;
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
cap >> frame;
|
||||||
|
ASSERT_FALSE(frame.empty());
|
||||||
|
|
||||||
|
if (useGray)
|
||||||
|
{
|
||||||
|
cv::Mat temp;
|
||||||
|
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
|
||||||
|
cv::swap(temp, frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
mog(loadMat(frame, useRoi), foreground, (float)learningRate);
|
||||||
|
|
||||||
|
mog_gold(frame, foreground_gold, learningRate);
|
||||||
|
|
||||||
|
ASSERT_MAT_NEAR(foreground_gold, foreground, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, MOG, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
testing::Values(std::string("768x576.avi")),
|
||||||
|
testing::Values(UseGray(true), UseGray(false)),
|
||||||
|
testing::Values(LearningRate(0.0), LearningRate(0.01)),
|
||||||
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MOG2
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(MOG2, cv::gpu::DeviceInfo, std::string, UseGray, UseRoi)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
std::string inputFile;
|
||||||
|
bool useGray;
|
||||||
|
bool useRoi;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
|
||||||
|
inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1);
|
||||||
|
|
||||||
|
useGray = GET_PARAM(2);
|
||||||
|
|
||||||
|
useRoi = GET_PARAM(3);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(MOG2, Update)
|
||||||
|
{
|
||||||
|
cv::VideoCapture cap(inputFile);
|
||||||
|
ASSERT_TRUE(cap.isOpened());
|
||||||
|
|
||||||
|
cv::Mat frame;
|
||||||
|
cap >> frame;
|
||||||
|
ASSERT_FALSE(frame.empty());
|
||||||
|
|
||||||
|
cv::gpu::MOG2_GPU mog2;
|
||||||
|
cv::gpu::GpuMat foreground = createMat(frame.size(), CV_8UC1, useRoi);
|
||||||
|
|
||||||
|
cv::BackgroundSubtractorMOG2 mog2_gold;
|
||||||
|
cv::Mat foreground_gold;
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
cap >> frame;
|
||||||
|
ASSERT_FALSE(frame.empty());
|
||||||
|
|
||||||
|
if (useGray)
|
||||||
|
{
|
||||||
|
cv::Mat temp;
|
||||||
|
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
|
||||||
|
cv::swap(temp, frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
mog2(loadMat(frame, useRoi), foreground);
|
||||||
|
|
||||||
|
mog2_gold(frame, foreground_gold);
|
||||||
|
|
||||||
|
double norm = cv::norm(foreground_gold, cv::Mat(foreground), cv::NORM_L1);
|
||||||
|
|
||||||
|
norm /= foreground_gold.size().area();
|
||||||
|
|
||||||
|
ASSERT_LE(norm, 0.09);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GPU_TEST_P(MOG2, getBackgroundImage)
|
||||||
|
{
|
||||||
|
if (useGray)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cv::VideoCapture cap(inputFile);
|
||||||
|
ASSERT_TRUE(cap.isOpened());
|
||||||
|
|
||||||
|
cv::Mat frame;
|
||||||
|
|
||||||
|
cv::gpu::MOG2_GPU mog2;
|
||||||
|
cv::gpu::GpuMat foreground;
|
||||||
|
|
||||||
|
cv::BackgroundSubtractorMOG2 mog2_gold;
|
||||||
|
cv::Mat foreground_gold;
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
cap >> frame;
|
||||||
|
ASSERT_FALSE(frame.empty());
|
||||||
|
|
||||||
|
mog2(loadMat(frame, useRoi), foreground);
|
||||||
|
|
||||||
|
mog2_gold(frame, foreground_gold);
|
||||||
|
}
|
||||||
|
|
||||||
|
cv::gpu::GpuMat background = createMat(frame.size(), frame.type(), useRoi);
|
||||||
|
mog2.getBackgroundImage(background);
|
||||||
|
|
||||||
|
cv::Mat background_gold;
|
||||||
|
mog2_gold.getBackgroundImage(background_gold);
|
||||||
|
|
||||||
|
ASSERT_MAT_NEAR(background_gold, background, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, MOG2, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
testing::Values(std::string("768x576.avi")),
|
||||||
|
testing::Values(UseGray(true), UseGray(false)),
|
||||||
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// VIBE
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(VIBE, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(VIBE, Accuracy)
|
||||||
|
{
|
||||||
|
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
const cv::Size size = GET_PARAM(1);
|
||||||
|
const int type = GET_PARAM(2);
|
||||||
|
const bool useRoi = GET_PARAM(3);
|
||||||
|
|
||||||
|
const cv::Mat fullfg(size, CV_8UC1, cv::Scalar::all(255));
|
||||||
|
|
||||||
|
cv::Mat frame = randomMat(size, type, 0.0, 100);
|
||||||
|
cv::gpu::GpuMat d_frame = loadMat(frame, useRoi);
|
||||||
|
|
||||||
|
cv::gpu::VIBE_GPU vibe;
|
||||||
|
cv::gpu::GpuMat d_fgmask = createMat(size, CV_8UC1, useRoi);
|
||||||
|
vibe.initialize(d_frame);
|
||||||
|
|
||||||
|
for (int i = 0; i < 20; ++i)
|
||||||
|
vibe(d_frame, d_fgmask);
|
||||||
|
|
||||||
|
frame = randomMat(size, type, 160, 255);
|
||||||
|
d_frame = loadMat(frame, useRoi);
|
||||||
|
vibe(d_frame, d_fgmask);
|
||||||
|
|
||||||
|
// now fgmask should be entirely foreground
|
||||||
|
ASSERT_MAT_NEAR(fullfg, d_fgmask, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, VIBE, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
DIFFERENT_SIZES,
|
||||||
|
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4)),
|
||||||
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// GMG
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(GMG, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, UseRoi)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(GMG, Accuracy)
|
||||||
|
{
|
||||||
|
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
const cv::Size size = GET_PARAM(1);
|
||||||
|
const int depth = GET_PARAM(2);
|
||||||
|
const int channels = GET_PARAM(3);
|
||||||
|
const bool useRoi = GET_PARAM(4);
|
||||||
|
|
||||||
|
const int type = CV_MAKE_TYPE(depth, channels);
|
||||||
|
|
||||||
|
const cv::Mat zeros(size, CV_8UC1, cv::Scalar::all(0));
|
||||||
|
const cv::Mat fullfg(size, CV_8UC1, cv::Scalar::all(255));
|
||||||
|
|
||||||
|
cv::Mat frame = randomMat(size, type, 0, 100);
|
||||||
|
cv::gpu::GpuMat d_frame = loadMat(frame, useRoi);
|
||||||
|
|
||||||
|
cv::gpu::GMG_GPU gmg;
|
||||||
|
gmg.numInitializationFrames = 5;
|
||||||
|
gmg.smoothingRadius = 0;
|
||||||
|
gmg.initialize(d_frame.size(), 0, 255);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_fgmask = createMat(size, CV_8UC1, useRoi);
|
||||||
|
|
||||||
|
for (int i = 0; i < gmg.numInitializationFrames; ++i)
|
||||||
|
{
|
||||||
|
gmg(d_frame, d_fgmask);
|
||||||
|
|
||||||
|
// fgmask should be entirely background during training
|
||||||
|
ASSERT_MAT_NEAR(zeros, d_fgmask, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = randomMat(size, type, 160, 255);
|
||||||
|
d_frame = loadMat(frame, useRoi);
|
||||||
|
gmg(d_frame, d_fgmask);
|
||||||
|
|
||||||
|
// now fgmask should be entirely foreground
|
||||||
|
ASSERT_MAT_NEAR(fullfg, d_fgmask, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, GMG, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
DIFFERENT_SIZES,
|
||||||
|
testing::Values(MatType(CV_8U), MatType(CV_16U), MatType(CV_32F)),
|
||||||
|
testing::Values(Channels(1), Channels(3), Channels(4)),
|
||||||
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
|
#endif // HAVE_CUDA
|
@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// StereoBM
|
// StereoBM
|
||||||
|
|
||||||
@ -60,7 +58,7 @@ struct StereoBM : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(StereoBM, Regression)
|
GPU_TEST_P(StereoBM, Regression)
|
||||||
{
|
{
|
||||||
cv::Mat left_image = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
|
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 right_image = readImage("stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
|
||||||
@ -95,7 +93,7 @@ struct StereoBeliefPropagation : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(StereoBeliefPropagation, Regression)
|
GPU_TEST_P(StereoBeliefPropagation, Regression)
|
||||||
{
|
{
|
||||||
cv::Mat left_image = readImage("stereobp/aloe-L.png");
|
cv::Mat left_image = readImage("stereobp/aloe-L.png");
|
||||||
cv::Mat right_image = readImage("stereobp/aloe-R.png");
|
cv::Mat right_image = readImage("stereobp/aloe-R.png");
|
||||||
@ -133,7 +131,7 @@ struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(StereoConstantSpaceBP, Regression)
|
GPU_TEST_P(StereoConstantSpaceBP, Regression)
|
||||||
{
|
{
|
||||||
cv::Mat left_image = readImage("csstereobp/aloe-L.png");
|
cv::Mat left_image = readImage("csstereobp/aloe-L.png");
|
||||||
cv::Mat right_image = readImage("csstereobp/aloe-R.png");
|
cv::Mat right_image = readImage("csstereobp/aloe-R.png");
|
||||||
@ -177,7 +175,7 @@ struct TransformPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(TransformPoints, Accuracy)
|
GPU_TEST_P(TransformPoints, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
|
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 rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||||
@ -225,7 +223,7 @@ struct ProjectPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(ProjectPoints, Accuracy)
|
GPU_TEST_P(ProjectPoints, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
|
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 rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
|
||||||
@ -275,7 +273,7 @@ struct SolvePnPRansac : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(SolvePnPRansac, Accuracy)
|
GPU_TEST_P(SolvePnPRansac, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat object = randomMat(cv::Size(5000, 1), CV_32FC3, 0, 100);
|
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);
|
cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1);
|
||||||
@ -324,7 +322,7 @@ PARAM_TEST_CASE(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth, Use
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(ReprojectImageTo3D, Accuracy)
|
GPU_TEST_P(ReprojectImageTo3D, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat disp = randomMat(size, depth, 5.0, 30.0);
|
cv::Mat disp = randomMat(size, depth, 5.0, 30.0);
|
||||||
cv::Mat Q = randomMat(cv::Size(4, 4), CV_32FC1, 0.1, 1.0);
|
cv::Mat Q = randomMat(cv::Size(4, 4), CV_32FC1, 0.1, 1.0);
|
||||||
@ -344,6 +342,4 @@ INSTANTIATE_TEST_CASE_P(GPU_Calib3D, ReprojectImageTo3D, testing::Combine(
|
|||||||
testing::Values(MatDepth(CV_8U), MatDepth(CV_16S)),
|
testing::Values(MatDepth(CV_8U), MatDepth(CV_16S)),
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cvtColor
|
// cvtColor
|
||||||
|
|
||||||
@ -70,7 +68,7 @@ PARAM_TEST_CASE(CvtColor, cv::gpu::DeviceInfo, cv::Size, MatDepth, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2RGB)
|
GPU_TEST_P(CvtColor, BGR2RGB)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -83,7 +81,7 @@ TEST_P(CvtColor, BGR2RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2RGBA)
|
GPU_TEST_P(CvtColor, BGR2RGBA)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -96,7 +94,7 @@ TEST_P(CvtColor, BGR2RGBA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2BGRA)
|
GPU_TEST_P(CvtColor, BGR2BGRA)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -109,7 +107,7 @@ TEST_P(CvtColor, BGR2BGRA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGRA2RGB)
|
GPU_TEST_P(CvtColor, BGRA2RGB)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
||||||
@ -123,7 +121,7 @@ TEST_P(CvtColor, BGRA2RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGRA2BGR)
|
GPU_TEST_P(CvtColor, BGRA2BGR)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
||||||
@ -137,7 +135,7 @@ TEST_P(CvtColor, BGRA2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGRA2RGBA)
|
GPU_TEST_P(CvtColor, BGRA2RGBA)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
||||||
@ -151,7 +149,7 @@ TEST_P(CvtColor, BGRA2RGBA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2GRAY)
|
GPU_TEST_P(CvtColor, BGR2GRAY)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -164,7 +162,7 @@ TEST_P(CvtColor, BGR2GRAY)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2GRAY)
|
GPU_TEST_P(CvtColor, RGB2GRAY)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -177,7 +175,7 @@ TEST_P(CvtColor, RGB2GRAY)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, GRAY2BGR)
|
GPU_TEST_P(CvtColor, GRAY2BGR)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
||||||
@ -191,7 +189,7 @@ TEST_P(CvtColor, GRAY2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, GRAY2BGRA)
|
GPU_TEST_P(CvtColor, GRAY2BGRA)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
|
||||||
@ -205,7 +203,7 @@ TEST_P(CvtColor, GRAY2BGRA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGRA2GRAY)
|
GPU_TEST_P(CvtColor, BGRA2GRAY)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
||||||
@ -219,7 +217,7 @@ TEST_P(CvtColor, BGRA2GRAY)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2GRAY)
|
GPU_TEST_P(CvtColor, RGBA2GRAY)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
||||||
@ -233,7 +231,7 @@ TEST_P(CvtColor, RGBA2GRAY)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2BGR565)
|
GPU_TEST_P(CvtColor, BGR2BGR565)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -249,7 +247,7 @@ TEST_P(CvtColor, BGR2BGR565)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2BGR565)
|
GPU_TEST_P(CvtColor, RGB2BGR565)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -265,7 +263,7 @@ TEST_P(CvtColor, RGB2BGR565)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5652BGR)
|
GPU_TEST_P(CvtColor, BGR5652BGR)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -282,7 +280,7 @@ TEST_P(CvtColor, BGR5652BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5652RGB)
|
GPU_TEST_P(CvtColor, BGR5652RGB)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -299,7 +297,7 @@ TEST_P(CvtColor, BGR5652RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGRA2BGR565)
|
GPU_TEST_P(CvtColor, BGRA2BGR565)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -316,7 +314,7 @@ TEST_P(CvtColor, BGRA2BGR565)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2BGR565)
|
GPU_TEST_P(CvtColor, RGBA2BGR565)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -333,7 +331,7 @@ TEST_P(CvtColor, RGBA2BGR565)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5652BGRA)
|
GPU_TEST_P(CvtColor, BGR5652BGRA)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -350,7 +348,7 @@ TEST_P(CvtColor, BGR5652BGRA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5652RGBA)
|
GPU_TEST_P(CvtColor, BGR5652RGBA)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -367,7 +365,7 @@ TEST_P(CvtColor, BGR5652RGBA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, GRAY2BGR565)
|
GPU_TEST_P(CvtColor, GRAY2BGR565)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -384,7 +382,7 @@ TEST_P(CvtColor, GRAY2BGR565)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5652GRAY)
|
GPU_TEST_P(CvtColor, BGR5652GRAY)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -401,7 +399,7 @@ TEST_P(CvtColor, BGR5652GRAY)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2BGR555)
|
GPU_TEST_P(CvtColor, BGR2BGR555)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -417,7 +415,7 @@ TEST_P(CvtColor, BGR2BGR555)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2BGR555)
|
GPU_TEST_P(CvtColor, RGB2BGR555)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -433,7 +431,7 @@ TEST_P(CvtColor, RGB2BGR555)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5552BGR)
|
GPU_TEST_P(CvtColor, BGR5552BGR)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -450,7 +448,7 @@ TEST_P(CvtColor, BGR5552BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5552RGB)
|
GPU_TEST_P(CvtColor, BGR5552RGB)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -467,7 +465,7 @@ TEST_P(CvtColor, BGR5552RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGRA2BGR555)
|
GPU_TEST_P(CvtColor, BGRA2BGR555)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -484,7 +482,7 @@ TEST_P(CvtColor, BGRA2BGR555)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2BGR555)
|
GPU_TEST_P(CvtColor, RGBA2BGR555)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -501,7 +499,7 @@ TEST_P(CvtColor, RGBA2BGR555)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5552BGRA)
|
GPU_TEST_P(CvtColor, BGR5552BGRA)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -518,7 +516,7 @@ TEST_P(CvtColor, BGR5552BGRA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5552RGBA)
|
GPU_TEST_P(CvtColor, BGR5552RGBA)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -535,7 +533,7 @@ TEST_P(CvtColor, BGR5552RGBA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, GRAY2BGR555)
|
GPU_TEST_P(CvtColor, GRAY2BGR555)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -552,7 +550,7 @@ TEST_P(CvtColor, GRAY2BGR555)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR5552GRAY)
|
GPU_TEST_P(CvtColor, BGR5552GRAY)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
@ -569,7 +567,7 @@ TEST_P(CvtColor, BGR5552GRAY)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2XYZ)
|
GPU_TEST_P(CvtColor, BGR2XYZ)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -582,7 +580,7 @@ TEST_P(CvtColor, BGR2XYZ)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2XYZ)
|
GPU_TEST_P(CvtColor, RGB2XYZ)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -595,7 +593,7 @@ TEST_P(CvtColor, RGB2XYZ)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2XYZ4)
|
GPU_TEST_P(CvtColor, BGR2XYZ4)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -616,7 +614,7 @@ TEST_P(CvtColor, BGR2XYZ4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGRA2XYZ4)
|
GPU_TEST_P(CvtColor, BGRA2XYZ4)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
|
||||||
@ -638,7 +636,7 @@ TEST_P(CvtColor, BGRA2XYZ4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, XYZ2BGR)
|
GPU_TEST_P(CvtColor, XYZ2BGR)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
||||||
@ -652,7 +650,7 @@ TEST_P(CvtColor, XYZ2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, XYZ2RGB)
|
GPU_TEST_P(CvtColor, XYZ2RGB)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
||||||
@ -666,7 +664,7 @@ TEST_P(CvtColor, XYZ2RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, XYZ42BGR)
|
GPU_TEST_P(CvtColor, XYZ42BGR)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
||||||
@ -685,7 +683,7 @@ TEST_P(CvtColor, XYZ42BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, XYZ42BGRA)
|
GPU_TEST_P(CvtColor, XYZ42BGRA)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
|
||||||
@ -704,7 +702,7 @@ TEST_P(CvtColor, XYZ42BGRA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2YCrCb)
|
GPU_TEST_P(CvtColor, BGR2YCrCb)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -717,7 +715,7 @@ TEST_P(CvtColor, BGR2YCrCb)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2YCrCb)
|
GPU_TEST_P(CvtColor, RGB2YCrCb)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -730,7 +728,7 @@ TEST_P(CvtColor, RGB2YCrCb)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2YCrCb4)
|
GPU_TEST_P(CvtColor, BGR2YCrCb4)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -751,7 +749,7 @@ TEST_P(CvtColor, BGR2YCrCb4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2YCrCb4)
|
GPU_TEST_P(CvtColor, RGBA2YCrCb4)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
||||||
@ -773,7 +771,7 @@ TEST_P(CvtColor, RGBA2YCrCb4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YCrCb2BGR)
|
GPU_TEST_P(CvtColor, YCrCb2BGR)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
||||||
@ -787,7 +785,7 @@ TEST_P(CvtColor, YCrCb2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YCrCb2RGB)
|
GPU_TEST_P(CvtColor, YCrCb2RGB)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
||||||
@ -801,7 +799,7 @@ TEST_P(CvtColor, YCrCb2RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YCrCb42RGB)
|
GPU_TEST_P(CvtColor, YCrCb42RGB)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
||||||
@ -820,7 +818,7 @@ TEST_P(CvtColor, YCrCb42RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YCrCb42RGBA)
|
GPU_TEST_P(CvtColor, YCrCb42RGBA)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
|
||||||
@ -839,7 +837,7 @@ TEST_P(CvtColor, YCrCb42RGBA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2HSV)
|
GPU_TEST_P(CvtColor, BGR2HSV)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -855,7 +853,7 @@ TEST_P(CvtColor, BGR2HSV)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HSV)
|
GPU_TEST_P(CvtColor, RGB2HSV)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -871,7 +869,7 @@ TEST_P(CvtColor, RGB2HSV)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HSV4)
|
GPU_TEST_P(CvtColor, RGB2HSV4)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -895,7 +893,7 @@ TEST_P(CvtColor, RGB2HSV4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2HSV4)
|
GPU_TEST_P(CvtColor, RGBA2HSV4)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -920,7 +918,7 @@ TEST_P(CvtColor, RGBA2HSV4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2HLS)
|
GPU_TEST_P(CvtColor, BGR2HLS)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -936,7 +934,7 @@ TEST_P(CvtColor, BGR2HLS)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HLS)
|
GPU_TEST_P(CvtColor, RGB2HLS)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -952,7 +950,7 @@ TEST_P(CvtColor, RGB2HLS)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HLS4)
|
GPU_TEST_P(CvtColor, RGB2HLS4)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -976,7 +974,7 @@ TEST_P(CvtColor, RGB2HLS4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2HLS4)
|
GPU_TEST_P(CvtColor, RGBA2HLS4)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1001,7 +999,7 @@ TEST_P(CvtColor, RGBA2HLS4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV2BGR)
|
GPU_TEST_P(CvtColor, HSV2BGR)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1018,7 +1016,7 @@ TEST_P(CvtColor, HSV2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV2RGB)
|
GPU_TEST_P(CvtColor, HSV2RGB)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1035,7 +1033,7 @@ TEST_P(CvtColor, HSV2RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV42BGR)
|
GPU_TEST_P(CvtColor, HSV42BGR)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1057,7 +1055,7 @@ TEST_P(CvtColor, HSV42BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV42BGRA)
|
GPU_TEST_P(CvtColor, HSV42BGRA)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1079,7 +1077,7 @@ TEST_P(CvtColor, HSV42BGRA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS2BGR)
|
GPU_TEST_P(CvtColor, HLS2BGR)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1096,7 +1094,7 @@ TEST_P(CvtColor, HLS2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS2RGB)
|
GPU_TEST_P(CvtColor, HLS2RGB)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1113,7 +1111,7 @@ TEST_P(CvtColor, HLS2RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS42RGB)
|
GPU_TEST_P(CvtColor, HLS42RGB)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1135,7 +1133,7 @@ TEST_P(CvtColor, HLS42RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS42RGBA)
|
GPU_TEST_P(CvtColor, HLS42RGBA)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1158,7 +1156,7 @@ TEST_P(CvtColor, HLS42RGBA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2HSV_FULL)
|
GPU_TEST_P(CvtColor, BGR2HSV_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1174,7 +1172,7 @@ TEST_P(CvtColor, BGR2HSV_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HSV_FULL)
|
GPU_TEST_P(CvtColor, RGB2HSV_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1190,7 +1188,7 @@ TEST_P(CvtColor, RGB2HSV_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HSV4_FULL)
|
GPU_TEST_P(CvtColor, RGB2HSV4_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1214,7 +1212,7 @@ TEST_P(CvtColor, RGB2HSV4_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2HSV4_FULL)
|
GPU_TEST_P(CvtColor, RGBA2HSV4_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1239,7 +1237,7 @@ TEST_P(CvtColor, RGBA2HSV4_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2HLS_FULL)
|
GPU_TEST_P(CvtColor, BGR2HLS_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1255,7 +1253,7 @@ TEST_P(CvtColor, BGR2HLS_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HLS_FULL)
|
GPU_TEST_P(CvtColor, RGB2HLS_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1271,7 +1269,7 @@ TEST_P(CvtColor, RGB2HLS_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2HLS4_FULL)
|
GPU_TEST_P(CvtColor, RGB2HLS4_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1295,7 +1293,7 @@ TEST_P(CvtColor, RGB2HLS4_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2HLS4_FULL)
|
GPU_TEST_P(CvtColor, RGBA2HLS4_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1320,7 +1318,7 @@ TEST_P(CvtColor, RGBA2HLS4_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV2BGR_FULL)
|
GPU_TEST_P(CvtColor, HSV2BGR_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1337,7 +1335,7 @@ TEST_P(CvtColor, HSV2BGR_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV2RGB_FULL)
|
GPU_TEST_P(CvtColor, HSV2RGB_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1354,7 +1352,7 @@ TEST_P(CvtColor, HSV2RGB_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV42RGB_FULL)
|
GPU_TEST_P(CvtColor, HSV42RGB_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1376,7 +1374,7 @@ TEST_P(CvtColor, HSV42RGB_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HSV42RGBA_FULL)
|
GPU_TEST_P(CvtColor, HSV42RGBA_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1398,7 +1396,7 @@ TEST_P(CvtColor, HSV42RGBA_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS2BGR_FULL)
|
GPU_TEST_P(CvtColor, HLS2BGR_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1415,7 +1413,7 @@ TEST_P(CvtColor, HLS2BGR_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS2RGB_FULL)
|
GPU_TEST_P(CvtColor, HLS2RGB_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1432,7 +1430,7 @@ TEST_P(CvtColor, HLS2RGB_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS42RGB_FULL)
|
GPU_TEST_P(CvtColor, HLS42RGB_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1454,7 +1452,7 @@ TEST_P(CvtColor, HLS42RGB_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, HLS42RGBA_FULL)
|
GPU_TEST_P(CvtColor, HLS42RGBA_FULL)
|
||||||
{
|
{
|
||||||
if (depth == CV_16U)
|
if (depth == CV_16U)
|
||||||
return;
|
return;
|
||||||
@ -1476,7 +1474,7 @@ TEST_P(CvtColor, HLS42RGBA_FULL)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2YUV)
|
GPU_TEST_P(CvtColor, BGR2YUV)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -1489,7 +1487,7 @@ TEST_P(CvtColor, BGR2YUV)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2YUV)
|
GPU_TEST_P(CvtColor, RGB2YUV)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -1502,7 +1500,7 @@ TEST_P(CvtColor, RGB2YUV)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YUV2BGR)
|
GPU_TEST_P(CvtColor, YUV2BGR)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
||||||
@ -1516,7 +1514,7 @@ TEST_P(CvtColor, YUV2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YUV42BGR)
|
GPU_TEST_P(CvtColor, YUV42BGR)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
||||||
@ -1535,7 +1533,7 @@ TEST_P(CvtColor, YUV42BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YUV42BGRA)
|
GPU_TEST_P(CvtColor, YUV42BGRA)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
|
||||||
@ -1554,7 +1552,7 @@ TEST_P(CvtColor, YUV42BGRA)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, YUV2RGB)
|
GPU_TEST_P(CvtColor, YUV2RGB)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_RGB2YUV);
|
cv::cvtColor(img, src, cv::COLOR_RGB2YUV);
|
||||||
@ -1568,7 +1566,7 @@ TEST_P(CvtColor, YUV2RGB)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2YUV4)
|
GPU_TEST_P(CvtColor, BGR2YUV4)
|
||||||
{
|
{
|
||||||
cv::Mat src = img;
|
cv::Mat src = img;
|
||||||
|
|
||||||
@ -1589,7 +1587,7 @@ TEST_P(CvtColor, BGR2YUV4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2YUV4)
|
GPU_TEST_P(CvtColor, RGBA2YUV4)
|
||||||
{
|
{
|
||||||
cv::Mat src;
|
cv::Mat src;
|
||||||
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
|
||||||
@ -1611,147 +1609,91 @@ TEST_P(CvtColor, RGBA2YUV4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
EXPECT_MAT_NEAR(dst_gold, h_dst, 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2Lab)
|
#if defined (CUDA_VERSION) && (CUDA_VERSION >= 5000)
|
||||||
|
|
||||||
|
GPU_TEST_P(CvtColor, BGR2Lab)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
cv::Mat src = readImage("stereobm/aloe-L.png");
|
||||||
{
|
|
||||||
cv::Mat src = readImage("stereobm/aloe-L.png");
|
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_lab = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_lab = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(loadMat(src, useRoi), dst_lab, cv::COLOR_BGR2Lab);
|
cv::gpu::cvtColor(loadMat(src, useRoi), dst_lab, cv::COLOR_BGR2Lab);
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_bgr = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_bgr = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(dst_lab, dst_bgr, cv::COLOR_Lab2BGR);
|
cv::gpu::cvtColor(dst_lab, dst_bgr, cv::COLOR_Lab2BGR);
|
||||||
|
|
||||||
EXPECT_MAT_NEAR(src, dst_bgr, 10);
|
EXPECT_MAT_NEAR(src, dst_bgr, 10);
|
||||||
}
|
|
||||||
catch (const cv::Exception& e)
|
|
||||||
{
|
|
||||||
(void)e;
|
|
||||||
#if defined (CUDA_VERSION) && (CUDA_VERSION < 5000)
|
|
||||||
ASSERT_EQ(CV_StsBadFlag, e.code);
|
|
||||||
#else
|
|
||||||
FAIL();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2Lab)
|
GPU_TEST_P(CvtColor, RGB2Lab)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
cv::Mat src = readImage("stereobm/aloe-L.png");
|
||||||
{
|
|
||||||
cv::Mat src = readImage("stereobm/aloe-L.png");
|
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_lab = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_lab = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(loadMat(src, useRoi), dst_lab, cv::COLOR_RGB2Lab);
|
cv::gpu::cvtColor(loadMat(src, useRoi), dst_lab, cv::COLOR_RGB2Lab);
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_bgr = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_bgr = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(dst_lab, dst_bgr, cv::COLOR_Lab2RGB);
|
cv::gpu::cvtColor(dst_lab, dst_bgr, cv::COLOR_Lab2RGB);
|
||||||
|
|
||||||
EXPECT_MAT_NEAR(src, dst_bgr, 10);
|
EXPECT_MAT_NEAR(src, dst_bgr, 10);
|
||||||
}
|
|
||||||
catch (const cv::Exception& e)
|
|
||||||
{
|
|
||||||
(void)e;
|
|
||||||
#if defined (CUDA_VERSION) && (CUDA_VERSION < 5000)
|
|
||||||
ASSERT_EQ(CV_StsBadFlag, e.code);
|
|
||||||
#else
|
|
||||||
FAIL();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BGR2Luv)
|
GPU_TEST_P(CvtColor, BGR2Luv)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
cv::Mat src = img;
|
||||||
{
|
|
||||||
cv::Mat src = img;
|
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_luv = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_luv = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(loadMat(src, useRoi), dst_luv, cv::COLOR_BGR2Luv);
|
cv::gpu::cvtColor(loadMat(src, useRoi), dst_luv, cv::COLOR_BGR2Luv);
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_rgb = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_rgb = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(dst_luv, dst_rgb, cv::COLOR_Luv2BGR);
|
cv::gpu::cvtColor(dst_luv, dst_rgb, cv::COLOR_Luv2BGR);
|
||||||
|
|
||||||
EXPECT_MAT_NEAR(src, dst_rgb, 10);
|
EXPECT_MAT_NEAR(src, dst_rgb, 10);
|
||||||
}
|
|
||||||
catch (const cv::Exception& e)
|
|
||||||
{
|
|
||||||
(void)e;
|
|
||||||
#if defined (CUDA_VERSION) && (CUDA_VERSION < 5000)
|
|
||||||
ASSERT_EQ(CV_StsBadFlag, e.code);
|
|
||||||
#else
|
|
||||||
FAIL();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGB2Luv)
|
GPU_TEST_P(CvtColor, RGB2Luv)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
cv::Mat src = img;
|
||||||
{
|
|
||||||
cv::Mat src = img;
|
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_luv = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_luv = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(loadMat(src, useRoi), dst_luv, cv::COLOR_RGB2Luv);
|
cv::gpu::cvtColor(loadMat(src, useRoi), dst_luv, cv::COLOR_RGB2Luv);
|
||||||
|
|
||||||
cv::gpu::GpuMat dst_rgb = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst_rgb = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(dst_luv, dst_rgb, cv::COLOR_Luv2RGB);
|
cv::gpu::cvtColor(dst_luv, dst_rgb, cv::COLOR_Luv2RGB);
|
||||||
|
|
||||||
EXPECT_MAT_NEAR(src, dst_rgb, 10);
|
EXPECT_MAT_NEAR(src, dst_rgb, 10);
|
||||||
}
|
|
||||||
catch (const cv::Exception& e)
|
|
||||||
{
|
|
||||||
(void)e;
|
|
||||||
#if defined (CUDA_VERSION) && (CUDA_VERSION < 5000)
|
|
||||||
ASSERT_EQ(CV_StsBadFlag, e.code);
|
|
||||||
#else
|
|
||||||
FAIL();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, RGBA2mRGBA)
|
GPU_TEST_P(CvtColor, RGBA2mRGBA)
|
||||||
{
|
{
|
||||||
if (depth != CV_8U)
|
if (depth != CV_8U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
cv::Mat src = randomMat(size, CV_MAKE_TYPE(depth, 4));
|
||||||
{
|
|
||||||
cv::Mat src = randomMat(size, CV_MAKE_TYPE(depth, 4));
|
|
||||||
|
|
||||||
cv::gpu::GpuMat dst = createMat(src.size(), src.type(), useRoi);
|
cv::gpu::GpuMat dst = createMat(src.size(), src.type(), useRoi);
|
||||||
cv::gpu::cvtColor(loadMat(src, useRoi), dst, cv::COLOR_RGBA2mRGBA);
|
cv::gpu::cvtColor(loadMat(src, useRoi), dst, cv::COLOR_RGBA2mRGBA);
|
||||||
|
|
||||||
cv::Mat dst_gold;
|
cv::Mat dst_gold;
|
||||||
cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2mRGBA);
|
cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2mRGBA);
|
||||||
|
|
||||||
EXPECT_MAT_NEAR(dst_gold, dst, 1);
|
EXPECT_MAT_NEAR(dst_gold, dst, 1);
|
||||||
}
|
|
||||||
catch (const cv::Exception& e)
|
|
||||||
{
|
|
||||||
(void)e;
|
|
||||||
#if defined (CUDA_VERSION) && (CUDA_VERSION < 5000)
|
|
||||||
ASSERT_EQ(CV_StsBadFlag, e.code);
|
|
||||||
#else
|
|
||||||
FAIL();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerBG2BGR)
|
#endif // defined (CUDA_VERSION) && (CUDA_VERSION >= 5000)
|
||||||
|
|
||||||
|
GPU_TEST_P(CvtColor, BayerBG2BGR)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1767,7 +1709,7 @@ TEST_P(CvtColor, BayerBG2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerBG2BGR4)
|
GPU_TEST_P(CvtColor, BayerBG2BGR4)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1790,7 +1732,7 @@ TEST_P(CvtColor, BayerBG2BGR4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst3(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst3(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerGB2BGR)
|
GPU_TEST_P(CvtColor, BayerGB2BGR)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1806,7 +1748,7 @@ TEST_P(CvtColor, BayerGB2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerGB2BGR4)
|
GPU_TEST_P(CvtColor, BayerGB2BGR4)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1828,7 +1770,7 @@ TEST_P(CvtColor, BayerGB2BGR4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst3(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst3(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerRG2BGR)
|
GPU_TEST_P(CvtColor, BayerRG2BGR)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1844,7 +1786,7 @@ TEST_P(CvtColor, BayerRG2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerRG2BGR4)
|
GPU_TEST_P(CvtColor, BayerRG2BGR4)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1866,7 +1808,7 @@ TEST_P(CvtColor, BayerRG2BGR4)
|
|||||||
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst3(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst3(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerGR2BGR)
|
GPU_TEST_P(CvtColor, BayerGR2BGR)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1882,7 +1824,7 @@ TEST_P(CvtColor, BayerGR2BGR)
|
|||||||
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
EXPECT_MAT_NEAR(dst_gold(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), dst(cv::Rect(1, 1, dst.cols - 2, dst.rows - 2)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CvtColor, BayerGR2BGR4)
|
GPU_TEST_P(CvtColor, BayerGR2BGR4)
|
||||||
{
|
{
|
||||||
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
if ((depth != CV_8U && depth != CV_16U) || useRoi)
|
||||||
return;
|
return;
|
||||||
@ -1929,7 +1871,7 @@ PARAM_TEST_CASE(SwapChannels, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(SwapChannels, Accuracy)
|
GPU_TEST_P(SwapChannels, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = readImageType("stereobm/aloe-L.png", CV_8UC4);
|
cv::Mat src = readImageType("stereobm/aloe-L.png", CV_8UC4);
|
||||||
ASSERT_FALSE(src.empty());
|
ASSERT_FALSE(src.empty());
|
||||||
@ -1950,6 +1892,4 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, SwapChannels, testing::Combine(
|
|||||||
DIFFERENT_SIZES,
|
DIFFERENT_SIZES,
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -43,9 +43,10 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
IMPLEMENT_PARAM_CLASS(Border, int)
|
IMPLEMENT_PARAM_CLASS(Border, int)
|
||||||
|
}
|
||||||
|
|
||||||
PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, Border, BorderType, UseRoi)
|
PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, Border, BorderType, UseRoi)
|
||||||
{
|
{
|
||||||
@ -69,7 +70,7 @@ PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, Border,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CopyMakeBorder, Accuracy)
|
GPU_TEST_P(CopyMakeBorder, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Scalar val = randomScalar(0, 255);
|
cv::Scalar val = randomScalar(0, 255);
|
||||||
@ -99,6 +100,4 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine(
|
|||||||
ALL_BORDER_TYPES,
|
ALL_BORDER_TYPES,
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -69,7 +69,7 @@ PARAM_TEST_CASE(BilateralFilter, cv::gpu::DeviceInfo, cv::Size, MatType)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(BilateralFilter, Accuracy)
|
GPU_TEST_P(BilateralFilter, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ struct BruteForceNonLocalMeans: testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(BruteForceNonLocalMeans, Regression)
|
GPU_TEST_P(BruteForceNonLocalMeans, Regression)
|
||||||
{
|
{
|
||||||
using cv::gpu::GpuMat;
|
using cv::gpu::GpuMat;
|
||||||
|
|
||||||
@ -134,8 +134,6 @@ TEST_P(BruteForceNonLocalMeans, Regression)
|
|||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(GPU_Denoising, BruteForceNonLocalMeans, ALL_DEVICES);
|
INSTANTIATE_TEST_CASE_P(GPU_Denoising, BruteForceNonLocalMeans, ALL_DEVICES);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// Fast Force Non local means
|
// Fast Force Non local means
|
||||||
|
|
||||||
@ -150,7 +148,7 @@ struct FastNonLocalMeans: testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(FastNonLocalMeans, Regression)
|
GPU_TEST_P(FastNonLocalMeans, Regression)
|
||||||
{
|
{
|
||||||
using cv::gpu::GpuMat;
|
using cv::gpu::GpuMat;
|
||||||
|
|
||||||
@ -167,8 +165,8 @@ TEST_P(FastNonLocalMeans, Regression)
|
|||||||
fnlmd.labMethod(GpuMat(bgr), dbgr, 20, 10);
|
fnlmd.labMethod(GpuMat(bgr), dbgr, 20, 10);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//dumpImage("denoising/fnlm_denoised_lena_bgr.png", cv::Mat(dbgr));
|
dumpImage("denoising/fnlm_denoised_lena_bgr.png", cv::Mat(dbgr));
|
||||||
//dumpImage("denoising/fnlm_denoised_lena_gray.png", cv::Mat(dgray));
|
dumpImage("denoising/fnlm_denoised_lena_gray.png", cv::Mat(dgray));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cv::Mat bgr_gold = readImage("denoising/fnlm_denoised_lena_bgr.png", cv::IMREAD_COLOR);
|
cv::Mat bgr_gold = readImage("denoising/fnlm_denoised_lena_bgr.png", cv::IMREAD_COLOR);
|
||||||
@ -181,5 +179,4 @@ TEST_P(FastNonLocalMeans, Regression)
|
|||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(GPU_Denoising, FastNonLocalMeans, ALL_DEVICES);
|
INSTANTIATE_TEST_CASE_P(GPU_Denoising, FastNonLocalMeans, ALL_DEVICES);
|
||||||
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -43,118 +43,122 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
|
||||||
bool keyPointsEquals(const cv::KeyPoint& p1, const cv::KeyPoint& p2)
|
|
||||||
{
|
{
|
||||||
const double maxPtDif = 1.0;
|
bool keyPointsEquals(const cv::KeyPoint& p1, const cv::KeyPoint& p2)
|
||||||
const double maxSizeDif = 1.0;
|
|
||||||
const double maxAngleDif = 2.0;
|
|
||||||
const double maxResponseDif = 0.1;
|
|
||||||
|
|
||||||
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;
|
const double maxPtDif = 1.0;
|
||||||
}
|
const double maxSizeDif = 1.0;
|
||||||
|
const double maxAngleDif = 2.0;
|
||||||
|
const double maxResponseDif = 0.1;
|
||||||
|
|
||||||
return false;
|
double dist = cv::norm(p1.pt - p2.pt);
|
||||||
}
|
|
||||||
|
|
||||||
struct KeyPointLess : std::binary_function<cv::KeyPoint, cv::KeyPoint, bool>
|
if (dist < maxPtDif &&
|
||||||
{
|
fabs(p1.size - p2.size) < maxSizeDif &&
|
||||||
bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
abs(p1.angle - p2.angle) < maxAngleDif &&
|
||||||
{
|
abs(p1.response - p2.response) < maxResponseDif &&
|
||||||
return kp1.pt.y < kp2.pt.y || (kp1.pt.y == kp2.pt.y && kp1.pt.x < kp2.pt.x);
|
p1.octave == p2.octave &&
|
||||||
}
|
p1.class_id == p2.class_id)
|
||||||
};
|
|
||||||
|
|
||||||
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 = 0; 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"
|
return true;
|
||||||
<< "\"" << 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 false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ::testing::AssertionSuccess();
|
struct KeyPointLess : std::binary_function<cv::KeyPoint, cv::KeyPoint, bool>
|
||||||
}
|
|
||||||
|
|
||||||
#define ASSERT_KEYPOINTS_EQ(gold, actual) EXPECT_PRED_FORMAT2(assertKeyPointsEquals, gold, actual);
|
|
||||||
|
|
||||||
int getMatchedPointsCount(std::vector<cv::KeyPoint>& gold, std::vector<cv::KeyPoint>& actual)
|
|
||||||
{
|
|
||||||
std::sort(actual.begin(), actual.end(), KeyPointLess());
|
|
||||||
std::sort(gold.begin(), gold.end(), KeyPointLess());
|
|
||||||
|
|
||||||
int validCount = 0;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < gold.size(); ++i)
|
|
||||||
{
|
{
|
||||||
const cv::KeyPoint& p1 = gold[i];
|
bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
||||||
const cv::KeyPoint& p2 = actual[i];
|
{
|
||||||
|
return kp1.pt.y < kp2.pt.y || (kp1.pt.y == kp2.pt.y && kp1.pt.x < kp2.pt.x);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (keyPointsEquals(p1, p2))
|
testing::AssertionResult assertKeyPointsEquals(const char* gold_expr, const char* actual_expr, std::vector<cv::KeyPoint>& gold, std::vector<cv::KeyPoint>& actual)
|
||||||
++validCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
return validCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getMatchedPointsCount(const std::vector<cv::KeyPoint>& keypoints1, const std::vector<cv::KeyPoint>& keypoints2, const std::vector<cv::DMatch>& matches)
|
|
||||||
{
|
|
||||||
int validCount = 0;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < matches.size(); ++i)
|
|
||||||
{
|
{
|
||||||
const cv::DMatch& m = matches[i];
|
if (gold.size() != actual.size())
|
||||||
|
{
|
||||||
|
return testing::AssertionFailure() << "KeyPoints size mistmach\n"
|
||||||
|
<< "\"" << gold_expr << "\" : " << gold.size() << "\n"
|
||||||
|
<< "\"" << actual_expr << "\" : " << actual.size();
|
||||||
|
}
|
||||||
|
|
||||||
const cv::KeyPoint& p1 = keypoints1[m.queryIdx];
|
std::sort(actual.begin(), actual.end(), KeyPointLess());
|
||||||
const cv::KeyPoint& p2 = keypoints2[m.trainIdx];
|
std::sort(gold.begin(), gold.end(), KeyPointLess());
|
||||||
|
|
||||||
if (keyPointsEquals(p1, p2))
|
for (size_t i = 0; i < gold.size(); ++i)
|
||||||
++validCount;
|
{
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return validCount;
|
#define ASSERT_KEYPOINTS_EQ(gold, actual) EXPECT_PRED_FORMAT2(assertKeyPointsEquals, gold, actual);
|
||||||
|
|
||||||
|
int getMatchedPointsCount(std::vector<cv::KeyPoint>& gold, std::vector<cv::KeyPoint>& actual)
|
||||||
|
{
|
||||||
|
std::sort(actual.begin(), actual.end(), KeyPointLess());
|
||||||
|
std::sort(gold.begin(), gold.end(), KeyPointLess());
|
||||||
|
|
||||||
|
int validCount = 0;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < gold.size(); ++i)
|
||||||
|
{
|
||||||
|
const cv::KeyPoint& p1 = gold[i];
|
||||||
|
const cv::KeyPoint& p2 = actual[i];
|
||||||
|
|
||||||
|
if (keyPointsEquals(p1, p2))
|
||||||
|
++validCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return validCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getMatchedPointsCount(const std::vector<cv::KeyPoint>& keypoints1, const std::vector<cv::KeyPoint>& keypoints2, const std::vector<cv::DMatch>& matches)
|
||||||
|
{
|
||||||
|
int validCount = 0;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < matches.size(); ++i)
|
||||||
|
{
|
||||||
|
const cv::DMatch& m = matches[i];
|
||||||
|
|
||||||
|
const cv::KeyPoint& p1 = keypoints1[m.queryIdx];
|
||||||
|
const cv::KeyPoint& p2 = keypoints2[m.trainIdx];
|
||||||
|
|
||||||
|
if (keyPointsEquals(p1, p2))
|
||||||
|
++validCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return validCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// SURF
|
// SURF
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(SURF_HessianThreshold, double)
|
namespace
|
||||||
IMPLEMENT_PARAM_CLASS(SURF_Octaves, int)
|
{
|
||||||
IMPLEMENT_PARAM_CLASS(SURF_OctaveLayers, int)
|
IMPLEMENT_PARAM_CLASS(SURF_HessianThreshold, double)
|
||||||
IMPLEMENT_PARAM_CLASS(SURF_Extended, bool)
|
IMPLEMENT_PARAM_CLASS(SURF_Octaves, int)
|
||||||
IMPLEMENT_PARAM_CLASS(SURF_Upright, bool)
|
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)
|
PARAM_TEST_CASE(SURF, cv::gpu::DeviceInfo, SURF_HessianThreshold, SURF_Octaves, SURF_OctaveLayers, SURF_Extended, SURF_Upright)
|
||||||
{
|
{
|
||||||
@ -178,7 +182,7 @@ PARAM_TEST_CASE(SURF, cv::gpu::DeviceInfo, SURF_HessianThreshold, SURF_Octaves,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(SURF, Detector)
|
GPU_TEST_P(SURF, Detector)
|
||||||
{
|
{
|
||||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||||
ASSERT_FALSE(image.empty());
|
ASSERT_FALSE(image.empty());
|
||||||
@ -226,7 +230,7 @@ TEST_P(SURF, Detector)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SURF, Detector_Masked)
|
GPU_TEST_P(SURF, Detector_Masked)
|
||||||
{
|
{
|
||||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||||
ASSERT_FALSE(image.empty());
|
ASSERT_FALSE(image.empty());
|
||||||
@ -277,7 +281,7 @@ TEST_P(SURF, Detector_Masked)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SURF, Descriptor)
|
GPU_TEST_P(SURF, Descriptor)
|
||||||
{
|
{
|
||||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||||
ASSERT_FALSE(image.empty());
|
ASSERT_FALSE(image.empty());
|
||||||
@ -343,8 +347,11 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, SURF, testing::Combine(
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FAST
|
// FAST
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(FAST_Threshold, int)
|
namespace
|
||||||
IMPLEMENT_PARAM_CLASS(FAST_NonmaxSupression, bool)
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(FAST_Threshold, int)
|
||||||
|
IMPLEMENT_PARAM_CLASS(FAST_NonmaxSupression, bool)
|
||||||
|
}
|
||||||
|
|
||||||
PARAM_TEST_CASE(FAST, cv::gpu::DeviceInfo, FAST_Threshold, FAST_NonmaxSupression)
|
PARAM_TEST_CASE(FAST, cv::gpu::DeviceInfo, FAST_Threshold, FAST_NonmaxSupression)
|
||||||
{
|
{
|
||||||
@ -362,7 +369,7 @@ PARAM_TEST_CASE(FAST, cv::gpu::DeviceInfo, FAST_Threshold, FAST_NonmaxSupression
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(FAST, Accuracy)
|
GPU_TEST_P(FAST, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||||
ASSERT_FALSE(image.empty());
|
ASSERT_FALSE(image.empty());
|
||||||
@ -402,14 +409,17 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, FAST, testing::Combine(
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// ORB
|
// ORB
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_FeaturesCount, int)
|
namespace
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_ScaleFactor, float)
|
{
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_LevelsCount, int)
|
IMPLEMENT_PARAM_CLASS(ORB_FeaturesCount, int)
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_EdgeThreshold, int)
|
IMPLEMENT_PARAM_CLASS(ORB_ScaleFactor, float)
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_firstLevel, int)
|
IMPLEMENT_PARAM_CLASS(ORB_LevelsCount, int)
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_WTA_K, int)
|
IMPLEMENT_PARAM_CLASS(ORB_EdgeThreshold, int)
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_PatchSize, int)
|
IMPLEMENT_PARAM_CLASS(ORB_firstLevel, int)
|
||||||
IMPLEMENT_PARAM_CLASS(ORB_BlurForDescriptor, bool)
|
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)
|
CV_ENUM(ORB_ScoreType, cv::ORB::HARRIS_SCORE, cv::ORB::FAST_SCORE)
|
||||||
|
|
||||||
@ -443,7 +453,7 @@ PARAM_TEST_CASE(ORB, cv::gpu::DeviceInfo, ORB_FeaturesCount, ORB_ScaleFactor, OR
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(ORB, Accuracy)
|
GPU_TEST_P(ORB, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE);
|
||||||
ASSERT_FALSE(image.empty());
|
ASSERT_FALSE(image.empty());
|
||||||
@ -505,8 +515,11 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, ORB, testing::Combine(
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// BruteForceMatcher
|
// BruteForceMatcher
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
|
namespace
|
||||||
IMPLEMENT_PARAM_CLASS(UseMask, bool)
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
|
||||||
|
IMPLEMENT_PARAM_CLASS(UseMask, bool)
|
||||||
|
}
|
||||||
|
|
||||||
PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, NormCode, DescriptorSize, UseMask)
|
PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, NormCode, DescriptorSize, UseMask)
|
||||||
{
|
{
|
||||||
@ -568,7 +581,7 @@ PARAM_TEST_CASE(BruteForceMatcher, cv::gpu::DeviceInfo, NormCode, DescriptorSize
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, Match_Single)
|
GPU_TEST_P(BruteForceMatcher, Match_Single)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -595,7 +608,7 @@ TEST_P(BruteForceMatcher, Match_Single)
|
|||||||
ASSERT_EQ(0, badCount);
|
ASSERT_EQ(0, badCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, Match_Collection)
|
GPU_TEST_P(BruteForceMatcher, Match_Collection)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -649,7 +662,7 @@ TEST_P(BruteForceMatcher, Match_Collection)
|
|||||||
ASSERT_EQ(0, badCount);
|
ASSERT_EQ(0, badCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, KnnMatch_2_Single)
|
GPU_TEST_P(BruteForceMatcher, KnnMatch_2_Single)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -688,7 +701,7 @@ TEST_P(BruteForceMatcher, KnnMatch_2_Single)
|
|||||||
ASSERT_EQ(0, badCount);
|
ASSERT_EQ(0, badCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, KnnMatch_3_Single)
|
GPU_TEST_P(BruteForceMatcher, KnnMatch_3_Single)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -727,7 +740,7 @@ TEST_P(BruteForceMatcher, KnnMatch_3_Single)
|
|||||||
ASSERT_EQ(0, badCount);
|
ASSERT_EQ(0, badCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, KnnMatch_2_Collection)
|
GPU_TEST_P(BruteForceMatcher, KnnMatch_2_Collection)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -789,7 +802,7 @@ TEST_P(BruteForceMatcher, KnnMatch_2_Collection)
|
|||||||
ASSERT_EQ(0, badCount);
|
ASSERT_EQ(0, badCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, KnnMatch_3_Collection)
|
GPU_TEST_P(BruteForceMatcher, KnnMatch_3_Collection)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -851,7 +864,7 @@ TEST_P(BruteForceMatcher, KnnMatch_3_Collection)
|
|||||||
ASSERT_EQ(0, badCount);
|
ASSERT_EQ(0, badCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, RadiusMatch_Single)
|
GPU_TEST_P(BruteForceMatcher, RadiusMatch_Single)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -900,7 +913,7 @@ TEST_P(BruteForceMatcher, RadiusMatch_Single)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(BruteForceMatcher, RadiusMatch_Collection)
|
GPU_TEST_P(BruteForceMatcher, RadiusMatch_Collection)
|
||||||
{
|
{
|
||||||
cv::gpu::BFMatcher_GPU matcher(normCode);
|
cv::gpu::BFMatcher_GPU matcher(normCode);
|
||||||
|
|
||||||
@ -985,6 +998,4 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, BruteForceMatcher, testing::Combine(
|
|||||||
testing::Values(DescriptorSize(57), DescriptorSize(64), DescriptorSize(83), DescriptorSize(128), DescriptorSize(179), DescriptorSize(256), DescriptorSize(304)),
|
testing::Values(DescriptorSize(57), DescriptorSize(64), DescriptorSize(83), DescriptorSize(128), DescriptorSize(179), DescriptorSize(256), DescriptorSize(304)),
|
||||||
testing::Values(UseMask(false), UseMask(true))));
|
testing::Values(UseMask(false), UseMask(true))));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -43,27 +43,30 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(KSize, cv::Size)
|
|
||||||
|
|
||||||
cv::Mat getInnerROI(cv::InputArray m_, cv::Size ksize)
|
|
||||||
{
|
{
|
||||||
cv::Mat m = getMat(m_);
|
IMPLEMENT_PARAM_CLASS(KSize, cv::Size)
|
||||||
cv::Rect roi(ksize.width, ksize.height, m.cols - 2 * ksize.width, m.rows - 2 * ksize.height);
|
IMPLEMENT_PARAM_CLASS(Anchor, cv::Point)
|
||||||
return m(roi);
|
IMPLEMENT_PARAM_CLASS(Deriv_X, int)
|
||||||
}
|
IMPLEMENT_PARAM_CLASS(Deriv_Y, int)
|
||||||
|
IMPLEMENT_PARAM_CLASS(Iterations, int)
|
||||||
|
|
||||||
cv::Mat getInnerROI(cv::InputArray m, int ksize)
|
cv::Mat getInnerROI(cv::InputArray m_, cv::Size ksize)
|
||||||
{
|
{
|
||||||
return getInnerROI(m, cv::Size(ksize, ksize));
|
cv::Mat m = getMat(m_);
|
||||||
|
cv::Rect roi(ksize.width, ksize.height, m.cols - 2 * ksize.width, m.rows - 2 * ksize.height);
|
||||||
|
return m(roi);
|
||||||
|
}
|
||||||
|
|
||||||
|
cv::Mat getInnerROI(cv::InputArray m, int ksize)
|
||||||
|
{
|
||||||
|
return getInnerROI(m, cv::Size(ksize, ksize));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Blur
|
// Blur
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(Anchor, cv::Point)
|
|
||||||
|
|
||||||
PARAM_TEST_CASE(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor, UseRoi)
|
PARAM_TEST_CASE(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor, UseRoi)
|
||||||
{
|
{
|
||||||
cv::gpu::DeviceInfo devInfo;
|
cv::gpu::DeviceInfo devInfo;
|
||||||
@ -86,7 +89,7 @@ PARAM_TEST_CASE(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor, Use
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Blur, Accuracy)
|
GPU_TEST_P(Blur, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
@ -110,9 +113,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, Blur, testing::Combine(
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Sobel
|
// Sobel
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(Deriv_X, int)
|
|
||||||
IMPLEMENT_PARAM_CLASS(Deriv_Y, int)
|
|
||||||
|
|
||||||
PARAM_TEST_CASE(Sobel, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, KSize, Deriv_X, Deriv_Y, BorderType, UseRoi)
|
PARAM_TEST_CASE(Sobel, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, KSize, Deriv_X, Deriv_Y, BorderType, UseRoi)
|
||||||
{
|
{
|
||||||
cv::gpu::DeviceInfo devInfo;
|
cv::gpu::DeviceInfo devInfo;
|
||||||
@ -145,7 +145,7 @@ PARAM_TEST_CASE(Sobel, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, KSize,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Sobel, Accuracy)
|
GPU_TEST_P(Sobel, Accuracy)
|
||||||
{
|
{
|
||||||
if (dx == 0 && dy == 0)
|
if (dx == 0 && dy == 0)
|
||||||
return;
|
return;
|
||||||
@ -208,7 +208,7 @@ PARAM_TEST_CASE(Scharr, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, Deriv
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Scharr, Accuracy)
|
GPU_TEST_P(Scharr, Accuracy)
|
||||||
{
|
{
|
||||||
if (dx + dy != 1)
|
if (dx + dy != 1)
|
||||||
return;
|
return;
|
||||||
@ -268,7 +268,7 @@ PARAM_TEST_CASE(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(GaussianBlur, Accuracy)
|
GPU_TEST_P(GaussianBlur, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
double sigma1 = randomDouble(0.1, 1.0);
|
double sigma1 = randomDouble(0.1, 1.0);
|
||||||
@ -347,7 +347,7 @@ PARAM_TEST_CASE(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, UseRoi
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Laplacian, Accuracy)
|
GPU_TEST_P(Laplacian, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
@ -370,8 +370,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, Laplacian, testing::Combine(
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Erode
|
// Erode
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(Iterations, int)
|
|
||||||
|
|
||||||
PARAM_TEST_CASE(Erode, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iterations, UseRoi)
|
PARAM_TEST_CASE(Erode, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iterations, UseRoi)
|
||||||
{
|
{
|
||||||
cv::gpu::DeviceInfo devInfo;
|
cv::gpu::DeviceInfo devInfo;
|
||||||
@ -394,7 +392,7 @@ PARAM_TEST_CASE(Erode, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iteration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Erode, Accuracy)
|
GPU_TEST_P(Erode, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
|
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
|
||||||
@ -443,7 +441,7 @@ PARAM_TEST_CASE(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iteratio
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Dilate, Accuracy)
|
GPU_TEST_P(Dilate, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
|
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
|
||||||
@ -497,7 +495,7 @@ PARAM_TEST_CASE(MorphEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp, Anchor
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MorphEx, Accuracy)
|
GPU_TEST_P(MorphEx, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
|
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
|
||||||
@ -551,7 +549,7 @@ PARAM_TEST_CASE(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Filter2D, Accuracy)
|
GPU_TEST_P(Filter2D, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Mat kernel = randomMat(cv::Size(ksize.width, ksize.height), CV_32FC1, 0.0, 1.0);
|
cv::Mat kernel = randomMat(cv::Size(ksize.width, ksize.height), CV_32FC1, 0.0, 1.0);
|
||||||
@ -574,6 +572,4 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, Filter2D, testing::Combine(
|
|||||||
testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_CONSTANT), BorderType(cv::BORDER_REFLECT)),
|
testing::Values(BorderType(cv::BORDER_REFLECT101), BorderType(cv::BORDER_REPLICATE), BorderType(cv::BORDER_CONSTANT), BorderType(cv::BORDER_REFLECT)),
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -51,7 +51,7 @@ struct CompactPoints : testing::TestWithParam<gpu::DeviceInfo>
|
|||||||
virtual void SetUp() { gpu::setDevice(GetParam().deviceID()); }
|
virtual void SetUp() { gpu::setDevice(GetParam().deviceID()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CompactPoints, CanCompactizeSmallInput)
|
GPU_TEST_P(CompactPoints, CanCompactizeSmallInput)
|
||||||
{
|
{
|
||||||
Mat src0(1, 3, CV_32FC2);
|
Mat src0(1, 3, CV_32FC2);
|
||||||
src0.at<Point2f>(0,0) = Point2f(0,0);
|
src0.at<Point2f>(0,0) = Point2f(0,0);
|
||||||
|
@ -44,8 +44,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// SetTo
|
// SetTo
|
||||||
|
|
||||||
@ -67,7 +65,7 @@ PARAM_TEST_CASE(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(SetTo, Zero)
|
GPU_TEST_P(SetTo, Zero)
|
||||||
{
|
{
|
||||||
cv::Scalar zero = cv::Scalar::all(0);
|
cv::Scalar zero = cv::Scalar::all(0);
|
||||||
|
|
||||||
@ -77,7 +75,7 @@ TEST_P(SetTo, Zero)
|
|||||||
EXPECT_MAT_NEAR(cv::Mat::zeros(size, type), mat, 0.0);
|
EXPECT_MAT_NEAR(cv::Mat::zeros(size, type), mat, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SetTo, SameVal)
|
GPU_TEST_P(SetTo, SameVal)
|
||||||
{
|
{
|
||||||
cv::Scalar val = cv::Scalar::all(randomDouble(0.0, 255.0));
|
cv::Scalar val = cv::Scalar::all(randomDouble(0.0, 255.0));
|
||||||
|
|
||||||
@ -102,7 +100,7 @@ TEST_P(SetTo, SameVal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SetTo, DifferentVal)
|
GPU_TEST_P(SetTo, DifferentVal)
|
||||||
{
|
{
|
||||||
cv::Scalar val = randomScalar(0.0, 255.0);
|
cv::Scalar val = randomScalar(0.0, 255.0);
|
||||||
|
|
||||||
@ -127,7 +125,7 @@ TEST_P(SetTo, DifferentVal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(SetTo, Masked)
|
GPU_TEST_P(SetTo, Masked)
|
||||||
{
|
{
|
||||||
cv::Scalar val = randomScalar(0.0, 255.0);
|
cv::Scalar val = randomScalar(0.0, 255.0);
|
||||||
cv::Mat mat_gold = randomMat(size, type);
|
cv::Mat mat_gold = randomMat(size, type);
|
||||||
@ -184,7 +182,7 @@ PARAM_TEST_CASE(CopyTo, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CopyTo, WithOutMask)
|
GPU_TEST_P(CopyTo, WithOutMask)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
@ -195,7 +193,7 @@ TEST_P(CopyTo, WithOutMask)
|
|||||||
EXPECT_MAT_NEAR(src, dst, 0.0);
|
EXPECT_MAT_NEAR(src, dst, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(CopyTo, Masked)
|
GPU_TEST_P(CopyTo, Masked)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
|
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
|
||||||
@ -255,7 +253,7 @@ PARAM_TEST_CASE(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth, Us
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(ConvertTo, WithOutScaling)
|
GPU_TEST_P(ConvertTo, WithOutScaling)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, depth1);
|
cv::Mat src = randomMat(size, depth1);
|
||||||
|
|
||||||
@ -285,7 +283,7 @@ TEST_P(ConvertTo, WithOutScaling)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ConvertTo, WithScaling)
|
GPU_TEST_P(ConvertTo, WithScaling)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, depth1);
|
cv::Mat src = randomMat(size, depth1);
|
||||||
double a = randomDouble(0.0, 1.0);
|
double a = randomDouble(0.0, 1.0);
|
||||||
@ -336,7 +334,7 @@ struct EnsureSizeIsEnough : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(EnsureSizeIsEnough, BufferReuse)
|
GPU_TEST_P(EnsureSizeIsEnough, BufferReuse)
|
||||||
{
|
{
|
||||||
cv::gpu::GpuMat buffer(100, 100, CV_8U);
|
cv::gpu::GpuMat buffer(100, 100, CV_8U);
|
||||||
cv::gpu::GpuMat old = buffer;
|
cv::gpu::GpuMat old = buffer;
|
||||||
@ -358,6 +356,4 @@ TEST_P(EnsureSizeIsEnough, BufferReuse)
|
|||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(GPU_GpuMat, EnsureSizeIsEnough, ALL_DEVICES);
|
INSTANTIATE_TEST_CASE_P(GPU_GpuMat, EnsureSizeIsEnough, ALL_DEVICES);
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// HoughLines
|
// HoughLines
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ PARAM_TEST_CASE(HoughLines, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(HoughLines, Accuracy)
|
GPU_TEST_P(HoughLines, Accuracy)
|
||||||
{
|
{
|
||||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||||
cv::gpu::setDevice(devInfo.deviceID());
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
@ -88,7 +86,7 @@ TEST_P(HoughLines, Accuracy)
|
|||||||
|
|
||||||
const float rho = 1.0f;
|
const float rho = 1.0f;
|
||||||
const float theta = (float) (1.5 * CV_PI / 180.0);
|
const float theta = (float) (1.5 * CV_PI / 180.0);
|
||||||
onst int threshold = 100;
|
const int threshold = 100;
|
||||||
|
|
||||||
cv::Mat src(size, CV_8UC1);
|
cv::Mat src(size, CV_8UC1);
|
||||||
generateLines(src);
|
generateLines(src);
|
||||||
@ -124,7 +122,7 @@ PARAM_TEST_CASE(HoughCircles, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(HoughCircles, Accuracy)
|
GPU_TEST_P(HoughCircles, Accuracy)
|
||||||
{
|
{
|
||||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||||
cv::gpu::setDevice(devInfo.deviceID());
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
@ -188,7 +186,7 @@ PARAM_TEST_CASE(GeneralizedHough, cv::gpu::DeviceInfo, UseRoi)
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(GeneralizedHough, POSITION)
|
GPU_TEST_P(GeneralizedHough, POSITION)
|
||||||
{
|
{
|
||||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||||
cv::gpu::setDevice(devInfo.deviceID());
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
@ -251,6 +249,4 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, GeneralizedHough, testing::Combine(
|
|||||||
ALL_DEVICES,
|
ALL_DEVICES,
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Integral
|
// Integral
|
||||||
|
|
||||||
@ -64,7 +62,7 @@ PARAM_TEST_CASE(Integral, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Integral, Accuracy)
|
GPU_TEST_P(Integral, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, CV_8UC1);
|
cv::Mat src = randomMat(size, CV_8UC1);
|
||||||
|
|
||||||
@ -97,7 +95,7 @@ struct HistEven : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(HistEven, Accuracy)
|
GPU_TEST_P(HistEven, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat img = readImage("stereobm/aloe-L.png");
|
cv::Mat img = readImage("stereobm/aloe-L.png");
|
||||||
ASSERT_FALSE(img.empty());
|
ASSERT_FALSE(img.empty());
|
||||||
@ -132,18 +130,21 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HistEven, ALL_DEVICES);
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// CalcHist
|
// CalcHist
|
||||||
|
|
||||||
void calcHistGold(const cv::Mat& src, cv::Mat& hist)
|
namespace
|
||||||
{
|
{
|
||||||
hist.create(1, 256, CV_32SC1);
|
void calcHistGold(const cv::Mat& src, cv::Mat& hist)
|
||||||
hist.setTo(cv::Scalar::all(0));
|
|
||||||
|
|
||||||
int* hist_row = hist.ptr<int>();
|
|
||||||
for (int y = 0; y < src.rows; ++y)
|
|
||||||
{
|
{
|
||||||
const uchar* src_row = src.ptr(y);
|
hist.create(1, 256, CV_32SC1);
|
||||||
|
hist.setTo(cv::Scalar::all(0));
|
||||||
|
|
||||||
for (int x = 0; x < src.cols; ++x)
|
int* hist_row = hist.ptr<int>();
|
||||||
++hist_row[src_row[x]];
|
for (int y = 0; y < src.rows; ++y)
|
||||||
|
{
|
||||||
|
const uchar* src_row = src.ptr(y);
|
||||||
|
|
||||||
|
for (int x = 0; x < src.cols; ++x)
|
||||||
|
++hist_row[src_row[x]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +163,7 @@ PARAM_TEST_CASE(CalcHist, cv::gpu::DeviceInfo, cv::Size)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CalcHist, Accuracy)
|
GPU_TEST_P(CalcHist, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, CV_8UC1);
|
cv::Mat src = randomMat(size, CV_8UC1);
|
||||||
|
|
||||||
@ -196,7 +197,7 @@ PARAM_TEST_CASE(EqualizeHist, cv::gpu::DeviceInfo, cv::Size)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(EqualizeHist, Accuracy)
|
GPU_TEST_P(EqualizeHist, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, CV_8UC1);
|
cv::Mat src = randomMat(size, CV_8UC1);
|
||||||
|
|
||||||
@ -230,7 +231,7 @@ PARAM_TEST_CASE(ColumnSum, cv::gpu::DeviceInfo, cv::Size)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(ColumnSum, Accuracy)
|
GPU_TEST_P(ColumnSum, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, CV_32FC1);
|
cv::Mat src = randomMat(size, CV_32FC1);
|
||||||
|
|
||||||
@ -264,8 +265,11 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ColumnSum, testing::Combine(
|
|||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// Canny
|
// Canny
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(AppertureSize, int);
|
namespace
|
||||||
IMPLEMENT_PARAM_CLASS(L2gradient, bool);
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(AppertureSize, int);
|
||||||
|
IMPLEMENT_PARAM_CLASS(L2gradient, bool);
|
||||||
|
}
|
||||||
|
|
||||||
PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient, UseRoi)
|
PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient, UseRoi)
|
||||||
{
|
{
|
||||||
@ -285,7 +289,7 @@ PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Canny, Accuracy)
|
GPU_TEST_P(Canny, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat img = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
|
cv::Mat img = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
|
||||||
ASSERT_FALSE(img.empty());
|
ASSERT_FALSE(img.empty());
|
||||||
@ -349,7 +353,7 @@ struct MeanShift : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MeanShift, Filtering)
|
GPU_TEST_P(MeanShift, Filtering)
|
||||||
{
|
{
|
||||||
cv::Mat img_template;
|
cv::Mat img_template;
|
||||||
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
||||||
@ -371,7 +375,7 @@ TEST_P(MeanShift, Filtering)
|
|||||||
EXPECT_MAT_NEAR(img_template, result, 0.0);
|
EXPECT_MAT_NEAR(img_template, result, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MeanShift, Proc)
|
GPU_TEST_P(MeanShift, Proc)
|
||||||
{
|
{
|
||||||
cv::FileStorage fs;
|
cv::FileStorage fs;
|
||||||
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
|
||||||
@ -402,7 +406,10 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MeanShift, ALL_DEVICES);
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// MeanShiftSegmentation
|
// MeanShiftSegmentation
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(MinSize, int);
|
namespace
|
||||||
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(MinSize, int);
|
||||||
|
}
|
||||||
|
|
||||||
PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, MinSize)
|
PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, MinSize)
|
||||||
{
|
{
|
||||||
@ -418,7 +425,7 @@ PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, MinSize)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MeanShiftSegmentation, Regression)
|
GPU_TEST_P(MeanShiftSegmentation, Regression)
|
||||||
{
|
{
|
||||||
cv::Mat img = readImageType("meanshift/cones.png", CV_8UC4);
|
cv::Mat img = readImageType("meanshift/cones.png", CV_8UC4);
|
||||||
ASSERT_FALSE(img.empty());
|
ASSERT_FALSE(img.empty());
|
||||||
@ -448,26 +455,29 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MeanShiftSegmentation, testing::Combine(
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Blend
|
// Blend
|
||||||
|
|
||||||
template <typename T>
|
namespace
|
||||||
void blendLinearGold(const cv::Mat& img1, const cv::Mat& img2, const cv::Mat& weights1, const cv::Mat& weights2, cv::Mat& result_gold)
|
|
||||||
{
|
{
|
||||||
result_gold.create(img1.size(), img1.type());
|
template <typename T>
|
||||||
|
void blendLinearGold(const cv::Mat& img1, const cv::Mat& img2, const cv::Mat& weights1, const cv::Mat& weights2, cv::Mat& result_gold)
|
||||||
int cn = img1.channels();
|
|
||||||
|
|
||||||
for (int y = 0; y < img1.rows; ++y)
|
|
||||||
{
|
{
|
||||||
const float* weights1_row = weights1.ptr<float>(y);
|
result_gold.create(img1.size(), img1.type());
|
||||||
const float* weights2_row = weights2.ptr<float>(y);
|
|
||||||
const T* img1_row = img1.ptr<T>(y);
|
|
||||||
const T* img2_row = img2.ptr<T>(y);
|
|
||||||
T* result_gold_row = result_gold.ptr<T>(y);
|
|
||||||
|
|
||||||
for (int x = 0; x < img1.cols * cn; ++x)
|
int cn = img1.channels();
|
||||||
|
|
||||||
|
for (int y = 0; y < img1.rows; ++y)
|
||||||
{
|
{
|
||||||
float w1 = weights1_row[x / cn];
|
const float* weights1_row = weights1.ptr<float>(y);
|
||||||
float w2 = weights2_row[x / cn];
|
const float* weights2_row = weights2.ptr<float>(y);
|
||||||
result_gold_row[x] = static_cast<T>((img1_row[x] * w1 + img2_row[x] * w2) / (w1 + w2 + 1e-5f));
|
const T* img1_row = img1.ptr<T>(y);
|
||||||
|
const T* img2_row = img2.ptr<T>(y);
|
||||||
|
T* result_gold_row = result_gold.ptr<T>(y);
|
||||||
|
|
||||||
|
for (int x = 0; x < img1.cols * cn; ++x)
|
||||||
|
{
|
||||||
|
float w1 = weights1_row[x / cn];
|
||||||
|
float w2 = weights2_row[x / cn];
|
||||||
|
result_gold_row[x] = static_cast<T>((img1_row[x] * w1 + img2_row[x] * w2) / (w1 + w2 + 1e-5f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,7 +500,7 @@ PARAM_TEST_CASE(Blend, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Blend, Accuracy)
|
GPU_TEST_P(Blend, Accuracy)
|
||||||
{
|
{
|
||||||
int depth = CV_MAT_DEPTH(type);
|
int depth = CV_MAT_DEPTH(type);
|
||||||
|
|
||||||
@ -520,48 +530,51 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, testing::Combine(
|
|||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// Convolve
|
// Convolve
|
||||||
|
|
||||||
void convolveDFT(const cv::Mat& A, const cv::Mat& B, cv::Mat& C, bool ccorr = false)
|
namespace
|
||||||
{
|
{
|
||||||
// reallocate the output array if needed
|
void convolveDFT(const cv::Mat& A, const cv::Mat& B, cv::Mat& C, bool ccorr = false)
|
||||||
C.create(std::abs(A.rows - B.rows) + 1, std::abs(A.cols - B.cols) + 1, A.type());
|
{
|
||||||
cv::Size dftSize;
|
// reallocate the output array if needed
|
||||||
|
C.create(std::abs(A.rows - B.rows) + 1, std::abs(A.cols - B.cols) + 1, A.type());
|
||||||
|
cv::Size dftSize;
|
||||||
|
|
||||||
// compute the size of DFT transform
|
// compute the size of DFT transform
|
||||||
dftSize.width = cv::getOptimalDFTSize(A.cols + B.cols - 1);
|
dftSize.width = cv::getOptimalDFTSize(A.cols + B.cols - 1);
|
||||||
dftSize.height = cv::getOptimalDFTSize(A.rows + B.rows - 1);
|
dftSize.height = cv::getOptimalDFTSize(A.rows + B.rows - 1);
|
||||||
|
|
||||||
// allocate temporary buffers and initialize them with 0s
|
// allocate temporary buffers and initialize them with 0s
|
||||||
cv::Mat tempA(dftSize, A.type(), cv::Scalar::all(0));
|
cv::Mat tempA(dftSize, A.type(), cv::Scalar::all(0));
|
||||||
cv::Mat tempB(dftSize, B.type(), cv::Scalar::all(0));
|
cv::Mat tempB(dftSize, B.type(), cv::Scalar::all(0));
|
||||||
|
|
||||||
// copy A and B to the top-left corners of tempA and tempB, respectively
|
// copy A and B to the top-left corners of tempA and tempB, respectively
|
||||||
cv::Mat roiA(tempA, cv::Rect(0, 0, A.cols, A.rows));
|
cv::Mat roiA(tempA, cv::Rect(0, 0, A.cols, A.rows));
|
||||||
A.copyTo(roiA);
|
A.copyTo(roiA);
|
||||||
cv::Mat roiB(tempB, cv::Rect(0, 0, B.cols, B.rows));
|
cv::Mat roiB(tempB, cv::Rect(0, 0, B.cols, B.rows));
|
||||||
B.copyTo(roiB);
|
B.copyTo(roiB);
|
||||||
|
|
||||||
// now transform the padded A & B in-place;
|
// now transform the padded A & B in-place;
|
||||||
// use "nonzeroRows" hint for faster processing
|
// use "nonzeroRows" hint for faster processing
|
||||||
cv::dft(tempA, tempA, 0, A.rows);
|
cv::dft(tempA, tempA, 0, A.rows);
|
||||||
cv::dft(tempB, tempB, 0, B.rows);
|
cv::dft(tempB, tempB, 0, B.rows);
|
||||||
|
|
||||||
// multiply the spectrums;
|
// multiply the spectrums;
|
||||||
// the function handles packed spectrum representations well
|
// the function handles packed spectrum representations well
|
||||||
cv::mulSpectrums(tempA, tempB, tempA, 0, ccorr);
|
cv::mulSpectrums(tempA, tempB, tempA, 0, ccorr);
|
||||||
|
|
||||||
// transform the product back from the frequency domain.
|
// transform the product back from the frequency domain.
|
||||||
// Even though all the result rows will be non-zero,
|
// Even though all the result rows will be non-zero,
|
||||||
// you need only the first C.rows of them, and thus you
|
// you need only the first C.rows of them, and thus you
|
||||||
// pass nonzeroRows == C.rows
|
// pass nonzeroRows == C.rows
|
||||||
cv::dft(tempA, tempA, cv::DFT_INVERSE + cv::DFT_SCALE, C.rows);
|
cv::dft(tempA, tempA, cv::DFT_INVERSE + cv::DFT_SCALE, C.rows);
|
||||||
|
|
||||||
// now copy the result back to C.
|
// now copy the result back to C.
|
||||||
tempA(cv::Rect(0, 0, C.cols, C.rows)).copyTo(C);
|
tempA(cv::Rect(0, 0, C.cols, C.rows)).copyTo(C);
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLEMENT_PARAM_CLASS(KSize, int);
|
||||||
|
IMPLEMENT_PARAM_CLASS(Ccorr, bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(KSize, int);
|
|
||||||
IMPLEMENT_PARAM_CLASS(Ccorr, bool);
|
|
||||||
|
|
||||||
PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr)
|
PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr)
|
||||||
{
|
{
|
||||||
cv::gpu::DeviceInfo devInfo;
|
cv::gpu::DeviceInfo devInfo;
|
||||||
@ -580,7 +593,7 @@ PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Convolve, Accuracy)
|
GPU_TEST_P(Convolve, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, CV_32FC1, 0.0, 100.0);
|
cv::Mat src = randomMat(size, CV_32FC1, 0.0, 100.0);
|
||||||
cv::Mat kernel = randomMat(cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0);
|
cv::Mat kernel = randomMat(cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0);
|
||||||
@ -606,7 +619,10 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Convolve, testing::Combine(
|
|||||||
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_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
|
||||||
#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_CCOEFF_NORMED))
|
#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_CCOEFF_NORMED))
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size);
|
namespace
|
||||||
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size);
|
||||||
|
}
|
||||||
|
|
||||||
PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod)
|
PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod)
|
||||||
{
|
{
|
||||||
@ -628,7 +644,7 @@ PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Ch
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MatchTemplate8U, Accuracy)
|
GPU_TEST_P(MatchTemplate8U, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
|
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
|
||||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn));
|
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn));
|
||||||
@ -674,7 +690,7 @@ PARAM_TEST_CASE(MatchTemplate32F, cv::gpu::DeviceInfo, cv::Size, TemplateSize, C
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MatchTemplate32F, Regression)
|
GPU_TEST_P(MatchTemplate32F, Regression)
|
||||||
{
|
{
|
||||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
|
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
|
||||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
|
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
|
||||||
@ -712,7 +728,7 @@ PARAM_TEST_CASE(MatchTemplateBlackSource, cv::gpu::DeviceInfo, TemplateMethod)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MatchTemplateBlackSource, Accuracy)
|
GPU_TEST_P(MatchTemplateBlackSource, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat image = readImage("matchtemplate/black.png");
|
cv::Mat image = readImage("matchtemplate/black.png");
|
||||||
ASSERT_FALSE(image.empty());
|
ASSERT_FALSE(image.empty());
|
||||||
@ -757,7 +773,7 @@ PARAM_TEST_CASE(MatchTemplate_CCOEF_NORMED, cv::gpu::DeviceInfo, std::pair<std::
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MatchTemplate_CCOEF_NORMED, Accuracy)
|
GPU_TEST_P(MatchTemplate_CCOEF_NORMED, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat image = readImage(imageName);
|
cv::Mat image = readImage(imageName);
|
||||||
ASSERT_FALSE(image.empty());
|
ASSERT_FALSE(image.empty());
|
||||||
@ -806,7 +822,7 @@ struct MatchTemplate_CanFindBigTemplate : testing::TestWithParam<cv::gpu::Device
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MatchTemplate_CanFindBigTemplate, SQDIFF_NORMED)
|
GPU_TEST_P(MatchTemplate_CanFindBigTemplate, SQDIFF_NORMED)
|
||||||
{
|
{
|
||||||
cv::Mat scene = readImage("matchtemplate/scene.png");
|
cv::Mat scene = readImage("matchtemplate/scene.png");
|
||||||
ASSERT_FALSE(scene.empty());
|
ASSERT_FALSE(scene.empty());
|
||||||
@ -829,7 +845,7 @@ TEST_P(MatchTemplate_CanFindBigTemplate, SQDIFF_NORMED)
|
|||||||
ASSERT_EQ(0, minLoc.y);
|
ASSERT_EQ(0, minLoc.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MatchTemplate_CanFindBigTemplate, SQDIFF)
|
GPU_TEST_P(MatchTemplate_CanFindBigTemplate, SQDIFF)
|
||||||
{
|
{
|
||||||
cv::Mat scene = readImage("matchtemplate/scene.png");
|
cv::Mat scene = readImage("matchtemplate/scene.png");
|
||||||
ASSERT_FALSE(scene.empty());
|
ASSERT_FALSE(scene.empty());
|
||||||
@ -879,7 +895,7 @@ PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MulSpectrums, Simple)
|
GPU_TEST_P(MulSpectrums, Simple)
|
||||||
{
|
{
|
||||||
cv::gpu::GpuMat c;
|
cv::gpu::GpuMat c;
|
||||||
cv::gpu::mulSpectrums(loadMat(a), loadMat(b), c, flag, false);
|
cv::gpu::mulSpectrums(loadMat(a), loadMat(b), c, flag, false);
|
||||||
@ -890,7 +906,7 @@ TEST_P(MulSpectrums, Simple)
|
|||||||
EXPECT_MAT_NEAR(c_gold, c, 1e-2);
|
EXPECT_MAT_NEAR(c_gold, c, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MulSpectrums, Scaled)
|
GPU_TEST_P(MulSpectrums, Scaled)
|
||||||
{
|
{
|
||||||
float scale = 1.f / size.area();
|
float scale = 1.f / size.area();
|
||||||
|
|
||||||
@ -924,31 +940,34 @@ struct Dft : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace)
|
namespace
|
||||||
{
|
{
|
||||||
SCOPED_TRACE(hint);
|
void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace)
|
||||||
|
|
||||||
cv::Mat a = randomMat(cv::Size(cols, rows), CV_32FC2, 0.0, 10.0);
|
|
||||||
|
|
||||||
cv::Mat b_gold;
|
|
||||||
cv::dft(a, b_gold, flags);
|
|
||||||
|
|
||||||
cv::gpu::GpuMat d_b;
|
|
||||||
cv::gpu::GpuMat d_b_data;
|
|
||||||
if (inplace)
|
|
||||||
{
|
{
|
||||||
d_b_data.create(1, a.size().area(), CV_32FC2);
|
SCOPED_TRACE(hint);
|
||||||
d_b = cv::gpu::GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
|
|
||||||
}
|
|
||||||
cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), flags);
|
|
||||||
|
|
||||||
EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
|
cv::Mat a = randomMat(cv::Size(cols, rows), CV_32FC2, 0.0, 10.0);
|
||||||
ASSERT_EQ(CV_32F, d_b.depth());
|
|
||||||
ASSERT_EQ(2, d_b.channels());
|
cv::Mat b_gold;
|
||||||
EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), rows * cols * 1e-4);
|
cv::dft(a, b_gold, flags);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_b;
|
||||||
|
cv::gpu::GpuMat d_b_data;
|
||||||
|
if (inplace)
|
||||||
|
{
|
||||||
|
d_b_data.create(1, a.size().area(), CV_32FC2);
|
||||||
|
d_b = cv::gpu::GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
|
||||||
|
}
|
||||||
|
cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), flags);
|
||||||
|
|
||||||
|
EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
|
||||||
|
ASSERT_EQ(CV_32F, d_b.depth());
|
||||||
|
ASSERT_EQ(2, d_b.channels());
|
||||||
|
EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), rows * cols * 1e-4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(Dft, C2C)
|
GPU_TEST_P(Dft, C2C)
|
||||||
{
|
{
|
||||||
int cols = randomInt(2, 100);
|
int cols = randomInt(2, 100);
|
||||||
int rows = randomInt(2, 100);
|
int rows = randomInt(2, 100);
|
||||||
@ -973,43 +992,46 @@ TEST_P(Dft, C2C)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
|
namespace
|
||||||
{
|
{
|
||||||
SCOPED_TRACE(hint);
|
void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
|
||||||
|
|
||||||
cv::Mat a = randomMat(cv::Size(cols, rows), CV_32FC1, 0.0, 10.0);
|
|
||||||
|
|
||||||
cv::gpu::GpuMat d_b, d_c;
|
|
||||||
cv::gpu::GpuMat d_b_data, d_c_data;
|
|
||||||
if (inplace)
|
|
||||||
{
|
{
|
||||||
if (a.cols == 1)
|
SCOPED_TRACE(hint);
|
||||||
|
|
||||||
|
cv::Mat a = randomMat(cv::Size(cols, rows), CV_32FC1, 0.0, 10.0);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_b, d_c;
|
||||||
|
cv::gpu::GpuMat d_b_data, d_c_data;
|
||||||
|
if (inplace)
|
||||||
{
|
{
|
||||||
d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);
|
if (a.cols == 1)
|
||||||
d_b = cv::gpu::GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
|
{
|
||||||
|
d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);
|
||||||
|
d_b = cv::gpu::GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);
|
||||||
|
d_b = cv::gpu::GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());
|
||||||
|
}
|
||||||
|
d_c_data.create(1, a.size().area(), CV_32F);
|
||||||
|
d_c = cv::gpu::GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), 0);
|
||||||
d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);
|
cv::gpu::dft(d_b, d_c, cv::Size(cols, rows), cv::DFT_REAL_OUTPUT | cv::DFT_SCALE);
|
||||||
d_b = cv::gpu::GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());
|
|
||||||
}
|
EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
|
||||||
d_c_data.create(1, a.size().area(), CV_32F);
|
EXPECT_TRUE(!inplace || d_c.ptr() == d_c_data.ptr());
|
||||||
d_c = cv::gpu::GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());
|
ASSERT_EQ(CV_32F, d_c.depth());
|
||||||
|
ASSERT_EQ(1, d_c.channels());
|
||||||
|
|
||||||
|
cv::Mat c(d_c);
|
||||||
|
EXPECT_MAT_NEAR(a, c, rows * cols * 1e-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), 0);
|
|
||||||
cv::gpu::dft(d_b, d_c, cv::Size(cols, rows), cv::DFT_REAL_OUTPUT | cv::DFT_SCALE);
|
|
||||||
|
|
||||||
EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
|
|
||||||
EXPECT_TRUE(!inplace || d_c.ptr() == d_c_data.ptr());
|
|
||||||
ASSERT_EQ(CV_32F, d_c.depth());
|
|
||||||
ASSERT_EQ(1, d_c.channels());
|
|
||||||
|
|
||||||
cv::Mat c(d_c);
|
|
||||||
EXPECT_MAT_NEAR(a, c, rows * cols * 1e-5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(Dft, R2CThenC2R)
|
GPU_TEST_P(Dft, R2CThenC2R)
|
||||||
{
|
{
|
||||||
int cols = randomInt(2, 100);
|
int cols = randomInt(2, 100);
|
||||||
int rows = randomInt(2, 100);
|
int rows = randomInt(2, 100);
|
||||||
@ -1036,8 +1058,11 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Dft, ALL_DEVICES);
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// CornerHarris
|
// CornerHarris
|
||||||
|
|
||||||
IMPLEMENT_PARAM_CLASS(BlockSize, int);
|
namespace
|
||||||
IMPLEMENT_PARAM_CLASS(ApertureSize, int);
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(BlockSize, int);
|
||||||
|
IMPLEMENT_PARAM_CLASS(ApertureSize, int);
|
||||||
|
}
|
||||||
|
|
||||||
PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderType, BlockSize, ApertureSize)
|
PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderType, BlockSize, ApertureSize)
|
||||||
{
|
{
|
||||||
@ -1059,7 +1084,7 @@ PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderType, BlockSiz
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CornerHarris, Accuracy)
|
GPU_TEST_P(CornerHarris, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
|
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
|
||||||
ASSERT_FALSE(src.empty());
|
ASSERT_FALSE(src.empty());
|
||||||
@ -1105,7 +1130,7 @@ PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, BorderType, BlockS
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CornerMinEigen, Accuracy)
|
GPU_TEST_P(CornerMinEigen, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
|
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
|
||||||
ASSERT_FALSE(src.empty());
|
ASSERT_FALSE(src.empty());
|
||||||
@ -1126,6 +1151,4 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CornerMinEigen, testing::Combine(
|
|||||||
testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)),
|
testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)),
|
||||||
testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7))));
|
testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7))));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
struct GreedyLabeling
|
struct GreedyLabeling
|
||||||
{
|
{
|
||||||
struct dot
|
struct dot
|
||||||
@ -166,7 +166,7 @@ struct Labeling : testing::TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Labeling, ConnectedComponents)
|
GPU_TEST_P(Labeling, ConnectedComponents)
|
||||||
{
|
{
|
||||||
cv::Mat image;
|
cv::Mat image;
|
||||||
cvtColor(loat_image(), image, CV_BGR2GRAY);
|
cvtColor(loat_image(), image, CV_BGR2GRAY);
|
||||||
@ -191,6 +191,6 @@ TEST_P(Labeling, ConnectedComponents)
|
|||||||
host.checkCorrectness(cv::Mat(components));
|
host.checkCorrectness(cv::Mat(components));
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(ConnectedComponents, Labeling, ALL_DEVICES);
|
INSTANTIATE_TEST_CASE_P(GPU_ConnectedComponents, Labeling, ALL_DEVICES);
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -41,11 +41,9 @@
|
|||||||
|
|
||||||
#include "test_precomp.hpp"
|
#include "test_precomp.hpp"
|
||||||
|
|
||||||
#if defined HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
OutputLevel nvidiaTestOutputLevel = OutputLevelNone;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined HAVE_CUDA && !defined(CUDA_DISABLER)
|
OutputLevel nvidiaTestOutputLevel = OutputLevelNone;
|
||||||
|
|
||||||
using namespace cvtest;
|
using namespace cvtest;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
@ -69,77 +67,77 @@ struct NVidiaTest : TestWithParam<cv::gpu::DeviceInfo>
|
|||||||
struct NPPST : NVidiaTest {};
|
struct NPPST : NVidiaTest {};
|
||||||
struct NCV : NVidiaTest {};
|
struct NCV : NVidiaTest {};
|
||||||
|
|
||||||
//TEST_P(NPPST, Integral)
|
GPU_TEST_P(NPPST, Integral)
|
||||||
//{
|
{
|
||||||
// bool res = nvidia_NPPST_Integral_Image(path, nvidiaTestOutputLevel);
|
bool res = nvidia_NPPST_Integral_Image(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
// ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
//}
|
}
|
||||||
|
|
||||||
TEST_P(NPPST, SquaredIntegral)
|
GPU_TEST_P(NPPST, SquaredIntegral)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NPPST_Squared_Integral_Image(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NPPST_Squared_Integral_Image(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NPPST, RectStdDev)
|
GPU_TEST_P(NPPST, RectStdDev)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NPPST_RectStdDev(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NPPST_RectStdDev(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NPPST, Resize)
|
GPU_TEST_P(NPPST, Resize)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NPPST_Resize(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NPPST_Resize(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NPPST, VectorOperations)
|
GPU_TEST_P(NPPST, VectorOperations)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NPPST_Vector_Operations(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NPPST_Vector_Operations(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NPPST, Transpose)
|
GPU_TEST_P(NPPST, Transpose)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NPPST_Transpose(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NPPST_Transpose(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NCV, VectorOperations)
|
GPU_TEST_P(NCV, VectorOperations)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NCV_Vector_Operations(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NCV_Vector_Operations(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NCV, HaarCascadeLoader)
|
GPU_TEST_P(NCV, HaarCascadeLoader)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NCV_Haar_Cascade_Loader(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NCV_Haar_Cascade_Loader(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NCV, HaarCascadeApplication)
|
GPU_TEST_P(NCV, HaarCascadeApplication)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NCV_Haar_Cascade_Application(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NCV_Haar_Cascade_Application(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NCV, HypothesesFiltration)
|
GPU_TEST_P(NCV, HypothesesFiltration)
|
||||||
{
|
{
|
||||||
bool res = nvidia_NCV_Hypotheses_Filtration(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NCV_Hypotheses_Filtration(_path, nvidiaTestOutputLevel);
|
||||||
|
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NCV, Visualization)
|
GPU_TEST_P(NCV, Visualization)
|
||||||
{
|
{
|
||||||
// this functionality doesn't used in gpu module
|
// this functionality doesn't used in gpu module
|
||||||
bool res = nvidia_NCV_Visualization(_path, nvidiaTestOutputLevel);
|
bool res = nvidia_NCV_Visualization(_path, nvidiaTestOutputLevel);
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
//#define DUMP
|
//#define DUMP
|
||||||
|
|
||||||
struct HOG : testing::TestWithParam<cv::gpu::DeviceInfo>, cv::gpu::HOGDescriptor
|
struct HOG : testing::TestWithParam<cv::gpu::DeviceInfo>, cv::gpu::HOGDescriptor
|
||||||
@ -176,7 +174,7 @@ struct HOG : testing::TestWithParam<cv::gpu::DeviceInfo>, cv::gpu::HOGDescriptor
|
|||||||
};
|
};
|
||||||
|
|
||||||
// desabled while resize does not fixed
|
// desabled while resize does not fixed
|
||||||
TEST_P(HOG, DISABLED_Detect)
|
GPU_TEST_P(HOG, Detect)
|
||||||
{
|
{
|
||||||
cv::Mat img_rgb = readImage("hog/road.png");
|
cv::Mat img_rgb = readImage("hog/road.png");
|
||||||
ASSERT_FALSE(img_rgb.empty());
|
ASSERT_FALSE(img_rgb.empty());
|
||||||
@ -201,7 +199,7 @@ TEST_P(HOG, DISABLED_Detect)
|
|||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(HOG, GetDescriptors)
|
GPU_TEST_P(HOG, GetDescriptors)
|
||||||
{
|
{
|
||||||
// Load image (e.g. train data, composed from windows)
|
// Load image (e.g. train data, composed from windows)
|
||||||
cv::Mat img_rgb = readImage("hog/train_data.png");
|
cv::Mat img_rgb = readImage("hog/train_data.png");
|
||||||
@ -288,6 +286,7 @@ TEST_P(HOG, GetDescriptors)
|
|||||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, HOG, ALL_DEVICES);
|
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, HOG, ALL_DEVICES);
|
||||||
|
|
||||||
//============== caltech hog tests =====================//
|
//============== caltech hog tests =====================//
|
||||||
|
|
||||||
struct CalTech : public ::testing::TestWithParam<std::tr1::tuple<cv::gpu::DeviceInfo, std::string> >
|
struct CalTech : public ::testing::TestWithParam<std::tr1::tuple<cv::gpu::DeviceInfo, std::string> >
|
||||||
{
|
{
|
||||||
cv::gpu::DeviceInfo devInfo;
|
cv::gpu::DeviceInfo devInfo;
|
||||||
@ -303,7 +302,7 @@ struct CalTech : public ::testing::TestWithParam<std::tr1::tuple<cv::gpu::Device
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(CalTech, HOG)
|
GPU_TEST_P(CalTech, HOG)
|
||||||
{
|
{
|
||||||
cv::gpu::GpuMat d_img(img);
|
cv::gpu::GpuMat d_img(img);
|
||||||
cv::Mat markedImage(img.clone());
|
cv::Mat markedImage(img.clone());
|
||||||
@ -350,7 +349,7 @@ PARAM_TEST_CASE(LBP_Read_classifier, cv::gpu::DeviceInfo, int)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(LBP_Read_classifier, Accuracy)
|
GPU_TEST_P(LBP_Read_classifier, Accuracy)
|
||||||
{
|
{
|
||||||
cv::gpu::CascadeClassifier_GPU classifier;
|
cv::gpu::CascadeClassifier_GPU classifier;
|
||||||
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
|
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
|
||||||
@ -372,7 +371,7 @@ PARAM_TEST_CASE(LBP_classify, cv::gpu::DeviceInfo, int)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(LBP_classify, Accuracy)
|
GPU_TEST_P(LBP_classify, Accuracy)
|
||||||
{
|
{
|
||||||
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
|
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
|
||||||
std::string imagePath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/er.png";
|
std::string imagePath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/er.png";
|
||||||
@ -422,6 +421,4 @@ TEST_P(LBP_classify, Accuracy)
|
|||||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify,
|
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify,
|
||||||
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
@ -68,7 +68,7 @@ PARAM_TEST_CASE(GlBuffer, cv::Size, MatType)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(GlBuffer, Constructor1)
|
GPU_TEST_P(GlBuffer, Constructor1)
|
||||||
{
|
{
|
||||||
cv::GlBuffer buf(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
cv::GlBuffer buf(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ TEST_P(GlBuffer, Constructor1)
|
|||||||
EXPECT_EQ(type, buf.type());
|
EXPECT_EQ(type, buf.type());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, Constructor2)
|
GPU_TEST_P(GlBuffer, Constructor2)
|
||||||
{
|
{
|
||||||
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ TEST_P(GlBuffer, Constructor2)
|
|||||||
EXPECT_EQ(type, buf.type());
|
EXPECT_EQ(type, buf.type());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, ConstructorFromMat)
|
GPU_TEST_P(GlBuffer, ConstructorFromMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ TEST_P(GlBuffer, ConstructorFromMat)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, ConstructorFromGpuMat)
|
GPU_TEST_P(GlBuffer, ConstructorFromGpuMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
cv::gpu::GpuMat d_gold(gold);
|
cv::gpu::GpuMat d_gold(gold);
|
||||||
@ -111,7 +111,7 @@ TEST_P(GlBuffer, ConstructorFromGpuMat)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, ConstructorFromGlBuffer)
|
GPU_TEST_P(GlBuffer, ConstructorFromGlBuffer)
|
||||||
{
|
{
|
||||||
cv::GlBuffer buf_gold(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
cv::GlBuffer buf_gold(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ TEST_P(GlBuffer, ConstructorFromGlBuffer)
|
|||||||
EXPECT_EQ(buf_gold.type(), buf.type());
|
EXPECT_EQ(buf_gold.type(), buf.type());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, ConstructorFromGlTexture2D)
|
GPU_TEST_P(GlBuffer, ConstructorFromGlTexture2D)
|
||||||
{
|
{
|
||||||
const int depth = CV_MAT_DEPTH(type);
|
const int depth = CV_MAT_DEPTH(type);
|
||||||
const int cn = CV_MAT_CN(type);
|
const int cn = CV_MAT_CN(type);
|
||||||
@ -142,7 +142,7 @@ TEST_P(GlBuffer, ConstructorFromGlTexture2D)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
|
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, Create)
|
GPU_TEST_P(GlBuffer, Create)
|
||||||
{
|
{
|
||||||
cv::GlBuffer buf;
|
cv::GlBuffer buf;
|
||||||
buf.create(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
buf.create(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
|
||||||
@ -152,7 +152,7 @@ TEST_P(GlBuffer, Create)
|
|||||||
EXPECT_EQ(type, buf.type());
|
EXPECT_EQ(type, buf.type());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, CopyFromMat)
|
GPU_TEST_P(GlBuffer, CopyFromMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ TEST_P(GlBuffer, CopyFromMat)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, CopyFromGpuMat)
|
GPU_TEST_P(GlBuffer, CopyFromGpuMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
cv::gpu::GpuMat d_gold(gold);
|
cv::gpu::GpuMat d_gold(gold);
|
||||||
@ -179,7 +179,7 @@ TEST_P(GlBuffer, CopyFromGpuMat)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, CopyFromGlBuffer)
|
GPU_TEST_P(GlBuffer, CopyFromGlBuffer)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
cv::GlBuffer buf_gold(gold, cv::GlBuffer::ARRAY_BUFFER, true);
|
cv::GlBuffer buf_gold(gold, cv::GlBuffer::ARRAY_BUFFER, true);
|
||||||
@ -195,7 +195,7 @@ TEST_P(GlBuffer, CopyFromGlBuffer)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, CopyFromGlTexture2D)
|
GPU_TEST_P(GlBuffer, CopyFromGlTexture2D)
|
||||||
{
|
{
|
||||||
const int depth = CV_MAT_DEPTH(type);
|
const int depth = CV_MAT_DEPTH(type);
|
||||||
const int cn = CV_MAT_CN(type);
|
const int cn = CV_MAT_CN(type);
|
||||||
@ -215,7 +215,7 @@ TEST_P(GlBuffer, CopyFromGlTexture2D)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
|
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, CopyToGpuMat)
|
GPU_TEST_P(GlBuffer, CopyToGpuMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ TEST_P(GlBuffer, CopyToGpuMat)
|
|||||||
EXPECT_MAT_NEAR(gold, dst, 0);
|
EXPECT_MAT_NEAR(gold, dst, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, CopyToGlBuffer)
|
GPU_TEST_P(GlBuffer, CopyToGlBuffer)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ TEST_P(GlBuffer, CopyToGlBuffer)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, CopyToGlTexture2D)
|
GPU_TEST_P(GlBuffer, CopyToGlTexture2D)
|
||||||
{
|
{
|
||||||
const int depth = CV_MAT_DEPTH(type);
|
const int depth = CV_MAT_DEPTH(type);
|
||||||
const int cn = CV_MAT_CN(type);
|
const int cn = CV_MAT_CN(type);
|
||||||
@ -265,7 +265,7 @@ TEST_P(GlBuffer, CopyToGlTexture2D)
|
|||||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, Clone)
|
GPU_TEST_P(GlBuffer, Clone)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ TEST_P(GlBuffer, Clone)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, MapHostRead)
|
GPU_TEST_P(GlBuffer, MapHostRead)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ TEST_P(GlBuffer, MapHostRead)
|
|||||||
buf.unmapHost();
|
buf.unmapHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, MapHostWrite)
|
GPU_TEST_P(GlBuffer, MapHostWrite)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ TEST_P(GlBuffer, MapHostWrite)
|
|||||||
EXPECT_MAT_NEAR(gold, bufData, 0);
|
EXPECT_MAT_NEAR(gold, bufData, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlBuffer, MapDevice)
|
GPU_TEST_P(GlBuffer, MapDevice)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type);
|
cv::Mat gold = randomMat(size, type);
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ PARAM_TEST_CASE(GlTexture2D, cv::Size, MatType)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(GlTexture2D, Constructor1)
|
GPU_TEST_P(GlTexture2D, Constructor1)
|
||||||
{
|
{
|
||||||
cv::GlTexture2D tex(size.height, size.width, format, true);
|
cv::GlTexture2D tex(size.height, size.width, format, true);
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ TEST_P(GlTexture2D, Constructor1)
|
|||||||
EXPECT_EQ(format, tex.format());
|
EXPECT_EQ(format, tex.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, Constructor2)
|
GPU_TEST_P(GlTexture2D, Constructor2)
|
||||||
{
|
{
|
||||||
cv::GlTexture2D tex(size, format, true);
|
cv::GlTexture2D tex(size, format, true);
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ TEST_P(GlTexture2D, Constructor2)
|
|||||||
EXPECT_EQ(format, tex.format());
|
EXPECT_EQ(format, tex.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, ConstructorFromMat)
|
GPU_TEST_P(GlTexture2D, ConstructorFromMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ TEST_P(GlTexture2D, ConstructorFromMat)
|
|||||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, ConstructorFromGpuMat)
|
GPU_TEST_P(GlTexture2D, ConstructorFromGpuMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
cv::gpu::GpuMat d_gold(gold);
|
cv::gpu::GpuMat d_gold(gold);
|
||||||
@ -401,7 +401,7 @@ TEST_P(GlTexture2D, ConstructorFromGpuMat)
|
|||||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, ConstructorFromGlBuffer)
|
GPU_TEST_P(GlTexture2D, ConstructorFromGlBuffer)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
|
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
|
||||||
@ -414,7 +414,7 @@ TEST_P(GlTexture2D, ConstructorFromGlBuffer)
|
|||||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, ConstructorFromGlTexture2D)
|
GPU_TEST_P(GlTexture2D, ConstructorFromGlTexture2D)
|
||||||
{
|
{
|
||||||
cv::GlTexture2D tex_gold(size, format, true);
|
cv::GlTexture2D tex_gold(size, format, true);
|
||||||
cv::GlTexture2D tex(tex_gold);
|
cv::GlTexture2D tex(tex_gold);
|
||||||
@ -425,7 +425,7 @@ TEST_P(GlTexture2D, ConstructorFromGlTexture2D)
|
|||||||
EXPECT_EQ(tex_gold.format(), tex.format());
|
EXPECT_EQ(tex_gold.format(), tex.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, Create)
|
GPU_TEST_P(GlTexture2D, Create)
|
||||||
{
|
{
|
||||||
cv::GlTexture2D tex;
|
cv::GlTexture2D tex;
|
||||||
tex.create(size.height, size.width, format, true);
|
tex.create(size.height, size.width, format, true);
|
||||||
@ -435,7 +435,7 @@ TEST_P(GlTexture2D, Create)
|
|||||||
EXPECT_EQ(format, tex.format());
|
EXPECT_EQ(format, tex.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, CopyFromMat)
|
GPU_TEST_P(GlTexture2D, CopyFromMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ TEST_P(GlTexture2D, CopyFromMat)
|
|||||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, CopyFromGpuMat)
|
GPU_TEST_P(GlTexture2D, CopyFromGpuMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
cv::gpu::GpuMat d_gold(gold);
|
cv::gpu::GpuMat d_gold(gold);
|
||||||
@ -462,7 +462,7 @@ TEST_P(GlTexture2D, CopyFromGpuMat)
|
|||||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, CopyFromGlBuffer)
|
GPU_TEST_P(GlTexture2D, CopyFromGlBuffer)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
|
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
|
||||||
@ -476,7 +476,7 @@ TEST_P(GlTexture2D, CopyFromGlBuffer)
|
|||||||
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
EXPECT_MAT_NEAR(gold, texData, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, CopyToGpuMat)
|
GPU_TEST_P(GlTexture2D, CopyToGpuMat)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ TEST_P(GlTexture2D, CopyToGpuMat)
|
|||||||
EXPECT_MAT_NEAR(gold, dst, 1e-2);
|
EXPECT_MAT_NEAR(gold, dst, 1e-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(GlTexture2D, CopyToGlBuffer)
|
GPU_TEST_P(GlTexture2D, CopyToGlBuffer)
|
||||||
{
|
{
|
||||||
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
|
||||||
|
|
||||||
|
623
modules/gpu/test/test_optflow.cpp
Normal file
623
modules/gpu/test/test_optflow.cpp
Normal file
@ -0,0 +1,623 @@
|
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Intel License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "test_precomp.hpp"
|
||||||
|
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// BroxOpticalFlow
|
||||||
|
|
||||||
|
//#define BROX_DUMP
|
||||||
|
|
||||||
|
struct BroxOpticalFlow : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GetParam();
|
||||||
|
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(BroxOpticalFlow, Regression)
|
||||||
|
{
|
||||||
|
cv::Mat frame0 = readImageType("opticalflow/frame0.png", CV_32FC1);
|
||||||
|
ASSERT_FALSE(frame0.empty());
|
||||||
|
|
||||||
|
cv::Mat frame1 = readImageType("opticalflow/frame1.png", CV_32FC1);
|
||||||
|
ASSERT_FALSE(frame1.empty());
|
||||||
|
|
||||||
|
cv::gpu::BroxOpticalFlow brox(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||||
|
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat u;
|
||||||
|
cv::gpu::GpuMat v;
|
||||||
|
brox(loadMat(frame0), loadMat(frame1), u, v);
|
||||||
|
|
||||||
|
std::string fname(cvtest::TS::ptr()->get_data_path());
|
||||||
|
if (devInfo.majorVersion() >= 2)
|
||||||
|
fname += "opticalflow/brox_optical_flow_cc20.bin";
|
||||||
|
else
|
||||||
|
fname += "opticalflow/brox_optical_flow.bin";
|
||||||
|
|
||||||
|
#ifndef BROX_DUMP
|
||||||
|
std::ifstream f(fname.c_str(), std::ios_base::binary);
|
||||||
|
|
||||||
|
int rows, cols;
|
||||||
|
|
||||||
|
f.read((char*) &rows, sizeof(rows));
|
||||||
|
f.read((char*) &cols, sizeof(cols));
|
||||||
|
|
||||||
|
cv::Mat u_gold(rows, cols, CV_32FC1);
|
||||||
|
|
||||||
|
for (int i = 0; i < u_gold.rows; ++i)
|
||||||
|
f.read(u_gold.ptr<char>(i), u_gold.cols * sizeof(float));
|
||||||
|
|
||||||
|
cv::Mat v_gold(rows, cols, CV_32FC1);
|
||||||
|
|
||||||
|
for (int i = 0; i < v_gold.rows; ++i)
|
||||||
|
f.read(v_gold.ptr<char>(i), v_gold.cols * sizeof(float));
|
||||||
|
|
||||||
|
EXPECT_MAT_NEAR(u_gold, u, 0);
|
||||||
|
EXPECT_MAT_NEAR(v_gold, v, 0);
|
||||||
|
#else
|
||||||
|
std::ofstream f(fname.c_str(), std::ios_base::binary);
|
||||||
|
|
||||||
|
f.write((char*) &u.rows, sizeof(u.rows));
|
||||||
|
f.write((char*) &u.cols, sizeof(u.cols));
|
||||||
|
|
||||||
|
cv::Mat h_u(u);
|
||||||
|
cv::Mat h_v(v);
|
||||||
|
|
||||||
|
for (int i = 0; i < u.rows; ++i)
|
||||||
|
f.write(h_u.ptr<char>(i), u.cols * sizeof(float));
|
||||||
|
|
||||||
|
for (int i = 0; i < v.rows; ++i)
|
||||||
|
f.write(h_v.ptr<char>(i), v.cols * sizeof(float));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
GPU_TEST_P(BroxOpticalFlow, OpticalFlowNan)
|
||||||
|
{
|
||||||
|
cv::Mat frame0 = readImageType("opticalflow/frame0.png", CV_32FC1);
|
||||||
|
ASSERT_FALSE(frame0.empty());
|
||||||
|
|
||||||
|
cv::Mat frame1 = readImageType("opticalflow/frame1.png", CV_32FC1);
|
||||||
|
ASSERT_FALSE(frame1.empty());
|
||||||
|
|
||||||
|
cv::Mat r_frame0, r_frame1;
|
||||||
|
cv::resize(frame0, r_frame0, cv::Size(1380,1000));
|
||||||
|
cv::resize(frame1, r_frame1, cv::Size(1380,1000));
|
||||||
|
|
||||||
|
cv::gpu::BroxOpticalFlow brox(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||||
|
5 /*inner_iterations*/, 150 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat u;
|
||||||
|
cv::gpu::GpuMat v;
|
||||||
|
brox(loadMat(r_frame0), loadMat(r_frame1), u, v);
|
||||||
|
|
||||||
|
cv::Mat h_u, h_v;
|
||||||
|
u.download(h_u);
|
||||||
|
v.download(h_v);
|
||||||
|
|
||||||
|
EXPECT_TRUE(cv::checkRange(h_u));
|
||||||
|
EXPECT_TRUE(cv::checkRange(h_v));
|
||||||
|
};
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, BroxOpticalFlow, ALL_DEVICES);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// GoodFeaturesToTrack
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(MinDistance, double)
|
||||||
|
}
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(GoodFeaturesToTrack, cv::gpu::DeviceInfo, MinDistance)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
double minDistance;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
minDistance = GET_PARAM(1);
|
||||||
|
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(GoodFeaturesToTrack, Accuracy)
|
||||||
|
{
|
||||||
|
cv::Mat image = readImage("opticalflow/frame0.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(image.empty());
|
||||||
|
|
||||||
|
int maxCorners = 1000;
|
||||||
|
double qualityLevel = 0.01;
|
||||||
|
|
||||||
|
cv::gpu::GoodFeaturesToTrackDetector_GPU detector(maxCorners, qualityLevel, minDistance);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_pts;
|
||||||
|
detector(loadMat(image), d_pts);
|
||||||
|
|
||||||
|
ASSERT_FALSE(d_pts.empty());
|
||||||
|
|
||||||
|
std::vector<cv::Point2f> pts(d_pts.cols);
|
||||||
|
cv::Mat pts_mat(1, d_pts.cols, CV_32FC2, (void*) &pts[0]);
|
||||||
|
d_pts.download(pts_mat);
|
||||||
|
|
||||||
|
std::vector<cv::Point2f> pts_gold;
|
||||||
|
cv::goodFeaturesToTrack(image, pts_gold, maxCorners, qualityLevel, minDistance);
|
||||||
|
|
||||||
|
ASSERT_EQ(pts_gold.size(), pts.size());
|
||||||
|
|
||||||
|
size_t mistmatch = 0;
|
||||||
|
for (size_t i = 0; i < pts.size(); ++i)
|
||||||
|
{
|
||||||
|
cv::Point2i a = pts_gold[i];
|
||||||
|
cv::Point2i b = pts[i];
|
||||||
|
|
||||||
|
bool eq = std::abs(a.x - b.x) < 1 && std::abs(a.y - b.y) < 1;
|
||||||
|
|
||||||
|
if (!eq)
|
||||||
|
++mistmatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
double bad_ratio = static_cast<double>(mistmatch) / pts.size();
|
||||||
|
|
||||||
|
ASSERT_LE(bad_ratio, 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
GPU_TEST_P(GoodFeaturesToTrack, EmptyCorners)
|
||||||
|
{
|
||||||
|
int maxCorners = 1000;
|
||||||
|
double qualityLevel = 0.01;
|
||||||
|
|
||||||
|
cv::gpu::GoodFeaturesToTrackDetector_GPU detector(maxCorners, qualityLevel, minDistance);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat src(100, 100, CV_8UC1, cv::Scalar::all(0));
|
||||||
|
cv::gpu::GpuMat corners(1, maxCorners, CV_32FC2);
|
||||||
|
|
||||||
|
detector(src, corners);
|
||||||
|
|
||||||
|
ASSERT_TRUE(corners.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, GoodFeaturesToTrack, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
testing::Values(MinDistance(0.0), MinDistance(3.0))));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// PyrLKOpticalFlow
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(UseGray, bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(PyrLKOpticalFlow, cv::gpu::DeviceInfo, UseGray)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
bool useGray;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
useGray = GET_PARAM(1);
|
||||||
|
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(PyrLKOpticalFlow, Sparse)
|
||||||
|
{
|
||||||
|
cv::Mat frame0 = readImage("opticalflow/frame0.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
|
||||||
|
ASSERT_FALSE(frame0.empty());
|
||||||
|
|
||||||
|
cv::Mat frame1 = readImage("opticalflow/frame1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
|
||||||
|
ASSERT_FALSE(frame1.empty());
|
||||||
|
|
||||||
|
cv::Mat gray_frame;
|
||||||
|
if (useGray)
|
||||||
|
gray_frame = frame0;
|
||||||
|
else
|
||||||
|
cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY);
|
||||||
|
|
||||||
|
std::vector<cv::Point2f> pts;
|
||||||
|
cv::goodFeaturesToTrack(gray_frame, pts, 1000, 0.01, 0.0);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_pts;
|
||||||
|
cv::Mat pts_mat(1, (int) pts.size(), CV_32FC2, (void*) &pts[0]);
|
||||||
|
d_pts.upload(pts_mat);
|
||||||
|
|
||||||
|
cv::gpu::PyrLKOpticalFlow pyrLK;
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_nextPts;
|
||||||
|
cv::gpu::GpuMat d_status;
|
||||||
|
pyrLK.sparse(loadMat(frame0), loadMat(frame1), d_pts, d_nextPts, d_status);
|
||||||
|
|
||||||
|
std::vector<cv::Point2f> nextPts(d_nextPts.cols);
|
||||||
|
cv::Mat nextPts_mat(1, d_nextPts.cols, CV_32FC2, (void*) &nextPts[0]);
|
||||||
|
d_nextPts.download(nextPts_mat);
|
||||||
|
|
||||||
|
std::vector<unsigned char> status(d_status.cols);
|
||||||
|
cv::Mat status_mat(1, d_status.cols, CV_8UC1, (void*) &status[0]);
|
||||||
|
d_status.download(status_mat);
|
||||||
|
|
||||||
|
std::vector<cv::Point2f> nextPts_gold;
|
||||||
|
std::vector<unsigned char> status_gold;
|
||||||
|
cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts_gold, status_gold, cv::noArray());
|
||||||
|
|
||||||
|
ASSERT_EQ(nextPts_gold.size(), nextPts.size());
|
||||||
|
ASSERT_EQ(status_gold.size(), status.size());
|
||||||
|
|
||||||
|
size_t mistmatch = 0;
|
||||||
|
for (size_t i = 0; i < nextPts.size(); ++i)
|
||||||
|
{
|
||||||
|
cv::Point2i a = nextPts[i];
|
||||||
|
cv::Point2i b = nextPts_gold[i];
|
||||||
|
|
||||||
|
if (status[i] != status_gold[i])
|
||||||
|
{
|
||||||
|
++mistmatch;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status[i])
|
||||||
|
{
|
||||||
|
bool eq = std::abs(a.x - b.x) <= 1 && std::abs(a.y - b.y) <= 1;
|
||||||
|
|
||||||
|
if (!eq)
|
||||||
|
++mistmatch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double bad_ratio = static_cast<double>(mistmatch) / nextPts.size();
|
||||||
|
|
||||||
|
ASSERT_LE(bad_ratio, 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, PyrLKOpticalFlow, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
testing::Values(UseGray(true), UseGray(false))));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// FarnebackOpticalFlow
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
IMPLEMENT_PARAM_CLASS(PyrScale, double)
|
||||||
|
IMPLEMENT_PARAM_CLASS(PolyN, int)
|
||||||
|
CV_FLAGS(FarnebackOptFlowFlags, 0, cv::OPTFLOW_FARNEBACK_GAUSSIAN)
|
||||||
|
IMPLEMENT_PARAM_CLASS(UseInitFlow, bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(FarnebackOpticalFlow, cv::gpu::DeviceInfo, PyrScale, PolyN, FarnebackOptFlowFlags, UseInitFlow)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
double pyrScale;
|
||||||
|
int polyN;
|
||||||
|
int flags;
|
||||||
|
bool useInitFlow;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
pyrScale = GET_PARAM(1);
|
||||||
|
polyN = GET_PARAM(2);
|
||||||
|
flags = GET_PARAM(3);
|
||||||
|
useInitFlow = GET_PARAM(4);
|
||||||
|
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(FarnebackOpticalFlow, Accuracy)
|
||||||
|
{
|
||||||
|
cv::Mat frame0 = readImage("opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame0.empty());
|
||||||
|
|
||||||
|
cv::Mat frame1 = readImage("opticalflow/rubberwhale2.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame1.empty());
|
||||||
|
|
||||||
|
double polySigma = polyN <= 5 ? 1.1 : 1.5;
|
||||||
|
|
||||||
|
cv::gpu::FarnebackOpticalFlow farn;
|
||||||
|
farn.pyrScale = pyrScale;
|
||||||
|
farn.polyN = polyN;
|
||||||
|
farn.polySigma = polySigma;
|
||||||
|
farn.flags = flags;
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_flowx, d_flowy;
|
||||||
|
farn(loadMat(frame0), loadMat(frame1), d_flowx, d_flowy);
|
||||||
|
|
||||||
|
cv::Mat flow;
|
||||||
|
if (useInitFlow)
|
||||||
|
{
|
||||||
|
cv::Mat flowxy[] = {cv::Mat(d_flowx), cv::Mat(d_flowy)};
|
||||||
|
cv::merge(flowxy, 2, flow);
|
||||||
|
|
||||||
|
farn.flags |= cv::OPTFLOW_USE_INITIAL_FLOW;
|
||||||
|
farn(loadMat(frame0), loadMat(frame1), d_flowx, d_flowy);
|
||||||
|
}
|
||||||
|
|
||||||
|
cv::calcOpticalFlowFarneback(
|
||||||
|
frame0, frame1, flow, farn.pyrScale, farn.numLevels, farn.winSize,
|
||||||
|
farn.numIters, farn.polyN, farn.polySigma, farn.flags);
|
||||||
|
|
||||||
|
std::vector<cv::Mat> flowxy;
|
||||||
|
cv::split(flow, flowxy);
|
||||||
|
|
||||||
|
EXPECT_MAT_SIMILAR(flowxy[0], d_flowx, 0.1);
|
||||||
|
EXPECT_MAT_SIMILAR(flowxy[1], d_flowy, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, FarnebackOpticalFlow, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
testing::Values(PyrScale(0.3), PyrScale(0.5), PyrScale(0.8)),
|
||||||
|
testing::Values(PolyN(5), PolyN(7)),
|
||||||
|
testing::Values(FarnebackOptFlowFlags(0), FarnebackOptFlowFlags(cv::OPTFLOW_FARNEBACK_GAUSSIAN)),
|
||||||
|
testing::Values(UseInitFlow(false), UseInitFlow(true))));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// OpticalFlowDual_TVL1
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(OpticalFlowDual_TVL1, cv::gpu::DeviceInfo, UseRoi)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
bool useRoi;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
useRoi = GET_PARAM(1);
|
||||||
|
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(OpticalFlowDual_TVL1, Accuracy)
|
||||||
|
{
|
||||||
|
cv::Mat frame0 = readImage("opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame0.empty());
|
||||||
|
|
||||||
|
cv::Mat frame1 = readImage("opticalflow/rubberwhale2.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame1.empty());
|
||||||
|
|
||||||
|
cv::gpu::OpticalFlowDual_TVL1_GPU d_alg;
|
||||||
|
cv::gpu::GpuMat d_flowx = createMat(frame0.size(), CV_32FC1, useRoi);
|
||||||
|
cv::gpu::GpuMat d_flowy = createMat(frame0.size(), CV_32FC1, useRoi);
|
||||||
|
d_alg(loadMat(frame0, useRoi), loadMat(frame1, useRoi), d_flowx, d_flowy);
|
||||||
|
|
||||||
|
cv::OpticalFlowDual_TVL1 alg;
|
||||||
|
cv::Mat flow;
|
||||||
|
alg(frame0, frame1, flow);
|
||||||
|
cv::Mat gold[2];
|
||||||
|
cv::split(flow, gold);
|
||||||
|
|
||||||
|
EXPECT_MAT_SIMILAR(gold[0], d_flowx, 3e-3);
|
||||||
|
EXPECT_MAT_SIMILAR(gold[1], d_flowy, 3e-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, OpticalFlowDual_TVL1, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// OpticalFlowBM
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void calcOpticalFlowBM(const cv::Mat& prev, const cv::Mat& curr,
|
||||||
|
cv::Size bSize, cv::Size shiftSize, cv::Size maxRange, int usePrevious,
|
||||||
|
cv::Mat& velx, cv::Mat& vely)
|
||||||
|
{
|
||||||
|
cv::Size sz((curr.cols - bSize.width + shiftSize.width)/shiftSize.width, (curr.rows - bSize.height + shiftSize.height)/shiftSize.height);
|
||||||
|
|
||||||
|
velx.create(sz, CV_32FC1);
|
||||||
|
vely.create(sz, CV_32FC1);
|
||||||
|
|
||||||
|
CvMat cvprev = prev;
|
||||||
|
CvMat cvcurr = curr;
|
||||||
|
|
||||||
|
CvMat cvvelx = velx;
|
||||||
|
CvMat cvvely = vely;
|
||||||
|
|
||||||
|
cvCalcOpticalFlowBM(&cvprev, &cvcurr, bSize, shiftSize, maxRange, usePrevious, &cvvelx, &cvvely);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct OpticalFlowBM : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(OpticalFlowBM, Accuracy)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
|
||||||
|
cv::Mat frame0 = readImage("opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame0.empty());
|
||||||
|
|
||||||
|
cv::Mat frame1 = readImage("opticalflow/rubberwhale2.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame1.empty());
|
||||||
|
|
||||||
|
cv::Size block_size(16, 16);
|
||||||
|
cv::Size shift_size(1, 1);
|
||||||
|
cv::Size max_range(16, 16);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_velx, d_vely, buf;
|
||||||
|
cv::gpu::calcOpticalFlowBM(loadMat(frame0), loadMat(frame1),
|
||||||
|
block_size, shift_size, max_range, false,
|
||||||
|
d_velx, d_vely, buf);
|
||||||
|
|
||||||
|
cv::Mat velx, vely;
|
||||||
|
calcOpticalFlowBM(frame0, frame1, block_size, shift_size, max_range, false, velx, vely);
|
||||||
|
|
||||||
|
EXPECT_MAT_NEAR(velx, d_velx, 0);
|
||||||
|
EXPECT_MAT_NEAR(vely, d_vely, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, OpticalFlowBM, ALL_DEVICES);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// FastOpticalFlowBM
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void FastOpticalFlowBM_gold(const cv::Mat_<uchar>& I0, const cv::Mat_<uchar>& I1, cv::Mat_<float>& velx, cv::Mat_<float>& vely, int search_window, int block_window)
|
||||||
|
{
|
||||||
|
velx.create(I0.size());
|
||||||
|
vely.create(I0.size());
|
||||||
|
|
||||||
|
int search_radius = search_window / 2;
|
||||||
|
int block_radius = block_window / 2;
|
||||||
|
|
||||||
|
for (int y = 0; y < I0.rows; ++y)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < I0.cols; ++x)
|
||||||
|
{
|
||||||
|
int bestDist = std::numeric_limits<int>::max();
|
||||||
|
int bestDx = 0;
|
||||||
|
int bestDy = 0;
|
||||||
|
|
||||||
|
for (int dy = -search_radius; dy <= search_radius; ++dy)
|
||||||
|
{
|
||||||
|
for (int dx = -search_radius; dx <= search_radius; ++dx)
|
||||||
|
{
|
||||||
|
int dist = 0;
|
||||||
|
|
||||||
|
for (int by = -block_radius; by <= block_radius; ++by)
|
||||||
|
{
|
||||||
|
for (int bx = -block_radius; bx <= block_radius; ++bx)
|
||||||
|
{
|
||||||
|
int I0_val = I0(cv::borderInterpolate(y + by, I0.rows, cv::BORDER_DEFAULT), cv::borderInterpolate(x + bx, I0.cols, cv::BORDER_DEFAULT));
|
||||||
|
int I1_val = I1(cv::borderInterpolate(y + dy + by, I0.rows, cv::BORDER_DEFAULT), cv::borderInterpolate(x + dx + bx, I0.cols, cv::BORDER_DEFAULT));
|
||||||
|
|
||||||
|
dist += std::abs(I0_val - I1_val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dist < bestDist)
|
||||||
|
{
|
||||||
|
bestDist = dist;
|
||||||
|
bestDx = dx;
|
||||||
|
bestDy = dy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
velx(y, x) = (float) bestDx;
|
||||||
|
vely(y, x) = (float) bestDy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double calc_rmse(const cv::Mat_<float>& flow1, const cv::Mat_<float>& flow2)
|
||||||
|
{
|
||||||
|
double sum = 0.0;
|
||||||
|
|
||||||
|
for (int y = 0; y < flow1.rows; ++y)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < flow1.cols; ++x)
|
||||||
|
{
|
||||||
|
double diff = flow1(y, x) - flow2(y, x);
|
||||||
|
sum += diff * diff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::sqrt(sum / flow1.size().area());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FastOpticalFlowBM : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(FastOpticalFlowBM, Accuracy)
|
||||||
|
{
|
||||||
|
const double MAX_RMSE = 0.6;
|
||||||
|
|
||||||
|
int search_window = 15;
|
||||||
|
int block_window = 5;
|
||||||
|
|
||||||
|
cv::gpu::DeviceInfo devInfo = GetParam();
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
|
||||||
|
cv::Mat frame0 = readImage("opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame0.empty());
|
||||||
|
|
||||||
|
cv::Mat frame1 = readImage("opticalflow/rubberwhale2.png", cv::IMREAD_GRAYSCALE);
|
||||||
|
ASSERT_FALSE(frame1.empty());
|
||||||
|
|
||||||
|
cv::Size smallSize(320, 240);
|
||||||
|
cv::Mat frame0_small;
|
||||||
|
cv::Mat frame1_small;
|
||||||
|
|
||||||
|
cv::resize(frame0, frame0_small, smallSize);
|
||||||
|
cv::resize(frame1, frame1_small, smallSize);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat d_flowx;
|
||||||
|
cv::gpu::GpuMat d_flowy;
|
||||||
|
cv::gpu::FastOpticalFlowBM fastBM;
|
||||||
|
|
||||||
|
fastBM(loadMat(frame0_small), loadMat(frame1_small), d_flowx, d_flowy, search_window, block_window);
|
||||||
|
|
||||||
|
cv::Mat_<float> flowx;
|
||||||
|
cv::Mat_<float> flowy;
|
||||||
|
FastOpticalFlowBM_gold(frame0_small, frame1_small, flowx, flowy, search_window, block_window);
|
||||||
|
|
||||||
|
double err;
|
||||||
|
|
||||||
|
err = calc_rmse(flowx, cv::Mat(d_flowx));
|
||||||
|
EXPECT_LE(err, MAX_RMSE);
|
||||||
|
|
||||||
|
err = calc_rmse(flowy, cv::Mat(d_flowy));
|
||||||
|
EXPECT_LE(err, MAX_RMSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Video, FastOpticalFlowBM, ALL_DEVICES);
|
||||||
|
|
||||||
|
#endif // HAVE_CUDA
|
@ -51,6 +51,7 @@
|
|||||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <ctime>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -64,7 +64,7 @@ PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(PyrDown, Accuracy)
|
GPU_TEST_P(PyrDown, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ PARAM_TEST_CASE(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(PyrUp, Accuracy)
|
GPU_TEST_P(PyrUp, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ PARAM_TEST_CASE(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Bo
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Remap, Accuracy)
|
GPU_TEST_P(Remap, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Scalar val = randomScalar(0.0, 255.0);
|
cv::Scalar val = randomScalar(0.0, 255.0);
|
||||||
|
@ -136,7 +136,7 @@ PARAM_TEST_CASE(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, double, Interpol
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Resize, Accuracy)
|
GPU_TEST_P(Resize, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
@ -157,8 +157,8 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Resize, testing::Combine(
|
|||||||
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
|
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|
||||||
PARAM_TEST_CASE(ResizeSameAsHost, cv::gpu::DeviceInfo, cv::Size, MatType, double, Interpolation, UseRoi)
|
PARAM_TEST_CASE(ResizeSameAsHost, cv::gpu::DeviceInfo, cv::Size, MatType, double, Interpolation, UseRoi)
|
||||||
{
|
{
|
||||||
cv::gpu::DeviceInfo devInfo;
|
cv::gpu::DeviceInfo devInfo;
|
||||||
@ -182,7 +182,7 @@ PARAM_TEST_CASE(ResizeSameAsHost, cv::gpu::DeviceInfo, cv::Size, MatType, double
|
|||||||
};
|
};
|
||||||
|
|
||||||
// downscaling only: used for classifiers
|
// downscaling only: used for classifiers
|
||||||
TEST_P(ResizeSameAsHost, Accuracy)
|
GPU_TEST_P(ResizeSameAsHost, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ PARAM_TEST_CASE(ResizeNPP, cv::gpu::DeviceInfo, MatType, double, Interpolation)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(ResizeNPP, Accuracy)
|
GPU_TEST_P(ResizeNPP, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
|
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
|
||||||
ASSERT_FALSE(src.empty());
|
ASSERT_FALSE(src.empty());
|
||||||
|
@ -40,14 +40,14 @@
|
|||||||
//
|
//
|
||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include <test_precomp.hpp>
|
#include "test_precomp.hpp"
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
|
|
||||||
using cv::gpu::GpuMat;
|
using cv::gpu::GpuMat;
|
||||||
|
|
||||||
// show detection results on input image with cv::imshow
|
// show detection results on input image with cv::imshow
|
||||||
// #define SHOW_DETECTIONS
|
//#define SHOW_DETECTIONS
|
||||||
|
|
||||||
#if defined SHOW_DETECTIONS
|
#if defined SHOW_DETECTIONS
|
||||||
# define SHOW(res) \
|
# define SHOW(res) \
|
||||||
@ -57,22 +57,22 @@ using cv::gpu::GpuMat;
|
|||||||
# define SHOW(res)
|
# define SHOW(res)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GPU_TEST_P(fixture, name, params) \
|
TEST(SCascadeTest, readCascade)
|
||||||
class fixture##_##name : public fixture { \
|
{
|
||||||
public: \
|
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/icf-template.xml";
|
||||||
fixture##_##name() {} \
|
cv::gpu::SCascade cascade;
|
||||||
protected: \
|
|
||||||
virtual void body(); \
|
|
||||||
}; \
|
|
||||||
TEST_P(fixture##_##name, name /*none*/){ body();} \
|
|
||||||
INSTANTIATE_TEST_CASE_P(/*none*/, fixture##_##name, params); \
|
|
||||||
void fixture##_##name::body()
|
|
||||||
|
|
||||||
namespace {
|
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
||||||
|
ASSERT_TRUE(fs.isOpened());
|
||||||
|
|
||||||
|
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
typedef cv::gpu::SCascade::Detection Detection;
|
typedef cv::gpu::SCascade::Detection Detection;
|
||||||
|
|
||||||
static cv::Rect getFromTable(int idx)
|
cv::Rect getFromTable(int idx)
|
||||||
{
|
{
|
||||||
static const cv::Rect rois[] =
|
static const cv::Rect rois[] =
|
||||||
{
|
{
|
||||||
@ -92,16 +92,16 @@ namespace {
|
|||||||
return rois[idx];
|
return rois[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string itoa(long i)
|
std::string itoa(long i)
|
||||||
{
|
{
|
||||||
static char s[65];
|
static char s[65];
|
||||||
sprintf(s, "%ld", i);
|
sprintf(s, "%ld", i);
|
||||||
return std::string(s);
|
return std::string(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print(std::ostream &out, const Detection& d)
|
void print(std::ostream &out, const Detection& d)
|
||||||
{
|
{
|
||||||
#if defined SHOW_DETECTIONS
|
#if defined SHOW_DETECTIONS
|
||||||
out << "\x1b[32m[ detection]\x1b[0m ("
|
out << "\x1b[32m[ detection]\x1b[0m ("
|
||||||
<< std::setw(4) << d.x
|
<< std::setw(4) << d.x
|
||||||
<< " "
|
<< " "
|
||||||
@ -113,22 +113,22 @@ namespace {
|
|||||||
<< ") "
|
<< ") "
|
||||||
<< std::setw(12) << d.confidence
|
<< std::setw(12) << d.confidence
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
(void)out; (void)d;
|
(void)out; (void)d;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printTotal(std::ostream &out, int detbytes)
|
void printTotal(std::ostream &out, int detbytes)
|
||||||
{
|
{
|
||||||
#if defined SHOW_DETECTIONS
|
#if defined SHOW_DETECTIONS
|
||||||
out << "\x1b[32m[ ]\x1b[0m Total detections " << (detbytes / sizeof(Detection)) << std::endl;
|
out << "\x1b[32m[ ]\x1b[0m Total detections " << (detbytes / sizeof(Detection)) << std::endl;
|
||||||
#else
|
#else
|
||||||
(void)out; (void)detbytes;
|
(void)out; (void)detbytes;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined SHOW_DETECTIONS
|
#if defined SHOW_DETECTIONS
|
||||||
static std::string getImageName(int level)
|
std::string getImageName(int level)
|
||||||
{
|
{
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm * timeinfo;
|
struct tm * timeinfo;
|
||||||
@ -141,7 +141,7 @@ namespace {
|
|||||||
return "gpu_rec_level_" + itoa(level)+ "_" + std::string(buffer) + ".png";
|
return "gpu_rec_level_" + itoa(level)+ "_" + std::string(buffer) + ".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeResult(const cv::Mat& result, const int level)
|
void writeResult(const cv::Mat& result, const int level)
|
||||||
{
|
{
|
||||||
std::string path = cv::tempfile(getImageName(level).c_str());
|
std::string path = cv::tempfile(getImageName(level).c_str());
|
||||||
cv::imwrite(path, result);
|
cv::imwrite(path, result);
|
||||||
@ -150,13 +150,11 @@ namespace {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef ::testing::TestWithParam<std::tr1::tuple<cv::gpu::DeviceInfo, std::string, std::string, int> > SCascadeTestRoi;
|
PARAM_TEST_CASE(SCascadeTestRoi, cv::gpu::DeviceInfo, std::string, std::string, int)
|
||||||
GPU_TEST_P(SCascadeTestRoi, detect,
|
{
|
||||||
testing::Combine(
|
};
|
||||||
ALL_DEVICES,
|
|
||||||
testing::Values(std::string("cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml")),
|
GPU_TEST_P(SCascadeTestRoi, Detect)
|
||||||
testing::Values(std::string("../cv/cascadeandhog/bahnhof/image_00000000_0.png")),
|
|
||||||
testing::Range(0, 5)))
|
|
||||||
{
|
{
|
||||||
cv::gpu::setDevice(GET_PARAM(0).deviceID());
|
cv::gpu::setDevice(GET_PARAM(0).deviceID());
|
||||||
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path() + GET_PARAM(2));
|
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path() + GET_PARAM(2));
|
||||||
@ -202,26 +200,24 @@ GPU_TEST_P(SCascadeTestRoi, detect,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SHOW(result);
|
SHOW(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SCascadeTest, readCascade)
|
INSTANTIATE_TEST_CASE_P(GPU_SoftCascade, SCascadeTestRoi, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
testing::Values(std::string("cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml")),
|
||||||
|
testing::Values(std::string("../cv/cascadeandhog/bahnhof/image_00000000_0.png")),
|
||||||
|
testing::Range(0, 5)));
|
||||||
|
|
||||||
|
struct SCascadeTestAll : testing::TestWithParam<cv::gpu::DeviceInfo>
|
||||||
{
|
{
|
||||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/icf-template.xml";
|
virtual void SetUp()
|
||||||
cv::gpu::SCascade cascade;
|
{
|
||||||
|
cv::gpu::setDevice(GetParam().deviceID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
GPU_TEST_P(SCascadeTestAll, detect)
|
||||||
ASSERT_TRUE(fs.isOpened());
|
|
||||||
|
|
||||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef ::testing::TestWithParam<cv::gpu::DeviceInfo > SCascadeTestAll;
|
|
||||||
GPU_TEST_P(SCascadeTestAll, detect,
|
|
||||||
ALL_DEVICES
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
cv::gpu::setDevice(GetParam().deviceID());
|
|
||||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||||
cv::gpu::SCascade cascade;
|
cv::gpu::SCascade cascade;
|
||||||
|
|
||||||
@ -239,20 +235,16 @@ GPU_TEST_P(SCascadeTestAll, detect,
|
|||||||
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
|
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
|
||||||
sub.setTo(cv::Scalar::all(1));
|
sub.setTo(cv::Scalar::all(1));
|
||||||
|
|
||||||
objectBoxes.setTo(0);
|
|
||||||
cascade.detect(colored, rois, objectBoxes);
|
cascade.detect(colored, rois, objectBoxes);
|
||||||
|
|
||||||
typedef cv::gpu::SCascade::Detection Detection;
|
typedef cv::gpu::SCascade::Detection Detection;
|
||||||
cv::Mat detections(objectBoxes);
|
cv::Mat detections(objectBoxes);
|
||||||
int a = *(detections.ptr<int>(0));
|
int a = *(detections.ptr<int>(0));
|
||||||
ASSERT_EQ(a ,2448);
|
ASSERT_EQ(a, 2448);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPU_TEST_P(SCascadeTestAll, detectOnIntegral,
|
GPU_TEST_P(SCascadeTestAll, detectOnIntegral)
|
||||||
ALL_DEVICES
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
cv::gpu::setDevice(GetParam().deviceID());
|
|
||||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||||
cv::gpu::SCascade cascade;
|
cv::gpu::SCascade cascade;
|
||||||
|
|
||||||
@ -283,15 +275,11 @@ GPU_TEST_P(SCascadeTestAll, detectOnIntegral,
|
|||||||
typedef cv::gpu::SCascade::Detection Detection;
|
typedef cv::gpu::SCascade::Detection Detection;
|
||||||
cv::Mat detections(objectBoxes);
|
cv::Mat detections(objectBoxes);
|
||||||
int a = *(detections.ptr<int>(0));
|
int a = *(detections.ptr<int>(0));
|
||||||
|
ASSERT_EQ(a, 1024);
|
||||||
ASSERT_EQ( a ,1024);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GPU_TEST_P(SCascadeTestAll, detectStream,
|
GPU_TEST_P(SCascadeTestAll, detectStream)
|
||||||
ALL_DEVICES
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
cv::gpu::setDevice(GetParam().deviceID());
|
|
||||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||||
cv::gpu::SCascade cascade;
|
cv::gpu::SCascade cascade;
|
||||||
|
|
||||||
@ -318,8 +306,9 @@ GPU_TEST_P(SCascadeTestAll, detectStream,
|
|||||||
typedef cv::gpu::SCascade::Detection Detection;
|
typedef cv::gpu::SCascade::Detection Detection;
|
||||||
cv::Mat detections(objectBoxes);
|
cv::Mat detections(objectBoxes);
|
||||||
int a = *(detections.ptr<int>(0));
|
int a = *(detections.ptr<int>(0));
|
||||||
ASSERT_EQ(a ,2448);
|
ASSERT_EQ(a, 2448);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_SoftCascade, SCascadeTestAll, ALL_DEVICES);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -66,7 +66,7 @@ PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, Use
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(Threshold, Accuracy)
|
GPU_TEST_P(Threshold, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
double maxVal = randomDouble(20.0, 127.0);
|
double maxVal = randomDouble(20.0, 127.0);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -48,6 +48,7 @@ namespace
|
|||||||
cv::Mat createTransfomMatrix(cv::Size srcSize, double angle)
|
cv::Mat createTransfomMatrix(cv::Size srcSize, double angle)
|
||||||
{
|
{
|
||||||
cv::Mat M(2, 3, CV_64FC1);
|
cv::Mat M(2, 3, CV_64FC1);
|
||||||
|
|
||||||
M.at<double>(0, 0) = std::cos(angle); M.at<double>(0, 1) = -std::sin(angle); M.at<double>(0, 2) = srcSize.width / 2;
|
M.at<double>(0, 0) = std::cos(angle); M.at<double>(0, 1) = -std::sin(angle); M.at<double>(0, 2) = srcSize.width / 2;
|
||||||
M.at<double>(1, 0) = std::sin(angle); M.at<double>(1, 1) = std::cos(angle); M.at<double>(1, 2) = 0.0;
|
M.at<double>(1, 0) = std::sin(angle); M.at<double>(1, 1) = std::cos(angle); M.at<double>(1, 2) = 0.0;
|
||||||
|
|
||||||
@ -74,22 +75,23 @@ PARAM_TEST_CASE(BuildWarpAffineMaps, cv::gpu::DeviceInfo, cv::Size, Inverse)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(BuildWarpAffineMaps, Accuracy)
|
GPU_TEST_P(BuildWarpAffineMaps, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
|
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
|
||||||
|
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
|
||||||
|
|
||||||
cv::gpu::GpuMat xmap, ymap;
|
cv::gpu::GpuMat xmap, ymap;
|
||||||
cv::gpu::buildWarpAffineMaps(M, inverse, size, xmap, ymap);
|
cv::gpu::buildWarpAffineMaps(M, inverse, size, xmap, ymap);
|
||||||
|
|
||||||
int interpolation = cv::INTER_NEAREST;
|
int interpolation = cv::INTER_NEAREST;
|
||||||
int borderMode = cv::BORDER_CONSTANT;
|
int borderMode = cv::BORDER_CONSTANT;
|
||||||
|
|
||||||
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
|
|
||||||
cv::Mat dst;
|
|
||||||
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), interpolation, borderMode);
|
|
||||||
|
|
||||||
int flags = interpolation;
|
int flags = interpolation;
|
||||||
if (inverse)
|
if (inverse)
|
||||||
flags |= cv::WARP_INVERSE_MAP;
|
flags |= cv::WARP_INVERSE_MAP;
|
||||||
|
|
||||||
|
cv::Mat dst;
|
||||||
|
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), interpolation, borderMode);
|
||||||
|
|
||||||
cv::Mat dst_gold;
|
cv::Mat dst_gold;
|
||||||
cv::warpAffine(src, dst_gold, M, size, flags, borderMode);
|
cv::warpAffine(src, dst_gold, M, size, flags, borderMode);
|
||||||
|
|
||||||
@ -199,7 +201,7 @@ PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Int
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(WarpAffine, Accuracy)
|
GPU_TEST_P(WarpAffine, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
|
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
|
||||||
@ -247,7 +249,7 @@ PARAM_TEST_CASE(WarpAffineNPP, cv::gpu::DeviceInfo, MatType, Inverse, Interpolat
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(WarpAffineNPP, Accuracy)
|
GPU_TEST_P(WarpAffineNPP, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
|
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
|
||||||
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
|
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
|
||||||
|
@ -48,6 +48,7 @@ namespace
|
|||||||
cv::Mat createTransfomMatrix(cv::Size srcSize, double angle)
|
cv::Mat createTransfomMatrix(cv::Size srcSize, double angle)
|
||||||
{
|
{
|
||||||
cv::Mat M(3, 3, CV_64FC1);
|
cv::Mat M(3, 3, CV_64FC1);
|
||||||
|
|
||||||
M.at<double>(0, 0) = std::cos(angle); M.at<double>(0, 1) = -std::sin(angle); M.at<double>(0, 2) = srcSize.width / 2;
|
M.at<double>(0, 0) = std::cos(angle); M.at<double>(0, 1) = -std::sin(angle); M.at<double>(0, 2) = srcSize.width / 2;
|
||||||
M.at<double>(1, 0) = std::sin(angle); M.at<double>(1, 1) = std::cos(angle); M.at<double>(1, 2) = 0.0;
|
M.at<double>(1, 0) = std::sin(angle); M.at<double>(1, 1) = std::cos(angle); M.at<double>(1, 2) = 0.0;
|
||||||
M.at<double>(2, 0) = 0.0 ; M.at<double>(2, 1) = 0.0 ; M.at<double>(2, 2) = 1.0;
|
M.at<double>(2, 0) = 0.0 ; M.at<double>(2, 1) = 0.0 ; M.at<double>(2, 2) = 1.0;
|
||||||
@ -75,21 +76,25 @@ PARAM_TEST_CASE(BuildWarpPerspectiveMaps, cv::gpu::DeviceInfo, cv::Size, Inverse
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(BuildWarpPerspectiveMaps, Accuracy)
|
GPU_TEST_P(BuildWarpPerspectiveMaps, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
|
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
|
||||||
|
|
||||||
cv::gpu::GpuMat xmap, ymap;
|
cv::gpu::GpuMat xmap, ymap;
|
||||||
cv::gpu::buildWarpPerspectiveMaps(M, inverse, size, xmap, ymap);
|
cv::gpu::buildWarpPerspectiveMaps(M, inverse, size, xmap, ymap);
|
||||||
|
|
||||||
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
|
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
|
||||||
cv::Mat dst;
|
int interpolation = cv::INTER_NEAREST;
|
||||||
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), cv::INTER_NEAREST, cv::BORDER_CONSTANT);
|
int borderMode = cv::BORDER_CONSTANT;
|
||||||
|
int flags = interpolation;
|
||||||
int flags = cv::INTER_NEAREST;
|
|
||||||
if (inverse)
|
if (inverse)
|
||||||
flags |= cv::WARP_INVERSE_MAP;
|
flags |= cv::WARP_INVERSE_MAP;
|
||||||
|
|
||||||
|
cv::Mat dst;
|
||||||
|
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), interpolation, borderMode);
|
||||||
|
|
||||||
cv::Mat dst_gold;
|
cv::Mat dst_gold;
|
||||||
cv::warpPerspective(src, dst_gold, M, size, flags, cv::BORDER_CONSTANT);
|
cv::warpPerspective(src, dst_gold, M, size, flags, borderMode);
|
||||||
|
|
||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
}
|
}
|
||||||
@ -199,7 +204,7 @@ PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(WarpPerspective, Accuracy)
|
GPU_TEST_P(WarpPerspective, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = randomMat(size, type);
|
cv::Mat src = randomMat(size, type);
|
||||||
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
|
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
|
||||||
@ -247,7 +252,7 @@ PARAM_TEST_CASE(WarpPerspectiveNPP, cv::gpu::DeviceInfo, MatType, Inverse, Inter
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(WarpPerspectiveNPP, Accuracy)
|
GPU_TEST_P(WarpPerspectiveNPP, Accuracy)
|
||||||
{
|
{
|
||||||
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
|
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
|
||||||
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
|
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
|
||||||
|
@ -67,7 +67,7 @@ double randomDouble(double minVal, double maxVal)
|
|||||||
|
|
||||||
Size randomSize(int minVal, int maxVal)
|
Size randomSize(int minVal, int maxVal)
|
||||||
{
|
{
|
||||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
return Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar randomScalar(double minVal, double maxVal)
|
Scalar randomScalar(double minVal, double maxVal)
|
||||||
@ -83,7 +83,7 @@ Mat randomMat(Size size, int type, double minVal, double maxVal)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// GpuMat create
|
// GpuMat create
|
||||||
|
|
||||||
cv::gpu::GpuMat createMat(cv::Size size, int type, bool useRoi)
|
GpuMat createMat(Size size, int type, bool useRoi)
|
||||||
{
|
{
|
||||||
Size size0 = size;
|
Size size0 = size;
|
||||||
|
|
||||||
@ -122,21 +122,13 @@ Mat readImageType(const std::string& fname, int type)
|
|||||||
if (CV_MAT_CN(type) == 4)
|
if (CV_MAT_CN(type) == 4)
|
||||||
{
|
{
|
||||||
Mat temp;
|
Mat temp;
|
||||||
cvtColor(src, temp, cv::COLOR_BGR2BGRA);
|
cvtColor(src, temp, COLOR_BGR2BGRA);
|
||||||
swap(src, temp);
|
swap(src, temp);
|
||||||
}
|
}
|
||||||
src.convertTo(src, CV_MAT_DEPTH(type), CV_MAT_DEPTH(type) == CV_32F ? 1.0 / 255.0 : 1.0);
|
src.convertTo(src, CV_MAT_DEPTH(type), CV_MAT_DEPTH(type) == CV_32F ? 1.0 / 255.0 : 1.0);
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Image dumping
|
|
||||||
|
|
||||||
void dumpImage(const std::string& fileName, const cv::Mat& image)
|
|
||||||
{
|
|
||||||
cv::imwrite(TS::ptr()->get_data_path() + fileName, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Gpu devices
|
// Gpu devices
|
||||||
|
|
||||||
@ -156,7 +148,7 @@ void DeviceManager::load(int i)
|
|||||||
devices_.clear();
|
devices_.clear();
|
||||||
devices_.reserve(1);
|
devices_.reserve(1);
|
||||||
|
|
||||||
ostringstream msg;
|
std::ostringstream msg;
|
||||||
|
|
||||||
if (i < 0 || i >= getCudaEnabledDeviceCount())
|
if (i < 0 || i >= getCudaEnabledDeviceCount())
|
||||||
{
|
{
|
||||||
@ -195,21 +187,39 @@ void DeviceManager::loadAll()
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Additional assertion
|
// Additional assertion
|
||||||
|
|
||||||
Mat getMat(InputArray arr)
|
namespace
|
||||||
{
|
{
|
||||||
if (arr.kind() == _InputArray::GPU_MAT)
|
template <typename T, typename OutT> std::string printMatValImpl(const Mat& m, Point p)
|
||||||
{
|
{
|
||||||
Mat m;
|
const int cn = m.channels();
|
||||||
arr.getGpuMat().download(m);
|
|
||||||
return m;
|
std::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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr.getMat();
|
std::string printMatVal(const Mat& m, Point p)
|
||||||
}
|
{
|
||||||
|
typedef std::string (*func_t)(const Mat& m, Point p);
|
||||||
|
|
||||||
double checkNorm(InputArray m1, InputArray m2)
|
static const func_t funcs[] =
|
||||||
{
|
{
|
||||||
return norm(getMat(m1), getMat(m2), NORM_INF);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minLoc_, Point* maxLoc_, const Mat& mask)
|
void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minLoc_, Point* maxLoc_, const Mat& mask)
|
||||||
@ -229,8 +239,8 @@ void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minL
|
|||||||
|
|
||||||
for (int y = 0; y < src.rows; ++y)
|
for (int y = 0; y < src.rows; ++y)
|
||||||
{
|
{
|
||||||
const schar* src_row = src.ptr<signed char>(y);
|
const schar* src_row = src.ptr<schar>(y);
|
||||||
const uchar* mask_row = mask.empty() ? 0 : mask.ptr<unsigned char>(y);
|
const uchar* mask_row = mask.empty() ? 0 : mask.ptr<uchar>(y);
|
||||||
|
|
||||||
for (int x = 0; x < src.cols; ++x)
|
for (int x = 0; x < src.cols; ++x)
|
||||||
{
|
{
|
||||||
@ -260,42 +270,19 @@ void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minL
|
|||||||
if (maxLoc_) *maxLoc_ = maxLoc;
|
if (maxLoc_) *maxLoc_ = maxLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
Mat getMat(InputArray arr)
|
||||||
{
|
{
|
||||||
template <typename T, typename OutT> std::string printMatValImpl(const Mat& m, Point p)
|
if (arr.kind() == _InputArray::GPU_MAT)
|
||||||
{
|
{
|
||||||
const int cn = m.channels();
|
Mat m;
|
||||||
|
arr.getGpuMat().download(m);
|
||||||
ostringstream ostr;
|
return m;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string printMatVal(const Mat& m, Point p)
|
return arr.getMat();
|
||||||
{
|
|
||||||
typedef std::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)
|
AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, InputArray m1_, InputArray m2_, double eps)
|
||||||
{
|
{
|
||||||
Mat m1 = getMat(m1_);
|
Mat m1 = getMat(m1_);
|
||||||
Mat m2 = getMat(m2_);
|
Mat m2 = getMat(m2_);
|
||||||
@ -344,18 +331,6 @@ double checkSimilarity(InputArray m1, InputArray m2)
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Helper structs for value-parameterized tests
|
// 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> types(int depth_start, int depth_end, int cn_start, int cn_end)
|
||||||
{
|
{
|
||||||
vector<MatType> v;
|
vector<MatType> v;
|
||||||
@ -366,7 +341,7 @@ vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
|
|||||||
{
|
{
|
||||||
for (int cn = cn_start; cn <= cn_end; ++cn)
|
for (int cn = cn_start; cn <= cn_end; ++cn)
|
||||||
{
|
{
|
||||||
v.push_back(CV_MAKETYPE(depth, cn));
|
v.push_back(MatType(CV_MAKE_TYPE(depth, cn)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,6 +376,14 @@ void PrintTo(const Inverse& inverse, std::ostream* os)
|
|||||||
(*os) << "direct";
|
(*os) << "direct";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Other
|
||||||
|
|
||||||
|
void dumpImage(const std::string& fileName, const Mat& image)
|
||||||
|
{
|
||||||
|
imwrite(TS::ptr()->get_data_path() + fileName, image);
|
||||||
|
}
|
||||||
|
|
||||||
void showDiff(InputArray gold_, InputArray actual_, double eps)
|
void showDiff(InputArray gold_, InputArray actual_, double eps)
|
||||||
{
|
{
|
||||||
Mat gold = getMat(gold_);
|
Mat gold = getMat(gold_);
|
||||||
|
@ -39,8 +39,14 @@
|
|||||||
//
|
//
|
||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#ifndef __OPENCV_TEST_UTILITY_HPP__
|
#ifndef __OPENCV_GPU_TEST_UTILITY_HPP__
|
||||||
#define __OPENCV_TEST_UTILITY_HPP__
|
#define __OPENCV_GPU_TEST_UTILITY_HPP__
|
||||||
|
|
||||||
|
#include "opencv2/core/core.hpp"
|
||||||
|
#include "opencv2/core/gpumat.hpp"
|
||||||
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
|
#include "opencv2/ts/ts.hpp"
|
||||||
|
#include "opencv2/ts/ts_perf.hpp"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// random generators
|
// random generators
|
||||||
@ -66,11 +72,6 @@ cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
|
|||||||
//! read image from testdata folder and convert it to specified type
|
//! read image from testdata folder and convert it to specified type
|
||||||
cv::Mat readImageType(const std::string& fname, int type);
|
cv::Mat readImageType(const std::string& fname, int type);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Image dumping
|
|
||||||
|
|
||||||
void dumpImage(const std::string& fileName, const cv::Mat& image);
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Gpu devices
|
// Gpu devices
|
||||||
|
|
||||||
@ -96,12 +97,10 @@ private:
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Additional assertion
|
// Additional assertion
|
||||||
|
|
||||||
cv::Mat getMat(cv::InputArray arr);
|
|
||||||
|
|
||||||
double checkNorm(cv::InputArray m1, cv::InputArray m2);
|
|
||||||
|
|
||||||
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());
|
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());
|
||||||
|
|
||||||
|
cv::Mat getMat(cv::InputArray arr);
|
||||||
|
|
||||||
testing::AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, cv::InputArray m1, cv::InputArray m2, double eps);
|
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 EXPECT_MAT_NEAR(m1, m2, eps) EXPECT_PRED_FORMAT3(assertMatNear, m1, m2, eps)
|
||||||
@ -164,6 +163,45 @@ double checkSimilarity(cv::InputArray m1, cv::InputArray m2);
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Helper structs for value-parameterized tests
|
// Helper structs for value-parameterized tests
|
||||||
|
|
||||||
|
#define GPU_TEST_P(test_case_name, test_name) \
|
||||||
|
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
|
||||||
|
: public test_case_name { \
|
||||||
|
public: \
|
||||||
|
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
|
||||||
|
virtual void TestBody(); \
|
||||||
|
private: \
|
||||||
|
void UnsafeTestBody(); \
|
||||||
|
static int AddToRegistry() { \
|
||||||
|
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
|
||||||
|
GetTestCasePatternHolder<test_case_name>(\
|
||||||
|
#test_case_name, __FILE__, __LINE__)->AddTestPattern(\
|
||||||
|
#test_case_name, \
|
||||||
|
#test_name, \
|
||||||
|
new ::testing::internal::TestMetaFactory< \
|
||||||
|
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
static int gtest_registering_dummy_; \
|
||||||
|
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
|
||||||
|
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
|
||||||
|
}; \
|
||||||
|
int GTEST_TEST_CLASS_NAME_(test_case_name, \
|
||||||
|
test_name)::gtest_registering_dummy_ = \
|
||||||
|
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
|
||||||
|
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() \
|
||||||
|
{ \
|
||||||
|
try \
|
||||||
|
{ \
|
||||||
|
UnsafeTestBody(); \
|
||||||
|
} \
|
||||||
|
catch (...) \
|
||||||
|
{ \
|
||||||
|
cv::gpu::resetDevice(); \
|
||||||
|
throw; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::UnsafeTestBody()
|
||||||
|
|
||||||
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
||||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
||||||
|
|
||||||
@ -178,11 +216,8 @@ namespace cv { namespace gpu
|
|||||||
|
|
||||||
using perf::MatDepth;
|
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 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)), \
|
#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_16U)), \
|
||||||
std::make_pair(MatDepth(CV_8U), MatDepth(CV_16S)), \
|
std::make_pair(MatDepth(CV_8U), MatDepth(CV_16S)), \
|
||||||
@ -237,8 +272,6 @@ private:
|
|||||||
|
|
||||||
void PrintTo(const UseRoi& useRoi, std::ostream* os);
|
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))
|
#define WHOLE_SUBMAT testing::Values(UseRoi(false), UseRoi(true))
|
||||||
|
|
||||||
// Direct/Inverse
|
// Direct/Inverse
|
||||||
@ -253,7 +286,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool val_;
|
bool val_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PrintTo(const Inverse& useRoi, std::ostream* os);
|
void PrintTo(const Inverse& useRoi, std::ostream* os);
|
||||||
|
|
||||||
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
|
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
|
||||||
|
|
||||||
// Param class
|
// Param class
|
||||||
@ -291,6 +326,7 @@ CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WA
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
|
void dumpImage(const std::string& fileName, const cv::Mat& image);
|
||||||
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||||
|
|
||||||
#endif // __OPENCV_TEST_UTILITY_HPP__
|
#endif // __OPENCV_GPU_TEST_UTILITY_HPP__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user