Commit db3f9b13 authored by Andrey Kamaev's avatar Andrey Kamaev

Fixed SURF behavior - from now it always returns keypoints in the same order

parent 562e4042
......@@ -19,8 +19,6 @@ import org.opencv.features2d.KeyPoint;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import android.util.Log;
public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
DescriptorMatcher matcher;
......@@ -86,18 +84,11 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
/*
new DMatch(0, 0, 0, 0.643284f),
new DMatch(1, 1, 0, 0.92945856f),
new DMatch(2, 1, 0, 0.2841479f),
new DMatch(3, 1, 0, 0.9194034f),
new DMatch(4, 1, 0, 0.3006621f)
*/
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.083795f),
new DMatch(2, 1, 0, 0.484352f),
new DMatch(3, 0, 0, 1.098605f),
new DMatch(4, 1, 0, 0.494587f)
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.098605f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 1, 0, 0.484352f),
new DMatch(4, 0, 0, 1.083795f)
};
super.setUp();
......@@ -180,9 +171,10 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
Mat query = getQueryDescriptors();
List<MatOfDMatch> matches = new ArrayList<MatOfDMatch>();
matcher.knnMatch(query, train, matches, k);
/*
Log.d("knnMatch", "train = " + train);
Log.d("knnMatch", "query = " + query);
/*
matcher.add(train);
matcher.knnMatch(query, matches, k);
*/
......@@ -190,7 +182,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
for(int i = 0; i<matches.size(); i++)
{
MatOfDMatch vdm = matches.get(i);
Log.d("knn", "vdm["+i+"]="+vdm.dump());
//Log.d("knn", "vdm["+i+"]="+vdm.dump());
assertTrue(Math.min(k, train.rows()) >= vdm.total());
for(DMatch dm : vdm.toArray())
{
......
......@@ -84,18 +84,11 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
/*
new DMatch(0, 0, 0, 3.175296f),
new DMatch(1, 1, 0, 3.5954158f),
new DMatch(2, 1, 0, 1.2537984f),
new DMatch(3, 1, 0, 3.5761614f),
new DMatch(4, 1, 0, 1.3250958f)
*/
new DMatch(0, 1, 0, 6.920234f),
new DMatch(1, 0, 0, 6.1294847f),
new DMatch(2, 1, 0, 2.6545324f),
new DMatch(3, 1, 0, 6.1675916f),
new DMatch(4, 1, 0, 2.679859f)
new DMatch(0, 1, 0, 6.9202342f),
new DMatch(1, 1, 0, 6.1675916f),
new DMatch(2, 1, 0, 2.6798589f),
new DMatch(3, 1, 0, 2.6545324f),
new DMatch(4, 0, 0, 6.1294847f)
};
super.setUp();
}
......
......@@ -89,18 +89,11 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
/*
new DMatch(0, 0, 0, sqr(0.643284f)),
new DMatch(1, 1, 0, sqr(0.92945856f)),
new DMatch(2, 1, 0, sqr(0.2841479f)),
new DMatch(3, 1, 0, sqr(0.9194034f)),
new DMatch(4, 1, 0, sqr(0.3006621f))
*/
new DMatch(0, 0, 0, 1.1018577f),
new DMatch(1, 0, 0, 1.1746116f),
new DMatch(2, 1, 0, 0.23459719f),
new DMatch(3, 0, 0, 1.2069331f),
new DMatch(4, 1, 0, 0.2446168f)
new DMatch(1, 0, 0, 1.2069331f),
new DMatch(2, 1, 0, 0.2446168f),
new DMatch(3, 1, 0, 0.2345972f),
new DMatch(4, 0, 0, 1.1746116f)
};
super.setUp();
......
......@@ -158,18 +158,11 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
/*
new DMatch(0, 0, 0, 0.643284f),
new DMatch(1, 1, 0, 0.92945856f),
new DMatch(2, 1, 0, 0.2841479f),
new DMatch(3, 1, 0, 0.9194034f),
new DMatch(4, 1, 0, 0.3006621f)
*/
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.083795f),
new DMatch(2, 1, 0, 0.484352f),
new DMatch(3, 0, 0, 1.098605f),
new DMatch(4, 1, 0, 0.494587f)
new DMatch(1, 0, 0, 1.098605f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 1, 0, 0.484352f),
new DMatch(4, 0, 0, 1.083795f)
};
super.setUp();
......
......@@ -443,6 +443,22 @@ struct SURFFindInvoker
float hessianThreshold;
};
struct KeypointGreater
{
inline bool operator()(const KeyPoint& kp1, const KeyPoint& kp2) const
{
if(kp1.response > kp2.response) return true;
if(kp1.response < kp2.response) return false;
if(kp1.size > kp2.size) return true;
if(kp1.size < kp2.size) return false;
if(kp1.octave > kp2.octave) return true;
if(kp1.octave < kp2.octave) return false;
if(kp1.pt.y < kp2.pt.y) return false;
if(kp1.pt.y > kp2.pt.y) return true;
return kp1.pt.x < kp2.pt.y;
}
};
static void fastHessianDetector( const Mat& sum, const Mat& mask_sum, vector<KeyPoint>& keypoints,
int nOctaves, int nOctaveLayers, float hessianThreshold )
......@@ -490,6 +506,8 @@ static void fastHessianDetector( const Mat& sum, const Mat& mask_sum, vector<Key
SURFFindInvoker(sum, mask_sum, dets, traces, sizes,
sampleSteps, middleIndices, keypoints,
nOctaveLayers, hessianThreshold) );
std::sort(keypoints.begin(), keypoints.end(), KeypointGreater());
}
......
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