Don't redo binarise if not needed.
authorDaniel Axtens <[email protected]>
Sat, 6 Aug 2011 04:59:28 +0000 (12:59 +0800)
committerDaniel Axtens <[email protected]>
Sat, 6 Aug 2011 04:59:28 +0000 (12:59 +0800)
scan2pages.sh

index 069b421..cbfe52f 100755 (executable)
@@ -128,9 +128,18 @@ for scanpgnum in `$my_seq 1 $pages`; do
 done;
 
 # do ocr binarise
-[ -e $outdir/scanpgs ] && rm -r $outdir/scanpgs
-ocropus book2pages $outdir/scanpgs $outdir/scanpg-*.png || exit 1
+if [ -e $outdir/scanpgs ]; then
+       #assume (for the sake of speed in repeated runs) that
+       # if the last file exists, the process completed successfully
+       if [ -e $outdir/scanpgs/$(printf '%04d' $pages).bin.png ]; then
+               [[ $verbose ]] && echo Binarisation already complete
+       else
+               rm -r $outdir/scanpgs
+       fi
+fi
+[ -e $outdir/scanpgs ] || ocropus book2pages $outdir/scanpgs $outdir/scanpg-*.png || exit 1
 
+# process each binarised scan page
 for scanpgnum in  `$my_seq 1 $pages`; do
 
        binscanpg=$outdir/scanpgs/$(printf '%04d' $scanpgnum).bin.png

UCC git Repository :: git.ucc.asn.au