mirror of
https://github.com/whoswhip/Spectrum.git
synced 2026-12-06 01:28:42 +00:00
Optimizations and fix memory leak/build up by disposing the mats
This commit is contained in:
@@ -114,11 +114,15 @@ namespace Spectrum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void AddToQueue(Mat mat, Rectangle bounds, OpenCvSharp.Point[][] filteredContours)
|
public static void AddToQueue(Mat mat, Rectangle bounds, OpenCvSharp.Point[][] filteredContours)
|
||||||
{
|
{
|
||||||
if (!Config.AutoLabel || filteredContours.Length == 0)
|
if (!Config.AutoLabel || filteredContours.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (labelingQueue.Count > 250)
|
||||||
|
return;
|
||||||
|
|
||||||
Mat clone = mat.Clone();
|
Mat clone = mat.Clone();
|
||||||
labelingQueue.Enqueue(new LabelingData
|
labelingQueue.Enqueue(new LabelingData
|
||||||
{
|
{
|
||||||
@@ -138,6 +142,9 @@ namespace Spectrum
|
|||||||
if (detectionAttemps < Config.BackgroundImageInterval || detected)
|
if (detectionAttemps < Config.BackgroundImageInterval || detected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (backgroundQueue.Count > 250)
|
||||||
|
return;
|
||||||
|
|
||||||
Mat clone = mat.Clone();
|
Mat clone = mat.Clone();
|
||||||
backgroundQueue.Enqueue(new BackgroundImageData
|
backgroundQueue.Enqueue(new BackgroundImageData
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ namespace Spectrum
|
|||||||
public static bool ClosestToMouse { get; set; } = true; // if false it will use the center of the screen
|
public static bool ClosestToMouse { get; set; } = true; // if false it will use the center of the screen
|
||||||
public static int Keybind { get; set; } = 0x06; // first side button on mouse
|
public static int Keybind { get; set; } = 0x06; // first side button on mouse
|
||||||
public static double Sensitivity { get; set; } = 0.5;
|
public static double Sensitivity { get; set; } = 0.5;
|
||||||
public static MovementType AimMovementType { get; set; } = MovementType.CubicBezier;
|
public static MovementType AimMovementType { get; set; } = MovementType.Adaptive;
|
||||||
|
|
||||||
// Display settings
|
// Display settings
|
||||||
public static bool ShowDetectionWindow { get; set; } = true;
|
public static bool ShowDetectionWindow { get; set; } = true;
|
||||||
|
|||||||
+6
-2
@@ -14,7 +14,6 @@ namespace Spectrum
|
|||||||
Config.LoadConfig();
|
Config.LoadConfig();
|
||||||
Config.StartFileWatcher();
|
Config.StartFileWatcher();
|
||||||
|
|
||||||
|
|
||||||
var screenSize = SystemHelper.GetPrimaryScreenSize();
|
var screenSize = SystemHelper.GetPrimaryScreenSize();
|
||||||
bounds = new Rectangle(
|
bounds = new Rectangle(
|
||||||
(screenSize.Width - Config.ImageWidth) / 2,
|
(screenSize.Width - Config.ImageWidth) / 2,
|
||||||
@@ -251,11 +250,16 @@ namespace Spectrum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Config.ShowDetectionWindow)
|
else if (Config.ShowDetectionWindow || Config.CollectData)
|
||||||
{
|
{
|
||||||
Cv2.ImShow("Spectrum Detection", drawing);
|
Cv2.ImShow("Spectrum Detection", drawing);
|
||||||
Cv2.WaitKey(1);
|
Cv2.WaitKey(1);
|
||||||
|
if (Config.CollectData)
|
||||||
|
AutoLabeling.AddBackgroundImage(drawing, false);
|
||||||
}
|
}
|
||||||
|
screenshot?.Dispose();
|
||||||
|
mat.Dispose();
|
||||||
|
drawing.Dispose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user