Java API: fixing more tests
authorAndrey Pavlenko <no@email>
Tue, 10 Apr 2012 19:17:44 +0000 (19:17 +0000)
committerAndrey Pavlenko <no@email>
Tue, 10 Apr 2012 19:17:44 +0000 (19:17 +0000)
modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java
modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java
modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java
modules/java/android_test/src/org/opencv/test/video/BackgroundSubtractorMOGTest.java

index c02b3ba..e565b48 100644 (file)
@@ -19,6 +19,8 @@ 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;
@@ -84,11 +86,19 @@ 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(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)
+                };
 
         super.setUp();
     }
@@ -179,6 +189,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
         {
                MatOfDMatch vdm = matches.get(i); 
             assertEquals(Math.min(k, train.total()), vdm.total());
+               Log.d("knn", "vdm["+i+"]="+vdm.dump());
             for(DMatch dm : vdm.toArray())
             {
                assertEquals(dm.queryIdx, i);
index d6cf9cd..6c1bd83 100644 (file)
@@ -127,7 +127,7 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
 
         detector.write(filename);
 
-        String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<threshold>10</threshold>\n<nonmaxSuppression>1</nonmaxSuppression>\n</opencv_storage>\n";
+        String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n</opencv_storage>\n";
         assertEquals(truth, readFile(filename));
     }
 
@@ -136,7 +136,7 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
 
         detector.write(filename);
 
-        String truth = "%YAML:1.0\nthreshold: 10\nnonmaxSuppression: 1\n";
+        String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\n";
         assertEquals(truth, readFile(filename));
     }
 
index a261c5b..bbb08f3 100644 (file)
@@ -191,11 +191,19 @@ 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(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)
+                };
 
         super.setUp();
     }
@@ -368,10 +376,16 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
         matcher.match(query, train, matches);
 
         assertArrayDMatchEquals(new DMatch[]{
+                       /*
                        new DMatch(0, 0, 0, 0),
                 new DMatch(1, 2, 0, 0),
                 new DMatch(2, 1, 0, 0),
-                new DMatch(3, 3, 0, 0)}, matches.toArray(), EPS);
+                new DMatch(3, 3, 0, 0)
+                */
+                       new DMatch(1, 2, 0, 42), 
+                       new DMatch(2, 1, 0, 40), 
+                       new DMatch(3, 3, 0, 53)
+                }, matches.toArray(), EPS);
     }
 
     public void testTrain() {
index 5f9874e..5bd64d0 100644 (file)
@@ -46,8 +46,8 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
 
         Mat truth = new Mat(1, 32, CvType.CV_8UC1) {
             {
-                put(0, 0, 20, 51, 88, 22, 14, 181, 78, 111, 36, 144, 62, 0, 188, 196, 4, 8, 133, 80, 96, 18, 64, 29, 0,
-                        254, 230, 247, 12, 2, 78, 129, 70, 145);
+                put(0, 0,
+                               6, 74, 6, 129, 2, 130, 56, 0, 36, 132, 66, 165, 172, 6, 3, 72, 102, 61, 163, 214, 0, 144, 65, 232, 4, 32, 138, 129, 4, 21, 37, 88);
             }
         };
         assertMatEqual(truth, descriptors);
@@ -83,8 +83,8 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
 
         Mat truth = new Mat(1, 32, CvType.CV_8UC1) {
             {
-                put(0, 0, 20, 55, 88, 20, 14, 49, 70, 111, 148, 144, 30, 16, 252, 133, 0, 8, 5, 85, 32, 0, 74, 25, 0,
-                        252, 119, 191, 4, 2, 66, 1, 66, 145);
+                put(0, 0,
+                               6, 10, 22, 5, 2, 130, 56, 0, 44, 164, 66, 165, 140, 6, 1, 72, 38, 61, 163, 210, 0, 208, 1, 104, 4, 32, 10, 131, 0, 37, 37, 67);
             }
         };
         assertMatEqual(truth, descriptors);
@@ -95,7 +95,7 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
 
         extractor.write(filename);
 
-        String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<scaleFactor>1.2000000476837158e+00</scaleFactor>\n<nLevels>3</nLevels>\n<firstLevel>0</firstLevel>\n<edgeThreshold>31</edgeThreshold>\n<patchSize>31</patchSize>\n</opencv_storage>\n";
+        String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.ORB</name>\n<WTA_K>2</WTA_K>\n<edgeThreshold>31</edgeThreshold>\n<firstLevel>0</firstLevel>\n<nFeatures>500</nFeatures>\n<nLevels>8</nLevels>\n<patchSize>31</patchSize>\n<scaleFactor>1.2000000476837158e+00</scaleFactor>\n<scoreType>0</scoreType>\n</opencv_storage>\n";
         assertEquals(truth, readFile(filename));
     }
 
@@ -104,7 +104,7 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
 
         extractor.write(filename);
 
-        String truth = "%YAML:1.0\nscaleFactor: 1.2000000476837158e+00\nnLevels: 3\nfirstLevel: 0\nedgeThreshold: 31\npatchSize: 31\n";
+        String truth = "%YAML:1.0\nname: \"Feature2D.ORB\"\nWTA_K: 2\nedgeThreshold: 31\nfirstLevel: 0\nnFeatures: 500\nnLevels: 8\npatchSize: 31\nscaleFactor: 1.2000000476837158e+00\nscoreType: 0\n";
         assertEquals(truth, readFile(filename));
     }
 
index 01d5221..198d065 100644 (file)
@@ -1,13 +1,6 @@
 package org.opencv.test.video;
 
-import org.opencv.core.Core;
-import org.opencv.core.CvType;
-import org.opencv.core.Mat;
-import org.opencv.core.Point;
-import org.opencv.core.Scalar;
-import org.opencv.highgui.Highgui;
 import org.opencv.test.OpenCVTestCase;
-import org.opencv.video.BackgroundSubtractorMOG;
 
 public class BackgroundSubtractorMOGTest extends OpenCVTestCase {