diff options
Diffstat (limited to 'UVtools.Core/EmguCV/MatRoi.cs')
-rw-r--r-- | UVtools.Core/EmguCV/MatRoi.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/UVtools.Core/EmguCV/MatRoi.cs b/UVtools.Core/EmguCV/MatRoi.cs new file mode 100644 index 0000000..6bd5b3f --- /dev/null +++ b/UVtools.Core/EmguCV/MatRoi.cs @@ -0,0 +1,49 @@ +/* + * GNU AFFERO GENERAL PUBLIC LICENSE + * Version 3, 19 November 2007 + * Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. + */ + + +using System; +using System.Drawing; +using Emgu.CV; +using UVtools.Core.Extensions; + +namespace UVtools.Core.EmguCV; + +/// <summary> +/// A disposable Mat with associated ROI Mat +/// </summary> +public class MatRoi : IDisposable +{ + #region Properties + public Mat SourceMat { get; } + public Rectangle Roi { get; } + public Mat RoiMat { get; } + + public Point RoiLocation => Roi.Location; + public Size RoiSize => Roi.Size; + + #endregion + + #region Constructor + + public MatRoi(Mat sourceMat, Rectangle roi) + { + SourceMat = sourceMat; + Roi = roi; + RoiMat = sourceMat.Roi(roi); + } + + #endregion + + + public void Dispose() + { + SourceMat.Dispose(); + RoiMat.Dispose(); + } +}
\ No newline at end of file |