public static void UpdateMinimap(CurrentGameState state)
{
TickNow();
// if (heroPoints[0].Count == 0) return;
var src = GrabScreenGDI(state.GameMode.MinimapRectangle);
//var thresholded = ThresholdCropBitmap(src, new Rectangle(1450, 775, 450, 350), 200);
var sourceImage = ChangePixelFormat(src, PixelFormat.Format24bppRgb);
src.Dispose();
Tools.ColorFilter.Red = new IntRange(180, 255);
Tools.ColorFilter.Green = new IntRange(180, 255);
Tools.ColorFilter.Blue = new IntRange(180, 255);
Tools.ColorFilter.ApplyInPlace(sourceImage);
var grayScale = Grayscale.CommonAlgorithms.BT709.Apply(sourceImage);
Tools.Thresholder.ThresholdValue = 1;
Tools.Thresholder.ApplyInPlace(grayScale);
var thresholded = Tools.GSToRgb.Apply(grayScale);
var bc = new BlobCounter();
bc.ProcessImage(thresholded);
var blobs = bc.GetObjectsInformation().ToList();
var debugPoints = new List<System.Drawing.Point>();
try
{
blobs = blobs.Where(o => o.Rectangle.Width > 3 && o.Rectangle.Width < 7
&& o.Rectangle.Height > 3 && o.Rectangle.Height < 7).ToList();
Point? cam = null;
Point[] cams = {new Point()};
for (var j = 0; j < blobs.Count; j++)
{
cam = FindCamera(blobs[j].CenterOfGravity, blobs);
if (cam != null)
{
break;
}
}
if (cam.HasValue)
state.Me.HeroMinimapPosition =
new System.Drawing.Point((int) (cam.Value.X + state.GameMode.MinimapRectangle.X),
(int) (cam.Value.Y + state.GameMode.MinimapRectangle.Y));
}
catch (Exception e)
{
}
src.Dispose();
sourceImage.Dispose();
MainWindow.DebugReaderStats("Minimap:" + TickNow());
//DebugFountainShenaningans(state, debugPoints);
}