采用线性回归方法降低双目测距到平面的误差(python+sklearn)
Posted 清热降火
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了采用线性回归方法降低双目测距到平面的误差(python+sklearn)相关的知识,希望对你有一定的参考价值。
继上篇,为了改善标定板的深度信息:
remove_idx1 = np.where(Z <= 0) remove_idx2 = np.where(Z > 500)#将Z轴坐标限定在0-500,以减少非标定板区域的坐标影响
采用线性回归并显示坐标信息
from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D #删除掉无效及多余点后,得到points_3d X = points_3d[:, 0] Y = points_3d[:, 1] Z = points_3d[:, 2] XY = points_3d[:, :2] #利用线性回归计算新的Z轴坐标 reg = LinearRegression() reg.fit(XY, Z) Z_predict = reg.predict(XY) fig=plt.figure() ax = plt.axes(projection=\'3d\') ax.scatter3D(X, Y, Z, c=\'gray\', s=1)#显示原始点信息 ax.scatter3D(X, Y, Z_predict, c=\'red\')#显示修正点信息 ax.set_xlabel(r\'$x_1$\',fontsize = 20, color = \'blue\') ax.set_ylabel(r\'$x_2$\',fontsize = 20, color = \'blue\') ax.set_zlabel(r\'$x_3$\',fontsize = 20, color = \'blue\')
以上是关于采用线性回归方法降低双目测距到平面的误差(python+sklearn)的主要内容,如果未能解决你的问题,请参考以下文章