tesseract_bin 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +23 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/ext/tesseract_bin/extconf.rb +17 -0
- data/lib/tesseract_bin.rb +12 -0
- data/tesseract_bin.gemspec +660 -0
- data/test/helper.rb +18 -0
- data/test/test_tesseract_bin.rb +7 -0
- data/vendor/tesseract-2.04/AUTHORS +8 -0
- data/vendor/tesseract-2.04/COPYING +23 -0
- data/vendor/tesseract-2.04/ChangeLog +71 -0
- data/vendor/tesseract-2.04/INSTALL +229 -0
- data/vendor/tesseract-2.04/Makefile.am +20 -0
- data/vendor/tesseract-2.04/Makefile.in +641 -0
- data/vendor/tesseract-2.04/NEWS +1 -0
- data/vendor/tesseract-2.04/README +138 -0
- data/vendor/tesseract-2.04/ReleaseNotes +213 -0
- data/vendor/tesseract-2.04/StdAfx.cpp +8 -0
- data/vendor/tesseract-2.04/StdAfx.h +24 -0
- data/vendor/tesseract-2.04/ccmain/Makefile.am +63 -0
- data/vendor/tesseract-2.04/ccmain/Makefile.in +735 -0
- data/vendor/tesseract-2.04/ccmain/adaptions.cpp +1082 -0
- data/vendor/tesseract-2.04/ccmain/adaptions.h +109 -0
- data/vendor/tesseract-2.04/ccmain/applybox.cpp +891 -0
- data/vendor/tesseract-2.04/ccmain/applybox.h +73 -0
- data/vendor/tesseract-2.04/ccmain/baseapi.cpp +1105 -0
- data/vendor/tesseract-2.04/ccmain/baseapi.h +256 -0
- data/vendor/tesseract-2.04/ccmain/blobcmp.cpp +76 -0
- data/vendor/tesseract-2.04/ccmain/blobcmp.h +29 -0
- data/vendor/tesseract-2.04/ccmain/callnet.cpp +93 -0
- data/vendor/tesseract-2.04/ccmain/callnet.h +32 -0
- data/vendor/tesseract-2.04/ccmain/charcut.cpp +704 -0
- data/vendor/tesseract-2.04/ccmain/charcut.h +120 -0
- data/vendor/tesseract-2.04/ccmain/charsample.cpp +699 -0
- data/vendor/tesseract-2.04/ccmain/control.cpp +1842 -0
- data/vendor/tesseract-2.04/ccmain/control.h +198 -0
- data/vendor/tesseract-2.04/ccmain/docqual.cpp +1481 -0
- data/vendor/tesseract-2.04/ccmain/docqual.h +155 -0
- data/vendor/tesseract-2.04/ccmain/expandblob.cpp +82 -0
- data/vendor/tesseract-2.04/ccmain/expandblob.h +13 -0
- data/vendor/tesseract-2.04/ccmain/fixspace.cpp +989 -0
- data/vendor/tesseract-2.04/ccmain/fixspace.h +72 -0
- data/vendor/tesseract-2.04/ccmain/fixxht.cpp +825 -0
- data/vendor/tesseract-2.04/ccmain/fixxht.h +93 -0
- data/vendor/tesseract-2.04/ccmain/imgscale.cpp +154 -0
- data/vendor/tesseract-2.04/ccmain/imgscale.h +32 -0
- data/vendor/tesseract-2.04/ccmain/matmatch.cpp +391 -0
- data/vendor/tesseract-2.04/ccmain/matmatch.h +48 -0
- data/vendor/tesseract-2.04/ccmain/output.cpp +1273 -0
- data/vendor/tesseract-2.04/ccmain/output.h +116 -0
- data/vendor/tesseract-2.04/ccmain/pagewalk.cpp +666 -0
- data/vendor/tesseract-2.04/ccmain/pagewalk.h +155 -0
- data/vendor/tesseract-2.04/ccmain/paircmp.cpp +107 -0
- data/vendor/tesseract-2.04/ccmain/paircmp.h +43 -0
- data/vendor/tesseract-2.04/ccmain/pgedit.cpp +1867 -0
- data/vendor/tesseract-2.04/ccmain/pgedit.h +181 -0
- data/vendor/tesseract-2.04/ccmain/reject.cpp +1775 -0
- data/vendor/tesseract-2.04/ccmain/reject.h +181 -0
- data/vendor/tesseract-2.04/ccmain/scaleimg.cpp +366 -0
- data/vendor/tesseract-2.04/ccmain/scaleimg.h +35 -0
- data/vendor/tesseract-2.04/ccmain/tessbox.cpp +375 -0
- data/vendor/tesseract-2.04/ccmain/tessbox.h +110 -0
- data/vendor/tesseract-2.04/ccmain/tessedit.cpp +278 -0
- data/vendor/tesseract-2.04/ccmain/tessedit.h +49 -0
- data/vendor/tesseract-2.04/ccmain/tessembedded.cpp +110 -0
- data/vendor/tesseract-2.04/ccmain/tessembedded.h +38 -0
- data/vendor/tesseract-2.04/ccmain/tesseractfull.cc +37 -0
- data/vendor/tesseract-2.04/ccmain/tesseractmain.cpp +387 -0
- data/vendor/tesseract-2.04/ccmain/tesseractmain.h +58 -0
- data/vendor/tesseract-2.04/ccmain/tessio.h +110 -0
- data/vendor/tesseract-2.04/ccmain/tessvars.cpp +38 -0
- data/vendor/tesseract-2.04/ccmain/tessvars.h +48 -0
- data/vendor/tesseract-2.04/ccmain/tfacep.h +62 -0
- data/vendor/tesseract-2.04/ccmain/tfacepp.cpp +443 -0
- data/vendor/tesseract-2.04/ccmain/tfacepp.h +85 -0
- data/vendor/tesseract-2.04/ccmain/tstruct.cpp +549 -0
- data/vendor/tesseract-2.04/ccmain/tstruct.h +108 -0
- data/vendor/tesseract-2.04/ccmain/varabled.cpp +346 -0
- data/vendor/tesseract-2.04/ccmain/varabled.h +125 -0
- data/vendor/tesseract-2.04/ccmain/werdit.cpp +193 -0
- data/vendor/tesseract-2.04/ccmain/werdit.h +67 -0
- data/vendor/tesseract-2.04/ccstruct/Makefile.am +25 -0
- data/vendor/tesseract-2.04/ccstruct/Makefile.in +650 -0
- data/vendor/tesseract-2.04/ccstruct/blckerr.h +29 -0
- data/vendor/tesseract-2.04/ccstruct/blobbox.cpp +778 -0
- data/vendor/tesseract-2.04/ccstruct/blobbox.h +381 -0
- data/vendor/tesseract-2.04/ccstruct/blobs.cpp +247 -0
- data/vendor/tesseract-2.04/ccstruct/blobs.h +119 -0
- data/vendor/tesseract-2.04/ccstruct/blread.cpp +537 -0
- data/vendor/tesseract-2.04/ccstruct/blread.h +63 -0
- data/vendor/tesseract-2.04/ccstruct/callcpp.cpp +252 -0
- data/vendor/tesseract-2.04/ccstruct/coutln.cpp +650 -0
- data/vendor/tesseract-2.04/ccstruct/coutln.h +186 -0
- data/vendor/tesseract-2.04/ccstruct/crakedge.h +39 -0
- data/vendor/tesseract-2.04/ccstruct/genblob.cpp +133 -0
- data/vendor/tesseract-2.04/ccstruct/genblob.h +52 -0
- data/vendor/tesseract-2.04/ccstruct/hpddef.h +39 -0
- data/vendor/tesseract-2.04/ccstruct/hpdsizes.h +8 -0
- data/vendor/tesseract-2.04/ccstruct/ipoints.h +479 -0
- data/vendor/tesseract-2.04/ccstruct/labls.cpp +188 -0
- data/vendor/tesseract-2.04/ccstruct/labls.h +38 -0
- data/vendor/tesseract-2.04/ccstruct/linlsq.cpp +249 -0
- data/vendor/tesseract-2.04/ccstruct/linlsq.h +102 -0
- data/vendor/tesseract-2.04/ccstruct/lmedsq.cpp +453 -0
- data/vendor/tesseract-2.04/ccstruct/lmedsq.h +84 -0
- data/vendor/tesseract-2.04/ccstruct/mod128.cpp +100 -0
- data/vendor/tesseract-2.04/ccstruct/mod128.h +85 -0
- data/vendor/tesseract-2.04/ccstruct/normalis.cpp +176 -0
- data/vendor/tesseract-2.04/ccstruct/normalis.h +108 -0
- data/vendor/tesseract-2.04/ccstruct/ocrblock.cpp +369 -0
- data/vendor/tesseract-2.04/ccstruct/ocrblock.h +235 -0
- data/vendor/tesseract-2.04/ccstruct/ocrrow.cpp +216 -0
- data/vendor/tesseract-2.04/ccstruct/ocrrow.h +133 -0
- data/vendor/tesseract-2.04/ccstruct/pageblk.cpp +879 -0
- data/vendor/tesseract-2.04/ccstruct/pageblk.h +318 -0
- data/vendor/tesseract-2.04/ccstruct/pageres.cpp +330 -0
- data/vendor/tesseract-2.04/ccstruct/pageres.h +313 -0
- data/vendor/tesseract-2.04/ccstruct/pdblock.cpp +361 -0
- data/vendor/tesseract-2.04/ccstruct/pdblock.h +181 -0
- data/vendor/tesseract-2.04/ccstruct/pdclass.h +54 -0
- data/vendor/tesseract-2.04/ccstruct/points.cpp +102 -0
- data/vendor/tesseract-2.04/ccstruct/points.h +299 -0
- data/vendor/tesseract-2.04/ccstruct/polyaprx.cpp +588 -0
- data/vendor/tesseract-2.04/ccstruct/polyaprx.h +51 -0
- data/vendor/tesseract-2.04/ccstruct/polyblk.cpp +398 -0
- data/vendor/tesseract-2.04/ccstruct/polyblk.h +122 -0
- data/vendor/tesseract-2.04/ccstruct/polyblob.cpp +357 -0
- data/vendor/tesseract-2.04/ccstruct/polyblob.h +102 -0
- data/vendor/tesseract-2.04/ccstruct/polyvert.cpp +23 -0
- data/vendor/tesseract-2.04/ccstruct/polyvert.h +58 -0
- data/vendor/tesseract-2.04/ccstruct/poutline.cpp +441 -0
- data/vendor/tesseract-2.04/ccstruct/poutline.h +125 -0
- data/vendor/tesseract-2.04/ccstruct/quadlsq.cpp +147 -0
- data/vendor/tesseract-2.04/ccstruct/quadlsq.h +67 -0
- data/vendor/tesseract-2.04/ccstruct/quadratc.cpp +21 -0
- data/vendor/tesseract-2.04/ccstruct/quadratc.h +63 -0
- data/vendor/tesseract-2.04/ccstruct/quspline.cpp +382 -0
- data/vendor/tesseract-2.04/ccstruct/quspline.h +113 -0
- data/vendor/tesseract-2.04/ccstruct/ratngs.cpp +372 -0
- data/vendor/tesseract-2.04/ccstruct/ratngs.h +198 -0
- data/vendor/tesseract-2.04/ccstruct/rect.cpp +229 -0
- data/vendor/tesseract-2.04/ccstruct/rect.h +320 -0
- data/vendor/tesseract-2.04/ccstruct/rejctmap.cpp +545 -0
- data/vendor/tesseract-2.04/ccstruct/rejctmap.h +284 -0
- data/vendor/tesseract-2.04/ccstruct/rwpoly.cpp +89 -0
- data/vendor/tesseract-2.04/ccstruct/rwpoly.h +45 -0
- data/vendor/tesseract-2.04/ccstruct/statistc.cpp +905 -0
- data/vendor/tesseract-2.04/ccstruct/statistc.h +135 -0
- data/vendor/tesseract-2.04/ccstruct/stepblob.cpp +296 -0
- data/vendor/tesseract-2.04/ccstruct/stepblob.h +88 -0
- data/vendor/tesseract-2.04/ccstruct/txtregn.cpp +230 -0
- data/vendor/tesseract-2.04/ccstruct/txtregn.h +155 -0
- data/vendor/tesseract-2.04/ccstruct/vecfuncs.cpp +63 -0
- data/vendor/tesseract-2.04/ccstruct/vecfuncs.h +91 -0
- data/vendor/tesseract-2.04/ccstruct/werd.cpp +967 -0
- data/vendor/tesseract-2.04/ccstruct/werd.h +277 -0
- data/vendor/tesseract-2.04/ccutil/Makefile.am +19 -0
- data/vendor/tesseract-2.04/ccutil/Makefile.in +626 -0
- data/vendor/tesseract-2.04/ccutil/basedir.cpp +118 -0
- data/vendor/tesseract-2.04/ccutil/basedir.h +32 -0
- data/vendor/tesseract-2.04/ccutil/bits16.cpp +30 -0
- data/vendor/tesseract-2.04/ccutil/bits16.h +61 -0
- data/vendor/tesseract-2.04/ccutil/boxread.cpp +105 -0
- data/vendor/tesseract-2.04/ccutil/boxread.h +44 -0
- data/vendor/tesseract-2.04/ccutil/clst.cpp +626 -0
- data/vendor/tesseract-2.04/ccutil/clst.h +1085 -0
- data/vendor/tesseract-2.04/ccutil/debugwin.cpp +500 -0
- data/vendor/tesseract-2.04/ccutil/debugwin.h +103 -0
- data/vendor/tesseract-2.04/ccutil/elst.cpp +593 -0
- data/vendor/tesseract-2.04/ccutil/elst.h +1125 -0
- data/vendor/tesseract-2.04/ccutil/elst2.cpp +606 -0
- data/vendor/tesseract-2.04/ccutil/elst2.h +1121 -0
- data/vendor/tesseract-2.04/ccutil/errcode.cpp +104 -0
- data/vendor/tesseract-2.04/ccutil/errcode.h +104 -0
- data/vendor/tesseract-2.04/ccutil/fileerr.h +34 -0
- data/vendor/tesseract-2.04/ccutil/globaloc.cpp +115 -0
- data/vendor/tesseract-2.04/ccutil/globaloc.h +40 -0
- data/vendor/tesseract-2.04/ccutil/hashfn.cpp +57 -0
- data/vendor/tesseract-2.04/ccutil/hashfn.h +30 -0
- data/vendor/tesseract-2.04/ccutil/host.h +180 -0
- data/vendor/tesseract-2.04/ccutil/hosthplb.h +1 -0
- data/vendor/tesseract-2.04/ccutil/lsterr.h +43 -0
- data/vendor/tesseract-2.04/ccutil/mainblk.cpp +126 -0
- data/vendor/tesseract-2.04/ccutil/mainblk.h +39 -0
- data/vendor/tesseract-2.04/ccutil/memblk.cpp +1106 -0
- data/vendor/tesseract-2.04/ccutil/memblk.h +189 -0
- data/vendor/tesseract-2.04/ccutil/memry.cpp +532 -0
- data/vendor/tesseract-2.04/ccutil/memry.h +192 -0
- data/vendor/tesseract-2.04/ccutil/memryerr.h +38 -0
- data/vendor/tesseract-2.04/ccutil/mfcpch.cpp +5 -0
- data/vendor/tesseract-2.04/ccutil/mfcpch.h +37 -0
- data/vendor/tesseract-2.04/ccutil/ndminx.h +31 -0
- data/vendor/tesseract-2.04/ccutil/notdll.h +28 -0
- data/vendor/tesseract-2.04/ccutil/nwmain.h +176 -0
- data/vendor/tesseract-2.04/ccutil/ocrclass.h +345 -0
- data/vendor/tesseract-2.04/ccutil/ocrshell.cpp +772 -0
- data/vendor/tesseract-2.04/ccutil/ocrshell.h +191 -0
- data/vendor/tesseract-2.04/ccutil/platform.h +18 -0
- data/vendor/tesseract-2.04/ccutil/scanutils.cpp +543 -0
- data/vendor/tesseract-2.04/ccutil/scanutils.h +55 -0
- data/vendor/tesseract-2.04/ccutil/secname.h +9 -0
- data/vendor/tesseract-2.04/ccutil/serialis.cpp +117 -0
- data/vendor/tesseract-2.04/ccutil/serialis.h +93 -0
- data/vendor/tesseract-2.04/ccutil/stderr.h +26 -0
- data/vendor/tesseract-2.04/ccutil/strngs.cpp +495 -0
- data/vendor/tesseract-2.04/ccutil/strngs.h +138 -0
- data/vendor/tesseract-2.04/ccutil/tessclas.h +135 -0
- data/vendor/tesseract-2.04/ccutil/tessopt.cpp +61 -0
- data/vendor/tesseract-2.04/ccutil/tessopt.h +30 -0
- data/vendor/tesseract-2.04/ccutil/tprintf.cpp +122 -0
- data/vendor/tesseract-2.04/ccutil/tprintf.h +35 -0
- data/vendor/tesseract-2.04/ccutil/unichar.cpp +144 -0
- data/vendor/tesseract-2.04/ccutil/unichar.h +84 -0
- data/vendor/tesseract-2.04/ccutil/unicharmap.cpp +172 -0
- data/vendor/tesseract-2.04/ccutil/unicharmap.h +82 -0
- data/vendor/tesseract-2.04/ccutil/unicharset.cpp +307 -0
- data/vendor/tesseract-2.04/ccutil/unicharset.h +267 -0
- data/vendor/tesseract-2.04/ccutil/varable.cpp +672 -0
- data/vendor/tesseract-2.04/ccutil/varable.h +419 -0
- data/vendor/tesseract-2.04/classify/Makefile.am +24 -0
- data/vendor/tesseract-2.04/classify/Makefile.in +647 -0
- data/vendor/tesseract-2.04/classify/adaptive.cpp +535 -0
- data/vendor/tesseract-2.04/classify/adaptive.h +199 -0
- data/vendor/tesseract-2.04/classify/adaptmatch.cpp +2958 -0
- data/vendor/tesseract-2.04/classify/adaptmatch.h +86 -0
- data/vendor/tesseract-2.04/classify/baseline.cpp +58 -0
- data/vendor/tesseract-2.04/classify/baseline.h +91 -0
- data/vendor/tesseract-2.04/classify/blobclass.cpp +123 -0
- data/vendor/tesseract-2.04/classify/blobclass.h +49 -0
- data/vendor/tesseract-2.04/classify/chartoname.cpp +74 -0
- data/vendor/tesseract-2.04/classify/chartoname.h +21 -0
- data/vendor/tesseract-2.04/classify/cluster.cpp +2834 -0
- data/vendor/tesseract-2.04/classify/cluster.h +158 -0
- data/vendor/tesseract-2.04/classify/clusttool.cpp +507 -0
- data/vendor/tesseract-2.04/classify/clusttool.h +70 -0
- data/vendor/tesseract-2.04/classify/cutoffs.cpp +73 -0
- data/vendor/tesseract-2.04/classify/cutoffs.h +49 -0
- data/vendor/tesseract-2.04/classify/extern.h +32 -0
- data/vendor/tesseract-2.04/classify/extract.cpp +100 -0
- data/vendor/tesseract-2.04/classify/extract.h +36 -0
- data/vendor/tesseract-2.04/classify/featdefs.cpp +244 -0
- data/vendor/tesseract-2.04/classify/featdefs.h +71 -0
- data/vendor/tesseract-2.04/classify/flexfx.cpp +87 -0
- data/vendor/tesseract-2.04/classify/flexfx.h +34 -0
- data/vendor/tesseract-2.04/classify/float2int.cpp +126 -0
- data/vendor/tesseract-2.04/classify/float2int.h +65 -0
- data/vendor/tesseract-2.04/classify/fpoint.cpp +73 -0
- data/vendor/tesseract-2.04/classify/fpoint.h +63 -0
- data/vendor/tesseract-2.04/classify/fxdefs.cpp +74 -0
- data/vendor/tesseract-2.04/classify/fxdefs.h +93 -0
- data/vendor/tesseract-2.04/classify/fxid.h +69 -0
- data/vendor/tesseract-2.04/classify/hideedge.cpp +35 -0
- data/vendor/tesseract-2.04/classify/hideedge.h +76 -0
- data/vendor/tesseract-2.04/classify/intfx.cpp +608 -0
- data/vendor/tesseract-2.04/classify/intfx.h +63 -0
- data/vendor/tesseract-2.04/classify/intmatcher.cpp +1524 -0
- data/vendor/tesseract-2.04/classify/intmatcher.h +199 -0
- data/vendor/tesseract-2.04/classify/intproto.cpp +1823 -0
- data/vendor/tesseract-2.04/classify/intproto.h +320 -0
- data/vendor/tesseract-2.04/classify/kdtree.cpp +884 -0
- data/vendor/tesseract-2.04/classify/kdtree.h +118 -0
- data/vendor/tesseract-2.04/classify/mf.cpp +106 -0
- data/vendor/tesseract-2.04/classify/mf.h +43 -0
- data/vendor/tesseract-2.04/classify/mfdefs.cpp +58 -0
- data/vendor/tesseract-2.04/classify/mfdefs.h +60 -0
- data/vendor/tesseract-2.04/classify/mfoutline.cpp +1087 -0
- data/vendor/tesseract-2.04/classify/mfoutline.h +277 -0
- data/vendor/tesseract-2.04/classify/mfx.cpp +436 -0
- data/vendor/tesseract-2.04/classify/mfx.h +52 -0
- data/vendor/tesseract-2.04/classify/normfeat.cpp +132 -0
- data/vendor/tesseract-2.04/classify/normfeat.h +63 -0
- data/vendor/tesseract-2.04/classify/normmatch.cpp +305 -0
- data/vendor/tesseract-2.04/classify/normmatch.h +38 -0
- data/vendor/tesseract-2.04/classify/ocrfeatures.cpp +310 -0
- data/vendor/tesseract-2.04/classify/ocrfeatures.h +148 -0
- data/vendor/tesseract-2.04/classify/outfeat.cpp +262 -0
- data/vendor/tesseract-2.04/classify/outfeat.h +76 -0
- data/vendor/tesseract-2.04/classify/picofeat.cpp +297 -0
- data/vendor/tesseract-2.04/classify/picofeat.h +65 -0
- data/vendor/tesseract-2.04/classify/protos.cpp +472 -0
- data/vendor/tesseract-2.04/classify/protos.h +258 -0
- data/vendor/tesseract-2.04/classify/sigmenu.cpp +225 -0
- data/vendor/tesseract-2.04/classify/sigmenu.h +39 -0
- data/vendor/tesseract-2.04/classify/speckle.cpp +127 -0
- data/vendor/tesseract-2.04/classify/speckle.h +69 -0
- data/vendor/tesseract-2.04/classify/xform2d.cpp +120 -0
- data/vendor/tesseract-2.04/classify/xform2d.h +60 -0
- data/vendor/tesseract-2.04/config/config.guess +1466 -0
- data/vendor/tesseract-2.04/config/config.h.in +188 -0
- data/vendor/tesseract-2.04/config/config.sub +1579 -0
- data/vendor/tesseract-2.04/config/depcomp +530 -0
- data/vendor/tesseract-2.04/config/install-sh +269 -0
- data/vendor/tesseract-2.04/config/missing +198 -0
- data/vendor/tesseract-2.04/config/mkinstalldirs +40 -0
- data/vendor/tesseract-2.04/config/stamp-h.in +0 -0
- data/vendor/tesseract-2.04/configure +10424 -0
- data/vendor/tesseract-2.04/cutil/Makefile.am +14 -0
- data/vendor/tesseract-2.04/cutil/Makefile.in +612 -0
- data/vendor/tesseract-2.04/cutil/bitvec.cpp +115 -0
- data/vendor/tesseract-2.04/cutil/bitvec.h +100 -0
- data/vendor/tesseract-2.04/cutil/callcpp.h +190 -0
- data/vendor/tesseract-2.04/cutil/const.h +108 -0
- data/vendor/tesseract-2.04/cutil/cutil.cpp +92 -0
- data/vendor/tesseract-2.04/cutil/cutil.h +159 -0
- data/vendor/tesseract-2.04/cutil/danerror.cpp +144 -0
- data/vendor/tesseract-2.04/cutil/danerror.h +41 -0
- data/vendor/tesseract-2.04/cutil/debug.cpp +97 -0
- data/vendor/tesseract-2.04/cutil/debug.h +348 -0
- data/vendor/tesseract-2.04/cutil/efio.cpp +62 -0
- data/vendor/tesseract-2.04/cutil/efio.h +32 -0
- data/vendor/tesseract-2.04/cutil/emalloc.cpp +91 -0
- data/vendor/tesseract-2.04/cutil/emalloc.h +44 -0
- data/vendor/tesseract-2.04/cutil/freelist.cpp +75 -0
- data/vendor/tesseract-2.04/cutil/freelist.h +45 -0
- data/vendor/tesseract-2.04/cutil/funcdefs.h +35 -0
- data/vendor/tesseract-2.04/cutil/general.h +33 -0
- data/vendor/tesseract-2.04/cutil/globals.cpp +69 -0
- data/vendor/tesseract-2.04/cutil/globals.h +70 -0
- data/vendor/tesseract-2.04/cutil/listio.cpp +68 -0
- data/vendor/tesseract-2.04/cutil/listio.h +43 -0
- data/vendor/tesseract-2.04/cutil/minmax.h +40 -0
- data/vendor/tesseract-2.04/cutil/oldheap.cpp +337 -0
- data/vendor/tesseract-2.04/cutil/oldheap.h +126 -0
- data/vendor/tesseract-2.04/cutil/oldlist.cpp +393 -0
- data/vendor/tesseract-2.04/cutil/oldlist.h +350 -0
- data/vendor/tesseract-2.04/cutil/structures.cpp +66 -0
- data/vendor/tesseract-2.04/cutil/structures.h +112 -0
- data/vendor/tesseract-2.04/cutil/tessarray.cpp +115 -0
- data/vendor/tesseract-2.04/cutil/tessarray.h +166 -0
- data/vendor/tesseract-2.04/cutil/tordvars.cpp +95 -0
- data/vendor/tesseract-2.04/cutil/tordvars.h +61 -0
- data/vendor/tesseract-2.04/cutil/variables.cpp +317 -0
- data/vendor/tesseract-2.04/cutil/variables.h +170 -0
- data/vendor/tesseract-2.04/dict/Makefile.am +13 -0
- data/vendor/tesseract-2.04/dict/Makefile.in +609 -0
- data/vendor/tesseract-2.04/dict/choicearr.h +96 -0
- data/vendor/tesseract-2.04/dict/choices.cpp +210 -0
- data/vendor/tesseract-2.04/dict/choices.h +241 -0
- data/vendor/tesseract-2.04/dict/context.cpp +270 -0
- data/vendor/tesseract-2.04/dict/context.h +82 -0
- data/vendor/tesseract-2.04/dict/dawg.cpp +363 -0
- data/vendor/tesseract-2.04/dict/dawg.h +394 -0
- data/vendor/tesseract-2.04/dict/hyphen.cpp +84 -0
- data/vendor/tesseract-2.04/dict/hyphen.h +125 -0
- data/vendor/tesseract-2.04/dict/lookdawg.cpp +228 -0
- data/vendor/tesseract-2.04/dict/lookdawg.h +76 -0
- data/vendor/tesseract-2.04/dict/makedawg.cpp +449 -0
- data/vendor/tesseract-2.04/dict/makedawg.h +83 -0
- data/vendor/tesseract-2.04/dict/matchdefs.h +145 -0
- data/vendor/tesseract-2.04/dict/permdawg.cpp +415 -0
- data/vendor/tesseract-2.04/dict/permdawg.h +98 -0
- data/vendor/tesseract-2.04/dict/permngram.cpp +358 -0
- data/vendor/tesseract-2.04/dict/permngram.h +33 -0
- data/vendor/tesseract-2.04/dict/permnum.cpp +522 -0
- data/vendor/tesseract-2.04/dict/permnum.h +83 -0
- data/vendor/tesseract-2.04/dict/permute.cpp +1704 -0
- data/vendor/tesseract-2.04/dict/permute.h +93 -0
- data/vendor/tesseract-2.04/dict/reduce.cpp +424 -0
- data/vendor/tesseract-2.04/dict/reduce.h +112 -0
- data/vendor/tesseract-2.04/dict/states.cpp +382 -0
- data/vendor/tesseract-2.04/dict/states.h +111 -0
- data/vendor/tesseract-2.04/dict/stopper.cpp +1458 -0
- data/vendor/tesseract-2.04/dict/stopper.h +103 -0
- data/vendor/tesseract-2.04/dict/trie.cpp +683 -0
- data/vendor/tesseract-2.04/dict/trie.h +190 -0
- data/vendor/tesseract-2.04/dlltest/Makefile.am +2 -0
- data/vendor/tesseract-2.04/dlltest/Makefile.in +388 -0
- data/vendor/tesseract-2.04/dlltest/dlltest.cpp +163 -0
- data/vendor/tesseract-2.04/dlltest/dlltest.dsp +186 -0
- data/vendor/tesseract-2.04/dlltest/dlltest.vcproj +637 -0
- data/vendor/tesseract-2.04/eurotext.tif +0 -0
- data/vendor/tesseract-2.04/image/Makefile.am +10 -0
- data/vendor/tesseract-2.04/image/Makefile.in +596 -0
- data/vendor/tesseract-2.04/image/bitstrm.cpp +157 -0
- data/vendor/tesseract-2.04/image/bitstrm.h +73 -0
- data/vendor/tesseract-2.04/image/img.h +336 -0
- data/vendor/tesseract-2.04/image/imgbmp.cpp +223 -0
- data/vendor/tesseract-2.04/image/imgbmp.h +50 -0
- data/vendor/tesseract-2.04/image/imgerrs.h +35 -0
- data/vendor/tesseract-2.04/image/imgio.cpp +321 -0
- data/vendor/tesseract-2.04/image/imgio.h +22 -0
- data/vendor/tesseract-2.04/image/imgs.cpp +1764 -0
- data/vendor/tesseract-2.04/image/imgs.h +102 -0
- data/vendor/tesseract-2.04/image/imgtiff.cpp +723 -0
- data/vendor/tesseract-2.04/image/imgtiff.h +89 -0
- data/vendor/tesseract-2.04/image/imgunpk.h +1377 -0
- data/vendor/tesseract-2.04/image/svshowim.cpp +40 -0
- data/vendor/tesseract-2.04/image/svshowim.h +25 -0
- data/vendor/tesseract-2.04/java/Makefile.am +4 -0
- data/vendor/tesseract-2.04/java/Makefile.in +473 -0
- data/vendor/tesseract-2.04/java/com/Makefile.am +1 -0
- data/vendor/tesseract-2.04/java/com/Makefile.in +470 -0
- data/vendor/tesseract-2.04/java/com/google/Makefile.am +1 -0
- data/vendor/tesseract-2.04/java/com/google/Makefile.in +470 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/Makefile.am +4 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/Makefile.in +473 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ScrollView.java +421 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/Makefile.am +5 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/Makefile.in +474 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEvent.java +87 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEventHandler.java +296 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEventType.java +31 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/Makefile.am +7 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/Makefile.in +476 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVAbstractMenuItem.java +58 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVCheckboxMenuItem.java +60 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVEmptyMenuItem.java +48 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVImageHandler.java +228 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVMenuBar.java +130 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVMenuItem.java +61 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVPopupMenu.java +142 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVSubMenuItem.java +41 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVWindow.java +643 -0
- data/vendor/tesseract-2.04/java/makefile +55 -0
- data/vendor/tesseract-2.04/pageseg/Makefile.am +13 -0
- data/vendor/tesseract-2.04/pageseg/Makefile.in +596 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg.cpp +363 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg.h +90 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg_interface.cpp +82 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg_interface.h +30 -0
- data/vendor/tesseract-2.04/pageseg/pageseg.cpp +170 -0
- data/vendor/tesseract-2.04/pageseg/pageseg.h +29 -0
- data/vendor/tesseract-2.04/phototest.tif +0 -0
- data/vendor/tesseract-2.04/tessdata/Makefile.am +31 -0
- data/vendor/tesseract-2.04/tessdata/Makefile.in +529 -0
- data/vendor/tesseract-2.04/tessdata/configs/Makefile.am +3 -0
- data/vendor/tesseract-2.04/tessdata/configs/Makefile.in +344 -0
- data/vendor/tesseract-2.04/tessdata/configs/api_config +1 -0
- data/vendor/tesseract-2.04/tessdata/configs/box.train +19 -0
- data/vendor/tesseract-2.04/tessdata/configs/box.train.stderr +18 -0
- data/vendor/tesseract-2.04/tessdata/configs/inter +4 -0
- data/vendor/tesseract-2.04/tessdata/configs/kannada +4 -0
- data/vendor/tesseract-2.04/tessdata/configs/makebox +1 -0
- data/vendor/tesseract-2.04/tessdata/configs/unlv +3 -0
- data/vendor/tesseract-2.04/tessdata/confsets +3 -0
- data/vendor/tesseract-2.04/tessdata/eng.DangAmbigs +39 -0
- data/vendor/tesseract-2.04/tessdata/eng.freq-dawg +0 -0
- data/vendor/tesseract-2.04/tessdata/eng.inttemp +0 -0
- data/vendor/tesseract-2.04/tessdata/eng.normproto +1247 -0
- data/vendor/tesseract-2.04/tessdata/eng.pffmtable +111 -0
- data/vendor/tesseract-2.04/tessdata/eng.unicharset +113 -0
- data/vendor/tesseract-2.04/tessdata/eng.user-words +921 -0
- data/vendor/tesseract-2.04/tessdata/eng.word-dawg +0 -0
- data/vendor/tesseract-2.04/tessdata/makedummies +8 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/Makefile.am +3 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/Makefile.in +344 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/batch +2 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/batch.nochop +2 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/matdemo +7 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/msdemo +13 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/nobatch +2 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/segdemo +9 -0
- data/vendor/tesseract-2.04/tessdll.cpp +351 -0
- data/vendor/tesseract-2.04/tessdll.dsp +2050 -0
- data/vendor/tesseract-2.04/tessdll.h +143 -0
- data/vendor/tesseract-2.04/tessdll.vcproj +5495 -0
- data/vendor/tesseract-2.04/tesseract.dsp +2124 -0
- data/vendor/tesseract-2.04/tesseract.dsw +116 -0
- data/vendor/tesseract-2.04/tesseract.sln +59 -0
- data/vendor/tesseract-2.04/tesseract.spec +188 -0
- data/vendor/tesseract-2.04/tesseract.vcproj +5859 -0
- data/vendor/tesseract-2.04/testing/Makefile.am +2 -0
- data/vendor/tesseract-2.04/testing/Makefile.in +312 -0
- data/vendor/tesseract-2.04/testing/README +43 -0
- data/vendor/tesseract-2.04/testing/counttestset.sh +61 -0
- data/vendor/tesseract-2.04/testing/reorgdata.sh +44 -0
- data/vendor/tesseract-2.04/testing/reports/1995.bus.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/1995.doe3.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/1995.mag.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/1995.news.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/2.03.summary +9 -0
- data/vendor/tesseract-2.04/testing/reports/2.04.summary +9 -0
- data/vendor/tesseract-2.04/testing/runalltests.sh +110 -0
- data/vendor/tesseract-2.04/testing/runtestset.sh +61 -0
- data/vendor/tesseract-2.04/textord/Makefile.am +20 -0
- data/vendor/tesseract-2.04/textord/Makefile.in +624 -0
- data/vendor/tesseract-2.04/textord/blkocc.cpp +809 -0
- data/vendor/tesseract-2.04/textord/blkocc.h +327 -0
- data/vendor/tesseract-2.04/textord/blobcmpl.h +31 -0
- data/vendor/tesseract-2.04/textord/drawedg.cpp +77 -0
- data/vendor/tesseract-2.04/textord/drawedg.h +34 -0
- data/vendor/tesseract-2.04/textord/drawtord.cpp +469 -0
- data/vendor/tesseract-2.04/textord/drawtord.h +107 -0
- data/vendor/tesseract-2.04/textord/edgblob.cpp +412 -0
- data/vendor/tesseract-2.04/textord/edgblob.h +100 -0
- data/vendor/tesseract-2.04/textord/edgloop.cpp +211 -0
- data/vendor/tesseract-2.04/textord/edgloop.h +66 -0
- data/vendor/tesseract-2.04/textord/fpchop.cpp +1641 -0
- data/vendor/tesseract-2.04/textord/fpchop.h +238 -0
- data/vendor/tesseract-2.04/textord/gap_map.cpp +166 -0
- data/vendor/tesseract-2.04/textord/gap_map.h +40 -0
- data/vendor/tesseract-2.04/textord/makerow.cpp +2628 -0
- data/vendor/tesseract-2.04/textord/makerow.h +295 -0
- data/vendor/tesseract-2.04/textord/oldbasel.cpp +1761 -0
- data/vendor/tesseract-2.04/textord/oldbasel.h +195 -0
- data/vendor/tesseract-2.04/textord/pithsync.cpp +696 -0
- data/vendor/tesseract-2.04/textord/pithsync.h +134 -0
- data/vendor/tesseract-2.04/textord/pitsync1.cpp +425 -0
- data/vendor/tesseract-2.04/textord/pitsync1.h +135 -0
- data/vendor/tesseract-2.04/textord/scanedg.cpp +452 -0
- data/vendor/tesseract-2.04/textord/scanedg.h +74 -0
- data/vendor/tesseract-2.04/textord/sortflts.cpp +80 -0
- data/vendor/tesseract-2.04/textord/sortflts.h +64 -0
- data/vendor/tesseract-2.04/textord/tessout.h +76 -0
- data/vendor/tesseract-2.04/textord/topitch.cpp +2019 -0
- data/vendor/tesseract-2.04/textord/topitch.h +195 -0
- data/vendor/tesseract-2.04/textord/tordmain.cpp +907 -0
- data/vendor/tesseract-2.04/textord/tordmain.h +132 -0
- data/vendor/tesseract-2.04/textord/tospace.cpp +1939 -0
- data/vendor/tesseract-2.04/textord/tospace.h +193 -0
- data/vendor/tesseract-2.04/textord/tovars.cpp +87 -0
- data/vendor/tesseract-2.04/textord/tovars.h +94 -0
- data/vendor/tesseract-2.04/textord/underlin.cpp +312 -0
- data/vendor/tesseract-2.04/textord/underlin.h +53 -0
- data/vendor/tesseract-2.04/textord/wordseg.cpp +620 -0
- data/vendor/tesseract-2.04/textord/wordseg.h +70 -0
- data/vendor/tesseract-2.04/training/Makefile.am +54 -0
- data/vendor/tesseract-2.04/training/Makefile.in +720 -0
- data/vendor/tesseract-2.04/training/cnTraining.cpp +855 -0
- data/vendor/tesseract-2.04/training/cntraining.dsp +243 -0
- data/vendor/tesseract-2.04/training/cntraining.vcproj +950 -0
- data/vendor/tesseract-2.04/training/mergenf.cpp +451 -0
- data/vendor/tesseract-2.04/training/mergenf.h +106 -0
- data/vendor/tesseract-2.04/training/mfTraining.cpp +1341 -0
- data/vendor/tesseract-2.04/training/mftraining.dsp +285 -0
- data/vendor/tesseract-2.04/training/mftraining.vcproj +1055 -0
- data/vendor/tesseract-2.04/training/name2char.cpp +166 -0
- data/vendor/tesseract-2.04/training/name2char.h +38 -0
- data/vendor/tesseract-2.04/training/training.cpp +190 -0
- data/vendor/tesseract-2.04/training/training.h +130 -0
- data/vendor/tesseract-2.04/training/unicharset_extractor.cpp +140 -0
- data/vendor/tesseract-2.04/training/unicharset_extractor.dsp +335 -0
- data/vendor/tesseract-2.04/training/unicharset_extractor.vcproj +769 -0
- data/vendor/tesseract-2.04/training/wordlist2dawg.cpp +69 -0
- data/vendor/tesseract-2.04/training/wordlist2dawg.dsp +319 -0
- data/vendor/tesseract-2.04/training/wordlist2dawg.vcproj +1113 -0
- data/vendor/tesseract-2.04/viewer/Makefile.am +9 -0
- data/vendor/tesseract-2.04/viewer/Makefile.in +591 -0
- data/vendor/tesseract-2.04/viewer/scrollview.cpp +825 -0
- data/vendor/tesseract-2.04/viewer/scrollview.h +414 -0
- data/vendor/tesseract-2.04/viewer/svmnode.cpp +140 -0
- data/vendor/tesseract-2.04/viewer/svmnode.h +94 -0
- data/vendor/tesseract-2.04/viewer/svpaint.cpp +220 -0
- data/vendor/tesseract-2.04/viewer/svutil.cpp +347 -0
- data/vendor/tesseract-2.04/viewer/svutil.h +138 -0
- data/vendor/tesseract-2.04/wordrec/Makefile.am +23 -0
- data/vendor/tesseract-2.04/wordrec/Makefile.in +641 -0
- data/vendor/tesseract-2.04/wordrec/associate.cpp +62 -0
- data/vendor/tesseract-2.04/wordrec/associate.h +93 -0
- data/vendor/tesseract-2.04/wordrec/badwords.cpp +106 -0
- data/vendor/tesseract-2.04/wordrec/badwords.h +51 -0
- data/vendor/tesseract-2.04/wordrec/bestfirst.cpp +526 -0
- data/vendor/tesseract-2.04/wordrec/bestfirst.h +203 -0
- data/vendor/tesseract-2.04/wordrec/charsample.h +208 -0
- data/vendor/tesseract-2.04/wordrec/chop.cpp +458 -0
- data/vendor/tesseract-2.04/wordrec/chop.h +153 -0
- data/vendor/tesseract-2.04/wordrec/chopper.cpp +750 -0
- data/vendor/tesseract-2.04/wordrec/chopper.h +104 -0
- data/vendor/tesseract-2.04/wordrec/closed.cpp +136 -0
- data/vendor/tesseract-2.04/wordrec/closed.h +65 -0
- data/vendor/tesseract-2.04/wordrec/djmenus.cpp +118 -0
- data/vendor/tesseract-2.04/wordrec/djmenus.h +33 -0
- data/vendor/tesseract-2.04/wordrec/drawfx.cpp +92 -0
- data/vendor/tesseract-2.04/wordrec/drawfx.h +33 -0
- data/vendor/tesseract-2.04/wordrec/findseam.cpp +566 -0
- data/vendor/tesseract-2.04/wordrec/findseam.h +69 -0
- data/vendor/tesseract-2.04/wordrec/gradechop.cpp +226 -0
- data/vendor/tesseract-2.04/wordrec/gradechop.h +91 -0
- data/vendor/tesseract-2.04/wordrec/heuristic.cpp +194 -0
- data/vendor/tesseract-2.04/wordrec/heuristic.h +120 -0
- data/vendor/tesseract-2.04/wordrec/makechop.cpp +281 -0
- data/vendor/tesseract-2.04/wordrec/makechop.h +69 -0
- data/vendor/tesseract-2.04/wordrec/matchtab.cpp +191 -0
- data/vendor/tesseract-2.04/wordrec/matchtab.h +45 -0
- data/vendor/tesseract-2.04/wordrec/matrix.cpp +118 -0
- data/vendor/tesseract-2.04/wordrec/matrix.h +104 -0
- data/vendor/tesseract-2.04/wordrec/measure.h +135 -0
- data/vendor/tesseract-2.04/wordrec/metrics.cpp +363 -0
- data/vendor/tesseract-2.04/wordrec/metrics.h +130 -0
- data/vendor/tesseract-2.04/wordrec/mfvars.cpp +51 -0
- data/vendor/tesseract-2.04/wordrec/mfvars.h +27 -0
- data/vendor/tesseract-2.04/wordrec/msmenus.cpp +110 -0
- data/vendor/tesseract-2.04/wordrec/msmenus.h +45 -0
- data/vendor/tesseract-2.04/wordrec/olutil.cpp +153 -0
- data/vendor/tesseract-2.04/wordrec/olutil.h +128 -0
- data/vendor/tesseract-2.04/wordrec/outlines.cpp +172 -0
- data/vendor/tesseract-2.04/wordrec/outlines.h +148 -0
- data/vendor/tesseract-2.04/wordrec/pieces.cpp +410 -0
- data/vendor/tesseract-2.04/wordrec/pieces.h +154 -0
- data/vendor/tesseract-2.04/wordrec/plotedges.cpp +134 -0
- data/vendor/tesseract-2.04/wordrec/plotedges.h +71 -0
- data/vendor/tesseract-2.04/wordrec/plotseg.cpp +116 -0
- data/vendor/tesseract-2.04/wordrec/plotseg.h +73 -0
- data/vendor/tesseract-2.04/wordrec/render.cpp +152 -0
- data/vendor/tesseract-2.04/wordrec/render.h +58 -0
- data/vendor/tesseract-2.04/wordrec/seam.cpp +482 -0
- data/vendor/tesseract-2.04/wordrec/seam.h +136 -0
- data/vendor/tesseract-2.04/wordrec/split.cpp +182 -0
- data/vendor/tesseract-2.04/wordrec/split.h +115 -0
- data/vendor/tesseract-2.04/wordrec/tally.cpp +68 -0
- data/vendor/tesseract-2.04/wordrec/tally.h +94 -0
- data/vendor/tesseract-2.04/wordrec/tessinit.cpp +108 -0
- data/vendor/tesseract-2.04/wordrec/tessinit.h +46 -0
- data/vendor/tesseract-2.04/wordrec/tface.cpp +272 -0
- data/vendor/tesseract-2.04/wordrec/tface.h +35 -0
- data/vendor/tesseract-2.04/wordrec/wordclass.cpp +284 -0
- data/vendor/tesseract-2.04/wordrec/wordclass.h +64 -0
- metadata +708 -0
@@ -0,0 +1,772 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
* File: ocrshell.cpp
|
3
|
+
* Description: Code for the OCR side of the OCR API.
|
4
|
+
* Author: Hewlett-Packard Co
|
5
|
+
*
|
6
|
+
* (C) Copyright 1996, Hewlett-Packard Co.
|
7
|
+
** Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
** you may not use this file except in compliance with the License.
|
9
|
+
** You may obtain a copy of the License at
|
10
|
+
** http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
** Unless required by applicable law or agreed to in writing, software
|
12
|
+
** distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
** See the License for the specific language governing permissions and
|
15
|
+
** limitations under the License.
|
16
|
+
*
|
17
|
+
**********************************************************************/
|
18
|
+
|
19
|
+
/**********************************************************************
|
20
|
+
* This file contains code for the OCR side of the HP OCR interface.
|
21
|
+
* The code is designed to be used with either an ANSI C or C++ compiler.
|
22
|
+
* The structures are designed to allow them to be used with any
|
23
|
+
* structure alignment upto 8.
|
24
|
+
**********************************************************************/
|
25
|
+
|
26
|
+
#include "mfcpch.h"
|
27
|
+
#include "ocrshell.h"
|
28
|
+
#include "tprintf.h"
|
29
|
+
#include <stdlib.h>
|
30
|
+
|
31
|
+
#define EXTERN
|
32
|
+
|
33
|
+
#ifdef __UNIX__
|
34
|
+
EXTERN ESHM_INFO shm; /*info on shm */
|
35
|
+
#define TICKS 1
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#ifdef __MSW32__
|
39
|
+
EXTERN ESHM_INFO shm; /*info on shm */
|
40
|
+
#define TICKS 1000
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#ifdef __MAC__
|
44
|
+
|
45
|
+
#if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
|
46
|
+
#pragma import on
|
47
|
+
#endif
|
48
|
+
|
49
|
+
extern volatile ESHM_INFO shm; /*info on shm */
|
50
|
+
extern unsigned short WaitForSingleObject( /*"C" */
|
51
|
+
volatile Boolean &semaphore,
|
52
|
+
unsigned long timeout);
|
53
|
+
extern unsigned short ReleaseSemaphore( /*"C" */
|
54
|
+
volatile Boolean &semaphore);
|
55
|
+
#if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
|
56
|
+
#pragma import reset
|
57
|
+
#endif
|
58
|
+
#define WAIT_OBJECT_0 1
|
59
|
+
#define TICKS 60
|
60
|
+
#endif
|
61
|
+
|
62
|
+
typedef enum {
|
63
|
+
OCS_UNINIT, /*uninitialized */
|
64
|
+
OCS_SETUP_SHM, /*shm setup done */
|
65
|
+
OCS_SETUP_INFO, /*startinfo sent */
|
66
|
+
OCS_READING_STRIPS, /*read first but more to come */
|
67
|
+
OCS_READ_STRIPS, /*read all but no monitor yet */
|
68
|
+
OCS_RECOGNIZING, /*OCR incomplete */
|
69
|
+
OCS_SENDING_TEXT, /*sent buffer but more to come */
|
70
|
+
OCS_DEAD /*disconnected */
|
71
|
+
} OCR_STATE;
|
72
|
+
|
73
|
+
/* forward declarations - not in .h file as not needed outside this file*/
|
74
|
+
inT16 ocr_internal_shutdown(); /*closedown */
|
75
|
+
inT16 wait_for_mutex(); /*wait for HP to be ready */
|
76
|
+
inT16 wait_for_hp( /*wait for semaphore */
|
77
|
+
inT32 timeout /*in seconds */
|
78
|
+
);
|
79
|
+
inT16 release_mutex(); /*release mutex */
|
80
|
+
inT16 release_ocr(); /*release semaphore */
|
81
|
+
|
82
|
+
static inT32 font_count = 0; /*number of fonts */
|
83
|
+
static inT16 lines_read = 0; /*no read in this image */
|
84
|
+
/*current state */
|
85
|
+
static OCR_STATE ocr_state = OCS_UNINIT;
|
86
|
+
|
87
|
+
#ifdef __MAC__
|
88
|
+
pascal short TerminateOCR(AppleEvent *theEvent,
|
89
|
+
AppleEvent *theReply,
|
90
|
+
long refCon) {
|
91
|
+
ocr_internal_shutdown();
|
92
|
+
ExitToShell();
|
93
|
+
|
94
|
+
}
|
95
|
+
#endif
|
96
|
+
|
97
|
+
/**********************************************************************
|
98
|
+
* ocr_open_shm
|
99
|
+
*
|
100
|
+
* Attempt to connect to the shared memory segment and semaphores used
|
101
|
+
* in talking to the OCR engine. Called from OCR engine.
|
102
|
+
* The parameters are the command line arguments in order.
|
103
|
+
**********************************************************************/
|
104
|
+
#ifdef __MAC__
|
105
|
+
inT16
|
106
|
+
ocr_open_shm (uinT16 * lang)
|
107
|
+
#else
|
108
|
+
inT16
|
109
|
+
ocr_open_shm ( /*open the shm */
|
110
|
+
const char *shm_h, /*handle of shm */
|
111
|
+
const char *shm_size, /*size of shm segment */
|
112
|
+
const char *mutex_h, /*hp mutex */
|
113
|
+
const char *ocr_h, /*ocr semaphore */
|
114
|
+
const char *hp_h, /*hp semaphore */
|
115
|
+
const char *lang_str, /*language */
|
116
|
+
uinT16 * lang /*required language */
|
117
|
+
)
|
118
|
+
#endif
|
119
|
+
{
|
120
|
+
font_count = 0; /*no fonts yet */
|
121
|
+
#ifdef __MAC__
|
122
|
+
if (shm.OCRProcess.lowLongOfPSN && shm.OCRProcess.highLongOfPSN)
|
123
|
+
return HPERR;
|
124
|
+
*lang = shm.language;
|
125
|
+
GetCurrentProcess (&shm.OCRProcess);
|
126
|
+
if (WakeUpProcess (&shm.IPEProcess))
|
127
|
+
ExitToShell();
|
128
|
+
AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
|
129
|
+
(AEEventHandlerUPP) TerminateOCR, 0, FALSE);
|
130
|
+
#else
|
131
|
+
if (lang != NULL)
|
132
|
+
/*get language */
|
133
|
+
*lang = (uinT16) strtol (lang_str, NULL, 10);
|
134
|
+
#endif
|
135
|
+
if (ocr_state != OCS_UNINIT) {
|
136
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
137
|
+
return OCR_API_BAD_STATE; /*incorrect state */
|
138
|
+
}
|
139
|
+
#ifdef __MSW32__
|
140
|
+
shm.shm_size = strtol (shm_size, NULL, 10);
|
141
|
+
/*convert to handle */
|
142
|
+
shm.shm_hand = (HANDLE) strtol (shm_h, NULL, 10);
|
143
|
+
shm.shm_mem = MapViewOfFile (shm.shm_hand, FILE_MAP_WRITE, 0, 0, 0);
|
144
|
+
if (shm.shm_mem == NULL)
|
145
|
+
return HPERR; /*failed */
|
146
|
+
/*convert to handle */
|
147
|
+
shm.mutex = (HANDLE) strtol (mutex_h, NULL, 10);
|
148
|
+
/*convert to handle */
|
149
|
+
shm.ocr_sem = (HANDLE) strtol (ocr_h, NULL, 10);
|
150
|
+
/*convert to handle */
|
151
|
+
shm.hp_sem = (HANDLE) strtol (hp_h, NULL, 10);
|
152
|
+
#endif
|
153
|
+
|
154
|
+
ocr_state = OCS_SETUP_SHM; /*record state */
|
155
|
+
return OKAY;
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
/**********************************************************************
|
161
|
+
* ocr_error
|
162
|
+
*
|
163
|
+
* Inform the HP side of an error.
|
164
|
+
* The OCR engine should do any cleanup of its own and exit aferwards.
|
165
|
+
* Uses the current state to determine how to send it and cleanup.
|
166
|
+
**********************************************************************/
|
167
|
+
|
168
|
+
void ocr_error( /*send an error code */
|
169
|
+
OCR_ERR_CODE code /*error code */
|
170
|
+
) {
|
171
|
+
ESTRIP_DESC *strip = (ESTRIP_DESC *) shm.shm_mem;
|
172
|
+
/*strip info */
|
173
|
+
ETEXT_DESC *monitor = (ETEXT_DESC *) shm.shm_mem;
|
174
|
+
/*progress monitor */
|
175
|
+
|
176
|
+
switch (ocr_state) {
|
177
|
+
case OCS_UNINIT: /*uninitialized */
|
178
|
+
case OCS_DEAD: /*uninitialized */
|
179
|
+
return; /*can't do anything else */
|
180
|
+
case OCS_SETUP_SHM: /*shm setup done */
|
181
|
+
if (font_count < 1)
|
182
|
+
font_count = 1;
|
183
|
+
ocr_setup_startinfo_ansi (-code, LANGE_NONE, "", "");
|
184
|
+
/*report error */
|
185
|
+
break;
|
186
|
+
case OCS_SETUP_INFO: /*startinfo sent */
|
187
|
+
if (ocr_get_first_image_strip () == NULL)
|
188
|
+
break; /*disconnected */
|
189
|
+
case OCS_READING_STRIPS: /*read first but more to come */
|
190
|
+
strip->x_size = -code; /*report error */
|
191
|
+
release_ocr(); /*send ack */
|
192
|
+
release_mutex();
|
193
|
+
break;
|
194
|
+
case OCS_READ_STRIPS: /*read all but no monitor yet */
|
195
|
+
monitor->count = 0; /*chars in this buffer(-1) */
|
196
|
+
monitor->progress = 0; /*percent complete increasing (0-100) */
|
197
|
+
/*text not complete */
|
198
|
+
monitor->more_to_come = FALSE;
|
199
|
+
monitor->ocr_alive = TRUE; /*ocr sets to 1, hp 0 */
|
200
|
+
monitor->err_code = -code; /*report error */
|
201
|
+
monitor->cancel = FALSE; /*0=continue, 1=cancel */
|
202
|
+
release_ocr(); /*send ack */
|
203
|
+
break;
|
204
|
+
case OCS_RECOGNIZING: /*OCR incomplete */
|
205
|
+
case OCS_SENDING_TEXT: /*sent buffer but more to come */
|
206
|
+
monitor->err_code = -code; /*report error */
|
207
|
+
release_ocr(); /*send ack */
|
208
|
+
}
|
209
|
+
ocr_internal_shutdown(); /*get ready for exit */
|
210
|
+
}
|
211
|
+
|
212
|
+
|
213
|
+
/**********************************************************************
|
214
|
+
* ocr_append_fontinfo
|
215
|
+
*
|
216
|
+
* Initialize one of the font descriptors.
|
217
|
+
**********************************************************************/
|
218
|
+
|
219
|
+
inT16 ocr_append_fontinfo( /*put info into shm */
|
220
|
+
uinT16 language, /*default language */
|
221
|
+
uinT8 font_family, /*serif/not, fixed/not */
|
222
|
+
uinT8 char_set, /*character set standard */
|
223
|
+
uinT8 pitch, /*fixed or prop */
|
224
|
+
const char *name /*plain ascii name */
|
225
|
+
) {
|
226
|
+
EOCR_DESC *desc; /*ocr engine info */
|
227
|
+
int index; /*char index */
|
228
|
+
inT32 font_index; /*which font */
|
229
|
+
|
230
|
+
if (ocr_state != OCS_SETUP_SHM) {
|
231
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
232
|
+
return OCR_API_BAD_STATE; /*incorrect state */
|
233
|
+
}
|
234
|
+
|
235
|
+
/*turn to right type */
|
236
|
+
desc = (EOCR_DESC *) shm.shm_mem;
|
237
|
+
if (font_count >
|
238
|
+
(inT32) ((shm.shm_size - sizeof (EOCR_DESC)) / sizeof (EFONT_DESC)))
|
239
|
+
return OCR_API_NO_MEM; /*insufficient space */
|
240
|
+
font_index = font_count++; /*add a font */
|
241
|
+
/*setup structure */
|
242
|
+
desc->fonts[font_index].language = language;
|
243
|
+
/*setup structure */
|
244
|
+
desc->fonts[font_index].font_family = font_family;
|
245
|
+
/*setup structure */
|
246
|
+
desc->fonts[font_index].char_set = char_set;
|
247
|
+
/*setup structure */
|
248
|
+
desc->fonts[font_index].pitch = pitch;
|
249
|
+
if (name != NULL) {
|
250
|
+
for (index = 0; index < MAX_FONT_NAME && name[index] != 0; index++)
|
251
|
+
desc->fonts[font_index].name[index] = name[index];
|
252
|
+
}
|
253
|
+
else
|
254
|
+
index = 0;
|
255
|
+
desc->fonts[font_index].name[index] = 0;
|
256
|
+
return OKAY;
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
/**********************************************************************
|
261
|
+
* ocr_setup_startinfo
|
262
|
+
*
|
263
|
+
* Setup the info on the OCR engine. Uses 16 bit chars to name the
|
264
|
+
* engine.
|
265
|
+
**********************************************************************/
|
266
|
+
|
267
|
+
inT16 ocr_setup_startinfo( /*put info into shm */
|
268
|
+
inT32 protocol, /*interface version */
|
269
|
+
uinT16 language, /*default language */
|
270
|
+
const uinT16 *name, /*name of engine */
|
271
|
+
const uinT16 *version /*version of engine */
|
272
|
+
) {
|
273
|
+
EOCR_DESC *desc; /*ocr engine info */
|
274
|
+
int index; /*char index */
|
275
|
+
inT16 result; /*from open */
|
276
|
+
|
277
|
+
if (ocr_state != OCS_SETUP_SHM || font_count < 1) {
|
278
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
279
|
+
return OCR_API_BAD_STATE; /*incorrect state */
|
280
|
+
}
|
281
|
+
|
282
|
+
/*turn to right type */
|
283
|
+
desc = (EOCR_DESC *) shm.shm_mem;
|
284
|
+
desc->protocol = protocol; /*setup structure */
|
285
|
+
desc->font_count = font_count;
|
286
|
+
desc->language = language;
|
287
|
+
for (index = 0; index < MAX_OCR_NAME && name[index] != 0; index++)
|
288
|
+
desc->name[index] = name[index];
|
289
|
+
desc->name[index] = 0;
|
290
|
+
for (index = 0; index < MAX_OCR_VERSION && version[index] != 0; index++)
|
291
|
+
desc->version[index] = version[index];
|
292
|
+
desc->version[index] = 0;
|
293
|
+
|
294
|
+
result = release_ocr ();
|
295
|
+
if (result != OKAY)
|
296
|
+
return result;
|
297
|
+
ocr_state = OCS_SETUP_INFO; /*record state */
|
298
|
+
return OKAY;
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
/**********************************************************************
|
303
|
+
* ocr_setup_startinfo_ansi
|
304
|
+
*
|
305
|
+
* Setup the info on the OCR engine. Uses 8 bit chars to name the
|
306
|
+
* engine.
|
307
|
+
**********************************************************************/
|
308
|
+
|
309
|
+
inT16 ocr_setup_startinfo_ansi( /*put info into shm */
|
310
|
+
uinT32 protocol, /*interface version */
|
311
|
+
uinT16 language, /*default language */
|
312
|
+
const char *name, /*name of engine */
|
313
|
+
const char *version /*version of engine */
|
314
|
+
) {
|
315
|
+
EOCR_DESC *desc; /*ocr engine info */
|
316
|
+
int index; /*char index */
|
317
|
+
inT16 result; /*from open */
|
318
|
+
|
319
|
+
if (ocr_state != OCS_SETUP_SHM || font_count < 1) {
|
320
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
321
|
+
return OCR_API_BAD_STATE; /*incorrect state */
|
322
|
+
}
|
323
|
+
|
324
|
+
/*turn to right type */
|
325
|
+
desc = (EOCR_DESC *) shm.shm_mem;
|
326
|
+
desc->protocol = protocol; /*setup structure */
|
327
|
+
desc->font_count = font_count;
|
328
|
+
desc->language = language;
|
329
|
+
for (index = 0; index < MAX_OCR_NAME && name[index] != 0; index++)
|
330
|
+
desc->name[index] = name[index];
|
331
|
+
desc->name[index] = 0;
|
332
|
+
for (index = 0; index < MAX_OCR_VERSION && version[index] != 0; index++)
|
333
|
+
desc->version[index] = version[index];
|
334
|
+
desc->version[index] = 0;
|
335
|
+
|
336
|
+
result = release_ocr ();
|
337
|
+
if (result != OKAY)
|
338
|
+
return result;
|
339
|
+
ocr_state = OCS_SETUP_INFO; /*record state */
|
340
|
+
return OKAY;
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
/**********************************************************************
|
345
|
+
* ocr_get_first_image_strip
|
346
|
+
*
|
347
|
+
* Wait for the master to send the first image strip and return a
|
348
|
+
* pointer to it. The result is NULL if it is time to exit.
|
349
|
+
**********************************************************************/
|
350
|
+
|
351
|
+
ESTRIP_DESC *ocr_get_first_image_strip() { /*get image strip */
|
352
|
+
ESTRIP_DESC *strip; /*strip info */
|
353
|
+
inT16 result; /*of wait/release */
|
354
|
+
|
355
|
+
if (ocr_state != OCS_SETUP_INFO) {
|
356
|
+
tprintf ("Bad state reading strip");
|
357
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
358
|
+
return NULL; /*incorrect state */
|
359
|
+
}
|
360
|
+
|
361
|
+
/*strip info */
|
362
|
+
strip = (ESTRIP_DESC *) shm.shm_mem;
|
363
|
+
lines_read = 0;
|
364
|
+
|
365
|
+
result = wait_for_mutex ();
|
366
|
+
if (result != OKAY) {
|
367
|
+
tprintf ("Mutax wait failed reading strip");
|
368
|
+
return NULL; /*HP dead */
|
369
|
+
}
|
370
|
+
result = release_mutex ();
|
371
|
+
if (result != OKAY) {
|
372
|
+
tprintf ("Mutax release failed reading strip");
|
373
|
+
return NULL; /*HP dead */
|
374
|
+
}
|
375
|
+
result = wait_for_hp (READIM_TIMEOUT);
|
376
|
+
if (result != OKAY) {
|
377
|
+
tprintf ("Wait for HP failed reading strip");
|
378
|
+
return NULL; /*HP dead */
|
379
|
+
}
|
380
|
+
lines_read = strip->strip_size;/*lines read so far */
|
381
|
+
if (lines_read < strip->y_size)
|
382
|
+
/*record state */
|
383
|
+
ocr_state = OCS_READING_STRIPS;
|
384
|
+
else
|
385
|
+
ocr_state = OCS_READ_STRIPS;
|
386
|
+
if (strip->x_size == 0 || strip->y_size == 0)
|
387
|
+
return NULL; /*end of job */
|
388
|
+
|
389
|
+
return strip;
|
390
|
+
}
|
391
|
+
|
392
|
+
|
393
|
+
/**********************************************************************
|
394
|
+
* ocr_get_next_image_strip
|
395
|
+
*
|
396
|
+
* Wait for the master to send the next image strip and return a
|
397
|
+
* pointer to it. The result is NULL if it is time to exit.
|
398
|
+
**********************************************************************/
|
399
|
+
|
400
|
+
ESTRIP_DESC *ocr_get_next_image_strip() { /*get image strip */
|
401
|
+
ESTRIP_DESC *strip; /*strip info */
|
402
|
+
inT16 result; /*of wait/release */
|
403
|
+
|
404
|
+
if (ocr_state != OCS_READING_STRIPS) {
|
405
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
406
|
+
return NULL; /*incorrect state */
|
407
|
+
}
|
408
|
+
|
409
|
+
/*strip info */
|
410
|
+
strip = (ESTRIP_DESC *) shm.shm_mem;
|
411
|
+
result = release_ocr ();
|
412
|
+
if (result != OKAY)
|
413
|
+
return NULL; /*HP dead */
|
414
|
+
result = wait_for_hp (READIM_TIMEOUT);
|
415
|
+
if (result != OKAY)
|
416
|
+
return NULL; /*HP dead */
|
417
|
+
/*lines read so far */
|
418
|
+
lines_read += strip->strip_size;
|
419
|
+
if (lines_read < strip->y_size)
|
420
|
+
/*record state */
|
421
|
+
ocr_state = OCS_READING_STRIPS;
|
422
|
+
else
|
423
|
+
ocr_state = OCS_READ_STRIPS;
|
424
|
+
|
425
|
+
return strip;
|
426
|
+
}
|
427
|
+
|
428
|
+
|
429
|
+
/**********************************************************************
|
430
|
+
* ocr_setup_monitor
|
431
|
+
*
|
432
|
+
* Setup the progress monitor. Call before starting the recognize task.
|
433
|
+
**********************************************************************/
|
434
|
+
|
435
|
+
ETEXT_DESC *ocr_setup_monitor() { /*setup monitor */
|
436
|
+
ETEXT_DESC *monitor; /*progress monitor */
|
437
|
+
|
438
|
+
/*text info */
|
439
|
+
monitor = (ETEXT_DESC *) shm.shm_mem;
|
440
|
+
monitor->count = 0; /*chars in this buffer(-1) */
|
441
|
+
monitor->progress = 0; /*percent complete increasing (0-100) */
|
442
|
+
monitor->more_to_come = TRUE; /*text not complete */
|
443
|
+
monitor->ocr_alive = TRUE; /*ocr sets to 1, hp 0 */
|
444
|
+
monitor->err_code = 0; /*used by ocr_error */
|
445
|
+
monitor->cancel = FALSE; /*0=continue, 1=cancel */
|
446
|
+
|
447
|
+
|
448
|
+
//by jetsoft
|
449
|
+
//the sem functions are old and were meant for an hp product
|
450
|
+
// if (release_ocr () != OKAY)
|
451
|
+
// return NULL; /*release failed */
|
452
|
+
|
453
|
+
ocr_state = OCS_RECOGNIZING; /*record state */
|
454
|
+
return monitor;
|
455
|
+
}
|
456
|
+
|
457
|
+
|
458
|
+
/**********************************************************************
|
459
|
+
* ocr_char_space
|
460
|
+
*
|
461
|
+
* Return the number of chars that can be fitted into the buffer.
|
462
|
+
**********************************************************************/
|
463
|
+
|
464
|
+
inT32 ocr_char_space() { /*put char into shm */
|
465
|
+
ETEXT_DESC *buf; /*text buffer */
|
466
|
+
int result;
|
467
|
+
|
468
|
+
/*progress info */
|
469
|
+
buf = (ETEXT_DESC *) shm.shm_mem;
|
470
|
+
if (buf == NULL)
|
471
|
+
return 0;
|
472
|
+
|
473
|
+
result =
|
474
|
+
(shm.shm_size - sizeof (ETEXT_DESC)) / sizeof (EANYCODE_CHAR) -
|
475
|
+
buf->count + 1;
|
476
|
+
|
477
|
+
// while (buf->hp_alive==-1)
|
478
|
+
// Sleep(50); /*wait for HP*/
|
479
|
+
|
480
|
+
return result;
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
/**********************************************************************
|
485
|
+
* ocr_append_char
|
486
|
+
*
|
487
|
+
* Add a character to the output. Returns OKAY if successful, OCR_API_NO_MEM
|
488
|
+
* if there was insufficient room in the buffer.
|
489
|
+
**********************************************************************/
|
490
|
+
|
491
|
+
inT16 ocr_append_char( /*put char into shm */
|
492
|
+
uinT16 char_code, /*character itself */
|
493
|
+
inT16 left, /*of char (-1) */
|
494
|
+
inT16 right, /*of char (-1) */
|
495
|
+
inT16 top, /*of char (-1) */
|
496
|
+
inT16 bottom, /*of char (-1) */
|
497
|
+
inT16 font_index, /*what font (-1) */
|
498
|
+
uinT8 confidence, /*0=perfect, 100=reject (0/100) */
|
499
|
+
uinT8 point_size, /*of char, 72=i inch, (10) */
|
500
|
+
inT8 blanks, /*no of spaces before this char (1) */
|
501
|
+
uinT8 enhancement, /*char enhancement (0) */
|
502
|
+
OCR_CHAR_DIRECTION text_dir, /*rendering direction (OCR_CDIR_RIGHT_LEFT) */
|
503
|
+
OCR_LINE_DIRECTION line_dir, /*line rendering direction (OCR_LDIR_DOWN_RIGHT) */
|
504
|
+
OCR_NEWLINE_TYPE nl_type /*type of newline (if any) (OCR_NL_NONE) */
|
505
|
+
) {
|
506
|
+
ETEXT_DESC *buf; /*text buffer */
|
507
|
+
int index; /*char index */
|
508
|
+
inT16 result; /*of callback */
|
509
|
+
|
510
|
+
if (ocr_state != OCS_RECOGNIZING && ocr_state != OCS_SENDING_TEXT) {
|
511
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
512
|
+
return OCR_API_BAD_STATE; /*incorrect state */
|
513
|
+
}
|
514
|
+
|
515
|
+
if (char_code == ' ' || char_code == '\n' || char_code == '\r'
|
516
|
+
|| char_code == '\t')
|
517
|
+
return OCR_API_BAD_CHAR; /*illegal char */
|
518
|
+
|
519
|
+
/*progress info */
|
520
|
+
buf = (ETEXT_DESC *) shm.shm_mem;
|
521
|
+
|
522
|
+
result =
|
523
|
+
(shm.shm_size - sizeof (ETEXT_DESC)) / sizeof (EANYCODE_CHAR) -
|
524
|
+
buf->count;
|
525
|
+
if (result < 1)
|
526
|
+
return OCR_API_NO_MEM; /*insufficient room */
|
527
|
+
|
528
|
+
index = buf->count++; /*count of chars */
|
529
|
+
/*setup structure */
|
530
|
+
buf->text[index].char_code = char_code;
|
531
|
+
buf->text[index].left = left; /*setup structure */
|
532
|
+
buf->text[index].right = right;/*setup structure */
|
533
|
+
buf->text[index].top = top; /*setup structure */
|
534
|
+
/*setup structure */
|
535
|
+
buf->text[index].bottom = bottom;
|
536
|
+
/*setup structure */
|
537
|
+
buf->text[index].font_index = font_index;
|
538
|
+
/*setup structure */
|
539
|
+
buf->text[index].confidence = confidence;
|
540
|
+
/*setup structure */
|
541
|
+
buf->text[index].point_size = point_size;
|
542
|
+
/*setup structure */
|
543
|
+
buf->text[index].blanks = blanks;
|
544
|
+
if (nl_type == OCR_NL_NONE) {
|
545
|
+
if (text_dir == OCR_CDIR_TOP_BOTTOM || text_dir == OCR_CDIR_BOTTOM_TOP)
|
546
|
+
buf->text[index].formatting = (text_dir << 5) | 128;
|
547
|
+
/*setup structure */
|
548
|
+
else
|
549
|
+
/*setup structure */
|
550
|
+
buf->text[index].formatting = text_dir << 5;
|
551
|
+
}
|
552
|
+
else {
|
553
|
+
buf->text[index].formatting = (nl_type << 6) | (line_dir << 5);
|
554
|
+
/*setup structure */
|
555
|
+
}
|
556
|
+
buf->text[index].formatting |= enhancement & (~EUC_FORMAT_MASK);
|
557
|
+
return OKAY;
|
558
|
+
}
|
559
|
+
|
560
|
+
|
561
|
+
/**********************************************************************
|
562
|
+
* ocr_send_text
|
563
|
+
*
|
564
|
+
* Send the text to the host and wait for the ack.
|
565
|
+
* Use this function after a sequence of ocr_append_char calls to
|
566
|
+
* actually sent the text to the master process.
|
567
|
+
* Set more to come TRUE if there is more text in this page, FALSE
|
568
|
+
* if the OCR engine is now ready to receive another image.
|
569
|
+
**********************************************************************/
|
570
|
+
|
571
|
+
inT16 ocr_send_text( /*send shm */
|
572
|
+
BOOL8 more_to_come /*any text left */
|
573
|
+
) {
|
574
|
+
ETEXT_DESC *buf; /*text buffer */
|
575
|
+
|
576
|
+
if (ocr_state != OCS_RECOGNIZING && ocr_state != OCS_SENDING_TEXT) {
|
577
|
+
ocr_error(OCR_ERR_BAD_STATE);
|
578
|
+
return OCR_API_BAD_STATE; /*incorrect state */
|
579
|
+
}
|
580
|
+
|
581
|
+
/*progress info */
|
582
|
+
buf = (ETEXT_DESC *) shm.shm_mem;
|
583
|
+
|
584
|
+
/*setup structure */
|
585
|
+
buf->more_to_come = more_to_come;
|
586
|
+
if (more_to_come) {
|
587
|
+
if ((buf->text[buf->count - 1].formatting >> 6) != OCR_NL_NEWLINE
|
588
|
+
&& (buf->text[buf->count - 1].formatting >> 6) != OCR_NL_NEWPARA) {
|
589
|
+
/*force line end */
|
590
|
+
buf->text[buf->count - 1].formatting &= 63;
|
591
|
+
buf->text[buf->count - 1].formatting |= OCR_NL_NEWLINE << 6;
|
592
|
+
}
|
593
|
+
}
|
594
|
+
else {
|
595
|
+
if (buf->count < 1)
|
596
|
+
ocr_append_char ('~', -1, -1, -1, -1, 0, 100, 10, 0,
|
597
|
+
0, OCR_CDIR_RIGHT_LEFT, OCR_LDIR_DOWN_RIGHT,
|
598
|
+
OCR_NL_NEWPARA);
|
599
|
+
/*dummy character */
|
600
|
+
else if ((buf->text[buf->count - 1].formatting >> 6) != OCR_NL_NEWPARA) {
|
601
|
+
/*force para end */
|
602
|
+
buf->text[buf->count - 1].formatting &= 63;
|
603
|
+
buf->text[buf->count - 1].formatting |= OCR_NL_NEWPARA << 6;
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
607
|
+
if (release_ocr () != OKAY)
|
608
|
+
return HPERR; /*release failed */
|
609
|
+
if (wait_for_hp (READTEXT_TIMEOUT) != OKAY)
|
610
|
+
return HPERR;
|
611
|
+
if (more_to_come) {
|
612
|
+
buf->count = 0; /*setup structure */
|
613
|
+
ocr_state = OCS_SENDING_TEXT;/*record state */
|
614
|
+
}
|
615
|
+
else
|
616
|
+
ocr_state = OCS_SETUP_INFO; /*record state */
|
617
|
+
return OKAY;
|
618
|
+
}
|
619
|
+
|
620
|
+
|
621
|
+
/**********************************************************************
|
622
|
+
* ocr_shutdown
|
623
|
+
*
|
624
|
+
* Closedown communications with the HP side and free up handles.
|
625
|
+
**********************************************************************/
|
626
|
+
|
627
|
+
inT16 ocr_shutdown() { /*closedown */
|
628
|
+
#ifdef __MAC__
|
629
|
+
shm.OCRProcess.lowLongOfPSN = kNoProcess;
|
630
|
+
shm.OCRProcess.highLongOfPSN = 0;
|
631
|
+
#endif
|
632
|
+
ocr_error(OCR_ERR_CLEAN_EXIT); /*signal exit */
|
633
|
+
|
634
|
+
return OKAY;
|
635
|
+
}
|
636
|
+
|
637
|
+
|
638
|
+
/**********************************************************************
|
639
|
+
* ocr_internal_shutdown
|
640
|
+
*
|
641
|
+
* Free up handles or whatever to clean up without attempting to communicate.
|
642
|
+
**********************************************************************/
|
643
|
+
|
644
|
+
inT16 ocr_internal_shutdown() { /*closedown */
|
645
|
+
ocr_state = OCS_DEAD; /*record state */
|
646
|
+
#ifdef __MSW32__
|
647
|
+
if (shm.shm_mem != NULL) {
|
648
|
+
UnmapViewOfFile (shm.shm_mem);
|
649
|
+
CloseHandle (shm.shm_hand); /*no longer used */
|
650
|
+
CloseHandle (shm.mutex); /*release handles */
|
651
|
+
CloseHandle (shm.ocr_sem);
|
652
|
+
CloseHandle (shm.hp_sem);
|
653
|
+
shm.shm_mem = NULL;
|
654
|
+
}
|
655
|
+
#elif defined (__MAC__)
|
656
|
+
shm.OCRProcess.lowLongOfPSN = kNoProcess;
|
657
|
+
shm.OCRProcess.highLongOfPSN = 0;
|
658
|
+
#endif
|
659
|
+
return OKAY;
|
660
|
+
}
|
661
|
+
|
662
|
+
|
663
|
+
/**********************************************************************
|
664
|
+
* wait_for_mutex
|
665
|
+
*
|
666
|
+
* Wait for the HP side to release its mutex.
|
667
|
+
* The return value is HPERR if the HP side has terminated.
|
668
|
+
**********************************************************************/
|
669
|
+
|
670
|
+
inT16 wait_for_mutex() { /*wait for HP to be ready */
|
671
|
+
inT16 result = HPERR; /*return code */
|
672
|
+
#if defined (__MSW32__) || defined (__MAC__)
|
673
|
+
result = WaitForSingleObject (shm.mutex, (unsigned long) -1)
|
674
|
+
/*wait for thread to move */
|
675
|
+
/*bad if timeout */
|
676
|
+
== WAIT_OBJECT_0 ? OKAY : HPERR;
|
677
|
+
#endif
|
678
|
+
if (result != OKAY)
|
679
|
+
ocr_internal_shutdown();
|
680
|
+
return result;
|
681
|
+
}
|
682
|
+
|
683
|
+
|
684
|
+
/**********************************************************************
|
685
|
+
* wait_for_hp
|
686
|
+
*
|
687
|
+
* Wait for the HP side to release its semaphore.
|
688
|
+
* The return value is HPERR if the timeout (in seconds) elapsed.
|
689
|
+
**********************************************************************/
|
690
|
+
|
691
|
+
inT16 wait_for_hp( /*wait for semaphore */
|
692
|
+
inT32 timeout /*in seconds */
|
693
|
+
) {
|
694
|
+
inT16 result = HPERR; /*return code */
|
695
|
+
#if defined (__MSW32__) || defined (__MAC__)
|
696
|
+
/*wait for thread to move */
|
697
|
+
result = WaitForSingleObject (shm.hp_sem, timeout * TICKS)
|
698
|
+
/*bad if timeout */
|
699
|
+
== WAIT_OBJECT_0 ? OKAY : HPERR;
|
700
|
+
#endif
|
701
|
+
if (result != OKAY)
|
702
|
+
ocr_internal_shutdown();
|
703
|
+
return result;
|
704
|
+
}
|
705
|
+
|
706
|
+
|
707
|
+
/**********************************************************************
|
708
|
+
* release_mutex
|
709
|
+
*
|
710
|
+
* Release the HP mutex.
|
711
|
+
* The return value is OKAY if the call succeeds.
|
712
|
+
**********************************************************************/
|
713
|
+
|
714
|
+
inT16 release_mutex() { /*release mutex */
|
715
|
+
inT16 result = HPERR; /*return code */
|
716
|
+
#ifdef __MSW32__
|
717
|
+
/*release it */
|
718
|
+
result = ReleaseMutex (shm.mutex) ? OKAY : HPERR;
|
719
|
+
#elif defined (__MAC__)
|
720
|
+
/*release it */
|
721
|
+
result = ReleaseSemaphore (shm.mutex) ? OKAY : HPERR;
|
722
|
+
#endif
|
723
|
+
if (result != OKAY)
|
724
|
+
ocr_internal_shutdown();
|
725
|
+
return result;
|
726
|
+
}
|
727
|
+
|
728
|
+
|
729
|
+
/**********************************************************************
|
730
|
+
* release_ocr
|
731
|
+
*
|
732
|
+
* Release the OCR semaphore.
|
733
|
+
* The return value is OKAY if the call succeeds.
|
734
|
+
**********************************************************************/
|
735
|
+
|
736
|
+
inT16 release_ocr() { /*release semaphore */
|
737
|
+
inT32 timeout; //time allowed
|
738
|
+
|
739
|
+
timeout = RELEASE_TIMEOUT * TICKS;
|
740
|
+
#ifdef __MSW32__
|
741
|
+
|
742
|
+
//jetsoft
|
743
|
+
// this stuff is old and no longer applies
|
744
|
+
|
745
|
+
return OKAY;
|
746
|
+
//
|
747
|
+
|
748
|
+
BOOL result = 0; //of release
|
749
|
+
do {
|
750
|
+
//release it
|
751
|
+
result = ReleaseSemaphore (shm.ocr_sem, 1, NULL);
|
752
|
+
if (result == FALSE) {
|
753
|
+
timeout -= 50;
|
754
|
+
Sleep (50);
|
755
|
+
}
|
756
|
+
}
|
757
|
+
while (result == FALSE && timeout > 0);
|
758
|
+
if (!result)
|
759
|
+
ocr_internal_shutdown();
|
760
|
+
return OKAY;
|
761
|
+
#elif defined (__MAC__)
|
762
|
+
inT16 result = HPERR; /*return code */
|
763
|
+
/*release it */
|
764
|
+
result = ReleaseSemaphore (shm.ocr_sem) ? OKAY : HPERR;
|
765
|
+
|
766
|
+
if (result != OKAY)
|
767
|
+
ocr_internal_shutdown();
|
768
|
+
return result;
|
769
|
+
#elif defined (__UNIX__)
|
770
|
+
return 0;
|
771
|
+
#endif
|
772
|
+
}
|