private void DrawMap(Map map) { DrawBorder(map); DrawCar(map); DrawParking(map); DrawObstacles(map); Canvas_trackPlanner.UpdateLayout(); }
void glyphRecogniser_frameProcessed(object sender, GlyphRecognitionStudio.MainForm.FrameData frameData) { baseImage = frameData.getImage(); this.Dispatcher.Invoke(new Action(() => image_baseImagePicker.Source = loadBitmap(baseImage))); if (waitingForNextBaseImage) { map = mapBuilder.BuildMap(baseImage, frameData.getGlyphs()); if (map != null) { this.Dispatcher.Invoke(new Action(() => TextBlock_marksInfo.Text = map.ToString())); this.Dispatcher.Invoke(new Action(() => DrawMap(map))); this.Dispatcher.Invoke(new Action(() => plannerBackGround.Source = loadBitmap(baseImage))); this.Dispatcher.Invoke(new Action(() => Canvas_trackPlanner.UpdateLayout())); } else { this.Dispatcher.Invoke(new Action(() => TextBlock_marksInfo.Text = "Map couldn't be build basing on current image!")); } //waitingForNextBaseImage = false; Console.WriteLine("New base frame acquired!"); } else { if (map != null) { mapBuilder.UpdateCarPosition(map, frameData.getGlyphs()); this.Dispatcher.Invoke(new Action(() => DrawMap(map))); Console.WriteLine("Car position updated!"); if (carUnderDriving) { CarSteering carSteering = carDriver.CalculateCarSteering(map); this.Dispatcher.Invoke(new Action(() => TextBlock_CarSteeringInformations.Text = carSteering.ToString())); carController.SetTargetSpeed(carSteering.speed); carController.SetTargetWheelAngle(carSteering.angle); carController.OverrideTargetBrakeSetting(carSteering.brake); } } } }