2024-10-02 18:18:02 发布
网友
我试着从一个校准过的照相机上找到相机的中心。 我有4个测量的三维物体点和它的图像,并试图从投影矩阵得到中心(平移),但没有可接受的结果。 关于opencv的准确性有什么建议吗?我应该增加点数吗?在
我得到的结果是:
TrueCenter in mm for XYZ [[4680.] [5180.] [1621.]] Center [[-2508.791] [ 6015.98 ] [-1096.674]]
我发现了一个关于billwolfe的位置确定问题的有趣的演示。Perspective View Of 3 Points
因此,使用4个非共面点(非3个共线点)改进了解决方案。在
import numpy as np import cv2 from scipy.linalg import inv,norm TrueCameraCenter = np.array([4680., 5180, 1621]) objectPoints = np.array( [[ 0., 5783., 1970.], [ 0., 5750., 1261.], [ 0., 6412., 1968.], [ 0., 6449., 1288.]]) imagePoints=np.array( [[ 497.5 , 674.75], [ 523.75, 1272.5 ], [1087.75, 696.75], [1120. , 1212.5 ]]) cameraMatrix= np.array( [[3189.096, 0. , 2064.431], [ 0. , 3177.615, 1482.859], [ 0. , 0. , 1. ]]) dist_coefs=np.array([[ 0.232, -1.215, -0.002, 0.011, 1.268]]) retval, rvec, tvec = cv2.solvePnP(objectPoints, imagePoints,cameraMatrix,dist_coefs, None, None, False, cv2.SOLVEPNP_ITERATIVE) R,_= cv2.Rodrigues(rvec) C=-inv(R).dot(tvec).flatten() print('TrueCenter in mm for XYZ\n', TrueCameraCenter, '\nCenter\n',C.astype(int) ) print('Distance:', int(norm(TrueCameraCenter-C)))
我发现了一个关于billwolfe的位置确定问题的有趣的演示。Perspective View Of 3 Points
因此,使用4个非共面点(非3个共线点)改进了解决方案。在
相关问题 更多 >
编程相关推荐