From 90d2f911c19999ac549ffe89e836fa274673bcd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Tue, 14 Sep 2021 20:05:05 +0100 Subject: [PATCH] Allow UMats --- UVtools.Core/Extensions/EmguExtensions.cs | 23 +++++++++++++++++++++++ UVtools.Core/Layer/LayerManager.cs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) 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 @@ -67,6 +67,14 @@ namespace UVtools.Core.Extensions public static Mat NewBlank(this Mat mat) => InitMat(mat.Size, mat.NumberOfChannels, mat.Depth); + /// + /// Creates a new blanked (All zeros) with same size and type of the source + /// + /// + /// Blanked + public static UMat NewBlank(this UMat mat) + => InitUMat(mat.Size, mat.NumberOfChannels, mat.Depth); + /// /// Creates a with same size and type of the source and set it to a color /// @@ -87,6 +95,21 @@ namespace UVtools.Core.Extensions public static Mat InitMat(Size size, int channels = 1, DepthType depthType = DepthType.Cv8U) => size.IsEmpty ? new() : Mat.Zeros(size.Height, size.Width, depthType, channels); + /// + /// Creates a new and zero it + /// + /// + /// + /// + /// + 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; + } + /// /// Creates a new and set it to a /// diff --git a/UVtools.Core/Layer/LayerManager.cs b/UVtools.Core/Layer/LayerManager.cs index b718767..1e7449c 100644 --- a/UVtools.Core/Layer/LayerManager.cs +++ b/UVtools.Core/Layer/LayerManager.cs @@ -775,7 +775,7 @@ namespace UVtools.Core return true; } - void GenerateAirMap(Mat input, Mat output, VectorOfVectorOfPoint externals) + void GenerateAirMap(IInputArray input, IInputOutputArray output, VectorOfVectorOfPoint externals) { CvInvoke.BitwiseNot(input, output); if (externals is null || externals.Size == 0) return;