我有以下数据
https://www.mediafire.com/file/f8tz1zbpxvyvko7/Waltersdorf_F3.csv/file
这是3D点云。
我可以正确地对其进行可视化,但是我想像红线中那样进行切割(线性切割),在这些切割处,在3D点云的值之间进行插值并对该线进行2D绘制(剪切)和2D插值。
有人会建议一种方法还是一种算法?
这是我到目前为止所做的,但是您无需为点云使用PyPCL库,可以使用原始数据...
def main():
#process first point cloud
f3data = np.loadtxt(r'C:\ahmed\Waltersdorf_feld3_4.csv', delimiter=',', dtype=[('sp', np.str_, 20), ('x1', np.float32), ('x2', np.float32), ('x3', np.float32)])
ptcloud_1 = np.vstack((f3data['x1'], f3data['x2'], f3data['x3'])).transpose()
pc_1 = pcl.PointCloud.PointXYZ(ptcloud_1)
#plotScatterRot3(f3rot)
pc_type = utils.get_point_cloud_type(pc_1)
seg = getattr(pcl.segmentation.SACSegmentation, pc_type)()
seg.setOptimizeCoefficients(True)
model = getattr(pcl.sample_consensus, "SACMODEL_" + 'PLANE'.upper())
seg.setModelType(model)
seg.setMethodType(pcl.sample_consensus.SAC_RANSAC)
seg.setDistanceThreshold(1)
seg.setInputCloud(pc_1)
coefficients = pcl.ModelCoefficients()
inliers = pcl.PointIndices()
seg.segment(inliers, coefficients)
inla = pc_1.xyz[inliers.indices]
cloud_filtered = pcl.PointCloud.PointXYZ(inla)
pcl.io.savePCDFile("original_first.txt", cloud_filtered)
X = np.vstack((cloud_filtered.x, cloud_filtered.y, cloud_filtered.z)).transpose()
pca = decomposition.PCA(n_components=3)
pca.fit(X)
X = pca.transform(X)
# Verify that everything looks right.
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d as m3d
ax = m3d.Axes3D(plt.figure())
ax.scatter3D(*X.T)
plt.show()
以下是该图的示例: