faster minimap load
This commit is contained in:
parent
d7948fd4a7
commit
a3001e36e4
2 changed files with 16 additions and 9 deletions
|
|
@ -10,7 +10,7 @@ public class MinimapCapture : IFrameConsumer, IDisposable
|
||||||
private readonly MinimapConfig _config;
|
private readonly MinimapConfig _config;
|
||||||
private readonly WallColorTracker _colorTracker;
|
private readonly WallColorTracker _colorTracker;
|
||||||
private readonly IScreenCapture _backend; // kept for debug capture paths
|
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 MinimapMode _detectedMode = MinimapMode.Overlay;
|
||||||
private MinimapFrame? _lastFrame;
|
private MinimapFrame? _lastFrame;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,14 @@ public class WorldMap : IDisposable
|
||||||
_frameCount, mode, wallMask.Width, wallMask.Height,
|
_frameCount, mode, wallMask.Width, wallMask.Height,
|
||||||
_position.X, _position.Y, needsBootstrap, _prevWallMask != null);
|
_position.X, _position.Y, needsBootstrap, _prevWallMask != null);
|
||||||
|
|
||||||
|
var wallCountBefore = Cv2.CountNonZero(wallMask);
|
||||||
|
|
||||||
// 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)
|
// Skip during warmup — we need walls to seed the canvas, confidence handles noise
|
||||||
|
if (!isCorner && !needsBootstrap)
|
||||||
{
|
{
|
||||||
var cleanFraction = FilterNoisyBlocks(wallMask, classifiedMat);
|
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)",
|
Log.Information("Noise filter: {Clean:P0} clean, skipping ({Ms:F1}ms)",
|
||||||
cleanFraction, sw.Elapsed.TotalMilliseconds);
|
cleanFraction, sw.Elapsed.TotalMilliseconds);
|
||||||
|
|
@ -54,8 +57,10 @@ public class WorldMap : IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Frame deduplication: skip if minimap hasn't scrolled yet
|
var wallCountAfter = Cv2.CountNonZero(wallMask);
|
||||||
if (_prevWallMask != null && _frameCount > 1)
|
|
||||||
|
// 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();
|
using var xor = new Mat();
|
||||||
Cv2.BitwiseXor(wallMask, _prevWallMask, xor);
|
Cv2.BitwiseXor(wallMask, _prevWallMask, xor);
|
||||||
|
|
@ -86,8 +91,9 @@ public class WorldMap : IDisposable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Information("Warmup frame {N}/{Total}: stitch={Ms:F1}ms",
|
Log.Information("Warmup frame {N}/{Total}: walls={WallsBefore}→{WallsAfter}(filtered) frameSize={FS} stitch={Ms:F1}ms",
|
||||||
_frameCount, _config.WarmupFrames, sw.Elapsed.TotalMilliseconds);
|
_frameCount, _config.WarmupFrames, wallCountBefore, wallCountAfter,
|
||||||
|
wallMask.Width, sw.Elapsed.TotalMilliseconds);
|
||||||
}
|
}
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
|
|
@ -529,8 +535,9 @@ public class WorldMap : IDisposable
|
||||||
_prevWallMask != null ? $"{_prevWallMask.Width}x{_prevWallMask.Height}" : "null");
|
_prevWallMask != null ? $"{_prevWallMask.Width}x{_prevWallMask.Height}" : "null");
|
||||||
_prevWallMask?.Dispose();
|
_prevWallMask?.Dispose();
|
||||||
_prevWallMask = null;
|
_prevWallMask = null;
|
||||||
// Don't reset _frameCount or _consecutiveMatchFails —
|
// Force one re-bootstrap stitch so the new mode seeds walls on the canvas.
|
||||||
// template matching continues seamlessly with the new frame size
|
// This triggers needsBootstrap=true (>= 30), skips dedup, stitches boosted.
|
||||||
|
_consecutiveMatchFails = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue