I am trying to calibrate a fisheye camera. In order to do that I load a video take with that camera and takes frames where appears a cheesboard pattern. In order to find patterns I use:
bool found = findChessboardCorners(image_to_show, board_sz, corners, CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_NORMALIZE_IMAGE | CALIB_CB_FAST_CHECK);
if(found)
{
cornerSubPix(gray_image, Mat(corners), Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.001));
drawChessboardCorners(gray_image, board_sz, Mat(corners), found);
}
when I take 15 pattern I calibrate the camera as follow:
double error = fisheye::calibrate(object_points, image_points, image_to_show.size(), intrinsic, distCoeffs, rvecs, tvecs, fisheye::CALIB_RECOMPUTE_EXTRINSIC | fisheye::CALIB_CHECK_COND | fisheye::CALIB_FIX_SKEW);
then I print the intrinsic matrix and distortion coeficients and I get
Intrinsic Matrix
[251.48312, 0, 471.14383;
0, 255.30005, 501.81467;
0, 0, 1]
Distortion coefficients
[0.055155002;
0.07189583;
-0.082159713;
0.026405662]
I think this values are wrong because the image resolution is 2048x2048, si cx and cy should be 1024 but the calibration method returns 471 and 501 for that variables.
then I try
fisheye::undistortImage(image_to_show, imageUndistorted, intrinsic, distCoeffs);
But I get a black image in imageUndistorted