Hi,
I'm trying to rewrite the stereo calibrate example in Java. I think I did things okayish but I got an error I don't understand how it can happen :
OpenCV Error: Assertion failed (K.size() == Size(3, 3) && (D.empty() || D.total() == 4)) in initUndistortRectifyMap, file /home/yolteotl/opencv/opencv-3.0.0/modules/calib3d/src/fisheye.cpp, line 410
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: /home/yolteotl/opencv/opencv-3.0.0/modules/calib3d/src/fisheye.cpp:410: error: (-215) K.size() == Size(3, 3) && (D.empty() || D.total() == 4) in function initUndistortRectifyMap
]
at org.opencv.calib3d.Calib3d.initUndistortRectifyMap_0(Native Method)
at org.opencv.calib3d.Calib3d.initUndistortRectifyMap(Calib3d.java:834)
at com.yolt.server.calibration.Calibration.calibrate(Calibration.java:267)
at com.yolt.server.GUI.<init>(GUI.java:67)
at com.yolt.server.ServerApplication.main(ServerApplication.java:30)
The correspond code :
double rms = Calib3d.stereoCalibrate(objectsPoint, cornersMatLeftList, cornersMatRightList,
cameraMatrix[0], distCoef[0], cameraMatrix[1], distCoef[1],
imgSize, rMat, tMat, eMat, fMat, CALIB_FLAGS, CALIB_CRITERIA);
System.out.println("Calibration done with RMS error=" + rms);
m1 = cameraMatrix[0];
m2 = cameraMatrix[1];
d1 = distCoef[0];
d2 = distCoef[1];
System.out.println("matrix saved");
r1 = new Mat();
r2 = new Mat();
p1 = new Mat();
p2 = new Mat();
qMat = new Mat();
Calib3d.stereoRectify(m1, d1, m2, d2, imgSize, rMat, tMat, r1, r2, p1, p2, qMat);
mx1 = new Mat();
mx2 = new Mat();
my1 = new Mat();
my2 = new Mat();
Calib3d.initUndistortRectifyMap(m1, d1, r1, p1, imgSize, CvType.CV_16SC2, mx1, my1);
Calib3d.initUndistortRectifyMap(m2, d2, r2, p2, imgSize, CvType.CV_16SC2, mx2, my2);
The error is coming from the initUndistortRectifyMap line, and from the d1 / d2 which are not empty and total() = 5 instead of 4. How this can happen whereas I didn't modify those Mat and I'm just using the returned Mat from stereoRectify() ?
Any help would be welcome!