Hello,
I am wondering if there is an example in python using the cv2 version for camera calibration using a chessboard pattern?
if not, here is a part of my code:
fn = ('home/image.jpg')
pattern_size = (7, 9)
img = cv2.imread(fn, cv2.CV_LOAD_IMAGE_GRAYSCALE)
h, w = img.shape
found, corners = cv2.findChessboardCorners(img, pattern_size)
cv2.drawChessboardCorners(img, pattern_size, corners, found)
Then:
square_size = 1.0
pattern_points = np.zeros( (np.prod(pattern_size), 3), np.float32 )
pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2)
pattern_points *= square_size
img_points.append(corners.reshape(-1, 2))
obj_points.append(pattern_points)
rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(obj_points, img_points, (w, h))
I am not sure about the use of cv2.calibrateCamera as I get an error with cameraMatrix which seems required but I don't know how to set it.
If someone could give me some inputs, It would be great.
Best Rergards