增加平面分割
This commit is contained in:
parent
4230d0ab7d
commit
df8bf74c7a
@ -991,12 +991,21 @@ int SegmentPlanesByRansac(
|
||||
if (used[nIdx] || inPlane[nIdx]) continue;
|
||||
if (!IsValidPoint(points[nIdx])) continue;
|
||||
|
||||
// 局部Z差检查:当前点与邻居点的Z值差
|
||||
// 局部Z差检查:防止跨越单步噪点
|
||||
float zDiff = std::abs(points[nIdx].z - points[curIdx].z);
|
||||
if (zDiff <= params.growthZThreshold) {
|
||||
inPlane[nIdx] = true;
|
||||
bfsQueue.push(nIdx);
|
||||
}
|
||||
if (zDiff > params.growthZThreshold) continue;
|
||||
|
||||
// 全局点到平面距离检查:防止BFS在渐变区域内漂移到不同表面。
|
||||
// 仅靠局部Z差无法阻止逐步穿越台阶(每步小但累积大),
|
||||
// 全局距离能确保生长点始终贴近当前RANSAC平面。
|
||||
float planeDist = std::abs(
|
||||
bestA * points[nIdx].x + bestB * points[nIdx].y +
|
||||
bestC * points[nIdx].z + bestD
|
||||
);
|
||||
if (planeDist > params.distanceThreshold * 2.0f) continue;
|
||||
|
||||
inPlane[nIdx] = true;
|
||||
bfsQueue.push(nIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1213,7 +1222,13 @@ int SegmentPlanesByRansac(
|
||||
std::cout << " Component " << (ci + 1)
|
||||
<< ": " << seg.pointCount << " points" << std::endl;
|
||||
|
||||
splitPlanes.push_back(std::move(seg));
|
||||
if (seg.pointCount >= params.minPlanePoints) {
|
||||
splitPlanes.push_back(std::move(seg));
|
||||
} else {
|
||||
std::cout << " Component " << (ci + 1)
|
||||
<< ": skipped (below minPlanePoints="
|
||||
<< params.minPlanePoints << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1309,6 +1324,7 @@ int SegmentPlanesByRansac(
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// 第 2 级:逐行列范围比对
|
||||
bool allRowsCovered = true;
|
||||
for (int r = bboxes[j].minRow; r <= bboxes[j].maxRow; r++) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user