mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 05:29:54 +08:00
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 Mat dst;
|
||||
protected static Mat truth;
|
||||
|
||||
//Naming notation: <channels info>_[depth]_[dimensions]_value
|
||||
//examples: gray0 - single channel 8U 2d Mat filled with 0
|
||||
// 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 gray1;
|
||||
@ -64,6 +68,8 @@ public class OpenCVTestCase extends TestCase {
|
||||
|
||||
dst = new Mat();
|
||||
assertTrue(dst.empty());
|
||||
truth = new Mat();
|
||||
assertTrue(truth.empty());
|
||||
|
||||
gray0 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0));
|
||||
gray1 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(1));
|
||||
|
@ -112,16 +112,16 @@ public class coreTest extends OpenCVTestCase {
|
||||
|
||||
public void testCartToPolarMatMatMatMat() {
|
||||
Mat x = 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();
|
||||
|
||||
Mat y = new Mat(1, 3, CvType.CV_32F);
|
||||
x.put(0, 0, 3.0, 6.0, 5,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);
|
||||
angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
|
||||
|
||||
Mat dst_angle = new Mat();
|
||||
core.cartToPolar(x, y, dst, dst_angle);
|
||||
assertMatEqual(magnitude, dst);
|
||||
assertMatEqual(angle, dst_angle);
|
||||
@ -130,17 +130,17 @@ public class coreTest extends OpenCVTestCase {
|
||||
public void testCartToPolarMatMatMatMatBoolean() {
|
||||
Mat x = 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);
|
||||
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);
|
||||
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(angle, dst_angle);
|
||||
}
|
||||
@ -274,13 +274,13 @@ public class coreTest extends OpenCVTestCase {
|
||||
assertMatEqual(gray0_32f_1d, dst);
|
||||
|
||||
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);
|
||||
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);
|
||||
assertMatEqual(out, dst);
|
||||
assertMatEqual(truth, dst);
|
||||
}
|
||||
|
||||
public void testDeterminant() {
|
||||
@ -298,10 +298,10 @@ public class coreTest extends OpenCVTestCase {
|
||||
Mat src = new Mat(1, 4, CvType.CV_32F);
|
||||
src.put(0, 0, 0, 0, 0, 0);
|
||||
|
||||
Mat out = new Mat(1, 4, CvType.CV_32F);
|
||||
out.put(0, 0, 0, 0, 0, 0);
|
||||
truth = new Mat(1, 4, CvType.CV_32F);
|
||||
truth.put(0, 0, 0, 0, 0, 0);
|
||||
core.dft(src, dst);
|
||||
assertMatEqual(out, dst);
|
||||
assertMatEqual(truth, dst);
|
||||
}
|
||||
|
||||
public void testDftMatMatInt() {
|
||||
|
@ -1,14 +1,21 @@
|
||||
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.core;
|
||||
import org.opencv.imgproc;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
|
||||
public class imgprocTest extends OpenCVTestCase {
|
||||
|
||||
|
||||
public void test_1() {
|
||||
super.test_1("IMGPROC");
|
||||
super.test_1("imgproc");
|
||||
}
|
||||
|
||||
//FIXME: this test crashes
|
||||
@ -54,6 +61,10 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testApproxPolyDP() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testArcLength() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -88,6 +99,10 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testBoundingRect() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testBoxFilterMatMatIntSize() {
|
||||
Size sz = new Size(3, 3);
|
||||
imgproc.boxFilter(gray0, dst, 8, sz);
|
||||
@ -106,6 +121,76 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
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() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -137,6 +222,18 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
public void testConvertMapsMatMatMatMatIntBoolean() {
|
||||
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() {
|
||||
fail("Not yet implemented");
|
||||
@ -174,6 +271,10 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCornerSubPix() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCvtColorMatMatInt() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -206,6 +307,30 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
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() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -246,6 +371,42 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
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() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -258,6 +419,10 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testGetAffineTransform() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testGetDefaultNewCameraMatrixMat() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -382,6 +547,10 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testHuMoments() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testInitUndistortRectifyMap() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -466,6 +635,22 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
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() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
@ -506,6 +691,18 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
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() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class Mat {
|
||||
}
|
||||
|
||||
//javadoc:Mat::size()
|
||||
public Size Size() {
|
||||
public Size size() {
|
||||
if(nativeObj == 0) return new Size();
|
||||
return new Size(nSize(nativeObj));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user