public void combineTessDatamethod() { if (!Directory.Exists(projectFolder + @"\Tessdata")) { Directory.CreateDirectory(projectFolder + @"\Tessdata"); } if (File.Exists(projectFolder + @"\word-list")) { TesseractExecutor.cmdExcute("wordlist2dawg.exe", " word-list " + Configuration.IsoLang + ".word-dawg " + Configuration.IsoLang + ".unicharset ", projectFolder); } if (File.Exists(projectFolder + @"\unambig-dawg")) { TesseractExecutor.cmdExcute("wordlist2dawg.exe", " unambig-dawg " + Configuration.IsoLang + ".unicharambigs " + Configuration.IsoLang + ".unicharset ", projectFolder); } if (File.Exists(projectFolder + @"\freq-dawg")) { TesseractExecutor.cmdExcute("wordlist2dawg.exe", " freq-dawg " + Configuration.IsoLang + ".freq-dawg " + Configuration.IsoLang + ".unicharset ", projectFolder); } try { File.Copy(projectFolder + @"\inttemp", projectFolder + '\\' + Configuration.IsoLang + @".inttemp", true); File.Copy(projectFolder + @"\shapetable", projectFolder + '\\' + Configuration.IsoLang + @".shapetable", true); File.Copy(projectFolder + @"\normproto", projectFolder + '\\' + Configuration.IsoLang + @".normproto", true); File.Copy(projectFolder + @"\pffmtable", projectFolder + '\\' + Configuration.IsoLang + @".pffmtable", true); TesseractExecutor.cmdExcute("combine_tessdata.exe", " " + Configuration.IsoLang + ".", projectFolder); } catch (IOException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { File.Copy(projectFolder + '\\' + Configuration.IsoLang + ".traineddata", projectFolder + @"\Tessdata\" + Configuration.IsoLang + @".traineddata", true); MessageBox.Show("Creation of Tessdata is Succesfull", "Completed Succesfully", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (IOException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void TrainTesseract() { foreach (var item in images) { if (File.Exists(projectFolder + '\\' + item.ToString().Substring(0, item.ToString().LastIndexOf('.')) + ".box")) { TesseractExecutor.cmdExcute(Configuration.TesseractName, " " + item + " " + item.ToString().Substring(0, item.ToString().LastIndexOf('.')) + " nobatch box.train", projectFolder); } else { MessageBox.Show("Box File is Missing", "Error Cannot continue excution"); return; } } string[] files = Directory.GetFiles(projectFolder); //Compute the Character Set string boxfilesingleline = null; string trfilessigleline = null; foreach (string item in files) { if (item.EndsWith(".box")) { boxfilesingleline += " " + item.Substring(item.LastIndexOf('\\') + 1) + " "; } if (item.EndsWith(".tr")) { trfilessigleline += " " + item.Substring(item.LastIndexOf('\\') + 1) + " "; } } TesseractExecutor.cmdExcute("unicharset_extractor.exe", boxfilesingleline, projectFolder); //Clustering TesseractExecutor.cmdExcute("shapeclustering.exe", " -F font_properties -U unicharset " + trfilessigleline, projectFolder); TesseractExecutor.cmdExcute("mftraining.exe", " -F font_properties -U unicharset -O " + Configuration.IsoLang + ".unicharset " + trfilessigleline, projectFolder); TesseractExecutor.cmdExcute("cntraining.exe", trfilessigleline, projectFolder); }
private void bootstrapnewchar(object sender, EventArgs e) { TesseractExecutor.cmdExcute(Configuration.TesseractName, " " + filename + " " + filename.Substring(0, filename.LastIndexOf('.')) + " -l " + Configuration.IsoLang + " batch.nochop makebox", projectFolder); }
private void createnewbox(object sender, EventArgs e) { TesseractExecutor.cmdExcute(Configuration.TesseractName, " " + filename + " " + filename.Substring(0, filename.LastIndexOf('.')) + " batch.nochop makebox", projectFolder); }
public string[] recognizeimage(string imagepath, string lang) { TesseractExecutor.cmdExcute(Configuration.TesseractName, " \"" + imagepath + "\" \"" + imagepath.Substring(0, imagepath.LastIndexOf('\\')) + "\\output\" -l " + lang, imagepath.Substring(0, imagepath.LastIndexOf('\\'))); return(File.ReadAllLines(imagepath.Substring(0, imagepath.LastIndexOf('\\')) + "\\output.txt", Encoding.UTF8)); }