22 #include "config_auto.h"
53 #define offset_table_entries \
54 255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \
55 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \
56 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, \
57 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, \
58 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \
59 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \
60 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, \
61 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, \
62 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \
63 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \
64 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
66 #define INTMATCHER_OFFSET_TABLE_SIZE 256
68 #define next_table_entries \
69 0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6, 0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e, \
70 0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16, 0x10, 0x18, 0x18, 0x1a, \
71 0x18, 0x1c, 0x1c, 0x1e, 0, 0x20, 0x20, 0x22, 0x20, 0x24, 0x24, 0x26, \
72 0x20, 0x28, 0x28, 0x2a, 0x28, 0x2c, 0x2c, 0x2e, 0x20, 0x30, 0x30, 0x32, \
73 0x30, 0x34, 0x34, 0x36, 0x30, 0x38, 0x38, 0x3a, 0x38, 0x3c, 0x3c, 0x3e, \
74 0, 0x40, 0x40, 0x42, 0x40, 0x44, 0x44, 0x46, 0x40, 0x48, 0x48, 0x4a, \
75 0x48, 0x4c, 0x4c, 0x4e, 0x40, 0x50, 0x50, 0x52, 0x50, 0x54, 0x54, 0x56, \
76 0x50, 0x58, 0x58, 0x5a, 0x58, 0x5c, 0x5c, 0x5e, 0x40, 0x60, 0x60, 0x62, \
77 0x60, 0x64, 0x64, 0x66, 0x60, 0x68, 0x68, 0x6a, 0x68, 0x6c, 0x6c, 0x6e, \
78 0x60, 0x70, 0x70, 0x72, 0x70, 0x74, 0x74, 0x76, 0x70, 0x78, 0x78, 0x7a, \
79 0x78, 0x7c, 0x7c, 0x7e, 0, 0x80, 0x80, 0x82, 0x80, 0x84, 0x84, 0x86, \
80 0x80, 0x88, 0x88, 0x8a, 0x88, 0x8c, 0x8c, 0x8e, 0x80, 0x90, 0x90, 0x92, \
81 0x90, 0x94, 0x94, 0x96, 0x90, 0x98, 0x98, 0x9a, 0x98, 0x9c, 0x9c, 0x9e, \
82 0x80, 0xa0, 0xa0, 0xa2, 0xa0, 0xa4, 0xa4, 0xa6, 0xa0, 0xa8, 0xa8, 0xaa, \
83 0xa8, 0xac, 0xac, 0xae, 0xa0, 0xb0, 0xb0, 0xb2, 0xb0, 0xb4, 0xb4, 0xb6, \
84 0xb0, 0xb8, 0xb8, 0xba, 0xb8, 0xbc, 0xbc, 0xbe, 0x80, 0xc0, 0xc0, 0xc2, \
85 0xc0, 0xc4, 0xc4, 0xc6, 0xc0, 0xc8, 0xc8, 0xca, 0xc8, 0xcc, 0xcc, 0xce, \
86 0xc0, 0xd0, 0xd0, 0xd2, 0xd0, 0xd4, 0xd4, 0xd6, 0xd0, 0xd8, 0xd8, 0xda, \
87 0xd8, 0xdc, 0xdc, 0xde, 0xc0, 0xe0, 0xe0, 0xe2, 0xe0, 0xe4, 0xe4, 0xe6, \
88 0xe0, 0xe8, 0xe8, 0xea, 0xe8, 0xec, 0xec, 0xee, 0xe0, 0xf0, 0xf0, 0xf2, \
89 0xf0, 0xf4, 0xf4, 0xf6, 0xf0, 0xf8, 0xf8, 0xfa, 0xf8, 0xfc, 0xfc, 0xfe
95 static const uinT8*
const offset_table = &data_table[0];
96 static const uinT8*
const next_table =
116 max_classes_ = max_classes;
119 class_count_ =
new int[rounded_classes_];
120 norm_count_ =
new int[rounded_classes_];
121 sort_key_ =
new int[rounded_classes_ + 1];
122 sort_index_ =
new int[rounded_classes_ + 1];
123 for (
int i = 0; i < rounded_classes_; i++) {
126 pruning_threshold_ = 0;
132 delete []class_count_;
133 delete []norm_count_;
135 delete []sort_index_;
142 num_features_ = num_features;
144 for (
int f = 0; f < num_features; ++f) {
153 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
156 const uinT32* pruner_word_ptr =
159 uinT32 pruner_word = *pruner_word_ptr++;
212 int cutoff_strength) {
213 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
214 if (num_features_ < expected_num_features[class_id]) {
215 int deficit = expected_num_features[class_id] - num_features_;
216 class_count_[class_id] -= class_count_[class_id] * deficit /
217 (num_features_ * cutoff_strength + deficit);
225 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
227 class_count_[class_id] = 0;
233 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
237 class_count_[class_id] = 0;
247 const uinT8* normalization_factors) {
248 for (
int class_id = 0; class_id < max_classes_; class_id++) {
249 norm_count_[class_id] = class_count_[class_id] -
250 ((norm_multiplier * normalization_factors[class_id]) >> 8);
256 for (
int class_id = 0; class_id < max_classes_; class_id++) {
257 norm_count_[class_id] = class_count_[class_id];
265 bool max_of_non_fragments,
const UNICHARSET& unicharset) {
267 for (
int c = 0; c < max_classes_; ++c) {
268 if (norm_count_[c] > max_count &&
274 (!max_of_non_fragments || !unicharset.
get_fragment(c))) {
275 max_count = norm_count_[c];
279 pruning_threshold_ = (max_count * pruning_factor) >> 8;
281 if (pruning_threshold_ < 1)
282 pruning_threshold_ = 1;
284 for (
int class_id = 0; class_id < max_classes_; class_id++) {
285 if (norm_count_[class_id] >= pruning_threshold_ ||
286 class_id == keep_this) {
288 sort_index_[num_classes_] = class_id;
289 sort_key_[num_classes_] = norm_count_[class_id];
294 if (num_classes_ > 1)
295 HeapSort(num_classes_, sort_key_, sort_index_);
303 int max_num_classes = int_templates->
NumClasses;
304 for (
int f = 0; f < num_features_; ++f) {
306 tprintf(
"F=%3d(%d,%d,%d),", f, feature->
X, feature->
Y, feature->
Theta);
312 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
315 const uinT32* pruner_word_ptr =
318 uinT32 pruner_word = *pruner_word_ptr++;
319 for (
int word_class = 0; word_class < 16 &&
320 class_id < max_num_classes; ++word_class, ++class_id) {
321 if (norm_count_[class_id] >= pruning_threshold_) {
338 const uinT16* expected_num_features,
340 const uinT8* normalization_factors)
const {
341 tprintf(
"CP:%d classes, %d features:\n", num_classes_, num_features_);
342 for (
int i = 0; i < num_classes_; ++i) {
343 int class_id = sort_index_[num_classes_ - i];
346 tprintf(
"%s:Initial=%d, E=%d, Xht-adj=%d, N=%d, Rat=%.2f\n",
348 class_count_[class_id],
349 expected_num_features[class_id],
350 (norm_multiplier * normalization_factors[class_id]) >> 8,
351 sort_key_[num_classes_ - i],
352 100.0 - 100.0 * sort_key_[num_classes_ - i] /
362 for (
int c = 0; c < num_classes_; ++c) {
363 (*results)[c].Class = sort_index_[num_classes_ - c];
364 (*results)[c].Rating = 1.0 - sort_key_[num_classes_ - c] /
383 int rounded_classes_;
385 int pruning_threshold_;
410 int num_features,
int keep_this,
412 const uinT8* normalization_factors,
413 const uinT16* expected_num_features,
429 if (normalization_factors !=
NULL) {
431 normalization_factors);
440 pruner.
DebugMatch(*
this, int_templates, features);
445 normalization_factors);
478 int AdaptFeatureThreshold,
480 bool SeparateDebugWindows) {
486 cprintf (
"Integer Matcher -------------------------------------------\n");
488 tables->
Clear(ClassTemplate);
491 for (Feature = 0; Feature < NumFeatures; Feature++) {
492 int csum = UpdateTablesForFeature(ClassTemplate, ProtoMask, ConfigMask,
493 Feature, &Features[Feature],
500 #ifndef GRAPHICS_DISABLED
502 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
507 DisplayProtoDebugInfo(ClassTemplate, ProtoMask, ConfigMask,
508 *tables, SeparateDebugWindows);
512 DisplayFeatureDebugInfo(ClassTemplate, ProtoMask, ConfigMask, NumFeatures,
513 Features, AdaptFeatureThreshold, Debug,
514 SeparateDebugWindows);
519 tables->
NormalizeSums(ClassTemplate, NumFeatures, NumFeatures);
521 BestMatch = FindBestMatch(ClassTemplate, *tables, Result);
523 #ifndef GRAPHICS_DISABLED
528 cprintf(
"Match Complete --------------------------------------------\n");
562 int AdaptProtoThreshold,
565 int NumGoodProtos = 0;
570 (
"Find Good Protos -------------------------------------------\n");
572 tables->
Clear(ClassTemplate);
574 for (
int Feature = 0; Feature < NumFeatures; Feature++)
575 UpdateTablesForFeature(
576 ClassTemplate, ProtoMask, ConfigMask, Feature, &(Features[Feature]),
579 #ifndef GRAPHICS_DISABLED
581 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
586 for (
int proto = 0; proto < ClassTemplate->
NumProtos; proto++) {
589 for (
int i = 0; i < ClassTemplate->
ProtoLengths[proto]; i++)
595 if (Temp >= AdaptProtoThreshold) {
603 cprintf (
"Match Complete --------------------------------------------\n");
606 return NumGoodProtos;
633 int AdaptFeatureThreshold,
636 int NumBadFeatures = 0;
640 cprintf(
"Find Bad Features -------------------------------------------\n");
642 tables->
Clear(ClassTemplate);
644 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
645 UpdateTablesForFeature(
646 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
651 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
656 if (best < AdaptFeatureThreshold) {
657 *FeatureArray = Feature;
663 #ifndef GRAPHICS_DISABLED
665 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
670 cprintf(
"Match Complete --------------------------------------------\n");
673 return NumBadFeatures;
678 classify_debug_level_ = classify_debug_level;
683 double Similarity = ((double) IntSimilarity) / 65536.0 / 65536.0;
685 evidence = 255.0 / (evidence * evidence + 1.0);
693 similarity_evidence_table_[i] = (
uinT8) (evidence + 0.5);
697 evidence_table_mask_ =
700 table_trunc_shift_bits_ = (27 -
SE_TABLE_BITS - (mult_trunc_shift_bits_ << 1));
733 cprintf (
"F = %3d, P = %3d, E = %3d, Configs = ",
734 FeatureNum, (
int) ActualProtoNum, (
int) Evidence);
753 uinT8 *FeatureEvidence,
755 cprintf(
"F=%3d, C=", FeatureNum);
756 for (
int ConfigNum = 0; ConfigNum < ConfigCount; ConfigNum++) {
757 cprintf(
"%4d", FeatureEvidence[ConfigNum]);
773 int IntegerMatcher::UpdateTablesForFeature(
781 register uinT32 ConfigWord;
782 register uinT32 ProtoWord;
784 register uinT32 ActualProtoNum;
786 inT32 proto_word_offset;
797 uinT32 ThetaFeatureAddress;
798 register uinT8 *UINT8Pointer;
799 register int ProtoIndex;
801 register int *IntPointer;
810 XFeatureAddress = ((Feature->
X >> 2) << 1);
814 for (ProtoSetIndex = 0, ActualProtoNum = 0;
815 ProtoSetIndex < ClassTemplate->
NumProtoSets; ProtoSetIndex++) {
816 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
817 ProtoPrunerPtr = (
uinT32 *) ((*ProtoSet).ProtoPruner);
819 ProtoNum += (PROTOS_PER_PROTO_SET >> 1), ActualProtoNum +=
820 (PROTOS_PER_PROTO_SET >> 1), ProtoMask++, ProtoPrunerPtr++) {
822 ProtoWord = *(ProtoPrunerPtr + XFeatureAddress);
823 ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress);
824 ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress);
825 ProtoWord &= *ProtoMask;
827 if (ProtoWord != 0) {
828 proto_byte = ProtoWord & 0xff;
830 proto_word_offset = 0;
831 while (ProtoWord != 0 || proto_byte != 0) {
832 while (proto_byte == 0) {
833 proto_byte = ProtoWord & 0xff;
835 proto_word_offset += 8;
837 proto_offset = offset_table[proto_byte] + proto_word_offset;
838 proto_byte = next_table[proto_byte];
839 Proto = &(ProtoSet->
Protos[ProtoNum + proto_offset]);
840 ConfigWord = Proto->
Configs[0];
841 A3 = (((Proto->
A * (Feature->
X - 128)) << 1)
842 - (Proto->
B * (Feature->
Y - 128)) + (Proto->
C << 9));
850 A3 >>= mult_trunc_shift_bits_;
851 M3 >>= mult_trunc_shift_bits_;
852 if (A3 > evidence_mult_mask_)
853 A3 = evidence_mult_mask_;
854 if (M3 > evidence_mult_mask_)
855 M3 = evidence_mult_mask_;
857 A4 = (A3 * A3) + (M3 * M3);
858 A4 >>= table_trunc_shift_bits_;
859 if (A4 > evidence_table_mask_)
862 Evidence = similarity_evidence_table_[A4];
866 ActualProtoNum + proto_offset,
867 Evidence, ConfigMask, ConfigWord);
869 ConfigWord &= *ConfigMask;
873 while (ConfigWord != 0 || config_byte != 0) {
874 while (config_byte == 0) {
875 config_byte = ConfigWord & 0xff;
879 config_offset = offset_table[config_byte];
880 config_byte = next_table[config_byte];
881 if (Evidence > UINT8Pointer[config_offset])
882 UINT8Pointer[config_offset] = Evidence;
888 ClassTemplate->
ProtoLengths[ActualProtoNum + proto_offset];
889 ProtoIndex > 0; ProtoIndex--, UINT8Pointer++) {
890 if (Evidence > *UINT8Pointer) {
891 Temp = *UINT8Pointer;
892 *UINT8Pointer = Evidence;
895 else if (Evidence == 0)
910 int SumOverConfigs = 0;
911 for (ConfigNum = ClassTemplate->
NumConfigs; ConfigNum > 0; ConfigNum--) {
912 int evidence = *UINT8Pointer++;
913 SumOverConfigs += evidence;
914 *IntPointer++ += evidence;
916 return SumOverConfigs;
926 #ifndef GRAPHICS_DISABLED
927 void IntegerMatcher::DebugFeatureProtoError(
944 cprintf(
"Configuration Mask:\n");
945 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
946 cprintf(
"%1d", (((*ConfigMask) >> ConfigNum) & 1));
949 cprintf(
"Feature Error for Configurations:\n");
950 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++) {
955 / NumFeatures / 256.0));
962 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
965 for (ProtoWordNum = 0; ProtoWordNum < 2;
966 ProtoWordNum++, ProtoMask++) {
969 ((ProtoNum < (PROTOS_PER_PROTO_SET >> 1))
970 && (ActualProtoNum < ClassTemplate->
NumProtos));
971 ProtoNum++, ActualProtoNum++)
972 cprintf (
"%1d", (((*ProtoMask) >> ProtoNum) & 1));
979 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
984 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
986 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
990 (ActualProtoNum < ClassTemplate->NumProtos));
991 ProtoNum++, ActualProtoNum++) {
992 cprintf (
"P %3d =", ActualProtoNum);
994 for (
int j = 0; j < ClassTemplate->
ProtoLengths[ActualProtoNum]; j++) {
1001 temp / 256.0 / ClassTemplate->
ProtoLengths[ActualProtoNum]);
1005 while (ConfigWord) {
1006 cprintf (
"%5d", ConfigWord & 1 ? temp : 0);
1008 ProtoConfigs[ConfigNum] += temp;
1018 cprintf (
"Proto Error for Configurations:\n");
1019 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1022 ProtoConfigs[ConfigNum] /
1028 cprintf (
"Proto Sum for Configurations:\n");
1029 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1030 cprintf (
" %4.1f", ProtoConfigs[ConfigNum] / 256.0);
1033 cprintf (
"Proto Length for Configurations:\n");
1034 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1042 void IntegerMatcher::DisplayProtoDebugInfo(
1047 bool SeparateDebugWindows) {
1054 if (SeparateDebugWindows) {
1060 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1062 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1066 (ActualProtoNum < ClassTemplate->NumProtos));
1067 ProtoNum++, ActualProtoNum++) {
1070 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1075 if ((ProtoSet->
Protos[ProtoNum]).Configs[0] & (*ConfigMask)) {
1083 void IntegerMatcher::DisplayFeatureDebugInfo(
1089 int AdaptFeatureThreshold,
1091 bool SeparateDebugWindows) {
1094 tables->
Clear(ClassTemplate);
1097 if (SeparateDebugWindows) {
1102 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
1103 UpdateTablesForFeature(
1104 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
1109 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
1115 if (best < AdaptFeatureThreshold)
1144 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1146 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1150 ProtoNum++, ActualProtoNum++) {
1152 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1156 ConfigWord &= *ConfigMask;
1158 while (ConfigWord) {
1160 *IntPointer += temp;
1177 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++) {
1191 int IntegerMatcher::FindBestMatch(
1197 result->
fonts.truncate(0);
1201 for (
int c = 0; c < class_template->
NumConfigs; ++c) {
1203 if (*classify_debug_level_ > 2)
1204 tprintf(
"Config %d, rating=%d\n", c, rating);
1205 if (rating > best_match) {
1207 best_match = rating;
1213 result->
rating = best_match / 65536.0f;
1223 int normalization_factor,
1224 int matcher_multiplier) {
1225 return (rating * blob_length +
1226 matcher_multiplier * normalization_factor / 256.0) /
1227 (blob_length + matcher_multiplier);
1242 HeapSort (
int n,
register int ra[],
register int rb[]) {
1243 register int i, rra, rrb;
1267 if (j < ir && ra[j] < ra[j + 1])
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT *templates, int class_id, int config_id) const
void SummarizeResult(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const uinT16 *expected_num_features, int norm_multiplier, const uinT8 *normalization_factors) const
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
void DisplayIntFeature(const INT_FEATURE_STRUCT *Feature, FLOAT32 Evidence)
void NormalizeSums(INT_CLASS ClassTemplate, inT16 NumFeatures, inT32 used_features)
void HeapSort(int n, register int ra[], register int rb[])
float ApplyCNCorrection(float rating, int blob_length, int normalization_factor, int matcher_multiplier)
INT_PROTO_STRUCT Protos[PROTOS_PER_PROTO_SET]
int FindBadFeatures(INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, uinT16 BlobLength, inT16 NumFeatures, INT_FEATURE_ARRAY Features, FEATURE_ID *FeatureArray, int AdaptFeatureThreshold, int Debug)
void DebugMatch(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const INT_FEATURE_STRUCT *features) const
#define INTMATCHER_OFFSET_TABLE_SIZE
void InitIntMatchWindowIfReqd()
void InitFeatureDisplayWindowIfReqd()
#define PrintFeatureMatchesOn(D)
#define PrintMatchSummaryOn(D)
void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence)
uinT8 proto_evidence_[MAX_NUM_PROTOS][MAX_PROTO_INDEX]
uinT16 ConfigLengths[MAX_NUM_CONFIGS]
void IMDebugConfiguration(int FeatureNum, uinT16 ActualProtoNum, uinT8 Evidence, BIT_VECTOR ConfigMask, uinT32 ConfigWord)
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
#define WERDS_PER_CP_VECTOR
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
void NormalizeForXheight(int norm_multiplier, const uinT8 *normalization_factors)
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
void IMDebugConfigurationSum(int FeatureNum, uinT8 *FeatureEvidence, inT32 ConfigCount)
ShapeTable * shape_table_
void InitProtoDisplayWindowIfReqd()
ClassPruner(int max_classes)
void ClearFeatureEvidence(const INT_CLASS class_template)
GenericVector< ScoredFont > fonts
void Match(INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, inT16 NumFeatures, const INT_FEATURE_STRUCT *Features, tesseract::UnicharRating *Result, int AdaptFeatureThreshold, int Debug, bool SeparateDebugWindows)
#define PrintProtoMatchesOn(D)
void UpdateSumOfProtoEvidences(INT_CLASS ClassTemplate, BIT_VECTOR ConfigMask, inT16 NumFeatures)
int classify_class_pruner_multiplier
void init_to_size(int size, T t)
int classify_class_pruner_threshold
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
int sum_feature_evidence_[MAX_NUM_CONFIGS]
#define next_table_entries
void Init(tesseract::IntParam *classify_debug_level)
static const int kIntThetaFudge
void DisableDisabledClasses(const UNICHARSET &unicharset)
void Clear(const INT_CLASS class_template)
static const float kSEExponentialMultiplier
void ComputeScores(const INT_TEMPLATES_STRUCT *int_templates, int num_features, const INT_FEATURE_STRUCT *features)
#define ClipMatchEvidenceOn(D)
static const int kEvidenceTableBits
int PruneClasses(const INT_TEMPLATES_STRUCT *int_templates, int num_features, int keep_this, const INT_FEATURE_STRUCT *features, const uinT8 *normalization_factors, const uinT16 *expected_num_features, GenericVector< CP_RESULT_STRUCT > *results)
#define MatchDebuggingOn(D)
void AdjustForExpectedNumFeatures(const uinT16 *expected_num_features, int cutoff_strength)
#define DisplayFeatureMatchesOn(D)
#define PROTOS_PER_PROTO_SET
bool get_enabled(UNICHAR_ID unichar_id) const
int RoundUp(int n, int block_size)
uinT8 feature_evidence_[MAX_NUM_CONFIGS]
#define NUM_BITS_PER_CLASS
int SetupResults(GenericVector< CP_RESULT_STRUCT > *results) const
static const float kSimilarityCenter
int FindGoodProtos(INT_CLASS ClassTemplate, BIT_VECTOR ProtoMask, BIT_VECTOR ConfigMask, uinT16 BlobLength, inT16 NumFeatures, INT_FEATURE_ARRAY Features, PROTO_ID *ProtoArray, int AdaptProtoThreshold, int Debug)
uinT32 p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
bool disable_character_fragments
#define DisplayProtoMatchesOn(D)
void PruneAndSort(int pruning_factor, int keep_this, bool max_of_non_fragments, const UNICHARSET &unicharset)
void cprintf(const char *format,...)
void DisableFragments(const UNICHARSET &unicharset)
const char * string() const
int classify_cp_cutoff_strength
#define offset_table_entries
static const int kIntEvidenceTruncBits
uinT32 Configs[WERDS_PER_CONFIG_VEC]
#define CLASS_PRUNER_CLASS_MASK