mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
604 lines
19 KiB
604 lines
19 KiB
14 years ago
|
package org.opencv.test.calib3d;
|
||
|
|
||
14 years ago
|
import org.opencv.calib3d.Calib3d;
|
||
|
import org.opencv.core.Core;
|
||
14 years ago
|
import org.opencv.core.CvType;
|
||
|
import org.opencv.core.Mat;
|
||
13 years ago
|
import org.opencv.core.MatOfDouble;
|
||
13 years ago
|
import org.opencv.core.MatOfPoint2f;
|
||
|
import org.opencv.core.MatOfPoint3f;
|
||
14 years ago
|
import org.opencv.core.Point;
|
||
|
import org.opencv.core.Scalar;
|
||
|
import org.opencv.core.Size;
|
||
14 years ago
|
import org.opencv.test.OpenCVTestCase;
|
||
10 years ago
|
import org.opencv.imgproc.Imgproc;
|
||
14 years ago
|
|
||
14 years ago
|
public class Calib3dTest extends OpenCVTestCase {
|
||
14 years ago
|
|
||
|
public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMatInt() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testCalibrationMatrixValues() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMat() {
|
||
|
Mat rvec1 = new Mat(3, 1, CvType.CV_32F);
|
||
|
rvec1.put(0, 0, 0.5302828, 0.19925919, 0.40105945);
|
||
|
Mat tvec1 = new Mat(3, 1, CvType.CV_32F);
|
||
|
tvec1.put(0, 0, 0.81438506, 0.43713298, 0.2487897);
|
||
|
Mat rvec2 = new Mat(3, 1, CvType.CV_32F);
|
||
|
rvec2.put(0, 0, 0.77310503, 0.76209372, 0.30779448);
|
||
|
Mat tvec2 = new Mat(3, 1, CvType.CV_32F);
|
||
|
tvec2.put(0, 0, 0.70243168, 0.4784472, 0.79219002);
|
||
|
|
||
|
Mat rvec3 = new Mat();
|
||
|
Mat tvec3 = new Mat();
|
||
|
|
||
|
Mat outRvec = new Mat(3, 1, CvType.CV_32F);
|
||
|
outRvec.put(0, 0, 1.418641, 0.88665926, 0.56020796);
|
||
|
Mat outTvec = new Mat(3, 1, CvType.CV_32F);
|
||
|
outTvec.put(0, 0, 1.4560841, 1.0680628, 0.81598103);
|
||
|
|
||
|
Calib3d.composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3);
|
||
|
|
||
14 years ago
|
assertMatEqual(outRvec, rvec3, EPS);
|
||
|
assertMatEqual(outTvec, tvec3, EPS);
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
// Mat dr3dr1;
|
||
|
// Mat dr3dt1;
|
||
|
// Mat dr3dr2;
|
||
|
// Mat dr3dt2;
|
||
|
// Mat dt3dr1;
|
||
|
// Mat dt3dt1;
|
||
|
// Mat dt3dr2;
|
||
|
// Mat dt3dt2;
|
||
|
// , dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2);
|
||
|
// [0.97031879, -0.091774099, 0.38594806;
|
||
|
// 0.15181915, 0.98091727, -0.44186208;
|
||
|
// -0.39509675, 0.43839464, 0.93872648]
|
||
|
// [0, 0, 0;
|
||
|
// 0, 0, 0;
|
||
|
// 0, 0, 0]
|
||
|
// [1.0117353, 0.16348237, -0.083180845;
|
||
|
// -0.1980398, 1.006078, 0.30299222;
|
||
|
// 0.075766489, -0.32784501, 1.0163091]
|
||
|
// [0, 0, 0;
|
||
|
// 0, 0, 0;
|
||
|
// 0, 0, 0]
|
||
|
// [0, 0, 0;
|
||
|
// 0, 0, 0;
|
||
|
// 0, 0, 0]
|
||
|
// [0.69658804, 0.018115902, 0.7172426;
|
||
|
// 0.51114357, 0.68899536, -0.51382649;
|
||
|
// -0.50348526, 0.72453934, 0.47068608]
|
||
|
// [0.18536358, -0.20515044, -0.48834875;
|
||
|
// -0.25120571, 0.29043972, 0.60573936;
|
||
|
// 0.35370794, -0.69923931, 0.45781645]
|
||
|
// [1, 0, 0;
|
||
|
// 0, 1, 0;
|
||
|
// 0, 0, 1]
|
||
|
}
|
||
|
|
||
|
public void testConvertPointsFromHomogeneous() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testConvertPointsToHomogeneous() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testDecomposeProjectionMatrixMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testDecomposeProjectionMatrixMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testDecomposeProjectionMatrixMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testDecomposeProjectionMatrixMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testDecomposeProjectionMatrixMatMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testDrawChessboardCorners() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testEstimateAffine3DMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testEstimateAffine3DMatMatMatMatDouble() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testEstimateAffine3DMatMatMatMatDoubleDouble() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testFilterSpecklesMatDoubleIntDouble() {
|
||
|
gray_16s_1024.copyTo(dst);
|
||
14 years ago
|
Point center = new Point(gray_16s_1024.rows() / 2., gray_16s_1024.cols() / 2.);
|
||
10 years ago
|
Imgproc.circle(dst, center, 1, Scalar.all(4096));
|
||
14 years ago
|
|
||
|
assertMatNotEqual(gray_16s_1024, dst);
|
||
|
Calib3d.filterSpeckles(dst, 1024.0, 100, 0.);
|
||
|
assertMatEqual(gray_16s_1024, dst);
|
||
|
}
|
||
|
|
||
|
public void testFilterSpecklesMatDoubleIntDoubleMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testFindChessboardCornersMatSizeMat() {
|
||
|
Size patternSize = new Size(9, 6);
|
||
13 years ago
|
MatOfPoint2f corners = new MatOfPoint2f();
|
||
|
Calib3d.findChessboardCorners(grayChess, patternSize, corners);
|
||
|
assertTrue(!corners.empty());
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testFindChessboardCornersMatSizeMatInt() {
|
||
|
Size patternSize = new Size(9, 6);
|
||
13 years ago
|
MatOfPoint2f corners = new MatOfPoint2f();
|
||
|
Calib3d.findChessboardCorners(grayChess, patternSize, corners, Calib3d.CALIB_CB_ADAPTIVE_THRESH + Calib3d.CALIB_CB_NORMALIZE_IMAGE
|
||
14 years ago
|
+ Calib3d.CALIB_CB_FAST_CHECK);
|
||
13 years ago
|
assertTrue(!corners.empty());
|
||
14 years ago
|
}
|
||
|
|
||
12 years ago
|
public void testFindCirclesGridMatSizeMat() {
|
||
14 years ago
|
int size = 300;
|
||
|
Mat img = new Mat(size, size, CvType.CV_8U);
|
||
|
img.setTo(new Scalar(255));
|
||
|
Mat centers = new Mat();
|
||
|
|
||
12 years ago
|
assertFalse(Calib3d.findCirclesGrid(img, new Size(5, 5), centers));
|
||
14 years ago
|
|
||
|
for (int i = 0; i < 5; i++)
|
||
|
for (int j = 0; j < 5; j++) {
|
||
14 years ago
|
Point pt = new Point(size * (2 * i + 1) / 10, size * (2 * j + 1) / 10);
|
||
10 years ago
|
Imgproc.circle(img, pt, 10, new Scalar(0), -1);
|
||
14 years ago
|
}
|
||
|
|
||
12 years ago
|
assertTrue(Calib3d.findCirclesGrid(img, new Size(5, 5), centers));
|
||
14 years ago
|
|
||
14 years ago
|
assertEquals(25, centers.rows());
|
||
|
assertEquals(1, centers.cols());
|
||
|
assertEquals(CvType.CV_32FC2, centers.type());
|
||
|
}
|
||
|
|
||
12 years ago
|
public void testFindCirclesGridMatSizeMatInt() {
|
||
14 years ago
|
int size = 300;
|
||
|
Mat img = new Mat(size, size, CvType.CV_8U);
|
||
|
img.setTo(new Scalar(255));
|
||
|
Mat centers = new Mat();
|
||
|
|
||
12 years ago
|
assertFalse(Calib3d.findCirclesGrid(img, new Size(3, 5), centers, Calib3d.CALIB_CB_CLUSTERING
|
||
14 years ago
|
| Calib3d.CALIB_CB_ASYMMETRIC_GRID));
|
||
14 years ago
|
|
||
|
int step = size * 2 / 15;
|
||
|
int offsetx = size / 6;
|
||
|
int offsety = (size - 4 * step) / 2;
|
||
|
for (int i = 0; i < 3; i++)
|
||
|
for (int j = 0; j < 5; j++) {
|
||
14 years ago
|
Point pt = new Point(offsetx + (2 * i + j % 2) * step, offsety + step * j);
|
||
10 years ago
|
Imgproc.circle(img, pt, 10, new Scalar(0), -1);
|
||
14 years ago
|
}
|
||
|
|
||
12 years ago
|
assertTrue(Calib3d.findCirclesGrid(img, new Size(3, 5), centers, Calib3d.CALIB_CB_CLUSTERING
|
||
14 years ago
|
| Calib3d.CALIB_CB_ASYMMETRIC_GRID));
|
||
14 years ago
|
|
||
14 years ago
|
assertEquals(15, centers.rows());
|
||
|
assertEquals(1, centers.cols());
|
||
|
assertEquals(CvType.CV_32FC2, centers.type());
|
||
|
}
|
||
|
|
||
14 years ago
|
public void testFindFundamentalMatListOfPointListOfPoint() {
|
||
14 years ago
|
int minFundamentalMatPoints = 8;
|
||
13 years ago
|
|
||
12 years ago
|
MatOfPoint2f pts = new MatOfPoint2f();
|
||
|
pts.alloc(minFundamentalMatPoints);
|
||
13 years ago
|
|
||
14 years ago
|
for (int i = 0; i < minFundamentalMatPoints; i++) {
|
||
|
double x = Math.random() * 100 - 50;
|
||
|
double y = Math.random() * 100 - 50;
|
||
13 years ago
|
pts.put(i, 0, x, y); //add(new Point(x, y));
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
13 years ago
|
Mat fm = Calib3d.findFundamentalMat(pts, pts);
|
||
14 years ago
|
|
||
|
truth = new Mat(3, 3, CvType.CV_64F);
|
||
13 years ago
|
truth.put(0, 0, 0, -0.577, 0.288, 0.577, 0, 0.288, -0.288, -0.288, 0);
|
||
14 years ago
|
assertMatEqual(truth, fm, EPS);
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
public void testFindFundamentalMatListOfPointListOfPointInt() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
14 years ago
|
public void testFindFundamentalMatListOfPointListOfPointIntDouble() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
14 years ago
|
public void testFindFundamentalMatListOfPointListOfPointIntDoubleDouble() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
14 years ago
|
public void testFindFundamentalMatListOfPointListOfPointIntDoubleDoubleMat() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
14 years ago
|
public void testFindHomographyListOfPointListOfPoint() {
|
||
12 years ago
|
final int NUM = 20;
|
||
|
|
||
|
MatOfPoint2f originalPoints = new MatOfPoint2f();
|
||
|
originalPoints.alloc(NUM);
|
||
|
MatOfPoint2f transformedPoints = new MatOfPoint2f();
|
||
|
transformedPoints.alloc(NUM);
|
||
13 years ago
|
|
||
|
for (int i = 0; i < NUM; i++) {
|
||
14 years ago
|
double x = Math.random() * 100 - 50;
|
||
|
double y = Math.random() * 100 - 50;
|
||
13 years ago
|
originalPoints.put(i, 0, x, y);
|
||
|
transformedPoints.put(i, 0, y, x);
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
14 years ago
|
Mat hmg = Calib3d.findHomography(originalPoints, transformedPoints);
|
||
14 years ago
|
|
||
|
truth = new Mat(3, 3, CvType.CV_64F);
|
||
|
truth.put(0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1);
|
||
|
|
||
14 years ago
|
assertMatEqual(truth, hmg, EPS);
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
public void testFindHomographyListOfPointListOfPointInt() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
14 years ago
|
public void testFindHomographyListOfPointListOfPointIntDouble() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
14 years ago
|
public void testFindHomographyListOfPointListOfPointIntDoubleMat() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testGetOptimalNewCameraMatrixMatMatSizeDouble() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSize() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRect() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRectBoolean() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testGetValidDisparityROI() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testInitCameraMatrix2DListOfMatListOfMatSize() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testInitCameraMatrix2DListOfMatListOfMatSizeDouble() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testMatMulDeriv() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testProjectPointsMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testProjectPointsMatMatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testProjectPointsMatMatMatMatMatMatMatDouble() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testRectify3Collinear() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
|
|
||
|
public void testReprojectImageTo3DMatMatMat() {
|
||
14 years ago
|
Mat transformMatrix = new Mat(4, 4, CvType.CV_64F);
|
||
|
transformMatrix.put(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
||
|
|
||
|
Mat disparity = new Mat(matSize, matSize, CvType.CV_32F);
|
||
|
|
||
14 years ago
|
float[] disp = new float[matSize * matSize];
|
||
|
for (int i = 0; i < matSize; i++)
|
||
14 years ago
|
for (int j = 0; j < matSize; j++)
|
||
14 years ago
|
disp[i * matSize + j] = i - j;
|
||
|
disparity.put(0, 0, disp);
|
||
14 years ago
|
|
||
14 years ago
|
Mat _3dPoints = new Mat();
|
||
14 years ago
|
|
||
14 years ago
|
Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix);
|
||
14 years ago
|
|
||
14 years ago
|
assertEquals(CvType.CV_32FC3, _3dPoints.type());
|
||
|
assertEquals(matSize, _3dPoints.rows());
|
||
|
assertEquals(matSize, _3dPoints.cols());
|
||
14 years ago
|
|
||
|
truth = new Mat(matSize, matSize, CvType.CV_32FC3);
|
||
|
|
||
14 years ago
|
float[] _truth = new float[matSize * matSize * 3];
|
||
|
for (int i = 0; i < matSize; i++)
|
||
14 years ago
|
for (int j = 0; j < matSize; j++) {
|
||
14 years ago
|
_truth[(i * matSize + j) * 3 + 0] = i;
|
||
|
_truth[(i * matSize + j) * 3 + 1] = j;
|
||
14 years ago
|
_truth[(i * matSize + j) * 3 + 2] = i - j;
|
||
14 years ago
|
}
|
||
|
truth.put(0, 0, _truth);
|
||
14 years ago
|
|
||
14 years ago
|
assertMatEqual(truth, _3dPoints, EPS);
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testReprojectImageTo3DMatMatMatBoolean() {
|
||
14 years ago
|
Mat transformMatrix = new Mat(4, 4, CvType.CV_64F);
|
||
|
transformMatrix.put(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
||
|
|
||
|
Mat disparity = new Mat(matSize, matSize, CvType.CV_32F);
|
||
|
|
||
14 years ago
|
float[] disp = new float[matSize * matSize];
|
||
|
for (int i = 0; i < matSize; i++)
|
||
14 years ago
|
for (int j = 0; j < matSize; j++)
|
||
14 years ago
|
disp[i * matSize + j] = i - j;
|
||
|
disp[0] = -Float.MAX_VALUE;
|
||
|
disparity.put(0, 0, disp);
|
||
14 years ago
|
|
||
14 years ago
|
Mat _3dPoints = new Mat();
|
||
14 years ago
|
|
||
14 years ago
|
Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix, true);
|
||
14 years ago
|
|
||
14 years ago
|
assertEquals(CvType.CV_32FC3, _3dPoints.type());
|
||
|
assertEquals(matSize, _3dPoints.rows());
|
||
|
assertEquals(matSize, _3dPoints.cols());
|
||
14 years ago
|
|
||
|
truth = new Mat(matSize, matSize, CvType.CV_32FC3);
|
||
|
|
||
14 years ago
|
float[] _truth = new float[matSize * matSize * 3];
|
||
|
for (int i = 0; i < matSize; i++)
|
||
14 years ago
|
for (int j = 0; j < matSize; j++) {
|
||
14 years ago
|
_truth[(i * matSize + j) * 3 + 0] = i;
|
||
|
_truth[(i * matSize + j) * 3 + 1] = j;
|
||
14 years ago
|
_truth[(i * matSize + j) * 3 + 2] = i - j;
|
||
14 years ago
|
}
|
||
|
_truth[2] = 10000;
|
||
|
truth.put(0, 0, _truth);
|
||
14 years ago
|
|
||
14 years ago
|
assertMatEqual(truth, _3dPoints, EPS);
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testReprojectImageTo3DMatMatMatBooleanInt() {
|
||
14 years ago
|
Mat transformMatrix = new Mat(4, 4, CvType.CV_64F);
|
||
|
transformMatrix.put(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
||
|
|
||
|
Mat disparity = new Mat(matSize, matSize, CvType.CV_32F);
|
||
|
|
||
14 years ago
|
float[] disp = new float[matSize * matSize];
|
||
|
for (int i = 0; i < matSize; i++)
|
||
14 years ago
|
for (int j = 0; j < matSize; j++)
|
||
14 years ago
|
disp[i * matSize + j] = i - j;
|
||
|
disparity.put(0, 0, disp);
|
||
14 years ago
|
|
||
14 years ago
|
Mat _3dPoints = new Mat();
|
||
14 years ago
|
|
||
14 years ago
|
Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix, false, CvType.CV_16S);
|
||
14 years ago
|
|
||
14 years ago
|
assertEquals(CvType.CV_16SC3, _3dPoints.type());
|
||
|
assertEquals(matSize, _3dPoints.rows());
|
||
|
assertEquals(matSize, _3dPoints.cols());
|
||
14 years ago
|
|
||
|
truth = new Mat(matSize, matSize, CvType.CV_16SC3);
|
||
|
|
||
14 years ago
|
short[] _truth = new short[matSize * matSize * 3];
|
||
|
for (short i = 0; i < matSize; i++)
|
||
14 years ago
|
for (short j = 0; j < matSize; j++) {
|
||
14 years ago
|
_truth[(i * matSize + j) * 3 + 0] = i;
|
||
|
_truth[(i * matSize + j) * 3 + 1] = j;
|
||
14 years ago
|
_truth[(i * matSize + j) * 3 + 2] = (short) (i - j);
|
||
14 years ago
|
}
|
||
|
truth.put(0, 0, _truth);
|
||
14 years ago
|
|
||
14 years ago
|
assertMatEqual(truth, _3dPoints, EPS);
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testRodriguesMatMat() {
|
||
14 years ago
|
Mat r = new Mat(3, 1, CvType.CV_32F);
|
||
|
Mat R = new Mat(3, 3, CvType.CV_32F);
|
||
|
|
||
14 years ago
|
r.put(0, 0, Math.PI, 0, 0);
|
||
14 years ago
|
|
||
14 years ago
|
Calib3d.Rodrigues(r, R);
|
||
14 years ago
|
|
||
|
truth = new Mat(3, 3, CvType.CV_32F);
|
||
|
truth.put(0, 0, 1, 0, 0, 0, -1, 0, 0, 0, -1);
|
||
14 years ago
|
assertMatEqual(truth, R, EPS);
|
||
14 years ago
|
|
||
14 years ago
|
Mat r2 = new Mat();
|
||
|
Calib3d.Rodrigues(R, r2);
|
||
14 years ago
|
|
||
14 years ago
|
assertMatEqual(r, r2, EPS);
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testRodriguesMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testRQDecomp3x3MatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testRQDecomp3x3MatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testRQDecomp3x3MatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testRQDecomp3x3MatMatMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPListOfPoint3ListOfPointMatMatMatMat() {
|
||
14 years ago
|
Mat intrinsics = Mat.eye(3, 3, CvType.CV_32F);
|
||
|
intrinsics.put(0, 0, 400);
|
||
|
intrinsics.put(1, 1, 400);
|
||
|
intrinsics.put(0, 2, 640 / 2);
|
||
|
intrinsics.put(1, 2, 480 / 2);
|
||
|
|
||
13 years ago
|
final int minPnpPointsNum = 4;
|
||
12 years ago
|
|
||
13 years ago
|
MatOfPoint3f points3d = new MatOfPoint3f();
|
||
|
points3d.alloc(minPnpPointsNum);
|
||
|
MatOfPoint2f points2d = new MatOfPoint2f();
|
||
|
points2d.alloc(minPnpPointsNum);
|
||
14 years ago
|
|
||
|
for (int i = 0; i < minPnpPointsNum; i++) {
|
||
|
double x = Math.random() * 100 - 50;
|
||
|
double y = Math.random() * 100 - 50;
|
||
13 years ago
|
points2d.put(i, 0, x, y); //add(new Point(x, y));
|
||
|
points3d.put(i, 0, 0, y, x); // add(new Point3(0, y, x));
|
||
14 years ago
|
}
|
||
|
|
||
|
Mat rvec = new Mat();
|
||
|
Mat tvec = new Mat();
|
||
13 years ago
|
Calib3d.solvePnP(points3d, points2d, intrinsics, new MatOfDouble(), rvec, tvec);
|
||
14 years ago
|
|
||
|
Mat truth_rvec = new Mat(3, 1, CvType.CV_64F);
|
||
|
truth_rvec.put(0, 0, 0, Math.PI / 2, 0);
|
||
|
|
||
|
Mat truth_tvec = new Mat(3, 1, CvType.CV_64F);
|
||
|
truth_tvec.put(0, 0, -320, -240, 400);
|
||
|
|
||
|
assertMatEqual(truth_rvec, rvec, EPS);
|
||
|
assertMatEqual(truth_tvec, tvec, EPS);
|
||
14 years ago
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPListOfPoint3ListOfPointMatMatMatMatBoolean() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMat() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBoolean() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanInt() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloat() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloatInt() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloatIntMat() {
|
||
14 years ago
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteria() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteriaInt() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testStereoRectifyUncalibratedMatMatMatSizeMatMat() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testStereoRectifyUncalibratedMatMatMatSizeMatMatDouble() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testValidateDisparityMatMatIntInt() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testValidateDisparityMatMatIntIntInt() {
|
||
|
fail("Not yet implemented");
|
||
|
}
|
||
12 years ago
|
|
||
|
public void testComputeCorrespondEpilines()
|
||
|
{
|
||
|
Mat fundamental = new Mat(3, 3, CvType.CV_64F);
|
||
|
fundamental.put(0, 0, 0, -0.577, 0.288, 0.577, 0, 0.288, -0.288, -0.288, 0);
|
||
|
MatOfPoint2f left = new MatOfPoint2f();
|
||
|
left.alloc(1);
|
||
|
left.put(0, 0, 2, 3); //add(new Point(x, y));
|
||
|
Mat lines = new Mat();
|
||
|
Mat truth = new Mat(1, 1, CvType.CV_32FC3);
|
||
|
truth.put(0, 0, -0.70735186, 0.70686162, -0.70588124);
|
||
|
Calib3d.computeCorrespondEpilines(left, 1, fundamental, lines);
|
||
|
assertMatEqual(truth, lines, EPS);
|
||
|
}
|
||
14 years ago
|
}
|