如何找到 2 skimage.measure.LineModelND 个对象之间的交集?
How to find the intersection between 2 skimage.measure.LineModelND objects?
这里是对我想要完成的事情的描述。我有一组 3D 点,我试图在这些点上拟合 2 条线,在定义这些线后,我想找到它们的交点。
这里有更多关于我到目前为止所做的事情的详细信息,从头开始。我有一组 3D 点存储在 np.ndarray
形状 (N, 3)
中,可以找到点 here.
之后,我使用 scikit-image 库使用 ransac 定义线条。我得到了 LineModelND 类型的线,它们由一个点(原点)和一个单位向量(方向)使用 ransac 定义。这是一个代码片段。在将一条线拟合到数据后,我将异常值拟合到另一条线上,所以现在我有 2 个 LineModelND 对象,我想找到它们的交点。有什么想法吗?
model = LineModelND()
model.estimate(proj_points_array)
model_robust, inliers = ransac(proj_points_array, LineModelND, min_samples=2,
residual_threshold=0.02, max_trials=1000)
print('line params: ', model_robust.params, ' line is type of: ', type(model_robust))
outliers = inliers == False
model_2 = LineModelND()
model_2.estimate(proj_points_array[outliers,:])
Here is the geometry of the points.
到目前为止我找到的解决方案是使用 skspatial.objects.Line.intersect_line
method. This method requires the points to be co-planar and the lines to actually have an intersection or in other words to not be parallel. The LineModelND returns a line model defined by point and direction as the line object definition of the skspatial.objects.Line 对象,因此在定义 skspatial Lines 之后,您可以使用此 class 的 intersect_line 方法。
在我的例子中,线条不是共面的。所以我必须将这些点投影到平面上,找到 2D 交点,从平面方程计算 3D 轴值,然后反转变换。这导致 following output(我无法 post 图片,所以我 post 编辑了 link 图片。