Ask Your Question

vividou's profile - activity

2016-11-07 01:16:50 -0500 received badge  Popular Question (source)
2013-04-09 04:27:05 -0500 asked a question camera calibration in python


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)


square_size = 1.0
pattern_points = np.zeros( (, 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))

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