mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-12 19:42:32 +02:00
957729525d
- **Tool - Morph:** - (Add) Operator: White tophat - Removes small isolated pixels and only return its affected pixels (Image - Noise removal) - (Add) Operator: Black tophat - Closes small holes inside the objects and only return its affected pixels (Gap closing - Image) - (Add) Operator: Hit or miss - Finds pixels in a given kernel pattern - (Remove) Operator: 'Isolate features' as that is the same as the 'White tophat' and is already inbuilt into OpenCV - **Kernels:** - (Add) Option: Use dynamic kernel to enhancement the quality of the borders (#367) - (Add) Kernels are now saved with the operation profile - **PrusaSlicer:** - (Add) Support to slice files to be converted for encrypted CTB format - (Add) Printer: Elegoo Mars 3 (#370) - (Add) Printer: EPAX E10 5K - (Add) Printer: EPAX X10 5K - (Add) Printer: Phrozen Sonic Mini 8K - (Add) Printer: Phrozen Sonic Mega 8K - (Fix) Printer: AnyCubic Photon Mono 4K - display size (#369) - (Fix) Printer: AnyCubic Photon Mono X 6K - display size (#369) - (Add) Tool - Double exposure: Kernel configuration - (Add) Tool - Pixel arithmetic: Kernel configuration - (Add) Calibration - Elephant foot: Use dynamic kernel to enhancement the quality of the borders (#367) - (Fix) Calibrate - Elephant foot: Redo (Ctrl + Z) the operation was crashing the application - (Fix) CTB, PHZ, FDG: Converting files with a null machine name would cause a exception - (Fix) Anycubic files: Bottom lift and speed were showing default values instead of real used value
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
/*
|
|
* 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.Collections.Concurrent;
|
|
using Emgu.CV;
|
|
using UVtools.Core.Extensions;
|
|
|
|
namespace UVtools.Core.Managers
|
|
{
|
|
public class KernelCacheManager : IDisposable
|
|
{
|
|
private readonly ConcurrentDictionary<int, Mat> _kernelCache = new();
|
|
|
|
public bool UseDynamicKernel { get; set; }
|
|
|
|
private readonly Mat _defaultKernel;
|
|
|
|
public KernelCacheManager(bool useDynamicKernel = false, Mat defaultKernel = null)
|
|
{
|
|
UseDynamicKernel = useDynamicKernel;
|
|
_defaultKernel = defaultKernel ?? EmguExtensions.Kernel3x3Rectangle;
|
|
}
|
|
|
|
public Mat Get(ref int iterations)
|
|
{
|
|
if (!UseDynamicKernel) return _defaultKernel;
|
|
var mat = _kernelCache.GetOrAdd(iterations, i => EmguExtensions.GetDynamicKernel(ref i));
|
|
iterations = 1;
|
|
return mat;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clears and dispose all the cache
|
|
/// </summary>
|
|
public void Clear()
|
|
{
|
|
foreach (var (_, mat) in _kernelCache)
|
|
{
|
|
if(ReferenceEquals(mat, EmguExtensions.Kernel3x3Rectangle)) mat?.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Dispose()
|
|
{
|
|
Clear();
|
|
}
|
|
}
|
|
}
|