diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java index 43386d977..bb4e402c3 100644 --- a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java +++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java @@ -23,15 +23,15 @@ import org.opencv.highgui.Highgui; public class OpenCVTestCase extends TestCase { - protected static int matSize = 10; - protected static double EPS = 0.001; - protected static double weakEPS = 0.5; + protected static final int matSize = 10; + protected static final double EPS = 0.001; + protected static final double weakEPS = 0.5; - protected static Mat dst; - protected static Mat truth; + protected Mat dst; + protected Mat truth; - protected static Scalar colorBlack; - protected static Scalar colorWhite; + protected Scalar colorBlack; + protected Scalar colorWhite; // Naming notation: _[depth]_[dimensions]_value // examples: gray0 - single channel 8U 2d Mat filled with 0 @@ -42,42 +42,42 @@ public class OpenCVTestCase extends TestCase { // - rename matrices // - create methods gray0() and create src1 explicitly // - create some masks - // - use truth member everywhere + // - use truth member everywhere - remove truth from base class - each test fixture should use own truth filed - protected static Mat gray0; - protected static Mat gray1; - protected static Mat gray2; - protected static Mat gray3; - protected static Mat gray9; - protected static Mat gray127; - protected static Mat gray128; - protected static Mat gray255; - protected static Mat grayRnd; + protected Mat gray0; + protected Mat gray1; + protected Mat gray2; + protected Mat gray3; + protected Mat gray9; + protected Mat gray127; + protected Mat gray128; + protected Mat gray255; + protected Mat grayRnd; - protected static Mat gray_16u_256; - protected static Mat gray_16s_1024; + protected Mat gray_16u_256; + protected Mat gray_16s_1024; - protected static Mat gray0_32f; - protected static Mat gray1_32f; - protected static Mat gray3_32f; - protected static Mat gray9_32f; - protected static Mat gray255_32f; - protected static Mat grayE_32f; - protected static Mat grayRnd_32f; + protected Mat gray0_32f; + protected Mat gray1_32f; + protected Mat gray3_32f; + protected Mat gray9_32f; + protected Mat gray255_32f; + protected Mat grayE_32f; + protected Mat grayRnd_32f; - protected static Mat gray0_32f_1d; + protected Mat gray0_32f_1d; - protected static Mat gray0_64f; - protected static Mat gray0_64f_1d; + protected Mat gray0_64f; + protected Mat gray0_64f_1d; - protected static Mat rgba0; - protected static Mat rgba128; + protected Mat rgba0; + protected Mat rgba128; - protected static Mat rgbLena; - protected static Mat grayChess; + protected Mat rgbLena; + protected Mat grayChess; - protected static Mat v1; - protected static Mat v2; + protected Mat v1; + protected Mat v2; @Override protected void setUp() throws Exception { diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java index bae3e45bc..e9a4a7ac4 100644 --- a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java +++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java @@ -12,8 +12,7 @@ import java.io.File; import java.io.IOException; /** - * This only class is Android specific. The original idea about test order - * randomization is from marek.defecinski blog. + * This only class is Android specific. * * @see OpenCV */ @@ -49,7 +48,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner { } static public void Log(Mat m) { - Log.e(TAG, m + "\n" + m.dump()); + Log.e(TAG, m + "\n " + m.dump()); } @Override @@ -59,6 +58,9 @@ public class OpenCVTestRunner extends InstrumentationTestRunner { CHESS_PATH = Utils.ExportResource(context, R.drawable.chessboard); LBPCASCADE_FRONTALFACE_PATH = Utils.ExportResource(context, R.raw.lbpcascade_frontalface); + /* + * The original idea about test order randomization is from marek.defecinski blog. + */ // List testCases = androidTestRunner.getTestCases(); // Collections.shuffle(testCases); //shuffle the tests order 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 9c264e657..00373f356 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 @@ -1,6 +1,7 @@ package org.opencv.test.core; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.opencv.core.Core; @@ -15,7 +16,6 @@ import org.opencv.core.Scalar; import org.opencv.core.Size; import org.opencv.core.TermCriteria; import org.opencv.test.OpenCVTestCase; -import org.opencv.test.OpenCVTestRunner; import org.opencv.utils.Converters; public class CoreTest extends OpenCVTestCase { @@ -169,7 +169,7 @@ public class CoreTest extends OpenCVTestCase { Core.checkRange(outOfRange, false); fail("Core.checkRange should throw the CvException"); } catch (CvException e) { - //expected + // expected } } @@ -180,8 +180,8 @@ public class CoreTest extends OpenCVTestCase { assertFalse(Core.checkRange(outOfRange, true, null)); assertFalse(Core.checkRange(outOfRange, true, pt)); - - assertPointEquals(new Point(2,0), pt, EPS); + + assertPointEquals(new Point(2, 0), pt, EPS); } public void testCheckRangeMatBooleanPointDouble() { @@ -221,7 +221,7 @@ public class CoreTest extends OpenCVTestCase { Scalar color = new Scalar(128); assertTrue(0 == Core.countNonZero(gray0)); - Core.circle(gray0, center, radius, color, -1 /* filled circle */); + Core.circle(gray0, center, radius, color, Core.FILLED); assertTrue(0 != Core.countNonZero(gray0)); } @@ -231,7 +231,7 @@ public class CoreTest extends OpenCVTestCase { Scalar color = new Scalar(128); assertTrue(0 == Core.countNonZero(gray0)); - Core.circle(gray0, center, radius, color, 2, 4/* 4-connected line */); + Core.circle(gray0, center, radius, color, 2, Core.LINE_4); assertTrue(0 != Core.countNonZero(gray0)); } @@ -482,7 +482,7 @@ public class CoreTest extends OpenCVTestCase { double angle = 30, startAngle = 60, endAngle = 90; assertTrue(0 == Core.countNonZero(gray0)); - Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, -1);//TODO: CV_FILLED ?? + Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED); assertTrue(0 != Core.countNonZero(gray0)); } @@ -490,10 +490,9 @@ public class CoreTest extends OpenCVTestCase { Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); Size axes = new Size(2, 2); double angle = 30, startAngle = 0, endAngle = 30; - int lineType = 4;//FIXME: use constant assertTrue(0 == Core.countNonZero(gray0)); - Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, -1, lineType); + Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED, Core.LINE_4); assertTrue(0 != Core.countNonZero(gray0)); } @@ -501,30 +500,60 @@ public class CoreTest extends OpenCVTestCase { Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); Size axes = new Size(2, 2); double angle = 30, startAngle = 0, endAngle = 30; - int lineType = 4;//FIXME: use constant int shift = 1; - assertTrue(0 == Core.countNonZero(gray0)); - Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, -1, lineType, shift); + + Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED, Core.LINE_4, shift); assertTrue(0 != Core.countNonZero(gray0)); } public void testEllipseMatRotatedRectScalar() { + int matSize = 10; + gray0 = Mat.zeros(matSize, matSize, CvType.CV_8U); Point center = new Point(matSize / 2, matSize / 2); Size size = new Size(matSize / 4, matSize / 2); - double angle = 40; - RotatedRect box = new RotatedRect(center, size, angle); - Core.ellipse(gray0, box, colorWhite); - // TODO: How do we get access to ellipse's center - // assertTrue(box.center.equals(ellipse.center)); - fail("Not yet implemented"); + 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(gray0.size(), CvType.CV_8U) { + { + put(0, 0, truth); + } + }, gray0); } public void testEllipseMatRotatedRectScalarInt() { - fail("Not yet implemented"); + 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() { - fail("Not yet implemented"); + 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() { @@ -548,75 +577,116 @@ public class CoreTest extends OpenCVTestCase { assertEquals(75.96, res2, delta); } - public void testFillConvexPolyMatMatScalar() { - List lp = new ArrayList(4); - lp.add(new Point(1, 1)); - lp.add(new Point(5, 0)); - lp.add(new Point(6, 8)); - lp.add(new Point(0, 9)); - Mat points = Converters.vector_Point_to_Mat(lp); - assertTrue(0 == Core.countNonZero(gray0)); + public void testFillConvexPolyMatListOfPointScalar() { + List polyline = Arrays.asList(new Point(1, 1), new Point(5, 0), new Point(6, 8), new Point(0, 9)); - Core.fillConvexPoly(gray0, points, new Scalar(150)); + Core.fillConvexPoly(gray0, polyline, new Scalar(150)); assertTrue(0 < Core.countNonZero(gray0)); - - Core.fillConvexPoly(gray0, points, new Scalar(0)); - assertTrue(0 == Core.countNonZero(gray0)); + assertTrue(gray0.total() > Core.countNonZero(gray0)); } - public void testFillConvexPolyMatMatScalarInt() { - List lp = new ArrayList(4); - lp.add(new Point(1, 1)); - lp.add(new Point(5, 0)); - lp.add(new Point(6, 8)); - lp.add(new Point(0, 9)); - Mat points = Converters.vector_Point_to_Mat(lp); - assertTrue(0 == Core.countNonZero(gray0)); + public void testFillConvexPolyMatListOfPointScalarInt() { + List 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); - Core.fillConvexPoly(gray0, points, new Scalar(150), 4); assertTrue(0 < Core.countNonZero(gray0)); - - Core.fillConvexPoly(gray0, points, new Scalar(0), 4); - assertTrue(0 == Core.countNonZero(gray0)); + assertTrue(gray0.total() > Core.countNonZero(gray0)); } - public void testFillConvexPolyMatMatScalarIntInt() { - List lp = new ArrayList(); - lp.add(new Point(1, 1)); - lp.add(new Point(5, 1)); - lp.add(new Point(5, 8)); - lp.add(new Point(1, 8)); - Mat points = Converters.vector_Point_to_Mat(lp); + public void testFillConvexPolyMatListOfPointScalarIntInt() { + List polyline1 = Arrays.asList(new Point(1, 1), new Point(5, 1), new Point(5, 8), new Point(1, 8)); + List polyline2 = Arrays.asList(new Point(2, 2), new Point(10, 2), new Point(10, 16), new Point(2, 16)); + /* TODO: this test fails because of a bug! + * find source of rounding error - java or OpenCV */ - List lp2 = new ArrayList(); - lp2.add(new Point(0, 0)); - lp2.add(new Point(10, 2)); - lp2.add(new Point(10, 16)); - lp2.add(new Point(2, 16)); - Mat points2 = Converters.vector_Point_to_Mat(lp2); + Core.fillConvexPoly(gray0, polyline1, colorWhite, Core.LINE_8, 0); - assertEquals(0, Core.countNonZero(gray0)); - Core.fillConvexPoly(gray0, points, colorWhite, 4 /* TODO: lineType */, 0); assertTrue(0 < Core.countNonZero(gray0)); + assertTrue(gray0.total() > Core.countNonZero(gray0)); + + Core.fillConvexPoly(gray0, polyline2, colorBlack, Core.LINE_8, 1); + // OpenCVTestRunner.Log(gray0); - Core.fillConvexPoly(gray0, points2, colorBlack, 4 /* TODO: lineType */, 0); assertEquals(0, Core.countNonZero(gray0)); } - public void testFillPolyMatListOfMatScalar() { - fail("Not yet implemented"); + public void testFillPolyMatListOfListOfPointScalar() { + int matSize = 10; + gray0 = Mat.zeros(matSize, matSize, CvType.CV_8U); + List polyline = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4)); + List> polylines = new ArrayList>(); + polylines.add(polyline); + + Core.fillPoly(gray0, polylines, new Scalar(1)); + + final byte[] truth = new byte[] { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, + 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + assertMatEqual(new Mat(gray0.size(), CvType.CV_8U) { + { + put(0, 0, truth); + } + }, gray0); } - public void testFillPolyMatListOfMatScalarInt() { - fail("Not yet implemented"); + public void testFillPolyMatListOfListOfPointScalarInt() { + List polyline = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(9, 3)); + List> polylines = new ArrayList>(); + 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 testFillPolyMatListOfMatScalarIntInt() { - fail("Not yet implemented"); + public void testFillPolyMatListOfListOfPointScalarIntInt() { + List polyline1 = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4)); + List polyline2 = Arrays.asList(new Point(2, 8), new Point(2, 16), new Point(8, 2), new Point(14, 16), new Point(14, 8)); + + List> polylines1 = new ArrayList>(); + polylines1.add(polyline1); + + List> polylines2 = new ArrayList>(); + 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 testFillPolyMatListOfMatScalarIntIntPoint() { - fail("Not yet implemented"); + public void testFillPolyMatListOfListOfPointScalarIntIntPoint() { + List polyline1 = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4)); + List polyline2 = Arrays.asList(new Point(0, 3), new Point(0, 7), new Point(3, 0), new Point(6, 7), new Point(6, 3)); + + List> polylines1 = new ArrayList>(); + polylines1.add(polyline1); + + List> polylines2 = new ArrayList>(); + polylines2.add(polyline2); + + Core.fillPoly(gray0, polylines1, new Scalar(1), Core.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)); + + assertEquals(0, Core.countNonZero(gray0)); } public void testFlip() { @@ -697,7 +767,8 @@ public class CoreTest extends OpenCVTestCase { } public void testGetNumberOfCPUs() { - fail("Not yet implemented"); + int cpus = Core.getNumberOfCPUs(); + assertEquals(Runtime.getRuntime().availableProcessors(), cpus); } public void testGetOptimalDFTSize() { @@ -851,23 +922,65 @@ public class CoreTest extends OpenCVTestCase { } public void testKmeansMatIntMatTermCriteriaIntInt() { - fail("Not yet implemented"); - Mat data = new Mat(4, 2, CvType.CV_32FC1); - data.put(0, 0, 2, 4); - data.put(1, 0, 3, 9); - data.put(1, 0, 1, 4); - data.put(1, 0, 8, 12); - int K = 3; - Mat bestLabels = new Mat(); - TermCriteria criteria = new TermCriteria(2/* TODO: CV_TERMCRIT_EPS */, 100, 0); - double res; - // TODO: returns 0 for most input combinations - res = Core.kmeans(data, K, bestLabels, criteria, 0, Core.KMEANS_PP_CENTERS); - assertEquals(10.0, res); + Mat data = new Mat(4, 5, CvType.CV_32FC1) { + { + put(0, 0, 1, 2, 3, 4, 5); + put(1, 0, 2, 3, 4, 5, 6); + put(2, 0, 5, 4, 3, 2, 1); + put(3, 0, 6, 5, 4, 3, 2); + } + }; + TermCriteria criteria = new TermCriteria(TermCriteria.EPS, 0, EPS); + Mat labels = new Mat(); + + Core.kmeans(data, 2, labels, criteria, 1, Core.KMEANS_PP_CENTERS); + + int[] first_center = new int[1]; + labels.get(0, 0, first_center); + final int c1 = first_center[0]; + + Mat expected_labels = new Mat(4, 1, CvType.CV_32S) { + { + put(0, 0, c1, c1, 1 - c1, 1 - c1); + } + }; + + assertMatEqual(expected_labels, labels); } public void testKmeansMatIntMatTermCriteriaIntIntMat() { - fail("Not yet implemented"); + Mat data = new Mat(4, 5, CvType.CV_32FC1) { + { + put(0, 0, 1, 2, 3, 4, 5); + put(1, 0, 2, 3, 4, 5, 6); + put(2, 0, 5, 4, 3, 2, 1); + put(3, 0, 6, 5, 4, 3, 2); + } + }; + TermCriteria criteria = new TermCriteria(TermCriteria.EPS, 0, EPS); + Mat labels = new Mat(); + Mat centers = new Mat(); + + Core.kmeans(data, 2, labels, criteria, 6, Core.KMEANS_RANDOM_CENTERS, centers); + + int[] first_center = new int[1]; + labels.get(0, 0, first_center); + final int c1 = first_center[0]; + + Mat expected_labels = new Mat(4, 1, CvType.CV_32S) { + { + put(0, 0, c1, c1, 1 - c1, 1 - c1); + } + }; + Mat expected_centers = new Mat(2, 5, CvType.CV_32FC1) { + { + put(c1, 0, 1.5, 2.5, 3.5, 4.5, 5.5); + put(1 - c1, 0, 5.5, 4.5, 3.5, 2.5, 1.5); + } + }; + + assertMatEqual(expected_labels, labels); + assertMatEqual(expected_centers, centers, EPS); } public void testLineMatPointPointScalar() { @@ -877,7 +990,6 @@ public class CoreTest extends OpenCVTestCase { Point point2 = new Point(nPoints, nPoints); Scalar color = new Scalar(255); - assertTrue(0 == Core.countNonZero(gray0)); Core.line(gray0, point1, point2, color); assertTrue(nPoints == Core.countNonZero(gray0)); } @@ -888,17 +1000,41 @@ public class CoreTest extends OpenCVTestCase { Point point1 = new Point(0, 0); Point point2 = new Point(nPoints, nPoints); - assertTrue(0 == Core.countNonZero(gray0)); Core.line(gray0, point1, point2, colorWhite, 0); assertTrue(nPoints == Core.countNonZero(gray0)); } public void testLineMatPointPointScalarIntInt() { - fail("Not yet implemented"); + 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() { - fail("Not yet implemented"); + int nPoints = Math.min(gray0.cols(), gray0.rows()); + + Point point1 = new Point(3, 4); + Point point2 = new Point(nPoints, nPoints); + + 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); + + assertFalse(0 == Core.countNonZero(gray0)); + + Core.line(gray0, point2_4, point1_4, colorBlack, 2, Core.LINE_8, 2); + + assertEquals(0, Core.countNonZero(gray0)); } public void testLog() { @@ -1285,26 +1421,118 @@ public class CoreTest extends OpenCVTestCase { } public void testPCABackProject() { - Mat data = new Mat(2, 2, CvType.CV_32F); - data.put(0, 0, 1, 3); - data.put(1, 0, 0, 2); - Mat eigenvectors = new Mat(1, 2, CvType.CV_32F); - eigenvectors.put(0, 0, 1, 3); - // Mat mean = new Mat(1, 1, CvType.CV_32F, new Scalar(2.5)); - // Core.PCABackProject(data, new Mat(), eigenvectors, dst); - fail("Not yet implemented"); + Mat mean = new Mat(1, 4, CvType.CV_32F) { + { + put(0, 0, 2, 4, 4, 8); + } + }; + Mat vectors = new Mat(1, 4, CvType.CV_32F, new Scalar(0)) { + { + put(0, 0, 0.2, 0.4, 0.4, 0.8); + } + }; + Mat data = new Mat(3, 1, CvType.CV_32F) { + { + put(0, 0, -5, 0, -10); + } + }; + Mat result = new Mat(); + + Core.PCABackProject(data, mean, vectors, result); + + Mat truth = new Mat(3, 4, CvType.CV_32F) { + { + put(0, 0, 1, 2, 2, 4); + put(1, 0, 2, 4, 4, 8); + put(2, 0, 0, 0, 0, 0); + } + }; + + assertMatEqual(truth, result, EPS); } public void testPCAComputeMatMatMat() { - fail("Not yet implemented"); + Mat data = new Mat(3, 4, CvType.CV_32F) { + { + put(0, 0, 1, 2, 2, 4); + put(1, 0, 2, 4, 4, 8); + put(2, 0, 3, 6, 6, 12); + } + }; + Mat mean = new Mat(); + Mat vectors = new Mat(); + + Core.PCACompute(data, mean, vectors); + + Mat mean_truth = new Mat(1, 4, CvType.CV_32F) { + { + put(0, 0, 2, 4, 4, 8); + } + }; + Mat vectors_truth = new Mat(3, 4, CvType.CV_32F, new Scalar(0)) { + { + put(0, 0, 0.2, 0.4, 0.4, 0.8); + } + }; + assertMatEqual(mean_truth, mean, EPS); + assertMatEqual(vectors_truth, vectors, EPS); } public void testPCAComputeMatMatMatInt() { - fail("Not yet implemented"); + Mat data = new Mat(3, 4, CvType.CV_32F) { + { + put(0, 0, 1, 2, 2, 4); + put(1, 0, 2, 4, 4, 8); + put(2, 0, 3, 6, 6, 12); + } + }; + Mat mean = new Mat(); + Mat vectors = new Mat(); + + Core.PCACompute(data, mean, vectors, 1); + + Mat mean_truth = new Mat(1, 4, CvType.CV_32F) { + { + put(0, 0, 2, 4, 4, 8); + } + }; + Mat vectors_truth = new Mat(1, 4, CvType.CV_32F, new Scalar(0)) { + { + put(0, 0, 0.2, 0.4, 0.4, 0.8); + } + }; + assertMatEqual(mean_truth, mean, EPS); + assertMatEqual(vectors_truth, vectors, EPS); } public void testPCAProject() { - fail("Not yet implemented"); + Mat mean = new Mat(1, 4, CvType.CV_32F) { + { + put(0, 0, 2, 4, 4, 8); + } + }; + Mat vectors = new Mat(1, 4, CvType.CV_32F, new Scalar(0)) { + { + put(0, 0, 0.2, 0.4, 0.4, 0.8); + } + }; + Mat data = new Mat(3, 4, CvType.CV_32F) { + { + put(0, 0, 1, 2, 2, 4); + put(1, 0, 2, 4, 4, 8); + put(2, 0, 0, 0, 0, 0); + } + }; + Mat result = new Mat(); + + Core.PCAProject(data, mean, vectors, result); + + Mat truth = new Mat(3, 1, CvType.CV_32F) { + { + put(0, 0, -5, 0, -10); + } + }; + assertMatEqual(truth, result, EPS); } public void testPerspectiveTransform() { @@ -1392,75 +1620,72 @@ public class CoreTest extends OpenCVTestCase { assertMatEqual(y, yCoordinate, EPS); } - public void testPolylinesMatListOfMatBooleanScalar() { + public void testPolylinesMatListOfListOfPointBooleanScalar() { Mat img = gray0; List pts = new ArrayList(); pts.add(new Point(1, 1)); pts.add(new Point(7, 1)); pts.add(new Point(7, 6)); pts.add(new Point(1, 6)); - List mats = new ArrayList(); - mats.add(Converters.vector_Point_to_Mat(pts)); - assertEquals(0, Core.countNonZero(img)); - Core.polylines(img, mats, true, new Scalar(100)); + List> polyline = new ArrayList>(); + polyline.add(pts); + + Core.polylines(img, polyline, true, new Scalar(100)); + assertEquals(22, Core.countNonZero(img)); - Core.polylines(img, mats, false, new Scalar(0)); + Core.polylines(img, polyline, false, new Scalar(0)); assertEquals(4, Core.countNonZero(img)); } - public void testPolylinesMatListOfMatBooleanScalarInt() { + public void testPolylinesMatListOfListOfPointBooleanScalarInt() { Mat img = gray0; List pts = new ArrayList(); pts.add(new Point(1, 1)); pts.add(new Point(7, 1)); pts.add(new Point(7, 6)); pts.add(new Point(1, 6)); - List mats = new ArrayList(); - mats.add(Converters.vector_Point_to_Mat(pts)); - assertEquals(0, Core.countNonZero(img)); - Core.polylines(img, mats, true, new Scalar(100), 2); + List> polyline = new ArrayList>(); + polyline.add(pts); + + Core.polylines(img, polyline, true, new Scalar(100), 2); + assertEquals(62, Core.countNonZero(img)); } - public void testPolylinesMatListOfMatBooleanScalarIntInt() { + public void testPolylinesMatListOfListOfPointBooleanScalarIntInt() { Mat img = gray0; List pts = new ArrayList(); pts.add(new Point(1, 1)); pts.add(new Point(4, 1)); pts.add(new Point(3, 6)); pts.add(new Point(1, 3)); - List mats = new ArrayList(); - mats.add(Converters.vector_Point_to_Mat(pts)); - assertEquals(0, Core.countNonZero(img)); - Core.polylines(img, mats, true, new Scalar(100), 2, 8); + List> polyline = new ArrayList>(); + polyline.add(pts); + + Core.polylines(img, polyline, true, new Scalar(100), 2, Core.LINE_4); + assertEquals(36, Core.countNonZero(img)); } - public void testPolylinesMatListOfMatBooleanScalarIntIntInt() { + public void testPolylinesMatListOfListOfPointBooleanScalarIntIntInt() { Mat img = gray0; - List pts = new ArrayList(); - List pts2 = new ArrayList(); - pts.add(new Point(1, 1)); - pts2.add(new Point(2, 2)); - pts.add(new Point(7, 1)); - pts2.add(new Point(14, 2)); - pts.add(new Point(7, 6)); - pts2.add(new Point(14, 12)); - pts.add(new Point(1, 6)); - pts2.add(new Point(2, 12)); - List mats = new ArrayList(); - List mats2 = new ArrayList(); - mats.add(Converters.vector_Point_to_Mat(pts)); - mats2.add(Converters.vector_Point_to_Mat(pts2)); - assertTrue(0 == Core.countNonZero(img)); - Core.polylines(img, mats, true, new Scalar(100), 2, 8, 0); - assertFalse(0 == Core.countNonZero(img)); - Core.polylines(img, mats2, true, new Scalar(0), 2, 8, 1); - assertTrue(0 == Core.countNonZero(img)); + List> polyline1 = new ArrayList>(); + polyline1.add(Arrays.asList(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6))); + + List> polyline2 = new ArrayList>(); + polyline2.add(Arrays.asList(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() { @@ -1471,28 +1696,61 @@ public class CoreTest extends OpenCVTestCase { 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); + + 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, -1);//TODO:CV_FILLED + // 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() { - fail("Not yet implemented"); + 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 testPutTextMatStringPointIntDoubleScalarIntInt() { - fail("Not yet implemented"); + 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() { - fail("Not yet implemented"); + 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() { @@ -1505,9 +1763,9 @@ public class CoreTest extends OpenCVTestCase { Mat original = new Mat(1, 5, CvType.CV_32F); original.put(0, 0, 7, 5, 2, 8, 1); Mat shuffled = original.clone(); - + Core.randShuffle(shuffled); - + assertMatNotEqual(original, shuffled, EPS); Mat dst1 = new Mat(); Mat dst2 = new Mat(); @@ -1520,9 +1778,9 @@ public class CoreTest extends OpenCVTestCase { Mat original = new Mat(1, 5, CvType.CV_32F); original.put(0, 0, 7, 5, 2, 8, 1); Mat shuffled = original.clone(); - + Core.randShuffle(shuffled, 10); - + assertMatNotEqual(original, shuffled, EPS); Mat dst1 = new Mat(); Mat dst2 = new Mat(); @@ -1563,7 +1821,7 @@ public class CoreTest extends OpenCVTestCase { Scalar color = new Scalar(128); assertTrue(0 == Core.countNonZero(gray0)); - Core.rectangle(gray0, center, origin, color, 2, 8); + Core.rectangle(gray0, center, origin, color, 2, Core.LINE_8); assertTrue(0 != Core.countNonZero(gray0)); } @@ -1573,7 +1831,7 @@ public class CoreTest extends OpenCVTestCase { Scalar color = new Scalar(128); assertTrue(0 == Core.countNonZero(gray0)); - Core.rectangle(gray0, center, origin, color, 2, 4, 2); + Core.rectangle(gray0, center, origin, color, 2, Core.LINE_4, 2); assertTrue(0 != Core.countNonZero(gray0)); } @@ -1812,18 +2070,13 @@ public class CoreTest extends OpenCVTestCase { Mat w = new Mat(); Mat u = new Mat(); Mat vt = new Mat(); - Core.SVDecomp(src, w, u, vt, 1/* TODO: SVD::MODIFY_A */); + + Core.SVDecomp(src, w, u, vt, Core.SVD_NO_UV); Mat truthW = new Mat(1, 1, CvType.CV_32FC1, new Scalar(10.816654)); assertMatEqual(truthW, w, EPS); - - Mat truthU = new Mat(1, 1, CvType.CV_32FC1, new Scalar(1)); - assertMatEqual(truthU, u, EPS); - - Mat truthVT = new Mat(1, 4, CvType.CV_32FC1); - truthVT.put(0, 0, 0.09245003, 0.36980012, 0.73960024, 0.5547002); - assertMatEqual(truthVT, vt, EPS); - + assertTrue(u.empty()); + assertTrue(vt.empty()); } public void testTrace() { diff --git a/modules/java/android_test/src/org/opencv/test/core/Point3Test.java b/modules/java/android_test/src/org/opencv/test/core/Point3Test.java index 5ca811ebb..4f6565eb5 100644 --- a/modules/java/android_test/src/org/opencv/test/core/Point3Test.java +++ b/modules/java/android_test/src/org/opencv/test/core/Point3Test.java @@ -96,5 +96,12 @@ public class Point3Test extends OpenCVTestCase { assertEquals(6., p1.y); assertEquals(10., p1.z); } + + public void testToString() { + String actual = p1.toString(); + String expected = "{2.0, 2.0, 2.0}"; + assertEquals(expected, actual); + } + } diff --git a/modules/java/android_test/src/org/opencv/test/core/RotatedRectTest.java b/modules/java/android_test/src/org/opencv/test/core/RotatedRectTest.java index 914bd6ee0..2602b51d9 100644 --- a/modules/java/android_test/src/org/opencv/test/core/RotatedRectTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/RotatedRectTest.java @@ -165,5 +165,11 @@ public class RotatedRectTest extends OpenCVTestCase { public void testSet() { fail("Not yet implemented"); } + + public void testToString() { + String actual = new RotatedRect(new Point(1,2), new Size(10,12), 4.5).toString(); + String expected = "{ {1.0, 2.0} 10x12 * 4.5 }"; + assertEquals(expected, actual); + } } diff --git a/modules/java/android_test/src/org/opencv/test/core/ScalarTest.java b/modules/java/android_test/src/org/opencv/test/core/ScalarTest.java index ddcfb9882..439614ef0 100644 --- a/modules/java/android_test/src/org/opencv/test/core/ScalarTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/ScalarTest.java @@ -100,5 +100,11 @@ public class ScalarTest extends OpenCVTestCase { s1.set(vals); assertEquals(s2, s1); } + + public void testToString() { + String actual = s2.toString(); + String expected = "[1.0, 1.0, 1.0, 1.0]"; + assertEquals(expected, actual); + } } diff --git a/modules/java/android_test/src/org/opencv/test/core/SizeTest.java b/modules/java/android_test/src/org/opencv/test/core/SizeTest.java index a624a7cac..542c35d26 100644 --- a/modules/java/android_test/src/org/opencv/test/core/SizeTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/SizeTest.java @@ -83,5 +83,11 @@ public class SizeTest extends OpenCVTestCase { assertEquals(2.0, sz1.width); assertEquals(4.0, sz1.height); } + + public void testToString() { + String actual = sz1.toString(); + String expected = "10x10"; + assertEquals(expected, actual); + } } diff --git a/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java b/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java index 2941818d9..b43881545 100644 --- a/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java +++ b/modules/java/android_test/src/org/opencv/test/utils/ConvertersTest.java @@ -16,7 +16,7 @@ public class ConvertersTest extends OpenCVTestCase { public void testMat_to_vector_char() { fail("Not yet implemented"); } - + public void testMat_to_vector_DMatch() { fail("Not yet implemented"); } @@ -291,4 +291,8 @@ public class ConvertersTest extends OpenCVTestCase { fail("Not yet implemented"); } + public void testVector_vector_Point_to_Mat() { + fail("Not yet implemented"); + } + } diff --git a/modules/java/gen_java.py b/modules/java/gen_java.py index 6cdc6591b..dad5d8b63 100644 --- a/modules/java/gen_java.py +++ b/modules/java/gen_java.py @@ -118,7 +118,13 @@ missing_consts = \ ('CV_32S', 4 ), ('CV_32F', 5 ), ('CV_64F', 6 ), ('CV_USRTYPE1', 7 ), - ) # private + ), # private + 'public' : + ( + ('SVD_MODIFY_A', 1), ('SVD_NO_UV', 2), ('SVD_FULL_UV', 4), + ('FILLED', -1), + ('LINE_AA', 16), ('LINE_8', 8), ('LINE_4', 4), + ) #public }, # Core "Imgproc": @@ -184,25 +190,26 @@ type_dict = { # "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" }, - "vector_Point" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point2f": { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point2d": { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point3i": { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point3f": { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Point3d": { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Mat" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_KeyPoint":{ "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_DMatch" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_Rect" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_uchar" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_char" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_int" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_float" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_double" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Point" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Point2f" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Point2d" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Point3i" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Point3f" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Point3d" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Mat" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_KeyPoint" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_DMatch" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_Rect" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_uchar" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_char" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_int" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_float" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, + "vector_double" : { "j_type" : "List", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector %(n)s", "suffix" : "J" }, - "vector_vector_KeyPoint":{ "j_type" : "List>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, - "vector_vector_DMatch" : { "j_type" : "List>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, - "vector_vector_char" : { "j_type" : "List>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, + "vector_vector_KeyPoint": { "j_type" : "List>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, + "vector_vector_DMatch" : { "j_type" : "List>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, + "vector_vector_char" : { "j_type" : "List>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, + "vector_vector_Point" : { "j_type" : "List>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector > %(n)s" }, "Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),), "jni_var" : "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)", @@ -678,6 +685,9 @@ func_arg_fix = { 'calcOpticalFlowPyrLK' : { 'prevPts' : 'vector_Point2f', 'nextPts' : 'vector_Point2f', 'status' : 'vector_uchar', 'err' : 'vector_float', }, 'fitEllipse' : { 'points' : 'vector_Point2f', }, + 'fillPoly' : { 'pts' : 'vector_vector_Point', }, + 'polylines' : { 'pts' : 'vector_vector_Point', }, + 'fillConvexPoly' : { 'points' : 'vector_Point', }, }, # '', i.e. no class } # func_arg_fix diff --git a/modules/java/gen_javadoc.py b/modules/java/gen_javadoc.py index 96bc14f82..215495f5e 100644 --- a/modules/java/gen_javadoc.py +++ b/modules/java/gen_javadoc.py @@ -39,7 +39,9 @@ class JavadocGenerator(object): module = "unknown" try: for l in inf.readlines(): - if l.lstrip().startswith(self.javadoc_marker): + org = l + l = l.replace(" ", "").replace("\t", "")#remove all whitespace + if l.startswith(self.javadoc_marker): marker = self.parceJavadocMarker(l) self.markers_processed += 1 decl = self.definitions.get(marker[0],None) @@ -55,7 +57,7 @@ class JavadocGenerator(object): elif show_errors: print >> sys.stderr, "gen_javadoc error: could not find documentation for %s (module: %s)" % (l.lstrip()[len(self.javadoc_marker):-1].strip(), module) else: - outf.write(l.replace("\t", " ").rstrip()+"\n") + outf.write(org.replace("\t", " ").rstrip()+"\n") except: inf.close() outf.close() diff --git a/modules/java/src/cpp/VideoCapture.cpp b/modules/java/src/cpp/VideoCapture.cpp index b796f7297..9659ab312 100644 --- a/modules/java/src/cpp/VideoCapture.cpp +++ b/modules/java/src/cpp/VideoCapture.cpp @@ -416,9 +416,9 @@ JNIEXPORT jstring JNICALL Java_org_opencv_highgui_VideoCapture_n_1getSupportedPr LOGD("highgui::VideoCapture_n_1set()"); #endif // DEBUG VideoCapture* me = (VideoCapture*) self; //TODO: check for NULL - double addr = me->get(CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING); - char* result = *((char**)&addr); - return env->NewStringUTF(result); + union {double prop; const char* name;} u; + u.prop = me->get(CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING); + return env->NewStringUTF(u.name); } catch(cv::Exception e) { #ifdef DEBUG LOGD("highgui::VideoCapture_n_1getSupportedPreviewSizes() catched cv::Exception: %s", e.what()); diff --git a/modules/java/src/cpp/converters.cpp b/modules/java/src/cpp/converters.cpp index 0416465ad..6cdae6bc6 100644 --- a/modules/java/src/cpp/converters.cpp +++ b/modules/java/src/cpp/converters.cpp @@ -264,6 +264,19 @@ void vector_DMatch_to_Mat(vector& v_dm, Mat& mat) } } +void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt) +{ + vector vm; + vm.reserve( mat.rows ); + Mat_to_vector_Mat(mat, vm); + for(size_t i=0; i vpt; + Mat_to_vector_Point(vm[i], vpt); + vv_pt.push_back(vpt); + } +} + void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp) { vector vm; diff --git a/modules/java/src/cpp/converters.h b/modules/java/src/cpp/converters.h index 4860b5b13..b8b0a6984 100644 --- a/modules/java/src/cpp/converters.h +++ b/modules/java/src/cpp/converters.h @@ -55,3 +55,5 @@ void vector_vector_DMatch_to_Mat(std::vector< std::vector< cv::DMatch > >& vv_dm void Mat_to_vector_vector_char(cv::Mat& mat, std::vector< std::vector< char > >& vv_ch); void vector_vector_char_to_Mat(std::vector< std::vector< char > >& vv_ch, cv::Mat& mat); + +void Mat_to_vector_vector_Point(cv::Mat& mat, std::vector< std::vector< cv::Point > >& vv_pt); diff --git a/modules/java/src/java/core+CvException.java b/modules/java/src/java/core+CvException.java index 161523fa5..ea00be13d 100644 --- a/modules/java/src/java/core+CvException.java +++ b/modules/java/src/java/core+CvException.java @@ -1,15 +1,15 @@ package org.opencv.core; -public class CvException extends RuntimeException { +public class CvException extends RuntimeException { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public CvException(String msg) { - super(msg); - } + public CvException(String msg) { + super(msg); + } - @Override - public String toString() { - return "CvException [" + super.toString() + "]"; - } + @Override + public String toString() { + return "CvException [" + super.toString() + "]"; + } } diff --git a/modules/java/src/java/core+CvType.java b/modules/java/src/java/core+CvType.java index c05503020..003883a90 100644 --- a/modules/java/src/java/core+CvType.java +++ b/modules/java/src/java/core+CvType.java @@ -1,111 +1,136 @@ package org.opencv.core; - public final class CvType { // type depth constants - public static final int CV_8U = 0, CV_8S = 1, - CV_16U = 2, CV_16S = 3, - CV_32S = 4, - CV_32F = 5, - CV_64F = 6, - CV_USRTYPE1=7; + public static final int + CV_8U = 0, CV_8S = 1, + CV_16U = 2, CV_16S = 3, + CV_32S = 4, + CV_32F = 5, + CV_64F = 6, + CV_USRTYPE1 = 7; // predefined type constants public static final int - CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4), - CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4), - CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4), - CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4), - CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4), - CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4), - CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4); + CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4), + CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4), + CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4), + CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4), + CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4), + CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4), + CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4); private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT); public static final int makeType(int depth, int channels) { - if(channels<=0 || channels>=CV_CN_MAX) { + if (channels <= 0 || channels >= CV_CN_MAX) { throw new java.lang.UnsupportedOperationException( - "Channels count should be 1.." + (CV_CN_MAX-1) ); + "Channels count should be 1.." + (CV_CN_MAX - 1)); } - if(depth<0 || depth>=CV_DEPTH_MAX) { + if (depth < 0 || depth >= CV_DEPTH_MAX) { throw new java.lang.UnsupportedOperationException( - "Data type depth should be 0.." + (CV_DEPTH_MAX-1) ); + "Data type depth should be 0.." + (CV_DEPTH_MAX - 1)); } - return (depth & (CV_DEPTH_MAX-1)) + ((channels-1) << CV_CN_SHIFT); + return (depth & (CV_DEPTH_MAX - 1)) + ((channels - 1) << CV_CN_SHIFT); } + public static final int CV_8UC(int ch) { + return makeType(CV_8U, ch); + } - public static final int CV_8UC(int ch) { return makeType(CV_8U, ch); } + public static final int CV_8SC(int ch) { + return makeType(CV_8S, ch); + } - public static final int CV_8SC(int ch) { return makeType(CV_8S, ch); } + public static final int CV_16UC(int ch) { + return makeType(CV_16U, ch); + } - public static final int CV_16UC(int ch) { return makeType(CV_16U, ch); } + public static final int CV_16SC(int ch) { + return makeType(CV_16S, ch); + } - public static final int CV_16SC(int ch) { return makeType(CV_16S, ch); } + public static final int CV_32SC(int ch) { + return makeType(CV_32S, ch); + } - public static final int CV_32SC(int ch) { return makeType(CV_32S, ch); } + public static final int CV_32FC(int ch) { + return makeType(CV_32F, ch); + } - public static final int CV_32FC(int ch) { return makeType(CV_32F, ch); } + public static final int CV_64FC(int ch) { + return makeType(CV_64F, ch); + } - public static final int CV_64FC(int ch) { return makeType(CV_64F, ch); } + public static final int channels(int type) { + return (type >> CV_CN_SHIFT) + 1; + } - public static final int channels(int type) { return (type >> CV_CN_SHIFT) + 1; } + public static final int depth(int type) { + return type & (CV_DEPTH_MAX - 1); + } - public static final int depth(int type) { return type & (CV_DEPTH_MAX-1); } - - public static final boolean isInteger(int type) { return depth(type) < CV_32F; } + public static final boolean isInteger(int type) { + return depth(type) < CV_32F; + } public static final int ELEM_SIZE(int type) { switch (depth(type)) { - case CV_8U: - case CV_8S: - return channels(type); - case CV_16U: - case CV_16S: - return 2 * channels(type); - case CV_32S: - case CV_32F: - return 4 * channels(type); - case CV_64F: - return 8 * channels(type); - default: - throw new java.lang.UnsupportedOperationException( - "Unsupported CvType value: " + type ); + case CV_8U: + case CV_8S: + return channels(type); + case CV_16U: + case CV_16S: + return 2 * channels(type); + case CV_32S: + case CV_32F: + return 4 * channels(type); + case CV_64F: + return 8 * channels(type); + default: + throw new java.lang.UnsupportedOperationException( + "Unsupported CvType value: " + type); } } public static final String typeToString(int type) { String s; switch (depth(type)) { - case CV_8U: - s = "CV_8U"; - break; - case CV_8S: - s = "CV_8S"; - break; - case CV_16U: - s = "CV_16U"; - break; - case CV_16S: - s = "CV_16S"; - break; - case CV_32S: - s = "CV_32S"; - break; - case CV_32F: - s = "CV_32F"; - break; - case CV_64F: - s = "CV_64F"; - break; - default: - s = "CV_USRTYPE1"; + case CV_8U: + s = "CV_8U"; + break; + case CV_8S: + s = "CV_8S"; + break; + case CV_16U: + s = "CV_16U"; + break; + case CV_16S: + s = "CV_16S"; + break; + case CV_32S: + s = "CV_32S"; + break; + case CV_32F: + s = "CV_32F"; + break; + case CV_64F: + s = "CV_64F"; + break; + case CV_USRTYPE1: + s = "CV_USRTYPE1"; + break; + default: + throw new java.lang.UnsupportedOperationException( + "Unsupported CvType value: " + type); } int ch = channels(type); - if(ch<=4) return s + "C" + ch; - else return s + "C(" + ch + ")"; + if (ch <= 4) + return s + "C" + ch; + else + return s + "C(" + ch + ")"; } } diff --git a/modules/java/src/java/core+Mat.java b/modules/java/src/java/core+Mat.java index 2a501a789..6a8c8dff5 100644 --- a/modules/java/src/java/core+Mat.java +++ b/modules/java/src/java/core+Mat.java @@ -5,1217 +5,1171 @@ package org.opencv.core; public class Mat { public final long nativeObj; - public Mat(long addr) - { - if(addr == 0) + + public Mat(long addr) + { + if (addr == 0) throw new java.lang.UnsupportedOperationException("Native object address is NULL"); nativeObj = addr; } - // - // C++: Mat::Mat() + // C++: Mat::Mat() // - //javadoc: Mat::Mat() - public Mat() + // javadoc: Mat::Mat() + public Mat() { - + nativeObj = n_Mat(); - + return; } - // - // C++: Mat::Mat(int rows, int cols, int type) + // C++: Mat::Mat(int rows, int cols, int type) // - //javadoc: Mat::Mat(rows, cols, type) - public Mat(int rows, int cols, int type) + // javadoc: Mat::Mat(rows, cols, type) + public Mat(int rows, int cols, int type) { - + nativeObj = n_Mat(rows, cols, type); - + return; } - // - // C++: Mat::Mat(Size size, int type) + // C++: Mat::Mat(Size size, int type) // - //javadoc: Mat::Mat(size, type) - public Mat(Size size, int type) + // javadoc: Mat::Mat(size, type) + public Mat(Size size, int type) { - + nativeObj = n_Mat(size.width, size.height, type); - + return; } - // - // C++: Mat::Mat(int rows, int cols, int type, Scalar s) + // C++: Mat::Mat(int rows, int cols, int type, Scalar s) // - //javadoc: Mat::Mat(rows, cols, type, s) - public Mat(int rows, int cols, int type, Scalar s) + // javadoc: Mat::Mat(rows, cols, type, s) + public Mat(int rows, int cols, int type, Scalar s) { - + nativeObj = n_Mat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]); - + return; } - // - // C++: Mat::Mat(Size size, int type, Scalar s) + // C++: Mat::Mat(Size size, int type, Scalar s) // - //javadoc: Mat::Mat(size, type, s) - public Mat(Size size, int type, Scalar s) + // javadoc: Mat::Mat(size, type, s) + public Mat(Size size, int type, Scalar s) { - + nativeObj = n_Mat(size.width, size.height, type, s.val[0], s.val[1], s.val[2], s.val[3]); - + return; } - // - // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all()) + // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all()) // - //javadoc: Mat::Mat(m, rowRange, colRange) - public Mat(Mat m, Range rowRange, Range colRange) + // javadoc: Mat::Mat(m, rowRange, colRange) + public Mat(Mat m, Range rowRange, Range colRange) { - + nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end); - + return; } - //javadoc: Mat::Mat(m, rowRange) - public Mat(Mat m, Range rowRange) + // javadoc: Mat::Mat(m, rowRange) + public Mat(Mat m, Range rowRange) { - + nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end); - + return; } - // - // C++: Mat::Mat(Mat m, Rect roi) + // C++: Mat::Mat(Mat m, Rect roi) // - //javadoc: Mat::Mat(m, roi) - public Mat(Mat m, Rect roi) + // javadoc: Mat::Mat(m, roi) + public Mat(Mat m, Rect roi) { - + nativeObj = n_Mat(m.nativeObj, roi.x, roi.y, roi.width, roi.height); - + return; } - // - // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright) + // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright) // - //javadoc: Mat::adjustROI(dtop, dbottom, dleft, dright) - public Mat adjustROI(int dtop, int dbottom, int dleft, int dright) + // javadoc: Mat::adjustROI(dtop, dbottom, dleft, dright) + public Mat adjustROI(int dtop, int dbottom, int dleft, int dright) { - + Mat retVal = new Mat(n_adjustROI(nativeObj, dtop, dbottom, dleft, dright)); - + return retVal; } - // - // C++: void Mat::assignTo(Mat m, int type = -1) + // C++: void Mat::assignTo(Mat m, int type = -1) // - //javadoc: Mat::assignTo(m, type) - public void assignTo(Mat m, int type) + // javadoc: Mat::assignTo(m, type) + public void assignTo(Mat m, int type) { - + n_assignTo(nativeObj, m.nativeObj, type); - + return; } - //javadoc: Mat::assignTo(m) - public void assignTo(Mat m) + // javadoc: Mat::assignTo(m) + public void assignTo(Mat m) { - + n_assignTo(nativeObj, m.nativeObj); - + return; } - // - // C++: int Mat::channels() + // C++: int Mat::channels() // - //javadoc: Mat::channels() - public int channels() + // javadoc: Mat::channels() + public int channels() { - + int retVal = n_channels(nativeObj); - + return retVal; } - // - // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true) + // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool + // requireContinuous = true) // - //javadoc: Mat::checkVector(elemChannels, depth, requireContinuous) - public int checkVector(int elemChannels, int depth, boolean requireContinuous) + // javadoc: Mat::checkVector(elemChannels, depth, requireContinuous) + public int checkVector(int elemChannels, int depth, boolean requireContinuous) { - + int retVal = n_checkVector(nativeObj, elemChannels, depth, requireContinuous); - + return retVal; } - //javadoc: Mat::checkVector(elemChannels, depth) - public int checkVector(int elemChannels, int depth) + // javadoc: Mat::checkVector(elemChannels, depth) + public int checkVector(int elemChannels, int depth) { - + int retVal = n_checkVector(nativeObj, elemChannels, depth); - + return retVal; } - //javadoc: Mat::checkVector(elemChannels) - public int checkVector(int elemChannels) + // javadoc: Mat::checkVector(elemChannels) + public int checkVector(int elemChannels) { - + int retVal = n_checkVector(nativeObj, elemChannels); - + return retVal; } - // - // C++: Mat Mat::clone() + // C++: Mat Mat::clone() // - //javadoc: Mat::clone() - public Mat clone() + // javadoc: Mat::clone() + public Mat clone() { - + Mat retVal = new Mat(n_clone(nativeObj)); - + return retVal; } - // - // C++: Mat Mat::col(int x) + // C++: Mat Mat::col(int x) // - //javadoc: Mat::col(x) - public Mat col(int x) + // javadoc: Mat::col(x) + public Mat col(int x) { - + Mat retVal = new Mat(n_col(nativeObj, x)); - + return retVal; } - // - // C++: Mat Mat::colRange(int startcol, int endcol) + // C++: Mat Mat::colRange(int startcol, int endcol) // - //javadoc: Mat::colRange(startcol, endcol) - public Mat colRange(int startcol, int endcol) + // javadoc: Mat::colRange(startcol, endcol) + public Mat colRange(int startcol, int endcol) { - + Mat retVal = new Mat(n_colRange(nativeObj, startcol, endcol)); - + return retVal; } - // - // C++: Mat Mat::colRange(Range r) + // C++: Mat Mat::colRange(Range r) // - //javadoc: Mat::colRange(r) - public Mat colRange(Range r) + // javadoc: Mat::colRange(r) + public Mat colRange(Range r) { - + Mat retVal = new Mat(n_colRange(nativeObj, r.start, r.end)); - + return retVal; } - // - // C++: int Mat::cols() + // C++: int Mat::cols() // - //javadoc: Mat::cols() - public int cols() + // javadoc: Mat::cols() + public int cols() { - + int retVal = n_cols(nativeObj); - + return retVal; } - // - // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0) + // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta + // = 0) // - //javadoc: Mat::convertTo(m, rtype, alpha, beta) - public void convertTo(Mat m, int rtype, double alpha, double beta) + // javadoc: Mat::convertTo(m, rtype, alpha, beta) + public void convertTo(Mat m, int rtype, double alpha, double beta) { - + n_convertTo(nativeObj, m.nativeObj, rtype, alpha, beta); - + return; } - //javadoc: Mat::convertTo(m, rtype, alpha) - public void convertTo(Mat m, int rtype, double alpha) + // javadoc: Mat::convertTo(m, rtype, alpha) + public void convertTo(Mat m, int rtype, double alpha) { - + n_convertTo(nativeObj, m.nativeObj, rtype, alpha); - + return; } - //javadoc: Mat::convertTo(m, rtype) - public void convertTo(Mat m, int rtype) + // javadoc: Mat::convertTo(m, rtype) + public void convertTo(Mat m, int rtype) { - + n_convertTo(nativeObj, m.nativeObj, rtype); - + return; } - // - // C++: void Mat::copyTo(Mat& m) + // C++: void Mat::copyTo(Mat& m) // - //javadoc: Mat::copyTo(m) - public void copyTo(Mat m) + // javadoc: Mat::copyTo(m) + public void copyTo(Mat m) { - + n_copyTo(nativeObj, m.nativeObj); - + return; } - // - // C++: void Mat::copyTo(Mat& m, Mat mask) + // C++: void Mat::copyTo(Mat& m, Mat mask) // - //javadoc: Mat::copyTo(m, mask) - public void copyTo(Mat m, Mat mask) + // javadoc: Mat::copyTo(m, mask) + public void copyTo(Mat m, Mat mask) { - + n_copyTo(nativeObj, m.nativeObj, mask.nativeObj); - + return; } - // - // C++: void Mat::create(int rows, int cols, int type) + // C++: void Mat::create(int rows, int cols, int type) // - //javadoc: Mat::create(rows, cols, type) - public void create(int rows, int cols, int type) + // javadoc: Mat::create(rows, cols, type) + public void create(int rows, int cols, int type) { - + n_create(nativeObj, rows, cols, type); - + return; } - // - // C++: void Mat::create(Size size, int type) + // C++: void Mat::create(Size size, int type) // - //javadoc: Mat::create(size, type) - public void create(Size size, int type) + // javadoc: Mat::create(size, type) + public void create(Size size, int type) { - + n_create(nativeObj, size.width, size.height, type); - + return; } - // - // C++: Mat Mat::cross(Mat m) + // C++: Mat Mat::cross(Mat m) // - //javadoc: Mat::cross(m) - public Mat cross(Mat m) + // javadoc: Mat::cross(m) + public Mat cross(Mat m) { - + Mat retVal = new Mat(n_cross(nativeObj, m.nativeObj)); - + return retVal; } - // - // C++: long Mat::dataAddr() + // C++: long Mat::dataAddr() // - //javadoc: Mat::dataAddr() - public long dataAddr() + // javadoc: Mat::dataAddr() + public long dataAddr() { - + long retVal = n_dataAddr(nativeObj); - + return retVal; } - // - // C++: int Mat::depth() + // C++: int Mat::depth() // - //javadoc: Mat::depth() - public int depth() + // javadoc: Mat::depth() + public int depth() { - + int retVal = n_depth(nativeObj); - + return retVal; } - // - // C++: Mat Mat::diag(int d = 0) + // C++: Mat Mat::diag(int d = 0) // - //javadoc: Mat::diag(d) - public Mat diag(int d) + // javadoc: Mat::diag(d) + public Mat diag(int d) { - + Mat retVal = new Mat(n_diag(nativeObj, d)); - + return retVal; } - //javadoc: Mat::diag() - public Mat diag() + // javadoc: Mat::diag() + public Mat diag() { - + Mat retVal = new Mat(n_diag(nativeObj, 0)); - + return retVal; } - // // C++: static Mat Mat::diag(Mat d) // - //javadoc: Mat::diag(d) + // javadoc: Mat::diag(d) public static Mat diag(Mat d) { - + Mat retVal = new Mat(n_diag(d.nativeObj)); - + return retVal; } - // - // C++: double Mat::dot(Mat m) + // C++: double Mat::dot(Mat m) // - //javadoc: Mat::dot(m) - public double dot(Mat m) + // javadoc: Mat::dot(m) + public double dot(Mat m) { - + double retVal = n_dot(nativeObj, m.nativeObj); - + return retVal; } - // - // C++: size_t Mat::elemSize() + // C++: size_t Mat::elemSize() // - //javadoc: Mat::elemSize() - public long elemSize() + // javadoc: Mat::elemSize() + public long elemSize() { - + long retVal = n_elemSize(nativeObj); - + return retVal; } - // - // C++: size_t Mat::elemSize1() + // C++: size_t Mat::elemSize1() // - //javadoc: Mat::elemSize1() - public long elemSize1() + // javadoc: Mat::elemSize1() + public long elemSize1() { - + long retVal = n_elemSize1(nativeObj); - + return retVal; } - // - // C++: bool Mat::empty() + // C++: bool Mat::empty() // - //javadoc: Mat::empty() - public boolean empty() + // javadoc: Mat::empty() + public boolean empty() { - + boolean retVal = n_empty(nativeObj); - + return retVal; } - // // C++: static Mat Mat::eye(int rows, int cols, int type) // - //javadoc: Mat::eye(rows, cols, type) + // javadoc: Mat::eye(rows, cols, type) public static Mat eye(int rows, int cols, int type) { - + Mat retVal = new Mat(n_eye(rows, cols, type)); - + return retVal; } - // // C++: static Mat Mat::eye(Size size, int type) // - //javadoc: Mat::eye(size, type) + // javadoc: Mat::eye(size, type) public static Mat eye(Size size, int type) { - + Mat retVal = new Mat(n_eye(size.width, size.height, type)); - + return retVal; } - // - // C++: Mat Mat::inv(int method = DECOMP_LU) + // C++: Mat Mat::inv(int method = DECOMP_LU) // - //javadoc: Mat::inv(method) - public Mat inv(int method) + // javadoc: Mat::inv(method) + public Mat inv(int method) { - + Mat retVal = new Mat(n_inv(nativeObj, method)); - + return retVal; } - //javadoc: Mat::inv() - public Mat inv() + // javadoc: Mat::inv() + public Mat inv() { - + Mat retVal = new Mat(n_inv(nativeObj)); - + return retVal; } - // - // C++: bool Mat::isContinuous() + // C++: bool Mat::isContinuous() // - //javadoc: Mat::isContinuous() - public boolean isContinuous() + // javadoc: Mat::isContinuous() + public boolean isContinuous() { - + boolean retVal = n_isContinuous(nativeObj); - + return retVal; } - // - // C++: bool Mat::isSubmatrix() + // C++: bool Mat::isSubmatrix() // - //javadoc: Mat::isSubmatrix() - public boolean isSubmatrix() + // javadoc: Mat::isSubmatrix() + public boolean isSubmatrix() { - + boolean retVal = n_isSubmatrix(nativeObj); - + return retVal; } - // - // C++: void Mat::locateROI(Size wholeSize, Point ofs) + // C++: void Mat::locateROI(Size wholeSize, Point ofs) // - //javadoc: Mat::locateROI(wholeSize, ofs) - public void locateROI(Size wholeSize, Point ofs) + // javadoc: Mat::locateROI(wholeSize, ofs) + public void locateROI(Size wholeSize, Point ofs) { - + n_locateROI(nativeObj, wholeSize.width, wholeSize.height, ofs.x, ofs.y); - + return; } - // - // C++: Mat Mat::mul(Mat m, double scale = 1) + // C++: Mat Mat::mul(Mat m, double scale = 1) // - //javadoc: Mat::mul(m, scale) - public Mat mul(Mat m, double scale) + // javadoc: Mat::mul(m, scale) + public Mat mul(Mat m, double scale) { - + Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj, scale)); - + return retVal; } - //javadoc: Mat::mul(m) - public Mat mul(Mat m) + // javadoc: Mat::mul(m) + public Mat mul(Mat m) { - + Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj)); - + return retVal; } - // // C++: static Mat Mat::ones(int rows, int cols, int type) // - //javadoc: Mat::ones(rows, cols, type) + // javadoc: Mat::ones(rows, cols, type) public static Mat ones(int rows, int cols, int type) { - + Mat retVal = new Mat(n_ones(rows, cols, type)); - + return retVal; } - // // C++: static Mat Mat::ones(Size size, int type) // - //javadoc: Mat::ones(size, type) + // javadoc: Mat::ones(size, type) public static Mat ones(Size size, int type) { - + Mat retVal = new Mat(n_ones(size.width, size.height, type)); - + return retVal; } - // - // C++: void Mat::push_back(Mat m) + // C++: void Mat::push_back(Mat m) // - //javadoc: Mat::push_back(m) - public void push_back(Mat m) + // javadoc: Mat::push_back(m) + public void push_back(Mat m) { - + n_push_back(nativeObj, m.nativeObj); - + return; } - // - // C++: void Mat::release() + // C++: void Mat::release() // - //javadoc: Mat::release() - public void release() + // javadoc: Mat::release() + public void release() { - + n_release(nativeObj); - + return; } - // - // C++: Mat Mat::reshape(int cn, int rows = 0) + // C++: Mat Mat::reshape(int cn, int rows = 0) // - //javadoc: Mat::reshape(cn, rows) - public Mat reshape(int cn, int rows) + // javadoc: Mat::reshape(cn, rows) + public Mat reshape(int cn, int rows) { - + Mat retVal = new Mat(n_reshape(nativeObj, cn, rows)); - + return retVal; } - //javadoc: Mat::reshape(cn) - public Mat reshape(int cn) + // javadoc: Mat::reshape(cn) + public Mat reshape(int cn) { - + Mat retVal = new Mat(n_reshape(nativeObj, cn)); - + return retVal; } - // - // C++: Mat Mat::row(int y) + // C++: Mat Mat::row(int y) // - //javadoc: Mat::row(y) - public Mat row(int y) + // javadoc: Mat::row(y) + public Mat row(int y) { - + Mat retVal = new Mat(n_row(nativeObj, y)); - + return retVal; } - // - // C++: Mat Mat::rowRange(int startrow, int endrow) + // C++: Mat Mat::rowRange(int startrow, int endrow) // - //javadoc: Mat::rowRange(startrow, endrow) - public Mat rowRange(int startrow, int endrow) + // javadoc: Mat::rowRange(startrow, endrow) + public Mat rowRange(int startrow, int endrow) { - + Mat retVal = new Mat(n_rowRange(nativeObj, startrow, endrow)); - + return retVal; } - // - // C++: Mat Mat::rowRange(Range r) + // C++: Mat Mat::rowRange(Range r) // - //javadoc: Mat::rowRange(r) - public Mat rowRange(Range r) + // javadoc: Mat::rowRange(r) + public Mat rowRange(Range r) { - + Mat retVal = new Mat(n_rowRange(nativeObj, r.start, r.end)); - + return retVal; } - // - // C++: int Mat::rows() + // C++: int Mat::rows() // - //javadoc: Mat::rows() - public int rows() + // javadoc: Mat::rows() + public int rows() { - + int retVal = n_rows(nativeObj); - + return retVal; } - // - // C++: Mat Mat::operator =(Scalar s) + // C++: Mat Mat::operator =(Scalar s) // - //javadoc: Mat::operator =(s) - public Mat setTo(Scalar s) + // javadoc: Mat::operator =(s) + public Mat setTo(Scalar s) { - + Mat retVal = new Mat(n_setTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3])); - + return retVal; } - // - // C++: Mat Mat::setTo(Mat value, Mat mask = Mat()) + // C++: Mat Mat::setTo(Mat value, Mat mask = Mat()) // - //javadoc: Mat::setTo(value, mask) - public Mat setTo(Mat value, Mat mask) + // javadoc: Mat::setTo(value, mask) + public Mat setTo(Mat value, Mat mask) { - + Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj, mask.nativeObj)); - + return retVal; } - //javadoc: Mat::setTo(value) - public Mat setTo(Mat value) + // javadoc: Mat::setTo(value) + public Mat setTo(Mat value) { - + Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj)); - + return retVal; } - // - // C++: Size Mat::size() + // C++: Size Mat::size() // - //javadoc: Mat::size() - public Size size() + // javadoc: Mat::size() + public Size size() { - + Size retVal = new Size(n_size(nativeObj)); - + return retVal; } - // - // C++: size_t Mat::step1(int i = 0) + // C++: size_t Mat::step1(int i = 0) // - //javadoc: Mat::step1(i) - public long step1(int i) + // javadoc: Mat::step1(i) + public long step1(int i) { - + long retVal = n_step1(nativeObj, i); - + return retVal; } - //javadoc: Mat::step1() - public long step1() + // javadoc: Mat::step1() + public long step1() { - + long retVal = n_step1(nativeObj); - + return retVal; } - // - // C++: Mat Mat::operator()(int rowStart, int rowEnd, int colStart, int colEnd) + // C++: Mat Mat::operator()(int rowStart, int rowEnd, int colStart, int + // colEnd) // - //javadoc: Mat::operator()(rowStart, rowEnd, colStart, colEnd) - public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) + // javadoc: Mat::operator()(rowStart, rowEnd, colStart, colEnd) + public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) { - + Mat retVal = new Mat(n_submat_rr(nativeObj, rowStart, rowEnd, colStart, colEnd)); - + return retVal; } - // - // C++: Mat Mat::operator()(Range rowRange, Range colRange) + // C++: Mat Mat::operator()(Range rowRange, Range colRange) // - //javadoc: Mat::operator()(rowRange, colRange) - public Mat submat(Range rowRange, Range colRange) + // javadoc: Mat::operator()(rowRange, colRange) + public Mat submat(Range rowRange, Range colRange) { - + Mat retVal = new Mat(n_submat_rr(nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end)); - + return retVal; } - // - // C++: Mat Mat::operator()(Rect roi) + // C++: Mat Mat::operator()(Rect roi) // - //javadoc: Mat::operator()(roi) - public Mat submat(Rect roi) + // javadoc: Mat::operator()(roi) + public Mat submat(Rect roi) { - + Mat retVal = new Mat(n_submat(nativeObj, roi.x, roi.y, roi.width, roi.height)); - + return retVal; } - // - // C++: Mat Mat::t() + // C++: Mat Mat::t() // - //javadoc: Mat::t() - public Mat t() + // javadoc: Mat::t() + public Mat t() { - + Mat retVal = new Mat(n_t(nativeObj)); - + return retVal; } - // - // C++: size_t Mat::total() + // C++: size_t Mat::total() // - //javadoc: Mat::total() - public long total() + // javadoc: Mat::total() + public long total() { - + long retVal = n_total(nativeObj); - + return retVal; } - // - // C++: int Mat::type() + // C++: int Mat::type() // - //javadoc: Mat::type() - public int type() + // javadoc: Mat::type() + public int type() { - + int retVal = n_type(nativeObj); - + return retVal; } - // // C++: static Mat Mat::zeros(int rows, int cols, int type) // - //javadoc: Mat::zeros(rows, cols, type) + // javadoc: Mat::zeros(rows, cols, type) public static Mat zeros(int rows, int cols, int type) { - + Mat retVal = new Mat(n_zeros(rows, cols, type)); - + return retVal; } - // // C++: static Mat Mat::zeros(Size size, int type) // - //javadoc: Mat::zeros(size, type) + // javadoc: Mat::zeros(size, type) public static Mat zeros(Size size, int type) { - + Mat retVal = new Mat(n_zeros(size.width, size.height, type)); - + return retVal; } - @Override protected void finalize() throws Throwable { n_delete(nativeObj); super.finalize(); } - - //javadoc:Mat::toString() + + // javadoc:Mat::toString() @Override public String toString() { - return "Mat [ " + + return "Mat [ " + rows() + "*" + cols() + "*" + CvType.typeToString(type()) + ", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() + - ", nativeObj=0x" + Long.toHexString(nativeObj) + - ", dataAddr=0x" + Long.toHexString(dataAddr()) + + ", nativeObj=0x" + Long.toHexString(nativeObj) + + ", dataAddr=0x" + Long.toHexString(dataAddr()) + " ]"; } - //javadoc:Mat::dump() + // javadoc:Mat::dump() public String dump() { return nDump(nativeObj); } - - //javadoc:Mat::put(row,col,data) - public int put(int row, int col, double...data) { + + // javadoc:Mat::put(row,col,data) + public int put(int row, int col, double... data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - return nPutD(nativeObj, row, col, data.length, data); + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + return nPutD(nativeObj, row, col, data.length, data); } - //javadoc:Mat::put(row,col,data) + // javadoc:Mat::put(row,col,data) public int put(int row, int col, float[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_32F) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_32F) { return nPutF(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - //javadoc:Mat::put(row,col,data) + // javadoc:Mat::put(row,col,data) public int put(int row, int col, int[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_32S) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_32S) { return nPutI(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - - //javadoc:Mat::put(row,col,data) + + // javadoc:Mat::put(row,col,data) public int put(int row, int col, short[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) { return nPutS(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - - //javadoc:Mat::put(row,col,data) + + // javadoc:Mat::put(row,col,data) public int put(int row, int col, byte[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) { return nPutB(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - - //javadoc:Mat::get(row,col,data) + + // javadoc:Mat::get(row,col,data) public int get(int row, int col, byte[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_8U || CvType.depth(t) == CvType.CV_8S) { return nGetB(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - //javadoc:Mat::get(row,col,data) + // javadoc:Mat::get(row,col,data) public int get(int row, int col, short[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_16U || CvType.depth(t) == CvType.CV_16S) { return nGetS(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - //javadoc:Mat::get(row,col,data) + // javadoc:Mat::get(row,col,data) public int get(int row, int col, int[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_32S) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_32S) { return nGetI(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - //javadoc:Mat::get(row,col,data) + // javadoc:Mat::get(row,col,data) public int get(int row, int col, float[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_32F) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_32F) { return nGetF(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - //javadoc:Mat::get(row,col,data) + // javadoc:Mat::get(row,col,data) public int get(int row, int col, double[] data) { int t = type(); - if(data == null || data.length % CvType.channels(t) != 0) - throw new java.lang.UnsupportedOperationException( - "Provided data element number (" + - (data == null ? 0 : data.length) + - ") should be multiple of the Mat channels count (" + - CvType.channels(t) + ")"); - if(CvType.depth(t) == CvType.CV_64F) { + if (data == null || data.length % CvType.channels(t) != 0) + throw new java.lang.UnsupportedOperationException( + "Provided data element number (" + + (data == null ? 0 : data.length) + + ") should be multiple of the Mat channels count (" + + CvType.channels(t) + ")"); + if (CvType.depth(t) == CvType.CV_64F) { return nGetD(nativeObj, row, col, data.length, data); } throw new java.lang.UnsupportedOperationException("Mat data type is not compatible: " + t); } - //javadoc:Mat::get(row,col) + // javadoc:Mat::get(row,col) public double[] get(int row, int col) { return nGet(nativeObj, row, col); } - //javadoc:Mat::height() - public int height() { - return rows(); - } - - //javadoc:Mat::width() - public int width() { - return cols(); + // javadoc:Mat::height() + public int height() { + return rows(); } - //javadoc:Mat::getNativeObjAddr() + // javadoc:Mat::width() + public int width() { + return cols(); + } + + // javadoc:Mat::getNativeObjAddr() public long getNativeObjAddr() { return nativeObj; } - // // native stuff // - static { System.loadLibrary("opencv_java"); } + static { + System.loadLibrary("opencv_java"); + } - // C++: Mat::Mat() + // C++: Mat::Mat() private static native long n_Mat(); - // C++: Mat::Mat(int rows, int cols, int type) + // C++: Mat::Mat(int rows, int cols, int type) private static native long n_Mat(int rows, int cols, int type); - // C++: Mat::Mat(Size size, int type) + // C++: Mat::Mat(Size size, int type) private static native long n_Mat(double size_width, double size_height, int type); - // C++: Mat::Mat(int rows, int cols, int type, Scalar s) + // C++: Mat::Mat(int rows, int cols, int type, Scalar s) private static native long n_Mat(int rows, int cols, int type, double s_val0, double s_val1, double s_val2, double s_val3); - // C++: Mat::Mat(Size size, int type, Scalar s) + // C++: Mat::Mat(Size size, int type, Scalar s) private static native long n_Mat(double size_width, double size_height, int type, double s_val0, double s_val1, double s_val2, double s_val3); - // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all()) + // C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all()) private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end); + private static native long n_Mat(long m_nativeObj, int rowRange_start, int rowRange_end); - // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright) + // C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright) private static native long n_adjustROI(long nativeObj, int dtop, int dbottom, int dleft, int dright); - // C++: void Mat::assignTo(Mat m, int type = -1) + // C++: void Mat::assignTo(Mat m, int type = -1) private static native void n_assignTo(long nativeObj, long m_nativeObj, int type); + private static native void n_assignTo(long nativeObj, long m_nativeObj); - // C++: int Mat::channels() + // C++: int Mat::channels() private static native int n_channels(long nativeObj); - // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true) + // C++: int Mat::checkVector(int elemChannels, int depth = -1, bool + // requireContinuous = true) private static native int n_checkVector(long nativeObj, int elemChannels, int depth, boolean requireContinuous); + private static native int n_checkVector(long nativeObj, int elemChannels, int depth); + private static native int n_checkVector(long nativeObj, int elemChannels); - // C++: Mat Mat::clone() + // C++: Mat Mat::clone() private static native long n_clone(long nativeObj); - // C++: Mat Mat::col(int x) + // C++: Mat Mat::col(int x) private static native long n_col(long nativeObj, int x); - // C++: Mat Mat::colRange(int startcol, int endcol) + // C++: Mat Mat::colRange(int startcol, int endcol) private static native long n_colRange(long nativeObj, int startcol, int endcol); - // C++: int Mat::cols() + // C++: int Mat::cols() private static native int n_cols(long nativeObj); - // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta = 0) + // C++: void Mat::convertTo(Mat& m, int rtype, double alpha = 1, double beta + // = 0) private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha, double beta); + private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype, double alpha); + private static native void n_convertTo(long nativeObj, long m_nativeObj, int rtype); - // C++: void Mat::copyTo(Mat& m) + // C++: void Mat::copyTo(Mat& m) private static native void n_copyTo(long nativeObj, long m_nativeObj); - // C++: void Mat::copyTo(Mat& m, Mat mask) + // C++: void Mat::copyTo(Mat& m, Mat mask) private static native void n_copyTo(long nativeObj, long m_nativeObj, long mask_nativeObj); - // C++: void Mat::create(int rows, int cols, int type) + // C++: void Mat::create(int rows, int cols, int type) private static native void n_create(long nativeObj, int rows, int cols, int type); - // C++: void Mat::create(Size size, int type) + // C++: void Mat::create(Size size, int type) private static native void n_create(long nativeObj, double size_width, double size_height, int type); - // C++: Mat Mat::cross(Mat m) + // C++: Mat Mat::cross(Mat m) private static native long n_cross(long nativeObj, long m_nativeObj); - // C++: long Mat::dataAddr() + // C++: long Mat::dataAddr() private static native long n_dataAddr(long nativeObj); - // C++: int Mat::depth() + // C++: int Mat::depth() private static native int n_depth(long nativeObj); - // C++: Mat Mat::diag(int d = 0) + // C++: Mat Mat::diag(int d = 0) private static native long n_diag(long nativeObj, int d); // C++: static Mat Mat::diag(Mat d) private static native long n_diag(long d_nativeObj); - // C++: double Mat::dot(Mat m) + // C++: double Mat::dot(Mat m) private static native double n_dot(long nativeObj, long m_nativeObj); - // C++: size_t Mat::elemSize() + // C++: size_t Mat::elemSize() private static native long n_elemSize(long nativeObj); - // C++: size_t Mat::elemSize1() + // C++: size_t Mat::elemSize1() private static native long n_elemSize1(long nativeObj); - // C++: bool Mat::empty() + // C++: bool Mat::empty() private static native boolean n_empty(long nativeObj); // C++: static Mat Mat::eye(int rows, int cols, int type) @@ -1224,21 +1178,23 @@ public class Mat { // C++: static Mat Mat::eye(Size size, int type) private static native long n_eye(double size_width, double size_height, int type); - // C++: Mat Mat::inv(int method = DECOMP_LU) + // C++: Mat Mat::inv(int method = DECOMP_LU) private static native long n_inv(long nativeObj, int method); + private static native long n_inv(long nativeObj); - // C++: bool Mat::isContinuous() + // C++: bool Mat::isContinuous() private static native boolean n_isContinuous(long nativeObj); - // C++: bool Mat::isSubmatrix() + // C++: bool Mat::isSubmatrix() private static native boolean n_isSubmatrix(long nativeObj); - // C++: void Mat::locateROI(Size wholeSize, Point ofs) + // C++: void Mat::locateROI(Size wholeSize, Point ofs) private static native void n_locateROI(long nativeObj, double wholeSize_width, double wholeSize_height, double ofs_x, double ofs_y); - // C++: Mat Mat::mul(Mat m, double scale = 1) + // C++: Mat Mat::mul(Mat m, double scale = 1) private static native long n_mul(long nativeObj, long m_nativeObj, double scale); + private static native long n_mul(long nativeObj, long m_nativeObj); // C++: static Mat Mat::ones(int rows, int cols, int type) @@ -1247,52 +1203,55 @@ public class Mat { // C++: static Mat Mat::ones(Size size, int type) private static native long n_ones(double size_width, double size_height, int type); - // C++: void Mat::push_back(Mat m) + // C++: void Mat::push_back(Mat m) private static native void n_push_back(long nativeObj, long m_nativeObj); - // C++: void Mat::release() + // C++: void Mat::release() private static native void n_release(long nativeObj); - // C++: Mat Mat::reshape(int cn, int rows = 0) + // C++: Mat Mat::reshape(int cn, int rows = 0) private static native long n_reshape(long nativeObj, int cn, int rows); + private static native long n_reshape(long nativeObj, int cn); - // C++: Mat Mat::row(int y) + // C++: Mat Mat::row(int y) private static native long n_row(long nativeObj, int y); - // C++: Mat Mat::rowRange(int startrow, int endrow) + // C++: Mat Mat::rowRange(int startrow, int endrow) private static native long n_rowRange(long nativeObj, int startrow, int endrow); - // C++: int Mat::rows() + // C++: int Mat::rows() private static native int n_rows(long nativeObj); - // C++: Mat Mat::operator =(Scalar s) + // C++: Mat Mat::operator =(Scalar s) private static native long n_setTo(long nativeObj, double s_val0, double s_val1, double s_val2, double s_val3); - // C++: Mat Mat::setTo(Mat value, Mat mask = Mat()) + // C++: Mat Mat::setTo(Mat value, Mat mask = Mat()) private static native long n_setTo(long nativeObj, long value_nativeObj, long mask_nativeObj); + private static native long n_setTo(long nativeObj, long value_nativeObj); - // C++: Size Mat::size() + // C++: Size Mat::size() private static native double[] n_size(long nativeObj); - // C++: size_t Mat::step1(int i = 0) + // C++: size_t Mat::step1(int i = 0) private static native long n_step1(long nativeObj, int i); + private static native long n_step1(long nativeObj); - - // C++: Mat Mat::operator()(Range rowRange, Range colRange) + + // C++: Mat Mat::operator()(Range rowRange, Range colRange) private static native long n_submat_rr(long nativeObj, int rowRange_start, int rowRange_end, int colRange_start, int colRange_end); - // C++: Mat Mat::operator()(Rect roi) + // C++: Mat Mat::operator()(Rect roi) private static native long n_submat(long nativeObj, int roi_x, int roi_y, int roi_width, int roi_height); - // C++: Mat Mat::t() + // C++: Mat Mat::t() private static native long n_t(long nativeObj); - // C++: size_t Mat::total() + // C++: size_t Mat::total() private static native long n_total(long nativeObj); - // C++: int Mat::type() + // C++: int Mat::type() private static native int n_type(long nativeObj); // C++: static Mat Mat::zeros(int rows, int cols, int type) @@ -1303,18 +1262,28 @@ public class Mat { // native support for java finalize() private static native void n_delete(long nativeObj); - - + private static native int nPutD(long self, int row, int col, int count, double[] data); + private static native int nPutF(long self, int row, int col, int count, float[] data); + private static native int nPutI(long self, int row, int col, int count, int[] data); + private static native int nPutS(long self, int row, int col, int count, short[] data); + private static native int nPutB(long self, int row, int col, int count, byte[] data); + private static native int nGetB(long self, int row, int col, int count, byte[] vals); + private static native int nGetS(long self, int row, int col, int count, short[] vals); + private static native int nGetI(long self, int row, int col, int count, int[] vals); + private static native int nGetF(long self, int row, int col, int count, float[] vals); + private static native int nGetD(long self, int row, int col, int count, double[] vals); + private static native double[] nGet(long self, int row, int col); + private static native String nDump(long self); } diff --git a/modules/java/src/java/core+Point.java b/modules/java/src/java/core+Point.java index 667b9f86d..d850860f7 100644 --- a/modules/java/src/java/core+Point.java +++ b/modules/java/src/java/core+Point.java @@ -18,17 +18,17 @@ public class Point { this(); set(vals); } + public void set(double[] vals) { - if(vals!=null) { - x = vals.length>0 ? vals[0] : 0; - y = vals.length>1 ? vals[1] : 0; + if (vals != null) { + x = vals.length > 0 ? vals[0] : 0; + y = vals.length > 1 ? vals[1] : 0; } else { x = 0; y = 0; - } + } } - public Point clone() { return new Point(x, y); } @@ -52,7 +52,7 @@ public class Point { @Override public boolean equals(Object obj) { if (this == obj) return true; - if ( ! (obj instanceof Point) ) return false; + if (!(obj instanceof Point)) return false; Point it = (Point) obj; return x == it.x && y == it.y; } @@ -61,10 +61,8 @@ public class Point { return r.contains(this); } - @Override public String toString() { - if (this == null) return "null"; return "{" + x + ", " + y + "}"; } } diff --git a/modules/java/src/java/core+Point3.java b/modules/java/src/java/core+Point3.java index 33cd44189..948a550f1 100644 --- a/modules/java/src/java/core+Point3.java +++ b/modules/java/src/java/core+Point3.java @@ -25,16 +25,17 @@ public class Point3 { this(); set(vals); } + public void set(double[] vals) { - if(vals!=null) { - x = vals.length>0 ? vals[0] : 0; - y = vals.length>1 ? vals[1] : 0; - z = vals.length>2 ? vals[2] : 0; + if (vals != null) { + x = vals.length > 0 ? vals[0] : 0; + y = vals.length > 1 ? vals[1] : 0; + z = vals.length > 2 ? vals[2] : 0; } else { x = 0; y = 0; z = 0; - } + } } public Point3 clone() { @@ -70,4 +71,9 @@ public class Point3 { Point3 it = (Point3) obj; return x == it.x && y == it.y && z == it.z; } + + @Override + public String toString() { + return "{" + x + ", " + y + ", " + z + "}"; + } } diff --git a/modules/java/src/java/core+Range.java b/modules/java/src/java/core+Range.java index 826b6e873..429ba7805 100644 --- a/modules/java/src/java/core+Range.java +++ b/modules/java/src/java/core+Range.java @@ -2,7 +2,7 @@ package org.opencv.core; //javadoc:Range public class Range { - + public int start, end; public Range(int s, int e) { @@ -13,31 +13,32 @@ public class Range { public Range() { this(0, 0); } + public Range(double[] vals) { - this(); set(vals); } + public void set(double[] vals) { - if(vals!=null) { - start = vals.length>0 ? (int)vals[0] : 0; - end = vals.length>1 ? (int)vals[1] : 0; + if (vals != null) { + start = vals.length > 0 ? (int) vals[0] : 0; + end = vals.length > 1 ? (int) vals[1] : 0; } else { start = 0; - end = 0; - } + end = 0; + } } public int size() { - return end-start; + return empty() ? 0 : end - start; } public boolean empty() { - return start==end; + return end <= start; } public static Range all() { - return new Range(Integer.MIN_VALUE , Integer.MAX_VALUE); + return new Range(Integer.MIN_VALUE, Integer.MAX_VALUE); } public Range intersection(Range r1) { @@ -45,15 +46,15 @@ public class Range { r.end = Math.max(r.end, r.start); return r; } + public Range shift(int delta) { - return new Range(start+delta, end+delta); + return new Range(start + delta, end + delta); } - - + public Range clone() { return new Range(start, end); } - + @Override public int hashCode() { final int prime = 31; @@ -76,7 +77,6 @@ public class Range { @Override public String toString() { - if (this == null) return "null"; return "[" + start + ", " + end + ")"; } } diff --git a/modules/java/src/java/core+Rect.java b/modules/java/src/java/core+Rect.java index 53499d03f..a2c28bee7 100644 --- a/modules/java/src/java/core+Rect.java +++ b/modules/java/src/java/core+Rect.java @@ -24,25 +24,25 @@ public class Rect { } public Rect(Point p, Size s) { - this((int)p.x, (int)p.y, (int)s.width, (int)s.height); + this((int) p.x, (int) p.y, (int) s.width, (int) s.height); } public Rect(double[] vals) { - this(); set(vals); } + public void set(double[] vals) { - if(vals!=null) { - x = vals.length>0 ? (int)vals[0] : 0; - y = vals.length>1 ? (int)vals[1] : 0; - width = vals.length>2 ? (int)vals[2] : 0; - height = vals.length>3 ? (int)vals[3] : 0; + if (vals != null) { + x = vals.length > 0 ? (int) vals[0] : 0; + y = vals.length > 1 ? (int) vals[1] : 0; + width = vals.length > 2 ? (int) vals[2] : 0; + height = vals.length > 3 ? (int) vals[3] : 0; } else { - x = 0; - y = 0; - width = 0; + x = 0; + y = 0; + width = 0; height = 0; - } + } } public Rect clone() { @@ -95,7 +95,6 @@ public class Rect { @Override public String toString() { - if (this == null) return "null"; - return "{" + x + ", " + y + ", " + width + "x" + height+"}"; + return "{" + x + ", " + y + ", " + width + "x" + height + "}"; } } diff --git a/modules/java/src/java/core+RotatedRect.java b/modules/java/src/java/core+RotatedRect.java index c60bd2731..023a4cb69 100644 --- a/modules/java/src/java/core+RotatedRect.java +++ b/modules/java/src/java/core+RotatedRect.java @@ -23,54 +23,54 @@ public class RotatedRect { this(); set(vals); } - + public void set(double[] vals) { - if(vals!=null) { - center.x = vals.length>0 ? (double)vals[0] : 0; - center.y = vals.length>1 ? (double)vals[1] : 0; - size.width = vals.length>2 ? (double)vals[2] : 0; - size.height = vals.length>3 ? (double)vals[3] : 0; - angle = vals.length>4 ? (double)vals[4] : 0; + if (vals != null) { + center.x = vals.length > 0 ? (double) vals[0] : 0; + center.y = vals.length > 1 ? (double) vals[1] : 0; + size.width = vals.length > 2 ? (double) vals[2] : 0; + size.height = vals.length > 3 ? (double) vals[3] : 0; + angle = vals.length > 4 ? (double) vals[4] : 0; } else { - center.x = 0; - center.x = 0; - size.width = 0; + center.x = 0; + center.x = 0; + size.width = 0; size.height = 0; - angle = 0; + angle = 0; } } public void points(Point pt[]) { - double _angle = angle*Math.PI/180.0; - double b = (double)Math.cos(_angle)*0.5f; - double a = (double)Math.sin(_angle)*0.5f; + double _angle = angle * Math.PI / 180.0; + double b = (double) Math.cos(_angle) * 0.5f; + double a = (double) Math.sin(_angle) * 0.5f; pt[0] = new Point( - center.x - a*size.height - b*size.width, - center.y + b*size.height - a*size.width); + center.x - a * size.height - b * size.width, + center.y + b * size.height - a * size.width); pt[1] = new Point( - center.x + a*size.height - b*size.width, - center.y - b*size.height - a*size.width); + center.x + a * size.height - b * size.width, + center.y - b * size.height - a * size.width); pt[2] = new Point( - 2*center.x - pt[0].x, - 2*center.y - pt[0].y); + 2 * center.x - pt[0].x, + 2 * center.y - pt[0].y); pt[3] = new Point( - 2*center.x - pt[1].x, - 2*center.y - pt[1].y); + 2 * center.x - pt[1].x, + 2 * center.y - pt[1].y); } public Rect boundingRect() { Point pt[] = new Point[4]; points(pt); - Rect r=new Rect((int)Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), - (int)Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)), - (int)Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), - (int)Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y))); + Rect r = new Rect((int) Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), + (int) Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)), + (int) Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), + (int) Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y))); r.width -= r.x - 1; r.height -= r.y - 1; return r; @@ -105,4 +105,9 @@ public class RotatedRect { RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; } + + @Override + public String toString() { + return "{ " + center + " " + size + " * " + angle + " }"; + } } diff --git a/modules/java/src/java/core+Scalar.java b/modules/java/src/java/core+Scalar.java index 6c45c15c1..72bfc58cf 100644 --- a/modules/java/src/java/core+Scalar.java +++ b/modules/java/src/java/core+Scalar.java @@ -6,34 +6,40 @@ public class Scalar { public double val[]; public Scalar(double v0, double v1, double v2, double v3) { - this.val = new double[] {v0, v1, v2, v3}; + val = new double[] { v0, v1, v2, v3 }; } public Scalar(double v0, double v1, double v2) { - this.val = new double[] {v0, v1, v2, 0}; + val = new double[] { v0, v1, v2, 0 }; } public Scalar(double v0, double v1) { - this.val = new double[] {v0, v1, 0, 0}; + val = new double[] { v0, v1, 0, 0 }; } public Scalar(double v0) { - this.val = new double[] {v0, 0, 0, 0}; + val = new double[] { v0, 0, 0, 0 }; } public Scalar(double[] vals) { - this.val = new double[4]; - set(vals); - } - public void set(double[] vals) { - if(vals!=null) { - this.val[0] = vals.length>0 ? vals[0] : 0; - this.val[1] = vals.length>1 ? vals[1] : 0; - this.val[2] = vals.length>2 ? vals[2] : 0; - this.val[3] = vals.length>3 ? vals[3] : 0; + if (vals != null && vals.length == 4) + val = vals.clone(); + else { + val = new double[4]; + set(vals); } } + public void set(double[] vals) { + if (vals != null) { + val[0] = vals.length > 0 ? vals[0] : 0; + val[1] = vals.length > 1 ? vals[1] : 0; + val[2] = vals.length > 2 ? vals[2] : 0; + val[3] = vals.length > 3 ? vals[3] : 0; + } else + val[0] = val[1] = val[2] = val[3] = 0; + } + public static Scalar all(double v) { return new Scalar(v, v, v, v); } @@ -43,13 +49,14 @@ public class Scalar { } public Scalar mul(Scalar it, double scale) { - return new Scalar( val[0] * it.val[0] * scale, val[1] * it.val[1] * scale, - val[2] * it.val[2] * scale, val[3] * it.val[3] * scale ); + return new Scalar(val[0] * it.val[0] * scale, val[1] * it.val[1] * scale, + val[2] * it.val[2] * scale, val[3] * it.val[3] * scale); } public Scalar mul(Scalar it) { return mul(it, 1); } + public Scalar conj() { return new Scalar(val[0], -val[1], -val[2], -val[3]); } @@ -58,22 +65,26 @@ public class Scalar { return val[1] == 0 && val[2] == 0 && val[3] == 0; } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + java.util.Arrays.hashCode(val); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + java.util.Arrays.hashCode(val); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (!(obj instanceof Scalar)) return false; - Scalar it = (Scalar) obj; - if (!java.util.Arrays.equals(val, it.val)) return false; - return true; - } + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (!(obj instanceof Scalar)) return false; + Scalar it = (Scalar) obj; + if (!java.util.Arrays.equals(val, it.val)) return false; + return true; + } + + @Override + public String toString() { + return "[" + val[0] + ", " + val[1] + ", " + val[2] + ", " + val[3] + "]"; + } - } diff --git a/modules/java/src/java/core+Size.java b/modules/java/src/java/core+Size.java index 23ce4cd80..5747a43a5 100644 --- a/modules/java/src/java/core+Size.java +++ b/modules/java/src/java/core+Size.java @@ -15,20 +15,20 @@ public class Size { } public Size(Point p) { - width = (double) p.x; - height = (double) p.y; + width = p.x; + height = p.y; } public Size(double[] vals) { - this(); set(vals); } + public void set(double[] vals) { - if(vals!=null) { - width = vals.length>0 ? vals[0] : 0; - height = vals.length>1 ? vals[1] : 0; + if (vals != null) { + width = vals.length > 0 ? vals[0] : 0; + height = vals.length > 1 ? vals[1] : 0; } else { - width = 0; + width = 0; height = 0; } } @@ -61,4 +61,9 @@ public class Size { return width == it.width && height == it.height; } + @Override + public String toString() { + return (int)width + "x" + (int)height; + } + } diff --git a/modules/java/src/java/core+TermCriteria.java b/modules/java/src/java/core+TermCriteria.java index 7458b6150..1717883d1 100644 --- a/modules/java/src/java/core+TermCriteria.java +++ b/modules/java/src/java/core+TermCriteria.java @@ -3,33 +3,59 @@ package org.opencv.core; //javadoc:TermCriteria public class TermCriteria { + /** + * the maximum number of iterations or elements to compute + */ + public static final int COUNT = 1; + /** + * the maximum number of iterations or elements to compute + */ + public static final int MAX_ITER = COUNT; + /** + * the desired accuracy or change in parameters at which the iterative algorithm stops + */ + public static final int EPS = 2; + public int type; public int maxCount; public double epsilon; - public TermCriteria(int t, int c, double e) { - this.type = t; - this.maxCount = c; - this.epsilon = e; + /** + * Termination criteria in iterative algorithms + * + * @param type + * the type of termination criteria: COUNT, EPS or COUNT + EPS + * @param maxCount + * the maximum number of iterations/elements + * @param epsilon + * the desired accuracy + */ + public TermCriteria(int type, int maxCount, double epsilon) { + this.type = type; + this.maxCount = maxCount; + this.epsilon = epsilon; } + /** + * Termination criteria in iterative algorithms + */ public TermCriteria() { this(0, 0, 0.0); } public TermCriteria(double[] vals) { - this(); set(vals); } + public void set(double[] vals) { - if(vals!=null) { - type = vals.length>0 ? (int)vals[0] : 0; - maxCount = vals.length>1 ? (int)vals[1] : 0; - epsilon = vals.length>2 ? (double)vals[2] : 0; + if (vals != null) { + type = vals.length > 0 ? (int) vals[0] : 0; + maxCount = vals.length > 1 ? (int) vals[1] : 0; + epsilon = vals.length > 2 ? (double) vals[2] : 0; } else { - type = 0; - maxCount = 0; - epsilon = 0; + type = 0; + maxCount = 0; + epsilon = 0; } } @@ -56,7 +82,7 @@ public class TermCriteria { if (this == obj) return true; if (!(obj instanceof TermCriteria)) return false; TermCriteria it = (TermCriteria) obj; - return type == it.type && maxCount == it.maxCount && epsilon== it.epsilon; + return type == it.type && maxCount == it.maxCount && epsilon == it.epsilon; } @Override diff --git a/modules/java/src/java/features2d+DMatch.java b/modules/java/src/java/features2d+DMatch.java index 9ecc80c6b..96914c51d 100644 --- a/modules/java/src/java/features2d+DMatch.java +++ b/modules/java/src/java/features2d+DMatch.java @@ -1,50 +1,61 @@ package org.opencv.features2d; //C++: class DMatch -//javadoc: DMatch + +/** + * Struct for matching: query descriptor index, train descriptor index, train + * image index and distance between descriptors. + */ public class DMatch { - - //javadoc: DMatch::queryIdx - public int queryIdx; - //javadoc: DMatch::trainIdx - public int trainIdx; - //javadoc: DMatch::imgIdx - public int imgIdx; - //javadoc: DMatch::distance - public float distance; - - - //javadoc: DMatch::DMatch() + + /** + * query descriptor index + */ + public int queryIdx; + /** + * train descriptor index + */ + public int trainIdx; + /** + * train image index + */ + public int imgIdx; + + // javadoc: DMatch::distance + public float distance; + + // javadoc: DMatch::DMatch() public DMatch() { - this(-1, -1, Float.MAX_VALUE); - } - - - public DMatch( int _queryIdx, int _trainIdx, float _distance ) { - queryIdx = _queryIdx; - trainIdx = _trainIdx; - imgIdx = -1; - distance = _distance; - } - - - public DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) { - queryIdx = _queryIdx; - trainIdx = _trainIdx; - imgIdx = _imgIdx; - distance = _distance; + this(-1, -1, Float.MAX_VALUE); } - // less is better + // javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _distance) + public DMatch(int _queryIdx, int _trainIdx, float _distance) { + queryIdx = _queryIdx; + trainIdx = _trainIdx; + imgIdx = -1; + distance = _distance; + } + + // javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _imgIdx, _distance) + public DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) { + queryIdx = _queryIdx; + trainIdx = _trainIdx; + imgIdx = _imgIdx; + distance = _distance; + } + + /** + * less is better + */ boolean lessThan(DMatch it) { return distance < it.distance; } - - @Override - public String toString() { - return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx - + ", imgIdx=" + imgIdx + ", distance=" + distance + "]"; - } + @Override + public String toString() { + return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx + + ", imgIdx=" + imgIdx + ", distance=" + distance + "]"; + } } diff --git a/modules/java/src/java/features2d+KeyPoint.java b/modules/java/src/java/features2d+KeyPoint.java index 373a57f85..f141cd16f 100644 --- a/modules/java/src/java/features2d+KeyPoint.java +++ b/modules/java/src/java/features2d+KeyPoint.java @@ -4,66 +4,80 @@ import org.opencv.core.Point; //javadoc: KeyPoint public class KeyPoint { - - //javadoc: KeyPoint::pt - public Point pt; - //javadoc: KeyPoint::size - public float size; - //javadoc: KeyPoint::angle - public float angle; - //javadoc: KeyPoint::response - public float response; - //javadoc: KeyPoint::octave - public int octave; - //javadoc: KeyPoint::class_id - public int class_id; - //javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave, _class_id) + /** + * coordinates of the keypoint + */ + public Point pt; + /** + * diameter of the meaningful keypoint neighborhood + */ + public float size; + /** + * computed orientation of the keypoint (-1 if not applicable) + */ + public float angle; + /** + * the response by which the most strong keypoints have been selected. Can + * be used for further sorting or subsampling + */ + public float response; + /** + * octave (pyramid layer) from which the keypoint has been extracted + */ + public int octave; + /** + * object id that can be used to clustered keypoints by an object they + * belong to + */ + public int class_id; + + // javadoc:KeyPoint::KeyPoint(x,y,_size,_angle,_response,_octave,_class_id) public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) { - pt = new Point(x, y); - size = _size; - angle = _angle; - response = _response; - octave = _octave; - class_id = _class_id; + pt = new Point(x, y); + size = _size; + angle = _angle; + response = _response; + octave = _octave; + class_id = _class_id; } - //javadoc: KeyPoint::KeyPoint() + // javadoc: KeyPoint::KeyPoint() public KeyPoint() { - this(0, 0, 0, -1, 0, 0, -1); + this(0, 0, 0, -1, 0, 0, -1); } - //javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave) + // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave) public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave) { - this(x, y, _size, _angle, _response, _octave, -1); + this(x, y, _size, _angle, _response, _octave, -1); } - //javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response) + // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response) public KeyPoint(float x, float y, float _size, float _angle, float _response) { - this(x, y, _size, _angle, _response, 0, -1); + this(x, y, _size, _angle, _response, 0, -1); } - //javadoc: KeyPoint::KeyPoint(x, y, _size, _angle) + // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle) public KeyPoint(float x, float y, float _size, float _angle) { - this(x, y, _size, _angle, 0, 0, -1); + this(x, y, _size, _angle, 0, 0, -1); } - //javadoc: KeyPoint::KeyPoint(x, y, _size) + // javadoc: KeyPoint::KeyPoint(x, y, _size) public KeyPoint(float x, float y, float _size) { - this(x, y, _size, -1, 0, 0, -1); + this(x, y, _size, -1, 0, 0, -1); } - @Override - public String toString() { - return "KeyPoint [pt=" + pt + ", size=" + size + ", angle=" + angle - + ", response=" + response + ", octave=" + octave - + ", class_id=" + class_id + "]"; - } + @Override + public String toString() { + return "KeyPoint [pt=" + pt + ", size=" + size + ", angle=" + angle + + ", response=" + response + ", octave=" + octave + + ", class_id=" + class_id + "]"; + } } diff --git a/modules/java/src/java/highgui+VideoCapture.java b/modules/java/src/java/highgui+VideoCapture.java index c6cf5b08d..9540f58e8 100644 --- a/modules/java/src/java/highgui+VideoCapture.java +++ b/modules/java/src/java/highgui+VideoCapture.java @@ -11,172 +11,183 @@ import org.opencv.core.Size; public class VideoCapture { protected final long nativeObj; - protected VideoCapture(long addr) { nativeObj = addr; } + protected VideoCapture(long addr) { + nativeObj = addr; + } // - // C++: VideoCapture::VideoCapture() + // C++: VideoCapture::VideoCapture() // - //javadoc: VideoCapture::VideoCapture() - public VideoCapture() + // javadoc: VideoCapture::VideoCapture() + public VideoCapture() { - + nativeObj = n_VideoCapture(); - + return; } - // - // C++: VideoCapture::VideoCapture(int device) + // C++: VideoCapture::VideoCapture(int device) // - //javadoc: VideoCapture::VideoCapture(device) - public VideoCapture(int device) + // javadoc: VideoCapture::VideoCapture(device) + public VideoCapture(int device) { - + nativeObj = n_VideoCapture(device); - + return; } - - // - // C++: double VideoCapture::get(int propId) + // C++: double VideoCapture::get(int propId) // - //javadoc: VideoCapture::get(propId) - public double get(int propId) +/** + * Returns the specified "VideoCapture" property + * + * Note: When querying a property that is not supported by the backend used by + * the "VideoCapture" class, value 0 is returned. + * + * @param propId Property identifier. It can be one of the following: + * * CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream. + * * CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream. + * + * @see org.opencv.highgui.VideoCapture.get + */ + public double get(int propId) { - + double retVal = n_get(nativeObj, propId); - + return retVal; } - public List getSupportedPreviewSizes() + public List getSupportedPreviewSizes() { String[] sizes_str = n_getSupportedPreviewSizes(nativeObj).split(","); List sizes = new LinkedList(); - for(String str : sizes_str){ + for (String str : sizes_str) { String[] wh = str.split("x"); sizes.add(new Size(Double.parseDouble(wh[0]), Double.parseDouble(wh[1]))); } - + return sizes; } - // - // C++: bool VideoCapture::grab() + // C++: bool VideoCapture::grab() // - //javadoc: VideoCapture::grab() - public boolean grab() + // javadoc: VideoCapture::grab() + public boolean grab() { - + boolean retVal = n_grab(nativeObj); - + return retVal; } - // - // C++: bool VideoCapture::isOpened() + // C++: bool VideoCapture::isOpened() // - //javadoc: VideoCapture::isOpened() - public boolean isOpened() + // javadoc: VideoCapture::isOpened() + public boolean isOpened() { - + boolean retVal = n_isOpened(nativeObj); - + return retVal; } - // - // C++: bool VideoCapture::open(int device) + // C++: bool VideoCapture::open(int device) // - //javadoc: VideoCapture::open(device) - public boolean open(int device) + // javadoc: VideoCapture::open(device) + public boolean open(int device) { - + boolean retVal = n_open(nativeObj, device); - + return retVal; } - // - // C++: bool VideoCapture::read(Mat image) + // C++: bool VideoCapture::read(Mat image) // - //javadoc: VideoCapture::read(image) - public boolean read(Mat image) + // javadoc: VideoCapture::read(image) + public boolean read(Mat image) { - + boolean retVal = n_read(nativeObj, image.nativeObj); - + return retVal; } - // - // C++: void VideoCapture::release() + // C++: void VideoCapture::release() // - //javadoc: VideoCapture::release() - public void release() + // javadoc: VideoCapture::release() + public void release() { - + n_release(nativeObj); - + return; } - // - // C++: bool VideoCapture::retrieve(Mat image, int channel = 0) + // C++: bool VideoCapture::retrieve(Mat image, int channel = 0) // - //javadoc: VideoCapture::retrieve(image, channel) - public boolean retrieve(Mat image, int channel) + // javadoc: VideoCapture::retrieve(image, channel) + public boolean retrieve(Mat image, int channel) { - + boolean retVal = n_retrieve(nativeObj, image.nativeObj, channel); - + return retVal; } - //javadoc: VideoCapture::retrieve(image) - public boolean retrieve(Mat image) + // javadoc: VideoCapture::retrieve(image) + public boolean retrieve(Mat image) { - + boolean retVal = n_retrieve(nativeObj, image.nativeObj); - + return retVal; } - // - // C++: bool VideoCapture::set(int propId, double value) + // C++: bool VideoCapture::set(int propId, double value) // - //javadoc: VideoCapture::set(propId, value) - public boolean set(int propId, double value) +/** + * Sets a property in the "VideoCapture". + * + * @param propId Property identifier. It can be one of the following: + * * CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream. + * * CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream. + * @param value Value of the property. + * + * @see org.opencv.highgui.VideoCapture.set + */ + public boolean set(int propId, double value) { - + boolean retVal = n_set(nativeObj, propId, value); - + return retVal; } - @Override protected void finalize() throws Throwable { n_delete(nativeObj); @@ -185,43 +196,46 @@ public class VideoCapture { // native stuff - static { System.loadLibrary("opencv_java"); } + static { + System.loadLibrary("opencv_java"); + } - // C++: VideoCapture::VideoCapture() + // C++: VideoCapture::VideoCapture() private static native long n_VideoCapture(); - // C++: VideoCapture::VideoCapture(string filename) + // C++: VideoCapture::VideoCapture(string filename) private static native long n_VideoCapture(java.lang.String filename); - // C++: VideoCapture::VideoCapture(int device) + // C++: VideoCapture::VideoCapture(int device) private static native long n_VideoCapture(int device); - // C++: double VideoCapture::get(int propId) + // C++: double VideoCapture::get(int propId) private static native double n_get(long nativeObj, int propId); - // C++: bool VideoCapture::grab() + // C++: bool VideoCapture::grab() private static native boolean n_grab(long nativeObj); - // C++: bool VideoCapture::isOpened() + // C++: bool VideoCapture::isOpened() private static native boolean n_isOpened(long nativeObj); - // C++: bool VideoCapture::open(string filename) + // C++: bool VideoCapture::open(string filename) private static native boolean n_open(long nativeObj, java.lang.String filename); - // C++: bool VideoCapture::open(int device) + // C++: bool VideoCapture::open(int device) private static native boolean n_open(long nativeObj, int device); - // C++: bool VideoCapture::read(Mat image) + // C++: bool VideoCapture::read(Mat image) private static native boolean n_read(long nativeObj, long image_nativeObj); - // C++: void VideoCapture::release() + // C++: void VideoCapture::release() private static native void n_release(long nativeObj); - // C++: bool VideoCapture::retrieve(Mat image, int channel = 0) + // C++: bool VideoCapture::retrieve(Mat image, int channel = 0) private static native boolean n_retrieve(long nativeObj, long image_nativeObj, int channel); + private static native boolean n_retrieve(long nativeObj, long image_nativeObj); - // C++: bool VideoCapture::set(int propId, double value) + // C++: bool VideoCapture::set(int propId, double value) private static native boolean n_set(long nativeObj, int propId, double value); private static native String n_getSupportedPreviewSizes(long nativeObj); diff --git a/modules/java/src/java/utils+Converters.java b/modules/java/src/java/utils+Converters.java index ab691ac54..b871f350c 100644 --- a/modules/java/src/java/utils+Converters.java +++ b/modules/java/src/java/utils+Converters.java @@ -27,50 +27,47 @@ public class Converters { public static Mat vector_Point_to_Mat(List pts, int typeDepth) { Mat res; - int count = (pts!=null) ? pts.size() : 0; - if(count>0){ + int count = (pts != null) ? pts.size() : 0; + if (count > 0) { switch (typeDepth) { - case CvType.CV_32S: - { - res = new Mat(count, 1, CvType.CV_32SC2); - int[] buff = new int[count*2]; - for(int i=0; i pts) { return vector_Point3_to_Mat(pts, CvType.CV_32S); } @@ -93,53 +89,50 @@ public class Converters { public static Mat vector_Point3_to_Mat(List pts, int typeDepth) { Mat res; - int count = (pts!=null) ? pts.size() : 0; - if(count>0){ - switch (typeDepth){ - case CvType.CV_32S: - { - res = new Mat(count, 1, CvType.CV_32SC3); - int[] buff = new int[count*3]; - for(int i=0; i 0) { + switch (typeDepth) { + case CvType.CV_32S: { + res = new Mat(count, 1, CvType.CV_32SC3); + int[] buff = new int[count * 3]; + for (int i = 0; i < count; i++) { + Point3 p = pts.get(i); + buff[i * 3] = (int) p.x; + buff[i * 3 + 1] = (int) p.y; + buff[i * 3 + 2] = (int) p.z; } + res.put(0, 0, buff); + } break; - case CvType.CV_32F: - { - res = new Mat(count, 1, CvType.CV_32FC3); - float[] buff = new float[count*3]; - for(int i=0; i pts) { Mat_to_vector_Point(m, pts); } + public static void Mat_to_vector_Point(Mat m, List pts) { - if(pts == null) + if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); int count = m.rows(); int type = m.type(); - if(m.cols() != 1) - throw new java.lang.IllegalArgumentException( "Input Mat should have one column\n" + m ); + if (m.cols() != 1) + throw new java.lang.IllegalArgumentException("Input Mat should have one column\n" + m); pts.clear(); - if(type == CvType.CV_32SC2) { - int[] buff = new int[2*count]; + if (type == CvType.CV_32SC2) { + int[] buff = new int[2 * count]; m.get(0, 0, buff); - for(int i=0; i pts) { Mat_to_vector_Point3(m, pts); } + public static void Mat_to_vector_Point3f(Mat m, List pts) { Mat_to_vector_Point3(m, pts); } @@ -197,49 +192,50 @@ public class Converters { public static void Mat_to_vector_Point3d(Mat m, List pts) { Mat_to_vector_Point3(m, pts); } + public static void Mat_to_vector_Point3(Mat m, List pts) { - if(pts == null) + if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); int count = m.rows(); int type = m.type(); - if(m.cols() != 1) - throw new java.lang.IllegalArgumentException( "Input Mat should have one column\n" + m ); + if (m.cols() != 1) + throw new java.lang.IllegalArgumentException("Input Mat should have one column\n" + m); pts.clear(); - if(type == CvType.CV_32SC3) { - int[] buff = new int[3*count]; + if (type == CvType.CV_32SC3) { + int[] buff = new int[3 * count]; m.get(0, 0, buff); - for(int i=0; i mats) { Mat res; - int count = (mats!=null) ? mats.size() : 0; - if(count>0){ + int count = (mats != null) ? mats.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_32SC2); - int[] buff = new int[count*2]; - for(int i=0; i> 32); - buff[i*2+1] = (int)(addr & 0xffffffff); + buff[i * 2] = (int) (addr >> 32); + buff[i * 2 + 1] = (int) (addr & 0xffffffff); } res.put(0, 0, buff); } else { @@ -249,31 +245,31 @@ public class Converters { } public static void Mat_to_vector_Mat(Mat m, List mats) { - if(mats == null) + if (mats == null) throw new java.lang.IllegalArgumentException("mats == null"); int count = m.rows(); - if( CvType.CV_32SC2 != m.type() || m.cols()!=1 ) + if (CvType.CV_32SC2 != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_32SC2 != m.type() || m.cols()!=1\n" + m); mats.clear(); - int[] buff = new int[count*2]; + int[] buff = new int[count * 2]; m.get(0, 0, buff); - for(int i=0; i fs) { Mat res; - int count = (fs!=null) ? fs.size() : 0; - if(count>0){ + int count = (fs != null) ? fs.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_32FC1); float[] buff = new float[count]; - for(int i=0; i fs) { - if(fs == null) + if (fs == null) throw new java.lang.IllegalArgumentException("fs == null"); int count = m.rows(); - if( CvType.CV_32FC1 != m.type() || m.cols()!=1 ) + if (CvType.CV_32FC1 != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_32FC1 != m.type() || m.cols()!=1\n" + m); fs.clear(); float[] buff = new float[count]; m.get(0, 0, buff); - for(int i=0; i bs) { Mat res; - int count = (bs!=null) ? bs.size() : 0; - if(count>0){ + int count = (bs != null) ? bs.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_8UC1); byte[] buff = new byte[count]; - for(int i=0; i us) { - if(us == null) + if (us == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); int count = m.rows(); - if( CvType.CV_8UC1 != m.type() || m.cols()!=1 ) + if (CvType.CV_8UC1 != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_8UC1 != m.type() || m.cols()!=1\n" + m); us.clear(); byte[] buff = new byte[count]; m.get(0, 0, buff); - for(int i=0; i bs) { Mat res; - int count = (bs!=null) ? bs.size() : 0; - if(count>0){ + int count = (bs != null) ? bs.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_8SC1); byte[] buff = new byte[count]; - for(int i=0; i is) { Mat res; - int count = (is!=null) ? is.size() : 0; - if(count>0){ + int count = (is != null) ? is.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_32SC1); int[] buff = new int[count]; - for(int i=0; i is) { - if(is == null) + if (is == null) throw new java.lang.IllegalArgumentException("is == null"); int count = m.rows(); - if( CvType.CV_32SC1 != m.type() || m.cols()!=1 ) + if (CvType.CV_32SC1 != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_32SC1 != m.type() || m.cols()!=1\n" + m); is.clear(); int[] buff = new int[count]; m.get(0, 0, buff); - for(int i=0; i bs) { - if(bs == null) + if (bs == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); int count = m.rows(); - if( CvType.CV_8SC1 != m.type() || m.cols()!=1 ) + if (CvType.CV_8SC1 != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_8SC1 != m.type() || m.cols()!=1\n" + m); bs.clear(); byte[] buff = new byte[count]; m.get(0, 0, buff); - for(int i=0; i rs) { Mat res; - int count = (rs!=null) ? rs.size() : 0; - if(count>0){ + int count = (rs != null) ? rs.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_32SC4); - int[] buff = new int[4*count]; - for(int i=0; i rs) { - if(rs == null) + if (rs == null) throw new java.lang.IllegalArgumentException("rs == null"); int count = m.rows(); - if(CvType.CV_32SC4 != m.type() || m.cols()!=1 ) + if (CvType.CV_32SC4 != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_32SC4 != m.type() || m.rows()!=1\n" + m); rs.clear(); - int[] buff = new int[4*count]; + int[] buff = new int[4 * count]; m.get(0, 0, buff); - for(int i=0; i kps) { Mat res; - int count = (kps!=null) ? kps.size() : 0; - if(count>0){ + int count = (kps != null) ? kps.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_64FC(7)); double[] buff = new double[count * 7]; - for(int i=0; i kps) { - if(kps == null) + if (kps == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); int count = m.rows(); - if( CvType.CV_64FC(7) != m.type() || m.cols()!=1 ) + if (CvType.CV_64FC(7) != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_64FC(7) != m.type() || m.cols()!=1\n" + m); kps.clear(); - double[] buff = new double[7*count]; + double[] buff = new double[7 * count]; m.get(0, 0, buff); - for(int i=0; i> pts) { + Mat res; + int lCount = (pts != null) ? pts.size() : 0; + if (lCount > 0) { + List mats = new ArrayList(lCount); + for (List lpt : pts) + mats.add(vector_Point_to_Mat(lpt)); + res = vector_Mat_to_Mat(mats); + } else { + res = new Mat(); + } + return res; + } // vector_vector_KeyPoint public static Mat vector_vector_KeyPoint_to_Mat(List> kps) { Mat res; - int lCount = (kps!=null) ? kps.size() : 0; - if(lCount>0){ + int lCount = (kps != null) ? kps.size() : 0; + if (lCount > 0) { List mats = new ArrayList(lCount); - for(List lkp: kps) mats.add( vector_KeyPoint_to_Mat(lkp) ); + for (List lkp : kps) + mats.add(vector_KeyPoint_to_Mat(lkp)); res = vector_Mat_to_Mat(mats); } else { res = new Mat(); @@ -490,31 +500,30 @@ public class Converters { } public static void Mat_to_vector_vector_KeyPoint(Mat m, List> kps) { - if(kps == null) + if (kps == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); - if(m == null) + if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List mats = new ArrayList(m.rows()); Mat_to_vector_Mat(m, mats); List lkp = new ArrayList(); - for(Mat mi : mats) { + for (Mat mi : mats) { Mat_to_vector_KeyPoint(mi, lkp); kps.add(lkp); } } - public static Mat vector_double_to_Mat(List ds) { Mat res; - int count = (ds!=null) ? ds.size() : 0; - if(count>0){ + int count = (ds != null) ? ds.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_64FC1); double[] buff = new double[count]; - for(int i=0; i matches) { Mat res; - int count = (matches!=null) ? matches.size() : 0; - if(count>0){ + int count = (matches != null) ? matches.size() : 0; + if (count > 0) { res = new Mat(count, 1, CvType.CV_64FC4); double[] buff = new double[count * 4]; - for(int i=0; i matches) { - if(matches == null) + if (matches == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); int count = m.rows(); - if( CvType.CV_64FC4 != m.type() || m.cols()!=1 ) + if (CvType.CV_64FC4 != m.type() || m.cols() != 1) throw new java.lang.IllegalArgumentException( "CvType.CV_64FC4 != m.type() || m.cols()!=1\n" + m); matches.clear(); - double[] buff = new double[4*count]; + double[] buff = new double[4 * count]; m.get(0, 0, buff); - for(int i=0; i> lldm) { - Mat res; - int lCount = (lldm!=null) ? lldm.size() : 0; - if(lCount>0){ - List mats = new ArrayList(lCount); - for(List ldm: lldm) mats.add( vector_DMatch_to_Mat(ldm) ); - res = vector_Mat_to_Mat(mats); - } else { - res = new Mat(); + // vector_vector_DMatch + public static Mat vector_vector_DMatch_to_Mat(List> lldm) { + Mat res; + int lCount = (lldm != null) ? lldm.size() : 0; + if (lCount > 0) { + List mats = new ArrayList(lCount); + for (List ldm : lldm) + mats.add(vector_DMatch_to_Mat(ldm)); + res = vector_Mat_to_Mat(mats); + } else { + res = new Mat(); + } + return res; } - return res; -} -public static void Mat_to_vector_vector_DMatch(Mat m, List> lldm) { - if(lldm == null) - throw new java.lang.IllegalArgumentException("Output List can't be null"); + public static void Mat_to_vector_vector_DMatch(Mat m, List> lldm) { + if (lldm == null) + throw new java.lang.IllegalArgumentException("Output List can't be null"); - if(m == null) - throw new java.lang.IllegalArgumentException("Input Mat can't be null"); + if (m == null) + throw new java.lang.IllegalArgumentException("Input Mat can't be null"); - List mats = new ArrayList(m.rows()); - Mat_to_vector_Mat(m, mats); - List ldm = new ArrayList(); - for(Mat mi : mats) { - Mat_to_vector_DMatch(mi, ldm); - lldm.add(ldm); + List mats = new ArrayList(m.rows()); + Mat_to_vector_Mat(m, mats); + List ldm = new ArrayList(); + for (Mat mi : mats) { + Mat_to_vector_DMatch(mi, ldm); + lldm.add(ldm); + } } -} -//vector_vector_char -public static Mat vector_vector_char_to_Mat(List> llb) { - Mat res; - int lCount = (llb!=null) ? llb.size() : 0; - if(lCount>0){ - List mats = new ArrayList(lCount); - for(List lb: llb) mats.add( vector_char_to_Mat(lb) ); - res = vector_Mat_to_Mat(mats); - } else { - res = new Mat(); - } - return res; -} + // vector_vector_char + public static Mat vector_vector_char_to_Mat(List> llb) { + Mat res; + int lCount = (llb != null) ? llb.size() : 0; + if (lCount > 0) { + List mats = new ArrayList(lCount); + for (List lb : llb) + mats.add(vector_char_to_Mat(lb)); + res = vector_Mat_to_Mat(mats); + } else { + res = new Mat(); + } + return res; + } -public static void Mat_to_vector_vector_char(Mat m, List> llb) { - if(llb == null) - throw new java.lang.IllegalArgumentException("Output List can't be null"); + public static void Mat_to_vector_vector_char(Mat m, List> llb) { + if (llb == null) + throw new java.lang.IllegalArgumentException("Output List can't be null"); - if(m == null) - throw new java.lang.IllegalArgumentException("Input Mat can't be null"); + if (m == null) + throw new java.lang.IllegalArgumentException("Input Mat can't be null"); - List mats = new ArrayList(m.rows()); - Mat_to_vector_Mat(m, mats); - List lb = new ArrayList(); - for(Mat mi : mats) { - Mat_to_vector_char(mi, lb); - llb.add(lb); - } -} + List mats = new ArrayList(m.rows()); + Mat_to_vector_Mat(m, mats); + List lb = new ArrayList(); + for (Mat mi : mats) { + Mat_to_vector_char(mi, lb); + llb.add(lb); + } + } }