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); } } } }
public void Initialize(int[] hiddenLayerSizes, Func <float, float> activationFunction, float raycastDistance, GameObject firstTrigger, Car oldCar = null) { // Initializes a NeuralNet if (oldCar == null) { int[] layerSizes = new int[hiddenLayerSizes.Length + 2]; layerSizes[0] = inputCount; hiddenLayerSizes.CopyTo(layerSizes, 1); layerSizes[layerSizes.Length - 1] = outputCount; nnet = new NeuralNet(layerSizes, activationFunction); } else { nnet = new NeuralNet(oldCar.nnet); } // Caches the CarSteering component steering = GetComponent <CarSteering>(); NextTrigger = firstTrigger; }
private void Start() { steering = car.GetComponent <CarSteering>(); }