当我尝试使用 cv2.calibrateCamera 校准相机时出现以下错误:
rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(pts3d, pts2d, self.imgsize, None, None)
cv2.error: /home/sarkar/opencv/opencv/modules/calib3d/src/calibration.cpp:2976: error: (-210) objectPoints should contain vector of vectors of points of type Point3f in function collectCalibrationData
我最初有用于 pts3d 和 pts2d 的 nx3 和 nx2 数组。然后,我尝试以以下形式重塑 pts3d 和 pts2d,因为该函数将向量 point3d(以及相应的 pts2d)的向量作为输入:
[1 xnx 3] 和 [1 xnx 2]
[kx n' x 3] 和 [kx n' x 3],其中 k 是某个随机值
[1 xnx 1 x 3] 和 [1 xnx 1 x 2]
没有任何效果,它总是给出同样的错误。
我看到提供的cameraclibration的代码示例代码运行良好,它们的输入是[kxnx 3]。我真的不知道我的实施有什么问题。准确地说,以下是我的代码:
#data contains [n x 5] dim array which is the hstacked arrays of pts3d and pts2d correspondences I obtained elsewhere.
pts3d = data[:, 0:3] #first 3 column
pts2d = data[:, 3:5] #next 2 column.. I checked the values are coming correctly
pts3d = pts3d.reshape(1,-1, 3) #Here, I have experimented by resizing with different values.
pts2d = pts2d.reshape(1,-1, 2)
rms, camera_matrix, dist_coefs, rvecs, tvecs = cv2.calibrateCamera(pts3d, pts2d, self.imgsize, None, None)
错误发生在函数调用时。很高兴知道这里可能出了什么问题。