import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
-import android.util.Log;
-
public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
DescriptorMatcher matcher;
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();
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);
*/
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())
{
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();
}
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();
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();
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 )
SURFFindInvoker(sum, mask_sum, dets, traces, sizes,
sampleSteps, middleIndices, keypoints,
nOctaveLayers, hessianThreshold) );
+
+ std::sort(keypoints.begin(), keypoints.end(), KeypointGreater());
}