看到有写的非常好的了
而且最后用的是超定方程求解,只是我不太明白怎么线性化的,还请知道的朋友不吝赐教。还真是迭代的最小二乘,至于为什么可以又迭代又最小二乘,有人能解释下吗?
线性化就是多元泰勒展开保留线性部分,使用牛顿迭代法求了最小二乘的数值解,防止因解析解求解过于复杂,带来的无法解或计算量大的问题。
迭代是因为每次计算使用的部分参数并不是精确参数,和最小二乘没有什么关系,就是一种解法。
链接:https://blog.csdn.net/qq_30815237/article/details/90405087
其他参考:https://blog.csdn.net/zhangxz259/article/details/86711348
文献:一种圆柱面拟合方法 袁建刚,潘 轶http://www.cnki.com.cn/Article/CJFDTotal-GCKC201712012.html
最小二乘:https://zhuanlan.zhihu.com/p/38128785
球拟合:https://zhuanlan.zhihu.com/p/97036816
空间圆拟合
球拟合(最小二乘)+ 平面拟合(最小二乘)
坐标转换到平面 + 二维圆拟合
https://blog.csdn.net/liyuanbhu/article/details/50889951
https://blog.csdn.net/weixin_43198881/article/details/103817694
椭圆拟合,避免讨论柱倾斜问题
https://zhuanlan.zhihu.com/p/143017326
各种拟合模型参考:https://www.geometrictools.com/Documentation/CylinderFitting.pdf
python库:https://pypi.org/project/pyransac3d/
注(2021-8-16):pyransac3d库对圆柱拟合效果不理想
def cylinderFitting(xyz, p, th):
"""
This is a fitting for a vertical cylinder fitting
Reference:
http://www.int-arch-photogramm-remote-sens-spatial-inf-sci.net/XXXIX-B5/169/2012/isprsarchives-XXXIX-B5-169-2012.pdf
xyz is a matrix contain at least 5 rows, and each row stores x y z of a cylindrical surface
p is initial values of the parameter;
p[0] = Xc, x coordinate of the cylinder centre
P[1] = Yc, y coordinate of the cylinder centre
P[2] = alpha, rotation angle (radian) about the x-axis
P[3] = beta, rotation angle (radian) about the y-axis
P[4] = r, radius of the cylinder
th, threshold for the convergence of the least squares
"""
x = xyz[:, 0]
y = xyz[:, 1]
z = xyz[:, 2]
def fitfunc(p, x, y, z): return (- np.cos(p[3])*(p[0] - x) - z*np.cos(p[2])*np.sin(p[3]) - np.sin(
p[2])*np.sin(p[3])*(p[1] - y))**2 + (z*np.sin(p[2]) - np.cos(p[2])*(p[1] - y))**2 # fit function
def errfunc(p, x, y, z): return fitfunc(
p, x, y, z) - p[4]**2 # error function
est_p, success = leastsq(errfunc, p, args=(x, y, z), maxfev=1000)
print("拟合状态:",success)
return est_p
参考:http://www.int-arch-photogramm-remote-sens-spatial-inf-sci.net/XXXIX-B5/169/2012/isprsarchives-XXXIX-B5-169-2012.pdf
https://www.geometrictools.com/Documentation/CylinderFitting.pdf