Java API:

* fixed manually ported classes;
* added vector<vector<Point>> support;
* changed argument types for 3 functions;
* finished tests for org.opencv.core.Core class.
This commit is contained in:
Andrey Kamaev 2011-08-06 09:22:07 +00:00
parent 6d9075812f
commit 1991440cf7
28 changed files with 1769 additions and 1365 deletions

View File

@ -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: <channels info>_[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 {

View File

@ -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 <a href="http://opencv.itseez.com">OpenCV</a>
*/
@ -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<TestCase> testCases = androidTestRunner.getTestCases();
// Collections.shuffle(testCases); //shuffle the tests order

View File

@ -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 {
@ -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<Point> lp = new ArrayList<Point>(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<Point> 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<Point> lp = new ArrayList<Point>(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<Point> polyline = Arrays.asList(new Point(1, 1), new Point(5, 0), new Point(6, 8), new Point(0, 9));
Core.fillConvexPoly(gray0, polyline, new Scalar(150), Core.LINE_8);
Core.fillConvexPoly(gray0, polyline, new Scalar(0), Core.LINE_4);
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<Point> lp = new ArrayList<Point>();
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<Point> polyline1 = Arrays.asList(new Point(1, 1), new Point(5, 1), new Point(5, 8), new Point(1, 8));
List<Point> 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<Point> lp2 = new ArrayList<Point>();
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<Point> polyline = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
List<List<Point>> polylines = new ArrayList<List<Point>>();
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<Point> polyline = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(9, 3));
List<List<Point>> polylines = new ArrayList<List<Point>>();
polylines.add(polyline);
Core.fillPoly(gray0, polylines, new Scalar(1), Core.LINE_8);
Core.fillPoly(gray0, polylines, new Scalar(0), Core.LINE_4);
assertTrue(0 < Core.countNonZero(gray0));
}
public void testFillPolyMatListOfMatScalarIntInt() {
fail("Not yet implemented");
public void testFillPolyMatListOfListOfPointScalarIntInt() {
List<Point> polyline1 = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
List<Point> polyline2 = Arrays.asList(new Point(2, 8), new Point(2, 16), new Point(8, 2), new Point(14, 16), new Point(14, 8));
List<List<Point>> polylines1 = new ArrayList<List<Point>>();
polylines1.add(polyline1);
List<List<Point>> polylines2 = new ArrayList<List<Point>>();
polylines2.add(polyline2);
Core.fillPoly(gray0, polylines1, new Scalar(1), Core.LINE_8, 0);
assertTrue(0 < Core.countNonZero(gray0));
Core.fillPoly(gray0, polylines2, new Scalar(0), Core.LINE_8, 1);
assertEquals(0, Core.countNonZero(gray0));
}
public void testFillPolyMatListOfMatScalarIntIntPoint() {
fail("Not yet implemented");
public void testFillPolyMatListOfListOfPointScalarIntIntPoint() {
List<Point> polyline1 = Arrays.asList(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
List<Point> polyline2 = Arrays.asList(new Point(0, 3), new Point(0, 7), new Point(3, 0), new Point(6, 7), new Point(6, 3));
List<List<Point>> polylines1 = new ArrayList<List<Point>>();
polylines1.add(polyline1);
List<List<Point>> polylines2 = new ArrayList<List<Point>>();
polylines2.add(polyline2);
Core.fillPoly(gray0, polylines1, new Scalar(1), Core.LINE_8, 0, 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<Point> pts = new ArrayList<Point>();
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<Mat> mats = new ArrayList<Mat>();
mats.add(Converters.vector_Point_to_Mat(pts));
assertEquals(0, Core.countNonZero(img));
Core.polylines(img, mats, true, new Scalar(100));
List<List<Point>> polyline = new ArrayList<List<Point>>();
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<Point> pts = new ArrayList<Point>();
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<Mat> mats = new ArrayList<Mat>();
mats.add(Converters.vector_Point_to_Mat(pts));
assertEquals(0, Core.countNonZero(img));
Core.polylines(img, mats, true, new Scalar(100), 2);
List<List<Point>> polyline = new ArrayList<List<Point>>();
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<Point> pts = new ArrayList<Point>();
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<Mat> mats = new ArrayList<Mat>();
mats.add(Converters.vector_Point_to_Mat(pts));
assertEquals(0, Core.countNonZero(img));
Core.polylines(img, mats, true, new Scalar(100), 2, 8);
List<List<Point>> polyline = new ArrayList<List<Point>>();
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<Point> pts = new ArrayList<Point>();
List<Point> pts2 = new ArrayList<Point>();
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<Mat> mats = new ArrayList<Mat>();
List<Mat> mats2 = new ArrayList<Mat>();
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<List<Point>> polyline1 = new ArrayList<List<Point>>();
polyline1.add(Arrays.asList(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
List<List<Point>> polyline2 = new ArrayList<List<Point>>();
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() {
@ -1479,20 +1704,53 @@ public class CoreTest extends OpenCVTestCase {
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
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() {
@ -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() {

View File

@ -97,4 +97,11 @@ public class Point3Test extends OpenCVTestCase {
assertEquals(10., p1.z);
}
public void testToString() {
String actual = p1.toString();
String expected = "{2.0, 2.0, 2.0}";
assertEquals(expected, actual);
}
}

View File

@ -166,4 +166,10 @@ public class RotatedRectTest extends OpenCVTestCase {
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);
}
}

View File

@ -101,4 +101,10 @@ public class ScalarTest extends OpenCVTestCase {
assertEquals(s2, s1);
}
public void testToString() {
String actual = s2.toString();
String expected = "[1.0, 1.0, 1.0, 1.0]";
assertEquals(expected, actual);
}
}

View File

@ -84,4 +84,10 @@ public class SizeTest extends OpenCVTestCase {
assertEquals(4.0, sz1.height);
}
public void testToString() {
String actual = sz1.toString();
String expected = "10x10";
assertEquals(expected, actual);
}
}

View File

@ -291,4 +291,8 @@ public class ConvertersTest extends OpenCVTestCase {
fail("Not yet implemented");
}
public void testVector_vector_Point_to_Mat() {
fail("Not yet implemented");
}
}

View File

@ -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":
@ -203,6 +209,7 @@ type_dict = {
"vector_vector_KeyPoint": { "j_type" : "List<List<KeyPoint>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<KeyPoint> > %(n)s" },
"vector_vector_DMatch" : { "j_type" : "List<List<DMatch>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<DMatch> > %(n)s" },
"vector_vector_char" : { "j_type" : "List<List<Byte>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<char> > %(n)s" },
"vector_vector_Point" : { "j_type" : "List<List<Point>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<Point> > %(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

View File

@ -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()

View File

@ -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());

View File

@ -264,6 +264,19 @@ void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat)
}
}
void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point> 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<Mat> vm;

View File

@ -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);

View File

@ -1,10 +1,10 @@
package org.opencv.core;
public final class CvType {
// type depth constants
public static final int CV_8U = 0, CV_8S = 1,
public static final int
CV_8U = 0, CV_8S = 1,
CV_16U = 2, CV_16S = 3,
CV_32S = 4,
CV_32F = 5,
@ -35,26 +35,45 @@ public final class CvType {
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)) {
@ -99,13 +118,19 @@ public final class CvType {
case CV_64F:
s = "CV_64F";
break;
default:
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 + ")";
}
}

View File

@ -5,6 +5,7 @@ package org.opencv.core;
public class Mat {
public final long nativeObj;
public Mat(long addr)
{
if (addr == 0)
@ -12,7 +13,6 @@ public class Mat {
nativeObj = addr;
}
//
// C++: Mat::Mat()
//
@ -26,7 +26,6 @@ public class Mat {
return;
}
//
// C++: Mat::Mat(int rows, int cols, int type)
//
@ -40,7 +39,6 @@ public class Mat {
return;
}
//
// C++: Mat::Mat(Size size, int type)
//
@ -54,7 +52,6 @@ public class Mat {
return;
}
//
// C++: Mat::Mat(int rows, int cols, int type, Scalar s)
//
@ -68,7 +65,6 @@ public class Mat {
return;
}
//
// C++: Mat::Mat(Size size, int type, Scalar s)
//
@ -82,7 +78,6 @@ public class Mat {
return;
}
//
// C++: Mat::Mat(Mat m, Range rowRange, Range colRange = Range::all())
//
@ -105,7 +100,6 @@ public class Mat {
return;
}
//
// C++: Mat::Mat(Mat m, Rect roi)
//
@ -119,7 +113,6 @@ public class Mat {
return;
}
//
// C++: Mat Mat::adjustROI(int dtop, int dbottom, int dleft, int dright)
//
@ -133,7 +126,6 @@ public class Mat {
return retVal;
}
//
// C++: void Mat::assignTo(Mat m, int type = -1)
//
@ -156,7 +148,6 @@ public class Mat {
return;
}
//
// C++: int Mat::channels()
//
@ -170,9 +161,9 @@ public class Mat {
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)
@ -202,7 +193,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::clone()
//
@ -216,7 +206,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::col(int x)
//
@ -230,7 +219,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::colRange(int startcol, int endcol)
//
@ -244,7 +232,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::colRange(Range r)
//
@ -258,7 +245,6 @@ public class Mat {
return retVal;
}
//
// C++: int Mat::cols()
//
@ -272,9 +258,9 @@ public class Mat {
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)
@ -304,7 +290,6 @@ public class Mat {
return;
}
//
// C++: void Mat::copyTo(Mat& m)
//
@ -318,7 +303,6 @@ public class Mat {
return;
}
//
// C++: void Mat::copyTo(Mat& m, Mat mask)
//
@ -332,7 +316,6 @@ public class Mat {
return;
}
//
// C++: void Mat::create(int rows, int cols, int type)
//
@ -346,7 +329,6 @@ public class Mat {
return;
}
//
// C++: void Mat::create(Size size, int type)
//
@ -360,7 +342,6 @@ public class Mat {
return;
}
//
// C++: Mat Mat::cross(Mat m)
//
@ -374,7 +355,6 @@ public class Mat {
return retVal;
}
//
// C++: long Mat::dataAddr()
//
@ -388,7 +368,6 @@ public class Mat {
return retVal;
}
//
// C++: int Mat::depth()
//
@ -402,7 +381,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::diag(int d = 0)
//
@ -425,7 +403,6 @@ public class Mat {
return retVal;
}
//
// C++: static Mat Mat::diag(Mat d)
//
@ -439,7 +416,6 @@ public class Mat {
return retVal;
}
//
// C++: double Mat::dot(Mat m)
//
@ -453,7 +429,6 @@ public class Mat {
return retVal;
}
//
// C++: size_t Mat::elemSize()
//
@ -467,7 +442,6 @@ public class Mat {
return retVal;
}
//
// C++: size_t Mat::elemSize1()
//
@ -481,7 +455,6 @@ public class Mat {
return retVal;
}
//
// C++: bool Mat::empty()
//
@ -495,7 +468,6 @@ public class Mat {
return retVal;
}
//
// C++: static Mat Mat::eye(int rows, int cols, int type)
//
@ -509,7 +481,6 @@ public class Mat {
return retVal;
}
//
// C++: static Mat Mat::eye(Size size, int type)
//
@ -523,7 +494,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::inv(int method = DECOMP_LU)
//
@ -546,7 +516,6 @@ public class Mat {
return retVal;
}
//
// C++: bool Mat::isContinuous()
//
@ -560,7 +529,6 @@ public class Mat {
return retVal;
}
//
// C++: bool Mat::isSubmatrix()
//
@ -574,7 +542,6 @@ public class Mat {
return retVal;
}
//
// C++: void Mat::locateROI(Size wholeSize, Point ofs)
//
@ -588,7 +555,6 @@ public class Mat {
return;
}
//
// C++: Mat Mat::mul(Mat m, double scale = 1)
//
@ -611,7 +577,6 @@ public class Mat {
return retVal;
}
//
// C++: static Mat Mat::ones(int rows, int cols, int type)
//
@ -625,7 +590,6 @@ public class Mat {
return retVal;
}
//
// C++: static Mat Mat::ones(Size size, int type)
//
@ -639,7 +603,6 @@ public class Mat {
return retVal;
}
//
// C++: void Mat::push_back(Mat m)
//
@ -653,7 +616,6 @@ public class Mat {
return;
}
//
// C++: void Mat::release()
//
@ -667,7 +629,6 @@ public class Mat {
return;
}
//
// C++: Mat Mat::reshape(int cn, int rows = 0)
//
@ -690,7 +651,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::row(int y)
//
@ -704,7 +664,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::rowRange(int startrow, int endrow)
//
@ -718,7 +677,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::rowRange(Range r)
//
@ -732,7 +690,6 @@ public class Mat {
return retVal;
}
//
// C++: int Mat::rows()
//
@ -746,7 +703,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::operator =(Scalar s)
//
@ -760,7 +716,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::setTo(Mat value, Mat mask = Mat())
//
@ -783,7 +738,6 @@ public class Mat {
return retVal;
}
//
// C++: Size Mat::size()
//
@ -797,7 +751,6 @@ public class Mat {
return retVal;
}
//
// C++: size_t Mat::step1(int i = 0)
//
@ -820,9 +773,9 @@ public class Mat {
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)
@ -834,7 +787,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::operator()(Range rowRange, Range colRange)
//
@ -848,7 +800,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::operator()(Rect roi)
//
@ -862,7 +813,6 @@ public class Mat {
return retVal;
}
//
// C++: Mat Mat::t()
//
@ -876,7 +826,6 @@ public class Mat {
return retVal;
}
//
// C++: size_t Mat::total()
//
@ -890,7 +839,6 @@ public class Mat {
return retVal;
}
//
// C++: int Mat::type()
//
@ -904,7 +852,6 @@ public class Mat {
return retVal;
}
//
// C++: static Mat Mat::zeros(int rows, int cols, int type)
//
@ -918,7 +865,6 @@ public class Mat {
return retVal;
}
//
// C++: static Mat Mat::zeros(Size size, int type)
//
@ -932,7 +878,6 @@ public class Mat {
return retVal;
}
@Override
protected void finalize() throws Throwable {
n_delete(nativeObj);
@ -1122,11 +1067,12 @@ public class Mat {
return nativeObj;
}
//
// native stuff
//
static { System.loadLibrary("opencv_java"); }
static {
System.loadLibrary("opencv_java");
}
// C++: Mat::Mat()
private static native long n_Mat();
@ -1145,6 +1091,7 @@ public class Mat {
// 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)
@ -1152,14 +1099,18 @@ public class Mat {
// 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()
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()
@ -1174,9 +1125,12 @@ public class Mat {
// 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)
@ -1226,6 +1180,7 @@ public class Mat {
// 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()
@ -1239,6 +1194,7 @@ public class Mat {
// 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)
@ -1255,6 +1211,7 @@ public class Mat {
// 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)
@ -1271,6 +1228,7 @@ public class 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()
@ -1278,6 +1236,7 @@ public class Mat {
// 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)
@ -1304,17 +1263,27 @@ 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);
}

View File

@ -18,6 +18,7 @@ public class Point {
this();
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
x = vals.length > 0 ? vals[0] : 0;
@ -28,7 +29,6 @@ public class Point {
}
}
public Point clone() {
return new Point(x, y);
}
@ -61,10 +61,8 @@ public class Point {
return r.contains(this);
}
@Override
public String toString() {
if (this == null) return "null";
return "{" + x + ", " + y + "}";
}
}

View File

@ -25,6 +25,7 @@ public class Point3 {
this();
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
x = vals.length > 0 ? vals[0] : 0;
@ -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 + "}";
}
}

View File

@ -13,10 +13,11 @@ 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;
@ -29,11 +30,11 @@ public class Range {
}
public int size() {
return end-start;
return empty() ? 0 : end - start;
}
public boolean empty() {
return start==end;
return end <= start;
}
public static Range all() {
@ -45,11 +46,11 @@ 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);
}
public Range clone() {
return new Range(start, end);
}
@ -76,7 +77,6 @@ public class Range {
@Override
public String toString() {
if (this == null) return "null";
return "[" + start + ", " + end + ")";
}
}

View File

@ -28,9 +28,9 @@ public class Rect {
}
public Rect(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if (vals != null) {
x = vals.length > 0 ? (int) vals[0] : 0;
@ -95,7 +95,6 @@ public class Rect {
@Override
public String toString() {
if (this == null) return "null";
return "{" + x + ", " + y + ", " + width + "x" + height + "}";
}
}

View File

@ -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 + " }";
}
}

View File

@ -6,32 +6,38 @@ 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];
if (vals != null && vals.length == 4)
val = vals.clone();
else {
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;
}
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) {
@ -50,6 +56,7 @@ public class Scalar {
public Scalar mul(Scalar it) {
return mul(it, 1);
}
public Scalar conj() {
return new Scalar(val[0], -val[1], -val[2], -val[3]);
}
@ -75,5 +82,9 @@ public class Scalar {
return true;
}
@Override
public String toString() {
return "[" + val[0] + ", " + val[1] + ", " + val[2] + ", " + val[3] + "]";
}
}

View File

@ -15,14 +15,14 @@ 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;
@ -61,4 +61,9 @@ public class Size {
return width == it.width && height == it.height;
}
@Override
public String toString() {
return (int)width + "x" + (int)height;
}
}

View File

@ -3,24 +3,50 @@ 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;

View File

@ -1,25 +1,35 @@
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
/**
* query descriptor index
*/
public int queryIdx;
//javadoc: DMatch::trainIdx
/**
* train descriptor index
*/
public int trainIdx;
//javadoc: DMatch::imgIdx
/**
* train image index
*/
public int imgIdx;
// javadoc: DMatch::distance
public float distance;
// javadoc: DMatch::DMatch()
public DMatch() {
this(-1, -1, Float.MAX_VALUE);
}
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _distance)
public DMatch(int _queryIdx, int _trainIdx, float _distance) {
queryIdx = _queryIdx;
trainIdx = _trainIdx;
@ -27,7 +37,7 @@ public class DMatch {
distance = _distance;
}
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _imgIdx, _distance)
public DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) {
queryIdx = _queryIdx;
trainIdx = _trainIdx;
@ -35,12 +45,13 @@ public class DMatch {
distance = _distance;
}
// less is better
/**
* less is better
*/
boolean lessThan(DMatch it) {
return distance < it.distance;
}
@Override
public String toString() {
return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx

View File

@ -5,17 +5,31 @@ import org.opencv.core.Point;
//javadoc: KeyPoint
public class KeyPoint {
//javadoc: KeyPoint::pt
/**
* coordinates of the keypoint
*/
public Point pt;
//javadoc: KeyPoint::size
/**
* diameter of the meaningful keypoint neighborhood
*/
public float size;
//javadoc: KeyPoint::angle
/**
* computed orientation of the keypoint (-1 if not applicable)
*/
public float angle;
//javadoc: KeyPoint::response
/**
* the response by which the most strong keypoints have been selected. Can
* be used for further sorting or subsampling
*/
public float response;
//javadoc: KeyPoint::octave
/**
* octave (pyramid layer) from which the keypoint has been extracted
*/
public int octave;
//javadoc: KeyPoint::class_id
/**
* 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)

View File

@ -11,8 +11,10 @@ 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()
@ -27,7 +29,6 @@ public class VideoCapture {
return;
}
//
// C++: VideoCapture::VideoCapture(int device)
//
@ -41,13 +42,22 @@ public class VideoCapture {
return;
}
//
// C++: double VideoCapture::get(int propId)
//
//javadoc: VideoCapture::get(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 <a href="http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get">org.opencv.highgui.VideoCapture.get</a>
*/
public double get(int propId)
{
@ -69,7 +79,6 @@ public class VideoCapture {
return sizes;
}
//
// C++: bool VideoCapture::grab()
//
@ -83,7 +92,6 @@ public class VideoCapture {
return retVal;
}
//
// C++: bool VideoCapture::isOpened()
//
@ -97,7 +105,6 @@ public class VideoCapture {
return retVal;
}
//
// C++: bool VideoCapture::open(int device)
//
@ -111,7 +118,6 @@ public class VideoCapture {
return retVal;
}
//
// C++: bool VideoCapture::read(Mat image)
//
@ -125,7 +131,6 @@ public class VideoCapture {
return retVal;
}
//
// C++: void VideoCapture::release()
//
@ -139,7 +144,6 @@ public class VideoCapture {
return;
}
//
// C++: bool VideoCapture::retrieve(Mat image, int channel = 0)
//
@ -162,12 +166,20 @@ public class VideoCapture {
return retVal;
}
//
// C++: bool VideoCapture::set(int propId, double value)
//
//javadoc: VideoCapture::set(propId, 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 <a href="http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-set">org.opencv.highgui.VideoCapture.set</a>
*/
public boolean set(int propId, double value)
{
@ -176,7 +188,6 @@ public class VideoCapture {
return retVal;
}
@Override
protected void finalize() throws Throwable {
n_delete(nativeObj);
@ -185,7 +196,9 @@ public class VideoCapture {
// native stuff
static { System.loadLibrary("opencv_java"); }
static {
System.loadLibrary("opencv_java");
}
// C++: VideoCapture::VideoCapture()
private static native long n_VideoCapture();
@ -219,6 +232,7 @@ public class VideoCapture {
// 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)

View File

@ -30,8 +30,7 @@ public class Converters {
int count = (pts != null) ? pts.size() : 0;
if (count > 0) {
switch (typeDepth) {
case CvType.CV_32S:
{
case CvType.CV_32S: {
res = new Mat(count, 1, CvType.CV_32SC2);
int[] buff = new int[count * 2];
for (int i = 0; i < count; i++) {
@ -43,8 +42,7 @@ public class Converters {
}
break;
case CvType.CV_32F:
{
case CvType.CV_32F: {
res = new Mat(count, 1, CvType.CV_32FC2);
float[] buff = new float[count * 2];
for (int i = 0; i < count; i++) {
@ -56,8 +54,7 @@ public class Converters {
}
break;
case CvType.CV_64F:
{
case CvType.CV_64F: {
res = new Mat(count, 1, CvType.CV_64FC2);
double[] buff = new double[count * 2];
for (int i = 0; i < count; i++) {
@ -78,7 +75,6 @@ public class Converters {
return res;
}
public static Mat vector_Point3i_to_Mat(List<Point3> pts) {
return vector_Point3_to_Mat(pts, CvType.CV_32S);
}
@ -96,8 +92,7 @@ public class Converters {
int count = (pts != null) ? pts.size() : 0;
if (count > 0) {
switch (typeDepth) {
case CvType.CV_32S:
{
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++) {
@ -110,8 +105,7 @@ public class Converters {
}
break;
case CvType.CV_32F:
{
case CvType.CV_32F: {
res = new Mat(count, 1, CvType.CV_32FC3);
float[] buff = new float[count * 3];
for (int i = 0; i < count; i++) {
@ -124,8 +118,7 @@ public class Converters {
}
break;
case CvType.CV_64F:
{
case CvType.CV_64F: {
res = new Mat(count, 1, CvType.CV_64FC3);
double[] buff = new double[count * 3];
for (int i = 0; i < count; i++) {
@ -154,6 +147,7 @@ public class Converters {
public static void Mat_to_vector_Point2d(Mat m, List<Point> pts) {
Mat_to_vector_Point(m, pts);
}
public static void Mat_to_vector_Point(Mat m, List<Point> pts) {
if (pts == null)
throw new java.lang.IllegalArgumentException("Output List can't be null");
@ -190,6 +184,7 @@ public class Converters {
public static void Mat_to_vector_Point3i(Mat m, List<Point3> pts) {
Mat_to_vector_Point3(m, pts);
}
public static void Mat_to_vector_Point3f(Mat m, List<Point3> pts) {
Mat_to_vector_Point3(m, pts);
}
@ -197,6 +192,7 @@ public class Converters {
public static void Mat_to_vector_Point3d(Mat m, List<Point3> pts) {
Mat_to_vector_Point3(m, pts);
}
public static void Mat_to_vector_Point3(Mat m, List<Point3> pts) {
if (pts == null)
throw new java.lang.IllegalArgumentException("Output List can't be null");
@ -331,7 +327,6 @@ public class Converters {
}
}
public static Mat vector_char_to_Mat(List<Byte> bs) {
Mat res;
int count = (bs != null) ? bs.size() : 0;
@ -434,7 +429,6 @@ public class Converters {
}
}
public static Mat vector_KeyPoint_to_Mat(List<KeyPoint> kps) {
Mat res;
int count = (kps != null) ? kps.size() : 0;
@ -475,13 +469,29 @@ public class Converters {
}
}
// vector_vector_Point
public static Mat vector_vector_Point_to_Mat(List<List<Point>> pts) {
Mat res;
int lCount = (pts != null) ? pts.size() : 0;
if (lCount > 0) {
List<Mat> mats = new ArrayList<Mat>(lCount);
for (List<Point> 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<List<KeyPoint>> kps) {
Mat res;
int lCount = (kps != null) ? kps.size() : 0;
if (lCount > 0) {
List<Mat> mats = new ArrayList<Mat>(lCount);
for(List<KeyPoint> lkp: kps) mats.add( vector_KeyPoint_to_Mat(lkp) );
for (List<KeyPoint> lkp : kps)
mats.add(vector_KeyPoint_to_Mat(lkp));
res = vector_Mat_to_Mat(mats);
} else {
res = new Mat();
@ -505,7 +515,6 @@ public class Converters {
}
}
public static Mat vector_double_to_Mat(List<Double> ds) {
Mat res;
int count = (ds != null) ? ds.size() : 0;
@ -559,14 +568,14 @@ public class Converters {
}
}
// vector_vector_DMatch
public static Mat vector_vector_DMatch_to_Mat(List<List<DMatch>> lldm) {
Mat res;
int lCount = (lldm != null) ? lldm.size() : 0;
if (lCount > 0) {
List<Mat> mats = new ArrayList<Mat>(lCount);
for(List<DMatch> ldm: lldm) mats.add( vector_DMatch_to_Mat(ldm) );
for (List<DMatch> ldm : lldm)
mats.add(vector_DMatch_to_Mat(ldm));
res = vector_Mat_to_Mat(mats);
} else {
res = new Mat();
@ -596,7 +605,8 @@ public static Mat vector_vector_char_to_Mat(List<List<Byte>> llb) {
int lCount = (llb != null) ? llb.size() : 0;
if (lCount > 0) {
List<Mat> mats = new ArrayList<Mat>(lCount);
for(List<Byte> lb: llb) mats.add( vector_char_to_Mat(lb) );
for (List<Byte> lb : llb)
mats.add(vector_char_to_Mat(lb));
res = vector_Mat_to_Mat(mats);
} else {
res = new Mat();