Python OpenCV calibrateCamera: objectPoints 应该包含 Point3f 类型的点向量的向量
Python OpenCV calibrateCamera: objectPoints should contain vector of vectors of points of type Point3f
我想根据一些编码标记的图片坐标和物体坐标来计算相机标定参数。
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(points, centers, gray.shape[::-1], None, None)
但我收到以下错误:
objectPoints should contain vector of vectors of points of type Point3f in function 'cv::collectCalibrationData'
这让我很困惑,因为对象点是这样实现的:
points=np.float32([[7.8, 4.9, 0], [5.2, 4.9, 0], [7.8, 7.35, 0], [5.2, 7.35, 0], [2.6, 7.35, 0],[10.4, 0, 0],...])
根据控制台打印和 np.shape
中的尺寸,它们似乎是 mx3 矩阵
[[ 7.8 4.9 0. ]
[ 5.2 4.9 0. ]
[ 7.8 7.35 0. ]
[ 5.2 7.35 0. ]
[ 2.6 7.35 0. ]
[10.4 0. 0. ]
...]
(20, 3)
我的图像点是根据一些 Aruco 标记计算的,看起来像这样:
[[2639. 1826.5 ]
[2265.5 1820.5 ]
[2638.75 1480. ]
[2269. 1475.25]
[1898. 1470.5 ]
[3024. 2551.25]
...]
(20, 2)
我知道共面物点不太适合这个任务。我刚刚开始创建一些虚拟数据来弄清楚所有内容的语法:)提前致谢
答案很简单:
objpoints=[]
objpoints.append(points)
然后调用 cv2.calibrateCamera 使用对象点而不是点
好吧,我的理智消失了:)
我想根据一些编码标记的图片坐标和物体坐标来计算相机标定参数。
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(points, centers, gray.shape[::-1], None, None)
但我收到以下错误:
objectPoints should contain vector of vectors of points of type Point3f in function 'cv::collectCalibrationData'
这让我很困惑,因为对象点是这样实现的:
points=np.float32([[7.8, 4.9, 0], [5.2, 4.9, 0], [7.8, 7.35, 0], [5.2, 7.35, 0], [2.6, 7.35, 0],[10.4, 0, 0],...])
根据控制台打印和 np.shape
中的尺寸,它们似乎是 mx3 矩阵[[ 7.8 4.9 0. ]
[ 5.2 4.9 0. ]
[ 7.8 7.35 0. ]
[ 5.2 7.35 0. ]
[ 2.6 7.35 0. ]
[10.4 0. 0. ]
...]
(20, 3)
我的图像点是根据一些 Aruco 标记计算的,看起来像这样:
[[2639. 1826.5 ]
[2265.5 1820.5 ]
[2638.75 1480. ]
[2269. 1475.25]
[1898. 1470.5 ]
[3024. 2551.25]
...]
(20, 2)
我知道共面物点不太适合这个任务。我刚刚开始创建一些虚拟数据来弄清楚所有内容的语法:)提前致谢
答案很简单:
objpoints=[]
objpoints.append(points)
然后调用 cv2.calibrateCamera 使用对象点而不是点
好吧,我的理智消失了:)