Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Conceição <Tiago_caza@hotmail.com>2021-09-14 22:05:05 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2021-09-14 22:05:05 +0300
commit90d2f911c19999ac549ffe89e836fa274673bcd7 (patch)
tree7ee459106618ddea2097e9e6edf96cfccd46cf54 /UVtools.Core/Extensions/EmguExtensions.cs
parent60db062e7017a30e226db8974bc2ee1262ace249 (diff)
Allow UMats
Diffstat (limited to 'UVtools.Core/Extensions/EmguExtensions.cs')
-rw-r--r--UVtools.Core/Extensions/EmguExtensions.cs23
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>