Commit 387334e9 authored by Kirill Kornyakov's avatar Kirill Kornyakov

java tests: imgproc test cleaned

parent e9cd8296
...@@ -17,20 +17,18 @@ import org.opencv.test.OpenCVTestRunner; ...@@ -17,20 +17,18 @@ import org.opencv.test.OpenCVTestRunner;
public class imgprocTest extends OpenCVTestCase { public class imgprocTest extends OpenCVTestCase {
private Mat src; private Mat gray_64f_2;
private Mat dstImage; private Mat dst64F;
private Mat out; private int imgprocSz;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
imgprocSz = 2;
src = new Mat(2, 2, CvType.CV_64F); gray_64f_2 = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
src.put(0, 0, 2, 2); dst64F = new Mat(imgprocSz, imgprocSz, CvType.CV_64F);
src.put(1, 0, 2, 2);
dstImage = new Mat(2, 2, CvType.CV_64F);
out = new Mat(2, 2, CvType.CV_64F);
} }
public void test_1() { public void test_1() {
...@@ -38,125 +36,100 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -38,125 +36,100 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testAccumulateMatMat() { public void testAccumulateMatMat() {
out.put(0, 0, 2, 2); truth = new Mat(2, 2, CvType.CV_64F, new Scalar(2));
out.put(1, 0, 2, 2); Imgproc.accumulate(gray_64f_2, dst64F);
assertMatEqual(truth, dst64F);
Imgproc.accumulate(src, dstImage);
assertMatEqual(out, dstImage);
dst = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0)); dst = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
Imgproc.accumulate(gray1_32f, dst); Imgproc.accumulate(gray1_32f, dst);
assertMatEqual(gray1_32f, dst); assertMatEqual(gray1_32f, dst);
} }
public void testAccumulateMatMatMat() { public void testAccumulateMatMatMat() {
Mat mask = new Mat(2, 2, CvType.CV_8U); Mat mask = new Mat(2, 2, CvType.CV_8U, new Scalar(1));
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(2));
out.put(0, 0, 2, 2); Imgproc.accumulate(gray_64f_2, dst64F, mask); //TODO: use better mask
out.put(1, 0, 2, 2); assertMatEqual(truth, dst64F);
mask.put(0, 0, 2, 2);
mask.put(1, 0, 2, 2);
Imgproc.accumulate(src, dstImage, mask); // TODO: use mask
assertMatEqual(out, dstImage);
} }
public void testAccumulateProductMatMatMat() { public void testAccumulateProductMatMatMat() {
Mat src1 = new Mat(2, 2, CvType.CV_64F); Mat src1 = new Mat(2, 2, CvType.CV_64F);
Mat src2 = new Mat(2, 2, CvType.CV_64F);
src1.put(0, 0, 1, 1); src1.put(0, 0, 1, 1);
src1.put(1, 0, 1, 1); src1.put(1, 0, 1, 1);
Mat src2 = new Mat(2, 2, 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.put(0, 0, 2, 1);
truth.put(1, 0, 1, 2);
Mat dstImage = new Mat(2, 2, CvType.CV_64F, new Scalar(0)); Mat dstImage = new Mat(2, 2, CvType.CV_64F, new Scalar(0));
Imgproc.accumulateProduct(src1, src2, dstImage); Imgproc.accumulateProduct(src1, src2, dstImage);
out.put(0, 0, 2, 1); assertMatEqual(truth, dstImage);
out.put(1, 0, 1, 2);
assertMatEqual(out, dstImage);
} }
public void testAccumulateProductMatMatMatMat() { public void testAccumulateProductMatMatMatMat() {
Mat src1 = new Mat(2, 2, CvType.CV_64F); Mat src1 = new Mat(2, 2, CvType.CV_64F);
Mat src2 = new Mat(2, 2, CvType.CV_64F);
Mat mask = new Mat(2, 2, CvType.CV_8U);
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);
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));
out.put(0, 0, 2, 1); truth = new Mat(2, 2, CvType.CV_64F, new Scalar(2));
out.put(1, 0, 0, 2); truth.put(0, 0, 2, 1);
truth.put(1, 0, 0, 2);
mask.put(0, 0, 1, 1);
mask.put(1, 0, 1, 1);
Imgproc.accumulateProduct(src1, src2, dstImage, mask); Imgproc.accumulateProduct(src1, src2, dst64F, mask);
OpenCVTestRunner.Log(dstImage.dump()); assertMatEqual(truth, dst64F);
assertMatEqual(out, dstImage);
} }
public void testAccumulateSquareMatMat() { public void testAccumulateSquareMatMat() {
truth = new Mat(2, 2, CvType.CV_64F, new Scalar(4));
out.put(0, 0, 4, 4); Imgproc.accumulateSquare(gray_64f_2, dst64F);
out.put(1, 0, 4, 4); assertMatEqual(truth, dst64F);
Imgproc.accumulateSquare(src, dstImage);
assertMatEqual(out, dstImage);
} }
public void testAccumulateSquareMatMatMat() { public void testAccumulateSquareMatMatMat() {
Mat mask = new Mat(2, 2, CvType.CV_8U); Mat mask = new Mat(2, 2, CvType.CV_8U, new Scalar(1));
out.put(0, 0, 4, 4); truth = new Mat(2, 2, CvType.CV_64F, new Scalar(4));
out.put(1, 0, 4, 4);
mask.put(0, 0, 1, 1); Imgproc.accumulateSquare(gray_64f_2, dst64F, mask);
mask.put(1, 0, 1, 1); assertMatEqual(truth, dst64F);
Imgproc.accumulateSquare(src, dstImage, mask);
assertMatEqual(out, dstImage);
} }
public void testAccumulateWeightedMatMatDouble() { public void testAccumulateWeightedMatMatDouble() {
out.put(0, 0, 4, 4); truth = new Mat(2, 2, CvType.CV_64F, new Scalar(4));
out.put(1, 0, 4, 4); Imgproc.accumulateWeighted(gray_64f_2, dst64F, 2.0);
assertMatEqual(truth, dst64F);
Imgproc.accumulateWeighted(src, dstImage, 2.0);
OpenCVTestRunner.Log(dstImage.dump());
assertMatEqual(out, dstImage);
} }
public void testAccumulateWeightedMatMatDoubleMat() { public void testAccumulateWeightedMatMatDoubleMat() {
Mat mask = new Mat(2, 2, CvType.CV_8U); Mat mask = new Mat(2, 2, CvType.CV_8U, new Scalar(1));
out.put(0, 0, 8, 8);
out.put(1, 0, 8, 8);
mask.put(0, 0, 1, 1); truth = new Mat(2, 2, CvType.CV_64F, new Scalar(8));
mask.put(1, 0, 1, 1); Imgproc.accumulateWeighted(gray_64f_2, dst64F, 4.0, mask);
assertMatEqual(truth, dst64F);
Imgproc.accumulateWeighted(src, dstImage, 4.0, mask);
assertMatEqual(out, dstImage);
} }
public void testAdaptiveThreshold() { public void testAdaptiveThreshold() {
Imgproc.adaptiveThreshold(gray0, dst, 2.0, Imgproc.adaptiveThreshold(gray0, dst, 2.0, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 3, 0);
Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 3, 0);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
} }
public void testApproxPolyDP() { public void testApproxPolyDP() {
Mat curve = new Mat(1, 5, CvType.CV_32FC2); Mat curve = new Mat(1, 5, CvType.CV_32FC2);
Mat approxCurve = new Mat(3, 1, CvType.CV_32FC2);
double epsilon = 0.001;
curve.put(0, 0, 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 4.0, 5.0, 3.0); curve.put(0, 0, 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 4.0, 5.0, 3.0);
Mat approxCurve = new Mat(3, 1, CvType.CV_32FC2);
approxCurve.put(0, 0, 1.0, 3.0, 3.0, 5.0, 5.0, 3.0); approxCurve.put(0, 0, 1.0, 3.0, 3.0, 5.0, 5.0, 3.0);
Imgproc.approxPolyDP(curve, dst, epsilon, true); Imgproc.approxPolyDP(curve, dst, EPS, true);
assertMatEqual(approxCurve, dst); assertMatEqual(approxCurve, dst);
} }
...@@ -175,8 +148,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -175,8 +148,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testBilateralFilterMatMatIntDoubleDoubleInt() { public void testBilateralFilterMatMatIntDoubleDoubleInt() {
Imgproc.bilateralFilter(gray255, dst, 5, 10.0, 5.0, Imgproc.bilateralFilter(gray255, dst, 5, 10.0, 5.0, Imgproc.BORDER_REFLECT);
Imgproc.BORDER_REFLECT);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
...@@ -207,8 +179,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -207,8 +179,7 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testBorderInterpolate() { public void testBorderInterpolate() {
float val1 = Imgproc.borderInterpolate(100, 150, float val1 = Imgproc.borderInterpolate(100, 150, Imgproc.BORDER_REFLECT_101);
Imgproc.BORDER_REFLECT_101);
Imgproc.borderInterpolate(-5, 10, Imgproc.BORDER_WRAP); Imgproc.borderInterpolate(-5, 10, Imgproc.BORDER_WRAP);
assertEquals(100.0f, val1); assertEquals(100.0f, val1);
...@@ -217,17 +188,15 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -217,17 +188,15 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testBoundingRect() { public void testBoundingRect() {
Rect dstRect = new Rect();
Mat points = new Mat(1, 4, CvType.CV_32FC2); Mat points = new Mat(1, 4, CvType.CV_32FC2);
Point p1 = new Point(1, 1);
Point p2 = new Point(-5, -2);
points.put(0, 0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 4.0, 4.0); points.put(0, 0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 4.0, 4.0);
Point p1 = new Point(1, 1);
Point p2 = new Point(-5, -2);
// TODO : are this a good tests? Rect bbox = Imgproc.boundingRect(points);
dstRect = Imgproc.boundingRect(points); assertTrue(bbox.contains(p1));
assertTrue(dstRect.contains(p1)); assertFalse(bbox.contains(p2));
assertFalse(dstRect.contains(p2));
} }
public void testBoxFilterMatMatIntSize() { public void testBoxFilterMatMatIntSize() {
...@@ -257,8 +226,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -257,8 +226,7 @@ public class imgprocTest extends OpenCVTestCase {
Size sz = new Size(3, 3); Size sz = new Size(3, 3);
Point anchor = new Point(2, 2); Point anchor = new Point(2, 2);
Imgproc.boxFilter(gray255, dst, 8, sz, anchor, false, Imgproc.boxFilter(gray255, dst, 8, sz, anchor, false, Imgproc.BORDER_REFLECT);
Imgproc.BORDER_REFLECT);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
...@@ -293,8 +261,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -293,8 +261,7 @@ public class imgprocTest extends OpenCVTestCase {
images.add(gray128); images.add(gray128);
channels.add(0); channels.add(0);
histSize.add(10); histSize.add(10);
ranges.add(0.0f); ranges.add(0.0f); ranges.add(256.0f);
ranges.add(256.0f);
truth = new Mat(10, 1, CvType.CV_32F, Scalar.all(0.0)); truth = new Mat(10, 1, CvType.CV_32F, Scalar.all(0.0));
truth.put(5, 0, 100.0); truth.put(5, 0, 100.0);
...@@ -319,10 +286,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -319,10 +286,8 @@ public class imgprocTest extends OpenCVTestCase {
histSize.add(10); histSize.add(10);
histSize.add(10); histSize.add(10);
ranges.add(0.0f); ranges.add(0.0f); ranges.add(256.0f);
ranges.add(256.0f); ranges.add(0.0f); ranges.add(256.0f);
ranges.add(0.0f);
ranges.add(256.0f);
truth = new Mat(10, 10, CvType.CV_32F, Scalar.all(0.0)); truth = new Mat(10, 10, CvType.CV_32F, Scalar.all(0.0));
truth.put(9, 5, 100.0); truth.put(9, 5, 100.0);
...@@ -348,22 +313,18 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -348,22 +313,18 @@ public class imgprocTest extends OpenCVTestCase {
histSize.add(10); histSize.add(10);
histSize.add(10); histSize.add(10);
ranges.add(0.0f); ranges.add(0.0f); ranges.add(256.0f);
ranges.add(256.0f); ranges.add(0.0f); ranges.add(256.0f);
ranges.add(0.0f);
ranges.add(256.0f);
truth = new Mat(10, 10, CvType.CV_32F, Scalar.all(0.0)); truth = new Mat(10, 10, CvType.CV_32F, Scalar.all(0.0));
truth.put(9, 5, 100.0); truth.put(9, 5, 100.0);
Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges, Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges, true);
true);
assertMatEqual(truth, hist); assertMatEqual(truth, hist);
} }
public void testCannyMatMatDoubleDouble() { public void testCannyMatMatDoubleDouble() {
Imgproc.Canny(gray255, dst, 5.0, 10.0); Imgproc.Canny(gray255, dst, 5.0, 10.0);
assertMatEqual(gray0, dst); assertMatEqual(gray0, dst);
;
} }
public void testCannyMatMatDoubleDoubleInt() { public void testCannyMatMatDoubleDoubleInt() {
...@@ -420,9 +381,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -420,9 +381,9 @@ public class imgprocTest extends OpenCVTestCase {
public void testConvexHullMatMat() { public void testConvexHullMatMat() {
Mat points = new Mat(1, 6, CvType.CV_32FC2); Mat points = new Mat(1, 6, CvType.CV_32FC2);
Mat expHull = new Mat(4, 1, 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);
Mat expHull = new Mat(4, 1, CvType.CV_32FC2);
expHull.put(0, 0, 4, 0, 3, 2, 0, 2, 2, 0); expHull.put(0, 0, 4, 0, 3, 2, 0, 2, 2, 0);
Imgproc.convexHull(points, dst); Imgproc.convexHull(points, dst);
...@@ -431,10 +392,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -431,10 +392,9 @@ public class imgprocTest extends OpenCVTestCase {
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);
Mat expHull = new Mat(4, 1, CvType.CV_32FC2); Mat expHull = new Mat(4, 1, 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);
expHull.put(0, 0, 0, 2, 3, 2, 4, 0, 2, 0); expHull.put(0, 0, 0, 2, 3, 2, 4, 0, 2, 0);
Imgproc.convexHull(points, dst, true); Imgproc.convexHull(points, dst, true);
...@@ -443,10 +403,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -443,10 +403,9 @@ public class imgprocTest extends OpenCVTestCase {
public void testConvexHullMatMatBooleanBoolean() { public void testConvexHullMatMatBooleanBoolean() {
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);
Mat expHull = new Mat(4, 1, CvType.CV_32FC2); Mat expHull = new Mat(4, 1, 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);
expHull.put(0, 0, 0, 2, 3, 2, 4, 0, 2, 0); expHull.put(0, 0, 0, 2, 3, 2, 4, 0, 2, 0);
Imgproc.convexHull(points, dst, true, true); Imgproc.convexHull(points, dst, true, true);
...@@ -455,77 +414,73 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -455,77 +414,73 @@ public class imgprocTest extends OpenCVTestCase {
public void testCopyMakeBorderMatMatIntIntIntIntInt() { public void testCopyMakeBorderMatMatIntIntIntIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
Mat out = new Mat(6, 6, CvType.CV_32F, new Scalar(1)); src.put(0, 0, 1, 1); //TODO: use setTo
int border = 2;
src.put(0, 0, 1, 1);
src.put(1, 0, 1, 1); src.put(1, 0, 1, 1);
Imgproc.copyMakeBorder(src, dst, border, border, border, border, truth = new Mat(6, 6, CvType.CV_32F, new Scalar(1));
Imgproc.BORDER_REPLICATE); int border = 2;
assertMatEqual(out, dst);
Imgproc.copyMakeBorder(src, dst, border, border, border, border, Imgproc.BORDER_REPLICATE);
assertMatEqual(truth, dst);
} }
public void testCopyMakeBorderMatMatIntIntIntIntIntScalar() { public void testCopyMakeBorderMatMatIntIntIntIntIntScalar() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
Mat out = new Mat(6, 6, 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));
Scalar value = new Scalar(0); Scalar value = new Scalar(0);
int border = 2; int border = 2;
src.put(0, 0, 1, 1); Imgproc.copyMakeBorder(src, dst, border, border, border, border, Imgproc.BORDER_REPLICATE, value);
src.put(1, 0, 1, 1); assertMatEqual(truth, dst);
Imgproc.copyMakeBorder(src, dst, border, border, border, border,
Imgproc.BORDER_REPLICATE, value);
assertMatEqual(out, dst);
} }
public void testCornerEigenValsAndVecsMatMatIntInt() { public void testCornerEigenValsAndVecsMatMatIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32FC1); Mat src = new Mat(2, 2, CvType.CV_32FC1);
int blockSize = 3;
int ksize = 5;
src.put(0, 0, 1, 2); src.put(0, 0, 1, 2);
src.put(1, 0, 4, 2); src.put(1, 0, 4, 2);
int blockSize = 3;
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
Mat out = new Mat(2, 2, CvType.CV_32FC(6), new Scalar(0)); truth = new Mat(2, 2, CvType.CV_32FC(6), new Scalar(0));
Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize); Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize);
OpenCVTestRunner.Log(dst.dump()); OpenCVTestRunner.Log(dst.dump());
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testCornerEigenValsAndVecsMatMatIntIntInt() { public void testCornerEigenValsAndVecsMatMatIntIntInt() {
Mat src = new Mat(4, 4, CvType.CV_32FC1, new Scalar(128)); Mat src = new Mat(4, 4, CvType.CV_32FC1, new Scalar(128));
int blockSize = 3; int blockSize = 3;
int ksize = 5; int ksize = 5;
Mat out = 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.cornerEigenValsAndVecs(src, dst, blockSize, ksize, Imgproc.BORDER_REFLECT);
Imgproc.BORDER_REFLECT);
OpenCVTestRunner.Log(dst.dump()); OpenCVTestRunner.Log(dst.dump());
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testCornerHarrisMatMatIntIntDouble() { public void testCornerHarrisMatMatIntIntDouble() {
Mat out = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0)); truth = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
int blockSize = 5; int blockSize = 5;
int ksize = 7; int ksize = 7;
double k = 0.1; double k = 0.1;
Imgproc.cornerHarris(gray128, dst, blockSize, ksize, k); Imgproc.cornerHarris(gray128, dst, blockSize, ksize, k);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testCornerHarrisMatMatIntIntDoubleInt() { public void testCornerHarrisMatMatIntIntDoubleInt() {
Mat out = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0)); truth = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
int blockSize = 5; int blockSize = 5;
int ksize = 7; int ksize = 7;
double k = 0.1; double k = 0.1;
Imgproc.cornerHarris(gray255, dst, blockSize, ksize, k, Imgproc.cornerHarris(gray255, dst, blockSize, ksize, k, Imgproc.BORDER_REFLECT);
Imgproc.BORDER_REFLECT); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testCornerMinEigenValMatMatInt() { public void testCornerMinEigenValMatMatInt() {
...@@ -533,52 +488,51 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -533,52 +488,51 @@ public class imgprocTest extends OpenCVTestCase {
src.put(0, 0, 1, 2); src.put(0, 0, 1, 2);
src.put(1, 0, 2, 1); src.put(1, 0, 2, 1);
Mat out = new Mat(2, 2, CvType.CV_32FC1, new Scalar(0));
int blockSize = 5; int blockSize = 5;
truth = new Mat(2, 2, CvType.CV_32FC1, new Scalar(0));
Imgproc.cornerMinEigenVal(src, dst, blockSize); Imgproc.cornerMinEigenVal(src, dst, blockSize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
Mat out1 = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
Mat truth1 = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
Imgproc.cornerMinEigenVal(gray255, dst, blockSize); Imgproc.cornerMinEigenVal(gray255, dst, blockSize);
assertMatEqual(out1, dst); assertMatEqual(truth1, dst);
} }
public void testCornerMinEigenValMatMatIntInt() { public void testCornerMinEigenValMatMatIntInt() {
Mat src = new Mat(3, 3, CvType.CV_32FC1); Mat src = new Mat(3, 3, CvType.CV_32FC1);
src.put(0, 0, 1, 0, 0); src.put(0, 0, 1, 0, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1, 0); src.put(1, 0, 0, 1, 0);
src.put(2, 0, 0, 0, 1); src.put(2, 0, 0, 0, 1);
Mat out = 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;
int ksize = 5; int ksize = 5;
out.put(0, 0, 0.055555549, 0.027777772, 0.055555549); truth.put(0, 0, 0.055555549, 0.027777772, 0.055555549);
out.put(1, 0, 0.027777772, 0.055555549, 0.027777772); truth.put(1, 0, 0.027777772, 0.055555549, 0.027777772);
out.put(2, 0, 0.055555549, 0.027777772, 0.055555549); truth.put(2, 0, 0.055555549, 0.027777772, 0.055555549);
Imgproc.cornerMinEigenVal(src, dst, blockSize, ksize); Imgproc.cornerMinEigenVal(src, dst, blockSize, ksize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testCornerMinEigenValMatMatIntIntInt() { public void testCornerMinEigenValMatMatIntIntInt() {
Mat src = new Mat(3, 3, CvType.CV_32FC1); Mat src = new Mat(3, 3, CvType.CV_32FC1);
src.put(0, 0, 1, 0, 0); src.put(0, 0, 1, 0, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1, 0); src.put(1, 0, 0, 1, 0);
src.put(2, 0, 0, 0, 1); src.put(2, 0, 0, 0, 1);
Mat out = 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;
int ksize = 5; int ksize = 5;
out.put(0, 0, 0.68055558, 0.92708349, 0.5868057); truth.put(0, 0, 0.68055558, 0.92708349, 0.5868057);
out.put(1, 0, 0.92708343, 0.92708343, 0.92708343); truth.put(1, 0, 0.92708343, 0.92708343, 0.92708343);
out.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.BORDER_REFLECT); Imgproc.cornerMinEigenVal(src, dst, blockSize, ksize, Imgproc.BORDER_REFLECT);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testCornerSubPix() { public void testCornerSubPix() {
...@@ -633,21 +587,18 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -633,21 +587,18 @@ public class imgprocTest extends OpenCVTestCase {
Point anchor = new Point(2, 2); Point anchor = new Point(2, 2);
Scalar value = new Scalar(0); Scalar value = new Scalar(0);
Imgproc.dilate(gray255, dst, kernel, anchor, 10, Imgproc.dilate(gray255, dst, kernel, anchor, 10, Imgproc.BORDER_REFLECT, value);
Imgproc.BORDER_REFLECT, value);
assertMatEqual(gray255, dst); assertMatEqual(gray255, dst);
} }
public void testDistanceTransform() { public void testDistanceTransform() {
Mat out = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(8192)); truth = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(8192));
Mat dstLables = new Mat(matSize, matSize, CvType.CV_32SC1, Mat dstLables = new Mat(matSize, matSize, CvType.CV_32SC1, new Scalar(0));
new Scalar(0));
Mat lables = new Mat(); Mat labels = new Mat();
Imgproc.distanceTransform(gray128, dst, lables, Imgproc.CV_DIST_L2, 3); Imgproc.distanceTransform(gray128, dst, labels, Imgproc.CV_DIST_L2, 3);
assertMatEqual(truth, dst);
assertMatEqual(out, dst); assertMatEqual(dstLables, labels);
assertMatEqual(dstLables, lables);
} }
public void testDrawContoursMatListOfMatIntScalar() { public void testDrawContoursMatListOfMatIntScalar() {
...@@ -690,59 +641,59 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -690,59 +641,59 @@ public class imgprocTest extends OpenCVTestCase {
public void testErodeMatMatMatPoint() { public void testErodeMatMatMatPoint() {
Mat src = new Mat(3, 3, CvType.CV_8U); Mat src = new Mat(3, 3, CvType.CV_8U);
Mat out = new Mat(3, 3, CvType.CV_8U, new Scalar(0.0));
Point point = new Point(2, 2);
Mat kernel = new Mat();
src.put(0, 0, 1, 4, 8); src.put(0, 0, 1, 4, 8);
src.put(1, 0, 2, 0, 1); src.put(1, 0, 2, 0, 1);
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));
Point point = new Point(2, 2);
Mat kernel = new Mat();
Imgproc.erode(src, dst, kernel, point); Imgproc.erode(src, dst, kernel, point);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testErodeMatMatMatPointInt() { public void testErodeMatMatMatPointInt() {
Mat src = new Mat(3, 3, CvType.CV_8U); Mat src = new Mat(3, 3, CvType.CV_8U);
Mat out = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat();
Point point = new Point(2, 2);
src.put(0, 0, 15, 9, 10); src.put(0, 0, 15, 9, 10);
src.put(1, 0, 10, 8, 12); src.put(1, 0, 10, 8, 12);
src.put(2, 0, 12, 20, 25); src.put(2, 0, 12, 20, 25);
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat();
Point point = new Point(2, 2);
Imgproc.erode(src, dst, kernel, point, 10); Imgproc.erode(src, dst, kernel, point, 10);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testErodeMatMatMatPointIntInt() { public void testErodeMatMatMatPointIntInt() {
Mat src = new Mat(3, 3, CvType.CV_8U); Mat src = new Mat(3, 3, CvType.CV_8U);
Mat out = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat();
Point point = new Point(2, 2);
src.put(0, 0, 15, 9, 10); src.put(0, 0, 15, 9, 10);
src.put(1, 0, 10, 8, 12); src.put(1, 0, 10, 8, 12);
src.put(2, 0, 12, 20, 25); src.put(2, 0, 12, 20, 25);
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
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, point, 10, Imgproc.BORDER_REFLECT);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testErodeMatMatMatPointIntIntScalar() { public void testErodeMatMatMatPointIntIntScalar() {
Mat src = new Mat(3, 3, CvType.CV_8U); Mat src = new Mat(3, 3, CvType.CV_8U);
Mat out = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat();
Point point = new Point(2, 2);
Scalar sc = new Scalar(3, 3);
src.put(0, 0, 15, 9, 10); src.put(0, 0, 15, 9, 10);
src.put(1, 0, 10, 8, 12); src.put(1, 0, 10, 8, 12);
src.put(2, 0, 12, 20, 25); src.put(2, 0, 12, 20, 25);
truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8.0));
Mat kernel = new Mat();
Point point = new Point(2, 2);
Scalar sc = new Scalar(3, 3);
Imgproc.erode(src, dst, kernel, point, 10, Imgproc.BORDER_REFLECT, sc); Imgproc.erode(src, dst, kernel, point, 10, Imgproc.BORDER_REFLECT, sc);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testFilter2DMatMatIntMat() { public void testFilter2DMatMatIntMat() {
...@@ -856,29 +807,29 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -856,29 +807,29 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testGetDefaultNewCameraMatrixMat() { public void testGetDefaultNewCameraMatrixMat() {
Mat out = new Mat(); truth = new Mat();
out = Imgproc.getDefaultNewCameraMatrix(gray0); truth = Imgproc.getDefaultNewCameraMatrix(gray0);
assertTrue(0 == Core.countNonZero(out)); assertTrue(0 == Core.countNonZero(truth));
assertFalse(out.empty()); assertFalse(truth.empty());
} }
public void testGetDefaultNewCameraMatrixMatSize() { public void testGetDefaultNewCameraMatrixMatSize() {
Mat out = new Mat(); truth = new Mat();
Size size = new Size(3, 3); Size size = new Size(3, 3);
out = Imgproc.getDefaultNewCameraMatrix(gray0, size); truth = Imgproc.getDefaultNewCameraMatrix(gray0, size);
assertTrue(0 == Core.countNonZero(out)); assertTrue(0 == Core.countNonZero(truth));
assertFalse(out.empty()); assertFalse(truth.empty());
} }
public void testGetDefaultNewCameraMatrixMatSizeBoolean() { public void testGetDefaultNewCameraMatrixMatSizeBoolean() {
Mat out = new Mat(); truth = new Mat();
Size size = new Size(3, 3); Size size = new Size(3, 3);
out = Imgproc.getDefaultNewCameraMatrix(gray0, size, true); truth = Imgproc.getDefaultNewCameraMatrix(gray0, size, true);
assertTrue(0 != Core.countNonZero(out)); assertTrue(0 != Core.countNonZero(truth));
assertFalse(out.empty()); assertFalse(truth.empty());
} }
public void testGetDerivKernelsMatMatIntIntInt() { public void testGetDerivKernelsMatMatIntIntInt() {
...@@ -942,70 +893,68 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -942,70 +893,68 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testGetGaussianKernelIntDouble() { public void testGetGaussianKernelIntDouble() {
Mat out = new Mat(1, 1, CvType.CV_64FC1, new Scalar(1.0)); truth = new Mat(1, 1, CvType.CV_64FC1, new Scalar(1.0));
dst = Imgproc.getGaussianKernel(1, 0.5); dst = Imgproc.getGaussianKernel(1, 0.5);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testGetGaussianKernelIntDoubleInt() { public void testGetGaussianKernelIntDoubleInt() {
Mat out = new Mat(3, 1, CvType.CV_32F); truth = new Mat(3, 1, CvType.CV_32F);
out.put(0, 0, 0.23899426, 0.52201146, 0.23899426); truth.put(0, 0, 0.23899426, 0.52201146, 0.23899426);
dst = Imgproc.getGaussianKernel(3, 0.8, CvType.CV_32F); dst = Imgproc.getGaussianKernel(3, 0.8, CvType.CV_32F);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testGetRectSubPixMatSizePointMat() { public void testGetRectSubPixMatSizePointMat() {
Mat out = 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 patchSize = 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, patchSize, center, dst);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testGetRectSubPixMatSizePointMatInt() { public void testGetRectSubPixMatSizePointMatInt() {
Mat src = new Mat(10, 10, CvType.CV_32F, new Scalar(2)); Mat src = new Mat(10, 10, CvType.CV_32F, new Scalar(2));
Mat out = new Mat(5, 5, CvType.CV_32F, new Scalar(2)); truth = new Mat(5, 5, CvType.CV_32F, new Scalar(2));
Size patchSize = new Size(5, 5); Size patchSize = new Size(5, 5);
Point center = new Point(src.cols() / 2, src.rows() / 2); Point center = new Point(src.cols() / 2, src.rows() / 2);
Imgproc.getRectSubPix(src, patchSize, center, dst); Imgproc.getRectSubPix(src, patchSize, center, dst);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testGetRotationMatrix2D() { public void testGetRotationMatrix2D() {
Mat out = new Mat(2, 3, CvType.CV_64F); truth = new Mat(2, 3, CvType.CV_64F);
out.put(0, 0, 1, 0, 0); truth.put(0, 0, 1, 0, 0);
out.put(1, 0, 0, 1, 0); truth.put(1, 0, 0, 1, 0);
Point center = new Point(0, 0); Point center = new Point(0, 0);
dst = Imgproc.getRotationMatrix2D(center, 0.0, 1.0); dst = Imgproc.getRotationMatrix2D(center, 0.0, 1.0);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testGetStructuringElementIntSize() { public void testGetStructuringElementIntSize() {
Mat out = 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); Size ksize = new Size(3, 3);
dst = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, ksize); dst = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, ksize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testGetStructuringElementIntSizePoint() { public void testGetStructuringElementIntSizePoint() {
Mat out = new Mat(3, 3, CvType.CV_8UC1); truth = new Mat(3, 3, CvType.CV_8UC1);
Size ksize = new Size(3, 3); Size ksize = new Size(3, 3);
Point point = new Point(2, 2); Point point = new Point(2, 2);
out.put(0, 0, 0, 0, 1); truth.put(0, 0, 0, 0, 1);
out.put(1, 0, 0, 0, 1); truth.put(1, 0, 0, 0, 1);
out.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, ksize, point);
OpenCVTestRunner.Log(dst.dump()); OpenCVTestRunner.Log(dst.dump());
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testGoodFeaturesToTrackMatMatIntDoubleDouble() { public void testGoodFeaturesToTrackMatMatIntDoubleDouble() {
...@@ -1123,13 +1072,13 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1123,13 +1072,13 @@ public class imgprocTest extends OpenCVTestCase {
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);
out.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
out.put(1, 0, 0, 0, 0); truth.put(1, 0, 0, 0, 0);
out.put(2, 0, 0, 3, 0); truth.put(2, 0, 0, 3, 0);
distCoeffs.put(0, 0, 1.0, 3.0, 2.0, 4); distCoeffs.put(0, 0, 1.0, 3.0, 2.0, 4);
// TODO: No documentation for this function // TODO: No documentation for this function
// Imgproc.initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize, 5.0, m1type, output1, output2); // Imgproc.initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize, 5.0, m1type, truthput1, truthput2);
fail("Not yet implemented"); fail("Not yet implemented");
} }
...@@ -1241,38 +1190,38 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1241,38 +1190,38 @@ 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(2, 2, CvType.CV_32F, new Scalar(2.0));
Mat out = new Mat(3, 3, CvType.CV_64F); truth = new Mat(3, 3, CvType.CV_64F);
out.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
out.put(1, 0, 0, 2, 4); truth.put(1, 0, 0, 2, 4);
out.put(2, 0, 0, 4, 8); truth.put(2, 0, 0, 4, 8);
Imgproc.integral(src, dst); Imgproc.integral(src, dst);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testIntegralMatMatInt() { public void testIntegralMatMatInt() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0));
Mat out = new Mat(3, 3, CvType.CV_64F); truth = new Mat(3, 3, CvType.CV_64F);
out.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
out.put(1, 0, 0, 2, 4); truth.put(1, 0, 0, 2, 4);
out.put(2, 0, 0, 4, 8); truth.put(2, 0, 0, 4, 8);
Imgproc.integral(src, dst, CvType.CV_64F); Imgproc.integral(src, dst, CvType.CV_64F);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testInvertAffineTransform() { public void testInvertAffineTransform() {
Mat src = new Mat(2, 3, CvType.CV_64F); Mat src = new Mat(2, 3, CvType.CV_64F);
Mat out = new Mat(2, 3, CvType.CV_64F, new Scalar(0)); src.put(0, 0, 1, 1, 1); //TODO: use setTo
src.put(0, 0, 1, 1, 1);
src.put(1, 0, 1, 1, 1); src.put(1, 0, 1, 1, 1);
truth = new Mat(2, 3, CvType.CV_64F, new Scalar(0));
Imgproc.invertAffineTransform(src, dst); Imgproc.invertAffineTransform(src, dst);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testIsContourConvex() { public void testIsContourConvex() {
...@@ -1292,49 +1241,46 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1292,49 +1241,46 @@ public class imgprocTest extends OpenCVTestCase {
public void testLaplacianMatMatIntInt() { public void testLaplacianMatMatIntInt() {
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));
Mat out = new Mat(3, 3, CvType.CV_32F, new Scalar(0.0)); truth = new Mat(3, 3, CvType.CV_32F, new Scalar(0.0));
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1); Imgproc.Laplacian(src, dst, CvType.CV_32F, 1);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testLaplacianMatMatIntIntDouble() { public void testLaplacianMatMatIntIntDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
Mat out = new Mat(2, 2, CvType.CV_32F); src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(0, 0, 1, 0);
src.put(1, 0, 0, 1); src.put(1, 0, 0, 1);
truth = new Mat(2, 2, CvType.CV_32F);
out.put(0, 0, -8, 8); truth.put(0, 0, -8, 8);
out.put(1, 0, 8, -8); truth.put(1, 0, 8, -8);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0); Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0);
OpenCVTestRunner.Log(dst.dump()); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testLaplacianMatMatIntIntDoubleDouble() { public void testLaplacianMatMatIntIntDoubleDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
Mat out = new Mat(2, 2, CvType.CV_32F); truth = new Mat(2, 2, CvType.CV_32F);
double delta = 0.0; double delta = 0.0;
src.put(0, 0, 1, 0); src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1); src.put(1, 0, 0, 1);
out.put(0, 0, -8, 8); truth.put(0, 0, -8, 8);
out.put(1, 0, 8, -8); truth.put(1, 0, 8, -8);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, delta); Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, delta);
OpenCVTestRunner.Log(dst.dump()); assertMatEqual(truth, dst);
assertMatEqual(out, 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));
Mat out = new Mat(3, 3, CvType.CV_32F, new Scalar(0.0)); truth = new Mat(3, 3, CvType.CV_32F, new Scalar(0.0));
double delta = 0.0; double delta = 0.0;
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, delta, Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, delta, Imgproc.BORDER_REFLECT);
Imgproc.BORDER_REFLECT); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testMatchShapes() { public void testMatchShapes() {
...@@ -1376,8 +1322,9 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1376,8 +1322,9 @@ public class imgprocTest extends OpenCVTestCase {
public void testMinAreaRect() { public void testMinAreaRect() {
Mat points = new Mat(1, 4, CvType.CV_32FC2); Mat points = new Mat(1, 4, CvType.CV_32FC2);
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 rotatedDst = new RotatedRect();
rotatedDst = 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");
} }
...@@ -1389,7 +1336,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1389,7 +1336,7 @@ public class imgprocTest extends OpenCVTestCase {
float radius = 0.0f; float radius = 0.0f;
// float expectedRadius = 1.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 //TODO: Unexpected radius is returned i.e 0
Imgproc.minEnclosingCircle(points, actualCenter, radius); Imgproc.minEnclosingCircle(points, actualCenter, radius);
assertEquals(expCenter, actualCenter); assertEquals(expCenter, actualCenter);
// assertEquals(expectedRadius, radius); // assertEquals(expectedRadius, radius);
...@@ -1411,74 +1358,71 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1411,74 +1358,71 @@ public class imgprocTest extends OpenCVTestCase {
public void testMorphologyExMatMatIntMatPoint() { public void testMorphologyExMatMatIntMatPoint() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = new Mat(2, 2, 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(2, 2, CvType.CV_8U, new Scalar(0));
Mat out = new Mat(2, 2, CvType.CV_8U);
Point point = new Point(0, 0); Point point = new Point(0, 0);
src.put(0, 0, 1, 0); truth = new Mat(2, 2, CvType.CV_8U);
src.put(1, 0, 0, 1); truth.put(0, 0, 1, 0); //TODO: use Mat.eye
truth.put(1, 0, 0, 1);
out.put(0, 0, 1, 0);
out.put(1, 0, 0, 1);
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_OPEN, kernel, point); Imgproc.morphologyEx(src, dst, Imgproc.MORPH_OPEN, kernel, point);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testMorphologyExMatMatIntMatPointInt() { public void testMorphologyExMatMatIntMatPointInt() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = new Mat(2, 2, 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(2, 2, CvType.CV_8U, new Scalar(0));
Mat out = new Mat(2, 2, CvType.CV_8U);
Point point = new Point(0, 0); Point point = new Point(0, 0);
src.put(0, 0, 1, 0); truth = new Mat(2, 2, CvType.CV_8U);
src.put(1, 0, 0, 1); truth.put(0, 0, 1, 0); //TODO: use Mat.eye
truth.put(1, 0, 0, 1);
out.put(0, 0, 1, 0);
out.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);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testMorphologyExMatMatIntMatPointIntInt() { public void testMorphologyExMatMatIntMatPointIntInt() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = new Mat(2, 2, CvType.CV_8U);
Mat kernel = new Mat(2, 2, CvType.CV_8U, new Scalar(1));
Mat out = new Mat(2, 2, CvType.CV_8U);
Point point = new Point(1, 1);
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));
Point point = new Point(1, 1);
truth = new Mat(2, 2, CvType.CV_8U);
truth.put(0, 0, 1, 0);
truth.put(1, 0, 1, 0);
out.put(0, 0, 1, 0); Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10, Imgproc.BORDER_REFLECT);
out.put(1, 0, 1, 0); assertMatEqual(truth, dst);
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10,
Imgproc.BORDER_REFLECT);
assertMatEqual(out, dst);
} }
public void testMorphologyExMatMatIntMatPointIntIntScalar() { public void testMorphologyExMatMatIntMatPointIntIntScalar() {
Mat src = new Mat(2, 2, CvType.CV_8U); Mat src = new Mat(2, 2, CvType.CV_8U);
src.put(0, 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(2, 2, CvType.CV_8U, new Scalar(1));
Mat out = new Mat(2, 2, CvType.CV_8U);
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);
truth.put(0, 0, 1, 0);
truth.put(1, 0, 1, 0);
src.put(0, 0, 2, 1); Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10, Imgproc.BORDER_REFLECT, sc);
src.put(1, 0, 2, 1); assertMatEqual(truth, dst);
out.put(0, 0, 1, 0);
out.put(1, 0, 1, 0);
Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10,
Imgproc.BORDER_REFLECT, sc);
assertMatEqual(out, dst);
} }
public void testPointPolygonTest() { public void testPointPolygonTest() {
Mat contour1 = new Mat(1, 5, CvType.CV_32FC2); Mat contour1 = new Mat(1, 5, CvType.CV_32FC2);
contour1.put(0, 0, 0.0, 0.0, 1.0, 3.0, 3.0, 4.0, 4.0, 3.0, 2.0, 1.0); contour1.put(0, 0, 0.0, 0.0, 1.0, 3.0, 3.0, 4.0, 4.0, 3.0, 2.0, 1.0);
Point pt1 = new Point(contour1.cols() / 2, contour1.rows() / 2); Point pt1 = new Point(contour1.cols() / 2, contour1.rows() / 2);
...@@ -1495,43 +1439,41 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1495,43 +1439,41 @@ public class imgprocTest extends OpenCVTestCase {
public void testPreCornerDetectMatMatInt() { public void testPreCornerDetectMatMatInt() {
Mat src = new Mat(4, 4, CvType.CV_32F, new Scalar(1)); Mat src = new Mat(4, 4, CvType.CV_32F, new Scalar(1));
Mat out = new Mat(4, 4, CvType.CV_32F, new Scalar(0)); truth = new Mat(4, 4, CvType.CV_32F, new Scalar(0));
int ksize = 3; int ksize = 3;
Imgproc.preCornerDetect(src, dst, ksize); Imgproc.preCornerDetect(src, dst, ksize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testPreCornerDetectMatMatIntInt() { public void testPreCornerDetectMatMatIntInt() {
Mat src = new Mat(4, 4, CvType.CV_32F, new Scalar(1)); Mat src = new Mat(4, 4, CvType.CV_32F, new Scalar(1));
Mat out = new Mat(4, 4, CvType.CV_32F, new Scalar(0)); truth = new Mat(4, 4, CvType.CV_32F, new Scalar(0));
int ksize = 3; int ksize = 3;
Imgproc.preCornerDetect(src, dst, ksize, Imgproc.BORDER_REFLECT); Imgproc.preCornerDetect(src, dst, ksize, Imgproc.BORDER_REFLECT);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testPyrDownMatMat() { public void testPyrDownMatMat() {
Mat src = new Mat(4, 4, CvType.CV_32F); Mat src = new Mat(4, 4, CvType.CV_32F);
Mat out = new Mat(2, 2, 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);
out.put(0, 0, 2.78125, 4.609375); truth.put(0, 0, 2.78125, 4.609375);
out.put(1, 0, 8.546875, 8.8515625); truth.put(1, 0, 8.546875, 8.8515625);
Imgproc.pyrDown(src, dst); Imgproc.pyrDown(src, dst);
; assertMatEqual(truth, dst);
assertMatEqual(out, 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);
Mat out = new Mat(2, 2, CvType.CV_32F); truth = new Mat(2, 2, 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);
...@@ -1539,11 +1481,11 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1539,11 +1481,11 @@ public class imgprocTest extends OpenCVTestCase {
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);
out.put(0, 0, 2.78125, 4.609375); truth.put(0, 0, 2.78125, 4.609375);
out.put(1, 0, 8.546875, 8.8515625); truth.put(1, 0, 8.546875, 8.8515625);
Imgproc.pyrDown(src, dst, dstSize); Imgproc.pyrDown(src, dst, dstSize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testPyrMeanShiftFilteringMatMatDoubleDouble() { public void testPyrMeanShiftFilteringMatMatDoubleDouble() {
...@@ -1562,219 +1504,214 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1562,219 +1504,214 @@ public class imgprocTest extends OpenCVTestCase {
public void testPyrUpMatMat() { public void testPyrUpMatMat() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
Mat out = new Mat(4, 4, 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);
out.put(0, 0, 2, 1.75, 1.375, 1.25); truth = new Mat(4, 4, CvType.CV_32F);
out.put(1, 0, 2.25, 2, 1.625, 1.5); truth.put(0, 0, 2, 1.75, 1.375, 1.25);
out.put(2, 0, 2.5, 2.25, 1.875, 1.75); truth.put(1, 0, 2.25, 2, 1.625, 1.5);
out.put(3, 0, 2.25, 2, 1.625, 1.5); truth.put(2, 0, 2.5, 2.25, 1.875, 1.75);
truth.put(3, 0, 2.25, 2, 1.625, 1.5);
Imgproc.pyrUp(src, dst); Imgproc.pyrUp(src, dst);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testPyrUpMatMatSize() { public void testPyrUpMatMatSize() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
Mat out = new Mat(4, 4, CvType.CV_32F);
Size dstSize = new Size(4, 4);
src.put(0, 0, 2, 1); src.put(0, 0, 2, 1);
src.put(1, 0, 3, 2); src.put(1, 0, 3, 2);
out.put(0, 0, 2, 1.75, 1.375, 1.25); Size dstSize = new Size(4, 4);
out.put(1, 0, 2.25, 2, 1.625, 1.5); truth = new Mat(4, 4, CvType.CV_32F);
out.put(2, 0, 2.5, 2.25, 1.875, 1.75); truth.put(0, 0, 2, 1.75, 1.375, 1.25);
out.put(3, 0, 2.25, 2, 1.625, 1.5); truth.put(1, 0, 2.25, 2, 1.625, 1.5);
truth.put(2, 0, 2.5, 2.25, 1.875, 1.75);
truth.put(3, 0, 2.25, 2, 1.625, 1.5);
Imgproc.pyrUp(src, dst, dstSize); Imgproc.pyrUp(src, dst, dstSize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testRemapMatMatMatMatInt() { public void testRemapMatMatMatMatInt() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(2, 2, 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);
Mat out = new Mat(1, 3, CvType.CV_32F, new Scalar(0));
map1.put(0, 0, 3.0, 6.0, 5, 0); map1.put(0, 0, 3.0, 6.0, 5, 0);
map2.put(0, 0, 4.0, 8.0, 12.0); map2.put(0, 0, 4.0, 8.0, 12.0);
truth = new Mat(1, 3, CvType.CV_32F, new Scalar(0));
Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR); Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testRemapMatMatMatMatIntInt() { public void testRemapMatMatMatMatIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(2, 2, 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);
Mat out = new Mat(1, 3, CvType.CV_32F, new Scalar(2));
map1.put(0, 0, 3.0, 6.0, 5, 0); map1.put(0, 0, 3.0, 6.0, 5, 0);
map2.put(0, 0, 4.0, 8.0, 12.0); map2.put(0, 0, 4.0, 8.0, 12.0);
truth = new Mat(1, 3, CvType.CV_32F, new Scalar(2));
Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR, Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR, Imgproc.BORDER_REFLECT);
Imgproc.BORDER_REFLECT); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testRemapMatMatMatMatIntIntScalar() { public void testRemapMatMatMatMatIntIntScalar() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(2, 2, 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);
Mat out = new Mat(1, 3, CvType.CV_32F, new Scalar(2));
Scalar sc = new Scalar(0.0); Scalar sc = new Scalar(0.0);
map1.put(0, 0, 3.0, 6.0, 5, 0); map1.put(0, 0, 3.0, 6.0, 5, 0);
map2.put(0, 0, 4.0, 8.0, 12.0); map2.put(0, 0, 4.0, 8.0, 12.0);
truth = new Mat(1, 3, CvType.CV_32F, new Scalar(2));
Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR, Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR, Imgproc.BORDER_REFLECT, sc);
Imgproc.BORDER_REFLECT, sc); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testResizeMatMatSize() { public void testResizeMatMatSize() {
Mat src = new Mat(2, 2, CvType.CV_8UC1, new Scalar(1.0)); Mat src = new Mat(2, 2, CvType.CV_8UC1, new Scalar(1.0));
Mat out = 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);
Imgproc.resize(src, dst, dsize); Imgproc.resize(src, dst, dsize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testResizeMatMatSizeDouble() { public void testResizeMatMatSizeDouble() {
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
Mat out = new Mat(2, 2, CvType.CV_8UC1, new Scalar(255)); truth = new Mat(2, 2, CvType.CV_8UC1, new Scalar(255));
Imgproc.resize(gray255, dst, dsize, 0.5); Imgproc.resize(gray255, dst, dsize, 0.5);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testResizeMatMatSizeDoubleDouble() { public void testResizeMatMatSizeDoubleDouble() {
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
Mat out = new Mat(2, 2, CvType.CV_8UC1, new Scalar(255)); truth = new Mat(2, 2, 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(out, dst); assertMatEqual(truth, dst);
} }
public void testResizeMatMatSizeDoubleDoubleInt() { public void testResizeMatMatSizeDoubleDoubleInt() {
Size dsize = new Size(2, 2); Size dsize = new Size(2, 2);
Mat out = new Mat(2, 2, CvType.CV_8UC1, new Scalar(255)); truth = new Mat(2, 2, 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(out, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntInt() { public void testScharrMatMatIntIntInt() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
src.put(0, 0, 1, 0); src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1); src.put(1, 0, 0, 1);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(0)); truth = new Mat(2, 2, 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(out, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntIntDouble() { public void testScharrMatMatIntIntIntDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
src.put(0, 0, 1, 0); src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1); src.put(1, 0, 0, 1);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(0)); truth = new Mat(2, 2, 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(out, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntIntDoubleDouble() { public void testScharrMatMatIntIntIntDoubleDouble() {
Mat src = new Mat(2, 2, CvType.CV_32F); Mat src = new Mat(2, 2, CvType.CV_32F);
src.put(0, 0, 1, 0); src.put(0, 0, 1, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1); src.put(1, 0, 0, 1);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(0.001)); truth = new Mat(2, 2, 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(out, dst); assertMatEqual(truth, dst);
} }
public void testScharrMatMatIntIntIntDoubleDoubleInt() { public void testScharrMatMatIntIntIntDoubleDoubleInt() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
src.put(0, 0, 1, 0, 0); src.put(0, 0, 1, 0, 0); //TODO: use Mat.eye
src.put(1, 0, 0, 1, 0); src.put(1, 0, 0, 1, 0);
src.put(2, 0, 0, 0, 1); src.put(2, 0, 0, 0, 1);
Mat out = new Mat(3, 3, CvType.CV_32F); truth = new Mat(3, 3, CvType.CV_32F);
out.put(0, 0, -15, -19.5, -4.5); truth.put(0, 0, -15, -19.5, -4.5);
out.put(1, 0, 10.5, 0, -10.5); truth.put(1, 0, 10.5, 0, -10.5);
out.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");
} }
public void testSepFilter2DMatMatIntMatMat() { public void testSepFilter2DMatMatIntMatMat() {
Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0)); Mat src = new Mat(2, 2, 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);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(420)); truth = new Mat(2, 2, 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()); OpenCVTestRunner.Log(dst.dump());
assertMatEqual(out, 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(2, 2, 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);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(36.0)); truth = new Mat(2, 2, CvType.CV_32F, new Scalar(36.0));
Point point = new Point(2, 2); 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, point);
assertMatEqual(out, 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(2, 2, 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);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(36.001));
Point point = new Point(2, 2); Point point = new Point(2, 2);
double delta = 0.001; double delta = 0.001;
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, truth = new Mat(2, 2, CvType.CV_32F, new Scalar(36.001));
delta); Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY, point, delta);
assertMatEqual(out, 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); Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
Mat out = new Mat(10, 10, CvType.CV_32F, new Scalar(0.001));
Point point = new Point(2, 2); Point point = new Point(2, 2);
double delta = 0.001; double delta = 0.001;
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(gray0, dst, CvType.CV_32F, kernelX, kernelY, point, truth = new Mat(10, 10, CvType.CV_32F, new Scalar(0.001));
delta, Imgproc.BORDER_REFLECT); Imgproc.sepFilter2D(gray0, dst, CvType.CV_32F, kernelX, kernelY, point, delta, Imgproc.BORDER_REFLECT);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testSobelMatMatIntIntInt() { public void testSobelMatMatIntIntInt() {
...@@ -1793,13 +1730,13 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1793,13 +1730,13 @@ public class imgprocTest extends OpenCVTestCase {
src.put(1, 0, 3, 0, -10); src.put(1, 0, 3, 0, -10);
src.put(2, 0, -4, 0, 3); src.put(2, 0, -4, 0, 3);
Mat out = new Mat(3, 3, CvType.CV_32F); truth = new Mat(3, 3, CvType.CV_32F);
out.put(0, 0, 0, -56, 0); truth.put(0, 0, 0, -56, 0);
out.put(1, 0, 0, -40, 0); truth.put(1, 0, 0, -40, 0);
out.put(2, 0, 0, -24, 0); truth.put(2, 0, 0, -24, 0);
Imgproc.Sobel(src, dst, CvType.CV_32F, 1, 0, 3, 2.0); Imgproc.Sobel(src, dst, CvType.CV_32F, 1, 0, 3, 2.0);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
...@@ -1814,14 +1751,13 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1814,14 +1751,13 @@ public class imgprocTest extends OpenCVTestCase {
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);
Mat out = new Mat(3, 3, CvType.CV_32F); truth = new Mat(3, 3, CvType.CV_32F);
out.put(0, 0, -16, -12, 4); truth.put(0, 0, -16, -12, 4);
out.put(1, 0, -14, -12, 2); truth.put(1, 0, -14, -12, 2);
out.put(2, 0, -10, 0, 10); truth.put(2, 0, -10, 0, 10);
Imgproc.Sobel(src, dst, CvType.CV_32F, 1, 0, 3, 2.0, 0.0, Imgproc.Sobel(src, dst, CvType.CV_32F, 1, 0, 3, 2.0, 0.0, Imgproc.BORDER_REPLICATE);
Imgproc.BORDER_REPLICATE); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testThreshold() { public void testThreshold() {
...@@ -1837,7 +1773,7 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1837,7 +1773,7 @@ public class imgprocTest extends OpenCVTestCase {
public void testUndistortMatMatMatMat() { public void testUndistortMatMatMatMat() {
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 out = new Mat(3, 3, CvType.CV_32F); truth = new Mat(3, 3, CvType.CV_32F);
Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F); Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F);
Mat distCoeffs = new Mat(1, 4, CvType.CV_32F); Mat distCoeffs = new Mat(1, 4, CvType.CV_32F);
...@@ -1845,19 +1781,19 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1845,19 +1781,19 @@ public class imgprocTest extends OpenCVTestCase {
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);
out.put(0, 0, 0, 0, 0);
out.put(1, 0, 0, 0, 0);
out.put(2, 0, 0, 3, 0);
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.put(0, 0, 0, 0, 0);
truth.put(1, 0, 0, 0, 0);
truth.put(2, 0, 0, 3, 0);
Imgproc.undistort(src, dst, cameraMatrix, distCoeffs); Imgproc.undistort(src, dst, cameraMatrix, distCoeffs);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testUndistortMatMatMatMatMat() { public void testUndistortMatMatMatMatMat() {
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 out = 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);
Mat distCoeffs = new Mat(1, 4, CvType.CV_32F); Mat distCoeffs = new Mat(1, 4, CvType.CV_32F);
...@@ -1868,13 +1804,13 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1868,13 +1804,13 @@ public class imgprocTest extends OpenCVTestCase {
distCoeffs.put(0, 0, 1.0, 4.0, 0.0, 5.0); distCoeffs.put(0, 0, 1.0, 4.0, 0.0, 5.0);
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(out, 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);
Mat out = new Mat(3, 3, CvType.CV_32F);
Size dsize = new Size(3, 3); Size dsize = new Size(3, 3);
Mat M = new Mat(2, 3, CvType.CV_32F); Mat M = new Mat(2, 3, CvType.CV_32F);
...@@ -1882,20 +1818,20 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1882,20 +1818,20 @@ public class imgprocTest extends OpenCVTestCase {
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);
out.put(0, 0, 0, 0, 0); truth.put(0, 0, 0, 0, 0);
out.put(1, 0, 0, 2, 0); truth.put(1, 0, 0, 2, 0);
out.put(2, 0, 0, 6, 4); truth.put(2, 0, 0, 6, 4);
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, dsize);
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testWarpAffineMatMatMatSizeInt() { public void testWarpAffineMatMatMatSizeInt() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Mat out = new Mat(2, 2, 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 = new Mat(2, 3, CvType.CV_32F);
...@@ -1903,20 +1839,21 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1903,20 +1839,21 @@ 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);
out.put(0, 0, 6, 4); truth.put(0, 0, 6, 4);
out.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()); OpenCVTestRunner.Log(dst.dump());
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testWarpAffineMatMatMatSizeIntInt() { public void testWarpAffineMatMatMatSizeIntInt() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Mat out = new Mat(2, 2, 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 = new Mat(2, 3, CvType.CV_32F);
...@@ -1924,20 +1861,20 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1924,20 +1861,20 @@ 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);
out.put(0, 0, 6, 4);
out.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);
truth.put(0, 0, 6, 4);
truth.put(1, 0, 6, 4);
Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_TRANSPARENT);
Imgproc.BORDER_TRANSPARENT); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testWarpAffineMatMatMatSizeIntIntScalar() { public void testWarpAffineMatMatMatSizeIntIntScalar() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Mat out = new Mat(2, 2, 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 = new Mat(2, 3, CvType.CV_32F);
Scalar sc = new Scalar(1.0); Scalar sc = new Scalar(1.0);
...@@ -1946,15 +1883,15 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1946,15 +1883,15 @@ 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);
out.put(0, 0, 6, 4);
out.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);
truth.put(0, 0, 6, 4);
truth.put(1, 0, 6, 4);
Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP, Imgproc.BORDER_CONSTANT, sc);
Imgproc.BORDER_CONSTANT, sc); assertMatEqual(truth, dst);
assertMatEqual(out, dst);
} }
public void testWarpPerspectiveMatMatMatSize() { public void testWarpPerspectiveMatMatMatSize() {
...@@ -1981,58 +1918,56 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -1981,58 +1918,56 @@ public class imgprocTest extends OpenCVTestCase {
public void testWarpPerspectiveMatMatMatSizeInt() { public void testWarpPerspectiveMatMatMatSizeInt() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0));
Size dsize = new Size(2, 2);
Mat M = new Mat(3, 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);
Size dsize = new Size(2, 2);
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);
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(out, dst); assertMatEqual(truth, dst);
} }
public void testWarpPerspectiveMatMatMatSizeIntInt() { public void testWarpPerspectiveMatMatMatSizeIntInt() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Mat out = new Mat(2, 2, CvType.CV_32F);
Size dsize = new Size(2, 2);
Mat M = new Mat(3, 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);
Size dsize = new Size(2, 2);
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);
out.put(0, 0, 6, 2); truth = new Mat(2, 2, CvType.CV_32F);
out.put(1, 0, 2, 2); truth.put(0, 0, 6, 2);
truth.put(1, 0, 2, 2);
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()); OpenCVTestRunner.Log(dst.dump());
assertMatEqual(out, dst); assertMatEqual(truth, dst);
} }
public void testWarpPerspectiveMatMatMatSizeIntIntScalar() { public void testWarpPerspectiveMatMatMatSizeIntIntScalar() {
Mat src = new Mat(3, 3, CvType.CV_32F); Mat src = new Mat(3, 3, CvType.CV_32F);
Mat out = new Mat(2, 2, CvType.CV_32F, new Scalar(2.0));
Size dsize = new Size(2, 2);
Mat M = new Mat(3, 3, CvType.CV_32F);
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);
Size dsize = new Size(2, 2);
Mat M = new Mat(3, 3, CvType.CV_32F);
Scalar sc = new Scalar(1.0);
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, 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(out, dst); assertMatEqual(truth, dst);
} }
public void testWatershed() { public void testWatershed() {
......
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