Menu

doOCR() conflict with Android target

JB Data31
2019-07-11
2019-07-11
  • JB Data31

    JB Data31 - 2019-07-11

    Hi,

    I want to use tess4j in an Androïd app.
    I test a simple snippet, works fine in Linux env, but fails in Androïd env.

    File imageFile = new File("...");
    ITesseract instance = new Tesseract();
    instance.setDatapath("...");
    ...
    try {
    String result = instance.doOCR(imageFile);
    System.out.println(result);
    }
    catch (TesseractException e) {
    System.err.println(e.getMessage());
    }

    Androïd needs to target JDK 1.8 and then there's a compile error:
    error: cannot access BufferedImage
    class file for java.awt.image.BufferedImage not found

    In the ITesseract there are methods doOCR() with input java.awt.image.BufferedImage parameter.
    Tess4j would be very usefull for an Androïd use of tesseract, but "linking" with awt prevents that.

    Is there a workaround to avoid such an issue ?

    Is there a way to use doOCR() with stream, such as FileInputStream or InputStream ?

    Help appriciate.

     
  • Quan Nguyen

    Quan Nguyen - 2019-07-11

    BufferedImage class is not supported on Android platform. Android API does not include the java.awt.image package.

    Try tess-two for OCR development on Android.

     

Log in to post a comment.