cv2.cameraCalibration using python


I am trying to learn how to do 3D and stereo camera calibration using openCV and python. Using 3 camera views of an 8x6 chessboard (7x5 interior corners), I was able to get cv.calibrateCamera() working OK but am totally stuck when I use cv2. One of the steps is to find the chessboard corners. Whereas cv.findChessboardCorners() returns corners as a list of points, cv2 uses numpy arrays, and returns the points as a (35,1,2) numpy array. The parameters for cv2.calibrateCamera() are object_points, image_points, and image_size. I am supplying the object points in a (3,35,3) numpy array and the image points in a (3,35,2) numpy array. The image size is (1632, 1224). Can anybody tell me what the problem is? The error I get isn't very useful:

Traceback (most recent call last):
  File "H:/pyCV/locv_book/ch11/", line 46, in <module>
error: ..\..\..\src\opencv\modules\calib3d\src\calibration.cpp:3173: error: (-215) ni >= 0

Points need to be float32, in matrix form (N,2) and (N,3). You can convert to float32 this way:

points32 = np.array(points,dtype=np.float32) 
By : memecs

This video can help you solving your question :)
By: admin