From a3001e36e48d4490e75d6f96e12c896829ea6fb4 Mon Sep 17 00:00:00 2001 From: Boki Date: Sun, 15 Feb 2026 11:22:20 -0500 Subject: [PATCH] faster minimap load --- src/Poe2Trade.Navigation/MinimapCapture.cs | 2 +- src/Poe2Trade.Navigation/WorldMap.cs | 23 ++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Poe2Trade.Navigation/MinimapCapture.cs b/src/Poe2Trade.Navigation/MinimapCapture.cs index 82c216c..97ec652 100644 --- a/src/Poe2Trade.Navigation/MinimapCapture.cs +++ b/src/Poe2Trade.Navigation/MinimapCapture.cs @@ -10,7 +10,7 @@ public class MinimapCapture : IFrameConsumer, IDisposable private readonly MinimapConfig _config; private readonly WallColorTracker _colorTracker; private readonly IScreenCapture _backend; // kept for debug capture paths - private int _modeCheckCounter; + private int _modeCheckCounter = 9; // trigger mode detection on first frame private MinimapMode _detectedMode = MinimapMode.Overlay; private MinimapFrame? _lastFrame; diff --git a/src/Poe2Trade.Navigation/WorldMap.cs b/src/Poe2Trade.Navigation/WorldMap.cs index 5d21465..7d9018f 100644 --- a/src/Poe2Trade.Navigation/WorldMap.cs +++ b/src/Poe2Trade.Navigation/WorldMap.cs @@ -42,11 +42,14 @@ public class WorldMap : IDisposable _frameCount, mode, wallMask.Width, wallMask.Height, _position.X, _position.Y, needsBootstrap, _prevWallMask != null); + var wallCountBefore = Cv2.CountNonZero(wallMask); + // Block-based noise filter: only needed for overlay (game effects bleed through) - if (!isCorner) + // Skip during warmup — we need walls to seed the canvas, confidence handles noise + if (!isCorner && !needsBootstrap) { var cleanFraction = FilterNoisyBlocks(wallMask, classifiedMat); - if (cleanFraction < 0.25 && !needsBootstrap) + if (cleanFraction < 0.25) { Log.Information("Noise filter: {Clean:P0} clean, skipping ({Ms:F1}ms)", cleanFraction, sw.Elapsed.TotalMilliseconds); @@ -54,8 +57,10 @@ public class WorldMap : IDisposable } } - // Frame deduplication: skip if minimap hasn't scrolled yet - if (_prevWallMask != null && _frameCount > 1) + var wallCountAfter = Cv2.CountNonZero(wallMask); + + // Frame deduplication: skip if minimap hasn't scrolled yet (but always allow warmup through) + if (!needsBootstrap && _prevWallMask != null && _frameCount > 1) { using var xor = new Mat(); Cv2.BitwiseXor(wallMask, _prevWallMask, xor); @@ -86,8 +91,9 @@ public class WorldMap : IDisposable } else { - Log.Information("Warmup frame {N}/{Total}: stitch={Ms:F1}ms", - _frameCount, _config.WarmupFrames, sw.Elapsed.TotalMilliseconds); + Log.Information("Warmup frame {N}/{Total}: walls={WallsBefore}→{WallsAfter}(filtered) frameSize={FS} stitch={Ms:F1}ms", + _frameCount, _config.WarmupFrames, wallCountBefore, wallCountAfter, + wallMask.Width, sw.Elapsed.TotalMilliseconds); } return _position; } @@ -529,8 +535,9 @@ public class WorldMap : IDisposable _prevWallMask != null ? $"{_prevWallMask.Width}x{_prevWallMask.Height}" : "null"); _prevWallMask?.Dispose(); _prevWallMask = null; - // Don't reset _frameCount or _consecutiveMatchFails — - // template matching continues seamlessly with the new frame size + // Force one re-bootstrap stitch so the new mode seeds walls on the canvas. + // This triggers needsBootstrap=true (>= 30), skips dedup, stitches boosted. + _consecutiveMatchFails = 30; } public void Dispose()