OCR-Naive

 view release on metacpan or  search on metacpan

bin/ocr  view on Meta::CPAN

#!/usr/bin/perl
# $Id: ocr,v 1.6 2009/02/10 08:04:55 dk Exp $

use strict;
use subs qw(log);

BEGIN { 
	local @ARGV; 
	require Prima::noX11; 
	require Prima; 
}

use Getopt::Long;
use OCR::Naive qw(:all);

my ( 
	%options,
	$db, @sorted_glyphs,
	@curr_ext, @curr_pos, $curr_glyph, $curr_index, $curr_entry,
);

%options = (
	verbose  => 0,
	dict     => 'dict',
	help     => 0,
	screen   => 0,
	sleep    => undef,
	contrast => 128,
	minspace => undef,
);

GetOptions( \%options,
	'verbose',
	'help',
	'screen',
	'dict=s',
	'sleep=i',
	'contrast=i',
	'minspace=i',
) or usage();

usage() if $options{help};

my $needarg = $options{screen} ? 0 : 1;
$needarg == @ARGV or usage();

sub usage
{
	print <<USAGE;

$0 - OCR an image

options:
   --verbose        - be verbose
   --help           - show this text

   --dict=FILE      - load from dictionary FILE, save changes there
   --screen         - grab screen instead of loading image
   --sleep=SEC      - sleep SECONDS before grabbing from screen
   --contrast=INT   - minimal contrast (0-255) between assumed foreground 
                      and background. default: 128
   --minspace=INT   - minimal width in pixel for space. 
                      calculated automatically by default

USAGE
	exit 1;
}



( run in 2.266 seconds using v1.01-cache-2.11-cpan-1191d43216d )