修改框架(未完全完成)实现单个相机分开绑定算法

This commit is contained in:
2025-10-20 17:47:48 +08:00
parent 31d9f8d6b6
commit 73249ee6c2
11 changed files with 1226 additions and 422 deletions

View File

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