using System; namespace YOLODetectProcessLib { public class InferenceNetworkInputImage : IDisposable { #region properties /// /// 图像 /// public IImage Image { get; protected set; } /// /// 感兴趣的区域 /// public Rect ROI { get; protected set; } /// /// 划定该ROI的置信度 /// public float Confidence { get; protected set; } /// /// 判断图像是否需要裁图 /// public bool IsCrop { get; protected set; } /// /// 额外的边界框 /// 有些模型在检测病灶时,可能需要除了感兴趣轮廓以外的图像作为补充信息 /// 如,肝脏弥漫性病灶分类模型,需要肝脏以外的其他器官作为对比,以便判断脂肪肝等疾病 /// 因此这里添加一个额外的边界框,供模型选择使用 /// public Rect ExtraBoundingBox { get; protected set; } #endregion #region constructor public InferenceNetworkInputImage(IImage image, Rect roi, float confidence = 1.0f) { Image = image; ROI = roi; Confidence = confidence; ExtraBoundingBox = Rect.Empty; } public InferenceNetworkInputImage(IImage image, bool iscrop = true, float confidence = 1.0f) { Image = image; Confidence = confidence; IsCrop = iscrop; ExtraBoundingBox = Rect.Empty; } #endregion #region dispose /// /// 析构函数 /// ~InferenceNetworkInputImage() { DoDispose(); LogHelper.InfoLog("InferenceNetworkInputImage.Disposed by destructor."); } /// /// 主动销毁 /// public void Dispose() { DoDispose(); GC.SuppressFinalize(this); LogHelper.InfoLog("InferenceNetworkInputImage.Disposed manually."); } /// /// 销毁 /// public void DoDispose() { Image?.Dispose(); Image = null; } #endregion } }