mirror of
https://github.com/opencv/opencv.git
synced 2024-11-26 20:20:20 +08:00
Java API: changing CvVectorXxx to MatOfXxx
This commit is contained in:
parent
85fa0e7763
commit
6c0ab28d8b
@ -3,9 +3,9 @@ package org.opencv.test.calib3d;
|
||||
import org.opencv.calib3d.Calib3d;
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.CvVectorPoint2f;
|
||||
import org.opencv.core.CvVectorPoint3f;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfPoint2f;
|
||||
import org.opencv.core.MatOfPoint3f;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.core.Size;
|
||||
@ -235,14 +235,14 @@ public class Calib3dTest extends OpenCVTestCase {
|
||||
public void testFindFundamentalMatListOfPointListOfPoint() {
|
||||
int minFundamentalMatPoints = 8;
|
||||
|
||||
CvVectorPoint2f pts1 = new CvVectorPoint2f();
|
||||
CvVectorPoint2f pts2 = new CvVectorPoint2f();
|
||||
MatOfPoint2f pts1 = new MatOfPoint2f();
|
||||
MatOfPoint2f pts2 = new MatOfPoint2f();
|
||||
pts2.alloc(minFundamentalMatPoints);
|
||||
|
||||
for (int i = 0; i < minFundamentalMatPoints; i++) {
|
||||
double x = Math.random() * 100 - 50;
|
||||
double y = Math.random() * 100 - 50;
|
||||
pts1.push_back(new CvVectorPoint2f(new Point(x, y))); //add(new Point(x, y));
|
||||
pts1.push_back(new MatOfPoint2f(new Point(x, y))); //add(new Point(x, y));
|
||||
pts2.put(i, 0, x, y); //add(new Point(x, y));
|
||||
}
|
||||
|
||||
@ -272,9 +272,9 @@ public class Calib3dTest extends OpenCVTestCase {
|
||||
public void testFindHomographyListOfPointListOfPoint() {
|
||||
final int NUM = 20;
|
||||
|
||||
CvVectorPoint2f originalPoints = new CvVectorPoint2f();
|
||||
MatOfPoint2f originalPoints = new MatOfPoint2f();
|
||||
originalPoints.alloc(NUM);
|
||||
CvVectorPoint2f transformedPoints = new CvVectorPoint2f();
|
||||
MatOfPoint2f transformedPoints = new MatOfPoint2f();
|
||||
transformedPoints.alloc(NUM);
|
||||
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
@ -503,9 +503,9 @@ public class Calib3dTest extends OpenCVTestCase {
|
||||
|
||||
final int minPnpPointsNum = 4;
|
||||
|
||||
CvVectorPoint3f points3d = new CvVectorPoint3f();
|
||||
MatOfPoint3f points3d = new MatOfPoint3f();
|
||||
points3d.alloc(minPnpPointsNum);
|
||||
CvVectorPoint2f points2d = new CvVectorPoint2f();
|
||||
MatOfPoint2f points2d = new MatOfPoint2f();
|
||||
points2d.alloc(minPnpPointsNum);
|
||||
|
||||
for (int i = 0; i < minPnpPointsNum; i++) {
|
||||
|
@ -1,13 +1,17 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.Core.MinMaxLocResult;
|
||||
import org.opencv.core.CvException;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.CvVectorDouble;
|
||||
import org.opencv.core.CvVectorInt;
|
||||
import org.opencv.core.CvVectorPoint;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDouble;
|
||||
import org.opencv.core.MatOfInt;
|
||||
import org.opencv.core.MatOfPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.core.RotatedRect;
|
||||
@ -16,10 +20,6 @@ import org.opencv.core.Size;
|
||||
import org.opencv.core.TermCriteria;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CoreTest extends OpenCVTestCase {
|
||||
|
||||
public void testAbsdiff() {
|
||||
@ -485,7 +485,7 @@ public class CoreTest extends OpenCVTestCase {
|
||||
int arcStart = 30;
|
||||
int arcEnd = 60;
|
||||
int delta = 2;
|
||||
CvVectorPoint pts = new CvVectorPoint();
|
||||
MatOfPoint pts = new MatOfPoint();
|
||||
|
||||
Core.ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta, pts);
|
||||
|
||||
@ -507,7 +507,7 @@ public class CoreTest extends OpenCVTestCase {
|
||||
new Point(4, 6),
|
||||
new Point(4, 6)
|
||||
};
|
||||
assertArrayPointsEquals(truth, pts.toArray(null), EPS);
|
||||
assertArrayPointsEquals(truth, pts.toArray(), EPS);
|
||||
}
|
||||
|
||||
public void testEllipseMatPointSizeDoubleDoubleDoubleScalar() {
|
||||
@ -621,7 +621,7 @@ public class CoreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testFillConvexPolyMatListOfPointScalar() {
|
||||
CvVectorPoint polyline = new CvVectorPoint(new Point[]{new Point(1, 1), new Point(5, 0), new Point(6, 8), new Point(0, 9)});
|
||||
MatOfPoint polyline = new MatOfPoint(new Point[]{new Point(1, 1), new Point(5, 0), new Point(6, 8), new Point(0, 9)});
|
||||
|
||||
Core.fillConvexPoly(gray0, polyline, new Scalar(150));
|
||||
|
||||
@ -630,8 +630,8 @@ public class CoreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testFillConvexPolyMatListOfPointScalarIntInt() {
|
||||
CvVectorPoint polyline1 = new CvVectorPoint(new Point(2, 1), new Point(5, 1), new Point(5, 7), new Point(2, 7));
|
||||
CvVectorPoint polyline2 = new CvVectorPoint(new Point(4, 2), new Point(10, 2), new Point(10, 14), new Point(4, 14));
|
||||
MatOfPoint polyline1 = new MatOfPoint(new Point(2, 1), new Point(5, 1), new Point(5, 7), new Point(2, 7));
|
||||
MatOfPoint polyline2 = new MatOfPoint(new Point(4, 2), new Point(10, 2), new Point(10, 14), new Point(4, 14));
|
||||
|
||||
// current implementation of fixed-point version of fillConvexPoly
|
||||
// requires image to be at least 2-pixel wider in each direction than
|
||||
@ -649,8 +649,8 @@ public class CoreTest extends OpenCVTestCase {
|
||||
public void testFillPolyMatListOfListOfPointScalar() {
|
||||
int matSize = 10;
|
||||
Mat gray0 = Mat.zeros(matSize, matSize, CvType.CV_8U);
|
||||
CvVectorPoint polyline = new CvVectorPoint(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
|
||||
List<CvVectorPoint> polylines = new ArrayList<CvVectorPoint>();
|
||||
MatOfPoint polyline = new MatOfPoint(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
|
||||
List<MatOfPoint> polylines = new ArrayList<MatOfPoint>();
|
||||
polylines.add(polyline);
|
||||
|
||||
Core.fillPoly(gray0, polylines, new Scalar(1));
|
||||
@ -675,13 +675,13 @@ public class CoreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testFillPolyMatListOfListOfPointScalarIntIntPoint() {
|
||||
CvVectorPoint polyline1 = new CvVectorPoint(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
|
||||
CvVectorPoint polyline2 = new CvVectorPoint(new Point(0, 3), new Point(0, 7), new Point(3, 0), new Point(6, 7), new Point(6, 3));
|
||||
MatOfPoint polyline1 = new MatOfPoint(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
|
||||
MatOfPoint polyline2 = new MatOfPoint(new Point(0, 3), new Point(0, 7), new Point(3, 0), new Point(6, 7), new Point(6, 3));
|
||||
|
||||
List<CvVectorPoint> polylines1 = new ArrayList<CvVectorPoint>();
|
||||
List<MatOfPoint> polylines1 = new ArrayList<MatOfPoint>();
|
||||
polylines1.add(polyline1);
|
||||
|
||||
List<CvVectorPoint> polylines2 = new ArrayList<CvVectorPoint>();
|
||||
List<MatOfPoint> polylines2 = new ArrayList<MatOfPoint>();
|
||||
polylines2.add(polyline2);
|
||||
|
||||
Core.fillPoly(gray0, polylines1, new Scalar(1), Core.LINE_8, 0, new Point(0, 0));
|
||||
@ -1194,8 +1194,8 @@ public class CoreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testMeanStdDevMatMatMat() {
|
||||
CvVectorDouble mean = new CvVectorDouble();
|
||||
CvVectorDouble stddev = new CvVectorDouble();
|
||||
MatOfDouble mean = new MatOfDouble();
|
||||
MatOfDouble stddev = new MatOfDouble();
|
||||
|
||||
Core.meanStdDev(rgbLena, mean, stddev);
|
||||
|
||||
@ -1204,8 +1204,8 @@ public class CoreTest extends OpenCVTestCase {
|
||||
double expectedDev[] = new double[]
|
||||
{33.74205485167219, 52.8734582803278, 49.01569488056406};
|
||||
|
||||
assertArrayEquals(expectedMean, mean.toPrimitiveArray(null), EPS);
|
||||
assertArrayEquals(expectedDev, stddev.toPrimitiveArray(null), EPS);
|
||||
assertArrayEquals(expectedMean, mean.toArray(), EPS);
|
||||
assertArrayEquals(expectedDev, stddev.toArray(), EPS);
|
||||
}
|
||||
|
||||
public void testMeanStdDevMatMatMatMat() {
|
||||
@ -1214,16 +1214,16 @@ public class CoreTest extends OpenCVTestCase {
|
||||
Mat mask = gray0.clone();
|
||||
submat = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2);
|
||||
submat.setTo(new Scalar(1));
|
||||
CvVectorDouble mean = new CvVectorDouble();
|
||||
CvVectorDouble stddev = new CvVectorDouble();
|
||||
MatOfDouble mean = new MatOfDouble();
|
||||
MatOfDouble stddev = new MatOfDouble();
|
||||
|
||||
Core.meanStdDev(grayRnd, mean, stddev, mask);
|
||||
|
||||
double expectedMean[] = new double[] {33d};
|
||||
double expectedDev[] = new double[] {0d};
|
||||
|
||||
assertArrayEquals(expectedMean, mean.toPrimitiveArray(null), EPS);
|
||||
assertArrayEquals(expectedDev, stddev.toPrimitiveArray(null), EPS);
|
||||
assertArrayEquals(expectedMean, mean.toArray(), EPS);
|
||||
assertArrayEquals(expectedDev, stddev.toArray(), EPS);
|
||||
}
|
||||
|
||||
public void testMerge() {
|
||||
@ -1284,7 +1284,7 @@ public class CoreTest extends OpenCVTestCase {
|
||||
rgba0.setTo(new Scalar(10, 20, 30, 40));
|
||||
List<Mat> src = Arrays.asList(rgba0);
|
||||
List<Mat> dst = Arrays.asList(gray3, gray2, gray1, gray0, getMat(CvType.CV_8UC3, 0, 0, 0));
|
||||
CvVectorInt fromTo = new CvVectorInt(1, new int[]
|
||||
MatOfInt fromTo = new MatOfInt(1, new int[]
|
||||
{ 3, 0,
|
||||
3, 1,
|
||||
2, 2,
|
||||
@ -1745,8 +1745,8 @@ public class CoreTest extends OpenCVTestCase {
|
||||
|
||||
public void testPolylinesMatListOfListOfPointBooleanScalar() {
|
||||
Mat img = gray0;
|
||||
List<CvVectorPoint> polyline = new ArrayList<CvVectorPoint>();
|
||||
polyline.add(new CvVectorPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
|
||||
List<MatOfPoint> polyline = new ArrayList<MatOfPoint>();
|
||||
polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
|
||||
|
||||
Core.polylines(img, polyline, true, new Scalar(100));
|
||||
|
||||
@ -1759,8 +1759,8 @@ public class CoreTest extends OpenCVTestCase {
|
||||
|
||||
public void testPolylinesMatListOfListOfPointBooleanScalarInt() {
|
||||
Mat img = gray0;
|
||||
List<CvVectorPoint> polyline = new ArrayList<CvVectorPoint>();
|
||||
polyline.add(new CvVectorPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
|
||||
List<MatOfPoint> polyline = new ArrayList<MatOfPoint>();
|
||||
polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
|
||||
|
||||
Core.polylines(img, polyline, true, new Scalar(100), 2);
|
||||
|
||||
@ -1769,10 +1769,10 @@ public class CoreTest extends OpenCVTestCase {
|
||||
|
||||
public void testPolylinesMatListOfListOfPointBooleanScalarIntIntInt() {
|
||||
Mat img = gray0;
|
||||
List<CvVectorPoint> polyline1 = new ArrayList<CvVectorPoint>();
|
||||
polyline1.add(new CvVectorPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
|
||||
List<CvVectorPoint> polyline2 = new ArrayList<CvVectorPoint>();
|
||||
polyline2.add(new CvVectorPoint(new Point(2, 2), new Point(14, 2), new Point(14, 12), new Point(2, 12)));
|
||||
List<MatOfPoint> polyline1 = new ArrayList<MatOfPoint>();
|
||||
polyline1.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
|
||||
List<MatOfPoint> polyline2 = new ArrayList<MatOfPoint>();
|
||||
polyline2.add(new MatOfPoint(new Point(2, 2), new Point(14, 2), new Point(14, 12), new Point(2, 12)));
|
||||
|
||||
Core.polylines(img, polyline1, true, new Scalar(100), 2, Core.LINE_8, 0);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.opencv.test.highgui;
|
||||
|
||||
import org.opencv.core.CvVectorByte;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.highgui.Highgui;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
@ -12,7 +12,7 @@ public class HighguiTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testImencodeStringMatListOfByte() {
|
||||
CvVectorByte buff = new CvVectorByte();
|
||||
MatOfByte buff = new MatOfByte();
|
||||
assertEquals(0, buff.size());
|
||||
assertTrue( Highgui.imencode(".jpg", gray127, buff) );
|
||||
assertFalse(0 == buff.total());
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.opencv.test.objdetect;
|
||||
|
||||
import org.opencv.core.CvVectorRect;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfRect;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.opencv.objdetect.CascadeClassifier;
|
||||
@ -32,7 +32,7 @@ public class CascadeClassifierTest extends OpenCVTestCase {
|
||||
|
||||
public void testDetectMultiScaleMatListOfRect() {
|
||||
CascadeClassifier cc = new CascadeClassifier(OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH);
|
||||
CvVectorRect faces = new CvVectorRect();
|
||||
MatOfRect faces = new MatOfRect();
|
||||
|
||||
Mat greyLena = new Mat();
|
||||
Imgproc.cvtColor(rgbLena, greyLena, Imgproc.COLOR_RGB2GRAY);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.opencv.test.objdetect;
|
||||
|
||||
import org.opencv.core.CvVectorRect;
|
||||
import org.opencv.core.MatOfRect;
|
||||
import org.opencv.objdetect.Objdetect;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
@ -9,7 +9,8 @@ public class ObjdetectTest extends OpenCVTestCase {
|
||||
public void testGroupRectanglesListOfRectListOfIntegerInt() {
|
||||
fail("Not yet implemented");
|
||||
final int NUM = 10;
|
||||
CvVectorRect rects = new CvVectorRect(NUM);
|
||||
MatOfRect rects = new MatOfRect();
|
||||
rects.alloc(NUM);
|
||||
|
||||
for (int i = 0; i < NUM; i++)
|
||||
rects.put(i, 0, 10, 10, 20, 20);
|
||||
@ -22,7 +23,8 @@ public class ObjdetectTest extends OpenCVTestCase {
|
||||
public void testGroupRectanglesListOfRectListOfIntegerIntDouble() {
|
||||
fail("Not yet implemented");
|
||||
final int NUM = 10;
|
||||
CvVectorRect rects = new CvVectorRect(NUM);
|
||||
MatOfRect rects = new MatOfRect();
|
||||
rects.alloc(NUM);
|
||||
|
||||
for (int i = 0; i < NUM; i++)
|
||||
rects.put(i, 0, 10, 10, 20, 20);
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.opencv.test.video;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvVectorByte;
|
||||
import org.opencv.core.CvVectorFloat;
|
||||
import org.opencv.core.CvVectorPoint2f;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.core.MatOfFloat;
|
||||
import org.opencv.core.MatOfPoint2f;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
@ -12,15 +12,15 @@ import org.opencv.video.Video;
|
||||
|
||||
public class VideoTest extends OpenCVTestCase {
|
||||
|
||||
private CvVectorFloat err = null;
|
||||
private MatOfFloat err = null;
|
||||
private int h;
|
||||
private CvVectorPoint2f nextPts = null;
|
||||
private CvVectorPoint2f prevPts = null;
|
||||
private MatOfPoint2f nextPts = null;
|
||||
private MatOfPoint2f prevPts = null;
|
||||
|
||||
private int shift1;
|
||||
private int shift2;
|
||||
|
||||
private CvVectorByte status = null;
|
||||
private MatOfByte status = null;
|
||||
private Mat subLena1 = null;
|
||||
private Mat subLena2 = null;
|
||||
private int w;
|
||||
@ -37,11 +37,11 @@ public class VideoTest extends OpenCVTestCase {
|
||||
subLena1 = rgbLena.submat(shift1, h + shift1, shift1, w + shift1);
|
||||
subLena2 = rgbLena.submat(shift2, h + shift2, shift2, w + shift2);
|
||||
|
||||
prevPts = new CvVectorPoint2f(new Point(11d, 8d), new Point(5d, 5d), new Point(10d, 10d));
|
||||
prevPts = new MatOfPoint2f(new Point(11d, 8d), new Point(5d, 5d), new Point(10d, 10d));
|
||||
|
||||
nextPts = new CvVectorPoint2f();
|
||||
status = new CvVectorByte();
|
||||
err = new CvVectorFloat();
|
||||
nextPts = new MatOfPoint2f();
|
||||
status = new MatOfByte();
|
||||
err = new MatOfFloat();
|
||||
}
|
||||
|
||||
public void testCalcGlobalOrientation() {
|
||||
|
@ -193,30 +193,30 @@ type_dict = {
|
||||
|
||||
# "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" },
|
||||
|
||||
"vector_Point" : { "j_type" : "CvVectorPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2f" : { "j_type" : "CvVectorPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2d" : { "j_type" : "CvVectorPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2d> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3i" : { "j_type" : "CvVectorPoint3", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3i> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3f" : { "j_type" : "CvVectorPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3d" : { "j_type" : "CvVectorPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3d> %(n)s", "suffix" : "J" },
|
||||
"vector_KeyPoint" : { "j_type" : "CvVectorKeyPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<KeyPoint> %(n)s", "suffix" : "J" },
|
||||
"vector_DMatch" : { "j_type" : "CvVectorDMatch", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<DMatch> %(n)s", "suffix" : "J" },
|
||||
"vector_Rect" : { "j_type" : "CvVectorRect", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Rect> %(n)s", "suffix" : "J" },
|
||||
"vector_uchar" : { "j_type" : "CvVectorByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<uchar> %(n)s", "suffix" : "J" },
|
||||
"vector_char" : { "j_type" : "CvVectorByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<char> %(n)s", "suffix" : "J" },
|
||||
"vector_int" : { "j_type" : "CvVectorInt", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<int> %(n)s", "suffix" : "J" },
|
||||
"vector_float" : { "j_type" : "CvVectorFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<float> %(n)s", "suffix" : "J" },
|
||||
"vector_double" : { "j_type" : "CvVectorDouble", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<double> %(n)s", "suffix" : "J" },
|
||||
"vector_Vec4f" : { "j_type" : "CvVectorFloat4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Vec4f> %(n)s", "suffix" : "J" },
|
||||
"vector_Vec6f" : { "j_type" : "CvVectorFloat6", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Vec6f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point" : { "j_type" : "MatOfPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2f" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point2d" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2d> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3i" : { "j_type" : "MatOfPoint3", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3i> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3f" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3f> %(n)s", "suffix" : "J" },
|
||||
"vector_Point3d" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3d> %(n)s", "suffix" : "J" },
|
||||
"vector_KeyPoint" : { "j_type" : "MatOfKeyPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<KeyPoint> %(n)s", "suffix" : "J" },
|
||||
"vector_DMatch" : { "j_type" : "MatOfDMatch", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<DMatch> %(n)s", "suffix" : "J" },
|
||||
"vector_Rect" : { "j_type" : "MatOfRect", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Rect> %(n)s", "suffix" : "J" },
|
||||
"vector_uchar" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<uchar> %(n)s", "suffix" : "J" },
|
||||
"vector_char" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<char> %(n)s", "suffix" : "J" },
|
||||
"vector_int" : { "j_type" : "MatOfInt", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<int> %(n)s", "suffix" : "J" },
|
||||
"vector_float" : { "j_type" : "MatOfFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<float> %(n)s", "suffix" : "J" },
|
||||
"vector_double" : { "j_type" : "MatOfDouble", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<double> %(n)s", "suffix" : "J" },
|
||||
"vector_Vec4f" : { "j_type" : "MatOfFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Vec4f> %(n)s", "suffix" : "J" },
|
||||
"vector_Vec6f" : { "j_type" : "MatOfFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Vec6f> %(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_vector_KeyPoint": { "j_type" : "List<CvVectorKeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<KeyPoint> > %(n)s" },
|
||||
"vector_vector_DMatch" : { "j_type" : "List<CvVectorDMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<DMatch> > %(n)s" },
|
||||
"vector_vector_char" : { "j_type" : "List<CvVectorByte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<char> > %(n)s" },
|
||||
"vector_vector_Point" : { "j_type" : "List<CvVectorPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<Point> > %(n)s" },
|
||||
"vector_vector_Point2f" : { "j_type" : "List<CvVectorPoint2f>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<Point2f> > %(n)s" },
|
||||
"vector_vector_KeyPoint": { "j_type" : "List<MatOfKeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<KeyPoint> > %(n)s" },
|
||||
"vector_vector_DMatch" : { "j_type" : "List<MatOfDMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<DMatch> > %(n)s" },
|
||||
"vector_vector_char" : { "j_type" : "List<MatOfByte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<char> > %(n)s" },
|
||||
"vector_vector_Point" : { "j_type" : "List<MatOfPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<Point> > %(n)s" },
|
||||
"vector_vector_Point2f" : { "j_type" : "List<MatOfPoint2f>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<Point2f> > %(n)s" },
|
||||
|
||||
"Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
|
||||
"jni_var" : "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)",
|
||||
@ -897,7 +897,7 @@ extern "C" {
|
||||
imports = self.classes[scope_classname or self.Module].imports
|
||||
if ctype.startswith('vector'):
|
||||
imports.add("org.opencv.core.Mat")
|
||||
if type_dict[ctype]['j_type'].startswith('CvVector'):
|
||||
if type_dict[ctype]['j_type'].startswith('MatOf'):
|
||||
imports.add("org.opencv.core." + type_dict[ctype]['j_type'])
|
||||
return #TMP
|
||||
else:
|
||||
@ -1001,18 +1001,18 @@ extern "C" {
|
||||
j_prologue.append( "List<Mat> %(n)s_tmplm = new ArrayList<Mat>((%(n)s != null) ? %(n)s.size() : 0);" % {"n" : a.name } )
|
||||
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s, %(n)s_tmplm);" % {"n" : a.name, "t" : a.ctype} )
|
||||
else:
|
||||
if not type_dict[a.ctype]["j_type"].startswith("CvVector"):
|
||||
if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
|
||||
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s);" % {"n" : a.name, "t" : a.ctype} )
|
||||
else:
|
||||
j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) )
|
||||
c_prologue.append( "Mat_to_%(t)s( %(n)s_mat, %(n)s );" % {"n" : a.name, "t" : a.ctype} )
|
||||
else:
|
||||
if not type_dict[a.ctype]["j_type"].startswith("CvVector"):
|
||||
if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
|
||||
j_prologue.append( "Mat %s_mat = new Mat();" % a.name )
|
||||
else:
|
||||
j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) )
|
||||
if "O" in a.out:
|
||||
if not type_dict[a.ctype]["j_type"].startswith("CvVector"):
|
||||
if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
|
||||
j_epilogue.append("Converters.Mat_to_%(t)s(%(n)s_mat, %(n)s);" % {"t" : a.ctype, "n" : a.name})
|
||||
c_epilogue.append( "%(t)s_to_Mat( %(n)s, %(n)s_mat );" % {"n" : a.name, "t" : a.ctype} )
|
||||
else:
|
||||
@ -1074,8 +1074,14 @@ extern "C" {
|
||||
if ret_type.startswith('vector'):
|
||||
tail = ")"
|
||||
j_type = type_dict[ret_type]["j_type"]
|
||||
if j_type.startswith('CvVector'):
|
||||
if j_type.startswith('MatOf'):
|
||||
ret_val += "new " + j_type + "("
|
||||
m_t = re.match('vector_(\w+)', ret_type)
|
||||
m_ch = re.match('vector_Vec(\d+)', ret_type)
|
||||
if m_ch:
|
||||
ret_val += m_ch.group(1) + ', '
|
||||
elif m_t.group(1) in ('char', 'uchar', 'int', 'float', 'double'):
|
||||
ret_val += '1, '
|
||||
else:
|
||||
ret_val = "Mat retValMat = new Mat("
|
||||
j_prologue.append( j_type + ' retVal = new Array' + j_type+'();')
|
||||
|
@ -1,35 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVector extends Mat {
|
||||
protected int depth;
|
||||
protected int channels;
|
||||
|
||||
protected CvVector(int d, int ch) {
|
||||
super();
|
||||
depth = d;
|
||||
channels = ch;
|
||||
}
|
||||
|
||||
protected CvVector(int d, int ch, long addr) {
|
||||
super(addr);
|
||||
depth = d;
|
||||
channels = ch;
|
||||
if( !empty() && checkVector(channels, depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
protected CvVector(int d, int ch, Mat m) {
|
||||
super(m, Range.all());
|
||||
depth = d;
|
||||
channels = ch;
|
||||
if( !empty() && checkVector(channels, depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
protected void create(int cnt) {
|
||||
if(cnt>0)
|
||||
super.create(cnt, 1, CvType.makeType(depth, channels));
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorByte extends CvVector {
|
||||
private static final int _d = CvType.CV_8U;
|
||||
|
||||
public CvVectorByte(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorByte() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorByte(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorByte(long addr) {
|
||||
super(_d, 1, addr);
|
||||
}
|
||||
|
||||
public CvVectorByte(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorByte(int ch, byte[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] toPrimitiveArray(byte[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new byte[0];//null;
|
||||
byte[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new byte[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import org.opencv.features2d.DMatch;
|
||||
|
||||
public class CvVectorDMatch extends CvVectorFloat {
|
||||
private static final int _ch = 4; //xxxC4
|
||||
|
||||
public CvVectorDMatch() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorDMatch(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorDMatch(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorDMatch(DMatch...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
DMatch m = a[i];
|
||||
buff[_ch*i+0] = m.queryIdx;
|
||||
buff[_ch*i+1] = m.trainIdx;
|
||||
buff[_ch*i+2] = m.imgIdx;
|
||||
buff[_ch*i+3] = m.distance;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public DMatch[] toArray(DMatch[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new DMatch[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
DMatch[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new DMatch[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new DMatch((int) buff[_ch*i+0], (int) buff[_ch*i+1], (int) buff[_ch*i+2], buff[_ch*i+3]);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorDouble extends CvVector {
|
||||
private static final int _d = CvType.CV_64F;
|
||||
|
||||
public CvVectorDouble(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorDouble() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorDouble(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorDouble(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorDouble(int ch, double[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public double[] toPrimitiveArray(double[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new double[0];//null;
|
||||
double[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new double[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorFloat extends CvVector {
|
||||
private static final int _d = CvType.CV_32F;
|
||||
|
||||
public CvVectorFloat(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorFloat() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorFloat(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat(long addr) {
|
||||
super(_d, 1, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorFloat(int ch, float[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public float[] toPrimitiveArray(float[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new float[0];//null;
|
||||
float[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new float[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorFloat4 extends CvVectorFloat {
|
||||
private static final int _ch = 4; //xxxC4
|
||||
|
||||
public CvVectorFloat4() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorFloat4(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat4(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorFloat4(float[] a) {
|
||||
super(_ch, a);
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorFloat6 extends CvVectorFloat {
|
||||
private static final int _ch = 6; //xxxC6
|
||||
|
||||
public CvVectorFloat6() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorFloat6(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat6(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorFloat6(float[] a) {
|
||||
super(_ch, a);
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
|
||||
public class CvVectorInt extends CvVector {
|
||||
private static final int _d = CvType.CV_32S;
|
||||
|
||||
public CvVectorInt(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorInt() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorInt(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorInt(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorInt(int ch, int[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public int[] toPrimitiveArray(int[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new int[0];//null;
|
||||
int[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new int[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
|
||||
public class CvVectorKeyPoint extends CvVectorFloat {
|
||||
private static final int _ch = 7; //xxxC7
|
||||
|
||||
public CvVectorKeyPoint() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorKeyPoint(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorKeyPoint(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorKeyPoint(KeyPoint...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
KeyPoint kp = a[i];
|
||||
buff[_ch*i+0] = (float) kp.pt.x;
|
||||
buff[_ch*i+1] = (float) kp.pt.y;
|
||||
buff[_ch*i+2] = kp.size;
|
||||
buff[_ch*i+3] = kp.angle;
|
||||
buff[_ch*i+4] = kp.response;
|
||||
buff[_ch*i+5] = kp.octave;
|
||||
buff[_ch*i+6] = kp.class_id;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public KeyPoint[] toArray(KeyPoint[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new KeyPoint[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
KeyPoint[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new KeyPoint[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new KeyPoint( buff[_ch*i+0], buff[_ch*i+1], buff[_ch*i+2], buff[_ch*i+3],
|
||||
buff[_ch*i+4], (int) buff[_ch*i+5], (int) buff[_ch*i+6] );
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint extends CvVectorInt {
|
||||
private static final int _ch = 2; //xxxC2
|
||||
|
||||
public CvVectorPoint() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint(Point...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
int buff[] = new int[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Point p = a[i];
|
||||
buff[_ch*i+0] = (int) p.x;
|
||||
buff[_ch*i+1] = (int) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray(Point[] a) {
|
||||
int buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point(buff[i*_ch], buff[i*_ch+1]);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint2f extends CvVectorFloat {
|
||||
private static final int _ch = 2; //xxxC2
|
||||
|
||||
public CvVectorPoint2f() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint2f(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint2f(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint2f(Point...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Point p = a[i];
|
||||
buff[_ch*i+0] = (float) p.x;
|
||||
buff[_ch*i+1] = (float) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray(Point[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point(buff[i*_ch], buff[i*_ch+1]);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint3 extends CvVectorInt {
|
||||
private static final int _ch = 3; //xxxC2
|
||||
|
||||
public CvVectorPoint3() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint3(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint3(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint3(Point3...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
int buff[] = new int[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_ch*i] = (int) p.x;
|
||||
buff[_ch*i+1] = (int) p.y;
|
||||
buff[_ch*i+2] = (int) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray(Point3[] a) {
|
||||
int buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point3[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point3[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point3[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point3(buff[i*_ch], buff[i*_ch+1], buff[i*_ch+2]);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint3f extends CvVectorFloat {
|
||||
private static final int _ch = 3; //xxxC2
|
||||
|
||||
public CvVectorPoint3f() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint3f(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint3f(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint3f(Point3...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_ch*i] = (float) p.x;
|
||||
buff[_ch*i+1] = (float) p.y;
|
||||
buff[_ch*i+2] = (float) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray(Point3[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point3[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point3[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point3[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point3(buff[i*_ch], buff[i*_ch+1], buff[i*_ch+2]);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
|
||||
public class CvVectorRect extends CvVectorInt {
|
||||
private static final int _ch = 4; //xxxC4
|
||||
|
||||
public CvVectorRect() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorRect(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorRect(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorRect(Rect...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
int buff[] = new int[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Rect r = a[i];
|
||||
buff[_ch*i] = r.x;
|
||||
buff[_ch*i+1] = r.y;
|
||||
buff[_ch*i+2] = r.width;
|
||||
buff[_ch*i+3] = r.height;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Rect[] toArray(Rect[] a) {
|
||||
int buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Rect[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Rect[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Rect[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Rect(buff[i*_ch], buff[i*_ch+1], buff[i*_ch+2], buff[i*_ch+3]);
|
||||
return res;
|
||||
}
|
||||
}
|
81
modules/java/src/java/core+MatOfByte.java
Normal file
81
modules/java/src/java/core+MatOfByte.java
Normal file
@ -0,0 +1,81 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfByte extends Mat {
|
||||
// 8UC(x)
|
||||
private static final int _depth = CvType.CV_8U;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfByte(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfByte() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfByte(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfByte(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfByte(int channels, byte...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(byte...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public byte[] toArray() {
|
||||
int num = (int) total();
|
||||
byte[] a = new byte[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Byte> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Byte ab[] = lb.toArray(null);
|
||||
byte a[] = new byte[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Byte> toList() {
|
||||
byte[] a = toArray();
|
||||
Byte ab[] = new Byte[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
79
modules/java/src/java/core+MatOfDMatch.java
Normal file
79
modules/java/src/java/core+MatOfDMatch.java
Normal file
@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.features2d.DMatch;
|
||||
|
||||
public class MatOfDMatch extends Mat {
|
||||
// 32FC4
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfDMatch() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfDMatch(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDMatch(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDMatch(DMatch...ap) {
|
||||
super();
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
|
||||
public void fromArray(DMatch...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
DMatch m = a[i];
|
||||
buff[_channels*i+0] = m.queryIdx;
|
||||
buff[_channels*i+1] = m.trainIdx;
|
||||
buff[_channels*i+2] = m.imgIdx;
|
||||
buff[_channels*i+3] = m.distance;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public DMatch[] toArray() {
|
||||
int num = (int) total();
|
||||
DMatch[] a = new DMatch[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<DMatch> ldm) {
|
||||
DMatch adm[] = ldm.toArray(null);
|
||||
fromArray(adm);
|
||||
}
|
||||
|
||||
public List<DMatch> toList() {
|
||||
DMatch[] adm = toArray();
|
||||
return Arrays.asList(adm);
|
||||
}
|
||||
}
|
81
modules/java/src/java/core+MatOfDouble.java
Normal file
81
modules/java/src/java/core+MatOfDouble.java
Normal file
@ -0,0 +1,81 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfDouble extends Mat {
|
||||
// 64FC(x)
|
||||
private static final int _depth = CvType.CV_64F;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfDouble(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfDouble() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfDouble(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDouble(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDouble(int channels, double...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(double...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public double[] toArray() {
|
||||
int num = (int) total();
|
||||
double[] a = new double[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Double> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Double ab[] = lb.toArray(null);
|
||||
double a[] = new double[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Double> toList() {
|
||||
double[] a = toArray();
|
||||
Double ab[] = new Double[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
81
modules/java/src/java/core+MatOfFloat.java
Normal file
81
modules/java/src/java/core+MatOfFloat.java
Normal file
@ -0,0 +1,81 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfFloat extends Mat {
|
||||
// 32FC(x)
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfFloat(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfFloat() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfFloat(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfFloat(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfFloat(int channels, float...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(float...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public float[] toArray() {
|
||||
int num = (int) total();
|
||||
float[] a = new float[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Float> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Float ab[] = lb.toArray(null);
|
||||
float a[] = new float[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Float> toList() {
|
||||
float[] a = toArray();
|
||||
Float ab[] = new Float[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
82
modules/java/src/java/core+MatOfInt.java
Normal file
82
modules/java/src/java/core+MatOfInt.java
Normal file
@ -0,0 +1,82 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MatOfInt extends Mat {
|
||||
// 32SC(x)
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfInt(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfInt() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfInt(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfInt(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfInt(int channels, int...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(int...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public int[] toArray() {
|
||||
int num = (int) total();
|
||||
int[] a = new int[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Integer> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Integer ab[] = lb.toArray(null);
|
||||
int a[] = new int[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Integer> toList() {
|
||||
int[] a = toArray();
|
||||
Integer ab[] = new Integer[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
82
modules/java/src/java/core+MatOfKeyPoint.java
Normal file
82
modules/java/src/java/core+MatOfKeyPoint.java
Normal file
@ -0,0 +1,82 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
|
||||
public class MatOfKeyPoint extends Mat {
|
||||
// 32FC7
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 7;
|
||||
|
||||
public MatOfKeyPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(KeyPoint...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(KeyPoint...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
KeyPoint kp = a[i];
|
||||
buff[_channels*i+0] = (float) kp.pt.x;
|
||||
buff[_channels*i+1] = (float) kp.pt.y;
|
||||
buff[_channels*i+2] = kp.size;
|
||||
buff[_channels*i+3] = kp.angle;
|
||||
buff[_channels*i+4] = kp.response;
|
||||
buff[_channels*i+5] = kp.octave;
|
||||
buff[_channels*i+6] = kp.class_id;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public KeyPoint[] toArray() {
|
||||
int num = (int) total();
|
||||
KeyPoint[] a = new KeyPoint[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new KeyPoint( buff[_channels*i+0], buff[_channels*i+1], buff[_channels*i+2], buff[_channels*i+3],
|
||||
buff[_channels*i+4], (int) buff[_channels*i+5], (int) buff[_channels*i+6] );
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<KeyPoint> lkp) {
|
||||
KeyPoint akp[] = lkp.toArray(null);
|
||||
fromArray(akp);
|
||||
}
|
||||
|
||||
public List<KeyPoint> toList() {
|
||||
KeyPoint[] akp = toArray();
|
||||
return Arrays.asList(akp);
|
||||
}
|
||||
}
|
74
modules/java/src/java/core+MatOfPoint.java
Normal file
74
modules/java/src/java/core+MatOfPoint.java
Normal file
@ -0,0 +1,74 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint extends Mat {
|
||||
// 32SC2
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 2;
|
||||
|
||||
public MatOfPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint(Point...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point p = a[i];
|
||||
buff[_channels*i+0] = (int) p.x;
|
||||
buff[_channels*i+1] = (int) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray() {
|
||||
int num = (int) total();
|
||||
Point[] ap = new Point[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point> lp) {
|
||||
Point ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point> toList() {
|
||||
Point[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
74
modules/java/src/java/core+MatOfPoint2f.java
Normal file
74
modules/java/src/java/core+MatOfPoint2f.java
Normal file
@ -0,0 +1,74 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint2f extends Mat {
|
||||
// 32FC2
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 2;
|
||||
|
||||
public MatOfPoint2f() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint2f(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint2f(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint2f(Point...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point p = a[i];
|
||||
buff[_channels*i+0] = (float) p.x;
|
||||
buff[_channels*i+1] = (float) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray() {
|
||||
int num = (int) total();
|
||||
Point[] ap = new Point[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point> lp) {
|
||||
Point ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point> toList() {
|
||||
Point[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
75
modules/java/src/java/core+MatOfPoint3.java
Normal file
75
modules/java/src/java/core+MatOfPoint3.java
Normal file
@ -0,0 +1,75 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint3 extends Mat {
|
||||
// 32SC3
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 3;
|
||||
|
||||
public MatOfPoint3() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint3(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3(Point3...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point3...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_channels*i+0] = (int) p.x;
|
||||
buff[_channels*i+1] = (int) p.y;
|
||||
buff[_channels*i+2] = (int) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray() {
|
||||
int num = (int) total();
|
||||
Point3[] ap = new Point3[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point3> lp) {
|
||||
Point3 ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point3> toList() {
|
||||
Point3[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
75
modules/java/src/java/core+MatOfPoint3f.java
Normal file
75
modules/java/src/java/core+MatOfPoint3f.java
Normal file
@ -0,0 +1,75 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint3f extends Mat {
|
||||
// 32FC3
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 3;
|
||||
|
||||
public MatOfPoint3f() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint3f(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3f(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3f(Point3...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point3...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_channels*i+0] = (float) p.x;
|
||||
buff[_channels*i+1] = (float) p.y;
|
||||
buff[_channels*i+2] = (float) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray() {
|
||||
int num = (int) total();
|
||||
Point3[] ap = new Point3[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point3> lp) {
|
||||
Point3 ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point3> toList() {
|
||||
Point3[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
77
modules/java/src/java/core+MatOfRect.java
Normal file
77
modules/java/src/java/core+MatOfRect.java
Normal file
@ -0,0 +1,77 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MatOfRect extends Mat {
|
||||
// 32SC4
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfRect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfRect(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfRect(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfRect(Rect...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Rect...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Rect r = a[i];
|
||||
buff[_channels*i+0] = (int) r.x;
|
||||
buff[_channels*i+1] = (int) r.y;
|
||||
buff[_channels*i+2] = (int) r.width;
|
||||
buff[_channels*i+3] = (int) r.height;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
|
||||
public Rect[] toArray() {
|
||||
int num = (int) total();
|
||||
Rect[] a = new Rect[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
|
||||
return a;
|
||||
}
|
||||
public void fromList(List<Rect> lr) {
|
||||
Rect ap[] = lr.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Rect> toList() {
|
||||
Rect[] ar = toArray();
|
||||
return Arrays.asList(ar);
|
||||
}
|
||||
}
|
@ -4,15 +4,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.CvVectorPoint2f;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.MatOfPoint;
|
||||
import org.opencv.core.MatOfPoint2f;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Point3;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.core.CvVectorByte;
|
||||
import org.opencv.core.CvVectorDMatch;
|
||||
import org.opencv.core.CvVectorKeyPoint;
|
||||
import org.opencv.core.CvVectorPoint;
|
||||
import org.opencv.features2d.DMatch;
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
|
||||
@ -475,11 +475,11 @@ public class Converters {
|
||||
}
|
||||
|
||||
// vector_vector_Point
|
||||
public static Mat vector_vector_Point_to_Mat(List<CvVectorPoint> pts, List<Mat> mats) {
|
||||
public static Mat vector_vector_Point_to_Mat(List<MatOfPoint> pts, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (pts != null) ? pts.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorPoint vpt : pts)
|
||||
for (MatOfPoint vpt : pts)
|
||||
mats.add(vpt);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
@ -488,7 +488,7 @@ public class Converters {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_Point(Mat m, List<CvVectorPoint> pts) {
|
||||
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) {
|
||||
if (pts == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@ -498,13 +498,13 @@ public class Converters {
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
for (Mat mi : mats) {
|
||||
CvVectorPoint pt = new CvVectorPoint(mi);
|
||||
MatOfPoint pt = new MatOfPoint(mi);
|
||||
pts.add(pt);
|
||||
}
|
||||
}
|
||||
|
||||
// vector_vector_Point2f
|
||||
public static void Mat_to_vector_vector_Point2f(Mat m, List<CvVectorPoint2f> pts) {
|
||||
public static void Mat_to_vector_vector_Point2f(Mat m, List<MatOfPoint2f> pts) {
|
||||
if (pts == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@ -514,17 +514,17 @@ public class Converters {
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
for (Mat mi : mats) {
|
||||
CvVectorPoint2f pt = new CvVectorPoint2f(mi);
|
||||
MatOfPoint2f pt = new MatOfPoint2f(mi);
|
||||
pts.add(pt);
|
||||
}
|
||||
}
|
||||
|
||||
// vector_vector_KeyPoint
|
||||
public static Mat vector_vector_KeyPoint_to_Mat(List<CvVectorKeyPoint> kps, List<Mat> mats) {
|
||||
public static Mat vector_vector_KeyPoint_to_Mat(List<MatOfKeyPoint> kps, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (kps != null) ? kps.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorKeyPoint vkp : kps)
|
||||
for (MatOfKeyPoint vkp : kps)
|
||||
mats.add(vkp);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
@ -533,7 +533,7 @@ public class Converters {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_KeyPoint(Mat m, List<CvVectorKeyPoint> kps) {
|
||||
public static void Mat_to_vector_vector_KeyPoint(Mat m, List<MatOfKeyPoint> kps) {
|
||||
if (kps == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@ -543,7 +543,7 @@ public class Converters {
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
for (Mat mi : mats) {
|
||||
CvVectorKeyPoint vkp = new CvVectorKeyPoint(mi);
|
||||
MatOfKeyPoint vkp = new MatOfKeyPoint(mi);
|
||||
kps.add(vkp);
|
||||
}
|
||||
}
|
||||
@ -618,11 +618,11 @@ public class Converters {
|
||||
}
|
||||
|
||||
// vector_vector_DMatch
|
||||
public static Mat vector_vector_DMatch_to_Mat(List<CvVectorDMatch> lvdm, List<Mat> mats) {
|
||||
public static Mat vector_vector_DMatch_to_Mat(List<MatOfDMatch> lvdm, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (lvdm != null) ? lvdm.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorDMatch vdm : lvdm)
|
||||
for (MatOfDMatch vdm : lvdm)
|
||||
mats.add(vdm);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
@ -631,7 +631,7 @@ public class Converters {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_DMatch(Mat m, List<CvVectorDMatch> lvdm) {
|
||||
public static void Mat_to_vector_vector_DMatch(Mat m, List<MatOfDMatch> lvdm) {
|
||||
if (lvdm == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@ -642,17 +642,17 @@ public class Converters {
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
lvdm.clear();
|
||||
for (Mat mi : mats) {
|
||||
CvVectorDMatch vdm = new CvVectorDMatch(mi);
|
||||
MatOfDMatch vdm = new MatOfDMatch(mi);
|
||||
lvdm.add(vdm);
|
||||
}
|
||||
}
|
||||
|
||||
// vector_vector_char
|
||||
public static Mat vector_vector_char_to_Mat(List<CvVectorByte> lvb, List<Mat> mats) {
|
||||
public static Mat vector_vector_char_to_Mat(List<MatOfByte> lvb, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (lvb != null) ? lvb.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorByte vb : lvb)
|
||||
for (MatOfByte vb : lvb)
|
||||
mats.add(vb);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user