一、代码
Python
import cv2
import open3d as o3d
import matplotlib.pyplot as plt
import numpy as np
def thPlaneSeg(pointcloud):
pcd_np = np.asarray(pointcloud.points)
# 设置深度阈值 (假设Z轴是深度轴)
depth_threshold = 0.196 # 1.0米
# 应用深度阈值,移除远于阈值的点
pcd_np_filtered = pcd_np[pcd_np[:, 2] < depth_threshold]
# 创建一个新的点云
pcd_filtered = o3d.geometry.PointCloud()
pcd_filtered.points = o3d.utility.Vector3dVector(pcd_np_filtered)
# 如果点云有颜色,则也要相应地过滤颜色
if pointcloud.colors:
pcd_colors_np = np.asarray(pointcloud.colors)
pcd_filtered.colors = o3d.utility.Vector3dVector(pcd_colors_np[pcd_np[:, 2] < depth_threshold])
# 如果点云有法线,则也要相应地过滤法线
if poi