Java API: fixing more tests

pull/13383/head
Andrey Pavlenko 13 years ago
parent 2c4b5014ac
commit 5f02bbd0d9
  1. 13
      modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java
  2. 12
      modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java
  3. 18
      modules/java/android_test/src/org/opencv/test/features2d/STARFeatureDetectorTest.java
  4. 28
      modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java
  5. 16
      modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java
  6. 6
      modules/java/android_test/src/org/opencv/test/objdetect/ObjdetectTest.java
  7. 2
      modules/java/gen_java.py

@ -41,7 +41,8 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.SURF);
String filename = OpenCVTestRunner.getTempFileName("yml");
writeFile(filename, "%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n");
//writeFile(filename, "%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n");
writeFile(filename, "%YAML:1.0\nname: \"Feature2D.SURF\"\nextended: 1\nhessianThreshold: 8000.\nnOctaveLayers: 2\nnOctaves: 3\nupright: 0\n");
detector.read(filename);
detector.detect(img, keypoints);
@ -83,11 +84,19 @@ 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(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)
};
super.setUp();
}

@ -32,9 +32,11 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
};
}
/*
private float sqr(float val){
return val * val;
}
*/
private Mat getQueryDescriptors() {
Mat img = getQueryImg();
@ -87,11 +89,19 @@ 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(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)
};
super.setUp();
}

@ -47,6 +47,7 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
matSize = 200;
truth = new KeyPoint[] {
/*
new KeyPoint(95, 80, 22, -1, 31.595734f, 0, -1),
new KeyPoint(105, 80, 22, -1, 31.595734f, 0, -1),
new KeyPoint(80, 95, 22, -1, 31.595734f, 0, -1),
@ -55,7 +56,18 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
new KeyPoint(80, 105, 22, -1, 31.595734f, 0, -1),
new KeyPoint(120, 105, 22, -1, 31.595734f, 0, -1),
new KeyPoint(95, 120, 22, -1, 31.595734f, 0, -1),
new KeyPoint(105, 120, 22, -1, 31.595734f, 0, -1) };
new KeyPoint(105, 120, 22, -1, 31.595734f, 0, -1)
*/
new KeyPoint( 95, 80, 22, -1, 31.5957f, 0, -1),
new KeyPoint(105, 80, 22, -1, 31.5957f, 0, -1),
new KeyPoint( 80, 95, 22, -1, 31.5957f, 0, -1),
new KeyPoint(120, 95, 22, -1, 31.5957f, 0, -1),
new KeyPoint(100, 100, 8, -1, 30.f, 0, -1),
new KeyPoint( 80, 105, 22, -1, 31.5957f, 0, -1),
new KeyPoint(120, 105, 22, -1, 31.5957f, 0, -1),
new KeyPoint( 95, 120, 22, -1, 31.5957f, 0, -1),
new KeyPoint(105, 120, 22, -1, 31.5957f, 0, -1)
};
super.setUp();
}
@ -116,7 +128,7 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<maxSize>45</maxSize>\n<responseThreshold>30</responseThreshold>\n<lineThresholdProjected>10</lineThresholdProjected>\n<lineThresholdBinarized>8</lineThresholdBinarized>\n<suppressNonmaxSize>5</suppressNonmaxSize>\n</opencv_storage>\n";
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.STAR</name>\n<lineThresholdBinarized>8</lineThresholdBinarized>\n<lineThresholdProjected>10</lineThresholdProjected>\n<maxSize>45</maxSize>\n<responseThreshold>30</responseThreshold>\n<suppressNonmaxSize>5</suppressNonmaxSize>\n</opencv_storage>\n";
assertEquals(truth, readFile(filename));
}
@ -125,7 +137,7 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "%YAML:1.0\nmaxSize: 45\nresponseThreshold: 30\nlineThresholdProjected: 10\nlineThresholdBinarized: 8\nsuppressNonmaxSize: 5\n";
String truth = "%YAML:1.0\nname: \"Feature2D.STAR\"\nlineThresholdBinarized: 8\nlineThresholdProjected: 10\nmaxSize: 45\nresponseThreshold: 30\nsuppressNonmaxSize: 5\n";
assertEquals(truth, readFile(filename));
}

@ -44,13 +44,29 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
extractor.compute(img, keypoints, descriptors);
Mat truth = new Mat(1, 64, CvType.CV_32FC1) {
Mat truth = new Mat(1, 128, CvType.CV_32FC1) {
{
put(0, 0, 0, 0, 0, 0, 0.011540107, 0.0029440077, 0.095483348, 0.018144149, 0.00014820647, 0, 0.00014820647, 0, 0, 0, 0, 0, 0, -0.00014820647,
put(0, 0,
/*
0, 0, 0, 0, 0.011540107, 0.0029440077, 0.095483348, 0.018144149, 0.00014820647, 0, 0.00014820647, 0, 0, 0, 0, 0, 0, -0.00014820647,
0, 0.00014820647, 0.10196275, 0.0099145742, 0.57075155, 0.047922116, 0, 0, 0, 0, 0, 0, 0, 0, 0.0029440068, -0.011540107, 0.018144149,
0.095483348, 0.085385554, -0.054076977, 0.34105155, 0.47911066, 0.023395451, -0.11012388, 0.088196531, 0.50863767, 0.0031790689,
-0.019882837, 0.0089476965, 0.054817006, -0.0033560959, -0.0011770058, 0.0033560959, 0.0011770058, 0.019882834, 0.0031790687,
0.054817006, 0.0089476984, 0, 0, 0, 0, -0.0011770058, 0.0033560959, 0.0011770058, 0.0033560959);
0.054817006, 0.0089476984, 0, 0, 0, 0, -0.0011770058, 0.0033560959, 0.0011770058, 0.0033560959
*/
0, 0, 0, 0, 0, 0, 0, 0, 0.045382127, 0.075976953, -0.031969212, 0.035002094, 0.012224297, 0.012286193,
-0.0088025155, 0.0088025155, 0.00017225844, 0.00017225844, 0, 0, 8.2743405e-05, 8.2743405e-05, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 8.2743405e-05, 8.2743405e-05, -0.00017225844, 0.00017225844, 0, 0, 0.31723264,
0.42715758, -0.19872268, 0.23621935, 0.033304065, 0.033918764, -0.021780485, 0.021780485, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0088025145, 0.0088025145, 0.012224296, 0.012286192, -0.045382123,
0.075976953, 0.031969212, 0.035002094, 0.10047197, 0.21463872, -0.0012294546, 0.18176091, -0.075555265,
0.35627601, 0.01270232, 0.20058797, -0.037658721, 0.037658721, 0.064850949, 0.064850949, -0.27688536,
0.44229308, 0.14888979, 0.14888979, -0.0031531656, 0.0031531656, 0.0068481555, 0.0072466261, -0.034193151,
0.040314503, 0.01108359, 0.023398584, -0.00071876607, 0.00071876607, -0.0031819802, 0.0031819802, 0, 0,
-0.0013680183, 0.0013680183, 0.034193147, 0.040314503, -0.01108359, 0.023398584, 0.006848156, 0.0072466265,
-0.0031531656, 0.0031531656, 0, 0, 0, 0, 0, 0, 0, 0, -0.0013680183, 0.0013680183, 0, 0, 0.00071876607,
0.00071876607, 0.0031819802, 0.0031819802
);
}
};
@ -62,7 +78,7 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
}
public void testDescriptorSize() {
assertEquals(64, extractor.descriptorSize());
assertEquals(128, extractor.descriptorSize());
}
public void testDescriptorType() {
@ -87,7 +103,7 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
extractor.write(filename);
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<nOctaves>4</nOctaves>\n<nOctaveLayers>2</nOctaveLayers>\n<extended>0</extended>\n<upright>0</upright>\n</opencv_storage>\n";
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.SURF</name>\n<extended>1</extended>\n<hessianThreshold>100.</hessianThreshold>\n<nOctaveLayers>2</nOctaveLayers>\n<nOctaves>4</nOctaves>\n<upright>0</upright>\n</opencv_storage>\n";
assertEquals(truth, readFile(filename));
}
@ -96,7 +112,7 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
extractor.write(filename);
String truth = "%YAML:1.0\nnOctaves: 4\nnOctaveLayers: 2\nextended: 0\nupright: 0\n";
String truth = "%YAML:1.0\nname: \"Feature2D.SURF\"\nextended: 1\nhessianThreshold: 100.\nnOctaveLayers: 2\nnOctaves: 4\nupright: 0\n";
assertEquals(truth, readFile(filename));
}

@ -56,10 +56,18 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
matSize = 100;
truth = new KeyPoint[] { new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1),
truth = new KeyPoint[] {
/*
new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1),
new KeyPoint(44.224422454833984f, 44.224422454833984f, 16, 99.75463f, 8617.863f, 1, -1),
new KeyPoint(44.224422454833984f, 55.775577545166016f, 16, 189.7546f, 8617.863f, 1, -1),
new KeyPoint(55.775577545166016f, 55.775577545166016f, 16, 279.75464f, 8617.863f, 1, -1) };
new KeyPoint(55.775577545166016f, 55.775577545166016f, 16, 279.75464f, 8617.863f, 1, -1)
*/
new KeyPoint(55.7755f, 44.2244f, 16, 9.754f, 8617.863f, 0, -1),
new KeyPoint(44.2244f, 44.2244f, 16, 99.754f, 8617.863f, 0, -1),
new KeyPoint(44.2244f, 55.7755f, 16, 189.754f, 8617.863f, 0, -1),
new KeyPoint(55.7755f, 55.7755f, 16, 279.754f, 8617.863f, 0, -1)
};
super.setUp();
}
@ -151,7 +159,7 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<hessianThreshold>400.</hessianThreshold>\n<octaves>3</octaves>\n<octaveLayers>4</octaveLayers>\n<upright>0</upright>\n</opencv_storage>\n";
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.SURF</name>\n<extended>1</extended>\n<hessianThreshold>100.</hessianThreshold>\n<nOctaveLayers>2</nOctaveLayers>\n<nOctaves>4</nOctaves>\n<upright>0</upright>\n</opencv_storage>\n";
assertEquals(truth, readFile(filename));
}
@ -160,7 +168,7 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "%YAML:1.0\nhessianThreshold: 400.\noctaves: 3\noctaveLayers: 4\nupright: 0\n";
String truth = "%YAML:1.0\nname: \"Feature2D.SURF\"\nextended: 1\nhessianThreshold: 100.\nnOctaveLayers: 2\nnOctaves: 4\nupright: 0\n";
assertEquals(truth, readFile(filename));
}

@ -1,13 +1,12 @@
package org.opencv.test.objdetect;
import org.opencv.core.MatOfRect;
import org.opencv.objdetect.Objdetect;
import org.opencv.test.OpenCVTestCase;
public class ObjdetectTest extends OpenCVTestCase {
public void testGroupRectanglesListOfRectListOfIntegerInt() {
fail("Not yet implemented");
/*
final int NUM = 10;
MatOfRect rects = new MatOfRect();
rects.alloc(NUM);
@ -16,7 +15,6 @@ public class ObjdetectTest extends OpenCVTestCase {
rects.put(i, 0, 10, 10, 20, 20);
int groupThreshold = 1;
/*
Objdetect.groupRectangles(rects, null, groupThreshold);//TODO: second parameter should not be null
assertEquals(1, rects.total());
*/
@ -24,6 +22,7 @@ public class ObjdetectTest extends OpenCVTestCase {
public void testGroupRectanglesListOfRectListOfIntegerIntDouble() {
fail("Not yet implemented");
/*
final int NUM = 10;
MatOfRect rects = new MatOfRect();
rects.alloc(NUM);
@ -36,7 +35,6 @@ public class ObjdetectTest extends OpenCVTestCase {
int groupThreshold = 1;
double eps = 0.2;
/*
Objdetect.groupRectangles(rects, null, groupThreshold, eps);//TODO: second parameter should not be null
assertEquals(2, rects.size());
*/

@ -488,6 +488,8 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize
"setTrackbarPos" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"imshow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"waitKey" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"moveWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
"resizeWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
}, # Highgui
}

Loading…
Cancel
Save