mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 01:52:32 +02:00
6dc26f7434
- **File formats:**
- (Add) Property: DisplayTotalOnTime
- (Add) Property: DisplayTotalOffTime
- (Add) SL1File Property: high_viscosity_tilt_time
- **Tools**
- **I printed this file**
- (Add) Display on time for the print information
- (Improvement) Labels on numeric box
- (Improvement) Show print time label formatted as hh:mm:ss
- **PCB Exposure:**
- (Improvement) Increase "Exposure time" maximum from 200s to 1000s (#592)
- (Fix) Set `BottomLightHeight` to 0
- (Fix) Set `TransitionLayerCount` to 0
- **Issues:**
- (Improvement) Overhang detection by using a dynamic cross kernel
- (Improvement) Bring back the discard logic of "false-positive" islands based on overhang detection but improve the threshold of the detection to be safer (#591, #591)
- **PrusaSlicer:**
- (Change) Elegoo Mars 2 to use file version 4
- (Change) Elegoo Mars 2 Pro to use file version 4
- (Add) Status bar: On and Off time (hh:mm:ss) as tooltip in the Print time label
- (Improvement) When any of libcvextern dependencies are missing, it try to show the missing libraries in the error message (Linux only)
- (Improvement) Auto-upgrade procedure for non-Windows systems
- (Improvement) macOS arm64 (M1/M2) can now run natively if installed via the auto installer script
- (Fix) Error on Mat cache manager when file have only one layer
- (Fix) Suggestion "Transition layer count" shows as never applied when using with file formats that use in-firmware transition layers
- (Upgrade) openCV from 4.5.4 to 4.6.0
- Custom library is now built to strip unused dependencies and reduce library size
- (Remove) arch and rhel packages in favor of a generic linux
57 lines
1.6 KiB
C#
57 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 Emgu.CV;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using Emgu.CV.CvEnum;
|
|
using UVtools.Core.Extensions;
|
|
|
|
namespace UVtools.Core.Managers;
|
|
|
|
public class KernelCacheManager : IDisposable
|
|
{
|
|
private readonly ConcurrentDictionary<int, Mat> _kernelCache = new();
|
|
|
|
public bool UseDynamicKernel { get; set; }
|
|
|
|
public ElementShape DynamicKernelShape { get; set; } = ElementShape.Ellipse;
|
|
|
|
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, DynamicKernelShape));
|
|
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();
|
|
}
|
|
} |