open3d python 鞋底点云点胶路径识别

测试效果

首先拿到点云

去除点云周围的杂点,可以通过高度,可以通过聚类,半径滤波都行

识别点云的边缘

这一圈大约200个点

识别到的边缘点 向内寻找最高点

识别到最高点后 向内推固定距离

计算点胶路径的法向量,方便六轴机械手点胶位姿

测试代码

import open3d as o3d
import numpy as np
from scipy.interpolate import splprep, splev
from scipy.spatial import ConvexHull
import cv2
from scipy.spatial import KDTree
import copy

# 2. 栅格化点云为二值图像
def points_to_binary_image(points_2d, resolution=0.1):
    """将点云转换为二值图像(1:有点,0:无点)"""
    # 计算图像范围和尺寸
    x_min, y_min = np.min(points_2d, axis=0)
    x_max, y_max = np.max(points_2d, axis=0)
    width = int((x_max - x_min) / resolution) + 1
    height = int((y_max - y_min) / resolution) + 1

    # 初始化图像
    image = np.zeros((height, width), dtype=np.uint8)

    # 填充点云位置为1
    coords = ((points_2d - [x_min, y_min]) / resolution).astype(int)
    image[coords[:, 1], coords[:, 0]] = 255

    return image, (x_min, y_min, resolution)


# 2. 计算边缘点的法线方向(指向内部)
def compute_inward_normals(points_2d):
    """计算指向内部的法线(垂直于边界,朝向点云中心)"""
    centroid = np.mean(points_2d, axis=0)
    normals = points_2d - centroid
    normals = normals / np.linalg.norm(normals, axis=1, keepdims=True)
    return normals


# 3. 对每个边缘点生成截面线并找最高点
def find_highest_point_on_section(pcd, edge_point, normal, length=5.0, steps=100):
    """
    沿法线方向生成截面线,并找最高Z值点
    :param edge_point: 边缘点坐标(3D)
    :param normal:     法线方向(3D,XY平面内)
    :param length:     截面线长度(mm)
    :param steps:      截面线采样点数
    """
    # 生成截面线点(沿法线方向向内延伸)
    t = np.linspace(0, length, steps)
    section_points = edge_point + t[:, np.newaxis] * normal

    # 找到截面线附近的原始点云中的点
    kdtree = KDTree(np.asa
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄晓魚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值