public void Recognize(double[] Input, RecognizeModel recognizeModel) { int i, j; double total = 0.0; double max = -1; //Apply input to the network for (i = 0; i < _preInputNum; i++) { _preInputLayer[i].Value = Input[i]; } //Calculate Input Layer's Inputs and Outputs for (i = 0; i < _inputNum; i++) { total = 0.0; for (j = 0; j < _preInputNum; j++) { total += _preInputLayer[j].Value * _preInputLayer[j].Weights[i]; } _inputLayer[i].InputSum = total; _inputLayer[i].Output = F(total); } //Find the [Two] Highest Outputs List <string> tempCharName = new List <string>(); //temp List <double> tempError = new List <double>(); //temp for (i = 0; i < _outputNum; i++) { total = 0.0; for (j = 0; j < _inputNum; j++) { total += _inputLayer[j].Output * _inputLayer[j].Weights[i]; } _outputLayer[i].InputSum = total; _outputLayer[i].output = F(total); tempCharName.Add(_outputLayer[i].Value); //temp tempError.Add(1 - _outputLayer[i].output); //temp if (_outputLayer[i].output > max) { recognizeModel.MatchedLow = recognizeModel.MatchedHigh; recognizeModel.OutputLowValue = max; max = _outputLayer[i].output; recognizeModel.MatchedHigh = _outputLayer[i].Value; recognizeModel.OutputHightValue = max; } } //temp foreach (var name in tempCharName) { Console.WriteLine(name); } foreach (var error in tempError) { Console.WriteLine(error); } //temp }
private void StartRecognize(Bitmap character) { _recognizeModel = new RecognizeModel { MatchedHigh = "?", MatchedLow = "?" }; double[] input = ImageProcessing.ToMatrix(character, _settings.SettingsModel.AverageImageHeight, _settings.SettingsModel.AverageImageWidth); _initializeNetwork.NeuralNetwork.Recognize(input, _recognizeModel); if (_recognizeModel.OutputHightValue > 0.1) { _viewModel.MatchedHightValue = _recognizeModel.MatchedHigh; _viewModel.MatchedLowValue = _recognizeModel.MatchedLow; _viewModel.MatchedHightPercent = Convert.ToInt32((100 * _recognizeModel.OutputHightValue)).ToString() + " %"; _viewModel.MatchedLowPercent = Convert.ToInt32((100 * _recognizeModel.OutputLowValue)).ToString() + " %"; _viewModel.LogTextBox += String.Format("Rozpoznano literę {0} - {1}, Drugie miejsce litera {2} - {3}\n", _viewModel.MatchedHightValue, _viewModel.MatchedHightPercent, _viewModel.MatchedLowValue, _viewModel.MatchedLowPercent); _licencePlate += _viewModel.MatchedHightValue; _loosedLicencePlate += _viewModel.MatchedLowValue; } }
public void Recognize(double[] Input, RecognizeModel recognizeModel) { _neuralNet.Recognize(Input, recognizeModel); }