From 5c0c81076b89db05ded6b70c7d8b793dd9d98a78 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Wed, 4 Apr 2012 15:10:26 +0000 Subject: [PATCH] Java API: fixing Objdetect tests --- .../src/org/opencv/test/imgproc/Subdiv2DTest.java | 4 +-- .../test/objdetect/CascadeClassifierTest.java | 8 +++--- .../org/opencv/test/objdetect/ObjdetectTest.java | 30 ++++++++++------------ 3 files changed, 19 insertions(+), 23 deletions(-) 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 5ce838c..64114a2 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.Mat; +import org.opencv.core.CvVectorFloat6; 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) ); - Mat triangles = new Mat(); + CvVectorFloat6 triangles = new CvVectorFloat6(); s2d.getTriangleList(triangles); assertEquals(10, triangles.rows()); /* diff --git a/modules/java/android_test/src/org/opencv/test/objdetect/CascadeClassifierTest.java b/modules/java/android_test/src/org/opencv/test/objdetect/CascadeClassifierTest.java index ae21aac..f514945 100644 --- a/modules/java/android_test/src/org/opencv/test/objdetect/CascadeClassifierTest.java +++ b/modules/java/android_test/src/org/opencv/test/objdetect/CascadeClassifierTest.java @@ -1,9 +1,7 @@ package org.opencv.test.objdetect; -import java.util.ArrayList; - +import org.opencv.core.CvVectorRect; import org.opencv.core.Mat; -import org.opencv.core.Rect; import org.opencv.core.Size; import org.opencv.imgproc.Imgproc; import org.opencv.objdetect.CascadeClassifier; @@ -34,14 +32,14 @@ public class CascadeClassifierTest extends OpenCVTestCase { public void testDetectMultiScaleMatListOfRect() { CascadeClassifier cc = new CascadeClassifier(OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH); - ArrayList faces = new ArrayList(); + CvVectorRect faces = new CvVectorRect(); Mat greyLena = new Mat(); Imgproc.cvtColor(rgbLena, greyLena, Imgproc.COLOR_RGB2GRAY); // TODO: doesn't detect with 1.1 scale cc.detectMultiScale(greyLena, faces, 1.09, 3, Objdetect.CASCADE_SCALE_IMAGE, new Size(30, 30), new Size()); - assertEquals(1, faces.size()); + assertEquals(1, faces.total()); } public void testDetectMultiScaleMatListOfRectDouble() { diff --git a/modules/java/android_test/src/org/opencv/test/objdetect/ObjdetectTest.java b/modules/java/android_test/src/org/opencv/test/objdetect/ObjdetectTest.java index 4fe33d1..28d25a8 100644 --- a/modules/java/android_test/src/org/opencv/test/objdetect/ObjdetectTest.java +++ b/modules/java/android_test/src/org/opencv/test/objdetect/ObjdetectTest.java @@ -1,8 +1,6 @@ package org.opencv.test.objdetect; -import java.util.ArrayList; - -import org.opencv.core.Rect; +import org.opencv.core.CvVectorRect; import org.opencv.objdetect.Objdetect; import org.opencv.test.OpenCVTestCase; @@ -10,27 +8,27 @@ public class ObjdetectTest extends OpenCVTestCase { public void testGroupRectanglesListOfRectListOfIntegerInt() { fail("Not yet implemented"); - Rect r = new Rect(10, 10, 20, 20); - ArrayList rects = new ArrayList(); + final int NUM = 10; + CvVectorRect rects = new CvVectorRect(NUM); - for (int i = 0; i < 10; i++) - rects.add(r); + for (int i = 0; i < NUM; i++) + 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.size()); + assertEquals(1, rects.total()); } public void testGroupRectanglesListOfRectListOfIntegerIntDouble() { fail("Not yet implemented"); - Rect r1 = new Rect(10, 10, 20, 20); - Rect r2 = new Rect(10, 10, 25, 25); - ArrayList rects = new ArrayList(); - - for (int i = 0; i < 10; i++) - rects.add(r1); - for (int i = 0; i < 10; i++) - rects.add(r2); + final int NUM = 10; + CvVectorRect rects = new CvVectorRect(NUM); + + for (int i = 0; i < NUM; i++) + rects.put(i, 0, 10, 10, 20, 20); + + for (int i = 0; i < NUM; i++) + rects.put(i, 0, 10, 10, 25, 25); int groupThreshold = 1; double eps = 0.2; -- 2.7.4