From a57bc4feea146ef08c81b735d7aae074ffd75269 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Tue, 10 Apr 2012 12:09:14 +0000 Subject: [PATCH] Java API: fixing more tests --- .../src/org/opencv/test/OpenCVTestRunner.java | 17 ++++++++--------- .../org/opencv/test/calib3d/Calib3dTest.java | 16 +++++++--------- .../BruteForceDescriptorMatcherTest.java | 2 +- .../org/opencv/test/highgui/HighguiTest.java | 2 +- .../org/opencv/test/imgproc/ImgprocTest.java | 18 ++++++++++-------- .../opencv/test/objdetect/ObjdetectTest.java | 4 ++++ .../video/BackgroundSubtractorMOGTest.java | 5 ++--- modules/java/gen_java.py | 12 ++++++++---- 8 files changed, 41 insertions(+), 35 deletions(-) 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 fd2920722a..714462ac24 100644 --- a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java +++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java @@ -1,18 +1,18 @@ package org.opencv.test; -import android.content.Context; -import android.test.AndroidTestRunner; -import android.test.InstrumentationTestRunner; -import android.util.Log; - -import org.opencv.android.Utils; -import org.opencv.core.Mat; - import java.io.File; import java.io.IOException; import junit.framework.Assert; +import org.opencv.android.Utils; +import org.opencv.core.Mat; + +import android.content.Context; +import android.test.AndroidTestRunner; +import android.test.InstrumentationTestRunner; +import android.util.Log; + /** * This only class is Android specific. * @@ -55,7 +55,6 @@ public class OpenCVTestRunner extends InstrumentationTestRunner { @Override public void onStart() { - Log.e("OpenCVTestRunner", "onStart()"); context = getContext(); Assert.assertTrue("Context can't be 'null'", context != null); LENA_PATH = Utils.exportResource(context, R.drawable.lena); diff --git a/modules/java/android_test/src/org/opencv/test/calib3d/Calib3dTest.java b/modules/java/android_test/src/org/opencv/test/calib3d/Calib3dTest.java index 4fdaf731f9..9779ef85bf 100644 --- a/modules/java/android_test/src/org/opencv/test/calib3d/Calib3dTest.java +++ b/modules/java/android_test/src/org/opencv/test/calib3d/Calib3dTest.java @@ -235,21 +235,19 @@ public class Calib3dTest extends OpenCVTestCase { public void testFindFundamentalMatListOfPointListOfPoint() { int minFundamentalMatPoints = 8; - MatOfPoint2f pts1 = new MatOfPoint2f(); - MatOfPoint2f pts2 = new MatOfPoint2f(); - pts2.alloc(minFundamentalMatPoints); + MatOfPoint2f pts = new MatOfPoint2f(); + pts.alloc(minFundamentalMatPoints); for (int i = 0; i < minFundamentalMatPoints; i++) { double x = Math.random() * 100 - 50; double y = Math.random() * 100 - 50; - pts1.push_back(new MatOfPoint2f(new Point(x, y))); //add(new Point(x, y)); - pts2.put(i, 0, x, y); //add(new Point(x, y)); + pts.put(i, 0, x, y); //add(new Point(x, y)); } - Mat fm = Calib3d.findFundamentalMat(pts1, pts2); + Mat fm = Calib3d.findFundamentalMat(pts, pts); truth = new Mat(3, 3, CvType.CV_64F); - truth.put(0, 0, 0, -0.5, -0.5, 0.5, 0, 0, 0.5, 0, 0); + truth.put(0, 0, 0, -0.577, 0.288, 0.577, 0, 0.288, -0.288, -0.288, 0); assertMatEqual(truth, fm, EPS); } @@ -280,8 +278,8 @@ public class Calib3dTest extends OpenCVTestCase { for (int i = 0; i < NUM; i++) { double x = Math.random() * 100 - 50; double y = Math.random() * 100 - 50; - originalPoints.put(i, 0, x, y); //add(new Point(x, y)); - transformedPoints.put(i, 0, x, y); //add(new Point(y, x)); + originalPoints.put(i, 0, x, y); + transformedPoints.put(i, 0, y, x); } Mat hmg = Calib3d.findHomography(originalPoints, transformedPoints); 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 a6c6dd1aa5..c02b3bab29 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 @@ -178,7 +178,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { for(int i = 0; i images = Arrays.asList(grayChess); - MatOfInt channels = new MatOfInt(1, 0); - MatOfInt histSize = new MatOfInt(1, 10); + MatOfInt channels = new MatOfInt(1, new int[]{0}); + MatOfInt histSize = new MatOfInt(1, new int[]{10}); MatOfFloat ranges = new MatOfFloat(1, 0f, 256f); Mat hist = new Mat(); @@ -259,8 +259,8 @@ public class ImgprocTest extends OpenCVTestCase { public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloat() { List images = Arrays.asList(gray128); - MatOfInt channels = new MatOfInt(1, 0); - MatOfInt histSize = new MatOfInt(1, 10); + MatOfInt channels = new MatOfInt(1, new int[]{0}); + MatOfInt histSize = new MatOfInt(1, new int[]{10}); MatOfFloat ranges = new MatOfFloat(1, 0f, 256f); Mat hist = new Mat(); @@ -754,8 +754,8 @@ public class ImgprocTest extends OpenCVTestCase { rrect = Imgproc.fitEllipse(points); assertPointEquals(new Point(0, 0), rrect.center, EPS); - assertEquals(2.53, rrect.size.width, EPS); - assertEquals(2.53, rrect.size.height, EPS); + assertEquals(2.828, rrect.size.width, EPS); + assertEquals(2.828, rrect.size.height, EPS); } public void testFitLine() { @@ -981,7 +981,7 @@ public class ImgprocTest extends OpenCVTestCase { Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3); - assertEquals(4, lp.size()); + assertEquals(4, lp.total()); } public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble() { @@ -991,7 +991,7 @@ public class ImgprocTest extends OpenCVTestCase { Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4, true, 0); - assertEquals(4, lp.size()); + assertEquals(4, lp.total()); } public void testGrabCutMatMatRectMatMatInt() { @@ -1759,7 +1759,9 @@ public class ImgprocTest extends OpenCVTestCase { MatOfPoint2f dst = new MatOfPoint2f(); Mat cameraMatrix = Mat.eye(3, 3, CvType.CV_64FC1); Mat distCoeffs = new Mat(8, 1, CvType.CV_64FC1, new Scalar(0)); + Imgproc.undistortPoints(src, dst, cameraMatrix, distCoeffs); + assertEquals(src.size(), dst.size()); for(int i=0; i %(n)s", "suffix" : "J" }, "vector_Point2f" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point2d" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + #"vector_Point2d" : { "j_type" : "MatOfPoint2d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, "vector_Point3i" : { "j_type" : "MatOfPoint3", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, "vector_Point3f" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point3d" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + #"vector_Point3d" : { "j_type" : "MatOfPoint3d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, "vector_KeyPoint" : { "j_type" : "MatOfKeyPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, "vector_DMatch" : { "j_type" : "MatOfDMatch", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, "vector_Rect" : { "j_type" : "MatOfRect", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, @@ -499,7 +499,7 @@ func_arg_fix = { 'randn' : { 'mean' : 'double', 'stddev' : 'double', }, 'inRange' : { 'lowerb' : 'Scalar', 'upperb' : 'Scalar', }, 'goodFeaturesToTrack' : { 'corners' : 'vector_Point', }, - 'findFundamentalMat' : { 'points1' : 'vector_Point2d', 'points2' : 'vector_Point2d', }, + 'findFundamentalMat' : { 'points1' : 'vector_Point2f', 'points2' : 'vector_Point2f', }, 'cornerSubPix' : { 'corners' : 'vector_Point2f', }, 'minEnclosingCircle' : { 'points' : 'vector_Point2f', }, 'findHomography' : { 'srcPoints' : 'vector_Point2f', 'dstPoints' : 'vector_Point2f', }, @@ -519,7 +519,7 @@ func_arg_fix = { 'getAffineTransform' : { 'src' : 'vector_Point2f', 'dst' : 'vector_Point2f', }, 'hconcat' : { 'src' : 'vector_Mat', }, 'vconcat' : { 'src' : 'vector_Mat', }, - 'undistortPoints' : { 'src' : 'vector_Point2d', 'dst' : 'vector_Point2d' }, + 'undistortPoints' : { 'src' : 'vector_Point2f', 'dst' : 'vector_Point2f' }, 'checkRange' : {'pos' : '*'}, 'meanStdDev' : {'mean' : 'vector_double', 'stddev' : 'vector_double'}, 'drawContours' : {'contours' : 'vector_vector_Point'}, @@ -572,6 +572,10 @@ class ArgInfo(object): if ctype.endswith("*"): ctype = ctype[:-1] self.pointer = True + if ctype == 'vector_Point2d': + ctype = 'vector_Point2f' + elif ctype == 'vector_Point3d': + ctype = 'vector_Point3f' self.ctype = ctype self.name = arg_tuple[1] self.defval = arg_tuple[2]