public string[] recognizeimage(string imagepath, string lang) { ShellExcutor sh = new ShellExcutor(); sh.cmdExcute("tesseract.exe", ShellExcutor.tesseractlocation, " \"" + 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)); }
public void combineTessDatamethod() { if (!Directory.Exists(projectFolder + @"\Tessdata")) { Directory.CreateDirectory(projectFolder + @"\Tessdata"); } ShellExcutor sh = new ShellExcutor(); if (File.Exists(projectFolder + @"\word-list")) { sh.cmdExcute("wordlist2dawg.exe", ShellExcutor.tesseractlocation, " word-list " + ShellExcutor.isolang + ".word-dawg " + ShellExcutor.isolang + ".unicharset ", projectFolder); } if (File.Exists(projectFolder + @"\unambig-dawg")) { sh.cmdExcute("wordlist2dawg.exe", ShellExcutor.tesseractlocation, " unambig-dawg " + ShellExcutor.isolang + ".unicharambigs " + ShellExcutor.isolang + ".unicharset ", projectFolder); } if (File.Exists(projectFolder + @"\freq-dawg")) { sh.cmdExcute("wordlist2dawg.exe", ShellExcutor.tesseractlocation, " freq-dawg " + ShellExcutor.isolang + ".freq-dawg " + ShellExcutor.isolang + ".unicharset ", projectFolder); } try { File.Copy(projectFolder + @"\inttemp", projectFolder + '\\' + ShellExcutor.isolang + @".inttemp", true); File.Copy(projectFolder + @"\shapetable", projectFolder + '\\' + ShellExcutor.isolang + @".shapetable", true); File.Copy(projectFolder + @"\normproto", projectFolder + '\\' + ShellExcutor.isolang + @".normproto", true); File.Copy(projectFolder + @"\pffmtable", projectFolder + '\\' + ShellExcutor.isolang + @".pffmtable", true); sh.cmdExcute("combine_tessdata.exe", ShellExcutor.tesseractlocation, " " + ShellExcutor.isolang + ".", projectFolder); } catch (IOException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { File.Copy(projectFolder + '\\' + ShellExcutor.isolang + ".traineddata", projectFolder + @"\Tessdata\" + ShellExcutor.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() { ShellExcutor sh = new ShellExcutor(); foreach (var item in images) { if (File.Exists(projectFolder + '\\' + item.ToString().Substring(0, item.ToString().LastIndexOf('.')) + ".box")) { sh.cmdExcute("tesseract.exe", ShellExcutor.tesseractlocation, " " + 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) + " "; } } sh.cmdExcute("unicharset_extractor.exe", ShellExcutor.tesseractlocation, boxfilesingleline, projectFolder); //Clustering sh.cmdExcute("shapeclustering.exe", ShellExcutor.tesseractlocation, " -F font_properties -U unicharset " + trfilessigleline, projectFolder); sh.cmdExcute("mftraining.exe", ShellExcutor.tesseractlocation, " -F font_properties -U unicharset -O " + ShellExcutor.isolang + ".unicharset " + trfilessigleline, projectFolder); sh.cmdExcute("cntraining.exe", ShellExcutor.tesseractlocation, trfilessigleline, projectFolder); }
public string[] recognizeimage(string imagepath,string lang) { ShellExcutor sh = new ShellExcutor(); sh.cmdExcute("tesseract.exe",ShellExcutor.tesseractlocation," \""+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)); }
public void combineTessDatamethod() { if (!Directory.Exists(projectFolder + @"\Tessdata")) { Directory.CreateDirectory(projectFolder + @"\Tessdata"); } ShellExcutor sh = new ShellExcutor(); if (File.Exists(projectFolder+@"\word-list")) { sh.cmdExcute("wordlist2dawg.exe", ShellExcutor.tesseractlocation, " word-list " + ShellExcutor.isolang + ".word-dawg " + ShellExcutor.isolang + ".unicharset ", projectFolder); } if (File.Exists(projectFolder + @"\unambig-dawg")) { sh.cmdExcute("wordlist2dawg.exe", ShellExcutor.tesseractlocation, " unambig-dawg " + ShellExcutor.isolang + ".unicharambigs " + ShellExcutor.isolang + ".unicharset ", projectFolder); } if (File.Exists(projectFolder + @"\freq-dawg")) { sh.cmdExcute("wordlist2dawg.exe", ShellExcutor.tesseractlocation, " freq-dawg " + ShellExcutor.isolang + ".freq-dawg " + ShellExcutor.isolang + ".unicharset ", projectFolder); } try { File.Copy(projectFolder + @"\inttemp", projectFolder + '\\' + ShellExcutor.isolang + @".inttemp",true); File.Copy(projectFolder + @"\shapetable", projectFolder + '\\' + ShellExcutor.isolang + @".shapetable",true); File.Copy(projectFolder + @"\normproto", projectFolder + '\\' + ShellExcutor.isolang + @".normproto",true); File.Copy(projectFolder + @"\pffmtable", projectFolder + '\\' + ShellExcutor.isolang + @".pffmtable",true); sh.cmdExcute("combine_tessdata.exe", ShellExcutor.tesseractlocation, " " + ShellExcutor.isolang + ".",projectFolder); } catch (IOException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { File.Copy(projectFolder + '\\' + ShellExcutor.isolang + ".traineddata", projectFolder + @"\Tessdata\" + ShellExcutor.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() { ShellExcutor sh = new ShellExcutor(); foreach (var item in images) { if (File.Exists(projectFolder+'\\'+item.ToString().Substring(0,item.ToString().LastIndexOf('.'))+".box")) { sh.cmdExcute("tesseract.exe", ShellExcutor.tesseractlocation," "+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) + " "; } } sh.cmdExcute("unicharset_extractor.exe", ShellExcutor.tesseractlocation, boxfilesingleline, projectFolder); //Clustering sh.cmdExcute("shapeclustering.exe", ShellExcutor.tesseractlocation, " -F font_properties -U unicharset " + trfilessigleline, projectFolder); sh.cmdExcute("mftraining.exe", ShellExcutor.tesseractlocation, " -F font_properties -U unicharset -O " + ShellExcutor.isolang + ".unicharset " + trfilessigleline, projectFolder); sh.cmdExcute("cntraining.exe", ShellExcutor.tesseractlocation, trfilessigleline, projectFolder); }