/// <summary> /// Make the training file /// </summary> /// <param name="filename">output filename</param> private void makeTraining(string filename) { DefinitionImage di; System.IO.StreamWriter sw = new System.IO.StreamWriter(filename); List <string> file = new List <string>(1); file.Add(""); int i, j, cat, len2, len = m_trainingFiles.Count; //Go through the different symbol names for (i = 0; i < len; ++i) { //Go through all of the specific symbols if (m_trainingFiles[i] == null) { Console.WriteLine("There were no training files at index {0}", i); continue; } len2 = m_trainingFiles[i].Count; for (j = 0; j < len2; ++j) { file[0] = m_trainingFiles[i][j]; di = new DefinitionImage(m_width, m_height, file); di.Main.writeToBitmap(file[0] + ".bmp"); sw = write(di, i + 1, sw); sw.WriteLine(); } } sw.Close(); }
/// <summary> /// Load definition images /// </summary> private void loadDefinitions() { DefinitionImage di; int i, len = m_symbols.Count;// m_definitionFiles.Count; m_defs = new List <DefinitionImage>(len); for (i = 0; i < len; ++i) { //should be normalized already :) di = new DefinitionImage(m_width, m_height, m_symbols[i] + ".amat"); m_defs.Add(di); //use this so we can rotate and recognize the training DefinitionImage.AddMatch(di); } }
/// <summary> /// Creates the average image /// </summary> /// <returns>Definition Image / Average image</returns> public DefinitionImage getDefinition() { di = new DefinitionImage(m_width, m_height, m_files); return(di); }
/// <summary> /// Write out to the stream /// </summary> /// <param name="di">Image to write</param> /// <param name="category">Training index</param> /// <param name="sw">Stream to write to</param> /// <returns>New place in stream</returns> private System.IO.StreamWriter write(DefinitionImage di, int category, System.IO.StreamWriter sw) { return(write(di.toNodes(), category, sw)); }