input arguments of python's cv2.calibrateCamera

北慕城南 提交于 2019-11-30 10:27:58
Csega

I had the same problem and found the answer for it at this topic: OpenCV 2.3 camera calibration

The main steps are:

pts3d = pts3d.astype('float32')
pts2d = pts2d.astype('float32')

# This can be omitted and can be substituted with None below.
camera_matrix = cv2.initCameraMatrix2D([pts3d],[pts2d]), self.imgsize)  

cv2.calibrateCamera([pts3d], [pts2d], self.imgsize, camera_matrix, None, 
                    flags=cv2.CALIB_USE_INTRINSIC_GUESS)

It was written for OpenCV 2.3, but it works for me even with OpenCV 3.0 (dev branch in git) with Python 3.3.5 (64 bit).

I'm using OpenCV 3.4 and found that pts3d (shape 1 * n * 3) and pts2d (shape 1 * n * 2) works for me. Just remember to change type (my default type is float64) to float32, as Csega noted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!