NAME

Finance::MICR::GOCR::Check - scan a check scan image file for a valid micr line

SYNOPSIS

	use Finance::MICR::Check;

	my $c = new Finance::MICR::GOCR::Check({ abs_check => '/path/to/check_CHECK.png });

   $c->found_valid;

DESCRIPTION

This object oriented module scans a check for a valid micr line.

The present status is pre release.

PREPPING

It can prep a check if it's turned 90 degrees right (batch scan in Canon scanners produce that).

SCAN ITERATIONS

The way the module works, after copying the target file to a temp directory, it creates smaller image excerpts from the bottom up and feeds it to Finance::MICR::GOCR , tests for validity with Finance::MICR::LineParser.

When a valid match is found it stops. See "SCAN ITERATION METHODS".

METHODS

The main methods you will likely be using are new() and parser(). The other methods are called internally, or can be called to tweak the process.

new()

abs_check

The absolute path to the check file

These are defaults:

CHECK_height => 738, # pixels tall
MICR_heigh => 78, # pixels tall

Your check images do not need to be exactly 738 pixels tall. MICR_height is the height of each iteration when we isolate parts of the check image to find the MICR line. I suggest you leave these alone. But you can set them via the constructor. The numbers are used to calculate ratios and dimensions.

These parameters are used for Finance::MICR::GOCR, but can be passed via the constructor

abs_path_gocrdb => $abs_path_gocrdb, # required
abs_gocr_bin => $abs_gocr_bin,
s => $s,
d => $d,

The only required parameter is abs_path_gocrdb To see more about these parameters, read Finance::MICR::GOCR

These parameters are used for Finance::MICR::LineParser, but can be passed via the constructor

Setting the symbols for Finance::MICR::LineParser, if you do not define these, they are set to these default values via this package:

on_us_symbol => 'CCc',
transit_symbol => 'Aa',
dash_symbol => 'DDd',
ammount_symbol => 'XxX',

If you do not want these symbols to default, and want to default to the Finance::MICR::LineParser symbols, you can set these yourself via the constructor. The included gocr db included in this package will work with those default symbols set by this package.

parser()

This is what you will do most interaction with. Returns Finance::MICR::LineParser object.

my $c = new Finance::MICR::GOCR::Check({ abs_check => '/path/to/check.png' });

my $check_number = $c->parser->check_number;

my $oruting_number = $c->parser->routing_number;

See Finance::MICR::LineParser

SCAN ITERATION METHODS

This calls to scan for a valid micrline inside the check image file provided as argument to constructor. Returns true or false depending on if the match was valid. If you want to know more.. you can call the parser.

Note that you don't need to call this subroutine directly. Calling the parser() will do the same.

The following methods trigger a scan if none was run: found_valid() rescan()

crop_sides()

Percentage to crop sides by when iterating, scanning up for MICR line default is fifteen percent number should be 0.15 for 15%

crop_iterations()

argument is number of iterations to do before giving up on searching for micrline scans.. starts from bottom.. does 5 pix increments. if no argumetn, returns number of iterations set. If you give 0, it switches to default, which is 12- max is 25

crop_increment()

argument is pixel increment per iteration if no argumetn, returns increment value If you give 0, it switches to default, which is 5 suggested is min 2, max 8

You must set these values BEFORE you ask for the micr from ocr

scan_iterations()

returns array ref of what the iterations are set at dafault are approximately:

70 75 80 85 90 95 100 105 110 115 120 130 140 150 160 170 180 190 200 210 220 230 240 250 300

That means the first image extract is the micr height from 70 pixels from the bottom, then 75, etc.. Until a valid micr line is found.

scan_iterations_reset()

will reset crop_sides, crop_increment, crop_iterations to default values.

found_valid()

will trigger a scan if none was already ran. returns boolean if at the last scan parser() returns true for parser->valid()

rescan()

If you want to change your parameters and rescan. returns boolean just like found_valid()

Example usage:

unless( $c->found_valid ){
	
	$c->s(70); # change the spacing for gocr
	$c->d(15); # change the dust size from default of 20 to 15
	
	$c->crop_increment(2); # set more precise iterations, default is 5 or so
	$c->crop_iterations(10); # set less iterations to happen

	$c->rescan;		

	if ($c->found_valid){
		printf STDERR "worked! found: %s\n", $c->parser->micr_pretty;
	}
	
}

abs_micr()

absolute path to micr file what was created. after the iterations, the one that closest matched is this file. This is useful to know if you want to build or increment the gocr database.

gocr_raw()

the raw ocr output for the micrfile that was last made, returns 'none' if none returned.

micr_height()

the height of the micr file, we try to make 70 80 90 100 110 120 130 and the first to match gets used.

im()

returns clone of image magick object that already read check image

REPORTING

save_report()

saves report in YAML format about the file this is saved as the abs check file appended with .report

report_filename()

returns filename of report

abs_report()

abs path to where report should be for this check

get_report()

get report text

CHECK PREPPING METHODS

A check file may be 90 degrees turned right or dimensions may be way off. This code helps that.

is_prepped()

returns boolean

prep_check()

argument is optionally abs path to check. will check that it is right side up and write over same path file name.

$c->prep_check;

$c->prep_check('/abs/path/to/check.png');

f()

returns check File::PathInfo object

my $c = new Finance::MICR::GOCR::Check({ abs_check => '/path/to/checkfile.png', abs_path_gocrdb =>'/path/to/my/micrdb' });

$c->f->abs_path;
$c->f->abs_loc;
$c->f->filename;
$c->f->mtime;

See File::PathInfo

set_check()

used internally argument is abs path to check file

CAVEATS

This is pre release.

BUGS

Yes. Please forward any concerns, suggestions, bugs to AUTHOR.

SEE ALSO

Finance::MICR::GOCR Finance::MICR::LineParser

AUTHOR

Leo Charre leocharre at cpan dot org