topcodes
Class Scanner

java.lang.Object
  extended by topcodes.Scanner

public class Scanner
extends java.lang.Object

Loads and scans images for TopCodes. The algorithm does a single sweep of an image (scanning one horizontal line at a time) looking for a pattern pattern: WHITE BLACK WHITE BLACK WHITE. If the pattern matches and the black and white regions meet certain ratio constraints, then the pixel is tested as the center of a candidate TopCode.

Version:
$Revision: 1.4 $, $Date: 2008/02/04 15:02:13 $
Author:
Michael Horn

Constructor Summary
Scanner()
          Default constructor
 
Method Summary
 java.awt.image.BufferedImage getImage()
          Returns the original (unaltered) image
 int getImageHeight()
          Returns the width in pixels of the current image (or zero if no image is loaded).
 int getImageWidth()
          Returns the width in pixels of the current image (or zero if no image is loaded).
 java.awt.image.BufferedImage getPreview()
          For debugging purposes, create a black and white image that shows the result of adaptive thresholding.
 java.util.List<TopCode> scan(java.awt.image.BufferedImage image)
          Scan the given image and return a list of all topcodes found in it.
 java.util.List<TopCode> scan(int[] rgb, int width, int height)
          Scan the image and return a list of all topcodes found in it.
 java.util.List<TopCode> scan(java.lang.String filename)
          Scan the given image file and return a list of topcodes found in it.
 void setMaxCodeDiameter(int diameter)
          Sets the maximum allowable diameter (in pixels) for a TopCode identified by the scanner.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner()
Default constructor

Method Detail

scan

public java.util.List<TopCode> scan(java.lang.String filename)
                             throws java.io.IOException
Scan the given image file and return a list of topcodes found in it.

Throws:
java.io.IOException

scan

public java.util.List<TopCode> scan(java.awt.image.BufferedImage image)
Scan the given image and return a list of all topcodes found in it.


scan

public java.util.List<TopCode> scan(int[] rgb,
                                    int width,
                                    int height)
Scan the image and return a list of all topcodes found in it.

Parameters:
rgb - an array of pixel data in packed RGB format
width - width of the image
height - height of the image

getImage

public java.awt.image.BufferedImage getImage()
Returns the original (unaltered) image


getImageWidth

public int getImageWidth()
Returns the width in pixels of the current image (or zero if no image is loaded).


getImageHeight

public int getImageHeight()
Returns the width in pixels of the current image (or zero if no image is loaded).


setMaxCodeDiameter

public void setMaxCodeDiameter(int diameter)
Sets the maximum allowable diameter (in pixels) for a TopCode identified by the scanner. Setting this to a reasonable value for your application will reduce false positives (recognizing codes that aren't actually there) and improve performance (because fewer candidate codes will be tested). Setting this value to as low as 50 or 60 pixels could be advisable for some applications. However, setting the maximum diameter too low will prevent valid codes from being recognized. The default value is 640 pixels.


getPreview

public java.awt.image.BufferedImage getPreview()
For debugging purposes, create a black and white image that shows the result of adaptive thresholding.