added console

This commit is contained in:
Boki 2026-02-13 13:18:29 -05:00
parent bb8e75a2f5
commit dab5735c80
3 changed files with 45 additions and 3 deletions

View file

@ -1,3 +1,4 @@
using System.Diagnostics;
using OpenCvSharp;
using Serilog;
@ -28,6 +29,7 @@ public class WorldMap : IDisposable
/// </summary>
public MapPosition MatchAndStitch(Mat classifiedMat, Mat wallMask)
{
var sw = Stopwatch.StartNew();
_frameCount++;
// Frame deduplication: skip if minimap hasn't scrolled yet
@ -38,11 +40,14 @@ public class WorldMap : IDisposable
var changedPixels = Cv2.CountNonZero(xor);
if (changedPixels < _config.FrameChangeThreshold)
{
Log.Debug("Frame dedup: {Changed} changed pixels, skipping", changedPixels);
Log.Information("Frame dedup: {Changed} changed pixels, skipping ({Ms:F1}ms)",
changedPixels, sw.Elapsed.TotalMilliseconds);
return _position;
}
}
var dedupMs = sw.Elapsed.TotalMilliseconds;
// Store current wall mask for next frame's dedup check
_prevWallMask?.Dispose();
_prevWallMask = wallMask.Clone();
@ -51,16 +56,30 @@ public class WorldMap : IDisposable
if (_frameCount <= _config.WarmupFrames)
{
StitchWithConfidence(classifiedMat, _position, boosted: true);
Log.Information("Warmup frame {N}/{Total}: stitch={Ms:F1}ms",
_frameCount, _config.WarmupFrames, sw.Elapsed.TotalMilliseconds);
return _position;
}
// Match wallMask against canvas to find best position
var matchStart = sw.Elapsed.TotalMilliseconds;
var matched = MatchPosition(wallMask, _position);
var matchMs = sw.Elapsed.TotalMilliseconds - matchStart;
if (matched == null)
{
Log.Information("MatchAndStitch: dedup={Dedup:F1}ms match={Match:F1}ms (FAILED) total={Total:F1}ms",
dedupMs, matchMs, sw.Elapsed.TotalMilliseconds);
return _position; // skip stitching entirely on failed match
}
_position = matched;
var stitchStart = sw.Elapsed.TotalMilliseconds;
StitchWithConfidence(classifiedMat, _position, boosted: false);
var stitchMs = sw.Elapsed.TotalMilliseconds - stitchStart;
Log.Information("MatchAndStitch: dedup={Dedup:F1}ms match={Match:F1}ms stitch={Stitch:F1}ms total={Total:F1}ms",
dedupMs, matchMs, stitchMs, sw.Elapsed.TotalMilliseconds);
return _position;
}