Commit cdbdb573 authored by acyen's avatar acyen Committed by Vladislav Sovrasov

Fix tests to work transparently with OpenCL SURF.

parent 66843d98
......@@ -357,9 +357,9 @@ protected:
}
if(imgLoadMode == IMREAD_GRAYSCALE)
image.create( 50, 50, CV_8UC1 );
image.create( 256, 256, CV_8UC1 );
else
image.create( 50, 50, CV_8UC3 );
image.create( 256, 256, CV_8UC3 );
try
{
dextractor->compute( image, keypoints, descriptors );
......@@ -1187,7 +1187,7 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression)
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce");
ASSERT_TRUE(matcher != NULL);
Mat imgT(sz, sz, CV_8U, Scalar(255));
Mat imgT(256, 256, CV_8U, Scalar(255));
line(imgT, Point(20, sz/2), Point(sz-21, sz/2), Scalar(100), 2);
line(imgT, Point(sz/2, 20), Point(sz/2, sz-21), Scalar(100), 2);
vector<KeyPoint> kpT;
......@@ -1196,7 +1196,7 @@ TEST(Features2d_BruteForceDescriptorMatcher_knnMatch, regression)
Mat descT;
ext->compute(imgT, kpT, descT);
Mat imgQ(sz, sz, CV_8U, Scalar(255));
Mat imgQ(256, 256, CV_8U, Scalar(255));
line(imgQ, Point(30, sz/2), Point(sz-31, sz/2), Scalar(100), 3);
line(imgQ, Point(sz/2, 30), Point(sz/2, sz-31), Scalar(100), 3);
vector<KeyPoint> kpQ;
......
......@@ -168,9 +168,6 @@ void matchKeyPoints(const vector<KeyPoint>& keypoints0, const Mat& H,
const float r0 = 0.5f * keypoints0[i0].size;
for(size_t i1 = 0; i1 < keypoints1.size(); i1++)
{
if(nearestPointIndex >= 0 && usedMask[i1])
continue;
float r1 = 0.5f * keypoints1[i1].size;
float intersectRatio = calcIntersectRatio(points0t.at<Point2f>(i0), r0,
keypoints1[i1].pt, r1);
......@@ -619,7 +616,7 @@ protected:
TEST(Features2d_RotationInvariance_Detector_SURF, regression)
{
DetectorRotationInvarianceTest test(SURF::create(),
0.44f,
0.65f,
0.76f);
test.safe_run();
}
......@@ -859,10 +856,21 @@ TEST(Features2d_RotationInvariance2_Detector_SURF, regression)
vector<KeyPoint> keypoints;
surf->detect(cross, keypoints);
// Expect 5 keypoints. One keypoint has coordinates (50.0, 50.0).
// The other 4 keypoints should have the same response.
// The order of the keypoints is indeterminate.
ASSERT_EQ(keypoints.size(), (vector<KeyPoint>::size_type) 5);
ASSERT_LT( fabs(keypoints[1].response - keypoints[2].response), 1e-6);
ASSERT_LT( fabs(keypoints[1].response - keypoints[3].response), 1e-6);
ASSERT_LT( fabs(keypoints[1].response - keypoints[4].response), 1e-6);
int i1 = -1;
for(int i = 0; i < 5; i++)
{
if(keypoints[i].pt.x == 50.0f)
;
else if(i1 == -1)
i1 = i;
else
ASSERT_LT(fabs(keypoints[i1].response - keypoints[i].response) / keypoints[i1].response, 1e-6);
}
}
TEST(DISABLED_Features2d_ScaleInvariance_Descriptor_DAISY, regression)
......
......@@ -119,6 +119,7 @@ IMPLEMENT_PARAM_CLASS(Upright, bool)
PARAM_TEST_CASE(SURF, HessianThreshold, Octaves, OctaveLayers, Extended, Upright)
{
bool useOpenCL;
double hessianThreshold;
int nOctaves;
int nOctaveLayers;
......@@ -127,12 +128,18 @@ PARAM_TEST_CASE(SURF, HessianThreshold, Octaves, OctaveLayers, Extended, Upright
virtual void SetUp()
{
useOpenCL = cv::ocl::useOpenCL();
hessianThreshold = get<0>(GetParam());
nOctaves = get<1>(GetParam());
nOctaveLayers = get<2>(GetParam());
extended = get<3>(GetParam());
upright = get<4>(GetParam());
}
virtual void TearDown()
{
cv::ocl::setUseOpenCL(useOpenCL);
}
};
TEST_P(SURF, Detector)
......
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