tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
IntegerMatcher Class Reference

#include <intmatcher.h>

Collaboration diagram for IntegerMatcher:

Public Member Functions

 IntegerMatcher (tesseract::IntParam *classify_debug_level)
 
void Match (INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, int16_t NumFeatures, const INT_FEATURE_STRUCT *Features, tesseract::UnicharRating *Result, int AdaptFeatureThreshold, int Debug, bool SeparateDebugWindows)
 
float ApplyCNCorrection (float rating, int blob_length, int normalization_factor, int matcher_multiplier)
 
int FindGoodProtos (INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, uint16_t BlobLength, int16_t NumFeatures, INT_FEATURE_ARRAY Features, PROTO_ID *ProtoArray, int AdaptProtoThreshold, int Debug)
 
int FindBadFeatures (INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, uint16_t BlobLength, int16_t NumFeatures, INT_FEATURE_ARRAY Features, FEATURE_ID *FeatureArray, int AdaptFeatureThreshold, int Debug)
 

Static Public Attributes

static const int kIntThetaFudge = 128
 
static const int kEvidenceTableBits = 9
 
static const int kIntEvidenceTruncBits = 14
 
static const float kSEExponentialMultiplier = 0.0
 
static const float kSimilarityCenter = 0.0075
 

Private Member Functions

int UpdateTablesForFeature (INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, int FeatureNum, const INT_FEATURE_STRUCT *Feature, ScratchEvidence *evidence, int Debug)
 
int FindBestMatch (INT_CLASS ClassTemplate, const ScratchEvidence &tables, tesseract::UnicharRating *Result)
 
void DebugFeatureProtoError (INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, const ScratchEvidence &tables, int16_t NumFeatures, int Debug)
 
void DisplayProtoDebugInfo (INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, const ScratchEvidence &tables, bool SeparateDebugWindows)
 
void DisplayFeatureDebugInfo (INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, int16_t NumFeatures, const INT_FEATURE_STRUCT *Features, int AdaptFeatureThreshold, int Debug, bool SeparateDebugWindows)
 

Private Attributes

tesseract::IntParamclassify_debug_level_
 
uint8_t similarity_evidence_table_ [512]
 
uint32_t evidence_table_mask_
 
uint32_t mult_trunc_shift_bits_
 
uint32_t table_trunc_shift_bits_
 
uint32_t evidence_mult_mask_
 

Constructor & Destructor Documentation

◆ IntegerMatcher()

IntegerMatcher::IntegerMatcher ( tesseract::IntParam classify_debug_level)

Member Function Documentation

◆ ApplyCNCorrection()

float IntegerMatcher::ApplyCNCorrection ( float  rating,
int  blob_length,
int  normalization_factor,
int  matcher_multiplier 
)

Applies the CN normalization factor to the given rating and returns the modified rating.

◆ DebugFeatureProtoError()

void IntegerMatcher::DebugFeatureProtoError ( INT_CLASS  ClassTemplate,
BIT_VECTOR  ProtoMask,
BIT_VECTOR  ConfigMask,
const ScratchEvidence tables,
int16_t  NumFeatures,
int  Debug 
)
private

Print debugging information for Configurations

Returns
none

◆ DisplayFeatureDebugInfo()

void IntegerMatcher::DisplayFeatureDebugInfo ( INT_CLASS  ClassTemplate,
BIT_VECTOR  ProtoMask,
BIT_VECTOR  ConfigMask,
int16_t  NumFeatures,
const INT_FEATURE_STRUCT Features,
int  AdaptFeatureThreshold,
int  Debug,
bool  SeparateDebugWindows 
)
private

◆ DisplayProtoDebugInfo()

void IntegerMatcher::DisplayProtoDebugInfo ( INT_CLASS  ClassTemplate,
BIT_VECTOR  ProtoMask,
BIT_VECTOR  ConfigMask,
const ScratchEvidence tables,
bool  SeparateDebugWindows 
)
private

◆ FindBadFeatures()

int IntegerMatcher::FindBadFeatures ( INT_CLASS  ClassTemplate,
BIT_VECTOR  ProtoMask,
BIT_VECTOR  ConfigMask,
uint16_t  BlobLength,
int16_t  NumFeatures,
INT_FEATURE_ARRAY  Features,
FEATURE_ID *  FeatureArray,
int  AdaptFeatureThreshold,
int  Debug 
)

FindBadFeatures finds all features with maximum feature-evidence < AdaptFeatureThresh. The list is ordered by increasing feature number.

Parameters
ClassTemplatePrototypes & tables for a class
ProtoMaskAND Mask for proto word
ConfigMaskAND Mask for config word
BlobLengthLength of unormalized blob
NumFeaturesNumber of features in blob
FeaturesArray of features
FeatureArrayArray of bad features
AdaptFeatureThresholdThreshold for bad features
DebugDebugger flag: 1=debugger on
Returns
Number of bad features in FeatureArray.

◆ FindBestMatch()

int IntegerMatcher::FindBestMatch ( INT_CLASS  class_template,
const ScratchEvidence tables,
tesseract::UnicharRating Result 
)
private

Find the best match for the current class and update the Result with the configuration and match rating.

Returns
The best normalized sum of evidences

◆ FindGoodProtos()

int IntegerMatcher::FindGoodProtos ( INT_CLASS  ClassTemplate,
BIT_VECTOR  ProtoMask,
BIT_VECTOR  ConfigMask,
uint16_t  BlobLength,
int16_t  NumFeatures,
INT_FEATURE_ARRAY  Features,
PROTO_ID *  ProtoArray,
int  AdaptProtoThreshold,
int  Debug 
)

FindGoodProtos finds all protos whose normalized proto-evidence exceed classify_adapt_proto_thresh. The list is ordered by increasing proto id number.

Globals:

  • local_matcher_multiplier_ Normalization factor multiplier param ClassTemplate Prototypes & tables for a class param ProtoMask AND Mask for proto word param ConfigMask AND Mask for config word param BlobLength Length of unormalized blob param NumFeatures Number of features in blob param Features Array of features param ProtoArray Array of good protos param AdaptProtoThreshold Threshold for good protos param Debug Debugger flag: 1=debugger on
    Returns
    Number of good protos in ProtoArray.

◆ Match()

void IntegerMatcher::Match ( INT_CLASS  ClassTemplate,
BIT_VECTOR  ProtoMask,
BIT_VECTOR  ConfigMask,
int16_t  NumFeatures,
const INT_FEATURE_STRUCT Features,
tesseract::UnicharRating Result,
int  AdaptFeatureThreshold,
int  Debug,
bool  SeparateDebugWindows 
)

IntegerMatcher returns the best configuration and rating for a single class. The class matched against is determined by the uniqueness of the ClassTemplate parameter. The best rating and its associated configuration are returned.

Globals:

  • local_matcher_multiplier_ Normalization factor multiplier param ClassTemplate Prototypes & tables for a class param BlobLength Length of unormalized blob param NumFeatures Number of features in blob param Features Array of features param NormalizationFactor Fudge factor from blob normalization process param Result Class rating & configuration: (0.0 -> 1.0), 0=bad, 1=good param Debug Debugger flag: 1=debugger on
    Returns
    none

◆ UpdateTablesForFeature()

int IntegerMatcher::UpdateTablesForFeature ( INT_CLASS  ClassTemplate,
BIT_VECTOR  ProtoMask,
BIT_VECTOR  ConfigMask,
int  FeatureNum,
const INT_FEATURE_STRUCT Feature,
ScratchEvidence tables,
int  Debug 
)
private

For the given feature: prune protos, compute evidence, update Feature Evidence, Proto Evidence, and Sum of Feature Evidence tables.

Parameters
ClassTemplatePrototypes & tables for a class
FeatureNumCurrent feature number (for DEBUG only)
FeaturePointer to a feature struct
tablesEvidence tables
DebugDebugger flag: 1=debugger on
Returns
none

Member Data Documentation

◆ classify_debug_level_

tesseract::IntParam* IntegerMatcher::classify_debug_level_
private

◆ evidence_mult_mask_

uint32_t IntegerMatcher::evidence_mult_mask_
private

◆ evidence_table_mask_

uint32_t IntegerMatcher::evidence_table_mask_
private

◆ kEvidenceTableBits

const int IntegerMatcher::kEvidenceTableBits = 9
static

◆ kIntEvidenceTruncBits

const int IntegerMatcher::kIntEvidenceTruncBits = 14
static

◆ kIntThetaFudge

const int IntegerMatcher::kIntThetaFudge = 128
static

◆ kSEExponentialMultiplier

const float IntegerMatcher::kSEExponentialMultiplier = 0.0
static

◆ kSimilarityCenter

const float IntegerMatcher::kSimilarityCenter = 0.0075
static

◆ mult_trunc_shift_bits_

uint32_t IntegerMatcher::mult_trunc_shift_bits_
private

◆ similarity_evidence_table_

uint8_t IntegerMatcher::similarity_evidence_table_[512]
private

◆ table_trunc_shift_bits_

uint32_t IntegerMatcher::table_trunc_shift_bits_
private

The documentation for this class was generated from the following files: