Java API: fixing Calib3d tests
This commit is contained in:
parent
51338ec7c3
commit
cd8dfd6c5d
@ -1,14 +1,12 @@
|
|||||||
package org.opencv.test.calib3d;
|
package org.opencv.test.calib3d;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.opencv.calib3d.Calib3d;
|
import org.opencv.calib3d.Calib3d;
|
||||||
import org.opencv.core.Core;
|
import org.opencv.core.Core;
|
||||||
import org.opencv.core.CvType;
|
import org.opencv.core.CvType;
|
||||||
|
import org.opencv.core.CvVectorPoint2f;
|
||||||
|
import org.opencv.core.CvVectorPoint3f;
|
||||||
import org.opencv.core.Mat;
|
import org.opencv.core.Mat;
|
||||||
import org.opencv.core.Point;
|
import org.opencv.core.Point;
|
||||||
import org.opencv.core.Point3;
|
|
||||||
import org.opencv.core.Scalar;
|
import org.opencv.core.Scalar;
|
||||||
import org.opencv.core.Size;
|
import org.opencv.core.Size;
|
||||||
import org.opencv.test.OpenCVTestCase;
|
import org.opencv.test.OpenCVTestCase;
|
||||||
@ -235,15 +233,16 @@ public class Calib3dTest extends OpenCVTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testFindFundamentalMatListOfPointListOfPoint() {
|
public void testFindFundamentalMatListOfPointListOfPoint() {
|
||||||
List<Point> pts1 = new ArrayList<Point>();
|
|
||||||
List<Point> pts2 = new ArrayList<Point>();
|
|
||||||
|
|
||||||
int minFundamentalMatPoints = 8;
|
int minFundamentalMatPoints = 8;
|
||||||
|
|
||||||
|
CvVectorPoint2f pts1 = new CvVectorPoint2f();
|
||||||
|
CvVectorPoint2f pts2 = new CvVectorPoint2f(minFundamentalMatPoints);
|
||||||
|
|
||||||
for (int i = 0; i < minFundamentalMatPoints; i++) {
|
for (int i = 0; i < minFundamentalMatPoints; i++) {
|
||||||
double x = Math.random() * 100 - 50;
|
double x = Math.random() * 100 - 50;
|
||||||
double y = Math.random() * 100 - 50;
|
double y = Math.random() * 100 - 50;
|
||||||
pts1.add(new Point(x, y));
|
pts1.push_back(new CvVectorPoint2f(new Point(x, y))); //add(new Point(x, y));
|
||||||
pts2.add(new Point(x, y));
|
pts2.put(i, 0, x, y); //add(new Point(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat fm = Calib3d.findFundamentalMat(pts1, pts2);
|
Mat fm = Calib3d.findFundamentalMat(pts1, pts2);
|
||||||
@ -270,14 +269,16 @@ public class Calib3dTest extends OpenCVTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testFindHomographyListOfPointListOfPoint() {
|
public void testFindHomographyListOfPointListOfPoint() {
|
||||||
List<Point> originalPoints = new ArrayList<Point>();
|
final int NUM = 20;
|
||||||
List<Point> transformedPoints = new ArrayList<Point>();
|
|
||||||
|
CvVectorPoint2f originalPoints = new CvVectorPoint2f(NUM);
|
||||||
|
CvVectorPoint2f transformedPoints = new CvVectorPoint2f(NUM);
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < NUM; i++) {
|
||||||
double x = Math.random() * 100 - 50;
|
double x = Math.random() * 100 - 50;
|
||||||
double y = Math.random() * 100 - 50;
|
double y = Math.random() * 100 - 50;
|
||||||
originalPoints.add(new Point(x, y));
|
originalPoints.put(i, 0, x, y); //add(new Point(x, y));
|
||||||
transformedPoints.add(new Point(y, x));
|
transformedPoints.put(i, 0, x, y); //add(new Point(y, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat hmg = Calib3d.findHomography(originalPoints, transformedPoints);
|
Mat hmg = Calib3d.findHomography(originalPoints, transformedPoints);
|
||||||
@ -497,15 +498,16 @@ public class Calib3dTest extends OpenCVTestCase {
|
|||||||
intrinsics.put(0, 2, 640 / 2);
|
intrinsics.put(0, 2, 640 / 2);
|
||||||
intrinsics.put(1, 2, 480 / 2);
|
intrinsics.put(1, 2, 480 / 2);
|
||||||
|
|
||||||
List<Point3> points3d = new ArrayList<Point3>();
|
final int minPnpPointsNum = 4;
|
||||||
List<Point> points2d = new ArrayList<Point>();
|
|
||||||
int minPnpPointsNum = 4;
|
CvVectorPoint3f points3d = new CvVectorPoint3f(minPnpPointsNum);
|
||||||
|
CvVectorPoint2f points2d = new CvVectorPoint2f(minPnpPointsNum);
|
||||||
|
|
||||||
for (int i = 0; i < minPnpPointsNum; i++) {
|
for (int i = 0; i < minPnpPointsNum; i++) {
|
||||||
double x = Math.random() * 100 - 50;
|
double x = Math.random() * 100 - 50;
|
||||||
double y = Math.random() * 100 - 50;
|
double y = Math.random() * 100 - 50;
|
||||||
points2d.add(new Point(x, y));
|
points2d.put(i, 0, x, y); //add(new Point(x, y));
|
||||||
points3d.add(new Point3(0, y, x));
|
points3d.put(i, 0, 0, y, x); // add(new Point3(0, y, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat rvec = new Mat();
|
Mat rvec = new Mat();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user