【问题标题】:Python OpenCV calibrateCamera: objectPoints should contain vector of vectors of points of type Point3fPython OpenCV calibrateCamera:objectPoints 应包含 Point3f 类型点的向量向量
【发布时间】:2021-06-11 07:21:59
【问题描述】:

我想从一些编码标记的图片坐标和物体坐标计算相机校准参数。

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-markers 计算出来的,看起来像这样:

[[2639.   1826.5 ]
 [2265.5  1820.5 ]
 [2638.75 1480.  ]
 [2269.   1475.25]
 [1898.   1470.5 ]
 [3024.   2551.25]
...]
(20, 2)

我知道共面对象点并不适合这项任务。我刚刚开始创建一些虚拟数据来弄清楚所有内容的语法:) 提前致谢

【问题讨论】:

    标签: python opencv camera-calibration


    【解决方案1】:

    答案很简单:

    objpoints=[]
    objpoints.append(points)
    

    然后用 objpoints 而不是点调用 cv2.calibrateCamera

    好吧,我的理智走了:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多