fixed minimap mode switching
This commit is contained in:
parent
3e49a96caa
commit
d7948fd4a7
2 changed files with 29 additions and 7 deletions
|
|
@ -37,8 +37,9 @@ public class MinimapCapture : IFrameConsumer, IDisposable
|
||||||
var detected = DetectMinimapMode(screen);
|
var detected = DetectMinimapMode(screen);
|
||||||
if (detected != _detectedMode)
|
if (detected != _detectedMode)
|
||||||
{
|
{
|
||||||
|
var oldMode = _detectedMode;
|
||||||
_detectedMode = detected;
|
_detectedMode = detected;
|
||||||
Log.Information("Minimap mode switched to {Mode}", _detectedMode);
|
Log.Information("MODE SWITCH: {Old} → {New}", oldMode, _detectedMode);
|
||||||
ResetAdaptation();
|
ResetAdaptation();
|
||||||
ModeChanged?.Invoke(_detectedMode);
|
ModeChanged?.Invoke(_detectedMode);
|
||||||
}
|
}
|
||||||
|
|
@ -55,6 +56,11 @@ public class MinimapCapture : IFrameConsumer, IDisposable
|
||||||
var frame = ProcessBgr(bgr);
|
var frame = ProcessBgr(bgr);
|
||||||
if (frame == null) return;
|
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);
|
var old = Interlocked.Exchange(ref _lastFrame, frame);
|
||||||
old?.Dispose();
|
old?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,10 @@ public class WorldMap : IDisposable
|
||||||
var warmupFrames = isCorner ? 2 : _config.WarmupFrames;
|
var warmupFrames = isCorner ? 2 : _config.WarmupFrames;
|
||||||
var needsBootstrap = _frameCount <= warmupFrames || _consecutiveMatchFails >= 30;
|
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)
|
// Block-based noise filter: only needed for overlay (game effects bleed through)
|
||||||
if (!isCorner)
|
if (!isCorner)
|
||||||
{
|
{
|
||||||
|
|
@ -147,10 +151,17 @@ public class WorldMap : IDisposable
|
||||||
// Check if canvas has enough walls to match against
|
// Check if canvas has enough walls to match against
|
||||||
var canvasWallCount = Cv2.CountNonZero(canvasWalls);
|
var canvasWallCount = Cv2.CountNonZero(canvasWalls);
|
||||||
var frameWallCount = Cv2.CountNonZero(wallMask);
|
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)
|
if (canvasWallCount < 50)
|
||||||
{
|
{
|
||||||
Log.Information("Match fail: too few canvas walls ({CanvasWalls}) frame walls={FrameWalls}",
|
Log.Information("Match fail: too few canvas walls ({CanvasWalls}) frame walls={FrameWalls} frameSize={FS} searchROI={SW}x{SH}",
|
||||||
canvasWallCount, frameWallCount);
|
canvasWallCount, frameWallCount, frameSize, sw, sh);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,8 +172,8 @@ public class WorldMap : IDisposable
|
||||||
|
|
||||||
if (maxVal < _config.MatchConfidence)
|
if (maxVal < _config.MatchConfidence)
|
||||||
{
|
{
|
||||||
Log.Information("Match fail: low confidence {Conf:F3} (need {Min:F2}) canvas={CanvasWalls} frame={FrameWalls}",
|
Log.Information("Match fail: low confidence {Conf:F3} (need {Min:F2}) frameSize={FS} searchROI={SW}x{SH} canvas={CanvasWalls} frame={FrameWalls}",
|
||||||
maxVal, _config.MatchConfidence, canvasWallCount, frameWallCount);
|
maxVal, _config.MatchConfidence, frameSize, sw, sh, canvasWallCount, frameWallCount);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,8 +182,10 @@ public class WorldMap : IDisposable
|
||||||
var matchX = sx0 + maxLoc.X + frameSize / 2.0;
|
var matchX = sx0 + maxLoc.X + frameSize / 2.0;
|
||||||
var matchY = sy0 + maxLoc.Y + 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}",
|
var deltaX = matchX - estimate.X;
|
||||||
maxVal, matchX, matchY, canvasWallCount, frameWallCount);
|
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);
|
return new MapPosition(matchX, matchY);
|
||||||
}
|
}
|
||||||
|
|
@ -511,6 +524,9 @@ public class WorldMap : IDisposable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Rebootstrap()
|
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?.Dispose();
|
||||||
_prevWallMask = null;
|
_prevWallMask = null;
|
||||||
// Don't reset _frameCount or _consecutiveMatchFails —
|
// Don't reset _frameCount or _consecutiveMatchFails —
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue