使用 solvePnPpython,opencv查找 3d 姿势已关闭为什么?

问题描述

我按照 this 教程校准了我的相机,使用了 20 张点图案图像。 绘制的点中心看起来很合适,但是我获得的重投影误差是 11.5 像素 - 这对我来说似乎很大?尚未完成亚像素化。

接下来,我使用与上面的校准数据相同的图像来查找点模式的姿势,使用 solvePnP 函数。 在这里,如下图所示 - 似乎中心总是正确的,但是绘制的三脚架是关闭的 - 它的两端应该对应

(1,0),(0,1,0) and (0,-1)

分别。

我的问题是 - 为什么三脚架会随机关闭 - 我会很高兴收到任何提示。

谢谢

不幸的是没有任何代表 - 我不能在这里张贴图片。因此只是链接...
img 1
img 2
img 3
img 4
img 5

更新: 使用solvePnP好像有问题: 我在校准期间将所有物点重新投影到它们找到的位置 - 看起来不错:

calibration

然而,当使用solvePnP时,会返回不同的rvecs和tvecs,导致对象点的投影错误。

solvePnP

欢迎提出任何想法;-)

这里是如何使用solvePnP的代码:

#gray is a grayvalue img of calib plate
#objp is an array of floats containing objpoints
#camera matrix and dist. coeff are imported from previous calibration

axis = np.float32([[1,0],[8,[0,-1]])
shape = (4,11)
ret,centers = cv2.findCirclesGrid( \
        gray,shape,flags=cv2.CALIB_CB_ASYMMETRIC_GRID)
if ret == True:
    # Find the rotation and translation vectors.
    ret,rvecs,tvecs = cv2.solvePnP(objp,centers,camera_matrix,distortion_coefficients)
    # project 3D points to image plane
    imgpts,jac = cv2.projectPoints(axis,tvecs,distortion_coefficients)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)