namespace HardwareControl.Core.SampleAnalysis { /// 硬件使用类型,对应系统参数 hardware_usage_type。 public enum HardwareUsageType { /// 仅使用 CPU。 Cpu = 1, /// 使用独立显卡(DirectML)。 DiscreteGpu = 2, /// 使用核心显卡(DirectML)。 IntegratedGpu = 3, } /// 靶样 ONNX 分割模型配置。 public sealed class OnnxSegmentationOptions { public const string SectionName = "SampleAnalysis:Onnx"; /// 模型路径;相对路径基于程序运行目录。 public string? ModelPath { get; set; } /// /// 模型目录;相对路径基于程序运行目录。 /// 目录内按文件名前面的数字从小到大依次尝试,直到某个模型识别成功。 /// public string? ModelDirectory { get; set; } = "Models"; public int InputWidth { get; set; } = 640; public int InputHeight { get; set; } = 640; /// /// 推理执行后端:Auto(优先 DirectML,不可用时回退 CPU)、DirectML、Cpu。 /// DirectML 可调用核显/独显,同时保留 CPU 算子回退。 /// public string ExecutionProvider { get; set; } = "Auto"; /// DirectML 设备序号,0 表示系统默认适配器。 public int DmlDeviceId { get; set; } /// YOLO 分割模型的目标置信度阈值。 public double ConfidenceThreshold { get; set; } = 0.25; /// /// 模型置信度低于该值时,继续尝试后续模型,取置信度最高的结果。 /// public double FallbackConfidenceThreshold { get; set; } = 0.6; /// 概率型二值 mask 的阈值;logits 输出会自动改用 0。 public double MaskThreshold { get; set; } = 0.5; /// 像素归一化系数。 public double Scale { get; set; } = 1.0 / 255.0; /// 是否交换 R/B 通道(大多数 ONNX 模型需要 true)。 public bool SwapRB { get; set; } = true; /// Letterbox 填充值。 public double LetterboxPadValue { get; set; } = 114; /// 轮廓面积占图像的最小比例。 public double MinAreaRatio { get; set; } = 0.0005; /// 轮廓面积占图像的最大比例。 public double MaxAreaRatio { get; set; } = 0.98; /// /// 采样点距轮廓边缘的最小比例(相对于轮廓外接矩形短边)。 /// 防止激光点过于贴近靶样边缘而脱离靶面。 /// public double SamplingMarginRatio { get; set; } = 0.1; } }