mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
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:
parent
6d9075812f
commit
1991440cf7
@ -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 {
|
||||
|
@ -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>
|
||||
*/
|
||||
@ -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<TestCase> testCases = androidTestRunner.getTestCases();
|
||||
// Collections.shuffle(testCases); //shuffle the tests order
|
||||
|
||||
|
@ -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<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() {
|
||||
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2f": { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2d": { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2d> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3i": { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3i> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3f": { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3d": { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3d> %(n)s", "suffix" : "J" },
|
||||
"vector_Mat" : { "j_type" : "List<Mat>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Mat> %(n)s", "suffix" : "J" },
|
||||
"vector_KeyPoint":{ "j_type" : "List<KeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<KeyPoint> %(n)s", "suffix" : "J" },
|
||||
"vector_DMatch" : { "j_type" : "List<DMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<DMatch> %(n)s", "suffix" : "J" },
|
||||
"vector_Rect" : { "j_type" : "List<Rect>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Rect> %(n)s", "suffix" : "J" },
|
||||
"vector_uchar" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<uchar> %(n)s", "suffix" : "J" },
|
||||
"vector_char" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<char> %(n)s", "suffix" : "J" },
|
||||
"vector_int" : { "j_type" : "List<Integer>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<int> %(n)s", "suffix" : "J" },
|
||||
"vector_float" : { "j_type" : "List<Float>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<float> %(n)s", "suffix" : "J" },
|
||||
"vector_double" : { "j_type" : "List<Double>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<double> %(n)s", "suffix" : "J" },
|
||||
"vector_Point" : { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2f" : { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2d" : { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2d> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3i" : { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3i> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3f" : { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3d" : { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3d> %(n)s", "suffix" : "J" },
|
||||
"vector_Mat" : { "j_type" : "List<Mat>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Mat> %(n)s", "suffix" : "J" },
|
||||
"vector_KeyPoint" : { "j_type" : "List<KeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<KeyPoint> %(n)s", "suffix" : "J" },
|
||||
"vector_DMatch" : { "j_type" : "List<DMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<DMatch> %(n)s", "suffix" : "J" },
|
||||
"vector_Rect" : { "j_type" : "List<Rect>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Rect> %(n)s", "suffix" : "J" },
|
||||
"vector_uchar" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<uchar> %(n)s", "suffix" : "J" },
|
||||
"vector_char" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<char> %(n)s", "suffix" : "J" },
|
||||
"vector_int" : { "j_type" : "List<Integer>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<int> %(n)s", "suffix" : "J" },
|
||||
"vector_float" : { "j_type" : "List<Float>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<float> %(n)s", "suffix" : "J" },
|
||||
"vector_double" : { "j_type" : "List<Double>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<double> %(n)s", "suffix" : "J" },
|
||||
|
||||
"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_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
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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() + "]";
|
||||
}
|
||||
}
|
||||
|
@ -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 + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 + "}";
|
||||
}
|
||||
}
|
||||
|
@ -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 + "}";
|
||||
}
|
||||
}
|
||||
|
@ -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 + ")";
|
||||
}
|
||||
}
|
||||
|
@ -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 + "}";
|
||||
}
|
||||
}
|
||||
|
@ -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 + " }";
|
||||
}
|
||||
}
|
||||
|
@ -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] + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 <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)
|
||||
{
|
||||
|
||||
|
||||
double retVal = n_get(nativeObj, propId);
|
||||
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public List<Size> getSupportedPreviewSizes()
|
||||
public List<Size> getSupportedPreviewSizes()
|
||||
{
|
||||
String[] sizes_str = n_getSupportedPreviewSizes(nativeObj).split(",");
|
||||
List<Size> sizes = new LinkedList<Size>();
|
||||
|
||||
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 <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)
|
||||
{
|
||||
|
||||
|
||||
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);
|
||||
|
@ -27,50 +27,47 @@ public class Converters {
|
||||
|
||||
public static Mat vector_Point_to_Mat(List<Point> 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<count; i++) {
|
||||
Point p = pts.get(i);
|
||||
buff[i*2] = (int)p.x;
|
||||
buff[i*2+1] = (int)p.y;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
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++) {
|
||||
Point p = pts.get(i);
|
||||
buff[i * 2] = (int) p.x;
|
||||
buff[i * 2 + 1] = (int) p.y;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
}
|
||||
break;
|
||||
|
||||
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++) {
|
||||
Point p = pts.get(i);
|
||||
buff[i*2] = (float)p.x;
|
||||
buff[i*2+1] = (float)p.y;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
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++) {
|
||||
Point p = pts.get(i);
|
||||
buff[i * 2] = (float) p.x;
|
||||
buff[i * 2 + 1] = (float) p.y;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
}
|
||||
break;
|
||||
|
||||
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++) {
|
||||
Point p = pts.get(i);
|
||||
buff[i*2] = p.x;
|
||||
buff[i*2+1] = p.y;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
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++) {
|
||||
Point p = pts.get(i);
|
||||
buff[i * 2] = p.x;
|
||||
buff[i * 2 + 1] = p.y;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("'typeDepth' can be CV_32S, CV_32F or CV_64F");
|
||||
default:
|
||||
throw new IllegalArgumentException("'typeDepth' can be CV_32S, CV_32F or CV_64F");
|
||||
}
|
||||
} else {
|
||||
res = new Mat();
|
||||
@ -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);
|
||||
}
|
||||
@ -93,53 +89,50 @@ public class Converters {
|
||||
|
||||
public static Mat vector_Point3_to_Mat(List<Point3> 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<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);
|
||||
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 < 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<count; i++) {
|
||||
Point3 p = pts.get(i);
|
||||
buff[i*3] = (float)p.x;
|
||||
buff[i*3+1] = (float)p.y;
|
||||
buff[i*3+2] = (float)p.z;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
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++) {
|
||||
Point3 p = pts.get(i);
|
||||
buff[i * 3] = (float) p.x;
|
||||
buff[i * 3 + 1] = (float) p.y;
|
||||
buff[i * 3 + 2] = (float) p.z;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
}
|
||||
break;
|
||||
|
||||
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++) {
|
||||
Point3 p = pts.get(i);
|
||||
buff[i*3] = p.x;
|
||||
buff[i*3+1] = p.y;
|
||||
buff[i*3+2] = p.z;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
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++) {
|
||||
Point3 p = pts.get(i);
|
||||
buff[i * 3] = p.x;
|
||||
buff[i * 3 + 1] = p.y;
|
||||
buff[i * 3 + 2] = p.z;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("'typeDepth' can be CV_32S, CV_32F or CV_64F");
|
||||
default:
|
||||
throw new IllegalArgumentException("'typeDepth' can be CV_32S, CV_32F or CV_64F");
|
||||
}
|
||||
} else {
|
||||
res = new Mat();
|
||||
@ -154,42 +147,44 @@ 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)
|
||||
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<count; i++) {
|
||||
pts.add( new Point(buff[i*2], buff[i*2+1]) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
pts.add(new Point(buff[i * 2], buff[i * 2 + 1]));
|
||||
}
|
||||
} else if(type == CvType.CV_32FC2){
|
||||
float[] buff = new float[2*count];
|
||||
} else if (type == CvType.CV_32FC2) {
|
||||
float[] buff = new float[2 * count];
|
||||
m.get(0, 0, buff);
|
||||
for(int i=0; i<count; i++) {
|
||||
pts.add( new Point(buff[i*2], buff[i*2+1]) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
pts.add(new Point(buff[i * 2], buff[i * 2 + 1]));
|
||||
}
|
||||
} else if(type == CvType.CV_64FC2){
|
||||
double[] buff = new double[2*count];
|
||||
} else if (type == CvType.CV_64FC2) {
|
||||
double[] buff = new double[2 * count];
|
||||
m.get(0, 0, buff);
|
||||
for(int i=0; i<count; i++) {
|
||||
pts.add( new Point(buff[i*2], buff[i*2+1]) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
pts.add(new Point(buff[i * 2], buff[i * 2 + 1]));
|
||||
}
|
||||
} else {
|
||||
throw new java.lang.IllegalArgumentException(
|
||||
"Input Mat should be of CV_32SC2, CV_32FC2 or CV_64FC2 type\n" + m );
|
||||
"Input Mat should be of CV_32SC2, CV_32FC2 or CV_64FC2 type\n" + m);
|
||||
}
|
||||
}
|
||||
|
||||
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,49 +192,50 @@ 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)
|
||||
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<count; i++) {
|
||||
pts.add( new Point3(buff[i*3], buff[i*3+1], buff[i*3+2]) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
pts.add(new Point3(buff[i * 3], buff[i * 3 + 1], buff[i * 3 + 2]));
|
||||
}
|
||||
} else if(type == CvType.CV_32FC3){
|
||||
float[] buff = new float[3*count];
|
||||
} else if (type == CvType.CV_32FC3) {
|
||||
float[] buff = new float[3 * count];
|
||||
m.get(0, 0, buff);
|
||||
for(int i=0; i<count; i++) {
|
||||
pts.add( new Point3(buff[i*3], buff[i*3+1], buff[i*3+2]) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
pts.add(new Point3(buff[i * 3], buff[i * 3 + 1], buff[i * 3 + 2]));
|
||||
}
|
||||
} else if(type == CvType.CV_64FC3){
|
||||
double[] buff = new double[3*count];
|
||||
} else if (type == CvType.CV_64FC3) {
|
||||
double[] buff = new double[3 * count];
|
||||
m.get(0, 0, buff);
|
||||
for(int i=0; i<count; i++) {
|
||||
pts.add( new Point3(buff[i*3], buff[i*3+1], buff[i*3+2]) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
pts.add(new Point3(buff[i * 3], buff[i * 3 + 1], buff[i * 3 + 2]));
|
||||
}
|
||||
} else {
|
||||
throw new java.lang.IllegalArgumentException(
|
||||
"Input Mat should be of CV_32SC3, CV_32FC3 or CV_64FC3 type\n" + m );
|
||||
"Input Mat should be of CV_32SC3, CV_32FC3 or CV_64FC3 type\n" + m);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mat vector_Mat_to_Mat(List<Mat> 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<count; i++) {
|
||||
int[] buff = new int[count * 2];
|
||||
for (int i = 0; i < count; i++) {
|
||||
long addr = mats.get(i).nativeObj;
|
||||
buff[i*2] = (int)(addr >> 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<Mat> 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<count; i++) {
|
||||
long addr = (((long)buff[i*2])<<32) | ((long)buff[i*2+1]);
|
||||
mats.add( new Mat(addr) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
long addr = (((long) buff[i * 2]) << 32) | ((long) buff[i * 2 + 1]);
|
||||
mats.add(new Mat(addr));
|
||||
}
|
||||
}
|
||||
|
||||
public static Mat vector_float_to_Mat(List<Float> 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<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
float f = fs.get(i);
|
||||
buff[i] = f;
|
||||
buff[i] = f;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -283,30 +279,30 @@ public class Converters {
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_float(Mat m, List<Float> 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<count; i++) {
|
||||
fs.add( buff[i] );
|
||||
for (int i = 0; i < count; i++) {
|
||||
fs.add(buff[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mat vector_uchar_to_Mat(List<Byte> 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<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
byte b = bs.get(i);
|
||||
buff[i] = b;
|
||||
buff[i] = b;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -316,31 +312,30 @@ public class Converters {
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_uchar(Mat m, List<Byte> 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<count; i++) {
|
||||
us.add( buff[i] );
|
||||
for (int i = 0; i < count; i++) {
|
||||
us.add(buff[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Mat vector_char_to_Mat(List<Byte> 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<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
byte b = bs.get(i);
|
||||
buff[i] = b;
|
||||
buff[i] = b;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -351,13 +346,13 @@ public class Converters {
|
||||
|
||||
public static Mat vector_int_to_Mat(List<Integer> 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<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int v = is.get(i);
|
||||
buff[i] = v;
|
||||
buff[i] = v;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -367,49 +362,49 @@ public class Converters {
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_int(Mat m, List<Integer> 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<count; i++) {
|
||||
is.add( buff[i] );
|
||||
for (int i = 0; i < count; i++) {
|
||||
is.add(buff[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_char(Mat m, List<Byte> 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<count; i++) {
|
||||
bs.add( buff[i] );
|
||||
for (int i = 0; i < count; i++) {
|
||||
bs.add(buff[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mat vector_Rect_to_Mat(List<Rect> 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<count; i++) {
|
||||
int[] buff = new int[4 * count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
Rect r = rs.get(i);
|
||||
buff[4*i ] = r.x;
|
||||
buff[4*i+1] = r.y;
|
||||
buff[4*i+2] = r.width;
|
||||
buff[4*i+3] = r.height;
|
||||
buff[4 * i] = r.x;
|
||||
buff[4 * i + 1] = r.y;
|
||||
buff[4 * i + 2] = r.width;
|
||||
buff[4 * i + 3] = r.height;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -419,37 +414,36 @@ public class Converters {
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_Rect(Mat m, List<Rect> 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<count; i++) {
|
||||
rs.add( new Rect(buff[4*i], buff[4*i+1], buff[4*i+2], buff[4*i+3]) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
rs.add(new Rect(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Mat vector_KeyPoint_to_Mat(List<KeyPoint> 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<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
KeyPoint kp = kps.get(i);
|
||||
buff[7*i ] = kp.pt.x;
|
||||
buff[7*i+1] = kp.pt.y;
|
||||
buff[7*i+2] = kp.size;
|
||||
buff[7*i+3] = kp.angle;
|
||||
buff[7*i+4] = kp.response;
|
||||
buff[7*i+5] = kp.octave;
|
||||
buff[7*i+6] = kp.class_id;
|
||||
buff[7 * i] = kp.pt.x;
|
||||
buff[7 * i + 1] = kp.pt.y;
|
||||
buff[7 * i + 2] = kp.size;
|
||||
buff[7 * i + 3] = kp.angle;
|
||||
buff[7 * i + 4] = kp.response;
|
||||
buff[7 * i + 5] = kp.octave;
|
||||
buff[7 * i + 6] = kp.class_id;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -459,29 +453,45 @@ public class Converters {
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_KeyPoint(Mat m, List<KeyPoint> 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<count; i++) {
|
||||
kps.add( new KeyPoint( (float)buff[7*i], (float)buff[7*i+1], (float)buff[7*i+2], (float)buff[7*i+3],
|
||||
(float)buff[7*i+4], (int)buff[7*i+5], (int)buff[7*i+6] ) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
kps.add(new KeyPoint((float) buff[7 * i], (float) buff[7 * i + 1], (float) buff[7 * i + 2], (float) buff[7 * i + 3],
|
||||
(float) buff[7 * i + 4], (int) buff[7 * i + 5], (int) buff[7 * i + 6]));
|
||||
}
|
||||
}
|
||||
|
||||
// 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){
|
||||
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();
|
||||
@ -490,31 +500,30 @@ public class Converters {
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_KeyPoint(Mat m, List<List<KeyPoint>> 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<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
List<KeyPoint> lkp = new ArrayList<KeyPoint>();
|
||||
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<Double> 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<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
double v = ds.get(i);
|
||||
buff[i] = v;
|
||||
buff[i] = v;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -525,16 +534,16 @@ public class Converters {
|
||||
|
||||
public static Mat vector_DMatch_to_Mat(List<DMatch> 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<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
DMatch m = matches.get(i);
|
||||
buff[4*i ] = m.queryIdx;
|
||||
buff[4*i+1] = m.trainIdx;
|
||||
buff[4*i+2] = m.imgIdx;
|
||||
buff[4*i+3] = m.distance;
|
||||
buff[4 * i] = m.queryIdx;
|
||||
buff[4 * i + 1] = m.trainIdx;
|
||||
buff[4 * i + 2] = m.imgIdx;
|
||||
buff[4 * i + 3] = m.distance;
|
||||
}
|
||||
res.put(0, 0, buff);
|
||||
} else {
|
||||
@ -544,80 +553,81 @@ public class Converters {
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> 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<count; i++) {
|
||||
matches.add( new DMatch( (int)buff[4*i], (int)buff[4*i+1], (int)buff[4*i+2], (float)buff[4*i+3] ) );
|
||||
for (int i = 0; i < count; i++) {
|
||||
matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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) );
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
res = new Mat();
|
||||
// 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));
|
||||
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<List<DMatch>> 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<List<DMatch>> 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<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
List<DMatch> ldm = new ArrayList<DMatch>();
|
||||
for(Mat mi : mats) {
|
||||
Mat_to_vector_DMatch(mi, ldm);
|
||||
lldm.add(ldm);
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
List<DMatch> ldm = new ArrayList<DMatch>();
|
||||
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<List<Byte>> llb) {
|
||||
Mat res;
|
||||
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) );
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
res = new Mat();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// vector_vector_char
|
||||
public static Mat vector_vector_char_to_Mat(List<List<Byte>> llb) {
|
||||
Mat res;
|
||||
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));
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
res = new Mat();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_char(Mat m, List<List<Byte>> 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<List<Byte>> 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<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
List<Byte> lb = new ArrayList<Byte>();
|
||||
for(Mat mi : mats) {
|
||||
Mat_to_vector_char(mi, lb);
|
||||
llb.add(lb);
|
||||
}
|
||||
}
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
List<Byte> lb = new ArrayList<Byte>();
|
||||
for (Mat mi : mats) {
|
||||
Mat_to_vector_char(mi, lb);
|
||||
llb.add(lb);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user