python - Python OpenCV calibrateCamera:objectPoints 应包含 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-matrix
[[ 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)
然后用 objpoints 而不是点调用 cv2.calibrateCamera
好吧,我的理智走了:)
推荐阅读
- android - 将重要数据存储在内部存储器中
- java - Try-with-resources 关闭订单
- react-native - React Native“交互式”keyboardDismissMode在拖动时抛出错误
- xml - XSLT - 计算 HH:MM
- scala - 在对列应用条件后从一组值中计算最小值和最大值
- exchangewebservices - ExchangeWebService 预约响应选项
- python - 如何从另一个数据帧更新一个数据帧的特定列
- vb.net - 使用 CsvHelper 在现有 CSV 文件中添加新列
- git - 从 git 中删除未跟踪的文件
- c# - 从文本文件中读取行并自动分配变量