java tests: added tests for calcHist, calcBackProject, Mat.size() method renamed
This commit is contained in:
parent
e715894ffb
commit
1fc895ff42
@ -15,13 +15,17 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
protected static double EPS = 0.001;
|
protected static double EPS = 0.001;
|
||||||
|
|
||||||
protected static Mat dst;
|
protected static Mat dst;
|
||||||
|
protected static Mat truth;
|
||||||
|
|
||||||
//Naming notation: <channels info>_[depth]_[dimensions]_value
|
//Naming notation: <channels info>_[depth]_[dimensions]_value
|
||||||
//examples: gray0 - single channel 8U 2d Mat filled with 0
|
//examples: gray0 - single channel 8U 2d Mat filled with 0
|
||||||
// grayRnd - single channel 8U 2d Mat filled with random numbers
|
// grayRnd - single channel 8U 2d Mat filled with random numbers
|
||||||
// gray0_32f_1d - TODO: refactor
|
// gray0_32f_1d
|
||||||
|
|
||||||
//TODO: create some masks
|
//TODO: OpenCVTestCase refactorings
|
||||||
|
// - rename matrices
|
||||||
|
// - create some masks
|
||||||
|
// - use truth member everywhere
|
||||||
|
|
||||||
protected static Mat gray0;
|
protected static Mat gray0;
|
||||||
protected static Mat gray1;
|
protected static Mat gray1;
|
||||||
@ -64,6 +68,8 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
|
|
||||||
dst = new Mat();
|
dst = new Mat();
|
||||||
assertTrue(dst.empty());
|
assertTrue(dst.empty());
|
||||||
|
truth = new Mat();
|
||||||
|
assertTrue(truth.empty());
|
||||||
|
|
||||||
gray0 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0));
|
gray0 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0));
|
||||||
gray1 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(1));
|
gray1 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(1));
|
||||||
|
@ -112,16 +112,16 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
|
|
||||||
public void testCartToPolarMatMatMatMat() {
|
public void testCartToPolarMatMatMatMat() {
|
||||||
Mat x = new Mat(1, 3, CvType.CV_32F);
|
Mat x = new Mat(1, 3, CvType.CV_32F);
|
||||||
Mat y = new Mat(1, 3, CvType.CV_32F);
|
Mat y = new Mat(1, 3, CvType.CV_32F);
|
||||||
Mat magnitude = new Mat(1, 3, CvType.CV_32F);
|
|
||||||
Mat angle = new Mat(1, 3, CvType.CV_32F);
|
|
||||||
Mat dst_angle = new Mat();
|
|
||||||
|
|
||||||
x.put(0, 0, 3.0, 6.0, 5,0);
|
x.put(0, 0, 3.0, 6.0, 5,0);
|
||||||
y.put(0, 0, 4.0, 8.0, 12.0);
|
y.put(0, 0, 4.0, 8.0, 12.0);
|
||||||
|
|
||||||
|
Mat magnitude = new Mat(1, 3, CvType.CV_32F);
|
||||||
|
Mat angle = new Mat(1, 3, CvType.CV_32F);
|
||||||
magnitude.put(0, 0, 5.0, 10.0, 13.0);
|
magnitude.put(0, 0, 5.0, 10.0, 13.0);
|
||||||
angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
|
angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
|
||||||
|
|
||||||
|
Mat dst_angle = new Mat();
|
||||||
core.cartToPolar(x, y, dst, dst_angle);
|
core.cartToPolar(x, y, dst, dst_angle);
|
||||||
assertMatEqual(magnitude, dst);
|
assertMatEqual(magnitude, dst);
|
||||||
assertMatEqual(angle, dst_angle);
|
assertMatEqual(angle, dst_angle);
|
||||||
@ -130,17 +130,17 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
public void testCartToPolarMatMatMatMatBoolean() {
|
public void testCartToPolarMatMatMatMatBoolean() {
|
||||||
Mat x = new Mat(1, 3, CvType.CV_32F);
|
Mat x = new Mat(1, 3, CvType.CV_32F);
|
||||||
Mat y = new Mat(1, 3, CvType.CV_32F);
|
Mat y = new Mat(1, 3, CvType.CV_32F);
|
||||||
Mat magnitude = new Mat(1, 3, CvType.CV_32F);
|
|
||||||
Mat angle = new Mat(1, 3, CvType.CV_32F);
|
|
||||||
Mat dst_angle = new Mat();
|
|
||||||
|
|
||||||
x.put(0 ,0, 3.0, 6.0, 5,0);
|
x.put(0 ,0, 3.0, 6.0, 5,0);
|
||||||
y.put(0 ,0, 4.0, 8.0, 12.0);
|
y.put(0 ,0, 4.0, 8.0, 12.0);
|
||||||
|
|
||||||
|
Mat magnitude = new Mat(1, 3, CvType.CV_32F);
|
||||||
|
Mat angle = new Mat(1, 3, CvType.CV_32F);
|
||||||
|
|
||||||
magnitude.put(0 ,0, 5.0, 10.0, 13.0);
|
magnitude.put(0 ,0, 5.0, 10.0, 13.0);
|
||||||
angle.put(0 ,0, 0.92729962, 0.92729962, 1.1759995);
|
angle.put(0 ,0, 0.92729962, 0.92729962, 1.1759995);
|
||||||
|
|
||||||
core.cartToPolar(x, y, dst, dst_angle,false);
|
Mat dst_angle = new Mat();
|
||||||
|
core.cartToPolar(x, y, dst, dst_angle,false);
|
||||||
assertMatEqual(magnitude, dst);
|
assertMatEqual(magnitude, dst);
|
||||||
assertMatEqual(angle, dst_angle);
|
assertMatEqual(angle, dst_angle);
|
||||||
}
|
}
|
||||||
@ -274,13 +274,13 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
assertMatEqual(gray0_32f_1d, dst);
|
assertMatEqual(gray0_32f_1d, dst);
|
||||||
|
|
||||||
Mat in = new Mat(1, 8, CvType.CV_32F);
|
Mat in = new Mat(1, 8, CvType.CV_32F);
|
||||||
Mat out = new Mat(1, 8, CvType.CV_32F);
|
|
||||||
|
|
||||||
in.put(0, 0, 0.203056, 0.980407, 0.35312, -0.106651, 0.0399382, 0.871475, -0.648355, 0.501067);
|
in.put(0, 0, 0.203056, 0.980407, 0.35312, -0.106651, 0.0399382, 0.871475, -0.648355, 0.501067);
|
||||||
out.put(0, 0, 0.77571625, 0.37270021, 0.18529896, 0.012146413, -0.32499927, -0.99302113, 0.55979407, -0.6251272);
|
|
||||||
|
truth = new Mat(1, 8, CvType.CV_32F);
|
||||||
|
truth.put(0, 0, 0.77571625, 0.37270021, 0.18529896, 0.012146413, -0.32499927, -0.99302113, 0.55979407, -0.6251272);
|
||||||
|
|
||||||
core.dct(in, dst);
|
core.dct(in, dst);
|
||||||
assertMatEqual(out, dst);
|
assertMatEqual(truth, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeterminant() {
|
public void testDeterminant() {
|
||||||
@ -298,10 +298,10 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
Mat src = new Mat(1, 4, CvType.CV_32F);
|
Mat src = new Mat(1, 4, CvType.CV_32F);
|
||||||
src.put(0, 0, 0, 0, 0, 0);
|
src.put(0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
Mat out = new Mat(1, 4, CvType.CV_32F);
|
truth = new Mat(1, 4, CvType.CV_32F);
|
||||||
out.put(0, 0, 0, 0, 0, 0);
|
truth.put(0, 0, 0, 0, 0, 0);
|
||||||
core.dft(src, dst);
|
core.dft(src, dst);
|
||||||
assertMatEqual(out, dst);
|
assertMatEqual(truth, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDftMatMatInt() {
|
public void testDftMatMatInt() {
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
package org.opencv.test.imgproc;
|
package org.opencv.test.imgproc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.opencv.CvType;
|
||||||
|
import org.opencv.Mat;
|
||||||
|
import org.opencv.Scalar;
|
||||||
import org.opencv.Size;
|
import org.opencv.Size;
|
||||||
|
import org.opencv.core;
|
||||||
import org.opencv.imgproc;
|
import org.opencv.imgproc;
|
||||||
import org.opencv.test.OpenCVTestCase;
|
import org.opencv.test.OpenCVTestCase;
|
||||||
|
|
||||||
|
|
||||||
public class imgprocTest extends OpenCVTestCase {
|
public class imgprocTest extends OpenCVTestCase {
|
||||||
|
|
||||||
public void test_1() {
|
public void test_1() {
|
||||||
super.test_1("IMGPROC");
|
super.test_1("imgproc");
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: this test crashes
|
//FIXME: this test crashes
|
||||||
@ -54,6 +61,10 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testApproxPolyDP() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testArcLength() {
|
public void testArcLength() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -88,6 +99,10 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBoundingRect() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testBoxFilterMatMatIntSize() {
|
public void testBoxFilterMatMatIntSize() {
|
||||||
Size sz = new Size(3, 3);
|
Size sz = new Size(3, 3);
|
||||||
imgproc.boxFilter(gray0, dst, 8, sz);
|
imgproc.boxFilter(gray0, dst, 8, sz);
|
||||||
@ -106,6 +121,76 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCalcBackProject() {
|
||||||
|
ArrayList<Mat> images = new ArrayList<Mat>();
|
||||||
|
List<Integer> channels = new ArrayList<Integer>();
|
||||||
|
List<Integer> histSize = new ArrayList<Integer>();
|
||||||
|
List<Float> ranges = new ArrayList<Float>();
|
||||||
|
|
||||||
|
images.add(grayChess);
|
||||||
|
channels.add(0);
|
||||||
|
histSize.add(10);
|
||||||
|
ranges.add(0.0f); ranges.add(256.0f);
|
||||||
|
|
||||||
|
Mat hist = new Mat();
|
||||||
|
imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges);
|
||||||
|
core.normalize(hist, hist);
|
||||||
|
|
||||||
|
imgproc.calcBackProject(images, channels, hist, dst, ranges, 255);
|
||||||
|
assertTrue(grayChess.size().equals(dst.size()));
|
||||||
|
assertEquals(grayChess.depth(), dst.depth());
|
||||||
|
assertTrue(0 != core.countNonZero(dst));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloat() {
|
||||||
|
ArrayList<Mat> images = new ArrayList<Mat>();
|
||||||
|
List<Integer> channels = new ArrayList<Integer>();
|
||||||
|
List<Integer> histSize = new ArrayList<Integer>();
|
||||||
|
List<Float> ranges = new ArrayList<Float>();
|
||||||
|
|
||||||
|
images.add(gray128);
|
||||||
|
channels.add(0);
|
||||||
|
histSize.add(10);
|
||||||
|
ranges.add(0.0f); ranges.add(256.0f);
|
||||||
|
|
||||||
|
truth = new Mat(10, 1, CvType.CV_32F, Scalar.all(0.0));
|
||||||
|
truth.put(5, 0, 100.0);
|
||||||
|
|
||||||
|
Mat hist = new Mat();
|
||||||
|
imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges);
|
||||||
|
assertMatEqual(truth, hist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloat2d() {
|
||||||
|
ArrayList<Mat> images = new ArrayList<Mat>();
|
||||||
|
List<Integer> channels = new ArrayList<Integer>();
|
||||||
|
List<Integer> histSize = new ArrayList<Integer>();
|
||||||
|
List<Float> ranges = new ArrayList<Float>();
|
||||||
|
|
||||||
|
images.add(gray255);
|
||||||
|
images.add(gray128);
|
||||||
|
|
||||||
|
channels.add(0);
|
||||||
|
channels.add(1);
|
||||||
|
|
||||||
|
histSize.add(10);
|
||||||
|
histSize.add(10);
|
||||||
|
|
||||||
|
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.put(9, 5, 100.0);
|
||||||
|
|
||||||
|
Mat hist = new Mat();
|
||||||
|
imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges);
|
||||||
|
assertMatEqual(truth, hist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloatBoolean() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testCannyMatMatDoubleDouble() {
|
public void testCannyMatMatDoubleDouble() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -137,6 +222,18 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
public void testConvertMapsMatMatMatMatIntBoolean() {
|
public void testConvertMapsMatMatMatMatIntBoolean() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testConvexHullMatMat() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConvexHullMatMatBoolean() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConvexHullMatMatBooleanBoolean() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testCopyMakeBorderMatMatIntIntIntIntInt() {
|
public void testCopyMakeBorderMatMatIntIntIntIntInt() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
@ -174,6 +271,10 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCornerSubPix() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testCvtColorMatMatInt() {
|
public void testCvtColorMatMatInt() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -206,6 +307,30 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDrawContoursMatListOfMatIntScalar() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDrawContoursMatListOfMatIntScalarInt() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDrawContoursMatListOfMatIntScalarIntInt() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDrawContoursMatListOfMatIntScalarIntIntMat() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDrawContoursMatListOfMatIntScalarIntIntMatInt() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDrawContoursMatListOfMatIntScalarIntIntMatIntPoint() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testEqualizeHist() {
|
public void testEqualizeHist() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -246,6 +371,42 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFindContoursMatListOfMatMatIntInt() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFindContoursMatListOfMatMatIntIntPoint() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFitEllipse() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFitLine() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFloodFillMatMatPointScalar() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFloodFillMatMatPointScalarRect() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFloodFillMatMatPointScalarRectScalar() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFloodFillMatMatPointScalarRectScalarScalar() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFloodFillMatMatPointScalarRectScalarScalarInt() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testGaussianBlurMatMatSizeDouble() {
|
public void testGaussianBlurMatMatSizeDouble() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -258,6 +419,10 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetAffineTransform() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testGetDefaultNewCameraMatrixMat() {
|
public void testGetDefaultNewCameraMatrixMat() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -382,6 +547,10 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testHuMoments() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testInitUndistortRectifyMap() {
|
public void testInitUndistortRectifyMap() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -466,6 +635,22 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMinAreaRect() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMinEnclosingCircle() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMomentsMat() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMomentsMatBoolean() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testMorphologyExMatMatIntMat() {
|
public void testMorphologyExMatMatIntMat() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
@ -506,6 +691,18 @@ public class imgprocTest extends OpenCVTestCase {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPyrMeanShiftFilteringMatMatDoubleDouble() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPyrMeanShiftFilteringMatMatDoubleDoubleInt() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPyrMeanShiftFilteringMatMatDoubleDoubleIntTermCriteria() {
|
||||||
|
fail("Not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
public void testPyrUpMatMat() {
|
public void testPyrUpMatMat() {
|
||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class Mat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//javadoc:Mat::size()
|
//javadoc:Mat::size()
|
||||||
public Size Size() {
|
public Size size() {
|
||||||
if(nativeObj == 0) return new Size();
|
if(nativeObj == 0) return new Size();
|
||||||
return new Size(nSize(nativeObj));
|
return new Size(nSize(nativeObj));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user