diff --git a/doc/tutorials/introduction/desktop_java/java_dev_intro.rst b/doc/tutorials/introduction/desktop_java/java_dev_intro.rst index 513f39d10..b67ea0313 100644 --- a/doc/tutorials/introduction/desktop_java/java_dev_intro.rst +++ b/doc/tutorials/introduction/desktop_java/java_dev_intro.rst @@ -398,7 +398,7 @@ Now modify src/main/java/HelloOpenCV.java so it contains the following Java code // Draw a bounding box around each face. for (Rect rect : faceDetections.toArray()) { - Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); + Imgproc.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); } // Save the visualized detection. diff --git a/modules/core/doc/core.rst b/modules/core/doc/core.rst index ec4e29c24..c7a200530 100644 --- a/modules/core/doc/core.rst +++ b/modules/core/doc/core.rst @@ -10,7 +10,6 @@ core. The Core Functionality old_basic_structures dynamic_structures operations_on_arrays - drawing_functions xml_yaml_persistence old_xml_yaml_persistence clustering diff --git a/modules/java/android_test/src/org/opencv/test/core/CoreTest.java b/modules/java/android_test/src/org/opencv/test/core/CoreTest.java index c13df193e..b94edc0e1 100644 --- a/modules/java/android_test/src/org/opencv/test/core/CoreTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/CoreTest.java @@ -209,69 +209,6 @@ public class CoreTest extends OpenCVTestCase { 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); - Scalar color = new Scalar(128); - - Core.circle(gray0, center, radius, color); - - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testCircleMatPointIntScalarInt() { - 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, Core.FILLED); - - 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()); - int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); - Scalar color128 = new Scalar(128); - Scalar color0 = new Scalar(0); - - Core.circle(gray0, center2, radius * 2, color128, 2, Core.LINE_4, 1/* - * Number - * of - * fractional - * bits - */); - assertFalse(0 == Core.countNonZero(gray0)); - - Core.circle(gray0, center, radius, color0, 2, Core.LINE_4, 0); - - assertTrue(0 == Core.countNonZero(gray0)); - } - - public void testClipLine() { - Rect r = new Rect(10, 10, 10, 10); - Point pt1 = new Point(5.0, 15.0); - Point pt2 = new Point(25.0, 15.0); - - assertTrue(Core.clipLine(r, pt1, pt2)); - - Point pt1Clipped = new Point(10.0, 15.0); - Point pt2Clipped = new Point(19.0, 15.0); - assertEquals(pt1Clipped, pt1); - assertEquals(pt2Clipped, pt2); - - pt1 = new Point(5.0, 5.0); - pt2 = new Point(25.0, 5.0); - pt1Clipped = new Point(5.0, 5.0); - pt2Clipped = new Point(25.0, 5.0); - - assertFalse(Core.clipLine(r, pt1, pt2)); - - assertEquals(pt1Clipped, pt1); - assertEquals(pt2Clipped, pt2); - } - public void testCompare() { Core.compare(gray0, gray0, dst, Core.CMP_EQ); @@ -478,110 +415,6 @@ public class CoreTest extends OpenCVTestCase { assertMatEqual(eigenVecs, expectedEigenVecs, EPS); } - public void testEllipse2Poly() { - Point center = new Point(4, 4); - Size axes = new Size(2, 2); - int angle = 30; - int arcStart = 30; - int arcEnd = 60; - int delta = 2; - MatOfPoint pts = new MatOfPoint(); - - Core.ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta, pts); - - Point truth[] = { - new Point(5, 6), - new Point(4, 6) - }; - assertArrayPointsEquals(truth, pts.toArray(), EPS); - } - - public void testEllipseMatPointSizeDoubleDoubleDoubleScalar() { - Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); - Size axes = new Size(2, 2); - double angle = 30, startAngle = 60, endAngle = 90; - - Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite); - - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testEllipseMatPointSizeDoubleDoubleDoubleScalarInt() { - Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); - Size axes = new Size(2, 2); - double angle = 30, startAngle = 60, endAngle = 90; - - Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED); - - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntIntInt() { - Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); - Size axes = new Size(2, 2); - Point center2 = new Point(gray0.cols(), gray0.rows()); - Size axes2 = new Size(4, 4); - double angle = 30, startAngle = 0, endAngle = 30; - - Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED, Core.LINE_4, 0); - - assertTrue(0 != Core.countNonZero(gray0)); - - Core.ellipse(gray0, center2, axes2, angle, startAngle, endAngle, colorBlack, Core.FILLED, Core.LINE_4, 1); - - assertEquals(0, Core.countNonZero(gray0)); - } - - public void testEllipseMatRotatedRectScalar() { - int matSize = 10; - Mat gray0 = Mat.zeros(matSize, matSize, CvType.CV_8U); - Point center = new Point(matSize / 2, matSize / 2); - Size size = new Size(matSize / 4, matSize / 2); - RotatedRect box = new RotatedRect(center, size, 45); - - Core.ellipse(gray0, box, new Scalar(1)); - - final byte[] truth = new byte[] { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, - 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, - 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - assertMatEqual(new Mat(matSize, matSize, CvType.CV_8U) { - { - put(0, 0, truth); - } - }, gray0); - } - - public void testEllipseMatRotatedRectScalarInt() { - Point center = new Point(matSize / 2, matSize / 2); - Size size = new Size(matSize / 4, matSize / 2); - RotatedRect box = new RotatedRect(center, size, 45); - - Core.ellipse(gray0, box, new Scalar(1), Core.FILLED); - Core.ellipse(gray0, box, new Scalar(0)); - - assertTrue(0 < Core.countNonZero(gray0)); - } - - public void testEllipseMatRotatedRectScalarIntInt() { - Point center = new Point(matSize / 2, matSize / 2); - Size size = new Size(2, matSize * 2 / 3); - RotatedRect box = new RotatedRect(center, size, 20); - - Core.ellipse(gray0, box, new Scalar(9), 1, Core.LINE_AA); - Core.ellipse(gray0, box, new Scalar(0), 1, Core.LINE_4); - - assertTrue(0 < Core.countNonZero(gray0)); - } - public void testExp() { Core.exp(gray0_32f, dst); @@ -609,7 +442,7 @@ public class CoreTest extends OpenCVTestCase { public void testFillConvexPolyMatListOfPointScalar() { MatOfPoint polyline = new MatOfPoint(new Point[]{new Point(1, 1), new Point(5, 0), new Point(6, 8), new Point(0, 9)}); - Core.fillConvexPoly(gray0, polyline, new Scalar(150)); + Imgproc.fillConvexPoly(gray0, polyline, new Scalar(150)); assertTrue(0 < Core.countNonZero(gray0)); assertTrue(gray0.total() > Core.countNonZero(gray0)); @@ -622,12 +455,12 @@ public class CoreTest extends OpenCVTestCase { // current implementation of fixed-point version of fillConvexPoly // requires image to be at least 2-pixel wider in each direction than // contour - Core.fillConvexPoly(gray0, polyline1, colorWhite, Core.LINE_8, 0); + Imgproc.fillConvexPoly(gray0, polyline1, colorWhite, Imgproc.line_8, 0); assertTrue(0 < Core.countNonZero(gray0)); assertTrue(gray0.total() > Core.countNonZero(gray0)); - Core.fillConvexPoly(gray0, polyline2, colorBlack, Core.LINE_8, 1); + Imgproc.fillConvexPoly(gray0, polyline2, colorBlack, Imgproc.line_8, 1); assertEquals("see http://code.opencv.org/issues/1284", 0, Core.countNonZero(gray0)); } @@ -639,7 +472,7 @@ public class CoreTest extends OpenCVTestCase { List polylines = new ArrayList(); polylines.add(polyline); - Core.fillPoly(gray0, polylines, new Scalar(1)); + Imgproc.fillPoly(gray0, polylines, new Scalar(1)); final byte[] truth = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -670,11 +503,11 @@ public class CoreTest extends OpenCVTestCase { List polylines2 = new ArrayList(); polylines2.add(polyline2); - Core.fillPoly(gray0, polylines1, new Scalar(1), Core.LINE_8, 0, new Point(0, 0)); + Imgproc.fillPoly(gray0, polylines1, new Scalar(1), Imgproc.line_8, 0, new Point(0, 0)); assertTrue(0 < Core.countNonZero(gray0)); - Core.fillPoly(gray0, polylines2, new Scalar(0), Core.LINE_8, 0, new Point(1, 1)); + Imgproc.fillPoly(gray0, polylines2, new Scalar(0), Imgproc.line_8, 0, new Point(1, 1)); assertEquals(0, Core.countNonZero(gray0)); } @@ -799,20 +632,6 @@ public class CoreTest extends OpenCVTestCase { assertEquals(15, Core.getOptimalDFTSize(13)); } - public void testGetTextSize() { - String text = "Android all the way"; - double fontScale = 2; - int thickness = 3; - int baseLine[] = new int[1]; - - Core.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, null); - Size res = Core.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, baseLine); - - assertEquals(543.0, res.width); - assertEquals(44.0, res.height); - assertEquals(20, baseLine[0]); - } - public void testGetTickCount() { long startCount, endCount, count; @@ -1036,7 +855,7 @@ public class CoreTest extends OpenCVTestCase { Point point2 = new Point(nPoints, nPoints); Scalar color = new Scalar(255); - Core.line(gray0, point1, point2, color); + Imgproc.line(gray0, point1, point2, color); assertTrue(nPoints == Core.countNonZero(gray0)); } @@ -1046,7 +865,7 @@ public class CoreTest extends OpenCVTestCase { Point point1 = new Point(0, 0); Point point2 = new Point(nPoints, nPoints); - Core.line(gray0, point1, point2, colorWhite, 0); + Imgproc.line(gray0, point1, point2, colorWhite, 0); assertTrue(nPoints == Core.countNonZero(gray0)); } @@ -1058,11 +877,11 @@ public class CoreTest extends OpenCVTestCase { Point point1_4 = new Point(3 * 4, 4 * 4); Point point2_4 = new Point(nPoints * 4, nPoints * 4); - Core.line(gray0, point2, point1, colorWhite, 2, Core.LINE_8, 0); + Imgproc.line(gray0, point2, point1, colorWhite, 2, Imgproc.line_8, 0); assertFalse(0 == Core.countNonZero(gray0)); - Core.line(gray0, point2_4, point1_4, colorBlack, 2, Core.LINE_8, 2); + Imgproc.line(gray0, point2_4, point1_4, colorBlack, 2, Imgproc.line_8, 2); assertEquals(0, Core.countNonZero(gray0)); } @@ -1717,95 +1536,12 @@ public class CoreTest extends OpenCVTestCase { assertMatEqual(y, yCoordinate, EPS); } - public void testPolylinesMatListOfListOfPointBooleanScalar() { - Mat img = gray0; - List polyline = new ArrayList(); - polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6))); - - Core.polylines(img, polyline, true, new Scalar(100)); - - assertEquals(22, Core.countNonZero(img)); - - Core.polylines(img, polyline, false, new Scalar(0)); - - assertEquals(4, Core.countNonZero(img)); - } - - public void testPolylinesMatListOfListOfPointBooleanScalarInt() { - Mat img = gray0; - List polyline = new ArrayList(); - polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6))); - - Core.polylines(img, polyline, true, new Scalar(100), 2); - - assertEquals(62, Core.countNonZero(img)); - } - - public void testPolylinesMatListOfListOfPointBooleanScalarIntIntInt() { - Mat img = gray0; - List polyline1 = new ArrayList(); - polyline1.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6))); - List polyline2 = new ArrayList(); - polyline2.add(new MatOfPoint(new Point(2, 2), new Point(14, 2), new Point(14, 12), new Point(2, 12))); - - Core.polylines(img, polyline1, true, new Scalar(100), 2, Core.LINE_8, 0); - - assertTrue(Core.countNonZero(img) > 0); - - Core.polylines(img, polyline2, true, new Scalar(0), 2, Core.LINE_8, 1); - - assertEquals(0, Core.countNonZero(img)); - } - public void testPow() { Core.pow(gray2, 7, dst); assertMatEqual(gray128, dst); } - public void testPutTextMatStringPointIntDoubleScalar() { - 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); - - assertTrue(Core.countNonZero(img) > 0); - // check that border is not corrupted - Core.rectangle(img, new Point(11, 11), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Core.FILLED); - assertEquals(0, Core.countNonZero(img)); - } - - public void testPutTextMatStringPointIntDoubleScalarInt() { - String text = "Hello World"; - Size labelSize = new Size(176, 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, 2); - - assertTrue(Core.countNonZero(img) > 0); - // check that border is not corrupted - Core.rectangle(img, new Point(10, 10), new Point(labelSize.width + 10 + 1, labelSize.height + 10 + 1), colorBlack, Core.FILLED); - assertEquals(0, Core.countNonZero(img)); - } - - public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() { - 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, 10); - - Core.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 1, Core.LINE_8, true); - - assertTrue(Core.countNonZero(img) > 0); - // check that border is not corrupted - Core.rectangle(img, new Point(10, 10), new Point(labelSize.width + 9, labelSize.height + 9), colorBlack, Core.FILLED); - assertEquals(0, Core.countNonZero(img)); - } - public void testRandn() { Core.randn(gray0, 100, 23); @@ -1859,7 +1595,7 @@ public class CoreTest extends OpenCVTestCase { Point topLeft = new Point(0, 0); Scalar color = new Scalar(128); - Core.rectangle(gray0, bottomRight, topLeft, color); + Imgproc.rectangle(gray0, bottomRight, topLeft, color); assertTrue(0 != Core.countNonZero(gray0)); } @@ -1869,8 +1605,8 @@ public class CoreTest extends OpenCVTestCase { Point topLeft = new Point(0, 0); Scalar color = new Scalar(128); - Core.rectangle(gray0, bottomRight, topLeft, color, 2); - Core.rectangle(gray0, bottomRight, topLeft, colorBlack); + Imgproc.rectangle(gray0, bottomRight, topLeft, color, 2); + Imgproc.rectangle(gray0, bottomRight, topLeft, colorBlack); assertTrue(0 != Core.countNonZero(gray0)); } @@ -1880,8 +1616,8 @@ public class CoreTest extends OpenCVTestCase { Point topLeft = new Point(0, 0); Scalar color = new Scalar(128); - Core.rectangle(gray0, bottomRight, topLeft, color, 2, Core.LINE_AA, 0); - Core.rectangle(gray0, bottomRight, topLeft, colorBlack, 2, Core.LINE_4, 0); + Imgproc.rectangle(gray0, bottomRight, topLeft, color, 2, Imgproc.line_AA, 0); + Imgproc.rectangle(gray0, bottomRight, topLeft, colorBlack, 2, Imgproc.line_4, 0); assertTrue(0 != Core.countNonZero(gray0)); } @@ -1892,11 +1628,11 @@ public class CoreTest extends OpenCVTestCase { Point topLeft = new Point(0, 0); Scalar color = new Scalar(128); - Core.rectangle(gray0, bottomRight1, topLeft, color, 2, Core.LINE_8, 1); + Imgproc.rectangle(gray0, bottomRight1, topLeft, color, 2, Imgproc.line_8, 1); assertTrue(0 != Core.countNonZero(gray0)); - Core.rectangle(gray0, bottomRight2, topLeft, colorBlack, 2, Core.LINE_8, 0); + Imgproc.rectangle(gray0, bottomRight2, topLeft, colorBlack, 2, Imgproc.line_8, 0); assertEquals(0, Core.countNonZero(gray0)); } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java index 060175234..f3e5c6562 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BRIEFDescriptorExtractorTest.java @@ -18,8 +18,8 @@ public class BRIEFDescriptorExtractorTest extends OpenCVTestCase { private Mat getTestImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java index ae8645e48..92290a68e 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceDescriptorMatcherTest.java @@ -53,8 +53,8 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { private Mat getQueryImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); - Core.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); + Imgproc.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); + Imgproc.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); return cross; } @@ -73,8 +73,8 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase { private Mat getTrainImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java index 5ed99df82..f33a7acf5 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingDescriptorMatcherTest.java @@ -38,7 +38,7 @@ public class BruteForceHammingDescriptorMatcherTest extends OpenCVTestCase { private Mat getQueryImg() { Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(img, new Point(40, matSize - 40), new Point(matSize - 50, 50), new Scalar(0), 8); + Imgproc.line(img, new Point(40, matSize - 40), new Point(matSize - 50, 50), new Scalar(0), 8); return img; } @@ -61,7 +61,7 @@ public class BruteForceHammingDescriptorMatcherTest extends OpenCVTestCase { private Mat getTrainImg() { Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(img, new Point(40, 40), new Point(matSize - 40, matSize - 40), new Scalar(0), 8); + Imgproc.line(img, new Point(40, 40), new Point(matSize - 40, matSize - 40), new Scalar(0), 8); return img; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java index 961d93605..f4d9437ba 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceHammingLUTDescriptorMatcherTest.java @@ -37,7 +37,7 @@ public class BruteForceHammingLUTDescriptorMatcherTest extends OpenCVTestCase { private Mat getQueryImg() { Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(img, new Point(40, matSize - 40), new Point(matSize - 50, 50), new Scalar(0), 8); + Imgproc.line(img, new Point(40, matSize - 40), new Point(matSize - 50, 50), new Scalar(0), 8); return img; } @@ -60,7 +60,7 @@ public class BruteForceHammingLUTDescriptorMatcherTest extends OpenCVTestCase { private Mat getTrainImg() { Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(img, new Point(40, 40), new Point(matSize - 40, matSize - 40), new Scalar(0), 8); + Imgproc.line(img, new Point(40, 40), new Point(matSize - 40, matSize - 40), new Scalar(0), 8); return img; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java index 485f9686e..7e9b7223c 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceL1DescriptorMatcherTest.java @@ -53,8 +53,8 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase { private Mat getQueryImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); - Core.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); + Imgproc.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); + Imgproc.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); return cross; } @@ -73,8 +73,8 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase { private Mat getTrainImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java index c19d1d5f5..e0361b145 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/BruteForceSL2DescriptorMatcherTest.java @@ -58,8 +58,8 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase { private Mat getQueryImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); - Core.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); + Imgproc.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); + Imgproc.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); return cross; } @@ -78,8 +78,8 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase { private Mat getTrainImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java index df123d2a1..9e273e39f 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/FASTFeatureDetectorTest.java @@ -27,7 +27,7 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase { private Mat getTestImg() { Mat img = new Mat(100, 100, CvType.CV_8U, new Scalar(255)); - Core.line(img, new Point(30, 30), new Point(70, 70), new Scalar(0), 8); + Imgproc.line(img, new Point(30, 30), new Point(70, 70), new Scalar(0), 8); return img; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java b/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java index 823947369..e6d6a412f 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/FlannBasedDescriptorMatcherTest.java @@ -127,8 +127,8 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase { private Mat getQueryImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); - Core.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); + Imgproc.line(cross, new Point(30, matSize / 2), new Point(matSize - 31, matSize / 2), new Scalar(100), 3); + Imgproc.line(cross, new Point(matSize / 2, 30), new Point(matSize / 2, matSize - 31), new Scalar(100), 3); return cross; } @@ -147,8 +147,8 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase { private Mat getTrainImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java index 2a14dd99a..be974b36b 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java @@ -23,8 +23,8 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase { private Mat getTestImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java index c793a6c3b..fd81aa4ab 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java @@ -20,8 +20,8 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase { private Mat getTestImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java index 6d63e36d5..96c61c951 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SURFDescriptorExtractorTest.java @@ -18,8 +18,8 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase { private Mat getTestImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java b/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java index b3c59b016..576ea4589 100644 --- a/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java +++ b/modules/java/android_test/src/org/opencv/test/features2d/SURFFeatureDetectorTest.java @@ -32,8 +32,8 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase { private Mat getTestImg() { Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); - Core.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); - Core.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); + Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2); + Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2); return cross; } diff --git a/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java b/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java index 15ea13b16..22d96ef85 100644 --- a/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java +++ b/modules/java/android_test/src/org/opencv/test/imgproc/ImgprocTest.java @@ -584,7 +584,7 @@ public class ImgprocTest extends OpenCVTestCase { Point truthPosition = new Point(img.cols() / 2, img.rows() / 2); Rect r = new Rect(new Point(0, 0), truthPosition); - Core.rectangle(img, r.tl(), r.br(), new Scalar(0), Core.FILLED); + Imgproc.rectangle(img, r.tl(), r.br(), new Scalar(0), Core.FILLED); MatOfPoint2f corners = new MatOfPoint2f(new Point(truthPosition.x + 1, truthPosition.y + 1)); Size winSize = new Size(2, 2); Size zeroZone = new Size(-1, -1); @@ -643,7 +643,7 @@ public class ImgprocTest extends OpenCVTestCase { } public void testDrawContoursMatListOfMatIntScalar() { - Core.rectangle(gray0, new Point(1, 2), new Point(7, 8), new Scalar(100)); + Imgproc.rectangle(gray0, new Point(1, 2), new Point(7, 8), new Scalar(100)); List contours = new ArrayList(); Imgproc.findContours(gray0, contours, new Mat(), Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); @@ -653,7 +653,7 @@ public class ImgprocTest extends OpenCVTestCase { } public void testDrawContoursMatListOfMatIntScalarInt() { - Core.rectangle(gray0, new Point(1, 2), new Point(7, 8), new Scalar(100)); + Imgproc.rectangle(gray0, new Point(1, 2), new Point(7, 8), new Scalar(100)); List contours = new ArrayList(); Imgproc.findContours(gray0, contours, new Mat(), Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); @@ -758,8 +758,8 @@ public class ImgprocTest extends OpenCVTestCase { 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, 0); - Core.rectangle(img, new Point(30, 35), new Point(40, 45), new Scalar(200)); + Imgproc.rectangle(img, new Point(10, 20), new Point(20, 30), new Scalar(100), 3, Imgproc.line_AA, 0); + Imgproc.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); @@ -775,8 +775,8 @@ public class ImgprocTest extends OpenCVTestCase { List contours2 = new ArrayList(); Mat hierarchy = new Mat(); - 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.rectangle(img, new Point(10, 20), new Point(20, 30), new Scalar(100), 3, Imgproc.line_AA, 0); + Imgproc.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); Imgproc.findContours(img2, contours2, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE, new Point(3, 5)); @@ -1020,7 +1020,7 @@ public class ImgprocTest extends OpenCVTestCase { public void testGoodFeaturesToTrackMatListOfPointIntDoubleDouble() { Mat src = gray0; - Core.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); + Imgproc.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); MatOfPoint lp = new MatOfPoint(); Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3); @@ -1030,7 +1030,7 @@ public class ImgprocTest extends OpenCVTestCase { public void testGoodFeaturesToTrackMatListOfPointIntDoubleDoubleMatIntBooleanDouble() { Mat src = gray0; - Core.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); + Imgproc.rectangle(src, new Point(2, 2), new Point(8, 8), new Scalar(100), -1); MatOfPoint lp = new MatOfPoint(); Imgproc.goodFeaturesToTrack(src, lp, 100, 0.01, 3, gray1, 4, true, 0); @@ -1079,7 +1079,7 @@ public class ImgprocTest extends OpenCVTestCase { Mat img = new Mat(sz, sz, CvType.CV_8U, new Scalar(0)); Point point1 = new Point(50, 50); Point point2 = new Point(img.cols() / 2, img.rows() / 2); - Core.line(img, point1, point2, colorWhite, 1); + Imgproc.line(img, point1, point2, colorWhite, 1); Mat lines = new Mat(); Imgproc.HoughLines(img, lines, 1, 3.1415926/180, 100); @@ -1110,8 +1110,8 @@ public class ImgprocTest extends OpenCVTestCase { Point point2 = new Point(sz, sz); Point point3 = new Point(sz, 0); Point point4 = new Point(2*sz/3, sz/3); - Core.line(img, point1, point2, Scalar.all(255), 1); - Core.line(img, point3, point4, Scalar.all(255), 1); + Imgproc.line(img, point1, point2, Scalar.all(255), 1); + Imgproc.line(img, point3, point4, Scalar.all(255), 1); Mat lines = new Mat(); Imgproc.HoughLinesP(img, lines, 1, 3.1415926/180, 100); @@ -1931,5 +1931,268 @@ public class ImgprocTest extends OpenCVTestCase { }; assertMatEqual(truth, markers); } + + public void testGetTextSize() { + String text = "Android all the way"; + double fontScale = 2; + int thickness = 3; + int baseLine[] = new int[1]; + Imgproc.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, null); + Size res = Imgproc.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, baseLine); + + assertEquals(543.0, res.width); + assertEquals(44.0, res.height); + assertEquals(20, baseLine[0]); + } + + public void testCircleMatPointIntScalar() { + 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); + + Imgproc.circle(gray0, center, radius, color); + + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testCircleMatPointIntScalarInt() { + 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); + + Imgproc.circle(gray0, center, radius, color, Core.FILLED); + + 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()); + int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); + Scalar color128 = new Scalar(128); + Scalar color0 = new Scalar(0); + + Imgproc.circle(gray0, center2, radius * 2, color128, 2, Imgproc.line_4, 1/* + * Number + * of + * fractional + * bits + */); + assertFalse(0 == Core.countNonZero(gray0)); + + Imgproc.circle(gray0, center, radius, color0, 2, Imgproc.line_4, 0); + + assertTrue(0 == Core.countNonZero(gray0)); + } + + public void testClipLine() { + Rect r = new Rect(10, 10, 10, 10); + Point pt1 = new Point(5.0, 15.0); + Point pt2 = new Point(25.0, 15.0); + + assertTrue(Core.clipLine(r, pt1, pt2)); + + Point pt1Clipped = new Point(10.0, 15.0); + Point pt2Clipped = new Point(19.0, 15.0); + assertEquals(pt1Clipped, pt1); + assertEquals(pt2Clipped, pt2); + + pt1 = new Point(5.0, 5.0); + pt2 = new Point(25.0, 5.0); + pt1Clipped = new Point(5.0, 5.0); + pt2Clipped = new Point(25.0, 5.0); + + assertFalse(Core.clipLine(r, pt1, pt2)); + + assertEquals(pt1Clipped, pt1); + assertEquals(pt2Clipped, pt2); + } + + public void testEllipse2Poly() { + Point center = new Point(4, 4); + Size axes = new Size(2, 2); + int angle = 30; + int arcStart = 30; + int arcEnd = 60; + int delta = 2; + MatOfPoint pts = new MatOfPoint(); + + Imgproc.ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta, pts); + + Point truth[] = { + new Point(5, 6), + new Point(4, 6) + }; + assertArrayPointsEquals(truth, pts.toArray(), EPS); + } + + public void testEllipseMatPointSizeDoubleDoubleDoubleScalar() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + Size axes = new Size(2, 2); + double angle = 30, startAngle = 60, endAngle = 90; + + Imgproc.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite); + + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testEllipseMatPointSizeDoubleDoubleDoubleScalarInt() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + Size axes = new Size(2, 2); + double angle = 30, startAngle = 60, endAngle = 90; + + Imgproc.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED); + + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntIntInt() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + Size axes = new Size(2, 2); + Point center2 = new Point(gray0.cols(), gray0.rows()); + Size axes2 = new Size(4, 4); + double angle = 30, startAngle = 0, endAngle = 30; + + Imgproc.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED, Imgproc.line_4, 0); + + assertTrue(0 != Core.countNonZero(gray0)); + + Imgproc.ellipse(gray0, center2, axes2, angle, startAngle, endAngle, colorBlack, Core.FILLED, Imgproc.line_4, 1); + + assertEquals(0, Core.countNonZero(gray0)); + } + + public void testEllipseMatRotatedRectScalar() { + int matSize = 10; + Mat gray0 = Mat.zeros(matSize, matSize, CvType.CV_8U); + Point center = new Point(matSize / 2, matSize / 2); + Size size = new Size(matSize / 4, matSize / 2); + RotatedRect box = new RotatedRect(center, size, 45); + + Imgproc.ellipse(gray0, box, new Scalar(1)); + + final byte[] truth = new byte[] { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, + 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + assertMatEqual(new Mat(matSize, matSize, CvType.CV_8U) { + { + put(0, 0, truth); + } + }, gray0); + } + + public void testEllipseMatRotatedRectScalarInt() { + Point center = new Point(matSize / 2, matSize / 2); + Size size = new Size(matSize / 4, matSize / 2); + RotatedRect box = new RotatedRect(center, size, 45); + + Imgproc.ellipse(gray0, box, new Scalar(1), Core.FILLED); + Imgproc.ellipse(gray0, box, new Scalar(0)); + + assertTrue(0 < Core.countNonZero(gray0)); + } + + public void testEllipseMatRotatedRectScalarIntInt() { + Point center = new Point(matSize / 2, matSize / 2); + Size size = new Size(2, matSize * 2 / 3); + RotatedRect box = new RotatedRect(center, size, 20); + + Imgproc.ellipse(gray0, box, new Scalar(9), 1, Imgproc.line_AA); + Imgproc.ellipse(gray0, box, new Scalar(0), 1, Imgproc.line_4); + + assertTrue(0 < Core.countNonZero(gray0)); + } + + public void testPolylinesMatListOfListOfPointBooleanScalar() { + Mat img = gray0; + List polyline = new ArrayList(); + polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6))); + + Imgproc.polylines(img, polyline, true, new Scalar(100)); + + assertEquals(22, Core.countNonZero(img)); + + Imgproc.polylines(img, polyline, false, new Scalar(0)); + + assertEquals(4, Core.countNonZero(img)); + } + + public void testPolylinesMatListOfListOfPointBooleanScalarInt() { + Mat img = gray0; + List polyline = new ArrayList(); + polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6))); + + Imgproc.polylines(img, polyline, true, new Scalar(100), 2); + + assertEquals(62, Core.countNonZero(img)); + } + + public void testPolylinesMatListOfListOfPointBooleanScalarIntIntInt() { + Mat img = gray0; + List polyline1 = new ArrayList(); + polyline1.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6))); + List polyline2 = new ArrayList(); + polyline2.add(new MatOfPoint(new Point(2, 2), new Point(14, 2), new Point(14, 12), new Point(2, 12))); + + Imgproc.polylines(img, polyline1, true, new Scalar(100), 2, Imgproc.line_8, 0); + + assertTrue(Core.countNonZero(img) > 0); + + Imgproc.polylines(img, polyline2, true, new Scalar(0), 2, Imgproc.line_8, 1); + + assertEquals(0, Core.countNonZero(img)); + } + + public void testPutTextMatStringPointIntDoubleScalar() { + 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); + + Imgproc.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite); + + assertTrue(Core.countNonZero(img) > 0); + // check that border is not corrupted + Imgproc.rectangle(img, new Point(11, 11), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Core.FILLED); + assertEquals(0, Core.countNonZero(img)); + } + + public void testPutTextMatStringPointIntDoubleScalarInt() { + String text = "Hello World"; + Size labelSize = new Size(176, 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); + + Imgproc.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 2); + + assertTrue(Core.countNonZero(img) > 0); + // check that border is not corrupted + Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 10 + 1, labelSize.height + 10 + 1), colorBlack, Core.FILLED); + assertEquals(0, Core.countNonZero(img)); + } + + public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() { + 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, 10); + + Imgproc.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 1, Imgproc.line_8, true); + + assertTrue(Core.countNonZero(img) > 0); + // check that border is not corrupted + Imgproc.rectangle(img, new Point(10, 10), new Point(labelSize.width + 9, labelSize.height + 9), colorBlack, Core.FILLED); + assertEquals(0, Core.countNonZero(img)); + } } diff --git a/modules/java/android_test/src/org/opencv/test/video/BackgroundSubtractorMOGTest.java b/modules/java/android_test/src/org/opencv/test/video/BackgroundSubtractorMOGTest.java index 198d06508..9d6f71d1a 100644 --- a/modules/java/android_test/src/org/opencv/test/video/BackgroundSubtractorMOGTest.java +++ b/modules/java/android_test/src/org/opencv/test/video/BackgroundSubtractorMOGTest.java @@ -14,12 +14,12 @@ public class BackgroundSubtractorMOGTest extends OpenCVTestCase { Scalar color = new Scalar(128); Mat mask = new Mat(rgbLena.size(), CvType.CV_16UC3, new Scalar(1)); - Core.rectangle(rgbLena, bottomRight, topLeft, color, Core.FILLED); + Imgproc.rectangle(rgbLena, bottomRight, topLeft, color, Core.FILLED); backGroundSubtract.apply(rgbLena, mask); Mat truth = new Mat(rgbLena.size(), rgbLena.type(), new Scalar(0)); - Core.rectangle(truth, bottomRight, topLeft, color, Core.FILLED); + Imgproc.rectangle(truth, bottomRight, topLeft, color, Core.FILLED); assertMatEqual(truth, rgbLena); */ } diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 0f317d524..41c3f75af 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -415,10 +415,22 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual """, }, # minMaxLoc + +## "checkRange" : #TBD +## {'j_code' : '/* TBD: checkRange() */', 'jn_code' : '', 'cpp_code' : '' }, + + "checkHardwareSupport" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' }, + "setUseOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' }, + "useOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' }, + + }, # Core + + 'Imgproc' : + { 'getTextSize' : { 'j_code' : -""" + """ // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine); //javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine) public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) { @@ -427,17 +439,17 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual Size retVal = new Size(n_getTextSize(text, fontFace, fontScale, thickness, baseLine)); return retVal; } -""", + """, 'jn_code' : -""" private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""", + """ private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""", 'cpp_code' : -""" -// C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine); -JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray); + """ + // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine); + JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray); -JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize - (JNIEnv* env, jclass, jstring text, jint fontFace, jdouble fontScale, jint thickness, jintArray baseLine) -{ + JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize + (JNIEnv* env, jclass, jstring text, jint fontFace, jdouble fontScale, jint thickness, jintArray baseLine) + { try { LOGD("Core::n_1getTextSize()"); jdoubleArray result; @@ -483,18 +495,11 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize env->ThrowNew(je, "Unknown exception in JNI code {core::getTextSize()}"); return NULL; } -} - -""", - }, # getTextSize -## "checkRange" : #TBD -## {'j_code' : '/* TBD: checkRange() */', 'jn_code' : '', 'cpp_code' : '' }, - - "checkHardwareSupport" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' }, - "setUseOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' }, - "useOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' }, - - }, # Core + } + """, + }, # getTextSize + + }, # Imgproc 'Highgui' : { diff --git a/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java b/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java index 1ffeca82e..afd15de2c 100644 --- a/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java +++ b/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java @@ -63,7 +63,7 @@ public class Puzzle15Processor { } for (int i = 0; i < GRID_AREA; i++) { - Size s = Core.getTextSize(Integer.toString(i + 1), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, 2, null); + Size s = Imgproc.getTextSize(Integer.toString(i + 1), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, 2, null); mTextHeights[i] = (int) s.height; mTextWidths[i] = (int) s.width; } @@ -98,7 +98,7 @@ public class Puzzle15Processor { else { cells[idx].copyTo(mCells15[i]); if (mShowTileNumbers) { - Core.putText(mCells15[i], Integer.toString(1 + idx), new Point((cols / GRID_SIZE - mTextWidths[idx]) / 2, + Imgproc.putText(mCells15[i], Integer.toString(1 + idx), new Point((cols / GRID_SIZE - mTextWidths[idx]) / 2, (rows / GRID_SIZE + mTextHeights[idx]) / 2), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, new Scalar(255, 0, 0, 255), 2); } } @@ -160,8 +160,8 @@ public class Puzzle15Processor { private void drawGrid(int cols, int rows, Mat drawMat) { for (int i = 1; i < GRID_SIZE; i++) { - Core.line(drawMat, new Point(0, i * rows / GRID_SIZE), new Point(cols, i * rows / GRID_SIZE), new Scalar(0, 255, 0, 255), 3); - Core.line(drawMat, new Point(i * cols / GRID_SIZE, 0), new Point(i * cols / GRID_SIZE, rows), new Scalar(0, 255, 0, 255), 3); + Imgproc.line(drawMat, new Point(0, i * rows / GRID_SIZE), new Point(cols, i * rows / GRID_SIZE), new Scalar(0, 255, 0, 255), 3); + Imgproc.line(drawMat, new Point(i * cols / GRID_SIZE, 0), new Point(i * cols / GRID_SIZE, rows), new Scalar(0, 255, 0, 255), 3); } } diff --git a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java index 2f9df6a3c..cfae73fc8 100644 --- a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java +++ b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java @@ -139,7 +139,7 @@ public class CameraCalibrator { private void renderFrame(Mat rgbaFrame) { drawPoints(rgbaFrame); - Core.putText(rgbaFrame, "Captured: " + mCornersBuffer.size(), new Point(rgbaFrame.cols() / 3 * 2, rgbaFrame.rows() * 0.1), + Imgproc.putText(rgbaFrame, "Captured: " + mCornersBuffer.size(), new Point(rgbaFrame.cols() / 3 * 2, rgbaFrame.rows() * 0.1), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); } diff --git a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java index 3f155c2bf..85a85040c 100644 --- a/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java +++ b/samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/OnCameraFrameRender.java @@ -80,11 +80,11 @@ class ComparisonFrameRender extends FrameRender { final int shift = (int)(mWidth * 0.005); border.add(new MatOfPoint(new Point(mWidth / 2 - shift, 0), new Point(mWidth / 2 + shift, 0), new Point(mWidth / 2 + shift, mHeight), new Point(mWidth / 2 - shift, mHeight))); - Core.fillPoly(comparisonFrame, border, new Scalar(255, 255, 255)); + Imgproc.fillPoly(comparisonFrame, border, new Scalar(255, 255, 255)); - Core.putText(comparisonFrame, mResources.getString(R.string.original), new Point(mWidth * 0.1, mHeight * 0.1), + Imgproc.putText(comparisonFrame, mResources.getString(R.string.original), new Point(mWidth * 0.1, mHeight * 0.1), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); - Core.putText(comparisonFrame, mResources.getString(R.string.undistorted), new Point(mWidth * 0.6, mHeight * 0.1), + Imgproc.putText(comparisonFrame, mResources.getString(R.string.undistorted), new Point(mWidth * 0.6, mHeight * 0.1), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 0)); return comparisonFrame; diff --git a/samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java b/samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java index d752f2a50..9fd738d2d 100644 --- a/samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java +++ b/samples/android/face-detection/src/org/opencv/samples/facedetect/FdActivity.java @@ -193,7 +193,7 @@ public class FdActivity extends Activity implements CvCameraViewListener2 { Rect[] facesArray = faces.toArray(); for (int i = 0; i < facesArray.length; i++) - Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3); + Imgproc.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3); return mRgba; } diff --git a/samples/android/hello-android/main.cpp b/samples/android/hello-android/main.cpp index 3e9f76245..868402967 100644 --- a/samples/android/hello-android/main.cpp +++ b/samples/android/hello-android/main.cpp @@ -1,6 +1,7 @@ -#include -#include -#include +#include +#include +#include +#include using namespace cv; const char* message = "Hello Android!"; diff --git a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java index f17a2731f..dee224a7e 100644 --- a/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java +++ b/samples/android/image-manipulations/src/org/opencv/samples/imagemanipulations/ImageManipulationsActivity.java @@ -231,7 +231,7 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView mP1.x = mP2.x = offset + (c * (mHistSizeNum + 10) + h) * thikness; mP1.y = sizeRgba.height-1; mP2.y = mP1.y - 2 - (int)mBuff[h]; - Core.line(rgba, mP1, mP2, mColorsRGB[c], thikness); + Imgproc.line(rgba, mP1, mP2, mColorsRGB[c], thikness); } } // Value and Hue @@ -244,7 +244,7 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView mP1.x = mP2.x = offset + (3 * (mHistSizeNum + 10) + h) * thikness; mP1.y = sizeRgba.height-1; mP2.y = mP1.y - 2 - (int)mBuff[h]; - Core.line(rgba, mP1, mP2, mWhilte, thikness); + Imgproc.line(rgba, mP1, mP2, mWhilte, thikness); } // Hue Imgproc.calcHist(Arrays.asList(mIntermediateMat), mChannels[0], mMat0, hist, mHistSize, mRanges); @@ -254,7 +254,7 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView mP1.x = mP2.x = offset + (4 * (mHistSizeNum + 10) + h) * thikness; mP1.y = sizeRgba.height-1; mP2.y = mP1.y - 2 - (int)mBuff[h]; - Core.line(rgba, mP1, mP2, mColorsHue[h], thikness); + Imgproc.line(rgba, mP1, mP2, mColorsHue[h], thikness); } break; @@ -287,7 +287,7 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView Mat mZoomWindow = rgba.submat(rows / 2 - 9 * rows / 100, rows / 2 + 9 * rows / 100, cols / 2 - 9 * cols / 100, cols / 2 + 9 * cols / 100); Imgproc.resize(mZoomWindow, zoomCorner, zoomCorner.size()); Size wsize = mZoomWindow.size(); - Core.rectangle(mZoomWindow, new Point(1, 1), new Point(wsize.width - 2, wsize.height - 2), new Scalar(255, 0, 0, 255), 2); + Imgproc.rectangle(mZoomWindow, new Point(1, 1), new Point(wsize.width - 2, wsize.height - 2), new Scalar(255, 0, 0, 255), 2); zoomCorner.release(); mZoomWindow.release(); break; diff --git a/samples/cpp/em.cpp b/samples/cpp/em.cpp index be792a904..bb777fcc8 100644 --- a/samples/cpp/em.cpp +++ b/samples/cpp/em.cpp @@ -1,4 +1,5 @@ #include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" #include "opencv2/ml.hpp" using namespace cv; diff --git a/samples/java/sbt/src/main/java/DetectFaceDemo.java b/samples/java/sbt/src/main/java/DetectFaceDemo.java index 686df02f9..af842d38c 100644 --- a/samples/java/sbt/src/main/java/DetectFaceDemo.java +++ b/samples/java/sbt/src/main/java/DetectFaceDemo.java @@ -32,7 +32,7 @@ public class DetectFaceDemo { // Draw a bounding box around each face. for (Rect rect : faceDetections.toArray()) { - Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + Imgproc.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); } diff --git a/samples/java/sbt/src/main/scala/ScalaDetectFaceDemo.scala b/samples/java/sbt/src/main/scala/ScalaDetectFaceDemo.scala index 479a7ec7f..d1df0e376 100644 --- a/samples/java/sbt/src/main/scala/ScalaDetectFaceDemo.scala +++ b/samples/java/sbt/src/main/scala/ScalaDetectFaceDemo.scala @@ -27,7 +27,7 @@ object ScalaDetectFaceDemo { // Draw a bounding box around each face. for (rect <- faceDetections.toArray) { - Core.rectangle( + Imgproc.rectangle( image, new Point(rect.x, rect.y), new Point(rect.x + rect.width,