fixed minimap mode switching

This commit is contained in:
Boki 2026-02-15 10:51:15 -05:00
parent 3e49a96caa
commit d7948fd4a7
2 changed files with 29 additions and 7 deletions

View file

@ -37,8 +37,9 @@ public class MinimapCapture : IFrameConsumer, IDisposable
var detected = DetectMinimapMode(screen);
if (detected != _detectedMode)
{
var oldMode = _detectedMode;
_detectedMode = detected;
Log.Information("Minimap mode switched to {Mode}", _detectedMode);
Log.Information("MODE SWITCH: {Old} → {New}", oldMode, _detectedMode);
ResetAdaptation();
ModeChanged?.Invoke(_detectedMode);
}
@ -55,6 +56,11 @@ public class MinimapCapture : IFrameConsumer, IDisposable
var frame = ProcessBgr(bgr);
if (frame == null) return;
Log.Debug("Process: mode={Mode} cropSize={W}x{H} classifiedSize={CW}x{CH} wallSize={WW}x{WH}",
_detectedMode, bgr.Width, bgr.Height,
frame.ClassifiedMat.Width, frame.ClassifiedMat.Height,
frame.WallMask.Width, frame.WallMask.Height);
var old = Interlocked.Exchange(ref _lastFrame, frame);
old?.Dispose();
}

View file

@ -38,6 +38,10 @@ public class WorldMap : IDisposable
var warmupFrames = isCorner ? 2 : _config.WarmupFrames;
var needsBootstrap = _frameCount <= warmupFrames || _consecutiveMatchFails >= 30;
Log.Debug("MatchAndStitch: frame#{N} mode={Mode} frameSize={W}x{H} pos=({X:F1},{Y:F1}) bootstrap={Boot} prevWallMask={HasPrev}",
_frameCount, mode, wallMask.Width, wallMask.Height,
_position.X, _position.Y, needsBootstrap, _prevWallMask != null);
// Block-based noise filter: only needed for overlay (game effects bleed through)
if (!isCorner)
{
@ -147,10 +151,17 @@ public class WorldMap : IDisposable
// Check if canvas has enough walls to match against
var canvasWallCount = Cv2.CountNonZero(canvasWalls);
var frameWallCount = Cv2.CountNonZero(wallMask);
if (frameWallCount < 50)
{
Log.Information("Match fail: too few frame walls ({FrameWalls}) frameSize={FS}",
frameWallCount, frameSize);
return null;
}
if (canvasWallCount < 50)
{
Log.Information("Match fail: too few canvas walls ({CanvasWalls}) frame walls={FrameWalls}",
canvasWallCount, frameWallCount);
Log.Information("Match fail: too few canvas walls ({CanvasWalls}) frame walls={FrameWalls} frameSize={FS} searchROI={SW}x{SH}",
canvasWallCount, frameWallCount, frameSize, sw, sh);
return null;
}
@ -161,8 +172,8 @@ public class WorldMap : IDisposable
if (maxVal < _config.MatchConfidence)
{
Log.Information("Match fail: low confidence {Conf:F3} (need {Min:F2}) canvas={CanvasWalls} frame={FrameWalls}",
maxVal, _config.MatchConfidence, canvasWallCount, frameWallCount);
Log.Information("Match fail: low confidence {Conf:F3} (need {Min:F2}) frameSize={FS} searchROI={SW}x{SH} canvas={CanvasWalls} frame={FrameWalls}",
maxVal, _config.MatchConfidence, frameSize, sw, sh, canvasWallCount, frameWallCount);
return null;
}
@ -171,8 +182,10 @@ public class WorldMap : IDisposable
var matchX = sx0 + maxLoc.X + frameSize / 2.0;
var matchY = sy0 + maxLoc.Y + frameSize / 2.0;
Log.Information("Match OK: conf={Conf:F3} pos=({X:F1},{Y:F1}) canvas={CanvasWalls} frame={FrameWalls}",
maxVal, matchX, matchY, canvasWallCount, frameWallCount);
var deltaX = matchX - estimate.X;
var deltaY = matchY - estimate.Y;
Log.Information("Match OK: conf={Conf:F3} pos=({X:F1},{Y:F1}) delta=({Dx:F1},{Dy:F1}) frameSize={FS} searchROI={SW}x{SH} canvas={CanvasWalls} frame={FrameWalls}",
maxVal, matchX, matchY, deltaX, deltaY, frameSize, sw, sh, canvasWallCount, frameWallCount);
return new MapPosition(matchX, matchY);
}
@ -511,6 +524,9 @@ public class WorldMap : IDisposable
/// </summary>
public void Rebootstrap()
{
Log.Information("Rebootstrap: frameCount={N} pos=({X:F1},{Y:F1}) matchFails={Fails} prevWallMask={Size}",
_frameCount, _position.X, _position.Y, _consecutiveMatchFails,
_prevWallMask != null ? $"{_prevWallMask.Width}x{_prevWallMask.Height}" : "null");
_prevWallMask?.Dispose();
_prevWallMask = null;
// Don't reset _frameCount or _consecutiveMatchFails —