From 89338a38af62d0e614757b9965194e30f4394462 Mon Sep 17 00:00:00 2001 From: Ivan Korolev Date: Fri, 6 Apr 2012 13:45:07 +0000 Subject: [PATCH] Fixed some bugs in the ImgprocTest.java module. --- .../src/org/opencv/test/imgproc/ImgprocTest.java | 38 ++++++++++------------ .../src/org/opencv/test/imgproc/Subdiv2DTest.java | 4 +-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java b/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java index 1ec2133..f53756e 100644 --- a/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java +++ b/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java @@ -6,8 +6,11 @@ import java.util.List; import org.opencv.core.Core; import org.opencv.core.CvType; -import org.opencv.core.CvVectorPoint2f; import org.opencv.core.Mat; +import org.opencv.core.MatOfFloat; +import org.opencv.core.MatOfInt; +import org.opencv.core.MatOfPoint; +import org.opencv.core.MatOfPoint2f; import org.opencv.core.Point; import org.opencv.core.Rect; import org.opencv.core.RotatedRect; @@ -142,14 +145,9 @@ public class ImgprocTest extends OpenCVTestCase { } public void testApproxPolyDP() { - CvVectorPoint2f curve = new CvVectorPoint2f(5); - curve.add(new Point(1, 3)); - curve.add(new Point(2, 4)); - curve.add(new Point(3, 5)); - curve.add(new Point(4, 4)); - curve.add(new Point(5, 3)); + MatOfPoint2f curve = new MatOfPoint2f(new Point(1, 3), new Point(2, 4), new Point(3, 5), new Point(4, 4), new Point(5, 3)); - List approxCurve = new ArrayList(); + MatOfPoint2f approxCurve = new MatOfPoint2f(); Imgproc.approxPolyDP(curve, approxCurve, EPS, true); @@ -158,11 +156,11 @@ public class ImgprocTest extends OpenCVTestCase { approxCurveGold.add(new Point(3, 5)); approxCurveGold.add(new Point(5, 3)); - assertListPointEquals(approxCurve, approxCurveGold, EPS); + assertListPointEquals(approxCurve.toList(), approxCurveGold, EPS); } public void testArcLength() { - List curve = Arrays.asList(new Point(1, 3), new Point(2, 4), new Point(3, 5), new Point(4, 4), new Point(5, 3)); + MatOfPoint2f curve = new MatOfPoint2f(new Point(1, 3), new Point(2, 4), new Point(3, 5), new Point(4, 4), new Point(5, 3)); double arcLength = Imgproc.arcLength(curve, false); @@ -213,7 +211,7 @@ public class ImgprocTest extends OpenCVTestCase { } public void testBoundingRect() { - List points = Arrays.asList(new Point(0, 0), new Point(0, 4), new Point(4, 0), new Point(4, 4)); + MatOfPoint points = new MatOfPoint(new Point(0, 0), new Point(0, 4), new Point(4, 0), new Point(4, 4)); Point p1 = new Point(1, 1); Point p2 = new Point(-5, -2); @@ -244,9 +242,9 @@ public class ImgprocTest extends OpenCVTestCase { public void testCalcBackProject() { List images = Arrays.asList(grayChess); - List channels = Arrays.asList(0); - List histSize = Arrays.asList(10); - List ranges = Arrays.asList(0f, 256f); + MatOfInt channels = new MatOfInt(1, 0); + MatOfInt histSize = new MatOfInt(1, 10); + MatOfFloat ranges = new MatOfFloat(1, 0f, 256f); Mat hist = new Mat(); Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges); @@ -261,9 +259,9 @@ public class ImgprocTest extends OpenCVTestCase { public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloat() { List images = Arrays.asList(gray128); - List channels = Arrays.asList(0); - List histSize = Arrays.asList(10); - List ranges = Arrays.asList(0f, 256f); + MatOfInt channels = new MatOfInt(1, 0); + MatOfInt histSize = new MatOfInt(1, 10); + MatOfFloat ranges = new MatOfFloat(1, 0f, 256f); Mat hist = new Mat(); Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges); @@ -278,9 +276,9 @@ public class ImgprocTest extends OpenCVTestCase { public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloat2d() { List images = Arrays.asList(gray255, gray128); - List channels = Arrays.asList(0, 1); - List histSize = Arrays.asList(10, 10); - List ranges = Arrays.asList(0f, 256f, 0f, 256f); + MatOfInt channels = new MatOfInt(1, 0, 1); + MatOfInt histSize = new MatOfInt(1, 10, 10); + MatOfFloat ranges = new MatOfFloat(1, 0f, 256f, 0f, 256f); Mat hist = new Mat(); Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges); diff --git a/modules/java/android_test/src/org/opencv/test/imgproc/Subdiv2DTest.java b/modules/java/android_test/src/org/opencv/test/imgproc/Subdiv2DTest.java index 64114a2..2b176b7 100644 --- a/modules/java/android_test/src/org/opencv/test/imgproc/Subdiv2DTest.java +++ b/modules/java/android_test/src/org/opencv/test/imgproc/Subdiv2DTest.java @@ -1,6 +1,6 @@ package org.opencv.test.imgproc; -import org.opencv.core.CvVectorFloat6; +import org.opencv.core.MatOfFloat; import org.opencv.core.Point; import org.opencv.core.Rect; import org.opencv.imgproc.Subdiv2D; @@ -50,7 +50,7 @@ public class Subdiv2DTest extends OpenCVTestCase { s2d.insert( new Point(20, 10) ); s2d.insert( new Point(20, 20) ); s2d.insert( new Point(10, 20) ); - CvVectorFloat6 triangles = new CvVectorFloat6(); + MatOfFloat triangles = new MatOfFloat(); s2d.getTriangleList(triangles); assertEquals(10, triangles.rows()); /* -- 2.7.4