Wednesday, August 8, 2012

OCR process in java

 use apire libraries

1.1 About OCR
OCR (Optical Character Recognition) is the technology that allows you to transform
images (e.g., images scanned from paper documents) into editable text-based
computer files.

package com.jnet.ocr;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.asprise.util.ocr.OCR;

public class OCRMain {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        OCR.setLibraryPath("C:/WINDOWS/system/AspriseOCR.dll");
        BufferedImage image = ImageIO.read(new File("scanned-text-100dpi.jpg"));
        System.out.println("height" + image.getHeight());
        System.out.println("width" + image.getWidth());
        System.out.println("minx" + image.getMinX());
        System.out.println("minY" + image.getMinY());

        image = image.getSubimage(75, 250, 240, 20);

        // String s = new OCR().recognizeEverything(image);

        // recognizes both characters and barcodes
        String s = new OCR().recognizeEverything(image);

        // prints the results.
        System.out.println("RESULTS: \n" + s);

    }

}

1 comment:

  1. You deliver interesting post related to Java. You provide different tips related to coding. Thank you for sharing post with us. Further, The private investigators in Laguna Beach CA present the quality work as your desire requirements.

    ReplyDelete