software.scanner
Class SerialNoRecognizer

java.lang.Object
  extended by software.scanner.SerialNoRecognizer

public class SerialNoRecognizer
extends java.lang.Object

Given an image with a serial number on it (horizontally streigth), it tries to detect the serial number. Only the offwhite method is used...For each off whitecluster, the digit with the lower hamming distance from the definition is returned.

Author:
stefan

Field Summary
static int NOT_WHITE
           
static int OCR_ENGINE_GOCR
           
 
Constructor Summary
SerialNoRecognizer()
           
 
Method Summary
static void main(java.lang.String[] args)
          Debug method
 java.lang.String recognize(java.awt.image.BufferedImage bufferedImage, int typeOfRecognitionUsed, double dpi)
           
static java.lang.String recognizeGOCR(java.awt.image.BufferedImage bufferedImage)
          Deprecated. No recomented, GOCR seems to give poor results.
 java.lang.String recognizeNotWhite(java.awt.image.BufferedImage bi, double dpi)
          Given an image with a serial number on it (horizontally streigth), it tries to detect the serial number.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OCR_ENGINE_GOCR

public static int OCR_ENGINE_GOCR

NOT_WHITE

public static int NOT_WHITE
Constructor Detail

SerialNoRecognizer

public SerialNoRecognizer()
Method Detail

recognize

public java.lang.String recognize(java.awt.image.BufferedImage bufferedImage,
                                  int typeOfRecognitionUsed,
                                  double dpi)
                           throws java.lang.Exception
Throws:
java.lang.Exception

recognizeGOCR

public static java.lang.String recognizeGOCR(java.awt.image.BufferedImage bufferedImage)
                                      throws java.lang.Exception
Deprecated. No recomented, GOCR seems to give poor results.

Parameters:
bufferedImage -
Returns:
the serial number detected with GOCR
Throws:
java.lang.Exception

recognizeNotWhite

public java.lang.String recognizeNotWhite(java.awt.image.BufferedImage bi,
                                          double dpi)
                                   throws java.lang.Exception
Given an image with a serial number on it (horizontally streigth), it tries to detect the serial number. Only the offwhite method is used...For each off whitecluster, the digit with the lower hamming distance from the definition is returned. The algorithm is the folowing:
  1. detect an off white cluster Once detected the cluster, clip it and apply the following adaptive algorithm
    transform the cluster into a matrix of size the deffinition of the digit
    Find the color of the first pixel. 1=black, 0=white
    current = 1, new higher -> if the difference is > threshold, make the new 0, otherwise new=1
    current = 1, new lower -> make the new 1
    current = 0, new higher -> make new =0
    current = 0, new lower -> if the difference > threshold, make new=1, otherwise new=0
  2. once digitized, find the definition digit with the smallest hamming distance

Parameters:
bi - an image with a serial number on it (horizontally streigth)
Returns:
the serial number detected in the image
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Debug method

Parameters:
args -
Throws:
java.lang.Exception