/// <summary> /// Recognizes the character in the file of the given path. /// </summary> /// <param name="p">Path to a file with a character image.</param> /// <returns>The character in this image.</returns> public string recognise(string p) { // file path 2 array ArrayInputData aid = new ArrayInputData(DataManipulation.Bmp2Pattern(p), null); // use the network Matrix <float> result = mln.use(aid); return(Mat2String(result)); }
/// <summary> /// Loads images into an input pattern structure. /// </summary> /// <param name="p">list of StringInputData, containing the image path as Key and the represented character as Value.</param> public void loadTrainImages(List <StringInputData> p) { trainImages = p; trainData = new ArrayInputData(new DenseMatrix(patternSize, p.Count), new DenseMatrix(26, p.Count, 0)); Matrix <float> inputPattern; for (int img = 0; img < p.Count; img++) { inputPattern = DataManipulation.Bmp2Pattern(p[img].Key); trainData.Key.SetColumn(img, inputPattern.Column(0)); // Careful: only upper letters are covered so far!! trainData.Value.At(p[img].Value.ToUpper()[0] - 'A', img, 1.0f); } }