2026-06-26 17:55:15 +08:00

250 lines
7.1 KiB
YAML

# ============================================================
# (C++ port)
#
# Python e:/02_Modules/StereoVisionBoltMeasurement/config.yaml
#
# Python paths
# ============================================================
# ---------- ----------
image:
width: 4096
height: 3000
channels: 1
expected_dtype: "uint8"
allowed_extensions: [".tiff", ".tif", ".bmp", ".png"]
# ---------- ----------
image_validation:
min_max_value: 10
max_saturation_ratio: 0.20
# ---------- ChArUco ----------
charuco:
rows: 9
cols: 9
square_length_mm: 50.0
marker_length_mm: 37.0
dict_id: 11 # DICT_6X6_1000
min_corners_per_image: 30
# ---------- ----------
calibration:
source: "xml"
xml_path: "calib/stereo_calib.xml" # 0621 新装配 baseline 482mm (ChArUco)
min_image_pairs: 15
max_skip_ratio: 0.30
max_single_rms: 0.40 # : 12MP RMS=0.373(5MP 0.19)
# 0.40 ;0.373 0.1px ,,
# <0.20
max_stereo_rms: 0.80
expected_baseline_range: [80, 600]
use_fix_intrinsic: true
# ---------- ----------
# alpha=1.0 CLAUDE.md #1
rectification:
alpha: 1.0
interpolation: "cubic"
validation_feature_count: 500
validation_match_count: 10
epipolar_inlier_threshold_pixel: 5.0
min_epipolar_inlier_count: 3
max_epipolar_error_pixel: 5.0
min_valid_roi_ratio: 0.25
# ---------- SGBM ----------
# min_disparity / num_disparities f_rectB
# f_rect3190, B235mmalpha=1.0
sgbm:
min_disparity: 288
num_disparities: 736
block_size: 5
P1: 600
P2: 2400
disp12_max_diff: 1
uniqueness_ratio: 10
speckle_window_size: 100
speckle_range: 2
pre_filter_cap: 63
mode: "SGBM_3WAY"
# ---------- WLS ----------
wls:
lambda_value: 8000.0
sigma_color: 1.5
# ---------- ----------
disparity_validation:
min_valid_pixel_ratio: 0.10
min_disparity_range: 50
max_nan_ratio: 0.90
# ---------- ----------
# z_min_mm / z_max_mm / expected_wd_range are FALLBACK only when run_pipeline /
# c_api are wired (the standard path) SceneRuntime derives the real reachable
# Z range from (f_rect, baseline, sgbm.min_disparity, sgbm.num_disparities) and
# overrides these values per frame. See docs/L_100_SCENE_HANDOFF.md 6.2 and
# include/stereo_bolt/scene_runtime.hpp. Keep the fallback values conservative
# enough to cover every supported workpiece distance.
pointcloud:
z_min_mm: 600
z_max_mm: 3000
expected_wd_range: [600, 3000]
min_num_points: 50000
max_z_std_mm: 800
min_bbox_extent_x_mm: 200
min_bbox_extent_y_mm: 100
sor_nb_neighbors: 30
sor_std_ratio: 2.0
voxel_downsample_min_points: 500000
voxel_size_mm: 0.5
roi_mask:
enabled: false
method: "hsv_threshold"
hsv_lower: [0, 0, 210]
hsv_upper: [180, 50, 255]
morph_close_kernel: 15
dilate_px: 100
min_area_ratio: 0.02
# ---------- 2D ----------
# mask_method: foam_mask( mask)
# "brightness" + (;
# rectify ROI 0, mask ROI )
# "ransac" dense xyz_map RANSAC ,
# " < ransac.distance_thresh_mm" mask
# "brightness" parity_tests , "ransac"
bolt_detect_2d:
mask_method: "ransac"
foam_brightness_threshold: 70
foam_morph_open_kernel: 21
foam_dilate_px: 0
bbox_margin_px: 60
bolt_morph_close_kernel: 15
bolt_min_area_px: 800
min_bolts: 1
max_bolts: 0
bolt_exclude_dilate_px: 0 # 0 CLAUDE.md #5
ransac:
distance_thresh_mm: 8.0 # < inlier(3
# frame 100 residual_std2.6 mm)
max_iterations: 200
min_inlier_ratio: 0.15 # inlier
sample_stride: 4 # xyz_map ( 44 1 RANSAC )
morph_close_kernel_px: 9 # mask +
# ---------- (SVD on foam mask) ----------
plane:
max_residual_std_mm: 15.0
max_normal_to_axis_deg: 60
outlier_rejection_iterations: 5
outlier_mad_k: 2.5
# ---------- ----------
# plane fit bolt extract bolt 3D
# inlier OBB, OBB margin_mm WARN
# margin_mm bolt.expected_diameter_mm,
# /
support_gate:
enabled: true
margin_mm: 10.0
# ---------- ----------
# (run_pipeline / c_api) bolt bbox_projection h_est,
# extract height max(h_est 1.3, h_est + 20 mm),
# validate_measurements |measured - h_est| < bolt.height_tolerance_mm
# max_height_mm / extract_height_filter_mm fallback
# bbox_projection h_est
# (expected_diameter_mm),
bolt:
min_height_mm: 5.0
max_height_mm: 250.0 # fallback ceiling (used only when h_est is unavailable)
extract_height_filter_mm: 200.0 # fallback filter (same condition)
height_tolerance_mm: 60.0 # |measured - h_est| ; validate_measurements
expected_diameter_mm: 16.0
min_points_per_bolt: 50
max_axis_plane_angle_deg: 30
extract_fallback: "bbox_projection" # 'none' | 'bbox_projection'; YOLO bbox + , SGBM /
# ---------- ----------
measurement:
top_extraction_method: "percentile_on_axis"
top_percentile: 0.99
foot_rim_correction: false # 0621 决定: 关 rim(圆顶无领圈杆上 rim 修正会过冲)
# ---------- Diagnostics ----------
diagnostics:
enabled: true
blind_strip_warn_ratio: 0.25
min_roi_pointcloud_coverage_ratio: 0.001
# ---------- YOLO ----------
# C++ ONNX Python best_v4_finetune.pt .onnx
# dilate (50/30),
# scene_runtime.cpp pixels_per_mm(= f / Z_repr),
# /
yolo:
enabled: true
# 统一模型: 精测(sb_process_bolt_module_*)与测距(sb_range_bolt_binned)共用 weights/best.rknn。
# 当前交付模型为 960 输入;文件名保持稳定,模型更新时只替换 weights/best.rknn。
model_path: "weights/best.rknn"
backend: "rknn"
imgsz: 960
conf: 0.5
dead_zone_min_valid_pts: 50
dead_zone_bbox_dilate_mm: 24.0 # = expected_diameter_mm 1.5; valid_xyz bbox ,/
foam_bbox_dilate_mm: 16.0 # = expected_diameter_mm 1.0; foam_mask YOLO bbox
# Experimental: keep sparse-global YOLO bolts only when right YOLO + local LR check pass.
local_stereo_fallback:
enabled: true
min_valid_points: 50
# ---------- working distance (physical, rig-level) ----------
# 0621 新装配 B=482mm: 精测视差带从 WD + 标定自推导 (disp = f*B/Z), 换基线无需重调像素。
# 旧固定 sgbm 像素带(288/736)是 200mm 装配的, 对 482mm 会 NEAR-clip 近处螺柱。
# 注意: 需 .so 含视差带解耦(commit dc696d8 起); 旧 .so 不读此块仍用固定带。
working_distance:
z_min_mm: 1200
z_max_mm: 2800
# ---------- ranging (binned) ----------
# 测距视差带也按 0621 rig 的 WD; 物理 LRC 门(mm)随距离自紧。
ranging:
z_min_mm: 1300
z_max_mm: 3600
lrc_max_mm: 2.5
lrc_trusted_mm: 1.2
# ---------- ----------
evaluation:
height_max_mm: 2.0
height_p95_mm: 1.5
pair_max_mm: 2.0
pair_p95_mm: 1.5
repeatability_std_max_mm: 1.0
matching_max_distance_mm: 50.0
# ---------- ----------
pipeline:
fail_fast: true
resume_from_checkpoint: true
parallel_frames: false
save_intermediate: false
# ---------- ----------
logging:
level: "INFO"
log_to_file: true
log_file: "outputs/logs/pipeline.log"
# ---------- ----------
# dataset/ , Python
paths:
calibration_dir: "calib"
test_dir: "dataset/test"
groundtruth_csv: "dataset/groundtruth.csv"
output_dir: "outputs_macro257"
stereo_params_yaml: "outputs_macro257/stereo_params.yaml"