diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-09-14 22:05:05 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-09-14 22:05:05 +0300 |
commit | 90d2f911c19999ac549ffe89e836fa274673bcd7 (patch) | |
tree | 7ee459106618ddea2097e9e6edf96cfccd46cf54 /UVtools.Core/Extensions/EmguExtensions.cs | |
parent | 60db062e7017a30e226db8974bc2ee1262ace249 (diff) |
Allow UMats
Diffstat (limited to 'UVtools.Core/Extensions/EmguExtensions.cs')
-rw-r--r-- | UVtools.Core/Extensions/EmguExtensions.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/UVtools.Core/Extensions/EmguExtensions.cs b/UVtools.Core/Extensions/EmguExtensions.cs index a21ca9c..7b4577e 100644 --- a/UVtools.Core/Extensions/EmguExtensions.cs +++ b/UVtools.Core/Extensions/EmguExtensions.cs @@ -68,6 +68,14 @@ namespace UVtools.Core.Extensions => InitMat(mat.Size, mat.NumberOfChannels, mat.Depth); /// <summary> + /// Creates a new blanked (All zeros) <see cref="UMat"/> with same size and type of the source + /// </summary> + /// <param name="mat"></param> + /// <returns>Blanked <see cref="Mat"/></returns> + public static UMat NewBlank(this UMat mat) + => InitUMat(mat.Size, mat.NumberOfChannels, mat.Depth); + + /// <summary> /// Creates a <see cref="Mat"/> with same size and type of the source and set it to a color /// </summary> /// <param name="mat"></param> @@ -88,6 +96,21 @@ namespace UVtools.Core.Extensions => size.IsEmpty ? new() : Mat.Zeros(size.Height, size.Width, depthType, channels); /// <summary> + /// Creates a new <see cref="UMat"/> and zero it + /// </summary> + /// <param name="size"></param> + /// <param name="channels"></param> + /// <param name="depthType"></param> + /// <returns></returns> + public static UMat InitUMat(Size size, int channels = 1, DepthType depthType = DepthType.Cv8U) + { + if (size.IsEmpty) return new(); + var umat = new UMat(size.Height, size.Width, depthType, channels); + umat.SetTo(BlackColor); + return umat; + } + + /// <summary> /// Creates a new <see cref="Mat"/> and set it to a <see cref="MCvScalar"/> /// </summary> /// <param name="size"></param> |