Package net.sourceforge.lept4j
Class L_Recog
java.lang.Object
com.sun.jna.Structure
net.sourceforge.lept4j.L_Recog
- Direct Known Subclasses:
- L_Recog.ByReference,- L_Recog.ByValue
public class L_Recog
extends com.sun.jna.Structure
recog.h
 
native declaration : recog.h:126
This file was autogenerated by JNAerator,
a tool written by Olivier Chafik that uses a few opensource projects..
For help, please visit NativeLibs4Java or JNA.
This is a simple utility for training and recognizing individual
machine-printed text characters. It is designed to be adapted
to a particular set of character images; e.g., from a book.
There are two methods of training the recognizer. In the most
simple, a set of bitmaps has been labeled by some means, such
a generic OCR program. This is input either one template at a time
or as a pixa of templates, to a function that creates a recog.
If in a pixa, the text string label must be embedded in the
text field of each pix.
If labeled data is not available, we start with a bootstrap
recognizer (BSR) that has labeled data from a variety of sources.
These images are scaled, typically to a fixed height, and then
fed similarly scaled unlabeled images from the source (e.g., book),
and the BSR attempts to identify them. All images that have
a high enough correlation score with one of the templates in the
BSR are emitted in a pixa, which now holds unscaled and labeled
templates from the source. This is the generator for a book adapted
recognizer (BAR).
The pixa should always be thought of as the primary structure.
It is the generator for the recog, because a recog is built
from a pixa of unscaled images.
New image templates can be added to a recog as long as it is
in training mode. Once training is finished, to add templates
it is necessary to extract the generating pixa, add templates
to that pixa, and make a new recog. Similarly, we do not
join two recog; instead, we simply join their generating pixa,
and make a recog from that.
To remove outliers from a pixa of labeled pix, make a recog,
determine the outliers, and generate a new pixa with the
outliers removed. The outliers are determined by building
special templates for each character set that are scaled averages
of the individual templates. Then a correlation score is found
between each template and the averaged templates. There are
two implementations; outliers are determined as either:
(1) a template having a correlation score with its class average
that is below a threshold, or
(2) a template having a correlation score with its class average
that is smaller than the correlation score with the average
of another class.
Outliers are removed from the generating pixa. Scaled averaging
is only performed for determining outliers and for splitting
characters; it is never used in a trained recognizer for identifying
unlabeled samples.
Two methods using averaged templates are provided for splitting
touching characters:
(1) greedy matching
(2) document image decoding (DID)
The DID method is the default. It is about 5x faster and
possibly more accurate.
Once a BAR has been made, unlabeled sample images are identified
by finding the individual template in the BAR with highest
correlation. The input images and images in the BAR can be
represented in two ways:
(1) as scanned, binarized to 1 bpp
(2) as a width-normalized outline formed by thinning to a
skeleton and then dilating by a fixed amount.
The recog can be serialized to file and read back. The serialized
version holds the templates used for correlation (which may have
been modified by scaling and turning into lines from the unscaled
templates), plus, for arbitrary character sets, the UTF8
representation and the lookup table mapping from the character
representation to index.
Why do we not use averaged templates for recognition?
Letterforms can take on significantly different shapes (eg.,
the letters 'a' and 'g'), and it makes no sense to average these.
The previous version of this utility allowed multiple recognizers
to exist, but this is an unnecessary complication if recognition
is done on all samples instead of on averages.
native declaration : recog.h:126
This file was autogenerated by JNAerator,
a tool written by Olivier Chafik that uses a few opensource projects..
For help, please visit NativeLibs4Java or JNA.
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classL_Recog.ByReferencestatic classL_Recog.ByValue
- 
Field SummaryFields Modifier and Type Field Description intave_doneset to 1 when averaged bitmaps are made
 C type : l_int32L_Bmf.ByReferencebmfbmf fonts
 C type : L_Bmf*intbmf_sizefont size of bmf; default is 6 pt
 C type : l_int32com.sun.jna.ptr.IntByReferencecenttabtable for finding centroids
 C type : l_int32*intcharset_sizeexpected number of classes in charset
 C type : l_int32intcharset_typeone of L_ARABIC_NUMERALS, etc.
 C type : l_int32L_Rdid.ByReferencedidtemp data used for image decoding
 C type : L_Rdid*L_Dna.ByReferencedna_tocharindex-to-char lut for arbitrary charset
 C type : L_Dna*intlinewuse a value > 0 to convert the bitmap
 C type : l_int32floatmax_ht_ratiomax of max/min template height ratio
 C type : l_float32intmax_splithmax component height kept in splitting
 C type : l_int32floatmax_wh_ratiomax width/height ratio to split
 C type : l_float32intmaxarraysizeinitialize container arrays to this
 C type : l_int32intmaxheight_umax height averaged unscaled templates
 C type : l_int32intmaxwidthmax width averaged scaled templates
 C type : l_int32intmaxwidth_umax width averaged unscaled templates
 C type : l_int32intmaxyshiftvertical jiggle on nominal centroid
 C type : l_int32intmin_nopadmin number of samples without padding
 C type : l_int32intmin_splitwmin component width kept in splitting
 C type : l_int32intminheight_umin height averaged unscaled templates
 C type : l_int32intminwidthmin width averaged scaled templates
 C type : l_int32intminwidth_umin width averaged unscaled templates
 C type : l_int32Numaa.ByReferencenaasumarea of all (scaled) templates
 C type : Numaa*Numaa.ByReferencenaasum_uarea of all unscaled templates
 C type : Numaa*Numa.ByReferencenasumarea of (scaled) averaged templates
 C type : Numa*Numa.ByReferencenasum_uarea of unscaled averaged templates
 C type : Numa*intnum_samplesnumber of training samples
 C type : l_int32Pixa.ByReferencepixaaveraged (scaled) templates per class
 C type : Pixa*Pixa.ByReferencepixa_idinput images for identifying
 C type : Pixa*Pixa.ByReferencepixa_trall input training images
 C type : Pixa*Pixa.ByReferencepixa_uaveraged unscaled templates per class
 C type : Pixa*Pixaa.ByReferencepixaaall (scaled) templates for each class
 C type : Pixaa*Pixaa.ByReferencepixaa_uall unscaled templates for each class
 C type : Pixaa*Pixa.ByReferencepixadb_aveunscaled and scaled averaged bitmaps
 C type : Pixa*Pixa.ByReferencepixadb_bootdebug: bootstrap training results
 C type : Pixa*Pixa.ByReferencepixadb_splitdebug: splitting results
 C type : Pixa*Pix.ByReferencepixdb_avedebug: best match of input against ave.
 C type : Pix*Pix.ByReferencepixdb_rangedebug: best matches within range
 C type : Pix*Pta.ByReferenceptacentroids of (scaled) ave.Pta.ByReferencepta_ucentroids of unscaled ave.Ptaa.ByReferenceptaacentroids of all (scaledl) templates
 C type : Ptaa*Ptaa.ByReferenceptaa_ucentroids of all unscaled templates
 C type : Ptaa*L_Rch.ByReferencerchtemp data used for holding best char
 C type : L_Rch*L_Rcha.ByReferencerchatemp data used for array of best chars
 C type : L_Rcha*Sarray.ByReferencesa_texttext array for arbitrary charset
 C type : Sarray*intscalehscale all examples to this height;
 C type : l_int32intscalewscale all examples to this width;
 C type : l_int32intsetsizesize of character set
 C type : l_int32com.sun.jna.ptr.IntByReferencesumtabtable for finding pixel sums
 C type : l_int32*inttempl_usetemplate use: use either the average
 C type : l_int32intthresholdfor binarizing if depth > 1
 C type : l_int32inttrain_doneset to 1 when training is complete or
 C type : l_int32
- 
Constructor Summary
- 
Method SummaryModifier and Type Method Description protected java.util.List<java.lang.String>getFieldOrder()Gets this Structure's field names in their proper order.Methods inherited from class com.sun.jna.StructureallocateMemory, allocateMemory, autoAllocate, autoRead, autoRead, autoWrite, autoWrite, cacheTypeInfo, calculateSize, clear, createFieldsOrder, createFieldsOrder, createFieldsOrder, createFieldsOrder, dataEquals, dataEquals, ensureAllocated, equals, fieldOffset, getAutoRead, getAutoWrite, getFieldList, getFields, getNativeAlignment, getNativeSize, getNativeSize, getPointer, getStringEncoding, getStructAlignment, hashCode, newInstance, newInstance, read, readField, readField, setAlignType, setAutoRead, setAutoSynch, setAutoWrite, setStringEncoding, size, sortFields, toArray, toArray, toString, toString, useMemory, useMemory, write, writeField, writeField, writeField
- 
Field Details- 
scalewpublic int scalewscale all examples to this width;
 C type : l_int32
- 
scalehpublic int scalehscale all examples to this height;
 C type : l_int32
- 
linewpublic int linewuse a value > 0 to convert the bitmap
 C type : l_int32
- 
templ_usepublic int templ_usetemplate use: use either the average
 C type : l_int32
- 
maxarraysizepublic int maxarraysizeinitialize container arrays to this
 C type : l_int32
- 
setsizepublic int setsizesize of character set
 C type : l_int32
- 
thresholdpublic int thresholdfor binarizing if depth > 1
 C type : l_int32
- 
maxyshiftpublic int maxyshiftvertical jiggle on nominal centroid
 C type : l_int32
- 
charset_typepublic int charset_typeone of L_ARABIC_NUMERALS, etc.
 C type : l_int32
- 
charset_sizepublic int charset_sizeexpected number of classes in charset
 C type : l_int32
- 
min_nopadpublic int min_nopadmin number of samples without padding
 C type : l_int32
- 
num_samplespublic int num_samplesnumber of training samples
 C type : l_int32
- 
minwidth_upublic int minwidth_umin width averaged unscaled templates
 C type : l_int32
- 
maxwidth_upublic int maxwidth_umax width averaged unscaled templates
 C type : l_int32
- 
minheight_upublic int minheight_umin height averaged unscaled templates
 C type : l_int32
- 
maxheight_upublic int maxheight_umax height averaged unscaled templates
 C type : l_int32
- 
minwidthpublic int minwidthmin width averaged scaled templates
 C type : l_int32
- 
maxwidthpublic int maxwidthmax width averaged scaled templates
 C type : l_int32
- 
ave_donepublic int ave_doneset to 1 when averaged bitmaps are made
 C type : l_int32
- 
train_donepublic int train_doneset to 1 when training is complete or
 C type : l_int32
- 
max_wh_ratiopublic float max_wh_ratiomax width/height ratio to split
 C type : l_float32
- 
max_ht_ratiopublic float max_ht_ratiomax of max/min template height ratio
 C type : l_float32
- 
min_splitwpublic int min_splitwmin component width kept in splitting
 C type : l_int32
- 
max_splithpublic int max_splithmax component height kept in splitting
 C type : l_int32
- 
sa_texttext array for arbitrary charset
 C type : Sarray*
- 
dna_tocharindex-to-char lut for arbitrary charset
 C type : L_Dna*
- 
centtabpublic com.sun.jna.ptr.IntByReference centtabtable for finding centroids
 C type : l_int32*
- 
sumtabpublic com.sun.jna.ptr.IntByReference sumtabtable for finding pixel sums
 C type : l_int32*
- 
pixaa_uall unscaled templates for each class
 C type : Pixaa*
- 
ptaa_ucentroids of all unscaled templates
 C type : Ptaa*
- 
naasum_uarea of all unscaled templates
 C type : Numaa*
- 
pixaaall (scaled) templates for each class
 C type : Pixaa*
- 
ptaacentroids of all (scaledl) templates
 C type : Ptaa*
- 
naasumarea of all (scaled) templates
 C type : Numaa*
- 
pixa_uaveraged unscaled templates per class
 C type : Pixa*
- 
pta_ucentroids of unscaled ave. templates
 C type : Pta*
- 
nasum_uarea of unscaled averaged templates
 C type : Numa*
- 
pixaaveraged (scaled) templates per class
 C type : Pixa*
- 
ptacentroids of (scaled) ave. templates
 C type : Pta*
- 
nasumarea of (scaled) averaged templates
 C type : Numa*
- 
pixa_trall input training images
 C type : Pixa*
- 
pixadb_aveunscaled and scaled averaged bitmaps
 C type : Pixa*
- 
pixa_idinput images for identifying
 C type : Pixa*
- 
pixdb_avedebug: best match of input against ave.
 C type : Pix*
- 
pixdb_rangedebug: best matches within range
 C type : Pix*
- 
pixadb_bootdebug: bootstrap training results
 C type : Pixa*
- 
pixadb_splitdebug: splitting results
 C type : Pixa*
- 
bmfbmf fonts
 C type : L_Bmf*
- 
bmf_sizepublic int bmf_sizefont size of bmf; default is 6 pt
 C type : l_int32
- 
didtemp data used for image decoding
 C type : L_Rdid*
- 
rchtemp data used for holding best char
 C type : L_Rch*
- 
rchatemp data used for array of best chars
 C type : L_Rcha*
 
- 
- 
Constructor Details
- 
Method Details- 
getFieldOrderprotected java.util.List<java.lang.String> getFieldOrder()Gets this Structure's field names in their proper order.- Overrides:
- getFieldOrderin class- com.sun.jna.Structure
- Returns:
- list of ordered field names
 
 
-