feat: 算法升级、整车配准集成与性能分析文档
算法更新: delivery v1.2.1、平整度v1.5、测距v2.2、整车配准v1.3 适配器: vehicle-registration 新增、各算法 manifest 和 adapter 更新 后端: taskCadFiles/source 字段迁移、derivedPointClouds 注册、取消任务联动 前端: ElapsedTime 时长显示、两步算法流程、canRun 逻辑修复 文档: 新增5份算法性能分析报告
This commit is contained in:
39
alg/平整度、平面度、轮廓测量v1.5/preprocessing/curvature.py
Normal file
39
alg/平整度、平面度、轮廓测量v1.5/preprocessing/curvature.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import numpy as np
|
||||
import open3d as o3d
|
||||
|
||||
|
||||
class CurvatureEstimator:
|
||||
"""Estimate local point-cloud curvature using neighborhood covariance."""
|
||||
|
||||
def compute(self, pointcloud: o3d.geometry.PointCloud, radius: float = 2.0, max_nn: int = 30) -> np.ndarray:
|
||||
pointcloud.estimate_normals(o3d.geometry.KDTreeSearchParamHybrid(radius=radius, max_nn=max_nn))
|
||||
points = np.asarray(pointcloud.points)
|
||||
kdtree = o3d.geometry.KDTreeFlann(pointcloud)
|
||||
curvatures = np.zeros(len(points), dtype=np.float64)
|
||||
|
||||
for i, point in enumerate(points):
|
||||
_, indices, _ = kdtree.search_hybrid_vector_3d(point, radius, max_nn)
|
||||
if len(indices) < 3:
|
||||
curvatures[i] = 1.0
|
||||
continue
|
||||
|
||||
neighbors = points[indices]
|
||||
cov = np.cov((neighbors - neighbors.mean(axis=0)).T)
|
||||
eigenvalues = np.linalg.eigvalsh(cov)
|
||||
denom = eigenvalues.sum()
|
||||
curvatures[i] = float(eigenvalues[0] / denom) if denom > 0 else 0.0
|
||||
|
||||
return curvatures
|
||||
|
||||
def colorize(self, pointcloud: o3d.geometry.PointCloud, curvatures: np.ndarray, color_scale: float = 3.0) -> o3d.geometry.PointCloud:
|
||||
pcd = copy.deepcopy(pointcloud)
|
||||
normalized = curvatures / (np.max(curvatures) + 1e-12)
|
||||
normalized = np.clip(normalized * color_scale, 0, 1)
|
||||
colors = np.zeros((len(normalized), 3))
|
||||
colors[:, 0] = normalized
|
||||
colors[:, 1] = 1 - normalized
|
||||
pcd.colors = o3d.utility.Vector3dVector(colors)
|
||||
return pcd
|
||||
Reference in New Issue
Block a user