assertMatEqual(truth_tvec, tvecs.get(0), 1000 * EPS);
}
+ public void testGetDefaultNewCameraMatrixMat() {
+ Mat mtx = Calib3d.getDefaultNewCameraMatrix(gray0);
+
+ assertFalse(mtx.empty());
+ assertEquals(0, Core.countNonZero(mtx));
+ }
+
+ public void testGetDefaultNewCameraMatrixMatSizeBoolean() {
+ Mat mtx = Calib3d.getDefaultNewCameraMatrix(gray0, size, true);
+
+ assertFalse(mtx.empty());
+ assertFalse(0 == Core.countNonZero(mtx));
+ // TODO_: write better test
+ }
+
+ 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
+ Calib3d.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
+ // Calib3d.initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize,
+ // 5, m1type, truthput1, truthput2);
+ }
+
+ public void testInitWideAngleProjMapMatMatSizeIntIntMatMatInt() {
+ fail("Not yet implemented");
+ }
+
+ public void testInitWideAngleProjMapMatMatSizeIntIntMatMatIntDouble() {
+ fail("Not yet implemented");
+ }
+
+ 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);
+ }
+ };
+
+ Calib3d.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));
+
+ Calib3d.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));
+
+ Calib3d.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 testEstimateNewCameraMatrixForUndistortRectify() {
+ Mat K = new Mat().eye(3, 3, CvType.CV_64FC1);
+ Mat K_new = new Mat().eye(3, 3, CvType.CV_64FC1);
+ Mat K_new_truth = new Mat().eye(3, 3, CvType.CV_64FC1);
+ Mat D = new Mat().zeros(4, 1, CvType.CV_64FC1);
+
+ K.put(0,0,600.4447738238429);
+ K.put(1,1,578.9929805505851);
+ K.put(0,2,992.0642578801213);
+ K.put(1,2,549.2682624212172);
+
+ D.put(0,0,-0.05090103223466704);
+ D.put(1,0,0.030944413642173308);
+ D.put(2,0,-0.021509225493198905);
+ D.put(3,0,0.0043378096628297145);
+
+ K_new_truth.put(0,0, 387.4809086880343);
+ K_new_truth.put(0,2, 1036.669802754649);
+ K_new_truth.put(1,1, 373.6375700303157);
+ K_new_truth.put(1,2, 538.8373261247601);
+
+ Calib3d.fisheye_estimateNewCameraMatrixForUndistortRectify(K,D,new Size(1920,1080),
+ new Mat().eye(3, 3, CvType.CV_64F), K_new, 0.0, new Size(1920,1080));
+
+ assertMatEqual(K_new, K_new_truth, EPS);
+ }
++
}