1 year ago

#234663

test-img

Caliber X

How to Convert distorted points to undistorted points?

Distorted image from camera

We have a distorted image from the camera.

We were trying to undistort the image, which was partially solved by calculating the calibration data -> calibration matrix & distortion coefficients; & putting the same in cv2's undistort function.

Steps for calibration:

ret, corners = cv2.findChessboardCorners(gray, CHECKERBOARD, cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FAST_CHECK + cv2.CALIB_CB_NORMALIZE_IMAGE)
corners2 = cv2.cornerSubPix(gray, corners, (11,11),(-1,-1), criteria)
imgpoints.append(corners2)
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)

Steps for undistortion of image:

undistorted_img = cv2.undistort(src=img,
                                cameraMatrix=np.array(
                                        calibration_params["calibration_matrix"]),
                                distCoeffs=np.array(
                                        calibration_params["dist"])
                               )

Steps to find undistorted points:

undistorted_points = cv2.undistortPointsIter(src=(x_, y_),
                                             cameraMatrix=np.array(
                                                 calibration_params["calibration_matrix"]),
                                             distCoeffs=np.array(
                                                 calibration_params["dist"]),
                                             R=np.eye(3, dtype=np.float64),
                                             P = np.array(
                                                 calibration_params["calibration_matrix"]),
                                             criteria=criteria
                                            )

Undistorted image

When plotted as shown in the image, the 2 outputs are quite different. I have also tried using camera matrix in distort image, but still no

python

opencv

camera-calibration

photogrammetry

0 Answers

Your Answer

Accepted video resources