File: ocr-client.pl

package info (click to toggle)
emacspeak 29.0-9
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 12,904 kB
  • sloc: xml: 55,354; lisp: 48,335; cpp: 2,321; tcl: 1,500; makefile: 936; python: 836; sh: 785; perl: 459; ansic: 241
file content (35 lines) | stat: -rwxr-xr-x 1,055 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -w
#$Id: ocr-client.pl 5844 2008-08-25 19:22:23Z tv.raman.tv $
#Description: Invoke ocrxtr client. Pipe result to stdout
#Usage: ocr-client.pl image-file [hostname]
use strict;
use File::Temp qw(tempfile);
use File::Basename;

#my $OCR = 'ocrxtr';
my $OCR = 'xtrclilite';
my $image =shift;
die "No image specified" unless defined ($image);
my $host =shift;
my ($name,$path,$suffix) = fileparse($image,"\.tiff");
my ($in, $input)  = tempfile(suffix=>'.tiff');
my ($out, $output) = tempfile(suffix=>'.txt');
$host ='localhost' unless defined ($host);
if ( $host =~ m/localhost/) {
  #qx($OCR -out_text_name $output $image 2>/dev/null);
  qx($OCR $image $output 2>/dev/null);
  open (OUT, "cat -s $output |");
  while ( <OUT>) {
    print;
  }
  unlink $output;
} else {
  qx(scp $image  $host:$input);
  #qx(ssh $host $OCR -out_text_name $output $input 2>&1 > /dev/null);
  qx(ssh $host $OCR  $input $output 2>&1 > /dev/null);
  open (OUT, "ssh $host cat -s $output |");
  while (<OUT>) {
    print;
  }
  qx(ssh $host rm $input $output);
}