由于相机安装问题,导致点云数据两边翘起来,为了计算把翘起来的部分拉平整?
import time
import open3d as o3d;
import numpy as np;
import matplotlib.pyplot as plt
from scipy.signal import find_peaks
import pandas as pd
OriginalPly = o3d.io.read_point_cloud("source/Glue4.ply")
#对点云进行变形后校准
tic = time.time()
# 将点云转换为NumPy数组
points = np.asarray(OriginalPly.points)
# 创建一个新的数组来存放调整后的点
new_points =np.asarray(OriginalPly.points) # np.zeros_like(points)
for x in np.unique(points[:, 0]):
x_indices = np.where(points[:, 0] == x)
min_z = np.min(points[x_indices, 2])
new_points[x_indices, 2] = new_points[x_indices, 2] +100-min_z
# 将调整后的点重新赋值给点云对象
toc = 1000 * (time.time() - tic)
print("点云校准耗时 {:.0f} [ms]".format(toc))
calibrationPly = o3d.geometry.PointCloud()
calibrationPly.points = o3d.utility.Vector3dVector(new_points)
o3d.visualization.draw_geometries([ calibrationPly],window_name="calibrationPly 校准")
校正前 红色是比较高的地方
拉平后的点云