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