Changeset 59

Show
Ignore:
Timestamp:
26.11.2006 18:49:57 (2 years ago)
Author:
decoder
Message:

New classes:

- Preprocessor (will be used by scansets)
- Scanset (will represent the scanset itself)

Adjusted save_execute to accept STDIN redirect as second argument, if an application expects input from STDIN only
All save_execute calls (except for those in Preprocessor and Scanset) now have an additional "undef" as second argument, because they don't need
any STDIN redirect.

Coming next: Parser for the two new classes, so one can specify a file which contains scansets and preprocessors, which is parsed then.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/devel/FuzzyOcr.pm

    r58 r59  
    312312            my ($retcode, @stdout_data) = save_execute( 
    313313                "$conf->{focr_bin_giftext} $file", 
     314                undef, 
    314315                ">$imgdir/giftext.info", 
    315316                ">>$imgdir/giftext.err", 1); 
     
    338339                $tfile .= "-fixed.gif"; 
    339340                printf RAWERR "## $conf->{focr_bin_giffix} $file >$tfile 2>>$efile\n" if ($haserr>0); 
    340                 $retcode = save_execute("$conf->{focr_bin_giffix} $file", ">$tfile", ">>$efile"); 
     341                 
     342                $retcode = save_execute("$conf->{focr_bin_giffix} $file", undef, ">$tfile", ">>$efile"); 
    341343 
    342344                if ($retcode<0) { # only care if we timed out 
     
    388390                } 
    389391                printf RAWERR qq(## $conf->{focr_bin_gifinter} $cfile >$tfile 2>>$efile\n) if ($haserr>0); 
    390                 $retcode = save_execute("$conf->{focr_bin_gifinter} $cfile", ">$tfile", ">>$efile"); 
     392         
     393                $retcode = save_execute("$conf->{focr_bin_gifinter} $cfile", undef, ">$tfile", ">>$efile"); 
    391394 
    392395                if ($retcode<0) { 
     
    404407 
    405408            printf RAWERR qq(## $conf->{focr_bin_giftopnm} $tfile >$pfile 2>>$efile\n) if ($haserr>0); 
    406             $retcode = save_execute("$conf->{focr_bin_giftopnm} $tfile", ">$pfile", ">>$efile"); 
     409 
     410            $retcode = save_execute("$conf->{focr_bin_giftopnm} $tfile", undef, ">$pfile", ">>$efile"); 
    407411 
    408412            if ($retcode<0) { 
     
    439443            } 
    440444            printf RAWERR qq(## $conf->{focr_bin_jpegtopnm} $file >$pfile 2>>$efile\n) if ($haserr>0); 
    441             my $retcode = save_execute("$conf->{focr_bin_jpegtopnm} $file", ">$pfile", ">>$efile"); 
     445            my $retcode = save_execute("$conf->{focr_bin_jpegtopnm} $file", undef, ">$pfile", ">>$efile"); 
    442446 
    443447            if ($retcode<0) { 
     
    474478 
    475479            printf RAWERR qq(## $conf->{focr_bin_pngtopnm} $file >$pfile 2>>$efile\n) if ($haserr>0); 
    476             my $retcode = save_execute("$conf->{focr_bin_pngtopnm} $file", ">$pfile", ">>$efile"); 
     480            my $retcode = save_execute("$conf->{focr_bin_pngtopnm} $file", undef, ">$pfile", ">>$efile"); 
    477481 
    478482            if ($retcode<0) { 
     
    509513            printf RAWERR qq(## $conf->{focr_bin_bmptopnm} $file >$pfile 2>>$efile\n) if ($haserr>0); 
    510514 
    511             my $retcode = save_execute("$conf->{focr_bin_bmptopnm} $file", ">$pfile", ">>$efile"); 
     515            my $retcode = save_execute("$conf->{focr_bin_bmptopnm} $file", undef, ">$pfile", ">>$efile"); 
    512516            if ($retcode<0) { 
    513517                chomp $retcode; 
     
    543547            } 
    544548            printf RAWERR qq(## $conf->{focr_bin_tifftopnm} $file >$pfile 2>>$efile\n) if ($haserr>0); 
    545             my $retcode = save_execute("$conf->{focr_bin_tifftopnm} $file", ">$pfile", ">>$efile"); 
     549            my $retcode = save_execute("$conf->{focr_bin_tifftopnm} $file", undef, ">$pfile", ">>$efile"); 
    546550 
    547551            if ($retcode<0) { 
     
    607611            printf RAWERR qq(## $scan 2>>$efile\n) if ($haserr>0); 
    608612 
    609             my ($retcode, @ocrdata) = save_execute("$scan", ">$imgdir/ocr.temp", ">>$efile",1); 
     613            my ($retcode, @ocrdata) = save_execute("$scan", undef, ">$imgdir/ocr.temp", ">>$efile",1); 
    610614            if ($retcode<0) { 
    611615                debuglog("Timeout: \"$scanset\" took more than $conf->{focr_timeout} sec."); 
  • trunk/devel/FuzzyOcr/Deanimate.pm

    r57 r59  
    3535        my $retcode = save_execute( 
    3636            "$conf->{focr_bin_gifsicle} --colors=255 $tfile", 
     37            undef, 
    3738            ">$tfile3", 
    3839            ">>$efile"); 
     
    4748    my $retcode = save_execute( 
    4849        "$conf->{focr_bin_gifsicle} --unoptimize $tfile \'#$index\'", 
     50        undef, 
    4951        ">$tfile2", 
    5052        ">>$efile"); 
     
    7577    ($retcode, @stdout_data) = save_execute( 
    7678        "$conf->{focr_bin_gifsicle} --info $giffile", 
     79        undef, 
    7780        ">$imgdir/gifsicle.info", 
    7881        ">>$imgdir/gifsicle.err", 1); 
  • trunk/devel/FuzzyOcr/Hashing.pm

    r58 r59  
    334334    my ($r, @stdout_data) = save_execute( 
    335335        "$conf->{focr_bin_ppmhist} -noheader $pfile", 
     336        undef, 
    336337        ">$imgdir/ppmhist.info", 
    337338        ">/dev/null", 1); 
  • trunk/devel/FuzzyOcr/Misc.pm

    r58 r59  
    4242    my $conf = get_config(); 
    4343    my $t = get_timeout(); 
    44     my ($cmd, $stdout, $stderr, $return_stdout) = @_; 
     44    my ($cmd, $stdin, $stdout, $stderr, $return_stdout) = @_; 
    4545    my ($pgm,undef) = split(' ',$cmd,2); 
    4646    $stdout = '>/dev/null' unless $stdout; 
     
    5555        } elsif (not $pid) { 
    5656            debuglog("Exec: $cmd $stdout $stderr",2); 
    57             open(STDOUT, $stdout); 
    58             open(STDERR, $stderr); 
     57            if (defined $stdin) { 
     58                open(STDIN, $stdin); 
     59            } 
     60            if (defined $stdout) { 
     61                open(STDOUT, $stdout); 
     62            } 
     63            if (defined $stderr) { 
     64                open(STDERR, $stderr); 
     65            } 
    5966            exec($cmd); 
    6067            exit($?); 
     
    8693            } elsif (not $pid) { 
    8794                debuglog("Exec: $cmd $stdout $stderr",2); 
    88                 open(STDOUT, $stdout); 
    89                 open(STDERR, $stderr); 
     95 
     96                if (defined $stdin) { 
     97                    open(STDIN, $stdin); 
     98                } 
     99                if (defined $stdout) { 
     100                    open(STDOUT, $stdout); 
     101                } 
     102                if (defined $stderr) { 
     103                    open(STDERR, $stderr); 
     104                } 
    90105                exec($cmd); 
    91106                exit($?);