Commit f4f38fcc authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fixed gpu test failure on empty test data

parent a5f38806
...@@ -43,18 +43,14 @@ ...@@ -43,18 +43,14 @@
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
struct StereoTest : testing::TestWithParam<cv::gpu::DeviceInfo> //////////////////////////////////////////////////////////////////////////
{ // BlockMatching
static cv::Mat img_l;
static cv::Mat img_r;
static cv::Mat img_template;
static void TearDownTestCase() struct StereoBlockMatching : testing::TestWithParam<cv::gpu::DeviceInfo>
{ {
img_l.release(); cv::Mat img_l;
img_r.release(); cv::Mat img_r;
img_template.release(); cv::Mat img_template;
}
cv::gpu::DeviceInfo devInfo; cv::gpu::DeviceInfo devInfo;
...@@ -63,30 +59,19 @@ struct StereoTest : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -63,30 +59,19 @@ struct StereoTest : testing::TestWithParam<cv::gpu::DeviceInfo>
devInfo = GetParam(); devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID()); 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_l = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
img_r = readImage("stereobm/aloe-R.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); img_template = readImage("stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
} }
}; };
TEST_P(StereoBlockMatching, Regression) TEST_P(StereoBlockMatching, Regression)
{ {
ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());
PRINT_PARAM(devInfo); PRINT_PARAM(devInfo);
cv::Mat disp; cv::Mat disp;
...@@ -110,20 +95,32 @@ INSTANTIATE_TEST_CASE_P(Calib3D, StereoBlockMatching, testing::ValuesIn(devices( ...@@ -110,20 +95,32 @@ INSTANTIATE_TEST_CASE_P(Calib3D, StereoBlockMatching, testing::ValuesIn(devices(
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// BeliefPropagation // 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_l = readImage("stereobp/aloe-L.png");
img_r = readImage("stereobp/aloe-R.png"); img_r = readImage("stereobp/aloe-R.png");
img_template = readImage("stereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE); img_template = readImage("stereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
ASSERT_FALSE(img_r.empty());
ASSERT_FALSE(img_template.empty());
} }
}; };
TEST_P(StereoBeliefPropagation, Regression) TEST_P(StereoBeliefPropagation, Regression)
{ {
ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());
PRINT_PARAM(devInfo); PRINT_PARAM(devInfo);
cv::Mat disp; cv::Mat disp;
...@@ -147,29 +144,36 @@ INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, testing::ValuesIn(devi ...@@ -147,29 +144,36 @@ INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, testing::ValuesIn(devi
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// ConstantSpaceBP // ConstantSpaceBP
struct StereoConstantSpaceBP : StereoTest struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo>
{ {
static void SetUpTestCase() cv::Mat img_l;
{ cv::Mat img_r;
img_l = readImage("csstereobp/aloe-L.png"); cv::Mat img_template;
img_r = readImage("csstereobp/aloe-R.png");
} cv::gpu::DeviceInfo devInfo;
virtual void SetUp() virtual void SetUp()
{ {
StereoTest::SetUp(); devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
if (supportFeature(GetParam(), cv::gpu::FEATURE_SET_COMPUTE_20)) 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); img_template = readImage("csstereobp/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
else else
img_template = readImage("csstereobp/aloe-disp_CC1X.png", CV_LOAD_IMAGE_GRAYSCALE); 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) TEST_P(StereoConstantSpaceBP, Regression)
{ {
ASSERT_TRUE(!img_l.empty() && !img_r.empty() && !img_template.empty());
PRINT_PARAM(devInfo); PRINT_PARAM(devInfo);
cv::Mat disp; cv::Mat disp;
......
...@@ -48,14 +48,21 @@ ...@@ -48,14 +48,21 @@
struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo> struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo>
{ {
static cv::Mat image; cv::Mat image;
static cv::Mat mask; cv::Mat mask;
static std::vector<cv::KeyPoint> keypoints_gold; std::vector<cv::KeyPoint> keypoints_gold;
static std::vector<float> descriptors_gold; std::vector<float> descriptors_gold;
static void SetUpTestCase() cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
{ {
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
image = readImage("features2d/aloe.png", CV_LOAD_IMAGE_GRAYSCALE); 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::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)); mask(cv::Range(0, image.rows / 2), cv::Range(0, image.cols / 2)).setTo(cv::Scalar::all(0));
...@@ -64,23 +71,6 @@ struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -64,23 +71,6 @@ struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo>
fdetector_gold(image, mask, keypoints_gold, descriptors_gold); fdetector_gold(image, mask, keypoints_gold, descriptors_gold);
} }
static void TearDownTestCase()
{
image.release();
mask.release();
keypoints_gold.clear();
descriptors_gold.clear();
}
cv::gpu::DeviceInfo devInfo;
virtual void SetUp()
{
devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
}
bool isSimilarKeypoints(const cv::KeyPoint& p1, const cv::KeyPoint& p2) bool isSimilarKeypoints(const cv::KeyPoint& p1, const cv::KeyPoint& p2)
{ {
const float maxPtDif = 1.f; const float maxPtDif = 1.f;
...@@ -98,11 +88,6 @@ struct SURF : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -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) TEST_P(SURF, EmptyDataTest)
{ {
PRINT_PARAM(devInfo); PRINT_PARAM(devInfo);
...@@ -123,8 +108,6 @@ TEST_P(SURF, EmptyDataTest) ...@@ -123,8 +108,6 @@ TEST_P(SURF, EmptyDataTest)
TEST_P(SURF, Accuracy) TEST_P(SURF, Accuracy)
{ {
ASSERT_TRUE(!image.empty());
PRINT_PARAM(devInfo); PRINT_PARAM(devInfo);
// Compute keypoints. // Compute keypoints.
...@@ -165,7 +148,7 @@ TEST_P(SURF, Accuracy) ...@@ -165,7 +148,7 @@ TEST_P(SURF, Accuracy)
abs(p1.angle - p2.angle) < maxAngleDif && abs(p1.angle - p2.angle) < maxAngleDif &&
abs(p1.response - p2.response) < maxResponseDif && abs(p1.response - p2.response) < maxResponseDif &&
p1.octave == p2.octave && p1.octave == p2.octave &&
p1.class_id == p2.class_id ) p1.class_id == p2.class_id)
{ {
++validCount; ++validCount;
} }
......
This diff is collapsed.
...@@ -50,7 +50,7 @@ struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor ...@@ -50,7 +50,7 @@ struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor
void run() void run()
{ {
cv::Mat img_rgb = readImage("hog/road.png"); cv::Mat img_rgb = readImage("hog/road.png");
ASSERT_TRUE(!img_rgb.empty()); ASSERT_FALSE(img_rgb.empty());
#ifdef DUMP #ifdef DUMP
f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary); 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 ...@@ -201,7 +201,7 @@ struct CV_GpuHogGetDescriptorsTestRunner : cv::gpu::HOGDescriptor
{ {
// 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");
ASSERT_TRUE(!img_rgb.empty()); ASSERT_FALSE(img_rgb.empty());
// Convert to C4 // Convert to C4
cv::Mat img; 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