java tests: added some new asserts, and new tests by Hussein Abdinoor

pull/13383/head
Kirill Kornyakov 13 years ago
parent c11a7184c9
commit edead9a2c2
  1. 5
      modules/java/android_test/src/org/opencv/test/ConvertersTest.java
  2. 29
      modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
  3. 35
      modules/java/android_test/src/org/opencv/test/core/coreTest.java
  4. 9
      modules/java/android_test/src/org/opencv/test/features2d/StarDetectorTest.java
  5. 141
      modules/java/android_test/src/org/opencv/test/imgproc/imgprocTest.java

@ -1,12 +1,15 @@
package org.opencv.test; package org.opencv.test;
import java.util.ArrayList;
import java.util.List;
public class ConvertersTest extends OpenCVTestCase { public class ConvertersTest extends OpenCVTestCase {
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
} }
public void testMat_to_vector_float() { public void testMat_to_vector_float() {
fail("Not yet implemented"); fail("Not yet implemented");
} }

@ -1,5 +1,7 @@
package org.opencv.test; package org.opencv.test;
import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.opencv.core.CvType; import org.opencv.core.CvType;
@ -14,9 +16,12 @@ public class OpenCVTestCase extends TestCase {
protected static int matSize = 10; protected static int matSize = 10;
protected static double EPS = 0.001; protected static double EPS = 0.001;
protected static double weakEPS = 0.5;
protected static Mat dst; protected static Mat dst;
protected static Mat truth; protected static Mat truth;
protected static Scalar colorBlack;
// Naming notation: <channels info>_[depth]_[dimensions]_value // Naming notation: <channels info>_[depth]_[dimensions]_value
// examples: gray0 - single channel 8U 2d Mat filled with 0 // examples: gray0 - single channel 8U 2d Mat filled with 0
@ -62,7 +67,7 @@ public class OpenCVTestCase extends TestCase {
protected static Mat v1; protected static Mat v1;
protected static Mat v2; protected static Mat v2;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
@ -71,6 +76,8 @@ public class OpenCVTestCase extends TestCase {
assertTrue(dst.empty()); assertTrue(dst.empty());
truth = new Mat(); truth = new Mat();
assertTrue(truth.empty()); assertTrue(truth.empty());
colorBlack = new Scalar(0);
gray0 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0)); gray0 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0));
gray1 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(1)); gray1 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(1));
@ -82,8 +89,7 @@ public class OpenCVTestCase extends TestCase {
gray255 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); gray255 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U, new Scalar(256)); gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U, new Scalar(256));
gray_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S, new Scalar( gray_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S, new Scalar(1024));
1024));
grayRnd = new Mat(matSize, matSize, CvType.CV_8U); grayRnd = new Mat(matSize, matSize, CvType.CV_8U);
Core.randu(grayRnd, new Scalar(0), new Scalar(256)); Core.randu(grayRnd, new Scalar(0), new Scalar(256));
@ -150,7 +156,17 @@ public class OpenCVTestCase extends TestCase {
super.tearDown(); super.tearDown();
} }
public static void assertListEqual(List<Float> list1, List<Float> list2, double epsilon)
{
if (list1.size() != list2.size()) {
throw new UnsupportedOperationException();
}
for (int i = 0; i < list1.size(); i++)
assertTrue(Math.abs(list1.get(i) - list2.get(i)) <= epsilon);
}
public static void assertMatEqual(Mat m1, Mat m2) { public static void assertMatEqual(Mat m1, Mat m2) {
compareMats(m1, m2, true); compareMats(m1, m2, true);
} }
@ -175,6 +191,11 @@ public class OpenCVTestCase extends TestCase {
assertEquals(expected.octave, actual.octave); assertEquals(expected.octave, actual.octave);
assertEquals(expected.class_id, actual.class_id); assertEquals(expected.class_id, actual.class_id);
} }
public static void assertPointEquals(Point expected, Point actual, double eps){
assertEquals(expected.x, actual.x, eps);
assertEquals(expected.y, actual.y, eps);
}
static private void compareMats(Mat expected, Mat actual, boolean isEqualityMeasured) { static private void compareMats(Mat expected, Mat actual, boolean isEqualityMeasured) {
if (expected.type() != actual.type() || expected.cols() != actual.cols() if (expected.type() != actual.type() || expected.cols() != actual.cols()

@ -99,10 +99,8 @@ public class coreTest extends OpenCVTestCase {
Mat covar = new Mat(matSize, matSize, CvType.CV_64FC1); Mat covar = new Mat(matSize, matSize, CvType.CV_64FC1);
Mat mean = new Mat(1, matSize, CvType.CV_64FC1); Mat mean = new Mat(1, matSize, CvType.CV_64FC1);
Core.calcCovarMatrix(gray0_32f, covar, mean, 8 | 1/* Core.calcCovarMatrix(gray0_32f, covar, mean, Core.COVAR_ROWS | Core.COVAR_NORMAL);
* TODO:
* CV_COVAR_NORMAL
*/);
assertMatEqual(gray0_64f, covar, EPS); assertMatEqual(gray0_64f, covar, EPS);
assertMatEqual(gray0_64f_1d, mean, EPS); assertMatEqual(gray0_64f_1d, mean, EPS);
} }
@ -111,10 +109,7 @@ public class coreTest extends OpenCVTestCase {
Mat covar = new Mat(matSize, matSize, CvType.CV_32F); Mat covar = new Mat(matSize, matSize, CvType.CV_32F);
Mat mean = new Mat(1, matSize, CvType.CV_32F); Mat mean = new Mat(1, matSize, CvType.CV_32F);
Core.calcCovarMatrix(gray0_32f, covar, mean, 8 | 1/* Core.calcCovarMatrix(gray0_32f, covar, mean, Core.COVAR_ROWS | Core.COVAR_NORMAL, CvType.CV_32F);
* TODO:
* CV_COVAR_NORMAL
*/, CvType.CV_32F);
assertMatEqual(gray0_32f, covar, EPS); assertMatEqual(gray0_32f, covar, EPS);
assertMatEqual(gray0_32f_1d, mean, EPS); assertMatEqual(gray0_32f_1d, mean, EPS);
} }
@ -744,11 +739,8 @@ public class coreTest extends OpenCVTestCase {
Core.invert(src, dst); Core.invert(src, dst);
assertMatEqual(truth, dst, EPS); assertMatEqual(truth, dst, EPS);
// TODO: needs epsilon comparison Core.gemm(grayRnd_32f, grayRnd_32f.inv(), 1.0, new Mat(), 0.0, dst);
// Mat m = grayRnd_32f.clone(); assertMatEqual(grayE_32f, dst, EPS);
// Mat inv = m.inv();
// Core.gemm(m, inv, 1.0, new Mat(), 0.0, dst);
// assertMatEqual(grayE_32f, dst);
} }
public void testInvertMatMatInt() { public void testInvertMatMatInt() {
@ -852,10 +844,7 @@ public class coreTest extends OpenCVTestCase {
public void testMahalanobis() { public void testMahalanobis() {
Mat covar = new Mat(matSize, matSize, CvType.CV_32F); Mat covar = new Mat(matSize, matSize, CvType.CV_32F);
Mat mean = new Mat(1, matSize, CvType.CV_32F); Mat mean = new Mat(1, matSize, CvType.CV_32F);
Core.calcCovarMatrix(grayRnd_32f, covar, mean, 8 | 1/* Core.calcCovarMatrix(grayRnd_32f, covar, mean, Core.COVAR_ROWS | Core.COVAR_NORMAL, CvType.CV_32F);
* TODO:
* CV_COVAR_NORMAL
*/, CvType.CV_32F);
covar.inv(); covar.inv();
Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols()); Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols());
@ -1222,18 +1211,12 @@ public class coreTest extends OpenCVTestCase {
Mat xCoordinate = new Mat(); Mat xCoordinate = new Mat();
Mat yCoordinate = new Mat(); Mat yCoordinate = new Mat();
// x.put(0, 0, 3.0, 6.0, 5,0);
// y.put(0, 0, 4.0, 8.0, 12.0);
// magnitude.put(0, 0, 5.0, 10.0, 13.0);
// angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
magnitude.put(0, 0, 5.0, 10.0, 13.0); magnitude.put(0, 0, 5.0, 10.0, 13.0);
angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
x.put(0, 0, 3.0, 6.0, 5, 0); x.put(0, 0, 3.0, 6.0, 5, 0);
y.put(0, 0, 4.0, 8.0, 12.0); y.put(0, 0, 4.0, 8.0, 12.0);
// TODO: needs epsilon comparison
Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate); Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate);
assertMatEqual(x, xCoordinate, EPS); assertMatEqual(x, xCoordinate, EPS);
} }
@ -1504,11 +1487,11 @@ public class coreTest extends OpenCVTestCase {
Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2); Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2);
submat.setTo(new Scalar(1.0)); submat.setTo(new Scalar(1.0));
Core.sort(gray0, dst, 0/* TODO: CV_SORT_EVERY_ROW */); Core.sort(gray0, dst, Core.SORT_EVERY_ROW);
submat = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols()); submat = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols());
assertTrue(submat.total() == Core.countNonZero(submat)); assertTrue(submat.total() == Core.countNonZero(submat));
Core.sort(gray0, dst, 1/* TODO: CV_SORT_EVERY_COLUMN */); Core.sort(gray0, dst, Core.SORT_EVERY_COLUMN);
submat = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2); submat = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2);
assertTrue(submat.total() == Core.countNonZero(submat)); assertTrue(submat.total() == Core.countNonZero(submat));
} }
@ -1522,7 +1505,7 @@ public class coreTest extends OpenCVTestCase {
truth.put(1, 0, 0, 2, 1); truth.put(1, 0, 0, 2, 1);
truth.put(2, 0, 0, 1, 2); truth.put(2, 0, 0, 1, 2);
Core.sortIdx(a, b, 0 + 0/* TODO: CV_SORT_EVERY_ROW + CV_SORT_ASCENDING */); Core.sortIdx(a, b, Core.SORT_EVERY_ROW + Core.SORT_ASCENDING);
assertMatEqual(truth, b); assertMatEqual(truth, b);
} }

@ -1,19 +1,16 @@
package org.opencv.test.features2d; package org.opencv.test.features2d;
import java.util.LinkedList;
import java.util.List;
import org.opencv.core.Core; import org.opencv.core.Core;
import org.opencv.core.CvType; import org.opencv.core.CvType;
import org.opencv.core.Mat; import org.opencv.core.Mat;
import org.opencv.core.Point; import org.opencv.core.Point;
import org.opencv.core.RotatedRect;
import org.opencv.core.Scalar; import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.features2d.KeyPoint; import org.opencv.features2d.KeyPoint;
import org.opencv.features2d.StarDetector; import org.opencv.features2d.StarDetector;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import java.util.LinkedList;
import java.util.List;
public class StarDetectorTest extends OpenCVTestCase { public class StarDetectorTest extends OpenCVTestCase {

@ -3,6 +3,7 @@ package org.opencv.test.imgproc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.opencv.Converters;
import org.opencv.core.Core; import org.opencv.core.Core;
import org.opencv.core.CvType; import org.opencv.core.CvType;
import org.opencv.core.Mat; import org.opencv.core.Mat;
@ -11,8 +12,10 @@ import org.opencv.core.Rect;
import org.opencv.core.RotatedRect; import org.opencv.core.RotatedRect;
import org.opencv.core.Scalar; import org.opencv.core.Scalar;
import org.opencv.core.Size; import org.opencv.core.Size;
import org.opencv.core.TermCriteria;
import org.opencv.imgproc.Imgproc; import org.opencv.imgproc.Imgproc;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
public class imgprocTest extends OpenCVTestCase { public class imgprocTest extends OpenCVTestCase {
@ -42,8 +45,8 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testAccumulateMatMat() { public void testAccumulateMatMat() {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
Imgproc.accumulate(gray_64f_2, dst64F); Imgproc.accumulate(gray_64f_2, dst64F);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
assertMatEqual(truth, dst64F, EPS); assertMatEqual(truth, dst64F, EPS);
dst = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0)); dst = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
@ -52,9 +55,8 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testAccumulateMatMatMat() { public void testAccumulateMatMatMat() {
Imgproc.accumulate(gray_64f_2, dst64F, mask); //TODO: use better mask
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
Imgproc.accumulate(gray_64f_2, dst64F, mask); // TODO: use better mask
assertMatEqual(truth, dst64F, EPS); assertMatEqual(truth, dst64F, EPS);
} }
@ -65,13 +67,11 @@ public class imgprocTest extends OpenCVTestCase {
src2.put(0, 0, 2, 1); src2.put(0, 0, 2, 1);
src2.put(1, 0, 1, 2); src2.put(1, 0, 1, 2);
Mat dstImage = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(0));
Imgproc.accumulateProduct(src1, src2, dstImage);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
truth.put(0, 0, 2, 1); truth.put(0, 0, 2, 1);
truth.put(1, 0, 1, 2); truth.put(1, 0, 1, 2);
Mat dstImage = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(
0));
Imgproc.accumulateProduct(src1, src2, dstImage);
assertMatEqual(truth, dstImage, EPS); assertMatEqual(truth, dstImage, EPS);
} }
@ -358,18 +358,35 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testConvertMapsMatMatMatMatInt() { public void testConvertMapsMatMatMatMatInt() {
Mat map1 = new Mat(1, 4, CvType.CV_32FC1, new Scalar(1)); Mat map1 = new Mat(1, 4, CvType.CV_32FC1, new Scalar(1.0));
Mat map2 = new Mat(1, 4, CvType.CV_32FC1, new Scalar(1)); Mat map2 = new Mat(1, 4, CvType.CV_32FC1, new Scalar(2.0));
Mat dstmap1 = new Mat(1, 4, CvType.CV_16SC2); Mat dstmap1 = new Mat(1, 4, CvType.CV_16SC2);
Mat dstmap2 = new Mat(1, 4, CvType.CV_16UC1); Mat dstmap2 = new Mat(1, 4, CvType.CV_16UC1);
// FIXME: dstmap1 - Documentation says Cvtype but requires integer Imgproc.convertMaps(map1, map2, dstmap1, dstmap2, CvType.CV_16SC2);
Imgproc.convertMaps(map1, map2, dstmap1, dstmap2, CvType.CV_32F); Mat truthMap1 = new Mat(1, 4, CvType.CV_16SC2);
fail("Not yet implemented"); truthMap1.put(0, 0, 1, 2, 1, 2, 1, 2, 1, 2);
assertMatEqual(truthMap1, dstmap1);
Mat truthMap2 = new Mat(1, 4, CvType.CV_16UC1, new Scalar(0));
assertMatEqual(truthMap2, dstmap2);
} }
public void testConvertMapsMatMatMatMatIntBoolean() { public void testConvertMapsMatMatMatMatIntBoolean() {
fail("Not yet implemented"); Mat map1 = new Mat(1, 3, CvType.CV_32FC1, new Scalar(2.0));
Mat map2 = new Mat(1, 3, CvType.CV_32FC1, new Scalar(4.0));
Mat dstmap1 = new Mat(1, 3, CvType.CV_16SC2);
Mat dstmap2 = new Mat(1, 3, CvType.CV_16UC1);
Imgproc.convertMaps(map1, map2, dstmap1, dstmap2, CvType.CV_16SC2, false);
Mat truthMap1 = new Mat(1, 3, CvType.CV_16SC2);
truthMap1.put(0, 0, 2, 4, 2, 4, 2, 4);
assertMatEqual(truthMap1, dstmap1);
Mat truthMap2 = new Mat(1, 3, CvType.CV_16UC1, new Scalar(0));
assertMatEqual(truthMap2, dstmap2);
} }
public void testConvexHullMatMat() { public void testConvexHullMatMat() {
@ -518,13 +535,29 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 0.92708343, 0.92708343, 0.92708343); truth.put(1, 0, 0.92708343, 0.92708343, 0.92708343);
truth.put(2, 0, 0.58680564, 0.92708343, 0.68055564); truth.put(2, 0, 0.58680564, 0.92708343, 0.68055564);
Imgproc.cornerMinEigenVal(src, dst, blockSize, ksize, Imgproc.cornerMinEigenVal(src, dst, blockSize, ksize, Imgproc.BORDER_REFLECT);
Imgproc.BORDER_REFLECT);
assertMatEqual(truth, dst, EPS); assertMatEqual(truth, dst, EPS);
} }
public void testCornerSubPix() { public void testCornerSubPix() {
fail("Not yet implemented"); Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128));
Point truthPosition = new Point(img.cols()/2, img.rows()/2);
Rect r = new Rect(new Point(0, 0), truthPosition);
Core.rectangle(img, r.tl(), r.br(), new Scalar(0), -1/*TODO: CV_FILLED*/);
List<Point> corners = new ArrayList<Point>();
corners.add(new Point(truthPosition.x+1, truthPosition.y+1));
Size winSize = new Size(2, 2);
Size zeroZone = new Size(-1, -1);
TermCriteria criteria = new TermCriteria(2/*TODO: CV_TERMCRIT_EPS*/, 0, 0.01);
Mat cornersMat = Converters.vector_Point2f_to_Mat(corners);
Imgproc.cornerSubPix(img, cornersMat, winSize, zeroZone, criteria);
Converters.Mat_to_vector_Point(cornersMat, corners);
assertPointEquals(truthPosition, corners.get(0), weakEPS);
} }
public void testCvtColorMatMatInt() { public void testCvtColorMatMatInt() {
@ -759,8 +792,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testFitEllipse() { public void testFitEllipse() {
Mat points = new Mat(1, 5, CvType.CV_32FC2); // TODO: use the list of Mat points = new Mat(1, 5, CvType.CV_32FC2); //TODO: use the list of Points
// Points
points.put(0, 0, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0); 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(); RotatedRect rrect = new RotatedRect();
@ -1064,12 +1096,20 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testHoughCirclesMatMatIntDoubleDouble() { public void testHoughCirclesMatMatIntDoubleDouble() {
// double minDist = gray255.row(0)/4; int sz = 512;
// Imgproc.HoughCircles(gray255, dst, Imgproc.CV_HOUGH_GRADIENT, 2.0, Mat img = new Mat(sz, sz, CvType.CV_8U, new Scalar(128));
// 0.5);
// TODO : How do we test this? Mat circles = new Mat();
fail("Not yet implemented"); Imgproc.HoughCircles(img, circles, Imgproc.CV_HOUGH_GRADIENT, 2.0, img.rows()/4);
assertEquals(0, circles.cols());
Point center = new Point(img.cols()/2, img.rows()/2);
int radius = Math.min(img.cols()/4, img.rows()/4);
Core.circle(img, center, radius, colorBlack, 3);
Imgproc.HoughCircles(img, circles, Imgproc.CV_HOUGH_GRADIENT, 2.0, img.rows()/4);
assertEquals(1, circles.cols());
} }
public void testHoughCirclesMatMatIntDoubleDoubleDouble() { public void testHoughCirclesMatMatIntDoubleDoubleDouble() {
@ -1129,9 +1169,9 @@ public class imgprocTest extends OpenCVTestCase {
Mat map1 = new Mat(); Mat map1 = new Mat();
Mat map2 = new Mat(); Mat map2 = new Mat();
// FIXME: dstmap1 - Documentation says Cvtype but requires integer //TODO: complete this test
Imgproc.initUndistortRectifyMap(cameraMatrix, distCoeffs, R, Imgproc.initUndistortRectifyMap(cameraMatrix, distCoeffs,
newCameraMatrix, size, CvType.CV_32F, map1, map2); R, newCameraMatrix, size, CvType.CV_32F, map1, map2);
fail("Not yet implemented"); fail("Not yet implemented");
} }
@ -1320,12 +1360,10 @@ public class imgprocTest extends OpenCVTestCase {
public void testLaplacianMatMatIntIntDouble() { public void testLaplacianMatMatIntIntDouble() {
Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(0, 0, -8, 8); truth.put(0, 0, -8, 8);
truth.put(1, 0, 8, -8); truth.put(1, 0, 8, -8);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0);
assertMatEqual(truth, dst, EPS); assertMatEqual(truth, dst, EPS);
} }
@ -1355,13 +1393,11 @@ public class imgprocTest extends OpenCVTestCase {
Mat contour2 = new Mat(1, 4, CvType.CV_32FC2); Mat contour2 = new Mat(1, 4, CvType.CV_32FC2);
contour1.put(0, 0, 1.0, 1.0, 5.0, 1.0, 4.0, 3.0, 6.0, 2.0); contour1.put(0, 0, 1.0, 1.0, 5.0, 1.0, 4.0, 3.0, 6.0, 2.0);
contour1.put(0, 0, 1.0, 1.0, 6.0, 1.0, 4.0, 1.0, 2.0, 5.0); contour2.put(0, 0, 1.0, 1.0, 6.0, 1.0, 4.0, 1.0, 2.0, 5.0);
// TODO: returns random comparers double comparer = Imgproc.matchShapes(contour1, contour2, Imgproc.CV_CONTOURS_MATCH_I1, 1.0);
double comparer = Imgproc.matchShapes(contour1, contour2, double truthComparer = 2.98;
Imgproc.CV_CONTOURS_MATCH_I1, 1.0); assertEquals(truthComparer, comparer, weakEPS);
double expComparer = 2.98;
assertEquals(expComparer, comparer);
} }
public void testMatchTemplate() { public void testMatchTemplate() {
@ -1393,22 +1429,28 @@ public class imgprocTest extends OpenCVTestCase {
points.put(0, 0, 1.0, 1.0, 5.0, 1.0, 4.0, 3.0, 6.0, 2.0); points.put(0, 0, 1.0, 1.0, 5.0, 1.0, 4.0, 3.0, 6.0, 2.0);
RotatedRect rrect = Imgproc.minAreaRect(points); RotatedRect rrect = Imgproc.minAreaRect(points);
// TODO - how to test rotated rectangle assertEquals(new Size(2, 5), rrect.size);
fail("Not yet implemented"); assertEquals(-90.0, rrect.angle);
assertEquals(new Point(3.5, 2), rrect.center);
} }
public void testMinEnclosingCircle() { public void testMinEnclosingCircle() {
Mat points = new Mat(1, 4, CvType.CV_32FC2); Mat points = new Mat(1, 4, CvType.CV_32FC2);
Point actualCenter = new Point();
Point expCenter = new Point(0, 0);
float radius = 0.0f;
// float expectedRadius = 1.0f;
points.put(0, 0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, -1.0); points.put(0, 0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, -1.0);
// TODO: Unexpected radius is returned i.e 0
OpenCVTestRunner.Log(points.toString());
OpenCVTestRunner.Log(points.dump());
Point actualCenter = new Point();
float radius = 347.0f; //FIXME: Unexpected radius is returned i.e 0
Imgproc.minEnclosingCircle(points, actualCenter, radius); Imgproc.minEnclosingCircle(points, actualCenter, radius);
assertEquals(expCenter, actualCenter);
// assertEquals(expectedRadius, radius); Point truthCenter = new Point(0, 0);
fail("Not yet implemented"); assertEquals(truthCenter, actualCenter);
float truthRadius = 1.0f;
OpenCVTestRunner.Log("" + radius);
assertEquals(truthRadius, radius, weakEPS);
} }
public void testMomentsMat() { public void testMomentsMat() {
@ -1548,9 +1590,10 @@ public class imgprocTest extends OpenCVTestCase {
public void testPyrMeanShiftFilteringMatMatDoubleDouble() { public void testPyrMeanShiftFilteringMatMatDoubleDouble() {
Mat src = new Mat(matSize, matSize, CvType.CV_8UC3, new Scalar(0.0)); Mat src = new Mat(matSize, matSize, CvType.CV_8UC3, new Scalar(0.0));
Imgproc.pyrMeanShiftFiltering(src, dst, 2.0, 4.0);
// TODO : size of destination matrix not understandable Imgproc.pyrMeanShiftFiltering(src, dst, 10.0, 50.0);
fail("Not yet implemented"); truth = src.clone();
assertMatEqual(truth, dst);
} }
public void testPyrMeanShiftFilteringMatMatDoubleDoubleInt() { public void testPyrMeanShiftFilteringMatMatDoubleDoubleInt() {

Loading…
Cancel
Save