diff --git a/netstandard/ClothONNX.Gpu/ClothONNX.Gpu.csproj b/netstandard/ClothONNX.Gpu/ClothONNX.Gpu.csproj index 0c1dbeb..9548b26 100644 --- a/netstandard/ClothONNX.Gpu/ClothONNX.Gpu.csproj +++ b/netstandard/ClothONNX.Gpu/ClothONNX.Gpu.csproj @@ -4,8 +4,8 @@ netstandard2.0 ClothONNX.Gpu 8.0 - 1.0.0.1 - 1.0.0.1 + 1.0.1.1 + 1.0.1.1 Valery Asiryan Valery Asiryan Cloth segmentation library based on deep neural networks and ONNX runtime. @@ -13,7 +13,7 @@ Open-source ClothONNX.Gpu ClothONNX.Gpu - 1.0.0.1 + 1.0.1.1 true cloth detection segmentation recognition onnx neural-networks unet https://github.com/FaceONNX/ClothONNX @@ -31,7 +31,7 @@ - + diff --git a/netstandard/ClothONNX.Gpu/ClothSegmentator.cs b/netstandard/ClothONNX.Gpu/ClothSegmentator.cs index 782ac82..877b2db 100644 --- a/netstandard/ClothONNX.Gpu/ClothSegmentator.cs +++ b/netstandard/ClothONNX.Gpu/ClothSegmentator.cs @@ -69,7 +69,7 @@ public ClothSegmentator(SessionOptions options) for (int i = 0; i < image.Length; i++) { - resized[i] = image[i].ResizeBilinear(size.Height, size.Width); + resized[i] = image[i].Resize(size.Height, size.Width, InterpolationMode.Bilinear); } var dimentions = new int[] { 1, 3, size.Width, size.Height }; @@ -113,7 +113,7 @@ public ClothSegmentator(SessionOptions options) } } - return mask.ResizeBilinear(height, width); + return mask.Resize(height, width, InterpolationMode.Bilinear); } #endregion @@ -142,6 +142,9 @@ private void Dispose(bool disposing) } } + /// + /// Destructor. + /// ~ClothSegmentator() { Dispose(false); diff --git a/netstandard/ClothONNX.Gpu/internal/Transformations.cs b/netstandard/ClothONNX.Gpu/internal/Transformations.cs deleted file mode 100644 index ed3e95f..0000000 --- a/netstandard/ClothONNX.Gpu/internal/Transformations.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace ClothONNX -{ - /// - /// Using for UNet transformations. - /// - internal static class Transformations - { - /// - /// Returns resized matrix. - /// - /// Matrix - /// Height - /// Width - /// Matrix - public static float[,] ResizeBilinear(this float[,] input, int h, int w) - { - // get source size - int width = input.GetLength(1); - int height = input.GetLength(0); - - float xFactor = (float)width / w; - float yFactor = (float)height / h; - - // width and height decreased by 1 - int ymax = height - 1; - int xmax = width - 1; - - // output - float[,] H = new float[h, w]; - - // for each line - for (int y = 0; y < h; y++) - { - // Y coordinates - double oy = (double)y * yFactor; - int oy1 = (int)oy; - int oy2 = (oy1 == ymax) ? oy1 : oy1 + 1; - double dy1 = oy - (double)oy1; - double dy2 = 1.0 - dy1; - - // for each pixel - for (int x = 0; x < w; x++) - { - // X coordinates - double ox = (double)x * xFactor; - int ox1 = (int)ox; - int ox2 = (ox1 == xmax) ? ox1 : ox1 + 1; - double dx1 = ox - (double)ox1; - double dx2 = 1.0 - dx1; - - // get four points - var p1 = input[oy1, ox1]; - var p2 = input[oy1, ox2]; - var p3 = input[oy2, ox1]; - var p4 = input[oy2, ox2]; - - // interpolate using 4 points - H[y, x] = (float)( - dy2 * (dx2 * p1 + dx1 * p2) + - dy1 * (dx2 * p3 + dx1 * p4)); - } - } - - return H; - } - } -} diff --git a/netstandard/ClothONNX/ClothONNX.csproj b/netstandard/ClothONNX/ClothONNX.csproj index 86cf267..5e875e5 100644 --- a/netstandard/ClothONNX/ClothONNX.csproj +++ b/netstandard/ClothONNX/ClothONNX.csproj @@ -4,8 +4,8 @@ netstandard2.0 ClothONNX 8.0 - 1.0.0.1 - 1.0.0.1 + 1.0.1.1 + 1.0.1.1 Valery Asiryan Valery Asiryan Cloth segmentation library based on deep neural networks and ONNX runtime. @@ -13,7 +13,7 @@ Open-source ClothONNX ClothONNX - 1.0.0.1 + 1.0.1.1 true cloth detection segmentation recognition onnx neural-networks unet https://github.com/FaceONNX/ClothONNX @@ -31,7 +31,7 @@ - + diff --git a/netstandard/ClothONNX/ClothSegmentator.cs b/netstandard/ClothONNX/ClothSegmentator.cs index 782ac82..877b2db 100644 --- a/netstandard/ClothONNX/ClothSegmentator.cs +++ b/netstandard/ClothONNX/ClothSegmentator.cs @@ -69,7 +69,7 @@ public ClothSegmentator(SessionOptions options) for (int i = 0; i < image.Length; i++) { - resized[i] = image[i].ResizeBilinear(size.Height, size.Width); + resized[i] = image[i].Resize(size.Height, size.Width, InterpolationMode.Bilinear); } var dimentions = new int[] { 1, 3, size.Width, size.Height }; @@ -113,7 +113,7 @@ public ClothSegmentator(SessionOptions options) } } - return mask.ResizeBilinear(height, width); + return mask.Resize(height, width, InterpolationMode.Bilinear); } #endregion @@ -142,6 +142,9 @@ private void Dispose(bool disposing) } } + /// + /// Destructor. + /// ~ClothSegmentator() { Dispose(false); diff --git a/netstandard/ClothONNX/internal/Transformations.cs b/netstandard/ClothONNX/internal/Transformations.cs deleted file mode 100644 index ed3e95f..0000000 --- a/netstandard/ClothONNX/internal/Transformations.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace ClothONNX -{ - /// - /// Using for UNet transformations. - /// - internal static class Transformations - { - /// - /// Returns resized matrix. - /// - /// Matrix - /// Height - /// Width - /// Matrix - public static float[,] ResizeBilinear(this float[,] input, int h, int w) - { - // get source size - int width = input.GetLength(1); - int height = input.GetLength(0); - - float xFactor = (float)width / w; - float yFactor = (float)height / h; - - // width and height decreased by 1 - int ymax = height - 1; - int xmax = width - 1; - - // output - float[,] H = new float[h, w]; - - // for each line - for (int y = 0; y < h; y++) - { - // Y coordinates - double oy = (double)y * yFactor; - int oy1 = (int)oy; - int oy2 = (oy1 == ymax) ? oy1 : oy1 + 1; - double dy1 = oy - (double)oy1; - double dy2 = 1.0 - dy1; - - // for each pixel - for (int x = 0; x < w; x++) - { - // X coordinates - double ox = (double)x * xFactor; - int ox1 = (int)ox; - int ox2 = (ox1 == xmax) ? ox1 : ox1 + 1; - double dx1 = ox - (double)ox1; - double dx2 = 1.0 - dx1; - - // get four points - var p1 = input[oy1, ox1]; - var p2 = input[oy1, ox2]; - var p3 = input[oy2, ox1]; - var p4 = input[oy2, ox2]; - - // interpolate using 4 points - H[y, x] = (float)( - dy2 * (dx2 * p1 + dx1 * p2) + - dy1 * (dx2 * p3 + dx1 * p4)); - } - } - - return H; - } - } -} diff --git a/netstandard/Examples/ClothSegmentation/MaskColorFilter.cs b/netstandard/Examples/ClothSegmentation/MaskColorFilter.cs deleted file mode 100644 index 8d0743d..0000000 --- a/netstandard/Examples/ClothSegmentation/MaskColorFilter.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Drawing.Imaging; -using UMapx.Colorspace; -using UMapx.Imaging; - -namespace ClothSegmentation -{ - /// - /// Defines the mask color filter. - /// - [Serializable] - public class MaskColorFilter - { - /// - /// Initializes the mask color filter. - /// - /// - public MaskColorFilter(System.Drawing.Color color) - { - Color = color; - } - - /// - /// Gets or sets color. - /// - public System.Drawing.Color Color { get; set; } - - /// - /// Apply filter. - /// - /// Bitmap data - /// Bitmap data - public unsafe void Apply(BitmapData bmData, BitmapData bmSrc) - { - byte* p = (byte*)bmData.Scan0.ToPointer(); - byte* pSrc = (byte*)bmSrc.Scan0.ToPointer(); - int y, x, width = bmData.Width, height = bmData.Height; - - for (x = 0; x < width; x++) - { - for (y = 0; y < height; y++, p += 4, pSrc += 4) - { - var average = (byte)RGB.Average(pSrc[2], pSrc[1], pSrc[0]); - - if (average > 0) - { - p[2] = Color.R; - p[1] = Color.G; - p[0] = Color.B; - } - } - } - return; - } - - /// - /// Apply filter. - /// - /// Bitmap - /// Bitmap - public void Apply(Bitmap Data, Bitmap Src) - { - BitmapData bmData = BitmapFormat.Lock32bpp(Data); - BitmapData bmSrc = BitmapFormat.Lock32bpp(Src); - Apply(bmData, bmSrc); - BitmapFormat.Unlock(Data, bmData); - BitmapFormat.Unlock(Src, bmSrc); - } - } -}