Java API: changing CvVectorXxx to MatOfXxx

This commit is contained in:
Andrey Pavlenko
2012-04-06 09:30:42 +00:00
parent 85fa0e7763
commit 6c0ab28d8b
33 changed files with 978 additions and 693 deletions

View File

@@ -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++) {

View File

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

View File

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

View File

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

View File

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

View File

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