software.scanner
Class ScannedBallot

java.lang.Object
  extended by software.scanner.ScannedBallot
All Implemented Interfaces:
ScannedBallotInterface
Direct Known Subclasses:
ScannedBallot

public class ScannedBallot
extends java.lang.Object
implements ScannedBallotInterface

Each ballot has two alignment marks. One close to the upper left corner and the other close of the lower right corner. Each alignment mark is a non-white circle = two black circles. For starter, we assume that the the width of the image is the width of the ballot. We can compute the dpi having this assumption. How to correct for alignment:
Stept1:

Stept2: Once the alignment elements are computer: Step 3: Step 5:


Field Summary
static boolean debug
           
 
Constructor Summary
ScannedBallot(BallotGeometry geom, org.gwu.voting.standardFormat.electionSpecification.ElectionSpecification es)
          Initialises the scanned ballot with the Geometry and the ELection Spec
 
Method Summary
 void detect(java.awt.image.BufferedImage img)
          Given a scanned ballot, detects the votes and the serial number
 void detect(java.lang.String pdfFile)
          Deprecated. (the intention is to convert a pdf to an image)
 void detectFromPerfectImage(java.awt.image.BufferedImage img, double dpi)
           
 void detectMarksFormPerfectImage(java.awt.image.BufferedImage img, double dpi)
           
 void detectSerialFromPerfectImage(java.awt.image.BufferedImage img, double dpi)
          Tries to read the serial from whre it should on the top page, if unssucesful, tries to read the serial number from where it should be on the bottom page
 java.util.TreeMap<java.lang.Integer,java.util.TreeMap<java.lang.Integer,java.util.TreeMap<java.lang.Integer,software.scanner.ScannedBallot.TypeOfVotes>>> getAllContests()
           
 BallotGeometryMap getBallotGeometryMap()
           
 java.lang.String getCompactRepresentation()
          [T|B]serial space separated marked possitions.
 double getDpi()
           
 java.util.Vector<Cluster> getFullVotes()
           
 java.util.Vector<Cluster> getOverVotes()
           
 java.awt.image.BufferedImage getPerfectImage()
           
 Prow.ChosenPage getSelectedPage()
           
 java.lang.String getSerial()
           
 java.util.Vector<Cluster> getUnderVotes()
           
 java.util.Vector<Cluster> getVotes(software.scanner.ScannedBallot.TypeOfVotes vote)
           
 boolean isMailIn()
           
static void main(java.lang.String[] args)
           
 void setMailIn(boolean mailIn)
           
 Prow toProw()
           
 byte[] toXMLString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug
Constructor Detail

ScannedBallot

public ScannedBallot(BallotGeometry geom,
                     org.gwu.voting.standardFormat.electionSpecification.ElectionSpecification es)
Initialises the scanned ballot with the Geometry and the ELection Spec

Parameters:
geom -
es -
Method Detail

detectFromPerfectImage

public void detectFromPerfectImage(java.awt.image.BufferedImage img,
                                   double dpi)
                            throws java.lang.Exception
Parameters:
img - a perfectly aligned image
dpi - - the dpi of the image
Throws:
java.lang.Exception - - no Exception is caugth and no Exception is Explicitly thrown

detectMarksFormPerfectImage

public void detectMarksFormPerfectImage(java.awt.image.BufferedImage img,
                                        double dpi)

detectSerialFromPerfectImage

public void detectSerialFromPerfectImage(java.awt.image.BufferedImage img,
                                         double dpi)
                                  throws java.lang.Exception
Tries to read the serial from whre it should on the top page, if unssucesful, tries to read the serial number from where it should be on the bottom page

Parameters:
img -
dpi -
Throws:
java.lang.Exception

detect

public void detect(java.lang.String pdfFile)
Deprecated. (the intention is to convert a pdf to an image)

Parameters:
pdfFile -

detect

public void detect(java.awt.image.BufferedImage img)
            throws java.lang.Exception
Description copied from interface: ScannedBallotInterface
Given a scanned ballot, detects the votes and the serial number

Specified by:
detect in interface ScannedBallotInterface
Throws:
java.lang.Exception - - if the serial number cannot be properly read

toXMLString

public byte[] toXMLString()
Specified by:
toXMLString in interface ScannedBallotInterface
Returns:
the scanned ballot in xml format, accepted by the web server for uploading

getCompactRepresentation

public java.lang.String getCompactRepresentation()
Description copied from interface: ScannedBallotInterface
[T|B]serial space separated marked possitions. If a possition is not marked, -1 is used

Specified by:
getCompactRepresentation in interface ScannedBallotInterface
Returns:
a one line representation of the scanned ballot

toProw

public Prow toProw()
Specified by:
toProw in interface ScannedBallotInterface
Returns:
a scanned ballot in Prow representation

getSerial

public java.lang.String getSerial()
Specified by:
getSerial in interface ScannedBallotInterface

getFullVotes

public java.util.Vector<Cluster> getFullVotes()
Specified by:
getFullVotes in interface ScannedBallotInterface
Returns:
the correct marks (only) for the contest that are fully votes

getOverVotes

public java.util.Vector<Cluster> getOverVotes()
Specified by:
getOverVotes in interface ScannedBallotInterface
Returns:
the overvotes that appear on the ballot

getUnderVotes

public java.util.Vector<Cluster> getUnderVotes()
Specified by:
getUnderVotes in interface ScannedBallotInterface
Returns:
the correct marks (only) for the contest that are undervoted

getVotes

public java.util.Vector<Cluster> getVotes(software.scanner.ScannedBallot.TypeOfVotes vote)

getSelectedPage

public Prow.ChosenPage getSelectedPage()
Specified by:
getSelectedPage in interface ScannedBallotInterface
Returns:
the scanned page

getPerfectImage

public java.awt.image.BufferedImage getPerfectImage()
Specified by:
getPerfectImage in interface ScannedBallotInterface
Returns:
- the streighen image (perfectly aligned)

getDpi

public double getDpi()
Specified by:
getDpi in interface ScannedBallotInterface
Returns:
the dpi of the scanned image

getBallotGeometryMap

public BallotGeometryMap getBallotGeometryMap()
Specified by:
getBallotGeometryMap in interface ScannedBallotInterface

getAllContests

public java.util.TreeMap<java.lang.Integer,java.util.TreeMap<java.lang.Integer,java.util.TreeMap<java.lang.Integer,software.scanner.ScannedBallot.TypeOfVotes>>> getAllContests()
Specified by:
getAllContests in interface ScannedBallotInterface

isMailIn

public boolean isMailIn()
Specified by:
isMailIn in interface ScannedBallotInterface
Returns:
if the ballot commes from a mailed in ballot

setMailIn

public void setMailIn(boolean mailIn)
Specified by:
setMailIn in interface ScannedBallotInterface
Parameters:
mailIn - if a ballot is mailed in, the other page is marked as scanned (i.e. the the top page is scanned, bottom is recorded). This can be done because only the possitions are retained

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception