This commit is contained in:
Boki 2026-02-17 19:40:53 -05:00
parent 2565028ad0
commit 23c581cff9
6 changed files with 41 additions and 54 deletions

View file

@ -20,6 +20,13 @@ public class MinimapCapture : IFrameConsumer, IDisposable
public MinimapMode DetectedMode => _detectedMode;
public MinimapFrame? LastFrame => _lastFrame;
/// <summary>
/// Atomically take ownership of the last frame (sets _lastFrame to null).
/// Caller is responsible for disposing the returned frame.
/// </summary>
public MinimapFrame? TakeFrame() => Interlocked.Exchange(ref _lastFrame, null);
public event Action<MinimapMode>? ModeChanged;
public MinimapCapture(MinimapConfig config, IScreenCapture backend, string? assetsDir = null)
@ -259,6 +266,22 @@ public class MinimapCapture : IFrameConsumer, IDisposable
Cv2.BitwiseNot(playerMask, notPlayer);
Cv2.BitwiseAnd(wallMask, notPlayer, wallMask);
// Overlay mode: exclude game text labels bleeding through the minimap.
// Text color #E0E0F6 → HSV(120, 23, 246): same blue hue as walls but
// much lower saturation. AA edges blend with the background pushing S
// above the wall floor. Detect the text core, dilate to cover the AA
// fringe, then subtract from wall mask before morphology amplifies it.
if (!isCorner)
{
using var textMask = new Mat();
Cv2.InRange(hsv, new Scalar(0, 0, 200), new Scalar(180, 50, 255), textMask);
using var textKernel = Cv2.GetStructuringElement(MorphShapes.Ellipse, new Size(11, 11));
Cv2.Dilate(textMask, textMask, textKernel);
using var notText = new Mat();
Cv2.BitwiseNot(textMask, notText);
Cv2.BitwiseAnd(wallMask, notText, wallMask);
}
if (sample && !isCorner)
_colorTracker.SampleFrame(hsv, wallMask);