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 Summary
Nested classes/interfaces inherited from class com.sun.jna.Structure
com.sun.jna.Structure.FieldOrder, com.sun.jna.Structure.StructField
-
Field Summary
Modifier and TypeFieldDescriptionint
set to 1 when averaged bitmaps are made
C type : l_int32bmf fonts
C type : L_Bmf*int
font size of bmf; default is 6 pt
C type : l_int32com.sun.jna.ptr.IntByReference
table for finding centroids
C type : l_int32*int
expected number of classes in charset
C type : l_int32int
one of L_ARABIC_NUMERALS, etc.
C type : l_int32temp data used for image decoding
C type : L_Rdid*index-to-char lut for arbitrary charset
C type : L_Dna*int
use a value > 0 to convert the bitmap
C type : l_int32float
max of max/min template height ratio
C type : l_float32int
max component height kept in splitting
C type : l_int32float
max width/height ratio to split
C type : l_float32int
initialize container arrays to this
C type : l_int32int
max height averaged unscaled templates
C type : l_int32int
max width averaged scaled templates
C type : l_int32int
max width averaged unscaled templates
C type : l_int32int
vertical jiggle on nominal centroid
C type : l_int32int
min number of samples without padding
C type : l_int32int
min component width kept in splitting
C type : l_int32int
min height averaged unscaled templates
C type : l_int32int
min width averaged scaled templates
C type : l_int32int
min width averaged unscaled templates
C type : l_int32area of all (scaled) templates
C type : Numaa*area of all unscaled templates
C type : Numaa*area of (scaled) averaged templates
C type : Numa*area of unscaled averaged templates
C type : Numa*int
number of training samples
C type : l_int32averaged (scaled) templates per class
C type : Pixa*input images for identifying
C type : Pixa*all input training images
C type : Pixa*averaged unscaled templates per class
C type : Pixa*all (scaled) templates for each class
C type : Pixaa*all unscaled templates for each class
C type : Pixaa*unscaled and scaled averaged bitmaps
C type : Pixa*debug: bootstrap training results
C type : Pixa*debug: splitting results
C type : Pixa*debug: best match of input against ave.
C type : Pix*debug: best matches within range
C type : Pix*centroids of (scaled) ave.centroids of unscaled ave.centroids of all (scaledl) templates
C type : Ptaa*centroids of all unscaled templates
C type : Ptaa*temp data used for holding best char
C type : L_Rch*temp data used for array of best chars
C type : L_Rcha*text array for arbitrary charset
C type : Sarray*int
scale all examples to this height;
C type : l_int32int
scale all examples to this width;
C type : l_int32int
size of character set
C type : l_int32com.sun.jna.ptr.IntByReference
table for finding pixel sums
C type : l_int32*int
template use: use either the average
C type : l_int32int
for binarizing if depth > 1
C type : l_int32int
set to 1 when training is complete or
C type : l_int32Fields inherited from class com.sun.jna.Structure
ALIGN_DEFAULT, ALIGN_GNUC, ALIGN_MSVC, ALIGN_NONE, CALCULATE_SIZE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets this Structure's field names in their proper order.Methods inherited from class com.sun.jna.Structure
allocateMemory, 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
-
scalew
public int scalewscale all examples to this width;
C type : l_int32 -
scaleh
public int scalehscale all examples to this height;
C type : l_int32 -
linew
public int linewuse a value > 0 to convert the bitmap
C type : l_int32 -
templ_use
public int templ_usetemplate use: use either the average
C type : l_int32 -
maxarraysize
public int maxarraysizeinitialize container arrays to this
C type : l_int32 -
setsize
public int setsizesize of character set
C type : l_int32 -
threshold
public int thresholdfor binarizing if depth > 1
C type : l_int32 -
maxyshift
public int maxyshiftvertical jiggle on nominal centroid
C type : l_int32 -
charset_type
public int charset_typeone of L_ARABIC_NUMERALS, etc.
C type : l_int32 -
charset_size
public int charset_sizeexpected number of classes in charset
C type : l_int32 -
min_nopad
public int min_nopadmin number of samples without padding
C type : l_int32 -
num_samples
public int num_samplesnumber of training samples
C type : l_int32 -
minwidth_u
public int minwidth_umin width averaged unscaled templates
C type : l_int32 -
maxwidth_u
public int maxwidth_umax width averaged unscaled templates
C type : l_int32 -
minheight_u
public int minheight_umin height averaged unscaled templates
C type : l_int32 -
maxheight_u
public int maxheight_umax height averaged unscaled templates
C type : l_int32 -
minwidth
public int minwidthmin width averaged scaled templates
C type : l_int32 -
maxwidth
public int maxwidthmax width averaged scaled templates
C type : l_int32 -
ave_done
public int ave_doneset to 1 when averaged bitmaps are made
C type : l_int32 -
train_done
public int train_doneset to 1 when training is complete or
C type : l_int32 -
max_wh_ratio
public float max_wh_ratiomax width/height ratio to split
C type : l_float32 -
max_ht_ratio
public float max_ht_ratiomax of max/min template height ratio
C type : l_float32 -
min_splitw
public int min_splitwmin component width kept in splitting
C type : l_int32 -
max_splith
public int max_splithmax component height kept in splitting
C type : l_int32 -
sa_text
text array for arbitrary charset
C type : Sarray* -
dna_tochar
index-to-char lut for arbitrary charset
C type : L_Dna* -
centtab
public com.sun.jna.ptr.IntByReference centtabtable for finding centroids
C type : l_int32* -
sumtab
public com.sun.jna.ptr.IntByReference sumtabtable for finding pixel sums
C type : l_int32* -
pixaa_u
all unscaled templates for each class
C type : Pixaa* -
ptaa_u
centroids of all unscaled templates
C type : Ptaa* -
naasum_u
area of all unscaled templates
C type : Numaa* -
pixaa
all (scaled) templates for each class
C type : Pixaa* -
ptaa
centroids of all (scaledl) templates
C type : Ptaa* -
naasum
area of all (scaled) templates
C type : Numaa* -
pixa_u
averaged unscaled templates per class
C type : Pixa* -
pta_u
centroids of unscaled ave. templates
C type : Pta* -
nasum_u
area of unscaled averaged templates
C type : Numa* -
pixa
averaged (scaled) templates per class
C type : Pixa* -
pta
centroids of (scaled) ave. templates
C type : Pta* -
nasum
area of (scaled) averaged templates
C type : Numa* -
pixa_tr
all input training images
C type : Pixa* -
pixadb_ave
unscaled and scaled averaged bitmaps
C type : Pixa* -
pixa_id
input images for identifying
C type : Pixa* -
pixdb_ave
debug: best match of input against ave.
C type : Pix* -
pixdb_range
debug: best matches within range
C type : Pix* -
pixadb_boot
debug: bootstrap training results
C type : Pixa* -
pixadb_split
debug: splitting results
C type : Pixa* -
bmf
bmf fonts
C type : L_Bmf* -
bmf_size
public int bmf_sizefont size of bmf; default is 6 pt
C type : l_int32 -
did
temp data used for image decoding
C type : L_Rdid* -
rch
temp data used for holding best char
C type : L_Rch* -
rcha
temp data used for array of best chars
C type : L_Rcha*
-
-
Constructor Details
-
L_Recog
public L_Recog() -
L_Recog
public L_Recog(com.sun.jna.Pointer peer)
-
-
Method Details
-
getFieldOrder
Gets this Structure's field names in their proper order.- Overrides:
getFieldOrder
in classcom.sun.jna.Structure
- Returns:
- list of ordered field names
-