if (isEqualityMeasured)
assertTrue("Max difference between expected and actiual Mats is bigger than " + eps,
- Core.checkRange(diff, true, new Point(), 0.0, eps));
+ Core.checkRange(diff, true, 0.0, eps));
else
assertFalse("Max difference between expected and actiual Mats is less than " + eps,
- Core.checkRange(diff, true, new Point(), 0.0, eps));
+ Core.checkRange(diff, true, 0.0, eps));
}
protected static String readFile(String path) {
assertMatEqual(gray255, dst);
}
- public void testAddMatMatMatMat() {
- Mat mask = makeMask(gray1.clone());
- dst = gray127.clone();
-
- Core.add(gray127, gray1, dst, mask);
-
- assertMatEqual(makeMask(gray128, 127), dst);
- }
-
public void testAddMatMatMatMatInt() {
Core.add(gray0, gray1, dst, gray1, CvType.CV_32F);
assertMatEqual(expected_angle, dst_angle, EPS * 180/Math.PI);
}
+
public void testCheckRangeMat() {
Mat outOfRange = new Mat(2, 2, CvType.CV_64F);
outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 0);
assertFalse(Core.checkRange(outOfRange));
}
- public void testCheckRangeMatBoolean() {
- Mat outOfRange = new Mat(2, 2, CvType.CV_64F);
- outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 0);
-
- assertFalse(Core.checkRange(outOfRange, true));
-
- try {
- Core.checkRange(outOfRange, false);
- fail("Core.checkRange should throw the CvException");
- } catch (CvException e) {
- // expected
- }
- }
-
- public void testCheckRangeMatBooleanPoint() {
- Mat outOfRange = new Mat(2, 3, CvType.CV_64F);
- outOfRange.put(0, 0, 1, 2, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 0);
- Point pt = new Point();
-
- assertFalse(Core.checkRange(outOfRange, true, null));
- assertFalse(Core.checkRange(outOfRange, true, pt));
-
- assertPointEquals(new Point(2, 0), pt, EPS);
- }
-
- public void testCheckRangeMatBooleanPointDouble() {
- assertFalse(Core.checkRange(gray255, true, null, 256));
- assertTrue(Core.checkRange(gray0, true, null, 0));
- }
public void testCheckRangeMatBooleanPointDoubleDouble() {
Mat inRange = new Mat(2, 3, CvType.CV_64F) {
}
};
- assertTrue(Core.checkRange(inRange, true, null, 5, 100));
+ assertTrue(Core.checkRange(inRange, true, 5, 100));
Mat outOfRange = new Mat(2, 3, CvType.CV_64F) {
{
}
};
- assertFalse(Core.checkRange(outOfRange, true, null, 5, 100));
+ assertFalse(Core.checkRange(outOfRange, true, 5, 100));
}
-
+
public void testCircleMatPointIntScalar() {
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4);
assertTrue(0 != Core.countNonZero(gray0));
}
- public void testCircleMatPointIntScalarIntInt() {
- Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
- int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4);
- Scalar color = new Scalar(128);
-
- Core.circle(gray0, center, radius, color, 2, Core.LINE_4);
-
- assertTrue(0 != Core.countNonZero(gray0));
- }
-
public void testCircleMatPointIntScalarIntIntInt() {
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
Point center2 = new Point(gray0.cols(), gray0.rows());
assertMatEqual(gray255, dst, EPS);
}
- public void testConvertScaleAbsMatMatDouble() {
- Core.convertScaleAbs(gray0, dst, 2);
-
- assertMatEqual(gray0, dst);
-
- Core.convertScaleAbs(gray_16u_256, dst, 2);
-
- assertMatEqual(gray255, dst);
- }
-
public void testConvertScaleAbsMatMatDoubleDouble() {
Core.convertScaleAbs(gray_16u_256, dst, 2, -513);
assertMatEqual(gray0_32f_1d, dst, EPS);
}
- public void testDftMatMatInt() {
- Mat src = new Mat(1, 4, CvType.CV_32F) {
- {
- put(0, 0, 1, 2, 3, 4);
- }
- };
-
- Core.dft(src, dst, Core.DFT_REAL_OUTPUT);
-
- truth = new Mat(1, 4, CvType.CV_32F) {
- {
- put(0, 0, 10, -2, 2, -2);
- }
- };
- assertMatEqual(truth, dst, EPS);
-
- Core.dft(src, dst, Core.DFT_INVERSE);
-
- truth = new Mat(1, 4, CvType.CV_32F) {
- {
- put(0, 0, 9, -9, 1, 3);
- }
- };
- assertMatEqual(truth, dst, EPS);
- }
-
public void testDftMatMatIntInt() {
Mat src1 = new Mat(2, 4, CvType.CV_32F) {
{
assertTrue(0 != Core.countNonZero(gray0));
}
- public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntInt() {
- Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
- Size axes = new Size(2, 2);
- double angle = 30, startAngle = 0, endAngle = 30;
-
- Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED, Core.LINE_4);
-
- assertTrue(0 != Core.countNonZero(gray0));
- }
-
public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntIntInt() {
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
Size axes = new Size(2, 2);
assertTrue(gray0.total() > Core.countNonZero(gray0));
}
- public void testFillConvexPolyMatListOfPointScalarInt() {
- List<Point> polyline = Arrays.asList(new Point(1, 1), new Point(5, 0), new Point(6, 8), new Point(0, 9));
-
- Core.fillConvexPoly(gray0, polyline, new Scalar(150), Core.LINE_8);
- Core.fillConvexPoly(gray0, polyline, new Scalar(0), Core.LINE_4);
-
- assertTrue(0 < Core.countNonZero(gray0));
- assertTrue(gray0.total() > Core.countNonZero(gray0));
- }
-
public void testFillConvexPolyMatListOfPointScalarIntInt() {
List<Point> polyline1 = Arrays.asList(new Point(2, 1), new Point(5, 1), new Point(5, 7), new Point(2, 7));
List<Point> polyline2 = Arrays.asList(new Point(4, 2), new Point(10, 2), new Point(10, 14), new Point(4, 14));
}, gray0);
}
- public void testFillPolyMatListOfListOfPointScalarInt() {
- List<Point> polyline = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(9, 3));
- List<List<Point>> polylines = new ArrayList<List<Point>>();
- polylines.add(polyline);
-
- Core.fillPoly(gray0, polylines, new Scalar(1), Core.LINE_8);
- Core.fillPoly(gray0, polylines, new Scalar(0), Core.LINE_4);
-
- assertTrue(0 < Core.countNonZero(gray0));
- }
-
- public void testFillPolyMatListOfListOfPointScalarIntInt() {
- List<Point> polyline1 = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
- List<Point> polyline2 = Arrays.asList(new Point(2, 8), new Point(2, 16), new Point(8, 2), new Point(14, 16), new Point(14, 8));
-
- List<List<Point>> polylines1 = new ArrayList<List<Point>>();
- polylines1.add(polyline1);
-
- List<List<Point>> polylines2 = new ArrayList<List<Point>>();
- polylines2.add(polyline2);
-
- Core.fillPoly(gray0, polylines1, new Scalar(1), Core.LINE_8, 0);
-
- assertTrue(0 < Core.countNonZero(gray0));
-
- Core.fillPoly(gray0, polylines2, new Scalar(0), Core.LINE_8, 1);
-
- assertEquals(0, Core.countNonZero(gray0));
- }
-
public void testFillPolyMatListOfListOfPointScalarIntIntPoint() {
List<Point> polyline1 = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
List<Point> polyline2 = Arrays.asList(new Point(0, 3), new Point(0, 7), new Point(3, 0), new Point(6, 7), new Point(6, 3));
assertMatEqual(truth, dst, EPS);
}
- public void testIdftMatMatInt() {
- Mat in = new Mat(1, 4, CvType.CV_32F) {
- {
- put(0, 0, 1.0, 2.0, 3.0, 4.0);
- }
- };
-
- Core.idft(in, dst, Core.DFT_SCALE);
-
- truth = new Mat(1, 4, CvType.CV_32F) {
- {
- put(0, 0, 2.25, -2.25, 0.25, 0.75);
- }
- };
- assertMatEqual(truth, dst, EPS);
- }
-
public void testIdftMatMatIntInt() {
Mat in = new Mat(2, 4, CvType.CV_32F) {
{
assertTrue(nPoints == Core.countNonZero(gray0));
}
- public void testLineMatPointPointScalarIntInt() {
- int nPoints = Math.min(gray0.cols(), gray0.rows());
- Point point1 = new Point(0, 3);
- Point point2 = new Point(nPoints, nPoints);
-
- Core.line(gray0, point2, point1, colorWhite, 2, Core.LINE_AA);
-
- assertFalse(0 == Core.countNonZero(gray0));
-
- Core.line(gray0, point2, point1, colorBlack, 2, Core.LINE_4);
-
- assertFalse(0 == Core.countNonZero(gray0));
- }
-
public void testLineMatPointPointScalarIntIntInt() {
int nPoints = Math.min(gray0.cols(), gray0.rows());
Point point1 = new Point(3, 4);
assertMatEqual(grayE_32f, dst, EPS);
}
- public void testMulTransposedMatMatBooleanMat() {
- Core.mulTransposed(grayRnd_32f, dst, false, grayRnd_32f);
-
- assertMatEqual(gray0_32f, dst, EPS);
- }
-
public void testMulTransposedMatMatBooleanMatDouble() {
Core.mulTransposed(grayE_32f, dst, true, gray0_32f, 2);
assertMatEqual(gray0, dst);
}
- public void testNormalizeMatMatDouble() {
- Mat m = gray0;
- m.diag().setTo(new Scalar(1));
-
- Core.normalize(m, dst, 255);
-
- truth = Mat.eye(matSize, matSize, CvType.CV_8U);
- truth.diag().setTo(new Scalar(81));
- assertMatEqual(truth, dst);
- }
-
- public void testNormalizeMatMatDoubleDouble() {
- Core.normalize(gray0, dst, 0.0, 1.0);
- // TODO: ban this overload
- assertMatEqual(gray0, dst);
- }
-
public void testNormalizeMatMatDoubleDoubleInt() {
Mat src = new Mat(1, 4, CvType.CV_32F) {
{
assertEquals(62, Core.countNonZero(img));
}
- public void testPolylinesMatListOfListOfPointBooleanScalarIntInt() {
- Mat img = gray0;
- List<List<Point>> polyline = new ArrayList<List<Point>>();
- polyline.add(Arrays.asList(new Point(1, 1), new Point(4, 1), new Point(3, 6), new Point(1, 3)));
-
- Core.polylines(img, polyline, true, new Scalar(100), 2, Core.LINE_4);
-
- assertEquals(36, Core.countNonZero(img));
- }
-
public void testPolylinesMatListOfListOfPointBooleanScalarIntIntInt() {
Mat img = gray0;
List<List<Point>> polyline1 = new ArrayList<List<Point>>();
assertEquals(0, Core.countNonZero(img));
}
- public void testPutTextMatStringPointIntDoubleScalarIntInt() {
- String text = "Hello World";
- Size labelSize = new Size(175, 22);
-
- Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
- Point origin = new Point(10, labelSize.height + 10);
-
- Core.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 1, Core.LINE_AA);
-
- assertTrue(Core.countNonZero(img) > 0);
- // check that text differs from 8-connected line
- Core.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorBlack, 1, Core.LINE_8);
- assertFalse(0 == Core.countNonZero(img));
- }
-
public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() {
String text = "Hello World";
Size labelSize = new Size(175, 22);
public void testRandu() {
Core.randu(gray0, 3, 23);
-
- assertTrue(Core.checkRange(gray0, true, null, 3, 23));
+ fail("Not yet implemented");
+ //assertTrue(Core.checkRange(gray0, true, null, 3, 23));
}
public void testRectangleMatPointPointScalar() {
Point topLeft = new Point(0, 0);
Scalar color = new Scalar(128);
- Core.rectangle(gray0, bottomRight, topLeft, color, 2, Core.LINE_AA);
- Core.rectangle(gray0, bottomRight, topLeft, colorBlack, 2, Core.LINE_4);
+ Core.rectangle(gray0, bottomRight, topLeft, color, 2, Core.LINE_AA, 0);
+ Core.rectangle(gray0, bottomRight, topLeft, colorBlack, 2, Core.LINE_4, 0);
assertTrue(0 != Core.countNonZero(gray0));
}
assertTrue(0 != Core.countNonZero(gray0));
- Core.rectangle(gray0, bottomRight2, topLeft, colorBlack, 2, Core.LINE_8);
+ Core.rectangle(gray0, bottomRight2, topLeft, colorBlack, 2, Core.LINE_8, 0);
assertEquals(0, Core.countNonZero(gray0));
}
points2.add(queryKeypoints.get(match.queryIdx).pt);
}
- Mat hmg = Calib3d.findHomography(points1, points2, Calib3d.RANSAC);
+ Mat hmg = Calib3d.findHomography(points1, points2, Calib3d.RANSAC, 3);
assertMatEqual(Mat.eye(3, 3, CvType.CV_64F), hmg, EPS);
import java.util.List;
import org.opencv.core.Core;
-import org.opencv.core.CvException;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Point;
// TODO_: write better test
}
- public void testBoxFilterMatMatIntSizePoint() {
- Imgproc.boxFilter(gray0, dst, 8, size, anchorPoint);
- assertMatEqual(gray0, dst);
- // TODO_: write better test
- }
-
public void testBoxFilterMatMatIntSizePointBoolean() {
Imgproc.boxFilter(gray255, dst, 8, size, anchorPoint, false);
assertMatEqual(gray255, dst);
// TODO_: write better test
}
- public void testCannyMatMatDoubleDoubleInt() {
- Imgproc.Canny(gray255, dst, 5, 10, 5);
- assertMatEqual(gray0, dst);
- // TODO_: write better test
- }
-
public void testCannyMatMatDoubleDoubleIntBoolean() {
Imgproc.Canny(gray0, dst, 5, 10, 5, true);
assertMatEqual(gray0, dst);
assertMatEqual(expHull, dst, EPS);
}
- public void testConvexHullMatMatBoolean() {
- Mat points = new Mat(1, 6, CvType.CV_32FC2);
- points.put(0, 0, 2, 0, 4, 0, 3, 2, 0, 2, 2, 1, 3, 1);
-
- Imgproc.convexHull(points, dst, true);
-
- Mat expHull = new Mat(4, 1, CvType.CV_32FC2);
- expHull.put(0, 0, 0, 2, 3, 2, 4, 0, 2, 0);
- assertMatEqual(expHull, dst, EPS);
- }
-
public void testConvexHullMatMatBooleanBoolean() {
Mat points = new Mat(1, 6, CvType.CV_32FC2);
points.put(0, 0, 2, 0, 4, 0, 3, 2, 0, 2, 2, 1, 3, 1);
assertEquals(0, Core.countNonZero(gray0));
}
- public void testDrawContoursMatListOfMatIntScalarIntInt() {
- Core.rectangle(gray0, new Point(1, 2), new Point(7, 8), new Scalar(100));
- List<Mat> contours = new ArrayList<Mat>();
- Imgproc.findContours(gray0, contours, new Mat(), Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
-
- Imgproc.drawContours(gray0, contours, -1, new Scalar(0), Core.FILLED, Core.LINE_8);
-
- assertEquals(0, Core.countNonZero(gray0));
- }
-
- public void testDrawContoursMatListOfMatIntScalarIntIntMat() {
- fail("Not yet implemented");
- }
-
- public void testDrawContoursMatListOfMatIntScalarIntIntMatInt() {
- fail("Not yet implemented");
- }
public void testDrawContoursMatListOfMatIntScalarIntIntMatIntPoint() {
fail("Not yet implemented");
assertMatEqual(gray128, dst);
}
- public void testErodeMatMatMatPoint() {
- Mat src = new Mat(3, 3, CvType.CV_8U) {
- {
- put(0, 0, 1, 4, 8);
- put(1, 0, 2, 0, 1);
- put(2, 0, 3, 4, 6);
- }
- };
- Mat kernel = new Mat();
-
- Imgproc.erode(src, dst, kernel, anchorPoint);
-
- truth = new Mat(3, 3, CvType.CV_8U, new Scalar(0));
- assertMatEqual(truth, dst);
- }
-
public void testErodeMatMatMatPointInt() {
Mat src = new Mat(3, 3, CvType.CV_8U) {
{
assertMatEqual(truth, dst);
}
- public void testErodeMatMatMatPointIntInt() {
- Mat src = new Mat(3, 3, CvType.CV_8U) {
- {
- put(0, 0, 15, 9, 10);
- put(1, 0, 10, 8, 12);
- put(2, 0, 12, 20, 25);
- }
- };
- Mat kernel = new Mat();
-
- Imgproc.erode(src, dst, kernel, anchorPoint, 10, Imgproc.BORDER_REFLECT);
-
- truth = new Mat(3, 3, CvType.CV_8U, new Scalar(8));
- assertMatEqual(truth, dst);
- }
-
public void testErodeMatMatMatPointIntIntScalar() {
Mat src = new Mat(3, 3, CvType.CV_8U) {
{
assertMatEqual(truth, dst, EPS);
}
- public void testFilter2DMatMatIntMatPoint() {
- Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(1));
- Point point = new Point(0, 0);
-
- Imgproc.filter2D(gray128, dst, -1, kernel, point);
-
- assertMatEqual(gray255, dst);
- }
-
public void testFilter2DMatMatIntMatPointDouble() {
fail("Not yet implemented");
}
assertEquals(contours.size(), 0);
assertEquals(contours.size(), hierarchy.total());
- Core.rectangle(img, new Point(10, 20), new Point(20, 30), new Scalar(100), 3, Core.LINE_AA);
+ Core.rectangle(img, new Point(10, 20), new Point(20, 30), new Scalar(100), 3, Core.LINE_AA, 0);
Core.rectangle(img, new Point(30, 35), new Point(40, 45), new Scalar(200));
Imgproc.findContours(img, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
List<Mat> contours2 = new ArrayList<Mat>();
Mat hierarchy = new Mat();
- Core.rectangle(img, new Point(10, 20), new Point(20, 30), new Scalar(100), 3, Core.LINE_AA);
+ Core.rectangle(img, new Point(10, 20), new Point(20, 30), new Scalar(100), 3, Core.LINE_AA, 0);
Core.rectangle(img, new Point(30, 35), new Point(40, 45), new Scalar(200));
Imgproc.findContours(img, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
assertEquals(0, Core.countNonZero(mtx));
}
- public void testGetDefaultNewCameraMatrixMatSize() {
- Mat mtx = Imgproc.getDefaultNewCameraMatrix(gray0, size);
-
- assertFalse(mtx.empty());
- assertEquals(0, Core.countNonZero(mtx));
- // TODO_: write better test
- }
-
public void testGetDefaultNewCameraMatrixMatSizeBoolean() {
Mat mtx = Imgproc.getDefaultNewCameraMatrix(gray0, size, true);
assertMatEqual(expKy, ky, EPS);
}
- public void testGetDerivKernelsMatMatIntIntIntBoolean() {
- Mat kx = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
- Mat ky = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
- Mat expKx = new Mat(3, 1, CvType.CV_32F);
- Mat expKy = new Mat(3, 1, CvType.CV_32F);
- kx.put(0, 0, 1, 1);
- kx.put(1, 0, 1, 1);
- ky.put(0, 0, 2, 2);
- ky.put(1, 0, 2, 2);
- expKx.put(0, 0, 1, -2, 1);
- expKy.put(0, 0, 1, -2, 1);
-
- Imgproc.getDerivKernels(kx, ky, 2, 2, 3, true);
-
- assertMatEqual(expKx, kx, EPS);
- assertMatEqual(expKy, ky, EPS);
- // TODO_: write better test
- }
-
public void testGetDerivKernelsMatMatIntIntIntBooleanInt() {
Mat kx = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat ky = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
assertEquals(4, lp.size());
}
- public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMat() {
- Mat src = gray128;
- Point tl = new Point(2, 2);
- Point br = new Point(8, 8);
- Scalar color = new Scalar(100);
- Core.rectangle(src, tl, br, color, -1);
- Mat mask = gray0;
- Core.circle(mask, tl, 3, color, -1);
- List<Point> lp = new ArrayList<Point>();
-
- Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, mask);
-
- assertEquals(1, lp.size());
- }
-
- public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatInt() {
- Mat src = gray0;
- Core.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1);
- List<Point> lp = new ArrayList<Point>();
-
- Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4);
-
- assertEquals(4, lp.size());
- }
-
- public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBoolean() {
- Mat src = gray0;
- Core.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1);
- List<Point> lp = new ArrayList<Point>();
-
- Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4, true);
-
- assertEquals(4, lp.size());
- }
-
public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble() {
Mat src = gray0;
Core.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1);
assertEquals(1, circles.cols());
}
- public void testHoughCirclesMatMatIntDoubleDoubleDouble() {
- int sz = 512;
- Mat img = new Mat(sz, sz, CvType.CV_8U, new Scalar(128));
- Mat circles = new Mat();
- double param1 = 50;
-
- Imgproc.HoughCircles(img, circles, Imgproc.CV_HOUGH_GRADIENT, 2, img.rows() / 4, param1);
-
- assertEquals(0, circles.cols());
- }
-
- public void testHoughCirclesMatMatIntDoubleDoubleDouble1() {
- int sz = 512;
- Mat img = new Mat(sz, sz, CvType.CV_8U, new Scalar(128));
- Mat circles = new Mat();
- double param1 = 50;
-
- Point center = new Point(img.cols() / 2, img.rows() / 2);
- int radius = Math.min(img.cols() / 4, img.rows() / 4);
- Core.circle(img, center, radius, colorBlack, 3);
-
- Imgproc.HoughCircles(img, circles, Imgproc.CV_HOUGH_GRADIENT, 2, img.rows() / 4, param1);
-
- assertEquals(1, circles.cols());
- }
-
- public void testHoughCirclesMatMatIntDoubleDoubleDoubleDouble() {
- int sz = 512;
- Mat img = new Mat(sz, sz, CvType.CV_8U, new Scalar(128));
- Mat circles = new Mat();
- double param1 = 50;
- double param2 = 100;
-
- Imgproc.HoughCircles(img, circles, Imgproc.CV_HOUGH_GRADIENT, 2, img.rows() / 4, param1, param2);
-
- assertEquals(0, circles.cols());
- }
-
- public void testHoughCirclesMatMatIntDoubleDoubleDoubleDouble1() {
- int sz = 512;
- Mat img = new Mat(sz, sz, CvType.CV_8U, new Scalar(128));
- Mat circles = new Mat();
- double param1 = 50;
- double param2 = 100;
-
- Point center = new Point(img.cols() / 2, img.rows() / 2);
- int radius = Math.min(img.cols() / 4, img.rows() / 4);
- Core.circle(img, center, radius, colorBlack, 3);
-
- Imgproc.HoughCircles(img, circles, Imgproc.CV_HOUGH_GRADIENT, 2, img.rows() / 4, param1, param2);
-
- assertEquals(1, circles.cols());
- }
-
- public void testHoughCirclesMatMatIntDoubleDoubleDoubleDoubleInt() {
- fail("Not yet implemented");
- }
-
public void testHoughCirclesMatMatIntDoubleDoubleDoubleDoubleIntInt() {
fail("Not yet implemented");
}
fail("Not yet implemented");
}
- /*
- public void testInpaint() {
- Core.circle(gray255, new Point(matSize / 2, matSize / 2), 2, colorBlack, Core.FILLED);
- Core.circle(gray0, new Point(matSize / 2, matSize / 2), 2, colorWhite, Core.FILLED);
-
- Imgproc.inpaint(gray255, gray0, dst, 3, Imgproc.INPAINT_TELEA);
-
- assertMatEqual(getMat(CvType.CV_8U, 255), dst);
- }
- */
-
public void testIntegral2MatMatMat() {
Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
Mat expSum = new Mat(4, 4, CvType.CV_64F);
assertMatEqual(gray0, dst);
}
- public void testLaplacianMatMatIntInt() {
- Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(2));
- truth = new Mat(3, 3, CvType.CV_32F, new Scalar(0));
-
- Imgproc.Laplacian(src, dst, CvType.CV_32F, 1);
-
- assertMatEqual(truth, dst, EPS);
- }
-
- public void testLaplacianMatMatIntIntDouble() {
- Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
-
- Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2);
-
- truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F) {
- {
- put(0, 0, -8, 8);
- put(1, 0, 8, -8);
- }
- };
- assertMatEqual(truth, dst, EPS);
- }
-
public void testLaplacianMatMatIntIntDoubleDouble() {
Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
// TODO_: write better test
}
- public void testMorphologyExMatMatIntMatPoint() {
- Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_8U);
- Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_8U, new Scalar(0));
- Point point = new Point(0, 0);
-
- Imgproc.morphologyEx(src, dst, Imgproc.MORPH_OPEN, kernel, point);
-
- truth = Mat.eye(imgprocSz, imgprocSz, CvType.CV_8U);
- assertMatEqual(truth, dst);
- // TODO_: write better test
- }
-
public void testMorphologyExMatMatIntMatPointInt() {
Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_8U);
// TODO_: write better test
}
- public void testMorphologyExMatMatIntMatPointIntInt() {
- Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
- src.put(0, 0, 2, 1);
- src.put(1, 0, 2, 1);
- Mat kernel = new Mat(imgprocSz, imgprocSz, CvType.CV_8U, new Scalar(1));
- Point point = new Point(1, 1);
-
- Imgproc.morphologyEx(src, dst, Imgproc.MORPH_TOPHAT, kernel, point, 10, Imgproc.BORDER_REFLECT);
-
- truth = new Mat(imgprocSz, imgprocSz, CvType.CV_8U) {
- {
- put(0, 0, 1, 0);
- put(1, 0, 1, 0);
- }
- };
- assertMatEqual(truth, dst);
- }
public void testMorphologyExMatMatIntMatPointIntIntScalar() {
Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_8U);
assertMatEqual(truth, dst, EPS);
}
- public void testRemapMatMatMatMatIntInt() {
- fail("Not yet implemented");
- // this test does something weird
- Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(2));
- Mat map1 = new Mat(1, 3, CvType.CV_32FC1);
- Mat map2 = new Mat(1, 3, CvType.CV_32FC1);
-
- map1.put(0, 0, 3, 6, 5, 0);
- map2.put(0, 0, 4, 8, 12);
-
- truth = new Mat(1, 3, CvType.CV_32F, new Scalar(2));
-
- Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR, Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst, EPS);
- }
-
public void testRemapMatMatMatMatIntIntScalar() {
fail("Not yet implemented");
// this test does something weird
assertMatEqual(truth, dst);
}
- public void testResizeMatMatSizeDouble() {
- try {
- Imgproc.resize(gray255, dst, new Size(), 0.5);
- fail("Expected CvException was not thrown");
- } catch (CvException e) {
- // expected
- }
- }
-
- public void testResizeMatMatSizeDoubleDouble() {
- Imgproc.resize(gray255, dst, new Size(), 0.5, 0.5);
-
- truth = new Mat((int) (matSize * 0.5), (int) (matSize * 0.5), CvType.CV_8U, new Scalar(255));
- assertMatEqual(truth, dst);
- }
-
public void testResizeMatMatSizeDoubleDoubleInt() {
Imgproc.resize(gray255, dst, new Size(2, 2), 0, 0, Imgproc.INTER_AREA);
assertMatEqual(truth, dst, EPS);
}
- public void testScharrMatMatIntIntIntDouble() {
- Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
-
- Imgproc.Scharr(src, dst, CvType.CV_32F, 0, 1, 1.5);
-
- truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0));
- assertMatEqual(truth, dst, EPS);
- // TODO_: write better test
- }
-
public void testScharrMatMatIntIntIntDoubleDouble() {
Mat src = Mat.eye(imgprocSz, imgprocSz, CvType.CV_32F);
assertMatEqual(truth, dst, EPS);
}
- public void testSepFilter2DMatMatIntMatMatPoint() {
- Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1, new Scalar(2));
- Mat kernelX = new Mat(1, 3, CvType.CV_32FC1);
- Mat kernelY = new Mat(1, 3, CvType.CV_32FC1);
- kernelX.put(0, 0, 2, 2, 2);
- kernelY.put(0, 0, 1, 1, 1);
-
- Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY, anchorPoint);
-
- truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(36));
- assertMatEqual(truth, dst, EPS);
- // TODO_: write better test
- }
-
public void testSepFilter2DMatMatIntMatMatPointDouble() {
Mat src = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1, new Scalar(2));
Mat kernelX = new Mat(1, 3, CvType.CV_32FC1);
assertMatEqual(gray0, dst);
}
- public void testSobelMatMatIntIntIntInt() {
- Imgproc.Sobel(gray255, dst, CvType.CV_8U, 1, 0, 3);
-
- assertMatEqual(gray0, dst);
- // TODO_: write better test
- }
-
- public void testSobelMatMatIntIntIntIntDouble() {
- Mat src = new Mat(3, 3, CvType.CV_32F) {
- {
- put(0, 0, 2, 0, 1);
- put(1, 0, 3, 0, -10);
- put(2, 0, -4, 0, 3);
- }
- };
-
- Imgproc.Sobel(src, dst, CvType.CV_32F, 1, 0, 3, 2);
-
- truth = new Mat(3, 3, CvType.CV_32F) {
- {
- put(0, 0, 0, -56, 0);
- put(1, 0, 0, -40, 0);
- put(2, 0, 0, -24, 0);
- }
- };
- assertMatEqual(truth, dst, EPS);
- }
-
public void testSobelMatMatIntIntIntIntDoubleDouble() {
Imgproc.Sobel(gray255, dst, CvType.CV_8U, 1, 0, 3, 2, 0.001);
assertMatEqual(gray0, dst);
Imgproc.cvtColor(rgbLena, greyLena, Imgproc.COLOR_RGB2GRAY);
// TODO: doesn't detect with 1.1 scale
- cc.detectMultiScale(greyLena, faces, 1.09, 3, Objdetect.CASCADE_SCALE_IMAGE, new Size(30, 30));
+ cc.detectMultiScale(greyLena, faces, 1.09, 3, Objdetect.CASCADE_SCALE_IMAGE, new Size(30, 30), new Size());
assertEquals(1, faces.size());
}
--- /dev/null
+package org.opencv.test.photo;\r
+\r
+import org.opencv.core.Core;\r
+import org.opencv.core.CvType;\r
+import org.opencv.core.Point;\r
+import org.opencv.photo.Photo;\r
+import org.opencv.test.OpenCVTestCase;\r
+\r
+public class PhotoTest extends OpenCVTestCase {\r
+\r
+ public void testInpaint() {\r
+ Point p = new Point(matSize / 2, matSize / 2);\r
+ Core.circle(gray255, p, 2, colorBlack, Core.FILLED);\r
+ Core.circle(gray0, p, 2, colorWhite, Core.FILLED);\r
+\r
+ Photo.inpaint(gray255, gray0, dst, 3, Photo.INPAINT_TELEA);\r
+\r
+ assertMatEqual(getMat(CvType.CV_8U, 255), dst);\r
+ }\r
+\r
+}\r
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSize() {
Size sz = new Size(3, 3);
- Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err, sz);
+ Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err, sz, 3);
assertEquals(0, Core.countNonZero(Converters.vector_uchar_to_Mat(status)));
}
- public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeInt() {
- fail("Not yet implemented");
- }
-
- public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteria() {
- fail("Not yet implemented");
- }
-
- public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDouble() {
- fail("Not yet implemented");
- }
-
- public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDoubleInt() {
- fail("Not yet implemented");
- }
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDoubleIntDouble() {
fail("Not yet implemented");
\r
""",\r
}, # getTextSize\r
+## "checkRange" : #TBD\r
+## {'j_code' : '/* TBD: checkRange() */', 'jn_code' : '', 'cpp_code' : '' },\r
\r
"checkHardwareSupport" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },\r
"setUseOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },\r
'getAffineTransform' : { 'src' : 'vector_Point2f', 'dst' : 'vector_Point2f', },\r
'hconcat' : { 'src' : 'vector_Mat', },\r
'vconcat' : { 'src' : 'vector_Mat', },\r
- 'undistortPoints' : { 'src' : 'vector_Point2d', 'dst' : 'vector_Point2d' }\r
+ 'undistortPoints' : { 'src' : 'vector_Point2d', 'dst' : 'vector_Point2d' },\r
+ 'checkRange' : {'pos' : '*'},\r
+ #'meanStdDev' : {'mean' : 'Scalar', 'stddev' : 'Scalar'},\r
}, # '', i.e. no class\r
} # func_arg_fix\r
\r
else:\r
decl_args = []\r
for a in fi.args:\r
- s = a.ctype\r
+ s = a.ctype or ' _hidden_ '\r
if a.pointer:\r
s += "*"\r
elif a.out:\r
jni_args.append( ArgInfo([ "__int64", "self", "", [], "" ]) )\r
self.get_imports(fi.classname, fi.ctype)\r
for a in args:\r
+ if not a.ctype: # hidden\r
+ continue\r
self.get_imports(fi.classname, a.ctype)\r
if "vector" in a.ctype: # pass as Mat\r
jn_args.append ( ArgInfo([ "__int64", "%s_mat.nativeObj" % a.name, "", [], "" ]) )\r
\r
j_args = []\r
for a in args:\r
+ if not a.ctype: #hidden\r
+ continue\r
jt = type_dict[a.ctype]["j_type"]\r
if a.out and a.ctype in ('bool', 'int', 'long', 'float', 'double'):\r
jt += '[]'\r
jni_name = "&%(n)s"\r
else:\r
jni_name = "%(n)s"\r
+ if not a.ctype: # hidden\r
+ jni_name = a.defval\r
cvargs.append( type_dict[a.ctype].get("jni_name", jni_name) % {"n" : a.name})\r
if "vector" not in a.ctype :\r
if ("I" in a.out or not a.out or a.ctype in self.classes) and "jni_var" in type_dict[a.ctype]: # complex type\r
c_prologue.append(type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";")\r
- if a.out and "I" not in a.out and a.ctype not in self.classes:\r
+ if a.out and "I" not in a.out and a.ctype not in self.classes and a.ctype:\r
c_prologue.append("%s %s;" % (a.ctype, a.name))\r
\r
rtype = type_dict[fi.ctype].get("jni_type", "jdoubleArray")\r
epilogue = " ".join(c_epilogue), \\r
ret = ret, \\r
cvname = cvname, \\r
- cvargs = ", ".join([a for a in cvargs]), \\r
+ cvargs = ", ".join(cvargs), \\r
default = default, \\r
retval = retval, \\r
) )\r
\r
# processing args with default values\r
- if args and args[-1].defval:\r
- a = args.pop()\r
- else:\r
+ if not args or not args[-1].defval:\r
break\r
+ while args and args[-1].defval:\r
+ # 'smart' overloads filtering\r
+ a = args.pop()\r
+ if a.name in ('mask', 'dtype', 'ddepth', 'lineType', 'borderType', 'borderMode', 'criteria'):\r
+ break\r
\r
\r
\r
import os, sys, re, string, glob
-allmodules = ["core", "flann", "imgproc", "ml", "highgui", "video", "features2d", "calib3d", "objdetect", "legacy", "contrib", "gpu", "androidcamera", "haartraining", "java", "python", "stitching", "traincascade", "ts"]
+allmodules = ["core", "flann", "imgproc", "ml", "highgui", "video", "features2d", "calib3d", "objdetect", "legacy", "contrib", "gpu", "androidcamera", "haartraining", "java", "python", "stitching", "traincascade", "ts", "photo"]
verbose = False
show_warnings = True
show_errors = True
import os, sys, re, string, glob
-allmodules = ["core", "flann", "imgproc", "ml", "highgui", "video", "features2d", "calib3d", "objdetect", "legacy", "contrib", "gpu", "androidcamera", "haartraining", "java", "python", "stitching", "traincascade", "ts"]
+allmodules = ["core", "flann", "imgproc", "ml", "highgui", "video", "features2d", "calib3d", "objdetect", "legacy", "contrib", "gpu", "androidcamera", "haartraining", "java", "python", "stitching", "traincascade", "ts", "photo"]
verbose = False
show_warnings = True
show_errors = True