java tests: updated testFillConvexPolyMatMatScalarIntInt, testFitEllipse colorWhite added

This commit is contained in:
Kirill Kornyakov 2011-08-03 14:18:26 +00:00
parent c57799a877
commit 66e79167ee
3 changed files with 19 additions and 23 deletions

View File

@ -31,6 +31,7 @@ public class OpenCVTestCase extends TestCase {
protected static Mat truth;
protected static Scalar colorBlack;
protected static Scalar colorWhite;
// Naming notation: <channels info>_[depth]_[dimensions]_value
// examples: gray0 - single channel 8U 2d Mat filled with 0
@ -87,6 +88,7 @@ public class OpenCVTestCase extends TestCase {
truth = null;
colorBlack = new Scalar(0);
colorWhite = new Scalar(255, 255, 255);
gray0 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0));
gray1 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(1));

View File

@ -3,7 +3,6 @@ package org.opencv.test.core;
import java.util.ArrayList;
import java.util.List;
import org.opencv.utils.Converters;
import org.opencv.core.Core;
import org.opencv.core.CvException;
import org.opencv.core.CvType;
@ -12,6 +11,7 @@ import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.test.OpenCVTestCase;
import org.opencv.utils.Converters;
public class coreTest extends OpenCVTestCase {
@ -503,25 +503,26 @@ public class coreTest extends OpenCVTestCase {
}
public void testFillConvexPolyMatMatScalarIntInt() {
List<Point> lp = new ArrayList<Point>(4);
List<Point> lp = new ArrayList<Point>();
lp.add(new Point(1, 1));
lp.add(new Point(5, 1));
lp.add(new Point(5, 8));
lp.add(new Point(1, 8));
lp.add(new Point(1, 8));
Mat points = Converters.vector_Point_to_Mat(lp);
List<Point> lp2 = new ArrayList<Point>(4);
lp2.add(new Point(2, 2));
List<Point> lp2 = new ArrayList<Point>();
lp2.add(new Point(0, 0));
lp2.add(new Point(10, 2));
lp2.add(new Point(10, 17)); // TODO: don't know why '16' fails the test
lp2.add(new Point(2, 17)); // TODO: don't know why '16' fails the test
lp2.add(new Point(10, 16));
lp2.add(new Point(2, 16));
Mat points2 = Converters.vector_Point_to_Mat(lp2);
assertTrue(0 == Core.countNonZero(gray0));
Core.fillConvexPoly(gray0, points, new Scalar(150), 4, 0);
assertEquals(0, Core.countNonZero(gray0));
Core.fillConvexPoly(gray0, points, colorWhite, 4 /*TODO: lineType*/, 0);
assertTrue(0 < Core.countNonZero(gray0));
Core.fillConvexPoly(gray0, points2, new Scalar(0), 4, 1);
assertTrue(0 == Core.countNonZero(gray0));
Core.fillConvexPoly(gray0, points2, colorBlack, 4 /*TODO: lineType*/, 0);
assertEquals(0, Core.countNonZero(gray0));
}
public void testFillPolyMatListOfMatScalar() {
@ -1152,14 +1153,11 @@ public class coreTest extends OpenCVTestCase {
public void testPerspectiveTransform() {
Mat src = new Mat(matSize, matSize, CvType.CV_32FC2);
Core.randu(src, 0, 256);
// FIXME: use Mat.diag
Mat transformMatrix = Mat.eye(3, 3, CvType.CV_32F);
Core.perspectiveTransform(src, dst, transformMatrix);
assertMatEqual(src, dst, EPS);
}

View File

@ -14,7 +14,6 @@ import org.opencv.core.Size;
import org.opencv.core.TermCriteria;
import org.opencv.imgproc.Imgproc;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
public class imgprocTest extends OpenCVTestCase {
@ -443,8 +442,8 @@ public class imgprocTest extends OpenCVTestCase {
int ksize = 5;
// TODO: eigen vals and vectors returned = 0 for most src matrices
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC(6), new Scalar(0));
Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC(6), new Scalar(0));
assertMatEqual(truth, dst, EPS);
}
@ -767,15 +766,15 @@ public class imgprocTest extends OpenCVTestCase {
}
public void testFitEllipse() {
Mat points = new Mat(1, 5, CvType.CV_32FC2); // TODO: use the list of Points
Mat points = new Mat(1, 5, CvType.CV_32FC2);
points.put(0, 0, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0);
RotatedRect rrect = new RotatedRect();
rrect = Imgproc.fitEllipse(points);
assertEquals(0.0, rrect.center.x);
assertEquals(0.0, rrect.center.y);
assertEquals(2.0, rrect.size.width);
assertEquals(2.0, rrect.size.height);
assertEquals(2.53, rrect.size.width, EPS);
assertEquals(2.53, rrect.size.height, EPS);
}
public void testFitLine() {
@ -1414,8 +1413,6 @@ public class imgprocTest extends OpenCVTestCase {
points.add(new Point(1, 0));
points.add(new Point(0, 1));
OpenCVTestRunner.Log(points.toString());
Point actualCenter = new Point();
float radius = 347.0f; // FIXME: Unexpected radius is returned i.e 0
Imgproc.minEnclosingCircle(points, actualCenter, radius);
@ -1424,7 +1421,6 @@ public class imgprocTest extends OpenCVTestCase {
assertEquals(truthCenter, actualCenter);
float truthRadius = 1.0f;
OpenCVTestRunner.Log("" + radius);
assertEquals(truthRadius, radius, weakEPS);
}