我正在尝试估计solvePnP
在 python 中使用的对象的 3D 姿势。但问题是,即使我将相机和对象都保持静止,solvePnP
(rvec
和tvec
) 的输出也会发生变化。世界坐标系以对象为中心并随之移动。我正在传递 4 个图像点和相应的 4 个对象点。
调用 SolvePnP:
retval, rvec, tvec = cv2.solvePnP(cam.object_points, cam.image_points, cam.camera_matrix, cam.dist_coefficients, None, None, False, cv2.SOLVEPNP_ITERATIVE)
输出 1:
Image points:
[[ 236. 243.]
[ 43. 368.]
[ 404. 372.]
[ 235. 357.]]
Object points:
[[ 0. 0. 0. ]
[ 6.5 0. 0. ]
[ 0. 0. 6.5]
[ 0. 6.5 0. ]]
R VECT==========
[[-0.56619693]
[-2.27732794]
[ 0.71053527]]
T VECT==========
[[ 0.54725923]
[-0.45834745]
[ 0.58522831]]
输出 2:
Image points:
[[ 236. 243.]
[ 43. 369.]
[ 404. 372.]
[ 235. 357.]]
Object points:
[[ 0. 0. 0. ]
[ 6.5 0. 0. ]
[ 0. 0. 6.5]
[ 0. 6.5 0. ]]
R VECT==========
[[ 0.33325838]
[ 2.12767845]
[ 0.98248134]]
T VECT==========
[[ -2.60687131]
[ 0.37989386]
[ 23.85078678]]
物点和图像点是相同的,但solvePnP 仍然给出几个不同的结果。上述结果是一个接一个交替的帧。
我应该如何解决?