Commit f4f38fcc authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fixed gpu test failure on empty test data

parent a5f38806
......@@ -43,50 +43,35 @@
#ifdef HAVE_CUDA
struct StereoTest : testing::TestWithParam<cv::gpu::DeviceInfo>
{
static cv::Mat img_l;
static cv::Mat img_r;
static cv::Mat img_template;
static void TearDownTestCase()
{
img_l.release();
img_r.release();
img_template.release();
}
cv::gpu::DeviceInfo devInfo;
//////////////////////////////////////////////////////////////////////////
// BlockMatching
struct StereoBlockMatching : testing::TestWithParam<cv::gpu::DeviceInfo>
{
cv::Mat img_l;
cv::Mat img_r;
cv::Mat img_template;
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
}
};
cv::Mat StereoTest::img_l;
cv::Mat StereoTest::img_r;
cv::Mat StereoTest::img_template;
//////////////////////////////////////////////////////////////////////////
// BlockMatching
struct StereoBlockMatching : StereoTest
{
static void SetUpTestCase()
{
img_l = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
img_r = readImage("stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);
img_template = readImage("stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
}
};
TEST_P(StereoBlockMatching, Regression)
{
ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());
PRINT_PARAM(devInfo);
cv::Mat disp;
......@@ -110,20 +95,32 @@ INSTANTIATE_TEST_CASE_P(Calib3D, StereoBlockMatching, testing::ValuesIn(devices(
//////////////////////////////////////////////////////////////////////////
// BeliefPropagation
struct StereoBeliefPropagation : StereoTest
struct StereoBeliefPropagation : testing::TestWithParam<cv::gpu::DeviceInfo>
{
static void SetUpTestCase()
cv::Mat img_l;
cv::Mat img_r;
cv::Mat img_template;
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
img_l = readImage("stereobp/aloe-L.png");
img_r = readImage("stereobp/aloe-R.png");
img_template = readImage("stereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
}
};
TEST_P(StereoBeliefPropagation, Regression)
{
ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());
PRINT_PARAM(devInfo);
cv::Mat disp;
......@@ -147,29 +144,36 @@ INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, testing::ValuesIn(devi
//////////////////////////////////////////////////////////////////////////
// ConstantSpaceBP
struct StereoConstantSpaceBP : StereoTest
struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo>
{
static void SetUpTestCase()
{
img_l = readImage("csstereobp/aloe-L.png");
img_r = readImage("csstereobp/aloe-R.png");
}
cv::Mat img_l;
cv::Mat img_r;
cv::Mat img_template;
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
{
StereoTest::SetUp();
devInfo = GetParam();
if (supportFeature(GetParam(), cv::gpu::FEATURE_SET_COMPUTE_20))
cv::gpu::setDevice(devInfo.deviceID());
img_l = readImage("csstereobp/aloe-L.png");
img_r = readImage("csstereobp/aloe-R.png");
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
img_template = readImage("csstereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
else
img_template = readImage("csstereobp/aloe-disp_CC1X.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
}
};
TEST_P(StereoConstantSpaceBP, Regression)
{
ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());
PRINT_PARAM(devInfo);
cv::Mat disp;
......
......@@ -48,29 +48,10 @@
struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo>
{
static cv::Mat image;
static cv::Mat mask;
static std::vector<cv::KeyPoint> keypoints_gold;
static std::vector<float> descriptors_gold;
static void SetUpTestCase()
{
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);
mask = cv::Mat(image.size(), CV_8UC1, cv::Scalar::all(1));
mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));
cv::SURF fdetector_gold; fdetector_gold.extended = false;
fdetector_gold(image, mask, keypoints_gold, descriptors_gold);
}
static void TearDownTestCase()
{
image.release();
mask.release();
keypoints_gold.clear();
descriptors_gold.clear();
}
cv::Mat image;
cv::Mat mask;
std::vector<cv::KeyPoint> keypoints_gold;
std::vector<float> descriptors_gold;
cv::gpu::DeviceInfo devInfo;
......@@ -79,6 +60,15 @@ struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo>
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(image.empty());
mask = cv::Mat(image.size(), CV_8UC1, cv::Scalar::all(1));
mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));
cv::SURF fdetector_gold; fdetector_gold.extended = false;
fdetector_gold(image, mask, keypoints_gold, descriptors_gold);
}
bool isSimilarKeypoints(const cv::KeyPoint& p1, const cv::KeyPoint& p2)
......@@ -98,11 +88,6 @@ struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo>
}
};
cv::Mat SURF::image;
cv::Mat SURF::mask;
std::vector<cv::KeyPoint> SURF::keypoints_gold;
std::vector<float> SURF::descriptors_gold;
TEST_P(SURF, EmptyDataTest)
{
PRINT_PARAM(devInfo);
......@@ -123,8 +108,6 @@ TEST_P(SURF, EmptyDataTest)
TEST_P(SURF, Accuracy)
{
ASSERT_TRUE(!image.empty());
PRINT_PARAM(devInfo);
// Compute keypoints.
......@@ -161,11 +144,11 @@ TEST_P(SURF, Accuracy)
float dist = (float)cv::norm(p1.pt - p2.pt);
if (dist < maxPtDif &&
fabs(p1.size - p2.size) < maxSizeDif &&
abs(p1.angle - p2.angle) < maxAngleDif &&
abs(p1.response - p2.response) < maxResponseDif &&
p1.octave == p2.octave &&
p1.class_id == p2.class_id )
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)
{
++validCount;
}
......
This diff is collapsed.
......@@ -50,7 +50,7 @@ struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor
void run()
{
cv::Mat img_rgb = readImage("hog/road.png");
ASSERT_TRUE(!img_rgb.empty());
ASSERT_FALSE(img_rgb.empty());
#ifdef DUMP
f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);
......@@ -201,7 +201,7 @@ struct CV_GpuHogGetDescriptorsTestRunner : cv::gpu::HOGDescriptor
{
// Load image (e.g. train data, composed from windows)
cv::Mat img_rgb = readImage("hog/train_data.png");
ASSERT_TRUE(!img_rgb.empty());
ASSERT_FALSE(img_rgb.empty());
// Convert to C4
cv::Mat img;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment