Image verification code identification using asprise

  java, ocr

asprise-java-ocr-api

The built-in class libraries for windows, mac and linux platforms are in jar and can be loaded by themselves without additional operating system installation, thus being more portable.

maven

<!-- https://mvnrepository.com/artifact/com.asprise.ocr/java-ocr-api -->
        <dependency>
            <groupId>com.asprise.ocr</groupId>
            <artifactId>java-ocr-api</artifactId>
            <version>15.3.0.3</version>
        </dependency>

call

public static String recognize(BufferedImage image) {
        Ocr.setUp();
        Ocr ocr = new Ocr();
        ocr.startEngine("eng", Ocr.SPEED_FASTEST);
        String result = ocr.recognize(image,com.asprise.ocr.Ocr.RECOGNIZE_TYPE_ALL, com.asprise.ocr.Ocr.OUTPUT_FORMAT_PLAINTEXT,0,null);
        ocr.stopEngine();
        return result;
}

Ocr is not thread safe, so if multiple threads are used, each thread will have its own new instance.

test

        ClassLoader classLoader = getClass().getClassLoader();
        String path = classLoader.getResource("xxxx.jpg").getPath();
        BufferedImage img = ImageIO.read(new File(path));
        String result = recognize(img);
        System.out.println(result);

doc