I'm trying to run the following command
tesseract test10.png text -l nor
using Java's
Runtime.getRuntime().exec()
command.
It is working when using, the simple "cmd /c dir" command, but I can not figure out the correct syntax/way to use the command.
Please help!
do you use exec(String cmd) or exec(String[] cmd)?
sometimes I had problems with the first one, though I can't tell, what went wrong
if you exec "tesseract test10.png text -l nor" then try out "cmd /C \\"tesseract test10.png text -l nor\\"" (and the same as String[]) maybe some of these work
This works:
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:\\Path_to_tesseract\\tesseract.exe D:\\image.png D:\\outputFile");
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line=null;
while((line=input.readLine()) != null) {
System.out.println(line);
}
int exitVal = pr.waitFor();
System.out.println("Exited with error code "+exitVal);
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.