修改了检测接口,将平面参数放出

This commit is contained in:
MaJunwei 2026-04-02 16:45:55 +08:00
parent 114170d248
commit f95e3dc753
6 changed files with 31 additions and 26 deletions

View File

@ -183,12 +183,13 @@ int main(int argc, char* argv[]) {
// 执行孔洞检测
SMultiHoleResult result;
RansacPlaneSegmentationParams ransacParams;
std::cout << "开始检测..." << std::endl;
int errorCode = DetectMultipleHoles(
points.data(),
rows,
cols,
ransacParams,
detectionParams,
filterParams,
&result,

View File

@ -484,7 +484,7 @@ int ProcessSingleFile(const std::string& inputFile,
debugCallbacks.onHoleFitted = OnHoleFitted;
debugCallbacks.onSegmentPairsDetected = OnSegmentPairsDetected;
debugCallbacks.onLineAngleProfileDetected = nullptr;// OnLineAngleProfileDetected;
debugCallbacks.onPlanesSegmented = nullptr;// OnPlanesSegmented;
debugCallbacks.onPlanesSegmented = OnPlanesSegmented;
debugCallbacks.onMaskedPointsReady = nullptr;// OnMaskedPointsReady;
#else
debugCallbacks.onBoundaryDetected = nullptr;
@ -498,8 +498,9 @@ int ProcessSingleFile(const std::string& inputFile,
#endif
debugCallbacks.userData = &callbackData;
RansacPlaneSegmentationParams ransacParams;
SMultiHoleResult result;
ret = DetectMultipleHoles(points, rows, cols, detectionParams, filterParams, &result, &debugCallbacks);
ret = DetectMultipleHoles(points, rows, cols, ransacParams, detectionParams, filterParams, &result, &debugCallbacks);
if (ret != HD_SUCCESS) {
std::cerr << "Error detecting holes: " << ret << std::endl;

View File

@ -235,6 +235,7 @@ HOLE_DETECTION_API int DetectMultipleHoles(
const SVzNLPointXYZ* points,
int rows,
int cols,
const RansacPlaneSegmentationParams& ransacParams,
const SHoleDetectionParams& detectionParams,
const SHoleFilterParams& filterParams,
SMultiHoleResult* result,

View File

@ -4,6 +4,28 @@
#include <cmath>
#include "VZNL_Types.h" // 使用 VZNL_Types.h 中定义的类型
/**
* @brief RANSAC平面分割参数
*/
struct RansacPlaneSegmentationParams {
float distanceThreshold; // 点到平面距离阈值 (mm), 建议 0.5-2.0
int maxIterations; // RANSAC最大迭代次数, 建议 100-1000
int minPlanePoints; // 最小平面点数, 建议 50-200
int maxPlanes; // 最大提取平面数量, 建议 3-10
float growthZThreshold; // 区域生长时相邻点Z差阈值 (mm), 建议 0.5-2.0
float minPlaneRatio; // 平面最小点数占比 (相对最大平面), 建议 0.05-0.2
RansacPlaneSegmentationParams()
: distanceThreshold(0.5f)
, maxIterations(500)
, minPlanePoints(100)
, maxPlanes(5)
, growthZThreshold(1.0f)
, minPlaneRatio(0.1f)
{
}
};
/**
* @brief
*/

View File

@ -172,6 +172,7 @@ int DetectMultipleHoles(
const SVzNLPointXYZ* points,
int rows,
int cols,
const RansacPlaneSegmentationParams& ransacParams,
const SHoleDetectionParams& detectionParams,
const SHoleFilterParams& filterParams,
SMultiHoleResult* result,
@ -190,7 +191,6 @@ int DetectMultipleHoles(
int totalPointCount = rows * cols;
// ============ Step 1: RANSAC 平面分割 ============
RansacPlaneSegmentationParams ransacParams;
std::vector<PlaneSegment> planes;
SegmentPlanesByRansac(points, rows, cols, ransacParams, planes, &errCode);

View File

@ -1,7 +1,8 @@
#ifndef PLANE_SEGMENTATION_H
#define PLANE_SEGMENTATION_H
#include "../include/VZNL_Types.h"
#include "VZNL_Types.h"
#include "HoleDetectionParams.h"
#include "ErrorCodes.h"
#include <vector>
@ -284,27 +285,6 @@ int ComputeRowZDiffFluctuation(
// ========== RANSAC 平面分割 ==========
/**
* @brief RANSAC平面分割参数
*/
struct RansacPlaneSegmentationParams {
float distanceThreshold; // 点到平面距离阈值 (mm), 建议 0.5-2.0
int maxIterations; // RANSAC最大迭代次数, 建议 100-1000
int minPlanePoints; // 最小平面点数, 建议 50-200
int maxPlanes; // 最大提取平面数量, 建议 3-10
float growthZThreshold; // 区域生长时相邻点Z差阈值 (mm), 建议 0.5-2.0
float minPlaneRatio; // 平面最小点数占比 (相对最大平面), 建议 0.05-0.2
RansacPlaneSegmentationParams()
: distanceThreshold(1.0f)
, maxIterations(500)
, minPlanePoints(100)
, maxPlanes(5)
, growthZThreshold(1.0f)
, minPlaneRatio(0.1f)
{}
};
/**
* @brief
*/