From efdc055fb1958cb47838804c821d1a0ecd6bfef5 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 3 Jul 2012 12:44:32 +0000 Subject: [PATCH] Fixed Java API tests --- .../src/org/opencv/test/OpenCVTestCase.java | 26 ++++++++-------- .../src/org/opencv/test/OpenCVTestRunner.java | 8 ++--- .../BruteForceDescriptorMatcherTest.java | 19 ++++++------ .../BruteForceL1DescriptorMatcherTest.java | 11 +++---- .../BruteForceSL2DescriptorMatcherTest.java | 16 +++++----- .../FlannBasedDescriptorMatcherTest.java | 17 +++++----- .../SURFDescriptorExtractorTest.java | 31 +++++++------------ .../features2d/SURFFeatureDetectorTest.java | 18 ++++------- 8 files changed, 66 insertions(+), 80 deletions(-) diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java index 59b34edf0..102adf195 100644 --- a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java +++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java @@ -25,10 +25,10 @@ import org.opencv.highgui.Highgui; public class OpenCVTestCase extends TestCase { - //change to 'true' to unblock fail on fail("Not yet implemented") - public static final boolean passNYI = true; - - protected static final int matSize = 10; + //change to 'true' to unblock fail on fail("Not yet implemented") + public static final boolean passNYI = true; + + protected static final int matSize = 10; protected static final double EPS = 0.001; protected static final double weakEPS = 0.5; @@ -185,11 +185,11 @@ public class OpenCVTestCase extends TestCase { } public static void fail(String msg) { - if(msg == "Not yet implemented" && passNYI) - return; - TestCase.fail(msg); + if(msg == "Not yet implemented" && passNYI) + return; + TestCase.fail(msg); } - + public static void assertListEquals(List list1, List list2) { if (list1.size() != list2.size()) { throw new UnsupportedOperationException(); @@ -220,7 +220,7 @@ public class OpenCVTestCase extends TestCase { } for (int i = 0; i < ar1.length; i++) - assertEquals(ar1[i].doubleValue(), ar2[i].doubleValue(), epsilon); + assertEquals(ar1[i].doubleValue(), ar2[i].doubleValue(), epsilon); //assertTrue(Math.abs(ar1[i].doubleValue() - ar2[i].doubleValue()) <= epsilon); } @@ -230,7 +230,7 @@ public class OpenCVTestCase extends TestCase { } for (int i = 0; i < ar1.length; i++) - assertEquals(ar1[i], ar2[i], epsilon); + assertEquals(ar1[i], ar2[i], epsilon); //assertTrue(Math.abs(ar1[i].doubleValue() - ar2[i].doubleValue()) <= epsilon); } @@ -341,9 +341,9 @@ public class OpenCVTestCase extends TestCase { } public static void assertListDMatchEquals(List expected, List actual, double epsilon) { - DMatch expectedArray[] = expected.toArray(new DMatch[0]); - DMatch actualArray[] = actual.toArray(new DMatch[0]); - assertArrayDMatchEquals(expectedArray, actualArray, epsilon); + DMatch expectedArray[] = expected.toArray(new DMatch[0]); + DMatch actualArray[] = actual.toArray(new DMatch[0]); + assertArrayDMatchEquals(expectedArray, actualArray, epsilon); } public static void assertPointEquals(Point expected, Point actual, double eps) { diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java index f9a9b15fe..3c416c510 100644 --- a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java +++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java @@ -17,15 +17,15 @@ import android.util.Log; /** * This only class is Android specific. - * + * * @see OpenCV */ public class OpenCVTestRunner extends InstrumentationTestRunner { - static { System.loadLibrary("opencv_java"); } - - public static String LENA_PATH; + static { System.loadLibrary("opencv_java"); } + + public static String LENA_PATH; public static String CHESS_PATH; public static String LBPCASCADE_FRONTALFACE_PATH; public static Context context; diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java index 342328e49..3de8e46a1 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java @@ -84,11 +84,11 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { matSize = 100; truth = new DMatch[] { - 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) + new DMatch(0, 0, 0, 1.049694f), + new DMatch(1, 0, 0, 1.066820f), + new DMatch(2, 1, 0, 0.494587f), + new DMatch(3, 0, 0, 1.141826f), + new DMatch(4, 0, 0, 1.084099f) }; super.setUp(); @@ -166,7 +166,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { } public void testKnnMatchMatMatListOfListOfDMatchInt() { - final int k = 3; + final int k = 3; Mat train = getTrainDescriptors(); Mat query = getQueryDescriptors(); List matches = new ArrayList(); @@ -181,12 +181,12 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { assertEquals(query.rows(), matches.size()); for(int i = 0; i lkp = mkp.toList(); + List lkp = mkp.toList(); order(lkp); assertListKeyPointEquals(Arrays.asList(truth), lkp, EPS); }