【问题标题】:Camera calibration opencv python相机校准opencv python
【发布时间】:2016-12-29 09:06:10
【问题描述】:

我正在关注 OpenCV 教程http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_calib3d/py_calibration/py_calibration.html

我没有使用棋盘运行它,而是从 LAS 文件中获取了我的 3D 点坐标。这是我的代码:

import cv2
import numpy as np

obj_point = [(630931.35,4833642.85,157.67),(630948.03,4833662.76,73.94), (631156.3, 4833904.18, 43.89),(630873.71, 4833790, 44.85), (631381.3, 4834152.6, 79.41)]
img_point = [(1346.82,843.206),(1293.03,808.146),(1041.92, 585.168), (1150.21, 894.724), (756.993,345.904) ]

obj_point = np.array(obj_point,'float32')
img_point = np.array(img_point,'float32')

ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(obj_point, img_point, (1125, 1725),None,None) 

我收到以下错误消息:

对于非平面校准装置,初始内在矩阵必须是 在函数 cvCalibrateCamera2 中指定

提前谢谢!

【问题讨论】:

    标签: python opencv image-processing computer-vision camera-calibration


    【解决方案1】:

    你需要使用标志CV_CALIB_USE_INTRINSIC_GUESS

    【讨论】:

    • 您好,感谢您的回答!你知道“ret”的值代表什么吗?是重投影错误吗?
    • 阅读here...简短版:是的;)
    【解决方案2】:

    通过以下代码。它可能会解决您的问题。

    3dPts = 3dPts.astype('float32')
    2dPts = 2dPts.astype('float32')
    
    imgsize=(640, 480)
    # This can be omitted and can be substituted with None below.
    camera_matrix = cv2.initCameraMatrix2D([3dPts],[2dPts]), imgsize)  
    
    cv2.calibrateCamera([3dPts], [2dPts], imgsize, camera_matrix, None, 
                        flags=cv2.CALIB_USE_INTRINSIC_GUESS)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-28
      • 2014-10-23
      • 1970-01-01
      • 2015-03-16
      • 2012-04-18
      • 1970-01-01
      • 2011-08-03
      • 2014-06-19
      相关资源
      最近更新 更多