com.asprise.util.ocr
Class OCR

java.lang.Object
  extended bycom.asprise.util.ocr.OCR

public class OCR
extends java.lang.Object

A high performance Java OCR engine.

This OCR engine is capable of recognizing both characters (letter and numbers) and barcodes accurately.

Sample use:

  // loads the image.
  BufferedImage image = ImageIO.read(new File("ocr.gif")); 
 
  // recognizes both characters and barcodes
  String s = new OCR().recognizeAll(image);
 
  // prints the results.
  System.out.println("RESULTS: \n"+ s);
 

The input image document:

Results:

 [123456789012]
 Asprise OCR
 Speed. Accuracy.
 
Note: [123456789012] is extracted from the barcode.

For more information, please visit http://asprise.com.


Constructor Summary
OCR()
          Creates an instance of OCR engine.
 
Method Summary
static java.lang.String getLibraryPath()
          Gets the native library path.
 java.lang.String recognizeBarcode(java.awt.image.RenderedImage image)
          Recognizes a barcode from the specified image.
 java.util.Vector recognizeBarcodes(java.awt.image.RenderedImage image)
          Recognizes one or more barcode from the specified image.
 java.lang.String recognizeCharacters(java.awt.image.RenderedImage image)
          Recognizes characters (letters and numbers) from the specified image.
 java.lang.String recognizeEverything(java.awt.image.RenderedImage image)
          Recognizes characters and barcodes from the specified image.
 java.lang.String recognizeEverything(java.awt.image.RenderedImage image, java.lang.String barcodePrefix, java.lang.String barcodeSuffix)
          Recognizes characters and barcodes from the specified image.
static void setLibraryPath(java.lang.String libraryPath)
          Sets the native library path.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OCR

public OCR()
Creates an instance of OCR engine.

Method Detail

recognizeEverything

public java.lang.String recognizeEverything(java.awt.image.RenderedImage image)
Recognizes characters and barcodes from the specified image. The content of a recognized bar code will be enclosed in a '[]' pair. If you need customize the prefix and suffix for barcodes, use the other function with the same name.

Parameters:
image -
Returns:
See Also:
recognizeEverything(RenderedImage, String, String)

recognizeEverything

public java.lang.String recognizeEverything(java.awt.image.RenderedImage image,
                                            java.lang.String barcodePrefix,
                                            java.lang.String barcodeSuffix)
Recognizes characters and barcodes from the specified image. This function allows you to customize the prefix and suffix for recognized barcodes.

Parameters:
image -
barcodePrefix -
barcodeSuffix -
Returns:

recognizeCharacters

public java.lang.String recognizeCharacters(java.awt.image.RenderedImage image)
Recognizes characters (letters and numbers) from the specified image.

Parameters:
image -
Returns:
the recoginized characters in a string.

recognizeBarcode

public java.lang.String recognizeBarcode(java.awt.image.RenderedImage image)
Recognizes a barcode from the specified image. If there is more than one barcode, only the first barcode will be recognized. If you need to recognize more than one, you should use recognizeBarcodes.

Parameters:
image -
Returns:
See Also:
recognizeBarcodes(RenderedImage)

recognizeBarcodes

public java.util.Vector recognizeBarcodes(java.awt.image.RenderedImage image)
Recognizes one or more barcode from the specified image. For your convenience, if there is only one barcode on the image or you only want the first one, you can use recognizeBarcode.

Parameters:
image -
Returns:
the recognized barcode content in a vector.
See Also:
recognizeBarcode(RenderedImage)

setLibraryPath

public static void setLibraryPath(java.lang.String libraryPath)
Sets the native library path. The default library path is null, in which case the system will load the native library from default locations, such as system directory.

Parameters:
libraryPath - path of the native library to be loaded; set to null to let the system load the library by automatic search.

getLibraryPath

public static java.lang.String getLibraryPath()
Gets the native library path.

Returns:
the library path. null if no library path has been set yet.