calib3d: move undistort files from imgproc

This commit is contained in:
Alexander Alekhin
2018-10-02 21:51:29 +00:00
parent a9c8a526cf
commit 8f1f4273a2
15 changed files with 989 additions and 694 deletions
@@ -891,21 +891,6 @@ public class ImgprocTest extends OpenCVTestCase {
assertMatEqual(truth, transform, EPS);
}
public void testGetDefaultNewCameraMatrixMat() {
Mat mtx = Imgproc.getDefaultNewCameraMatrix(gray0);
assertFalse(mtx.empty());
assertEquals(0, Core.countNonZero(mtx));
}
public void testGetDefaultNewCameraMatrixMatSizeBoolean() {
Mat mtx = Imgproc.getDefaultNewCameraMatrix(gray0, size, true);
assertFalse(mtx.empty());
assertFalse(0 == Core.countNonZero(mtx));
// TODO_: write better test
}
public void testGetDerivKernelsMatMatIntIntInt() {
Mat kx = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
Mat ky = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
@@ -1139,52 +1124,6 @@ public class ImgprocTest extends OpenCVTestCase {
fail("Not yet implemented");
}
public void testInitUndistortRectifyMap() {
fail("Not yet implemented");
Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F);
cameraMatrix.put(0, 0, 1, 0, 1);
cameraMatrix.put(1, 0, 0, 1, 1);
cameraMatrix.put(2, 0, 0, 0, 1);
Mat R = new Mat(3, 3, CvType.CV_32F, new Scalar(2));
Mat newCameraMatrix = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
Mat distCoeffs = new Mat();
Mat map1 = new Mat();
Mat map2 = new Mat();
// TODO: complete this test
Imgproc.initUndistortRectifyMap(cameraMatrix, distCoeffs, R, newCameraMatrix, size, CvType.CV_32F, map1, map2);
}
public void testInitWideAngleProjMapMatMatSizeIntIntMatMat() {
fail("Not yet implemented");
Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F);
Mat distCoeffs = new Mat(1, 4, CvType.CV_32F);
// Size imageSize = new Size(2, 2);
cameraMatrix.put(0, 0, 1, 0, 1);
cameraMatrix.put(1, 0, 0, 1, 2);
cameraMatrix.put(2, 0, 0, 0, 1);
distCoeffs.put(0, 0, 1, 3, 2, 4);
truth = new Mat(3, 3, CvType.CV_32F);
truth.put(0, 0, 0, 0, 0);
truth.put(1, 0, 0, 0, 0);
truth.put(2, 0, 0, 3, 0);
// TODO: No documentation for this function
// Imgproc.initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize,
// 5, m1type, truthput1, truthput2);
}
public void testInitWideAngleProjMapMatMatSizeIntIntMatMatInt() {
fail("Not yet implemented");
}
public void testInitWideAngleProjMapMatMatSizeIntIntMatMatIntDouble() {
fail("Not yet implemented");
}
public void testIntegral2MatMatMat() {
Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
Mat expSum = new Mat(4, 4, CvType.CV_64F);
@@ -1748,72 +1687,6 @@ public class ImgprocTest extends OpenCVTestCase {
assertMatEqual(makeMask(gray255.clone(), 0), dst);
}
public void testUndistortMatMatMatMat() {
Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F) {
{
put(0, 0, 1, 0, 1);
put(1, 0, 0, 1, 2);
put(2, 0, 0, 0, 1);
}
};
Mat distCoeffs = new Mat(1, 4, CvType.CV_32F) {
{
put(0, 0, 1, 3, 2, 4);
}
};
Imgproc.undistort(src, dst, cameraMatrix, distCoeffs);
truth = new Mat(3, 3, CvType.CV_32F) {
{
put(0, 0, 0, 0, 0);
put(1, 0, 0, 0, 0);
put(2, 0, 0, 3, 0);
}
};
assertMatEqual(truth, dst, EPS);
}
public void testUndistortMatMatMatMatMat() {
Mat src = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
Mat cameraMatrix = new Mat(3, 3, CvType.CV_32F) {
{
put(0, 0, 1, 0, 1);
put(1, 0, 0, 1, 2);
put(2, 0, 0, 0, 1);
}
};
Mat distCoeffs = new Mat(1, 4, CvType.CV_32F) {
{
put(0, 0, 2, 1, 4, 5);
}
};
Mat newCameraMatrix = new Mat(3, 3, CvType.CV_32F, new Scalar(1));
Imgproc.undistort(src, dst, cameraMatrix, distCoeffs, newCameraMatrix);
truth = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
assertMatEqual(truth, dst, EPS);
}
//undistortPoints(List<Point> src, List<Point> dst, Mat cameraMatrix, Mat distCoeffs)
public void testUndistortPointsListOfPointListOfPointMatMat() {
MatOfPoint2f src = new MatOfPoint2f(new Point(1, 2), new Point(3, 4), new Point(-1, -1));
MatOfPoint2f dst = new MatOfPoint2f();
Mat cameraMatrix = Mat.eye(3, 3, CvType.CV_64FC1);
Mat distCoeffs = new Mat(8, 1, CvType.CV_64FC1, new Scalar(0));
Imgproc.undistortPoints(src, dst, cameraMatrix, distCoeffs);
assertEquals(src.size(), dst.size());
for(int i=0; i<src.toList().size(); i++) {
//Log.d("UndistortPoints", "s="+src.get(i)+", d="+dst.get(i));
assertTrue(src.toList().get(i).equals(dst.toList().get(i)));
}
}
public void testWarpAffineMatMatMatSize() {
Mat src = new Mat(3, 3, CvType.CV_32F) {
{