using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Check.Main.Infer
{
public interface IDetector : IDisposable
{
///
/// 初始化检测器。
///
/// 模型文件路径(对于传统算法可能是模板目录)
/// 特定于检测器的设置对象(可选,可以用于传递阈值等)
void Initialize(string modelPath, object detectionSettings = null);
///
/// 执行图像检测。
///
/// 待检测的图像。
/// 包含检测结果(如OK/NG,得分,边界框等)的统一对象。
DetectionResult Detect(Bitmap image);
}
///
/// 统一的检测结果类。
///
public class DetectionResult
{
public bool IsOk { get; set; }
public string Message { get; set; }
public double Score { get; set; }
public List BoundingBoxes { get; set; } // 深度学习可能返回多个目标框
// 如果需要,可以添加带有绘制结果的图像
public Bitmap ResultImage { get; set; }
public DetectionResult(bool isOk, string message = "Unknown", double score = 0.0, List boundingBoxes = null, Bitmap resultImage = null)
{
IsOk = isOk;
Message = message;
Score = score;
BoundingBoxes = boundingBoxes ?? new List();
ResultImage = resultImage;
}
}
//// 辅助设置类,用于传递给 HalconTemplateDetector
//public class HalconDetectionSettings
//{
// public double ScoreThreshold { get; set; } = 0.5;
//}
// 辅助设置类,用于传递给 YoloDetector
public class YoloDetectionSettings
{
public float ConfidenceThreshold { get; set; } = 0.25f;
public float NmsThreshold { get; set; } = 0.45f;
}
}