1

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!

3

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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();
    }

Comments

0

Take a look at OCR.java file of VietOCR, which uses ProcessBuilder to invoke Tesseract executable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.