Commit f7ff65f5 authored by Kirill Kornyakov's avatar Kirill Kornyakov

added java tests for imgproc by Hussein Abdinoor

parent 55aab59e
package org.opencv.test.features2d; package org.opencv.test.features2d;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.opencv.core.Mat; import org.opencv.core.Mat;
import org.opencv.features2d.SURF;
import org.opencv.features2d.KeyPoint; import org.opencv.features2d.KeyPoint;
import org.opencv.features2d.SURF;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner; import org.opencv.test.OpenCVTestRunner;
......
...@@ -13,13 +13,15 @@ import org.opencv.core.Size; ...@@ -13,13 +13,15 @@ import org.opencv.core.Size;
import org.opencv.core.Core; import org.opencv.core.Core;
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 {
private Mat gray_64f_2; private Mat gray_64f_2;
private Mat dst64F; private Mat dst64F;
private Mat mask;
private int imgprocSz; private int imgprocSz;
Point anchorPoint;
Size size;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
...@@ -28,7 +30,10 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -28,7 +30,10 @@ public class imgprocTest extends OpenCVTestCase {
imgprocSz = 2; imgprocSz = 2;
gray_64f_2 = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2)); gray_64f_2 = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
dst64F = new Mat(imgprocSz, imgprocSz, CvType.CV_64F); dst64F = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(0));
mask = new Mat (imgprocSz, imgprocSz, CvType.CV_8U, new Scalar(1));
anchorPoint = new Point(2, 2);
size = new Size(3, 3);
} }
public void test_1() { public void test_1() {
...@@ -36,7 +41,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -36,7 +41,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testAccumulateMatMat() { public void testAccumulateMatMat() {
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(2)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
Imgproc.accumulate(gray_64f_2, dst64F); Imgproc.accumulate(gray_64f_2, dst64F);
assertMatEqual(truth, dst64F); assertMatEqual(truth, dst64F);
...@@ -46,42 +51,38 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -46,42 +51,38 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testAccumulateMatMatMat() { public void testAccumulateMatMatMat() {
Mat mask = new Mat(2, 2, CvType.CV_8U, new Scalar(1)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(2));
Imgproc.accumulate(gray_64f_2, dst64F, mask); //TODO: use better mask Imgproc.accumulate(gray_64f_2, dst64F, mask); //TODO: use better mask
assertMatEqual(truth, dst64F); assertMatEqual(truth, dst64F);
} }
public void testAccumulateProductMatMatMat() { public void testAccumulateProductMatMatMat() {
Mat src1 = new Mat(2, 2, CvType.CV_64F); Mat src1 = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(1));
src1.put(0, 0, 1, 1);
src1.put(1, 0, 1, 1);
Mat src2 = new Mat(2, 2, CvType.CV_64F); Mat src2 = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
src2.put(0, 0, 2, 1); src2.put(0, 0, 2, 1);
src2.put(1, 0, 1, 2); src2.put(1, 0, 1, 2);
truth = new Mat(2, 2, 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(2, 2, CvType.CV_64F, new Scalar(0)); Mat dstImage = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(0));
Imgproc.accumulateProduct(src1, src2, dstImage); Imgproc.accumulateProduct(src1, src2, dstImage);
assertMatEqual(truth, dstImage); assertMatEqual(truth, dstImage);
} }
public void testAccumulateProductMatMatMatMat() { public void testAccumulateProductMatMatMatMat() {
Mat src1 = new Mat(2, 2, CvType.CV_64F); Mat src1 = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
src1.put(0, 0, 1, 1); src1.put(0, 0, 1, 1);
src1.put(1, 0, 0, 1); src1.put(1, 0, 0, 1);
Mat src2 = new Mat(2, 2, CvType.CV_64F); Mat src2 = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
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 mask = new Mat(2, 2, CvType.CV_8U, new Scalar(1)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(0));
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(2));
truth.put(0, 0, 2, 1); truth.put(0, 0, 2, 1);
truth.put(1, 0, 0, 2); truth.put(1, 0, 0, 2);
...@@ -90,29 +91,28 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -90,29 +91,28 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testAccumulateSquareMatMat() { public void testAccumulateSquareMatMat() {
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(4)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(4));
Imgproc.accumulateSquare(gray_64f_2, dst64F); Imgproc.accumulateSquare(gray_64f_2, dst64F);
assertMatEqual(truth, dst64F); assertMatEqual(truth, dst64F);
} }
public void testAccumulateSquareMatMatMat() { public void testAccumulateSquareMatMatMat() {
Mat mask = new Mat(2, 2, CvType.CV_8U, new Scalar(1)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(4));
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(4));
Imgproc.accumulateSquare(gray_64f_2, dst64F, mask); Imgproc.accumulateSquare(gray_64f_2, dst64F, mask);
assertMatEqual(truth, dst64F); assertMatEqual(truth, dst64F);
} }
public void testAccumulateWeightedMatMatDouble() { public void testAccumulateWeightedMatMatDouble() {
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(4)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(4));
Imgproc.accumulateWeighted(gray_64f_2, dst64F, 2.0); Imgproc.accumulateWeighted(gray_64f_2, dst64F, 2.0);
assertMatEqual(truth, dst64F); assertMatEqual(truth, dst64F);
} }
public void testAccumulateWeightedMatMatDoubleMat() { public void testAccumulateWeightedMatMatDoubleMat() {
Mat mask = new Mat(2, 2, CvType.CV_8U, new Scalar(1)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(8));
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(8));
Imgproc.accumulateWeighted(gray_64f_2, dst64F, 4.0, mask); Imgproc.accumulateWeighted(gray_64f_2, dst64F, 4.0, mask);
assertMatEqual(truth, dst64F); assertMatEqual(truth, dst64F);
} }
...@@ -153,34 +153,25 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -153,34 +153,25 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testBlurMatMatSize() { public void testBlurMatMatSize() {
Size sz = new Size(3, 3); Imgproc.blur(gray0, dst, size);
Imgproc.blur(gray0, dst, sz);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
Imgproc.blur(gray255, dst, sz); Imgproc.blur(gray255, dst, size);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
public void testBlurMatMatSizePoint() { public void testBlurMatMatSizePoint() {
Size sz = new Size(3, 3); Imgproc.blur(gray0, dst, size, anchorPoint);
Point anchor = new Point(2, 2);
Imgproc.blur(gray0, dst, sz, anchor);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
} }
public void testBlurMatMatSizePointInt() { public void testBlurMatMatSizePointInt() {
Size sz = new Size(3, 3); Imgproc.blur(gray0, dst, size, anchorPoint, Imgproc.BORDER_REFLECT);
Point anchor = new Point(2, 2);
Imgproc.blur(gray0, dst, sz, anchor, Imgproc.BORDER_REFLECT);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
} }
public void testBorderInterpolate() { public void testBorderInterpolate() {
float val1 = Imgproc.borderInterpolate(100, 150, Imgproc.BORDER_REFLECT_101); float val1 = Imgproc.borderInterpolate(100, 150, Imgproc.BORDER_REFLECT_101);
Imgproc.borderInterpolate(-5, 10, Imgproc.BORDER_WRAP);
assertEquals(100.0f, val1); assertEquals(100.0f, val1);
float val2 = Imgproc.borderInterpolate(-5, 10, Imgproc.BORDER_WRAP); float val2 = Imgproc.borderInterpolate(-5, 10, Imgproc.BORDER_WRAP);
...@@ -200,33 +191,23 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -200,33 +191,23 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testBoxFilterMatMatIntSize() { public void testBoxFilterMatMatIntSize() {
Size sz = new Size(3, 3); Size size = new Size(3, 3);
Imgproc.boxFilter(gray0, dst, 8, sz); Imgproc.boxFilter(gray0, dst, 8, size);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
} }
public void testBoxFilterMatMatIntSizePoint() { public void testBoxFilterMatMatIntSizePoint() {
Size sz = new Size(3, 3); Imgproc.boxFilter(gray0, dst, 8, size, anchorPoint);
Point anchor = new Point(2, 2);
Imgproc.boxFilter(gray0, dst, 8, sz, anchor);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
} }
public void testBoxFilterMatMatIntSizePointBoolean() { public void testBoxFilterMatMatIntSizePointBoolean() {
Size sz = new Size(3, 3); Imgproc.boxFilter(gray255, dst, 8, size, anchorPoint, false);
Point anchor = new Point(2, 2);
Imgproc.boxFilter(gray255, dst, 8, sz, anchor, false);
OpenCVTestRunner.Log(dst.dump());
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
public void testBoxFilterMatMatIntSizePointBooleanInt() { public void testBoxFilterMatMatIntSizePointBooleanInt() {
Size sz = new Size(3, 3); Imgproc.boxFilter(gray255, dst, 8, size, anchorPoint, false, Imgproc.BORDER_REFLECT);
Point anchor = new Point(2, 2);
Imgproc.boxFilter(gray255, dst, 8, sz, anchor, false, Imgproc.BORDER_REFLECT);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
...@@ -390,6 +371,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -390,6 +371,7 @@ public class imgprocTest extends OpenCVTestCase {
assertMatEqual(expHull, dst); assertMatEqual(expHull, dst);
} }
public void testConvexHullMatMatBoolean() { public void testConvexHullMatMatBoolean() {
Mat points = new Mat(1, 6, CvType.CV_32FC2); Mat points = new Mat(1, 6, CvType.CV_32FC2);
points.put(0, 0, 2.0, 0.0, 4.0, 0.0, 3.0, 2.0, 0.0, 2.0, 2.0, 1.0, 3.0, 1.0); points.put(0, 0, 2.0, 0.0, 4.0, 0.0, 3.0, 2.0, 0.0, 2.0, 2.0, 1.0, 3.0, 1.0);
...@@ -413,10 +395,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -413,10 +395,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testCopyMakeBorderMatMatIntIntIntIntInt() { public void testCopyMakeBorderMatMatIntIntIntIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(1));
src.put(0, 0, 1, 1); //TODO: use setTo
src.put(1, 0, 1, 1);
truth = new Mat(6, 6, CvType.CV_32F, new Scalar(1)); truth = new Mat(6, 6, CvType.CV_32F, new Scalar(1));
int border = 2; int border = 2;
...@@ -425,9 +404,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -425,9 +404,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testCopyMakeBorderMatMatIntIntIntIntIntScalar() { public void testCopyMakeBorderMatMatIntIntIntIntIntScalar() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(1.0));
src.put(0, 0, 1, 1); //TODO: use setTo
src.put(1, 0, 1, 1);
truth = new Mat(6, 6, CvType.CV_32F, new Scalar(1)); truth = new Mat(6, 6, CvType.CV_32F, new Scalar(1));
Scalar value = new Scalar(0); Scalar value = new Scalar(0);
...@@ -438,7 +415,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -438,7 +415,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testCornerEigenValsAndVecsMatMatIntInt() { public void testCornerEigenValsAndVecsMatMatIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32FC1); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1);
src.put(0, 0, 1, 2); src.put(0, 0, 1, 2);
src.put(1, 0, 4, 2); src.put(1, 0, 4, 2);
...@@ -446,9 +423,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -446,9 +423,8 @@ public class imgprocTest extends OpenCVTestCase {
int ksize = 5; int ksize = 5;
//TODO: eigen vals and vectors returned = 0 for most src matrices //TODO: eigen vals and vectors returned = 0 for most src matrices
truth = new Mat(2, 2, CvType.CV_32FC(6), new Scalar(0)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC(6), new Scalar(0));
Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize); Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize);
OpenCVTestRunner.Log(dst.dump());
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -461,7 +437,6 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -461,7 +437,6 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(4, 4, CvType.CV_32FC(6), new Scalar(0)); truth = new Mat(4, 4, CvType.CV_32FC(6), new Scalar(0));
Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize, Imgproc.BORDER_REFLECT); Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize, Imgproc.BORDER_REFLECT);
OpenCVTestRunner.Log(dst.dump());
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -484,13 +459,13 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -484,13 +459,13 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testCornerMinEigenValMatMatInt() { public void testCornerMinEigenValMatMatInt() {
Mat src = new Mat(2, 2, CvType.CV_32FC1); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1);
src.put(0, 0, 1, 2); src.put(0, 0, 1, 2);
src.put(1, 0, 2, 1); src.put(1, 0, 2, 1);
int blockSize = 5; int blockSize = 5;
truth = new Mat(2, 2, CvType.CV_32FC1, new Scalar(0)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1, new Scalar(0));
Imgproc.cornerMinEigenVal(src, dst, blockSize); Imgproc.cornerMinEigenVal(src, dst, blockSize);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
...@@ -500,10 +475,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -500,10 +475,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testCornerMinEigenValMatMatIntInt() { public void testCornerMinEigenValMatMatIntInt() {
Mat src = new Mat(3, 3, CvType.CV_32FC1); Mat src = Mat.eye(3, 3, CvType.CV_32FC1);
src.put(0, 0, 1, 0, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1, 0);
src.put(2, 0, 0, 0, 1);
truth = new Mat(3, 3, CvType.CV_32FC1, new Scalar(0)); truth = new Mat(3, 3, CvType.CV_32FC1, new Scalar(0));
int blockSize = 3; int blockSize = 3;
...@@ -518,10 +490,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -518,10 +490,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testCornerMinEigenValMatMatIntIntInt() { public void testCornerMinEigenValMatMatIntIntInt() {
Mat src = new Mat(3, 3, CvType.CV_32FC1); Mat src = Mat.eye(3, 3, CvType.CV_32FC1);
src.put(0, 0, 1, 0, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1, 0);
src.put(2, 0, 0, 0, 1);
truth = new Mat(3, 3, CvType.CV_32FC1, new Scalar(0)); truth = new Mat(3, 3, CvType.CV_32FC1, new Scalar(0));
int blockSize = 3; int blockSize = 3;
...@@ -560,34 +529,30 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -560,34 +529,30 @@ public class imgprocTest extends OpenCVTestCase {
public void testDilateMatMatMatPoint() { public void testDilateMatMatMatPoint() {
Mat kernel = new Mat(); Mat kernel = new Mat();
Point anchor = new Point(2, 2);
Imgproc.dilate(gray255, dst, kernel, anchor); Imgproc.dilate(gray255, dst, kernel, anchorPoint);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
public void testDilateMatMatMatPointInt() { public void testDilateMatMatMatPointInt() {
Mat kernel = new Mat(); Mat kernel = new Mat();
Point anchor = new Point(2, 2);
Imgproc.dilate(gray255, dst, kernel, anchor, 10); Imgproc.dilate(gray255, dst, kernel, anchorPoint, 10);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
public void testDilateMatMatMatPointIntInt() { public void testDilateMatMatMatPointIntInt() {
Mat kernel = new Mat(); Mat kernel = new Mat();
Point anchor = new Point(2, 2);
Imgproc.dilate(gray255, dst, kernel, anchor, 10, Imgproc.BORDER_REFLECT); Imgproc.dilate(gray255, dst, kernel, anchorPoint, 10, Imgproc.BORDER_REFLECT);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
public void testDilateMatMatMatPointIntIntScalar() { public void testDilateMatMatMatPointIntIntScalar() {
Mat kernel = new Mat(); Mat kernel = new Mat();
Point anchor = new Point(2, 2);
Scalar value = new Scalar(0); Scalar value = new Scalar(0);
Imgproc.dilate(gray255, dst, kernel, anchor, 10, Imgproc.BORDER_REFLECT, value); Imgproc.dilate(gray255, dst, kernel, anchorPoint, 10, Imgproc.BORDER_REFLECT, value);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
...@@ -646,10 +611,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -646,10 +611,9 @@ public class imgprocTest extends OpenCVTestCase {
src.put(2, 0, 3, 4, 6); src.put(2, 0, 3, 4, 6);
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(0.0)); truth = new Mat(3, 3, CvType.CV_8U, new Scalar(0.0));
Point point = new Point(2, 2);
Mat kernel = new Mat(); Mat kernel = new Mat();
Imgproc.erode(src, dst, kernel, point); Imgproc.erode(src, dst, kernel, anchorPoint);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -661,9 +625,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -661,9 +625,8 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0)); truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat(); Mat kernel = new Mat();
Point point = new Point(2, 2);
Imgproc.erode(src, dst, kernel, point, 10); Imgproc.erode(src, dst, kernel, anchorPoint, 10);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -675,9 +638,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -675,9 +638,8 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0)); truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat(); Mat kernel = new Mat();
Point point = new Point(2, 2);
Imgproc.erode(src, dst, kernel, point, 10, Imgproc.BORDER_REFLECT); Imgproc.erode(src, dst, kernel, anchorPoint, 10, Imgproc.BORDER_REFLECT);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -689,41 +651,39 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -689,41 +651,39 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0)); truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat(); Mat kernel = new Mat();
Point point = new Point(2, 2);
Scalar sc = new Scalar(3, 3); Scalar sc = new Scalar(3, 3);
Imgproc.erode(src, dst, kernel, point, 10, Imgproc.BORDER_REFLECT, sc); Imgproc.erode(src, dst, kernel, anchorPoint, 10, Imgproc.BORDER_REFLECT, sc);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testFilter2DMatMatIntMat() { public void testFilter2DMatMatIntMat() {
Mat kernel = new Mat(2, 2, CvType.CV_32F); Mat src = Mat.eye(4, 4, CvType.CV_32F);
Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(1.0));
Imgproc.filter2D(gray128, dst, -1, kernel); truth = Mat.eye(4, 4, CvType.CV_32F);
assertMatEqual(gray0, dst); truth.put(0, 0, 2, 2, 1, 0);
} truth.put(1, 0, 2, 2, 1, 0);
truth.put(2, 0, 1, 1, 2, 1);
truth.put(3, 0, 0, 0, 1, 2);
public void testFilter2DMatMatIntMatPoint() { Imgproc.filter2D(src, dst, -1, kernel);
Mat kernel = new Mat(2, 2, CvType.CV_32F); assertMatEqual(truth, dst);
Point anchor = new Point(0, 0);
Imgproc.filter2D(gray128, dst, -1, kernel, anchor);
assertMatEqual(gray0, dst);
} }
public void testFilter2DMatMatIntMatPointDouble() { public void testFilter2DMatMatIntMatPoint() {
Mat kernel = new Mat(2, 2, CvType.CV_32F); Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(1.0));
Point anchor = new Point(0, 0); Point point = new Point(0, 0);
Imgproc.filter2D(gray0, dst, -1, kernel, anchor, 2.0); Imgproc.filter2D(gray128, dst, -1, kernel, point);
assertMatEqual(gray2, dst); assertMatEqual(gray255, dst);
} }
public void testFilter2DMatMatIntMatPointDoubleInt() { public void testFilter2DMatMatIntMatPointDoubleInt() {
Mat kernel = new Mat(2, 2, CvType.CV_32F); Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0.0));
Point anchor = new Point(0, 0); Point point = new Point(0, 0);
Imgproc.filter2D(gray128, dst, -1, kernel, anchor, 2.0, Imgproc.BORDER_CONSTANT); Imgproc.filter2D(gray128, dst, -1, kernel, point, 2.0, Imgproc.BORDER_CONSTANT);
assertMatEqual(gray2, dst); assertMatEqual(gray2, dst);
} }
...@@ -736,8 +696,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -736,8 +696,8 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testFitEllipse() { public void testFitEllipse() {
Mat points = new Mat(1, 6, CvType.CV_32FC2); //TODO: use the list of Point Mat points = new Mat(1, 5, CvType.CV_32FC2); //TODO: use the list of Points
points.put(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();
rrect = Imgproc.fitEllipse(points); rrect = Imgproc.fitEllipse(points);
...@@ -779,26 +739,21 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -779,26 +739,21 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testGaussianBlurMatMatSizeDouble() { public void testGaussianBlurMatMatSizeDouble() {
Size sz = new Size(3, 3); Imgproc.GaussianBlur(gray0, dst, size, 1.0);
Imgproc.GaussianBlur(gray0, dst, sz, 1.0);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
Imgproc.GaussianBlur(gray2, dst, sz, 1.0); Imgproc.GaussianBlur(gray2, dst, size, 1.0);
assertMatEqual(gray2, dst); assertMatEqual(gray2, dst);
} }
public void testGaussianBlurMatMatSizeDoubleDouble() { public void testGaussianBlurMatMatSizeDoubleDouble() {
Size sz = new Size(3, 3); Imgproc.GaussianBlur(gray2, dst, size, 0.0, 0.0);
Imgproc.GaussianBlur(gray2, dst, sz, 0.0, 0.0);
assertMatEqual(gray2, dst); assertMatEqual(gray2, dst);
} }
public void testGaussianBlurMatMatSizeDoubleDoubleInt() { public void testGaussianBlurMatMatSizeDoubleDoubleInt() {
Size sz = new Size(3, 3); Imgproc.GaussianBlur(gray2, dst, size, 1.0, 3.0, Imgproc.BORDER_REFLECT);
Imgproc.GaussianBlur(gray2, dst, sz, 1.0, 3.0, Imgproc.BORDER_REFLECT);
assertMatEqual(gray2, dst); assertMatEqual(gray2, dst);
} }
...@@ -816,7 +771,6 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -816,7 +771,6 @@ public class imgprocTest extends OpenCVTestCase {
public void testGetDefaultNewCameraMatrixMatSize() { public void testGetDefaultNewCameraMatrixMatSize() {
truth = new Mat(); truth = new Mat();
Size size = new Size(3, 3);
truth = Imgproc.getDefaultNewCameraMatrix(gray0, size); truth = Imgproc.getDefaultNewCameraMatrix(gray0, size);
assertTrue(0 == Core.countNonZero(truth)); assertTrue(0 == Core.countNonZero(truth));
...@@ -825,7 +779,6 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -825,7 +779,6 @@ public class imgprocTest extends OpenCVTestCase {
public void testGetDefaultNewCameraMatrixMatSizeBoolean() { public void testGetDefaultNewCameraMatrixMatSizeBoolean() {
truth = new Mat(); truth = new Mat();
Size size = new Size(3, 3);
truth = Imgproc.getDefaultNewCameraMatrix(gray0, size, true); truth = Imgproc.getDefaultNewCameraMatrix(gray0, size, true);
assertTrue(0 != Core.countNonZero(truth)); assertTrue(0 != Core.countNonZero(truth));
...@@ -833,8 +786,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -833,8 +786,8 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testGetDerivKernelsMatMatIntIntInt() { public void testGetDerivKernelsMatMatIntIntInt() {
Mat kx = new Mat(2, 2, CvType.CV_32F); Mat kx = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat ky = new Mat(2, 2, CvType.CV_32F); Mat ky = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat expKx = new Mat(3, 1, CvType.CV_32F); Mat expKx = new Mat(3, 1, CvType.CV_32F);
Mat expKy = new Mat(3, 1, CvType.CV_32F); Mat expKy = new Mat(3, 1, CvType.CV_32F);
...@@ -853,8 +806,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -853,8 +806,8 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testGetDerivKernelsMatMatIntIntIntBoolean() { public void testGetDerivKernelsMatMatIntIntIntBoolean() {
Mat kx = new Mat(2, 2, CvType.CV_32F); Mat kx = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat ky = new Mat(2, 2, CvType.CV_32F); Mat ky = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat expKx = new Mat(3, 1, CvType.CV_32F); Mat expKx = new Mat(3, 1, CvType.CV_32F);
Mat expKy = new Mat(3, 1, CvType.CV_32F); Mat expKy = new Mat(3, 1, CvType.CV_32F);
...@@ -873,8 +826,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -873,8 +826,8 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testGetDerivKernelsMatMatIntIntIntBooleanInt() { public void testGetDerivKernelsMatMatIntIntIntBooleanInt() {
Mat kx = new Mat(2, 2, CvType.CV_32F); Mat kx = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat ky = new Mat(2, 2, CvType.CV_32F); Mat ky = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat expKx = new Mat(3, 1, CvType.CV_32F); Mat expKx = new Mat(3, 1, CvType.CV_32F);
Mat expKy = new Mat(3, 1, CvType.CV_32F); Mat expKy = new Mat(3, 1, CvType.CV_32F);
...@@ -909,10 +862,10 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -909,10 +862,10 @@ public class imgprocTest extends OpenCVTestCase {
public void testGetRectSubPixMatSizePointMat() { public void testGetRectSubPixMatSizePointMat() {
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(255)); truth = new Mat(3, 3, CvType.CV_8U, new Scalar(255));
Size patchSize = new Size(3, 3); Size size = new Size(3, 3);
Point center = new Point(gray255.cols() / 2, gray255.rows() / 2); Point center = new Point(gray255.cols() / 2, gray255.rows() / 2);
Imgproc.getRectSubPix(gray255, patchSize, center, dst); Imgproc.getRectSubPix(gray255, size, center, dst);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -937,23 +890,19 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -937,23 +890,19 @@ public class imgprocTest extends OpenCVTestCase {
public void testGetStructuringElementIntSize() { public void testGetStructuringElementIntSize() {
truth = new Mat(3, 3, CvType.CV_8UC1, new Scalar(1.0)); truth = new Mat(3, 3, CvType.CV_8UC1, new Scalar(1.0));
Size ksize = new Size(3, 3);
dst = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, ksize); dst = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, size);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testGetStructuringElementIntSizePoint() { public void testGetStructuringElementIntSizePoint() {
truth = new Mat(3, 3, CvType.CV_8UC1); truth = new Mat(3, 3, CvType.CV_8UC1);
Size ksize = new Size(3, 3);
Point point = new Point(2, 2);
truth.put(0, 0, 0, 0, 1); truth.put(0, 0, 0, 0, 1);
truth.put(1, 0, 0, 0, 1); truth.put(1, 0, 0, 0, 1);
truth.put(2, 0, 1, 1, 1); truth.put(2, 0, 1, 1, 1);
dst = Imgproc.getStructuringElement(Imgproc.MORPH_CROSS, ksize, point); dst = Imgproc.getStructuringElement(Imgproc.MORPH_CROSS, size, anchorPoint);
OpenCVTestRunner.Log(dst.dump());
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1054,7 +1003,6 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1054,7 +1003,6 @@ public class imgprocTest extends OpenCVTestCase {
Mat newCameraMatrix = new Mat(3, 3, CvType.CV_32F, new Scalar(3.0)); Mat newCameraMatrix = new Mat(3, 3, CvType.CV_32F, new Scalar(3.0));
Mat distCoeffs = new Mat(); Mat distCoeffs = new Mat();
Size size = new Size(3, 3);
Mat map1 = new Mat(); Mat map1 = new Mat();
Mat map2 = new Mat(); Mat map2 = new Mat();
...@@ -1141,9 +1089,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1141,9 +1089,9 @@ public class imgprocTest extends OpenCVTestCase {
public void testIntegral3MatMatMatMat() { public void testIntegral3MatMatMatMat() {
Mat src = new Mat(1, 1, CvType.CV_32F, new Scalar(1.0)); Mat src = new Mat(1, 1, CvType.CV_32F, new Scalar(1.0));
Mat expSum = new Mat(2, 2, CvType.CV_64F); Mat expSum = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
Mat expSqsum = new Mat(2, 2, CvType.CV_64F); Mat expSqsum = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
Mat expTilted = new Mat(2, 2, CvType.CV_64F); Mat expTilted = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
Mat sum = new Mat(); Mat sum = new Mat();
Mat sqsum = new Mat(); Mat sqsum = new Mat();
Mat tilted = new Mat(); Mat tilted = new Mat();
...@@ -1166,9 +1114,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1166,9 +1114,9 @@ public class imgprocTest extends OpenCVTestCase {
public void testIntegral3MatMatMatMatInt() { public void testIntegral3MatMatMatMatInt() {
Mat src = new Mat(1, 1, CvType.CV_32F, new Scalar(1.0)); Mat src = new Mat(1, 1, CvType.CV_32F, new Scalar(1.0));
Mat expSum = new Mat(2, 2, CvType.CV_64F); Mat expSum = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
Mat expSqsum = new Mat(2, 2, CvType.CV_64F); Mat expSqsum = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
Mat expTilted = new Mat(2, 2, CvType.CV_64F); Mat expTilted = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
Mat sum = new Mat(); Mat sum = new Mat();
Mat sqsum = new Mat(); Mat sqsum = new Mat();
Mat tilted = new Mat(); Mat tilted = new Mat();
...@@ -1189,7 +1137,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1189,7 +1137,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testIntegralMatMat() { public void testIntegralMatMat() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(2.0));
truth = new Mat(3, 3, CvType.CV_64F); truth = new Mat(3, 3, CvType.CV_64F);
truth.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
...@@ -1202,7 +1150,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1202,7 +1150,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testIntegralMatMatInt() { public void testIntegralMatMatInt() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(2.0));
truth = new Mat(3, 3, CvType.CV_64F); truth = new Mat(3, 3, CvType.CV_64F);
truth.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
...@@ -1214,10 +1162,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1214,10 +1162,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testInvertAffineTransform() { public void testInvertAffineTransform() {
Mat src = new Mat(2, 3, CvType.CV_64F); Mat src = new Mat(2, 3, CvType.CV_64F, new Scalar(1));
src.put(0, 0, 1, 1, 1); //TODO: use setTo
src.put(1, 0, 1, 1, 1);
truth = new Mat(2, 3, CvType.CV_64F, new Scalar(0)); truth = new Mat(2, 3, CvType.CV_64F, new Scalar(0));
Imgproc.invertAffineTransform(src, dst); Imgproc.invertAffineTransform(src, dst);
...@@ -1248,11 +1193,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1248,11 +1193,9 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testLaplacianMatMatIntIntDouble() { public void testLaplacianMatMatIntIntDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1);
truth = new Mat(2, 2, 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);
...@@ -1262,24 +1205,22 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1262,24 +1205,22 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testLaplacianMatMatIntIntDoubleDouble() { public void testLaplacianMatMatIntIntDoubleDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
truth = new Mat(2, 2, CvType.CV_32F);
double delta = 0.0;
src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1);
truth.put(0, 0, -8, 8); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(1, 0, 8, -8);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, delta); truth.put(0, 0, -7.9990001, 8.0009995);
truth.put(1, 0, 8.0009995, -7.9990001);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, EPS);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testLaplacianMatMatIntIntDoubleDoubleInt() { public void testLaplacianMatMatIntIntDoubleDoubleInt() {
Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(2.0));
truth = new Mat(3, 3, CvType.CV_32F, new Scalar(0.0)); truth = new Mat(3, 3, CvType.CV_32F, new Scalar(0.00099945068));
double delta = 0.0;
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, delta, Imgproc.BORDER_REFLECT); Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, EPS, Imgproc.BORDER_REFLECT);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1290,14 +1231,15 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1290,14 +1231,15 @@ public class imgprocTest extends OpenCVTestCase {
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); contour1.put(0, 0, 1.0, 1.0, 6.0, 1.0, 4.0, 1.0, 2.0, 5.0);
double comparer = Imgproc.matchShapes(contour1, contour2, Imgproc.CV_CONTOURS_MATCH_I1, 0.0); //TODO: returns random comparers
double expComparer = 3.277376429165456; double comparer = Imgproc.matchShapes(contour1, contour2, Imgproc.CV_CONTOURS_MATCH_I1, 1.0);
double expComparer = 2.98;
assertEquals(expComparer, comparer); assertEquals(expComparer, comparer);
} }
public void testMatchTemplate() { public void testMatchTemplate() {
Mat image = new Mat(2, 2, CvType.CV_8U); Mat image = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
Mat templ = new Mat(2, 2, CvType.CV_8U); Mat templ = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
image.put(0, 0, 1, 2, 3, 4); image.put(0, 0, 1, 2, 3, 4);
templ.put(0, 0, 5, 6, 7, 8); templ.put(0, 0, 5, 6, 7, 8);
...@@ -1324,7 +1266,6 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1324,7 +1266,6 @@ 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);
OpenCVTestRunner.Log(rrect.toString());
// TODO - how to test rotated rectangle // TODO - how to test rotated rectangle
fail("Not yet implemented"); fail("Not yet implemented");
} }
...@@ -1357,67 +1298,56 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1357,67 +1298,56 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testMorphologyExMatMatIntMatPoint() { public void testMorphologyExMatMatIntMatPoint() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_8U);
src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1);
Mat kernel = new Mat(2, 2, CvType.CV_8U, new Scalar(0)); Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_8U, new Scalar(0));
Point point = new Point(0, 0); Point point = new Point(0, 0);
truth = new Mat(2, 2, CvType.CV_8U); truth = Mat.eye(imgprocSz, imgprocSz, CvType.CV_8U);
truth.put(0, 0, 1, 0); //TODO: use Mat.eye
truth.put(1, 0, 0, 1);
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_OPEN, kernel, point); Imgproc.morphologyEx(src, dst, Imgproc.MORPH_OPEN, kernel, point);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testMorphologyExMatMatIntMatPointInt() { public void testMorphologyExMatMatIntMatPointInt() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_8U);
src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1);
Mat kernel = new Mat(2, 2, CvType.CV_8U, new Scalar(0)); Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_8U, new Scalar(0));
Point point = new Point(0, 0); Point point = new Point(0, 0);
truth = new Mat(2, 2, CvType.CV_8U);
truth.put(0, 0, 1, 0); //TODO: use Mat.eye
truth.put(1, 0, 0, 1);
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_CLOSE, kernel, point, 10); Imgproc.morphologyEx(src, dst, Imgproc.MORPH_CLOSE, kernel, point, 10);
truth = Mat.eye(imgprocSz, imgprocSz, CvType.CV_8U);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testMorphologyExMatMatIntMatPointIntInt() { public void testMorphologyExMatMatIntMatPointIntInt() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
src.put(0, 0, 2, 1); src.put(0, 0, 2, 1);
src.put(1, 0, 2, 1); src.put(1, 0, 2, 1);
Mat kernel = new Mat(2, 2, CvType.CV_8U, new Scalar(1)); Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_8U, new Scalar(1));
Point point = new Point(1, 1); Point point = new Point(1, 1);
truth = new Mat(2, 2, CvType.CV_8U); Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10, Imgproc.BORDER_REFLECT);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
truth.put(0, 0, 1, 0); truth.put(0, 0, 1, 0);
truth.put(1, 0, 1, 0); truth.put(1, 0, 1, 0);
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10, Imgproc.BORDER_REFLECT);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testMorphologyExMatMatIntMatPointIntIntScalar() { public void testMorphologyExMatMatIntMatPointIntIntScalar() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
src.put(0, 0, 2, 1); src.put(0, 0, 2, 1);
src.put(1, 0, 2, 1); src.put(1, 0, 2, 1);
Mat kernel = new Mat(2, 2, CvType.CV_8U, new Scalar(1)); Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_8U, new Scalar(1));
Point point = new Point(1, 1); Point point = new Point(1, 1);
Scalar sc = new Scalar(3, 3); Scalar sc = new Scalar(3, 3);
truth = new Mat(2, 2, CvType.CV_8U); Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10, Imgproc.BORDER_REFLECT, sc);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
truth.put(0, 0, 1, 0); truth.put(0, 0, 1, 0);
truth.put(1, 0, 1, 0); truth.put(1, 0, 1, 0);
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10, Imgproc.BORDER_REFLECT, sc);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1457,23 +1387,21 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1457,23 +1387,21 @@ public class imgprocTest extends OpenCVTestCase {
public void testPyrDownMatMat() { public void testPyrDownMatMat() {
Mat src = new Mat(4, 4, CvType.CV_32F); Mat src = new Mat(4, 4, CvType.CV_32F);
truth = new Mat(2, 2, CvType.CV_32F);
src.put(0, 0, 2, 1, 4, 2); src.put(0, 0, 2, 1, 4, 2);
src.put(1, 0, 3, 2, 6, 8); src.put(1, 0, 3, 2, 6, 8);
src.put(2, 0, 4, 6, 8, 10); src.put(2, 0, 4, 6, 8, 10);
src.put(3, 0, 12, 32, 6, 18); src.put(3, 0, 12, 32, 6, 18);
Imgproc.pyrDown(src, dst);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(0, 0, 2.78125, 4.609375); truth.put(0, 0, 2.78125, 4.609375);
truth.put(1, 0, 8.546875, 8.8515625); truth.put(1, 0, 8.546875, 8.8515625);
Imgproc.pyrDown(src, dst);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testPyrDownMatMatSize() { public void testPyrDownMatMatSize() {
Mat src = new Mat(4, 4, CvType.CV_32F); Mat src = new Mat(4, 4, CvType.CV_32F);
truth = new Mat(2, 2, CvType.CV_32F); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Size dstSize = new Size(2, 2); Size dstSize = new Size(2, 2);
src.put(0, 0, 2, 1, 4, 2); src.put(0, 0, 2, 1, 4, 2);
...@@ -1489,8 +1417,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1489,8 +1417,9 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testPyrMeanShiftFilteringMatMatDoubleDouble() { public void testPyrMeanShiftFilteringMatMatDoubleDouble() {
Mat src = new Mat(8, 8, CvType.CV_8UC3, new Scalar(1.0)); Mat src = new Mat(matSize, matSize, CvType.CV_8UC3, new Scalar(0.0));
Imgproc.pyrMeanShiftFiltering(src, dst, 2.0, 4.0); Imgproc.pyrMeanShiftFiltering(src, dst, 2.0, 4.0);
//TODO : size of destination matrix not understandable
fail("Not yet implemented"); fail("Not yet implemented");
} }
...@@ -1503,7 +1432,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1503,7 +1432,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testPyrUpMatMat() { public void testPyrUpMatMat() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
src.put(0, 0, 2, 1); src.put(0, 0, 2, 1);
src.put(1, 0, 3, 2); src.put(1, 0, 3, 2);
...@@ -1518,7 +1447,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1518,7 +1447,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testPyrUpMatMatSize() { public void testPyrUpMatMatSize() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
src.put(0, 0, 2, 1); src.put(0, 0, 2, 1);
src.put(1, 0, 3, 2); src.put(1, 0, 3, 2);
...@@ -1534,7 +1463,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1534,7 +1463,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testRemapMatMatMatMatInt() { public void testRemapMatMatMatMatInt() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(2.0));
Mat map1 = new Mat(1, 3, CvType.CV_32FC1); Mat map1 = new Mat(1, 3, CvType.CV_32FC1);
Mat map2 = new Mat(1, 3, CvType.CV_32FC1); Mat map2 = new Mat(1, 3, CvType.CV_32FC1);
...@@ -1548,7 +1477,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1548,7 +1477,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testRemapMatMatMatMatIntInt() { public void testRemapMatMatMatMatIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(2.0));
Mat map1 = new Mat(1, 3, CvType.CV_32FC1); Mat map1 = new Mat(1, 3, CvType.CV_32FC1);
Mat map2 = new Mat(1, 3, CvType.CV_32FC1); Mat map2 = new Mat(1, 3, CvType.CV_32FC1);
...@@ -1562,7 +1491,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1562,7 +1491,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testRemapMatMatMatMatIntIntScalar() { public void testRemapMatMatMatMatIntIntScalar() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(2.0));
Mat map1 = new Mat(1, 3, CvType.CV_32FC1); Mat map1 = new Mat(1, 3, CvType.CV_32FC1);
Mat map2 = new Mat(1, 3, CvType.CV_32FC1); Mat map2 = new Mat(1, 3, CvType.CV_32FC1);
...@@ -1578,7 +1507,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1578,7 +1507,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testResizeMatMatSize() { public void testResizeMatMatSize() {
Mat src = new Mat(2, 2, CvType.CV_8UC1, new Scalar(1.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_8UC1, new Scalar(1.0));
truth = new Mat(1, 1, CvType.CV_8UC1, new Scalar(1.0)); truth = new Mat(1, 1, CvType.CV_8UC1, new Scalar(1.0));
Size dsize = new Size(1, 1); Size dsize = new Size(1, 1);
...@@ -1588,7 +1517,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1588,7 +1517,7 @@ public class imgprocTest extends OpenCVTestCase {
public void testResizeMatMatSizeDouble() { public void testResizeMatMatSizeDouble() {
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
truth = new Mat(2, 2, CvType.CV_8UC1, new Scalar(255)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_8UC1, new Scalar(255));
Imgproc.resize(gray255, dst, dsize, 0.5); Imgproc.resize(gray255, dst, dsize, 0.5);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
...@@ -1596,7 +1525,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1596,7 +1525,7 @@ public class imgprocTest extends OpenCVTestCase {
public void testResizeMatMatSizeDoubleDouble() { public void testResizeMatMatSizeDoubleDouble() {
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
truth = new Mat(2, 2, CvType.CV_8UC1, new Scalar(255)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_8UC1, new Scalar(255));
Imgproc.resize(gray255, dst, dsize, 0.0, 0.0); Imgproc.resize(gray255, dst, dsize, 0.0, 0.0);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
...@@ -1604,47 +1533,38 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1604,47 +1533,38 @@ public class imgprocTest extends OpenCVTestCase {
public void testResizeMatMatSizeDoubleDoubleInt() { public void testResizeMatMatSizeDoubleDoubleInt() {
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
truth = new Mat(2, 2, CvType.CV_8UC1, new Scalar(255)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_8UC1, new Scalar(255));
Imgproc.resize(gray255, dst, dsize, 1.5, 1.5, Imgproc.INTER_AREA); Imgproc.resize(gray255, dst, dsize, 1.5, 1.5, Imgproc.INTER_AREA);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntInt() { public void testScharrMatMatIntIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(0)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0));
Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0); Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntIntDouble() { public void testScharrMatMatIntIntIntDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(0)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0));
Imgproc.Scharr(src, dst, CvType.CV_32F, 0, 1, 1.5); Imgproc.Scharr(src, dst, CvType.CV_32F, 0, 1, 1.5);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntIntDoubleDouble() { public void testScharrMatMatIntIntIntDoubleDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(0.001)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0.001));
Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0, 1.5, 0.001); Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0, 1.5, 0.001);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntIntDoubleDoubleInt() { public void testScharrMatMatIntIntIntDoubleDoubleInt() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = Mat.eye(3, 3, CvType.CV_32F);
src.put(0, 0, 1, 0, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1, 0);
src.put(2, 0, 0, 0, 1);
truth = new Mat(3, 3, CvType.CV_32F); truth = new Mat(3, 3, CvType.CV_32F);
truth.put(0, 0, -15, -19.5, -4.5); truth.put(0, 0, -15, -19.5, -4.5);
...@@ -1652,65 +1572,58 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1652,65 +1572,58 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(2, 0, 4.5, 19.5, 15); truth.put(2, 0, 4.5, 19.5, 15);
Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0, 1.5, 0.0, Imgproc.BORDER_REFLECT); Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0, 1.5, 0.0, Imgproc.BORDER_REFLECT);
fail("Not yet implemented"); assertMatEqual(truth, dst);
} }
public void testSepFilter2DMatMatIntMatMat() { public void testSepFilter2DMatMatIntMatMat() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(2.0));
Mat kernelX = new Mat(1, 3, CvType.CV_32FC1); Mat kernelX = new Mat(1, 3, CvType.CV_32FC1);
Mat kernelY = new Mat(1, 3, CvType.CV_32FC1); Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(420)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(420));
kernelX.put(0, 0, 4.0, 3.0, 7.0); kernelX.put(0, 0, 4.0, 3.0, 7.0);
kernelY.put(0, 0, 9.0, 4.0, 2.0); kernelY.put(0, 0, 9.0, 4.0, 2.0);
Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY); Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY);
OpenCVTestRunner.Log(dst.dump());
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testSepFilter2DMatMatIntMatMatPoint() { public void testSepFilter2DMatMatIntMatMatPoint() {
Mat src = new Mat(2, 2, CvType.CV_32FC1, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1, new Scalar(2.0));
Mat kernelX = new Mat(1, 3, CvType.CV_32FC1); Mat kernelX = new Mat(1, 3, CvType.CV_32FC1);
Mat kernelY = new Mat(1, 3, CvType.CV_32FC1); Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(36.0)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(36.0));
Point point = new Point(2, 2);
kernelX.put(0, 0, 2.0, 2.0, 2.0); kernelX.put(0, 0, 2.0, 2.0, 2.0);
kernelY.put(0, 0, 1.0, 1.0, 1.0); kernelY.put(0, 0, 1.0, 1.0, 1.0);
Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY, point); Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY, anchorPoint);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testSepFilter2DMatMatIntMatMatPointDouble() { public void testSepFilter2DMatMatIntMatMatPointDouble() {
Mat src = new Mat(2, 2, CvType.CV_32FC1, new Scalar(2.0)); Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1, new Scalar(2.0));
Mat kernelX = new Mat(1, 3, CvType.CV_32FC1);
Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
Point point = new Point(2, 2);
double delta = 0.001;
Mat kernelX = new Mat(1, 3, CvType.CV_32FC1);
kernelX.put(0, 0, 2.0, 2.0, 2.0); kernelX.put(0, 0, 2.0, 2.0, 2.0);
Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
kernelY.put(0, 0, 1.0, 1.0, 1.0); kernelY.put(0, 0, 1.0, 1.0, 1.0);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(36.001)); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(36.001));
Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY, point, delta); Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY, anchorPoint, EPS);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testSepFilter2DMatMatIntMatMatPointDoubleInt() { public void testSepFilter2DMatMatIntMatMatPointDoubleInt() {
Mat kernelX = new Mat(1, 3, CvType.CV_32FC1); Mat kernelX = new Mat(1, 3, CvType.CV_32FC1);
Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
Point point = new Point(2, 2);
double delta = 0.001;
kernelX.put(0, 0, 2.0, 2.0, 2.0); kernelX.put(0, 0, 2.0, 2.0, 2.0);
Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
kernelY.put(0, 0, 1.0, 1.0, 1.0); kernelY.put(0, 0, 1.0, 1.0, 1.0);
truth = new Mat(10, 10, CvType.CV_32F, new Scalar(0.001)); truth = new Mat(10, 10, CvType.CV_32F, new Scalar(0.001));
Imgproc.sepFilter2D(gray0, dst, CvType.CV_32F, kernelX, kernelY, point, delta, Imgproc.BORDER_REFLECT); Imgproc.sepFilter2D(gray0, dst, CvType.CV_32F, kernelX, kernelY, anchorPoint, EPS, Imgproc.BORDER_REFLECT);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1783,6 +1696,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1783,6 +1696,7 @@ public class imgprocTest extends OpenCVTestCase {
distCoeffs.put(0, 0, 1.0, 3.0, 2.0, 4.0); distCoeffs.put(0, 0, 1.0, 3.0, 2.0, 4.0);
truth = new Mat(3, 3, CvType.CV_32F);
truth.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
truth.put(1, 0, 0, 0, 0); truth.put(1, 0, 0, 0, 0);
truth.put(2, 0, 0, 3, 0); truth.put(2, 0, 0, 3, 0);
...@@ -1795,29 +1709,30 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1795,29 +1709,30 @@ public class imgprocTest extends OpenCVTestCase {
Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(3.0)); Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(3.0));
Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F); Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F);
Mat newCameraMatrix = new Mat(3, 3, CvType.CV_32F); Mat newCameraMatrix = new Mat(3, 3, CvType.CV_32F, new Scalar(1.0));
Mat distCoeffs = new Mat(1, 4, CvType.CV_32F); Mat distCoeffs = new Mat(1, 4, CvType.CV_32F);
cameraMatrix.put(0, 0, 1, 0, 2); cameraMatrix.put(0, 0, 1, 0, 1);
cameraMatrix.put(1, 0, 0, 1, 2); cameraMatrix.put(1, 0, 0, 1, 2);
cameraMatrix.put(2, 0, 0, 0, 1); cameraMatrix.put(2, 0, 0, 0, 1);
distCoeffs.put(0, 0, 1.0, 4.0, 0.0, 5.0); distCoeffs.put(0, 0, 2.0, 1.0, 4.0, 5.0);
truth = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
truth = new Mat(3, 3, CvType.CV_32F, new Scalar(3.0));
Imgproc.undistort(src, dst, cameraMatrix, distCoeffs, newCameraMatrix); Imgproc.undistort(src, dst, cameraMatrix, distCoeffs, newCameraMatrix);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testWarpAffineMatMatMatSize() { public void testWarpAffineMatMatMatSize() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);;
Size dsize = new Size(3, 3);
Mat M = new Mat(2, 3, CvType.CV_32F); Mat M = new Mat(2, 3, CvType.CV_32F);
src.put(0, 0, 2, 0, 1); src.put(0, 0, 2, 0, 1);
src.put(1, 0, 6, 4, 3); src.put(1, 0, 6, 4, 3);
src.put(2, 0, 1, 0, 2); src.put(2, 0, 1, 0, 2);
truth = new Mat(3, 3, CvType.CV_32F);
truth.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
truth.put(1, 0, 0, 2, 0); truth.put(1, 0, 0, 2, 0);
truth.put(2, 0, 0, 6, 4); truth.put(2, 0, 0, 6, 4);
...@@ -1825,8 +1740,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1825,8 +1740,8 @@ public class imgprocTest extends OpenCVTestCase {
M.put(0, 0, 1, 0, 1); M.put(0, 0, 1, 0, 1);
M.put(1, 0, 0, 1, 1); M.put(1, 0, 0, 1, 1);
truth = new Mat(3, 3, CvType.CV_32F);
Imgproc.warpAffine(src, dst, M, dsize); Imgproc.warpAffine(src, dst, M, size);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1839,15 +1754,14 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1839,15 +1754,14 @@ public class imgprocTest extends OpenCVTestCase {
src.put(1, 0, 6, 4, 3); src.put(1, 0, 6, 4, 3);
src.put(2, 0, 0, 2, 2); src.put(2, 0, 0, 2, 2);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(0, 0, 6, 4); truth.put(0, 0, 6, 4);
truth.put(1, 0, 6, 4); truth.put(1, 0, 6, 4);
M.put(0, 0, 1, 0, 0); M.put(0, 0, 1, 0, 0);
M.put(1, 0, 0, 0, 1); M.put(1, 0, 0, 0, 1);
truth = new Mat(2, 2, CvType.CV_32F);
Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP); Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP);
OpenCVTestRunner.Log(dst.dump());
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1855,17 +1769,14 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1855,17 +1769,14 @@ public class imgprocTest extends OpenCVTestCase {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
Mat M = new Mat(2, 3, CvType.CV_32F); Mat M = Mat.eye(2, 3, CvType.CV_32F);
src.put(0, 0, 2, 4, 1); src.put(0, 0, 2, 4, 1);
src.put(1, 0, 6, 4, 3); src.put(1, 0, 6, 4, 3);
src.put(2, 0, 0, 2, 2); src.put(2, 0, 0, 2, 2);
M.put(0, 0, 1, 0, 0); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
M.put(1, 0, 0, 0, 1); truth.put(0, 0, 2, 4);
truth = new Mat(2, 2, CvType.CV_32F);
truth.put(0, 0, 6, 4);
truth.put(1, 0, 6, 4); truth.put(1, 0, 6, 4);
Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_TRANSPARENT); Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_TRANSPARENT);
...@@ -1874,19 +1785,18 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1874,19 +1785,18 @@ public class imgprocTest extends OpenCVTestCase {
public void testWarpAffineMatMatMatSizeIntIntScalar() { public void testWarpAffineMatMatMatSizeIntIntScalar() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
Mat M = new Mat(2, 3, CvType.CV_32F);
Scalar sc = new Scalar(1.0); Scalar sc = new Scalar(1.0);
src.put(0, 0, 2, 4, 1); src.put(0, 0, 2, 4, 1);
src.put(1, 0, 6, 4, 3); src.put(1, 0, 6, 4, 3);
src.put(2, 0, 0, 2, 2); src.put(2, 0, 0, 2, 2);
Mat M = new Mat(2, 3, CvType.CV_32F);
M.put(0, 0, 1, 0, 0); M.put(0, 0, 1, 0, 0);
M.put(1, 0, 0, 0, 1); M.put(1, 0, 0, 0, 1);
truth = new Mat(2, 2, CvType.CV_32F); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(0, 0, 6, 4); truth.put(0, 0, 6, 4);
truth.put(1, 0, 6, 4); truth.put(1, 0, 6, 4);
...@@ -1896,7 +1806,6 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1896,7 +1806,6 @@ public class imgprocTest extends OpenCVTestCase {
public void testWarpPerspectiveMatMatMatSize() { public void testWarpPerspectiveMatMatMatSize() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Size dsize = new Size(3, 3);
Mat M = new Mat(3, 3, CvType.CV_32F); Mat M = new Mat(3, 3, CvType.CV_32F);
src.put(0, 0, 2, 4, 1); src.put(0, 0, 2, 4, 1);
...@@ -1912,7 +1821,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1912,7 +1821,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 0, 2, 4); truth.put(1, 0, 0, 2, 4);
truth.put(2, 0, 0, 0, 4); truth.put(2, 0, 0, 0, 4);
Imgproc.warpPerspective(src, dst, M, dsize); Imgproc.warpPerspective(src, dst, M, size);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1926,10 +1835,15 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1926,10 +1835,15 @@ public class imgprocTest extends OpenCVTestCase {
Mat M = new Mat(3, 3, CvType.CV_32F); Mat M = new Mat(3, 3, CvType.CV_32F);
M.put(0, 0, 1, 0, 0); M.put(0, 0, 1, 0, 0);
M.put(1, 0, 0, 0, 1); M.put(1, 0, 0, 0, 1);
M.put(2, 0, 0, 0, 1);
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(0, 0, 6, 4);
truth.put(1, 0, 6, 4);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0));
Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP); Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testWarpPerspectiveMatMatMatSizeIntInt() { public void testWarpPerspectiveMatMatMatSizeIntInt() {
...@@ -1942,13 +1856,13 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1942,13 +1856,13 @@ public class imgprocTest extends OpenCVTestCase {
Mat M = new Mat(3, 3, CvType.CV_32F); Mat M = new Mat(3, 3, CvType.CV_32F);
M.put(0, 0, 1, 0, 0); M.put(0, 0, 1, 0, 0);
M.put(1, 0, 0, 0, 1); M.put(1, 0, 0, 0, 1);
M.put(2, 0, 0, 0, 1);
truth = new Mat(2, 2, CvType.CV_32F); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(0, 0, 6, 2); truth.put(0, 0, 6, 4);
truth.put(1, 0, 2, 2); truth.put(1, 0, 6, 4);
Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_REFLECT); Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_REFLECT);
OpenCVTestRunner.Log(dst.dump());
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
...@@ -1959,23 +1873,29 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1959,23 +1873,29 @@ public class imgprocTest extends OpenCVTestCase {
src.put(2, 0, 0, 2, 2); src.put(2, 0, 0, 2, 2);
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
Mat M = new Mat(3, 3, CvType.CV_32F); Mat M = Mat.eye(3, 3, CvType.CV_32F);
Scalar sc = new Scalar(1.0); Scalar sc = new Scalar(1.0);
M.put(0, 0, 1, 0, 0); truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
M.put(1, 0, 0, 0, 1); truth.put(0, 0, 2, 4);
truth.put(1, 0, 6, 4);
truth = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0));
Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_REFLECT, sc); Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_REFLECT, sc);
assertMatEqual(truth, dst); assertMatEqual(truth, dst);
} }
public void testWatershed() { public void testWatershed() {
Mat image = new Mat(matSize, matSize, CvType.CV_8UC(3), new Scalar(1.0)); Mat image = Mat.eye(4, 4, CvType.CV_8UC(3));
Mat markers = new Mat(matSize, matSize, CvType.CV_32SC1, new Scalar(1.0)); Mat markers = new Mat(4, 4, CvType.CV_32SC1, new Scalar(0));
truth = new Mat(4, 4, CvType.CV_32SC1);
truth.put(0, 0, -1, -1, -1, -1);
truth.put(1, 0,-1, 0, 0, -1);
truth.put(2, 0, -1, 0, 0, -1);
truth.put(3, 0, -1, -1, -1, -1);
Imgproc.watershed(image, markers); Imgproc.watershed(image, markers);
fail("Not yet implemented"); assertMatEqual(truth, markers);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment