tesseract_bin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,1524 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
** Filename: intmatcher.c
|
|
3
|
+
** Purpose: Generic high level classification routines.
|
|
4
|
+
** Author: Robert Moss
|
|
5
|
+
** History: Wed Feb 13 17:35:28 MST 1991, RWM, Created.
|
|
6
|
+
** Mon Mar 11 16:33:02 MST 1991, RWM, Modified to add
|
|
7
|
+
** support for adaptive matching.
|
|
8
|
+
** (c) Copyright Hewlett-Packard Company, 1988.
|
|
9
|
+
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
** you may not use this file except in compliance with the License.
|
|
11
|
+
** You may obtain a copy of the License at
|
|
12
|
+
** http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
** Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
** See the License for the specific language governing permissions and
|
|
17
|
+
** limitations under the License.
|
|
18
|
+
******************************************************************************/
|
|
19
|
+
/**----------------------------------------------------------------------------
|
|
20
|
+
Include Files and Type Defines
|
|
21
|
+
----------------------------------------------------------------------------**/
|
|
22
|
+
#include "intmatcher.h"
|
|
23
|
+
#include "tordvars.h"
|
|
24
|
+
#include "callcpp.h"
|
|
25
|
+
#include "scrollview.h"
|
|
26
|
+
#include "globals.h"
|
|
27
|
+
#include <math.h>
|
|
28
|
+
|
|
29
|
+
#define CLASS_MASK_SIZE ((MAX_NUM_CLASSES*NUM_BITS_PER_CLASS \
|
|
30
|
+
+BITS_PER_WERD-1)/BITS_PER_WERD)
|
|
31
|
+
|
|
32
|
+
/**----------------------------------------------------------------------------
|
|
33
|
+
Global Data Definitions and Declarations
|
|
34
|
+
----------------------------------------------------------------------------**/
|
|
35
|
+
#define SE_TABLE_BITS 9
|
|
36
|
+
#define SE_TABLE_SIZE 512
|
|
37
|
+
#define TEMPLATE_CACHE 2
|
|
38
|
+
static uinT8 SimilarityEvidenceTable[SE_TABLE_SIZE];
|
|
39
|
+
static uinT8 offset_table[256] = {
|
|
40
|
+
255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
41
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
42
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
43
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
44
|
+
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
45
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
46
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
47
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
48
|
+
7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
49
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
50
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
51
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
52
|
+
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
53
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
54
|
+
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
|
55
|
+
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
|
|
56
|
+
};
|
|
57
|
+
static uinT8 next_table[256] = {
|
|
58
|
+
0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6, 0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e,
|
|
59
|
+
0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16, 0x10, 0x18, 0x18, 0x1a, 0x18,
|
|
60
|
+
0x1c, 0x1c, 0x1e,
|
|
61
|
+
0, 0x20, 0x20, 0x22, 0x20, 0x24, 0x24, 0x26, 0x20, 0x28, 0x28, 0x2a, 0x28,
|
|
62
|
+
0x2c, 0x2c, 0x2e,
|
|
63
|
+
0x20, 0x30, 0x30, 0x32, 0x30, 0x34, 0x34, 0x36, 0x30, 0x38, 0x38, 0x3a,
|
|
64
|
+
0x38, 0x3c, 0x3c, 0x3e,
|
|
65
|
+
0, 0x40, 0x40, 0x42, 0x40, 0x44, 0x44, 0x46, 0x40, 0x48, 0x48, 0x4a, 0x48,
|
|
66
|
+
0x4c, 0x4c, 0x4e,
|
|
67
|
+
0x40, 0x50, 0x50, 0x52, 0x50, 0x54, 0x54, 0x56, 0x50, 0x58, 0x58, 0x5a,
|
|
68
|
+
0x58, 0x5c, 0x5c, 0x5e,
|
|
69
|
+
0x40, 0x60, 0x60, 0x62, 0x60, 0x64, 0x64, 0x66, 0x60, 0x68, 0x68, 0x6a,
|
|
70
|
+
0x68, 0x6c, 0x6c, 0x6e,
|
|
71
|
+
0x60, 0x70, 0x70, 0x72, 0x70, 0x74, 0x74, 0x76, 0x70, 0x78, 0x78, 0x7a,
|
|
72
|
+
0x78, 0x7c, 0x7c, 0x7e,
|
|
73
|
+
0, 0x80, 0x80, 0x82, 0x80, 0x84, 0x84, 0x86, 0x80, 0x88, 0x88, 0x8a, 0x88,
|
|
74
|
+
0x8c, 0x8c, 0x8e,
|
|
75
|
+
0x80, 0x90, 0x90, 0x92, 0x90, 0x94, 0x94, 0x96, 0x90, 0x98, 0x98, 0x9a,
|
|
76
|
+
0x98, 0x9c, 0x9c, 0x9e,
|
|
77
|
+
0x80, 0xa0, 0xa0, 0xa2, 0xa0, 0xa4, 0xa4, 0xa6, 0xa0, 0xa8, 0xa8, 0xaa,
|
|
78
|
+
0xa8, 0xac, 0xac, 0xae,
|
|
79
|
+
0xa0, 0xb0, 0xb0, 0xb2, 0xb0, 0xb4, 0xb4, 0xb6, 0xb0, 0xb8, 0xb8, 0xba,
|
|
80
|
+
0xb8, 0xbc, 0xbc, 0xbe,
|
|
81
|
+
0x80, 0xc0, 0xc0, 0xc2, 0xc0, 0xc4, 0xc4, 0xc6, 0xc0, 0xc8, 0xc8, 0xca,
|
|
82
|
+
0xc8, 0xcc, 0xcc, 0xce,
|
|
83
|
+
0xc0, 0xd0, 0xd0, 0xd2, 0xd0, 0xd4, 0xd4, 0xd6, 0xd0, 0xd8, 0xd8, 0xda,
|
|
84
|
+
0xd8, 0xdc, 0xdc, 0xde,
|
|
85
|
+
0xc0, 0xe0, 0xe0, 0xe2, 0xe0, 0xe4, 0xe4, 0xe6, 0xe0, 0xe8, 0xe8, 0xea,
|
|
86
|
+
0xe8, 0xec, 0xec, 0xee,
|
|
87
|
+
0xe0, 0xf0, 0xf0, 0xf2, 0xf0, 0xf4, 0xf4, 0xf6, 0xf0, 0xf8, 0xf8, 0xfa,
|
|
88
|
+
0xf8, 0xfc, 0xfc, 0xfe
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
static uinT32 EvidenceTableMask;
|
|
92
|
+
|
|
93
|
+
static uinT32 MultTruncShiftBits;
|
|
94
|
+
|
|
95
|
+
static uinT32 TableTruncShiftBits;
|
|
96
|
+
|
|
97
|
+
uinT32 EvidenceMultMask;
|
|
98
|
+
|
|
99
|
+
static inT16 LocalMatcherMultiplier;
|
|
100
|
+
|
|
101
|
+
make_int_var (ClassPrunerThreshold, 229, MakeClassPrunerThreshold,
|
|
102
|
+
16, 20, SetClassPrunerThreshold,
|
|
103
|
+
"Class Pruner Threshold 0-255: ");
|
|
104
|
+
|
|
105
|
+
make_int_var (ClassPrunerMultiplier, 30, MakeClassPrunerMultiplier,
|
|
106
|
+
16, 21, SetClassPrunerMultiplier,
|
|
107
|
+
"Class Pruner Multiplier 0-255: ");
|
|
108
|
+
|
|
109
|
+
make_int_var (IntegerMatcherMultiplier, 14, MakeIntegerMatcherMultiplier,
|
|
110
|
+
16, 22, SetIntegerMatcherMultiplier,
|
|
111
|
+
"Integer Matcher Multiplier 0-255: ");
|
|
112
|
+
|
|
113
|
+
make_int_var (IntThetaFudge, 128, MakeIntThetaFudge,
|
|
114
|
+
16, 23, SetIntThetaFudge,
|
|
115
|
+
"Integer Matcher Theta Fudge 0-255: ");
|
|
116
|
+
|
|
117
|
+
make_int_var (CPCutoffStrength, 7, MakeCPCutoffStrength,
|
|
118
|
+
16, 24, SetCPCutoffStrength,
|
|
119
|
+
"Class Pruner CutoffStrength: ");
|
|
120
|
+
|
|
121
|
+
make_int_var (EvidenceTableBits, 9, MakeEvidenceTableBits,
|
|
122
|
+
16, 25, SetEvidenceTableBits,
|
|
123
|
+
"Bits in Similarity to Evidence Lookup 8-9: ");
|
|
124
|
+
|
|
125
|
+
make_int_var (IntEvidenceTruncBits, 14, MakeIntEvidenceTruncBits,
|
|
126
|
+
16, 26, SetIntEvidenceTruncBits,
|
|
127
|
+
"Integer Evidence Truncation Bits (Distance) 8-14: ");
|
|
128
|
+
|
|
129
|
+
make_float_var (SEExponentialMultiplier, 0, MakeSEExponentialMultiplier,
|
|
130
|
+
16, 27, SetSEExponentialMultiplier,
|
|
131
|
+
"Similarity to Evidence Table Exponential Multiplier: ");
|
|
132
|
+
|
|
133
|
+
make_float_var (SimilarityCenter, 0.0075, MakeSimilarityCenter,
|
|
134
|
+
16, 28, SetSimilarityCenter, "Center of Similarity Curve: ");
|
|
135
|
+
|
|
136
|
+
make_int_var (AdaptProtoThresh, 230, MakeAdaptProtoThresh,
|
|
137
|
+
16, 29, SetAdaptProtoThresh,
|
|
138
|
+
"Threshold for good protos during adaptive 0-255: ");
|
|
139
|
+
|
|
140
|
+
make_int_var (AdaptFeatureThresh, 230, MakeAdaptFeatureThresh,
|
|
141
|
+
16, 30, SetAdaptFeatureThresh,
|
|
142
|
+
"Threshold for good features during adaptive 0-255: ");
|
|
143
|
+
//extern int display_ratings;
|
|
144
|
+
//extern inT32 cp_maps[4];
|
|
145
|
+
|
|
146
|
+
int protoword_lookups;
|
|
147
|
+
int zero_protowords;
|
|
148
|
+
int proto_shifts;
|
|
149
|
+
int set_proto_bits;
|
|
150
|
+
int config_shifts;
|
|
151
|
+
int set_config_bits;
|
|
152
|
+
|
|
153
|
+
/**----------------------------------------------------------------------------
|
|
154
|
+
Public Code
|
|
155
|
+
----------------------------------------------------------------------------**/
|
|
156
|
+
/*---------------------------------------------------------------------------*/
|
|
157
|
+
int ClassPruner(INT_TEMPLATES IntTemplates,
|
|
158
|
+
inT16 NumFeatures,
|
|
159
|
+
INT_FEATURE_ARRAY Features,
|
|
160
|
+
CLASS_NORMALIZATION_ARRAY NormalizationFactors,
|
|
161
|
+
CLASS_CUTOFF_ARRAY ExpectedNumFeatures,
|
|
162
|
+
CLASS_PRUNER_RESULTS Results,
|
|
163
|
+
int Debug) {
|
|
164
|
+
/*
|
|
165
|
+
** Parameters:
|
|
166
|
+
** IntTemplates Class pruner tables
|
|
167
|
+
** NumFeatures Number of features in blob
|
|
168
|
+
** Features Array of features
|
|
169
|
+
** NormalizationFactors Array of fudge factors from blob
|
|
170
|
+
** normalization process
|
|
171
|
+
** (by CLASS_INDEX)
|
|
172
|
+
** ExpectedNumFeatures Array of expected number of features
|
|
173
|
+
** for each class
|
|
174
|
+
** (by CLASS_INDEX)
|
|
175
|
+
** Results Sorted Array of pruned classes
|
|
176
|
+
** (by CLASS_ID)
|
|
177
|
+
** Debug Debugger flag: 1=debugger on
|
|
178
|
+
** Globals:
|
|
179
|
+
** ClassPrunerThreshold Cutoff threshold
|
|
180
|
+
** ClassPrunerMultiplier Normalization factor multiplier
|
|
181
|
+
** Operation:
|
|
182
|
+
** Prune the classes using a modified fast match table.
|
|
183
|
+
** Return a sorted list of classes along with the number
|
|
184
|
+
** of pruned classes in that list.
|
|
185
|
+
** Return: Number of pruned classes.
|
|
186
|
+
** Exceptions: none
|
|
187
|
+
** History: Tue Feb 19 10:24:24 MST 1991, RWM, Created.
|
|
188
|
+
*/
|
|
189
|
+
uinT32 PrunerWord;
|
|
190
|
+
inT32 class_index; //index to class
|
|
191
|
+
int Word;
|
|
192
|
+
uinT32 *BasePrunerAddress;
|
|
193
|
+
uinT32 feature_address; //current feature index
|
|
194
|
+
INT_FEATURE feature; //current feature
|
|
195
|
+
CLASS_PRUNER *ClassPruner;
|
|
196
|
+
int PrunerSet;
|
|
197
|
+
int NumPruners;
|
|
198
|
+
inT32 feature_index; //current feature
|
|
199
|
+
|
|
200
|
+
static int ClassCount[MAX_NUM_CLASSES];
|
|
201
|
+
static int NormCount[MAX_NUM_CLASSES];
|
|
202
|
+
static int SortKey[MAX_NUM_CLASSES + 1];
|
|
203
|
+
static int SortIndex[MAX_NUM_CLASSES + 1];
|
|
204
|
+
CLASS_INDEX Class;
|
|
205
|
+
int out_class;
|
|
206
|
+
int MaxNumClasses;
|
|
207
|
+
int MaxCount;
|
|
208
|
+
int NumClasses;
|
|
209
|
+
FLOAT32 max_rating; //max allowed rating
|
|
210
|
+
int *ClassCountPtr;
|
|
211
|
+
CLASS_ID classch;
|
|
212
|
+
|
|
213
|
+
MaxNumClasses = IntTemplates->NumClasses;
|
|
214
|
+
|
|
215
|
+
/* Clear Class Counts */
|
|
216
|
+
ClassCountPtr = &(ClassCount[0]);
|
|
217
|
+
for (Class = 0; Class < MaxNumClasses; Class++) {
|
|
218
|
+
*ClassCountPtr++ = 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Update Class Counts */
|
|
222
|
+
NumPruners = IntTemplates->NumClassPruners;
|
|
223
|
+
for (feature_index = 0; feature_index < NumFeatures; feature_index++) {
|
|
224
|
+
feature = &Features[feature_index];
|
|
225
|
+
feature_address = (((feature->X * NUM_CP_BUCKETS >> 8) * NUM_CP_BUCKETS
|
|
226
|
+
+
|
|
227
|
+
(feature->Y * NUM_CP_BUCKETS >> 8)) *
|
|
228
|
+
NUM_CP_BUCKETS +
|
|
229
|
+
(feature->Theta * NUM_CP_BUCKETS >> 8)) << 1;
|
|
230
|
+
ClassPruner = IntTemplates->ClassPruner;
|
|
231
|
+
class_index = 0;
|
|
232
|
+
for (PrunerSet = 0; PrunerSet < NumPruners; PrunerSet++, ClassPruner++) {
|
|
233
|
+
BasePrunerAddress = (uinT32 *) (*ClassPruner) + feature_address;
|
|
234
|
+
|
|
235
|
+
for (Word = 0; Word < WERDS_PER_CP_VECTOR; Word++) {
|
|
236
|
+
PrunerWord = *BasePrunerAddress++;
|
|
237
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
238
|
+
PrunerWord >>= 2;
|
|
239
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
240
|
+
PrunerWord >>= 2;
|
|
241
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
242
|
+
PrunerWord >>= 2;
|
|
243
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
244
|
+
PrunerWord >>= 2;
|
|
245
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
246
|
+
PrunerWord >>= 2;
|
|
247
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
248
|
+
PrunerWord >>= 2;
|
|
249
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
250
|
+
PrunerWord >>= 2;
|
|
251
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
252
|
+
PrunerWord >>= 2;
|
|
253
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
254
|
+
PrunerWord >>= 2;
|
|
255
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
256
|
+
PrunerWord >>= 2;
|
|
257
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
258
|
+
PrunerWord >>= 2;
|
|
259
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
260
|
+
PrunerWord >>= 2;
|
|
261
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
262
|
+
PrunerWord >>= 2;
|
|
263
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
264
|
+
PrunerWord >>= 2;
|
|
265
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
266
|
+
PrunerWord >>= 2;
|
|
267
|
+
ClassCount[class_index++] += cp_maps[PrunerWord & 3];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* Adjust Class Counts for Number of Expected Features */
|
|
273
|
+
for (Class = 0; Class < MaxNumClasses; Class++) {
|
|
274
|
+
if (NumFeatures < ExpectedNumFeatures[Class]) {
|
|
275
|
+
int deficit = ExpectedNumFeatures[Class] - NumFeatures;
|
|
276
|
+
ClassCount[Class] -= ClassCount[Class] * deficit /
|
|
277
|
+
(NumFeatures*CPCutoffStrength + deficit);
|
|
278
|
+
}
|
|
279
|
+
if (!unicharset.get_enabled(IntTemplates->ClassIdFor[Class]))
|
|
280
|
+
ClassCount[Class] = 0; // This char is disabled!
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* Adjust Class Counts for Normalization Factors */
|
|
284
|
+
MaxCount = 0;
|
|
285
|
+
for (Class = 0; Class < MaxNumClasses; Class++) {
|
|
286
|
+
NormCount[Class] = ClassCount[Class]
|
|
287
|
+
- ((ClassPrunerMultiplier * NormalizationFactors[Class]) >> 8)
|
|
288
|
+
* cp_maps[3] / 3;
|
|
289
|
+
if (NormCount[Class] > MaxCount)
|
|
290
|
+
MaxCount = NormCount[Class];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* Prune Classes */
|
|
294
|
+
MaxCount *= ClassPrunerThreshold;
|
|
295
|
+
MaxCount >>= 8;
|
|
296
|
+
/* Select Classes */
|
|
297
|
+
if (MaxCount < 1)
|
|
298
|
+
MaxCount = 1;
|
|
299
|
+
NumClasses = 0;
|
|
300
|
+
for (Class = 0; Class < MaxNumClasses; Class++)
|
|
301
|
+
if (NormCount[Class] >= MaxCount) {
|
|
302
|
+
NumClasses++;
|
|
303
|
+
SortIndex[NumClasses] = Class;
|
|
304
|
+
SortKey[NumClasses] = NormCount[Class];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/* Sort Classes using Heapsort Algorithm */
|
|
308
|
+
if (NumClasses > 1)
|
|
309
|
+
HeapSort(NumClasses, SortKey, SortIndex);
|
|
310
|
+
|
|
311
|
+
if (display_ratings > 1) {
|
|
312
|
+
cprintf ("CP:%d classes, %d features:\n", NumClasses, NumFeatures);
|
|
313
|
+
for (Class = 0; Class < NumClasses; Class++) {
|
|
314
|
+
classch = IntTemplates->ClassIdFor[SortIndex[NumClasses - Class]];
|
|
315
|
+
cprintf ("%s:C=%d, E=%d, N=%d, Rat=%d\n",
|
|
316
|
+
unicharset.id_to_unichar(classch),
|
|
317
|
+
ClassCount[SortIndex[NumClasses - Class]],
|
|
318
|
+
ExpectedNumFeatures[SortIndex[NumClasses - Class]],
|
|
319
|
+
SortKey[NumClasses - Class],
|
|
320
|
+
1010 - 1000 * SortKey[NumClasses - Class] /
|
|
321
|
+
(cp_maps[3] * NumFeatures));
|
|
322
|
+
}
|
|
323
|
+
if (display_ratings > 2) {
|
|
324
|
+
NumPruners = IntTemplates->NumClassPruners;
|
|
325
|
+
for (feature_index = 0; feature_index < NumFeatures;
|
|
326
|
+
feature_index++) {
|
|
327
|
+
cprintf ("F=%3d,", feature_index);
|
|
328
|
+
feature = &Features[feature_index];
|
|
329
|
+
feature_address =
|
|
330
|
+
(((feature->X * NUM_CP_BUCKETS >> 8) * NUM_CP_BUCKETS +
|
|
331
|
+
(feature->Y * NUM_CP_BUCKETS >> 8)) * NUM_CP_BUCKETS +
|
|
332
|
+
(feature->Theta * NUM_CP_BUCKETS >> 8)) << 1;
|
|
333
|
+
ClassPruner = IntTemplates->ClassPruner;
|
|
334
|
+
class_index = 0;
|
|
335
|
+
for (PrunerSet = 0; PrunerSet < NumPruners;
|
|
336
|
+
PrunerSet++, ClassPruner++) {
|
|
337
|
+
BasePrunerAddress = (uinT32 *) (*ClassPruner)
|
|
338
|
+
+ feature_address;
|
|
339
|
+
|
|
340
|
+
for (Word = 0; Word < WERDS_PER_CP_VECTOR; Word++) {
|
|
341
|
+
PrunerWord = *BasePrunerAddress++;
|
|
342
|
+
for (Class = 0; Class < 16; Class++, class_index++) {
|
|
343
|
+
if (NormCount[class_index] >= MaxCount)
|
|
344
|
+
cprintf (" %s=%d,",
|
|
345
|
+
unicharset.id_to_unichar(IntTemplates->ClassIdFor[class_index]),
|
|
346
|
+
PrunerWord & 3);
|
|
347
|
+
PrunerWord >>= 2;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
cprintf ("\n");
|
|
352
|
+
}
|
|
353
|
+
cprintf ("Adjustments:");
|
|
354
|
+
for (Class = 0; Class < MaxNumClasses; Class++) {
|
|
355
|
+
if (NormCount[Class] > MaxCount)
|
|
356
|
+
cprintf (" %s=%d,",
|
|
357
|
+
unicharset.id_to_unichar(IntTemplates->ClassIdFor[Class]),
|
|
358
|
+
-((ClassPrunerMultiplier *
|
|
359
|
+
NormalizationFactors[Class]) >> 8) * cp_maps[3] /
|
|
360
|
+
3);
|
|
361
|
+
}
|
|
362
|
+
cprintf ("\n");
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/* Set Up Results */
|
|
367
|
+
max_rating = 0.0f;
|
|
368
|
+
for (Class = 0, out_class = 0; Class < NumClasses; Class++) {
|
|
369
|
+
Results[out_class].Class =
|
|
370
|
+
IntTemplates->ClassIdFor[SortIndex[NumClasses - Class]];
|
|
371
|
+
Results[out_class].Rating =
|
|
372
|
+
1.0 - SortKey[NumClasses -
|
|
373
|
+
Class] / ((float) cp_maps[3] * NumFeatures);
|
|
374
|
+
out_class++;
|
|
375
|
+
}
|
|
376
|
+
NumClasses = out_class;
|
|
377
|
+
return NumClasses;
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
/*---------------------------------------------------------------------------*/
|
|
383
|
+
void IntegerMatcher(INT_CLASS ClassTemplate,
|
|
384
|
+
BIT_VECTOR ProtoMask,
|
|
385
|
+
BIT_VECTOR ConfigMask,
|
|
386
|
+
uinT16 BlobLength,
|
|
387
|
+
inT16 NumFeatures,
|
|
388
|
+
INT_FEATURE_ARRAY Features,
|
|
389
|
+
uinT8 NormalizationFactor,
|
|
390
|
+
INT_RESULT Result,
|
|
391
|
+
int Debug) {
|
|
392
|
+
/*
|
|
393
|
+
** Parameters:
|
|
394
|
+
** ClassTemplate Prototypes & tables for a class
|
|
395
|
+
** BlobLength Length of unormalized blob
|
|
396
|
+
** NumFeatures Number of features in blob
|
|
397
|
+
** Features Array of features
|
|
398
|
+
** NormalizationFactor Fudge factor from blob
|
|
399
|
+
** normalization process
|
|
400
|
+
** Result Class rating & configuration:
|
|
401
|
+
** (0.0 -> 1.0), 0=good, 1=bad
|
|
402
|
+
** Debug Debugger flag: 1=debugger on
|
|
403
|
+
** Globals:
|
|
404
|
+
** LocalMatcherMultiplier Normalization factor multiplier
|
|
405
|
+
** IntThetaFudge Theta fudge factor used for
|
|
406
|
+
** evidence calculation
|
|
407
|
+
** Operation:
|
|
408
|
+
** IntegerMatcher returns the best configuration and rating
|
|
409
|
+
** for a single class. The class matched against is determined
|
|
410
|
+
** by the uniqueness of the ClassTemplate parameter. The
|
|
411
|
+
** best rating and its associated configuration are returned.
|
|
412
|
+
** Return:
|
|
413
|
+
** Exceptions: none
|
|
414
|
+
** History: Tue Feb 19 16:36:23 MST 1991, RWM, Created.
|
|
415
|
+
*/
|
|
416
|
+
static uinT8 FeatureEvidence[MAX_NUM_CONFIGS];
|
|
417
|
+
static int SumOfFeatureEvidence[MAX_NUM_CONFIGS];
|
|
418
|
+
static uinT8 ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX];
|
|
419
|
+
int Feature;
|
|
420
|
+
int BestMatch;
|
|
421
|
+
|
|
422
|
+
if (MatchDebuggingOn (Debug))
|
|
423
|
+
cprintf ("Integer Matcher -------------------------------------------\n");
|
|
424
|
+
|
|
425
|
+
IMClearTables(ClassTemplate, SumOfFeatureEvidence, ProtoEvidence);
|
|
426
|
+
Result->FeatureMisses = 0;
|
|
427
|
+
|
|
428
|
+
for (Feature = 0; Feature < NumFeatures; Feature++) {
|
|
429
|
+
int csum = IMUpdateTablesForFeature(ClassTemplate, ProtoMask, ConfigMask,
|
|
430
|
+
Feature, &(Features[Feature]),
|
|
431
|
+
FeatureEvidence, SumOfFeatureEvidence,
|
|
432
|
+
ProtoEvidence, Debug);
|
|
433
|
+
// Count features that were missed over all configs.
|
|
434
|
+
if (csum == 0)
|
|
435
|
+
Result->FeatureMisses++;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
#ifndef GRAPHICS_DISABLED
|
|
439
|
+
if (PrintProtoMatchesOn (Debug) || PrintMatchSummaryOn (Debug))
|
|
440
|
+
IMDebugFeatureProtoError(ClassTemplate,
|
|
441
|
+
ProtoMask,
|
|
442
|
+
ConfigMask,
|
|
443
|
+
SumOfFeatureEvidence,
|
|
444
|
+
ProtoEvidence,
|
|
445
|
+
NumFeatures,
|
|
446
|
+
Debug);
|
|
447
|
+
|
|
448
|
+
if (DisplayProtoMatchesOn (Debug))
|
|
449
|
+
IMDisplayProtoDebugInfo(ClassTemplate,
|
|
450
|
+
ProtoMask,
|
|
451
|
+
ConfigMask,
|
|
452
|
+
ProtoEvidence,
|
|
453
|
+
Debug);
|
|
454
|
+
|
|
455
|
+
if (DisplayFeatureMatchesOn (Debug))
|
|
456
|
+
IMDisplayFeatureDebugInfo(ClassTemplate,
|
|
457
|
+
ProtoMask,
|
|
458
|
+
ConfigMask,
|
|
459
|
+
NumFeatures,
|
|
460
|
+
Features,
|
|
461
|
+
Debug);
|
|
462
|
+
#endif
|
|
463
|
+
|
|
464
|
+
IMUpdateSumOfProtoEvidences(ClassTemplate,
|
|
465
|
+
ConfigMask,
|
|
466
|
+
SumOfFeatureEvidence,
|
|
467
|
+
ProtoEvidence,
|
|
468
|
+
NumFeatures);
|
|
469
|
+
|
|
470
|
+
IMNormalizeSumOfEvidences(ClassTemplate,
|
|
471
|
+
SumOfFeatureEvidence,
|
|
472
|
+
NumFeatures,
|
|
473
|
+
NumFeatures);
|
|
474
|
+
|
|
475
|
+
BestMatch =
|
|
476
|
+
IMFindBestMatch(ClassTemplate,
|
|
477
|
+
SumOfFeatureEvidence,
|
|
478
|
+
BlobLength,
|
|
479
|
+
NormalizationFactor,
|
|
480
|
+
Result);
|
|
481
|
+
|
|
482
|
+
#ifndef GRAPHICS_DISABLED
|
|
483
|
+
if (PrintMatchSummaryOn (Debug))
|
|
484
|
+
IMDebugBestMatch(BestMatch, Result, BlobLength, NormalizationFactor);
|
|
485
|
+
|
|
486
|
+
if (MatchDebuggingOn (Debug))
|
|
487
|
+
cprintf ("Match Complete --------------------------------------------\n");
|
|
488
|
+
#endif
|
|
489
|
+
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
/*---------------------------------------------------------------------------*/
|
|
494
|
+
int FindGoodProtos(INT_CLASS ClassTemplate,
|
|
495
|
+
BIT_VECTOR ProtoMask,
|
|
496
|
+
BIT_VECTOR ConfigMask,
|
|
497
|
+
uinT16 BlobLength,
|
|
498
|
+
inT16 NumFeatures,
|
|
499
|
+
INT_FEATURE_ARRAY Features,
|
|
500
|
+
PROTO_ID *ProtoArray,
|
|
501
|
+
int Debug) {
|
|
502
|
+
/*
|
|
503
|
+
** Parameters:
|
|
504
|
+
** ClassTemplate Prototypes & tables for a class
|
|
505
|
+
** ProtoMask AND Mask for proto word
|
|
506
|
+
** ConfigMask AND Mask for config word
|
|
507
|
+
** BlobLength Length of unormalized blob
|
|
508
|
+
** NumFeatures Number of features in blob
|
|
509
|
+
** Features Array of features
|
|
510
|
+
** ProtoArray Array of good protos
|
|
511
|
+
** Debug Debugger flag: 1=debugger on
|
|
512
|
+
** Globals:
|
|
513
|
+
** LocalMatcherMultiplier Normalization factor multiplier
|
|
514
|
+
** IntThetaFudge Theta fudge factor used for
|
|
515
|
+
** evidence calculation
|
|
516
|
+
** AdaptProtoThresh Threshold for good protos
|
|
517
|
+
** Operation:
|
|
518
|
+
** FindGoodProtos finds all protos whose normalized proto-evidence
|
|
519
|
+
** exceed AdaptProtoThresh. The list is ordered by increasing
|
|
520
|
+
** proto id number.
|
|
521
|
+
** Return:
|
|
522
|
+
** Number of good protos in ProtoArray.
|
|
523
|
+
** Exceptions: none
|
|
524
|
+
** History: Tue Mar 12 17:09:26 MST 1991, RWM, Created
|
|
525
|
+
*/
|
|
526
|
+
static uinT8 FeatureEvidence[MAX_NUM_CONFIGS];
|
|
527
|
+
static int SumOfFeatureEvidence[MAX_NUM_CONFIGS];
|
|
528
|
+
static uinT8 ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX];
|
|
529
|
+
int Feature;
|
|
530
|
+
register uinT8 *UINT8Pointer;
|
|
531
|
+
register int ProtoIndex;
|
|
532
|
+
int NumProtos;
|
|
533
|
+
int NumGoodProtos;
|
|
534
|
+
uinT16 ActualProtoNum;
|
|
535
|
+
register int Temp;
|
|
536
|
+
|
|
537
|
+
/* DEBUG opening heading */
|
|
538
|
+
if (MatchDebuggingOn (Debug))
|
|
539
|
+
cprintf
|
|
540
|
+
("Find Good Protos -------------------------------------------\n");
|
|
541
|
+
|
|
542
|
+
IMClearTables(ClassTemplate, SumOfFeatureEvidence, ProtoEvidence);
|
|
543
|
+
|
|
544
|
+
for (Feature = 0; Feature < NumFeatures; Feature++)
|
|
545
|
+
IMUpdateTablesForFeature (ClassTemplate, ProtoMask, ConfigMask, Feature,
|
|
546
|
+
&(Features[Feature]), FeatureEvidence,
|
|
547
|
+
SumOfFeatureEvidence, ProtoEvidence, Debug);
|
|
548
|
+
|
|
549
|
+
#ifndef GRAPHICS_DISABLED
|
|
550
|
+
if (PrintProtoMatchesOn (Debug) || PrintMatchSummaryOn (Debug))
|
|
551
|
+
IMDebugFeatureProtoError(ClassTemplate,
|
|
552
|
+
ProtoMask,
|
|
553
|
+
ConfigMask,
|
|
554
|
+
SumOfFeatureEvidence,
|
|
555
|
+
ProtoEvidence,
|
|
556
|
+
NumFeatures,
|
|
557
|
+
Debug);
|
|
558
|
+
#endif
|
|
559
|
+
|
|
560
|
+
/* Average Proto Evidences & Find Good Protos */
|
|
561
|
+
NumProtos = ClassTemplate->NumProtos;
|
|
562
|
+
NumGoodProtos = 0;
|
|
563
|
+
for (ActualProtoNum = 0; ActualProtoNum < NumProtos; ActualProtoNum++) {
|
|
564
|
+
/* Compute Average for Actual Proto */
|
|
565
|
+
Temp = 0;
|
|
566
|
+
UINT8Pointer = &(ProtoEvidence[ActualProtoNum][0]);
|
|
567
|
+
for (ProtoIndex = ClassTemplate->ProtoLengths[ActualProtoNum];
|
|
568
|
+
ProtoIndex > 0; ProtoIndex--, UINT8Pointer++)
|
|
569
|
+
Temp += *UINT8Pointer;
|
|
570
|
+
|
|
571
|
+
Temp /= ClassTemplate->ProtoLengths[ActualProtoNum];
|
|
572
|
+
|
|
573
|
+
/* Find Good Protos */
|
|
574
|
+
if (Temp >= AdaptProtoThresh) {
|
|
575
|
+
*ProtoArray = ActualProtoNum;
|
|
576
|
+
ProtoArray++;
|
|
577
|
+
NumGoodProtos++;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (MatchDebuggingOn (Debug))
|
|
582
|
+
cprintf ("Match Complete --------------------------------------------\n");
|
|
583
|
+
return NumGoodProtos;
|
|
584
|
+
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
/*---------------------------------------------------------------------------*/
|
|
589
|
+
int FindBadFeatures(INT_CLASS ClassTemplate,
|
|
590
|
+
BIT_VECTOR ProtoMask,
|
|
591
|
+
BIT_VECTOR ConfigMask,
|
|
592
|
+
uinT16 BlobLength,
|
|
593
|
+
inT16 NumFeatures,
|
|
594
|
+
INT_FEATURE_ARRAY Features,
|
|
595
|
+
FEATURE_ID *FeatureArray,
|
|
596
|
+
int Debug) {
|
|
597
|
+
/*
|
|
598
|
+
** Parameters:
|
|
599
|
+
** ClassTemplate Prototypes & tables for a class
|
|
600
|
+
** ProtoMask AND Mask for proto word
|
|
601
|
+
** ConfigMask AND Mask for config word
|
|
602
|
+
** BlobLength Length of unormalized blob
|
|
603
|
+
** NumFeatures Number of features in blob
|
|
604
|
+
** Features Array of features
|
|
605
|
+
** FeatureArray Array of bad features
|
|
606
|
+
** Debug Debugger flag: 1=debugger on
|
|
607
|
+
** Globals:
|
|
608
|
+
** LocalMatcherMultiplier Normalization factor multiplier
|
|
609
|
+
** IntThetaFudge Theta fudge factor used for
|
|
610
|
+
** evidence calculation
|
|
611
|
+
** AdaptFeatureThresh Threshold for bad features
|
|
612
|
+
** Operation:
|
|
613
|
+
** FindBadFeatures finds all features whose maximum feature-evidence
|
|
614
|
+
** was less than AdaptFeatureThresh. The list is ordered by increasing
|
|
615
|
+
** feature number.
|
|
616
|
+
** Return:
|
|
617
|
+
** Number of bad features in FeatureArray.
|
|
618
|
+
** Exceptions: none
|
|
619
|
+
** History: Tue Mar 12 17:09:26 MST 1991, RWM, Created
|
|
620
|
+
*/
|
|
621
|
+
static uinT8 FeatureEvidence[MAX_NUM_CONFIGS];
|
|
622
|
+
static int SumOfFeatureEvidence[MAX_NUM_CONFIGS];
|
|
623
|
+
static uinT8 ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX];
|
|
624
|
+
int Feature;
|
|
625
|
+
register uinT8 *UINT8Pointer;
|
|
626
|
+
register int ConfigNum;
|
|
627
|
+
int NumConfigs;
|
|
628
|
+
int NumBadFeatures;
|
|
629
|
+
register int Temp;
|
|
630
|
+
|
|
631
|
+
/* DEBUG opening heading */
|
|
632
|
+
if (MatchDebuggingOn (Debug))
|
|
633
|
+
cprintf
|
|
634
|
+
("Find Bad Features -------------------------------------------\n");
|
|
635
|
+
|
|
636
|
+
IMClearTables(ClassTemplate, SumOfFeatureEvidence, ProtoEvidence);
|
|
637
|
+
|
|
638
|
+
NumBadFeatures = 0;
|
|
639
|
+
NumConfigs = ClassTemplate->NumConfigs;
|
|
640
|
+
for (Feature = 0; Feature < NumFeatures; Feature++) {
|
|
641
|
+
IMUpdateTablesForFeature (ClassTemplate, ProtoMask, ConfigMask, Feature,
|
|
642
|
+
&(Features[Feature]), FeatureEvidence,
|
|
643
|
+
SumOfFeatureEvidence, ProtoEvidence, Debug);
|
|
644
|
+
|
|
645
|
+
/* Find Best Evidence for Current Feature */
|
|
646
|
+
Temp = 0;
|
|
647
|
+
UINT8Pointer = FeatureEvidence;
|
|
648
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++, UINT8Pointer++)
|
|
649
|
+
if (*UINT8Pointer > Temp)
|
|
650
|
+
Temp = *UINT8Pointer;
|
|
651
|
+
|
|
652
|
+
/* Find Bad Features */
|
|
653
|
+
if (Temp < AdaptFeatureThresh) {
|
|
654
|
+
*FeatureArray = Feature;
|
|
655
|
+
FeatureArray++;
|
|
656
|
+
NumBadFeatures++;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
#ifndef GRAPHICS_DISABLED
|
|
661
|
+
if (PrintProtoMatchesOn (Debug) || PrintMatchSummaryOn (Debug))
|
|
662
|
+
IMDebugFeatureProtoError(ClassTemplate,
|
|
663
|
+
ProtoMask,
|
|
664
|
+
ConfigMask,
|
|
665
|
+
SumOfFeatureEvidence,
|
|
666
|
+
ProtoEvidence,
|
|
667
|
+
NumFeatures,
|
|
668
|
+
Debug);
|
|
669
|
+
#endif
|
|
670
|
+
|
|
671
|
+
if (MatchDebuggingOn (Debug))
|
|
672
|
+
cprintf ("Match Complete --------------------------------------------\n");
|
|
673
|
+
|
|
674
|
+
return NumBadFeatures;
|
|
675
|
+
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
/*---------------------------------------------------------------------------*/
|
|
680
|
+
void InitIntegerMatcher() {
|
|
681
|
+
int i;
|
|
682
|
+
uinT32 IntSimilarity;
|
|
683
|
+
double Similarity;
|
|
684
|
+
double Evidence;
|
|
685
|
+
double ScaleFactor;
|
|
686
|
+
|
|
687
|
+
/* Set default mode of operation of IntegerMatcher */
|
|
688
|
+
SetCharNormMatch();
|
|
689
|
+
|
|
690
|
+
/* Initialize table for evidence to similarity lookup */
|
|
691
|
+
for (i = 0; i < SE_TABLE_SIZE; i++) {
|
|
692
|
+
IntSimilarity = i << (27 - SE_TABLE_BITS);
|
|
693
|
+
Similarity = ((double) IntSimilarity) / 65536.0 / 65536.0;
|
|
694
|
+
Evidence = Similarity / SimilarityCenter;
|
|
695
|
+
Evidence *= Evidence;
|
|
696
|
+
Evidence += 1.0;
|
|
697
|
+
Evidence = 1.0 / Evidence;
|
|
698
|
+
Evidence *= 255.0;
|
|
699
|
+
|
|
700
|
+
if (SEExponentialMultiplier > 0.0) {
|
|
701
|
+
ScaleFactor = 1.0 - exp (-SEExponentialMultiplier) *
|
|
702
|
+
exp (SEExponentialMultiplier * ((double) i / SE_TABLE_SIZE));
|
|
703
|
+
if (ScaleFactor > 1.0)
|
|
704
|
+
ScaleFactor = 1.0;
|
|
705
|
+
if (ScaleFactor < 0.0)
|
|
706
|
+
ScaleFactor = 0.0;
|
|
707
|
+
Evidence *= ScaleFactor;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
SimilarityEvidenceTable[i] = (uinT8) (Evidence + 0.5);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/* Initialize evidence computation variables */
|
|
714
|
+
EvidenceTableMask =
|
|
715
|
+
((1 << EvidenceTableBits) - 1) << (9 - EvidenceTableBits);
|
|
716
|
+
MultTruncShiftBits = (14 - IntEvidenceTruncBits);
|
|
717
|
+
TableTruncShiftBits = (27 - SE_TABLE_BITS - (MultTruncShiftBits << 1));
|
|
718
|
+
EvidenceMultMask = ((1 << IntEvidenceTruncBits) - 1);
|
|
719
|
+
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
/*---------------------------------------------------------------------------*/
|
|
724
|
+
void InitIntegerMatcherVars() {
|
|
725
|
+
MakeClassPrunerThreshold();
|
|
726
|
+
MakeClassPrunerMultiplier();
|
|
727
|
+
MakeIntegerMatcherMultiplier();
|
|
728
|
+
MakeIntThetaFudge();
|
|
729
|
+
MakeCPCutoffStrength();
|
|
730
|
+
MakeEvidenceTableBits();
|
|
731
|
+
MakeIntEvidenceTruncBits();
|
|
732
|
+
MakeSEExponentialMultiplier();
|
|
733
|
+
MakeSimilarityCenter();
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
/*-------------------------------------------------------------------------*/
|
|
738
|
+
void PrintIntMatcherStats(FILE *f) {
|
|
739
|
+
fprintf (f, "protoword_lookups=%d, zero_protowords=%d, proto_shifts=%d\n",
|
|
740
|
+
protoword_lookups, zero_protowords, proto_shifts);
|
|
741
|
+
fprintf (f, "set_proto_bits=%d, config_shifts=%d, set_config_bits=%d\n",
|
|
742
|
+
set_proto_bits, config_shifts, set_config_bits);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
/*-------------------------------------------------------------------------*/
|
|
747
|
+
void SetProtoThresh(FLOAT32 Threshold) {
|
|
748
|
+
AdaptProtoThresh = (int) (255 * Threshold);
|
|
749
|
+
if (AdaptProtoThresh < 0)
|
|
750
|
+
AdaptProtoThresh = 0;
|
|
751
|
+
if (AdaptProtoThresh > 255)
|
|
752
|
+
AdaptProtoThresh = 255;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
/*---------------------------------------------------------------------------*/
|
|
757
|
+
void SetFeatureThresh(FLOAT32 Threshold) {
|
|
758
|
+
AdaptFeatureThresh = (int) (255 * Threshold);
|
|
759
|
+
if (AdaptFeatureThresh < 0)
|
|
760
|
+
AdaptFeatureThresh = 0;
|
|
761
|
+
if (AdaptFeatureThresh > 255)
|
|
762
|
+
AdaptFeatureThresh = 255;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
/*--------------------------------------------------------------------------*/
|
|
767
|
+
void SetBaseLineMatch() {
|
|
768
|
+
LocalMatcherMultiplier = 0;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
/*--------------------------------------------------------------------------*/
|
|
773
|
+
void SetCharNormMatch() {
|
|
774
|
+
LocalMatcherMultiplier = IntegerMatcherMultiplier;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
/**----------------------------------------------------------------------------
|
|
779
|
+
Private Code
|
|
780
|
+
----------------------------------------------------------------------------**/
|
|
781
|
+
/*---------------------------------------------------------------------------*/
|
|
782
|
+
void
|
|
783
|
+
IMClearTables (INT_CLASS ClassTemplate,
|
|
784
|
+
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
|
785
|
+
uinT8 ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX]) {
|
|
786
|
+
/*
|
|
787
|
+
** Parameters:
|
|
788
|
+
** SumOfFeatureEvidence Sum of Feature Evidence Table
|
|
789
|
+
** NumConfigs Number of Configurations
|
|
790
|
+
** ProtoEvidence Prototype Evidence Table
|
|
791
|
+
** NumProtos Number of Prototypes
|
|
792
|
+
** Globals:
|
|
793
|
+
** Operation:
|
|
794
|
+
** Clear SumOfFeatureEvidence and ProtoEvidence tables.
|
|
795
|
+
** Return:
|
|
796
|
+
** Exceptions: none
|
|
797
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
798
|
+
*/
|
|
799
|
+
int NumProtos = ClassTemplate->NumProtos;
|
|
800
|
+
int NumConfigs = ClassTemplate->NumConfigs;
|
|
801
|
+
|
|
802
|
+
memset(SumOfFeatureEvidence, 0,
|
|
803
|
+
NumConfigs * sizeof(SumOfFeatureEvidence[0]));
|
|
804
|
+
memset(ProtoEvidence, 0,
|
|
805
|
+
NumProtos * sizeof(ProtoEvidence[0]));
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
/*---------------------------------------------------------------------------*/
|
|
810
|
+
void
|
|
811
|
+
IMClearFeatureEvidenceTable (uinT8 FeatureEvidence[MAX_NUM_CONFIGS],
|
|
812
|
+
int NumConfigs) {
|
|
813
|
+
/*
|
|
814
|
+
** Parameters:
|
|
815
|
+
** FeatureEvidence Feature Evidence Table
|
|
816
|
+
** NumConfigs Number of Configurations
|
|
817
|
+
** Globals:
|
|
818
|
+
** Operation:
|
|
819
|
+
** Clear FeatureEvidence table.
|
|
820
|
+
** Return:
|
|
821
|
+
** Exceptions: none
|
|
822
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
823
|
+
*/
|
|
824
|
+
memset(FeatureEvidence, 0, NumConfigs * sizeof(*FeatureEvidence));
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
/*---------------------------------------------------------------------------*/
|
|
829
|
+
void IMDebugConfiguration(int FeatureNum,
|
|
830
|
+
uinT16 ActualProtoNum,
|
|
831
|
+
uinT8 Evidence,
|
|
832
|
+
BIT_VECTOR ConfigMask,
|
|
833
|
+
uinT32 ConfigWord) {
|
|
834
|
+
/*
|
|
835
|
+
** Parameters:
|
|
836
|
+
** Globals:
|
|
837
|
+
** Operation:
|
|
838
|
+
** Print debugging information for Configuations
|
|
839
|
+
** Return:
|
|
840
|
+
** Exceptions: none
|
|
841
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
842
|
+
*/
|
|
843
|
+
cprintf ("F = %3d, P = %3d, E = %3d, Configs = ",
|
|
844
|
+
FeatureNum, (int) ActualProtoNum, (int) Evidence);
|
|
845
|
+
while (ConfigWord) {
|
|
846
|
+
if (ConfigWord & 1)
|
|
847
|
+
cprintf ("1");
|
|
848
|
+
else
|
|
849
|
+
cprintf ("0");
|
|
850
|
+
ConfigWord >>= 1;
|
|
851
|
+
}
|
|
852
|
+
cprintf ("\n");
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
/*---------------------------------------------------------------------------*/
|
|
857
|
+
void IMDebugConfigurationSum(int FeatureNum,
|
|
858
|
+
uinT8 *FeatureEvidence,
|
|
859
|
+
inT32 ConfigCount) {
|
|
860
|
+
/*
|
|
861
|
+
** Parameters:
|
|
862
|
+
** Globals:
|
|
863
|
+
** Operation:
|
|
864
|
+
** Print debugging information for Configuations
|
|
865
|
+
** Return:
|
|
866
|
+
** Exceptions: none
|
|
867
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
868
|
+
*/
|
|
869
|
+
int ConfigNum;
|
|
870
|
+
|
|
871
|
+
cprintf ("F=%3d, C=", (int) FeatureNum);
|
|
872
|
+
|
|
873
|
+
for (ConfigNum = 0; ConfigNum < ConfigCount; ConfigNum++) {
|
|
874
|
+
cprintf ("%4d", FeatureEvidence[ConfigNum]);
|
|
875
|
+
}
|
|
876
|
+
cprintf ("\n");
|
|
877
|
+
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
/*---------------------------------------------------------------------------*/
|
|
883
|
+
int
|
|
884
|
+
IMUpdateTablesForFeature (INT_CLASS ClassTemplate,
|
|
885
|
+
BIT_VECTOR ProtoMask,
|
|
886
|
+
BIT_VECTOR ConfigMask,
|
|
887
|
+
int FeatureNum,
|
|
888
|
+
INT_FEATURE Feature,
|
|
889
|
+
uinT8 FeatureEvidence[MAX_NUM_CONFIGS],
|
|
890
|
+
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
|
891
|
+
uinT8
|
|
892
|
+
ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],
|
|
893
|
+
int Debug) {
|
|
894
|
+
/*
|
|
895
|
+
** Parameters:
|
|
896
|
+
** ClassTemplate Prototypes & tables for a class
|
|
897
|
+
** FeatureNum Current feature number (for DEBUG only)
|
|
898
|
+
** Feature Pointer to a feature struct
|
|
899
|
+
** FeatureEvidence Feature Evidence Table
|
|
900
|
+
** SumOfFeatureEvidence Sum of Feature Evidence Table
|
|
901
|
+
** ProtoEvidence Prototype Evidence Table
|
|
902
|
+
** Debug Debugger flag: 1=debugger on
|
|
903
|
+
** Globals:
|
|
904
|
+
** Operation:
|
|
905
|
+
** For the given feature: prune protos, compute evidence, update Feature Evidence,
|
|
906
|
+
** Proto Evidence, and Sum of Feature Evidence tables.
|
|
907
|
+
** Return:
|
|
908
|
+
** Exceptions: none
|
|
909
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
910
|
+
*/
|
|
911
|
+
register uinT32 ConfigWord;
|
|
912
|
+
register uinT32 ProtoWord;
|
|
913
|
+
register uinT32 ProtoNum;
|
|
914
|
+
register uinT32 ActualProtoNum;
|
|
915
|
+
uinT8 proto_byte;
|
|
916
|
+
inT32 proto_word_offset;
|
|
917
|
+
inT32 proto_offset;
|
|
918
|
+
uinT8 config_byte;
|
|
919
|
+
inT32 config_offset;
|
|
920
|
+
PROTO_SET ProtoSet;
|
|
921
|
+
uinT32 *ProtoPrunerPtr;
|
|
922
|
+
INT_PROTO Proto;
|
|
923
|
+
int ProtoSetIndex;
|
|
924
|
+
uinT8 Evidence;
|
|
925
|
+
uinT32 XFeatureAddress;
|
|
926
|
+
uinT32 YFeatureAddress;
|
|
927
|
+
uinT32 ThetaFeatureAddress;
|
|
928
|
+
register uinT8 *UINT8Pointer;
|
|
929
|
+
register int ProtoIndex;
|
|
930
|
+
uinT8 Temp;
|
|
931
|
+
register int *IntPointer;
|
|
932
|
+
int ConfigNum;
|
|
933
|
+
register inT32 M3;
|
|
934
|
+
register inT32 A3;
|
|
935
|
+
register uinT32 A4;
|
|
936
|
+
|
|
937
|
+
IMClearFeatureEvidenceTable(FeatureEvidence, ClassTemplate->NumConfigs);
|
|
938
|
+
|
|
939
|
+
/* Precompute Feature Address offset for Proto Pruning */
|
|
940
|
+
XFeatureAddress = ((Feature->X >> 2) << 1);
|
|
941
|
+
YFeatureAddress = (NUM_PP_BUCKETS << 1) + ((Feature->Y >> 2) << 1);
|
|
942
|
+
ThetaFeatureAddress = (NUM_PP_BUCKETS << 2) + ((Feature->Theta >> 2) << 1);
|
|
943
|
+
|
|
944
|
+
for (ProtoSetIndex = 0, ActualProtoNum = 0;
|
|
945
|
+
ProtoSetIndex < ClassTemplate->NumProtoSets; ProtoSetIndex++) {
|
|
946
|
+
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
|
|
947
|
+
ProtoPrunerPtr = (uinT32 *) ((*ProtoSet).ProtoPruner);
|
|
948
|
+
for (ProtoNum = 0; ProtoNum < PROTOS_PER_PROTO_SET;
|
|
949
|
+
ProtoNum += (PROTOS_PER_PROTO_SET >> 1), ActualProtoNum +=
|
|
950
|
+
(PROTOS_PER_PROTO_SET >> 1), ProtoMask++, ProtoPrunerPtr++) {
|
|
951
|
+
/* Prune Protos of current Proto Set */
|
|
952
|
+
ProtoWord = *(ProtoPrunerPtr + XFeatureAddress);
|
|
953
|
+
ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress);
|
|
954
|
+
ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress);
|
|
955
|
+
ProtoWord &= *ProtoMask;
|
|
956
|
+
|
|
957
|
+
if (ProtoWord != 0) {
|
|
958
|
+
proto_byte = ProtoWord & 0xff;
|
|
959
|
+
ProtoWord >>= 8;
|
|
960
|
+
proto_word_offset = 0;
|
|
961
|
+
while (ProtoWord != 0 || proto_byte != 0) {
|
|
962
|
+
while (proto_byte == 0) {
|
|
963
|
+
proto_byte = ProtoWord & 0xff;
|
|
964
|
+
ProtoWord >>= 8;
|
|
965
|
+
proto_word_offset += 8;
|
|
966
|
+
}
|
|
967
|
+
proto_offset = offset_table[proto_byte] + proto_word_offset;
|
|
968
|
+
proto_byte = next_table[proto_byte];
|
|
969
|
+
Proto = &(ProtoSet->Protos[ProtoNum + proto_offset]);
|
|
970
|
+
ConfigWord = Proto->Configs[0];
|
|
971
|
+
A3 = (((Proto->A * (Feature->X - 128)) << 1)
|
|
972
|
+
- (Proto->B * (Feature->Y - 128)) + (Proto->C << 9));
|
|
973
|
+
M3 =
|
|
974
|
+
(((inT8) (Feature->Theta - Proto->Angle)) *
|
|
975
|
+
IntThetaFudge) << 1;
|
|
976
|
+
|
|
977
|
+
if (A3 < 0)
|
|
978
|
+
A3 = ~A3;
|
|
979
|
+
if (M3 < 0)
|
|
980
|
+
M3 = ~M3;
|
|
981
|
+
A3 >>= MultTruncShiftBits;
|
|
982
|
+
M3 >>= MultTruncShiftBits;
|
|
983
|
+
if (A3 > EvidenceMultMask)
|
|
984
|
+
A3 = EvidenceMultMask;
|
|
985
|
+
if (M3 > EvidenceMultMask)
|
|
986
|
+
M3 = EvidenceMultMask;
|
|
987
|
+
|
|
988
|
+
A4 = (A3 * A3) + (M3 * M3);
|
|
989
|
+
A4 >>= TableTruncShiftBits;
|
|
990
|
+
if (A4 > EvidenceTableMask)
|
|
991
|
+
Evidence = 0;
|
|
992
|
+
else
|
|
993
|
+
Evidence = SimilarityEvidenceTable[A4];
|
|
994
|
+
|
|
995
|
+
if (PrintFeatureMatchesOn (Debug))
|
|
996
|
+
IMDebugConfiguration (FeatureNum,
|
|
997
|
+
ActualProtoNum + proto_offset,
|
|
998
|
+
Evidence, ConfigMask, ConfigWord);
|
|
999
|
+
|
|
1000
|
+
ConfigWord &= *ConfigMask;
|
|
1001
|
+
|
|
1002
|
+
UINT8Pointer = FeatureEvidence - 8;
|
|
1003
|
+
config_byte = 0;
|
|
1004
|
+
while (ConfigWord != 0 || config_byte != 0) {
|
|
1005
|
+
while (config_byte == 0) {
|
|
1006
|
+
config_byte = ConfigWord & 0xff;
|
|
1007
|
+
ConfigWord >>= 8;
|
|
1008
|
+
UINT8Pointer += 8;
|
|
1009
|
+
// config_shifts++;
|
|
1010
|
+
}
|
|
1011
|
+
config_offset = offset_table[config_byte];
|
|
1012
|
+
config_byte = next_table[config_byte];
|
|
1013
|
+
if (Evidence > UINT8Pointer[config_offset])
|
|
1014
|
+
UINT8Pointer[config_offset] = Evidence;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
UINT8Pointer =
|
|
1018
|
+
&(ProtoEvidence[ActualProtoNum + proto_offset][0]);
|
|
1019
|
+
for (ProtoIndex =
|
|
1020
|
+
ClassTemplate->ProtoLengths[ActualProtoNum + proto_offset];
|
|
1021
|
+
ProtoIndex > 0; ProtoIndex--, UINT8Pointer++) {
|
|
1022
|
+
if (Evidence > *UINT8Pointer) {
|
|
1023
|
+
Temp = *UINT8Pointer;
|
|
1024
|
+
*UINT8Pointer = Evidence;
|
|
1025
|
+
Evidence = Temp;
|
|
1026
|
+
}
|
|
1027
|
+
else if (Evidence == 0)
|
|
1028
|
+
break;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
if (PrintFeatureMatchesOn (Debug))
|
|
1036
|
+
IMDebugConfigurationSum (FeatureNum, FeatureEvidence,
|
|
1037
|
+
ClassTemplate->NumConfigs);
|
|
1038
|
+
IntPointer = SumOfFeatureEvidence;
|
|
1039
|
+
UINT8Pointer = FeatureEvidence;
|
|
1040
|
+
int SumOverConfigs = 0;
|
|
1041
|
+
for (ConfigNum = ClassTemplate->NumConfigs; ConfigNum > 0; ConfigNum--) {
|
|
1042
|
+
int evidence = *UINT8Pointer++;
|
|
1043
|
+
SumOverConfigs += evidence;
|
|
1044
|
+
*IntPointer++ += evidence;
|
|
1045
|
+
}
|
|
1046
|
+
return SumOverConfigs;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
/*---------------------------------------------------------------------------*/
|
|
1051
|
+
#ifndef GRAPHICS_DISABLED
|
|
1052
|
+
void
|
|
1053
|
+
IMDebugFeatureProtoError (INT_CLASS ClassTemplate,
|
|
1054
|
+
BIT_VECTOR ProtoMask,
|
|
1055
|
+
BIT_VECTOR ConfigMask,
|
|
1056
|
+
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
|
1057
|
+
uinT8
|
|
1058
|
+
ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],
|
|
1059
|
+
inT16 NumFeatures, int Debug) {
|
|
1060
|
+
/*
|
|
1061
|
+
** Parameters:
|
|
1062
|
+
** Globals:
|
|
1063
|
+
** Operation:
|
|
1064
|
+
** Print debugging information for Configuations
|
|
1065
|
+
** Return:
|
|
1066
|
+
** Exceptions: none
|
|
1067
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
1068
|
+
*/
|
|
1069
|
+
uinT8 *UINT8Pointer;
|
|
1070
|
+
int *IntPointer;
|
|
1071
|
+
FLOAT32 ProtoConfigs[MAX_NUM_CONFIGS];
|
|
1072
|
+
int ConfigNum;
|
|
1073
|
+
uinT32 ConfigWord;
|
|
1074
|
+
int ProtoSetIndex;
|
|
1075
|
+
uinT16 ProtoNum;
|
|
1076
|
+
uinT8 ProtoWordNum;
|
|
1077
|
+
PROTO_SET ProtoSet;
|
|
1078
|
+
int ProtoIndex;
|
|
1079
|
+
int NumProtos;
|
|
1080
|
+
uinT16 ActualProtoNum;
|
|
1081
|
+
int Temp;
|
|
1082
|
+
int NumConfigs;
|
|
1083
|
+
|
|
1084
|
+
NumProtos = ClassTemplate->NumProtos;
|
|
1085
|
+
NumConfigs = ClassTemplate->NumConfigs;
|
|
1086
|
+
|
|
1087
|
+
if (PrintMatchSummaryOn (Debug)) {
|
|
1088
|
+
cprintf ("Configuration Mask:\n");
|
|
1089
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++)
|
|
1090
|
+
cprintf ("%1d", (((*ConfigMask) >> ConfigNum) & 1));
|
|
1091
|
+
cprintf ("\n");
|
|
1092
|
+
|
|
1093
|
+
cprintf ("Feature Error for Configurations:\n");
|
|
1094
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++)
|
|
1095
|
+
cprintf (" %5.1f",
|
|
1096
|
+
100.0 * (1.0 -
|
|
1097
|
+
(FLOAT32) SumOfFeatureEvidence[ConfigNum] /
|
|
1098
|
+
NumFeatures / 256.0));
|
|
1099
|
+
cprintf ("\n\n\n");
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
if (PrintMatchSummaryOn (Debug)) {
|
|
1103
|
+
cprintf ("Proto Mask:\n");
|
|
1104
|
+
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
|
|
1105
|
+
ProtoSetIndex++) {
|
|
1106
|
+
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
|
|
1107
|
+
for (ProtoWordNum = 0; ProtoWordNum < 2;
|
|
1108
|
+
ProtoWordNum++, ProtoMask++) {
|
|
1109
|
+
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
|
|
1110
|
+
for (ProtoNum = 0;
|
|
1111
|
+
((ProtoNum < (PROTOS_PER_PROTO_SET >> 1))
|
|
1112
|
+
&& (ActualProtoNum < NumProtos));
|
|
1113
|
+
ProtoNum++, ActualProtoNum++)
|
|
1114
|
+
cprintf ("%1d", (((*ProtoMask) >> ProtoNum) & 1));
|
|
1115
|
+
cprintf ("\n");
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
cprintf ("\n");
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++)
|
|
1122
|
+
ProtoConfigs[ConfigNum] = 0;
|
|
1123
|
+
|
|
1124
|
+
if (PrintProtoMatchesOn (Debug)) {
|
|
1125
|
+
cprintf ("Proto Evidence:\n");
|
|
1126
|
+
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
|
|
1127
|
+
ProtoSetIndex++) {
|
|
1128
|
+
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
|
|
1129
|
+
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
|
|
1130
|
+
for (ProtoNum = 0;
|
|
1131
|
+
((ProtoNum < PROTOS_PER_PROTO_SET)
|
|
1132
|
+
&& (ActualProtoNum < NumProtos));
|
|
1133
|
+
ProtoNum++, ActualProtoNum++) {
|
|
1134
|
+
cprintf ("P %3d =", ActualProtoNum);
|
|
1135
|
+
Temp = 0;
|
|
1136
|
+
UINT8Pointer = &(ProtoEvidence[ActualProtoNum][0]);
|
|
1137
|
+
for (ProtoIndex = 0;
|
|
1138
|
+
ProtoIndex < ClassTemplate->ProtoLengths[ActualProtoNum];
|
|
1139
|
+
ProtoIndex++, UINT8Pointer++) {
|
|
1140
|
+
cprintf (" %d", *UINT8Pointer);
|
|
1141
|
+
Temp += *UINT8Pointer;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
cprintf (" = %6.4f%%\n", Temp /
|
|
1145
|
+
256.0 / ClassTemplate->ProtoLengths[ActualProtoNum]);
|
|
1146
|
+
|
|
1147
|
+
ConfigWord = (ProtoSet->Protos[ProtoNum]).Configs[0];
|
|
1148
|
+
IntPointer = SumOfFeatureEvidence;
|
|
1149
|
+
ConfigNum = 0;
|
|
1150
|
+
while (ConfigWord) {
|
|
1151
|
+
cprintf ("%5d", ConfigWord & 1 ? Temp : 0);
|
|
1152
|
+
if (ConfigWord & 1)
|
|
1153
|
+
ProtoConfigs[ConfigNum] += Temp;
|
|
1154
|
+
IntPointer++;
|
|
1155
|
+
ConfigNum++;
|
|
1156
|
+
ConfigWord >>= 1;
|
|
1157
|
+
}
|
|
1158
|
+
cprintf ("\n");
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
if (PrintMatchSummaryOn (Debug)) {
|
|
1164
|
+
cprintf ("Proto Error for Configurations:\n");
|
|
1165
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++)
|
|
1166
|
+
cprintf (" %5.1f",
|
|
1167
|
+
100.0 * (1.0 -
|
|
1168
|
+
ProtoConfigs[ConfigNum] /
|
|
1169
|
+
ClassTemplate->ConfigLengths[ConfigNum] / 256.0));
|
|
1170
|
+
cprintf ("\n\n");
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
if (PrintProtoMatchesOn (Debug)) {
|
|
1174
|
+
cprintf ("Proto Sum for Configurations:\n");
|
|
1175
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++)
|
|
1176
|
+
cprintf (" %4.1f", ProtoConfigs[ConfigNum] / 256.0);
|
|
1177
|
+
cprintf ("\n\n");
|
|
1178
|
+
|
|
1179
|
+
cprintf ("Proto Length for Configurations:\n");
|
|
1180
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++)
|
|
1181
|
+
cprintf (" %4.1f",
|
|
1182
|
+
(float) ClassTemplate->ConfigLengths[ConfigNum]);
|
|
1183
|
+
cprintf ("\n\n");
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
/*---------------------------------------------------------------------------*/
|
|
1190
|
+
void
|
|
1191
|
+
IMDisplayProtoDebugInfo (INT_CLASS ClassTemplate,
|
|
1192
|
+
BIT_VECTOR ProtoMask,
|
|
1193
|
+
BIT_VECTOR ConfigMask,
|
|
1194
|
+
uinT8 ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],
|
|
1195
|
+
int Debug) {
|
|
1196
|
+
register uinT8 *UINT8Pointer;
|
|
1197
|
+
register uinT32 ConfigWord;
|
|
1198
|
+
register uinT16 ProtoNum;
|
|
1199
|
+
register uinT16 ActualProtoNum;
|
|
1200
|
+
PROTO_SET ProtoSet;
|
|
1201
|
+
int ProtoSetIndex;
|
|
1202
|
+
int ProtoIndex;
|
|
1203
|
+
int NumProtos;
|
|
1204
|
+
register int Temp;
|
|
1205
|
+
|
|
1206
|
+
extern ScrollView *IntMatchWindow;
|
|
1207
|
+
|
|
1208
|
+
if (IntMatchWindow == NULL) {
|
|
1209
|
+
IntMatchWindow = c_create_window ("IntMatchWindow", 50, 200,
|
|
1210
|
+
520, 520,
|
|
1211
|
+
-130.0, 130.0, -130.0, 130.0);
|
|
1212
|
+
}
|
|
1213
|
+
NumProtos = ClassTemplate->NumProtos;
|
|
1214
|
+
|
|
1215
|
+
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
|
|
1216
|
+
ProtoSetIndex++) {
|
|
1217
|
+
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
|
|
1218
|
+
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
|
|
1219
|
+
for (ProtoNum = 0;
|
|
1220
|
+
((ProtoNum < PROTOS_PER_PROTO_SET)
|
|
1221
|
+
&& (ActualProtoNum < NumProtos)); ProtoNum++, ActualProtoNum++) {
|
|
1222
|
+
/* Compute Average for Actual Proto */
|
|
1223
|
+
Temp = 0;
|
|
1224
|
+
UINT8Pointer = &(ProtoEvidence[ActualProtoNum][0]);
|
|
1225
|
+
for (ProtoIndex = ClassTemplate->ProtoLengths[ActualProtoNum];
|
|
1226
|
+
ProtoIndex > 0; ProtoIndex--, UINT8Pointer++)
|
|
1227
|
+
Temp += *UINT8Pointer;
|
|
1228
|
+
|
|
1229
|
+
Temp /= ClassTemplate->ProtoLengths[ActualProtoNum];
|
|
1230
|
+
|
|
1231
|
+
ConfigWord = (ProtoSet->Protos[ProtoNum]).Configs[0];
|
|
1232
|
+
ConfigWord &= *ConfigMask;
|
|
1233
|
+
if (ConfigWord) {
|
|
1234
|
+
/* Update display for current proto */
|
|
1235
|
+
if (ClipMatchEvidenceOn (Debug)) {
|
|
1236
|
+
if (Temp < AdaptProtoThresh)
|
|
1237
|
+
DisplayIntProto (ClassTemplate, ActualProtoNum,
|
|
1238
|
+
(Temp / 255.0));
|
|
1239
|
+
else
|
|
1240
|
+
DisplayIntProto (ClassTemplate, ActualProtoNum,
|
|
1241
|
+
(Temp / 255.0));
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
DisplayIntProto (ClassTemplate, ActualProtoNum,
|
|
1245
|
+
(Temp / 255.0));
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
/*---------------------------------------------------------------------------*/
|
|
1254
|
+
void IMDisplayFeatureDebugInfo(INT_CLASS ClassTemplate,
|
|
1255
|
+
BIT_VECTOR ProtoMask,
|
|
1256
|
+
BIT_VECTOR ConfigMask,
|
|
1257
|
+
inT16 NumFeatures,
|
|
1258
|
+
INT_FEATURE_ARRAY Features,
|
|
1259
|
+
int Debug) {
|
|
1260
|
+
static uinT8 FeatureEvidence[MAX_NUM_CONFIGS];
|
|
1261
|
+
static int SumOfFeatureEvidence[MAX_NUM_CONFIGS];
|
|
1262
|
+
static uinT8 ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX];
|
|
1263
|
+
int Feature;
|
|
1264
|
+
register uinT8 *UINT8Pointer;
|
|
1265
|
+
register int ConfigNum;
|
|
1266
|
+
int NumConfigs;
|
|
1267
|
+
register int Temp;
|
|
1268
|
+
|
|
1269
|
+
IMClearTables(ClassTemplate, SumOfFeatureEvidence, ProtoEvidence);
|
|
1270
|
+
|
|
1271
|
+
NumConfigs = ClassTemplate->NumConfigs;
|
|
1272
|
+
for (Feature = 0; Feature < NumFeatures; Feature++) {
|
|
1273
|
+
IMUpdateTablesForFeature (ClassTemplate, ProtoMask, ConfigMask, Feature,
|
|
1274
|
+
&(Features[Feature]), FeatureEvidence,
|
|
1275
|
+
SumOfFeatureEvidence, ProtoEvidence, 0);
|
|
1276
|
+
|
|
1277
|
+
/* Find Best Evidence for Current Feature */
|
|
1278
|
+
Temp = 0;
|
|
1279
|
+
UINT8Pointer = FeatureEvidence;
|
|
1280
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++, UINT8Pointer++)
|
|
1281
|
+
if (*UINT8Pointer > Temp)
|
|
1282
|
+
Temp = *UINT8Pointer;
|
|
1283
|
+
|
|
1284
|
+
/* Update display for current feature */
|
|
1285
|
+
if (ClipMatchEvidenceOn (Debug)) {
|
|
1286
|
+
if (Temp < AdaptFeatureThresh)
|
|
1287
|
+
DisplayIntFeature (&(Features[Feature]), 0.0);
|
|
1288
|
+
else
|
|
1289
|
+
DisplayIntFeature (&(Features[Feature]), 1.0);
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
DisplayIntFeature (&(Features[Feature]), (Temp / 255.0));
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
#endif
|
|
1297
|
+
|
|
1298
|
+
/*---------------------------------------------------------------------------*/
|
|
1299
|
+
void
|
|
1300
|
+
IMUpdateSumOfProtoEvidences (INT_CLASS ClassTemplate,
|
|
1301
|
+
BIT_VECTOR ConfigMask,
|
|
1302
|
+
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
|
1303
|
+
uinT8
|
|
1304
|
+
ProtoEvidence[MAX_NUM_PROTOS][MAX_PROTO_INDEX],
|
|
1305
|
+
inT16 NumFeatures) {
|
|
1306
|
+
/*
|
|
1307
|
+
** Parameters:
|
|
1308
|
+
** Globals:
|
|
1309
|
+
** Operation:
|
|
1310
|
+
** Add sum of Proto Evidences into Sum Of Feature Evidence Array
|
|
1311
|
+
** Return:
|
|
1312
|
+
** Exceptions: none
|
|
1313
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
1314
|
+
*/
|
|
1315
|
+
register uinT8 *UINT8Pointer;
|
|
1316
|
+
register int *IntPointer;
|
|
1317
|
+
register uinT32 ConfigWord;
|
|
1318
|
+
int ProtoSetIndex;
|
|
1319
|
+
register uinT16 ProtoNum;
|
|
1320
|
+
PROTO_SET ProtoSet;
|
|
1321
|
+
register int ProtoIndex;
|
|
1322
|
+
int NumProtos;
|
|
1323
|
+
uinT16 ActualProtoNum;
|
|
1324
|
+
int Temp;
|
|
1325
|
+
|
|
1326
|
+
NumProtos = ClassTemplate->NumProtos;
|
|
1327
|
+
|
|
1328
|
+
for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->NumProtoSets;
|
|
1329
|
+
ProtoSetIndex++) {
|
|
1330
|
+
ProtoSet = ClassTemplate->ProtoSets[ProtoSetIndex];
|
|
1331
|
+
ActualProtoNum = (ProtoSetIndex * PROTOS_PER_PROTO_SET);
|
|
1332
|
+
for (ProtoNum = 0;
|
|
1333
|
+
((ProtoNum < PROTOS_PER_PROTO_SET)
|
|
1334
|
+
&& (ActualProtoNum < NumProtos)); ProtoNum++, ActualProtoNum++) {
|
|
1335
|
+
Temp = 0;
|
|
1336
|
+
UINT8Pointer = &(ProtoEvidence[ActualProtoNum][0]);
|
|
1337
|
+
for (ProtoIndex = ClassTemplate->ProtoLengths[ActualProtoNum];
|
|
1338
|
+
ProtoIndex > 0; ProtoIndex--, UINT8Pointer++)
|
|
1339
|
+
Temp += *UINT8Pointer;
|
|
1340
|
+
|
|
1341
|
+
ConfigWord = (ProtoSet->Protos[ProtoNum]).Configs[0];
|
|
1342
|
+
ConfigWord &= *ConfigMask;
|
|
1343
|
+
IntPointer = SumOfFeatureEvidence;
|
|
1344
|
+
while (ConfigWord) {
|
|
1345
|
+
if (ConfigWord & 1)
|
|
1346
|
+
*IntPointer += Temp;
|
|
1347
|
+
IntPointer++;
|
|
1348
|
+
ConfigWord >>= 1;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
/*---------------------------------------------------------------------------*/
|
|
1357
|
+
void
|
|
1358
|
+
IMNormalizeSumOfEvidences (INT_CLASS ClassTemplate,
|
|
1359
|
+
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
|
1360
|
+
inT16 NumFeatures, inT32 used_features) {
|
|
1361
|
+
/*
|
|
1362
|
+
** Parameters:
|
|
1363
|
+
** Globals:
|
|
1364
|
+
** Operation:
|
|
1365
|
+
** Normalize Sum of Proto and Feature Evidence by dividing by
|
|
1366
|
+
** the sum of the Feature Lengths and the Proto Lengths for each
|
|
1367
|
+
** configuration.
|
|
1368
|
+
** Return:
|
|
1369
|
+
** Exceptions: none
|
|
1370
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
1371
|
+
*/
|
|
1372
|
+
register int *IntPointer;
|
|
1373
|
+
register int ConfigNum;
|
|
1374
|
+
int NumConfigs;
|
|
1375
|
+
|
|
1376
|
+
NumConfigs = ClassTemplate->NumConfigs;
|
|
1377
|
+
|
|
1378
|
+
IntPointer = SumOfFeatureEvidence;
|
|
1379
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++, IntPointer++)
|
|
1380
|
+
*IntPointer = (*IntPointer << 8) /
|
|
1381
|
+
(NumFeatures + ClassTemplate->ConfigLengths[ConfigNum]);
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
/*---------------------------------------------------------------------------*/
|
|
1386
|
+
int
|
|
1387
|
+
IMFindBestMatch (INT_CLASS ClassTemplate,
|
|
1388
|
+
int SumOfFeatureEvidence[MAX_NUM_CONFIGS],
|
|
1389
|
+
uinT16 BlobLength,
|
|
1390
|
+
uinT8 NormalizationFactor, INT_RESULT Result) {
|
|
1391
|
+
/*
|
|
1392
|
+
** Parameters:
|
|
1393
|
+
** Globals:
|
|
1394
|
+
** Operation:
|
|
1395
|
+
** Find the best match for the current class and update the Result
|
|
1396
|
+
** with the configuration and match rating.
|
|
1397
|
+
** Return:
|
|
1398
|
+
** The best normalized sum of evidences
|
|
1399
|
+
** Exceptions: none
|
|
1400
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
1401
|
+
*/
|
|
1402
|
+
register int *IntPointer;
|
|
1403
|
+
register int ConfigNum;
|
|
1404
|
+
register int NumConfigs;
|
|
1405
|
+
register int BestMatch;
|
|
1406
|
+
register int Best2Match;
|
|
1407
|
+
|
|
1408
|
+
NumConfigs = ClassTemplate->NumConfigs;
|
|
1409
|
+
|
|
1410
|
+
/* Find best match */
|
|
1411
|
+
BestMatch = 0;
|
|
1412
|
+
Best2Match = 0;
|
|
1413
|
+
IntPointer = SumOfFeatureEvidence;
|
|
1414
|
+
for (ConfigNum = 0; ConfigNum < NumConfigs; ConfigNum++, IntPointer++) {
|
|
1415
|
+
if (display_ratings > 1)
|
|
1416
|
+
cprintf ("Config %d, rating=%d\n", ConfigNum, *IntPointer);
|
|
1417
|
+
if (*IntPointer > BestMatch) {
|
|
1418
|
+
if (BestMatch > 0) {
|
|
1419
|
+
Result->Config2 = Result->Config;
|
|
1420
|
+
Best2Match = BestMatch;
|
|
1421
|
+
}
|
|
1422
|
+
else
|
|
1423
|
+
Result->Config2 = ConfigNum;
|
|
1424
|
+
Result->Config = ConfigNum;
|
|
1425
|
+
BestMatch = *IntPointer;
|
|
1426
|
+
}
|
|
1427
|
+
else if (*IntPointer > Best2Match) {
|
|
1428
|
+
Result->Config2 = ConfigNum;
|
|
1429
|
+
Best2Match = *IntPointer;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/* Compute Certainty Rating */
|
|
1434
|
+
(*Result).Rating = ((65536.0 - BestMatch) / 65536.0 * BlobLength +
|
|
1435
|
+
LocalMatcherMultiplier * NormalizationFactor / 256.0) /
|
|
1436
|
+
(BlobLength + LocalMatcherMultiplier);
|
|
1437
|
+
|
|
1438
|
+
return BestMatch;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
/*---------------------------------------------------------------------------*/
|
|
1443
|
+
#ifndef GRAPHICS_DISABLED
|
|
1444
|
+
void IMDebugBestMatch(int BestMatch,
|
|
1445
|
+
INT_RESULT Result,
|
|
1446
|
+
uinT16 BlobLength,
|
|
1447
|
+
uinT8 NormalizationFactor) {
|
|
1448
|
+
/*
|
|
1449
|
+
** Parameters:
|
|
1450
|
+
** Globals:
|
|
1451
|
+
** Operation:
|
|
1452
|
+
** Find the best match for the current class and update the Result
|
|
1453
|
+
** Return:
|
|
1454
|
+
** Exceptions: none
|
|
1455
|
+
** History: Wed Feb 27 14:12:28 MST 1991, RWM, Created.
|
|
1456
|
+
*/
|
|
1457
|
+
cprintf ("Rating = %5.1f%% Best Config = %3d\n",
|
|
1458
|
+
100.0 * ((*Result).Rating), (int) ((*Result).Config));
|
|
1459
|
+
cprintf
|
|
1460
|
+
("Matcher Error = %5.1f%% Blob Length = %3d Weight = %4.1f%%\n",
|
|
1461
|
+
100.0 * (65536.0 - BestMatch) / 65536.0, (int) BlobLength,
|
|
1462
|
+
100.0 * BlobLength / (BlobLength + LocalMatcherMultiplier));
|
|
1463
|
+
cprintf
|
|
1464
|
+
("Char Norm Error = %5.1f%% Norm Strength = %3d Weight = %4.1f%%\n",
|
|
1465
|
+
100.0 * NormalizationFactor / 256.0, LocalMatcherMultiplier,
|
|
1466
|
+
100.0 * LocalMatcherMultiplier / (BlobLength + LocalMatcherMultiplier));
|
|
1467
|
+
}
|
|
1468
|
+
#endif
|
|
1469
|
+
|
|
1470
|
+
/*---------------------------------------------------------------------------*/
|
|
1471
|
+
void
|
|
1472
|
+
HeapSort (int n, register int ra[], register int rb[]) {
|
|
1473
|
+
/*
|
|
1474
|
+
** Parameters:
|
|
1475
|
+
** n Number of elements to sort
|
|
1476
|
+
** ra Key array [1..n]
|
|
1477
|
+
** rb Index array [1..n]
|
|
1478
|
+
** Globals:
|
|
1479
|
+
** Operation:
|
|
1480
|
+
** Sort Key array in ascending order using heap sort
|
|
1481
|
+
** algorithm. Also sort Index array that is tied to
|
|
1482
|
+
** the key array.
|
|
1483
|
+
** Return:
|
|
1484
|
+
** Exceptions: none
|
|
1485
|
+
** History: Tue Feb 19 10:24:24 MST 1991, RWM, Created.
|
|
1486
|
+
*/
|
|
1487
|
+
register int i, rra, rrb;
|
|
1488
|
+
int l, j, ir;
|
|
1489
|
+
|
|
1490
|
+
l = (n >> 1) + 1;
|
|
1491
|
+
ir = n;
|
|
1492
|
+
for (;;) {
|
|
1493
|
+
if (l > 1) {
|
|
1494
|
+
rra = ra[--l];
|
|
1495
|
+
rrb = rb[l];
|
|
1496
|
+
}
|
|
1497
|
+
else {
|
|
1498
|
+
rra = ra[ir];
|
|
1499
|
+
rrb = rb[ir];
|
|
1500
|
+
ra[ir] = ra[1];
|
|
1501
|
+
rb[ir] = rb[1];
|
|
1502
|
+
if (--ir == 1) {
|
|
1503
|
+
ra[1] = rra;
|
|
1504
|
+
rb[1] = rrb;
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
i = l;
|
|
1509
|
+
j = l << 1;
|
|
1510
|
+
while (j <= ir) {
|
|
1511
|
+
if (j < ir && ra[j] < ra[j + 1])
|
|
1512
|
+
++j;
|
|
1513
|
+
if (rra < ra[j]) {
|
|
1514
|
+
ra[i] = ra[j];
|
|
1515
|
+
rb[i] = rb[j];
|
|
1516
|
+
j += (i = j);
|
|
1517
|
+
}
|
|
1518
|
+
else
|
|
1519
|
+
j = ir + 1;
|
|
1520
|
+
}
|
|
1521
|
+
ra[i] = rra;
|
|
1522
|
+
rb[i] = rrb;
|
|
1523
|
+
}
|
|
1524
|
+
}
|