19 #include "config_auto.h" 50 #define offset_table_entries \ 51 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, \ 52 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \ 53 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, \ 54 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, \ 55 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \ 56 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \ 57 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, \ 58 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, \ 59 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, \ 60 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, \ 61 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 63 #define INTMATCHER_OFFSET_TABLE_SIZE 256 65 #define next_table_entries \ 66 0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6, 0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e, \ 67 0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16, 0x10, 0x18, 0x18, 0x1a, \ 68 0x18, 0x1c, 0x1c, 0x1e, 0, 0x20, 0x20, 0x22, 0x20, 0x24, 0x24, 0x26, \ 69 0x20, 0x28, 0x28, 0x2a, 0x28, 0x2c, 0x2c, 0x2e, 0x20, 0x30, 0x30, 0x32, \ 70 0x30, 0x34, 0x34, 0x36, 0x30, 0x38, 0x38, 0x3a, 0x38, 0x3c, 0x3c, 0x3e, \ 71 0, 0x40, 0x40, 0x42, 0x40, 0x44, 0x44, 0x46, 0x40, 0x48, 0x48, 0x4a, \ 72 0x48, 0x4c, 0x4c, 0x4e, 0x40, 0x50, 0x50, 0x52, 0x50, 0x54, 0x54, 0x56, \ 73 0x50, 0x58, 0x58, 0x5a, 0x58, 0x5c, 0x5c, 0x5e, 0x40, 0x60, 0x60, 0x62, \ 74 0x60, 0x64, 0x64, 0x66, 0x60, 0x68, 0x68, 0x6a, 0x68, 0x6c, 0x6c, 0x6e, \ 75 0x60, 0x70, 0x70, 0x72, 0x70, 0x74, 0x74, 0x76, 0x70, 0x78, 0x78, 0x7a, \ 76 0x78, 0x7c, 0x7c, 0x7e, 0, 0x80, 0x80, 0x82, 0x80, 0x84, 0x84, 0x86, \ 77 0x80, 0x88, 0x88, 0x8a, 0x88, 0x8c, 0x8c, 0x8e, 0x80, 0x90, 0x90, 0x92, \ 78 0x90, 0x94, 0x94, 0x96, 0x90, 0x98, 0x98, 0x9a, 0x98, 0x9c, 0x9c, 0x9e, \ 79 0x80, 0xa0, 0xa0, 0xa2, 0xa0, 0xa4, 0xa4, 0xa6, 0xa0, 0xa8, 0xa8, 0xaa, \ 80 0xa8, 0xac, 0xac, 0xae, 0xa0, 0xb0, 0xb0, 0xb2, 0xb0, 0xb4, 0xb4, 0xb6, \ 81 0xb0, 0xb8, 0xb8, 0xba, 0xb8, 0xbc, 0xbc, 0xbe, 0x80, 0xc0, 0xc0, 0xc2, \ 82 0xc0, 0xc4, 0xc4, 0xc6, 0xc0, 0xc8, 0xc8, 0xca, 0xc8, 0xcc, 0xcc, 0xce, \ 83 0xc0, 0xd0, 0xd0, 0xd2, 0xd0, 0xd4, 0xd4, 0xd6, 0xd0, 0xd8, 0xd8, 0xda, \ 84 0xd8, 0xdc, 0xdc, 0xde, 0xc0, 0xe0, 0xe0, 0xe2, 0xe0, 0xe4, 0xe4, 0xe6, \ 85 0xe0, 0xe8, 0xe8, 0xea, 0xe8, 0xec, 0xec, 0xee, 0xe0, 0xf0, 0xf0, 0xf2, \ 86 0xf0, 0xf4, 0xf4, 0xf6, 0xf0, 0xf8, 0xf8, 0xfa, 0xf8, 0xfc, 0xfc, 0xfe 92 static const uint8_t*
const offset_table = &data_table[0];
93 static const uint8_t*
const next_table =
113 max_classes_ = max_classes;
116 class_count_ =
new int[rounded_classes_];
117 norm_count_ =
new int[rounded_classes_];
118 sort_key_ =
new int[rounded_classes_ + 1];
119 sort_index_ =
new int[rounded_classes_ + 1];
120 for (
int i = 0; i < rounded_classes_; i++) {
123 pruning_threshold_ = 0;
129 delete []class_count_;
130 delete []norm_count_;
132 delete []sort_index_;
139 num_features_ = num_features;
141 for (
int f = 0; f < num_features; ++f) {
150 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
153 const uint32_t* pruner_word_ptr =
156 uint32_t pruner_word = *pruner_word_ptr++;
209 int cutoff_strength) {
210 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
211 if (num_features_ < expected_num_features[class_id]) {
212 int deficit = expected_num_features[class_id] - num_features_;
213 class_count_[class_id] -= class_count_[class_id] * deficit /
214 (num_features_ * cutoff_strength + deficit);
222 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
224 class_count_[class_id] = 0;
230 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
234 class_count_[class_id] = 0;
244 const uint8_t* normalization_factors) {
245 for (
int class_id = 0; class_id < max_classes_; class_id++) {
246 norm_count_[class_id] = class_count_[class_id] -
247 ((norm_multiplier * normalization_factors[class_id]) >> 8);
253 for (
int class_id = 0; class_id < max_classes_; class_id++) {
254 norm_count_[class_id] = class_count_[class_id];
262 bool max_of_non_fragments,
const UNICHARSET& unicharset) {
264 for (
int c = 0; c < max_classes_; ++c) {
265 if (norm_count_[c] > max_count &&
271 (!max_of_non_fragments || !unicharset.
get_fragment(c))) {
272 max_count = norm_count_[c];
276 pruning_threshold_ = (max_count * pruning_factor) >> 8;
278 if (pruning_threshold_ < 1)
279 pruning_threshold_ = 1;
281 for (
int class_id = 0; class_id < max_classes_; class_id++) {
282 if (norm_count_[class_id] >= pruning_threshold_ ||
283 class_id == keep_this) {
285 sort_index_[num_classes_] = class_id;
286 sort_key_[num_classes_] = norm_count_[class_id];
291 if (num_classes_ > 1)
292 HeapSort(num_classes_, sort_key_, sort_index_);
301 int max_num_classes = int_templates->
NumClasses;
302 for (
int f = 0; f < num_features_; ++f) {
304 tprintf(
"F=%3d(%d,%d,%d),", f, feature->
X, feature->
Y, feature->
Theta);
310 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
313 const uint32_t* pruner_word_ptr =
316 uint32_t pruner_word = *pruner_word_ptr++;
317 for (
int word_class = 0; word_class < 16 &&
318 class_id < max_num_classes; ++word_class, ++class_id) {
319 if (norm_count_[class_id] >= pruning_threshold_) {
336 const uint16_t* expected_num_features,
338 const uint8_t* normalization_factors)
const {
339 tprintf(
"CP:%d classes, %d features:\n", num_classes_, num_features_);
340 for (
int i = 0; i < num_classes_; ++i) {
341 int class_id = sort_index_[num_classes_ - i];
344 tprintf(
"%s:Initial=%d, E=%d, Xht-adj=%d, N=%d, Rat=%.2f\n",
346 class_count_[class_id],
347 expected_num_features[class_id],
348 (norm_multiplier * normalization_factors[class_id]) >> 8,
349 sort_key_[num_classes_ - i],
350 100.0 - 100.0 * sort_key_[num_classes_ - i] /
360 for (
int c = 0; c < num_classes_; ++c) {
361 (*results)[c].Class = sort_index_[num_classes_ - c];
362 (*results)[c].Rating = 1.0 - sort_key_[num_classes_ - c] /
382 int rounded_classes_;
384 int pruning_threshold_;
410 int num_features,
int keep_this,
412 const uint8_t* normalization_factors,
413 const uint16_t* expected_num_features,
429 if (normalization_factors !=
nullptr) {
431 normalization_factors);
440 pruner.
DebugMatch(*
this, int_templates, features);
445 normalization_factors);
476 int AdaptFeatureThreshold,
478 bool SeparateDebugWindows) {
483 cprintf (
"Integer Matcher -------------------------------------------\n");
485 tables->
Clear(ClassTemplate);
488 for (Feature = 0; Feature < NumFeatures; Feature++) {
489 int csum = UpdateTablesForFeature(ClassTemplate, ProtoMask, ConfigMask,
490 Feature, &Features[Feature],
497 #ifndef GRAPHICS_DISABLED 499 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
504 DisplayProtoDebugInfo(ClassTemplate, ProtoMask, ConfigMask,
505 *tables, SeparateDebugWindows);
509 DisplayFeatureDebugInfo(ClassTemplate, ProtoMask, ConfigMask, NumFeatures,
510 Features, AdaptFeatureThreshold, Debug,
511 SeparateDebugWindows);
516 tables->
NormalizeSums(ClassTemplate, NumFeatures, NumFeatures);
518 FindBestMatch(ClassTemplate, *tables, Result);
520 #ifndef GRAPHICS_DISABLED 525 cprintf(
"Match Complete --------------------------------------------\n");
557 int AdaptProtoThreshold,
560 int NumGoodProtos = 0;
565 (
"Find Good Protos -------------------------------------------\n");
567 tables->
Clear(ClassTemplate);
569 for (
int Feature = 0; Feature < NumFeatures; Feature++)
570 UpdateTablesForFeature(
571 ClassTemplate, ProtoMask, ConfigMask, Feature, &(Features[Feature]),
574 #ifndef GRAPHICS_DISABLED 576 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
581 for (
int proto = 0; proto < ClassTemplate->
NumProtos; proto++) {
584 for (
int i = 0; i < ClassTemplate->
ProtoLengths[proto]; i++)
590 if (Temp >= AdaptProtoThreshold) {
598 cprintf (
"Match Complete --------------------------------------------\n");
601 return NumGoodProtos;
626 int AdaptFeatureThreshold,
629 int NumBadFeatures = 0;
633 cprintf(
"Find Bad Features -------------------------------------------\n");
635 tables->
Clear(ClassTemplate);
637 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
638 UpdateTablesForFeature(
639 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
644 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
649 if (best < AdaptFeatureThreshold) {
650 *FeatureArray = Feature;
656 #ifndef GRAPHICS_DISABLED 658 DebugFeatureProtoError(ClassTemplate, ProtoMask, ConfigMask, *tables,
663 cprintf(
"Match Complete --------------------------------------------\n");
666 return NumBadFeatures;
671 : classify_debug_level_(classify_debug_level)
676 double Similarity = ((double) IntSimilarity) / 65536.0 / 65536.0;
678 evidence = 255.0 / (evidence * evidence + 1.0);
686 similarity_evidence_table_[i] = (uint8_t) (evidence + 0.5);
690 evidence_table_mask_ =
693 table_trunc_shift_bits_ = (27 -
SE_TABLE_BITS - (mult_trunc_shift_bits_ << 1));
718 uint32_t ConfigWord) {
719 cprintf (
"F = %3d, P = %3d, E = %3d, Configs = ",
720 FeatureNum, (
int) ActualProtoNum, (
int) Evidence);
736 int32_t ConfigCount) {
737 cprintf(
"F=%3d, C=", FeatureNum);
738 for (
int ConfigNum = 0; ConfigNum < ConfigCount; ConfigNum++) {
739 cprintf(
"%4d", FeatureEvidence[ConfigNum]);
755 int IntegerMatcher::UpdateTablesForFeature(
766 uint32_t ActualProtoNum;
768 int32_t proto_word_offset;
769 int32_t proto_offset;
771 int32_t config_offset;
773 uint32_t *ProtoPrunerPtr;
777 uint32_t XFeatureAddress;
778 uint32_t YFeatureAddress;
779 uint32_t ThetaFeatureAddress;
780 uint8_t* UINT8Pointer;
792 XFeatureAddress = ((Feature->
X >> 2) << 1);
796 for (ProtoSetIndex = 0, ActualProtoNum = 0;
797 ProtoSetIndex < ClassTemplate->
NumProtoSets; ProtoSetIndex++) {
798 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
799 ProtoPrunerPtr = (uint32_t *) ((*ProtoSet).ProtoPruner);
804 ProtoWord = *(ProtoPrunerPtr + XFeatureAddress);
805 ProtoWord &= *(ProtoPrunerPtr + YFeatureAddress);
806 ProtoWord &= *(ProtoPrunerPtr + ThetaFeatureAddress);
807 ProtoWord &= *ProtoMask;
809 if (ProtoWord != 0) {
810 proto_byte = ProtoWord & 0xff;
812 proto_word_offset = 0;
813 while (ProtoWord != 0 || proto_byte != 0) {
814 while (proto_byte == 0) {
815 proto_byte = ProtoWord & 0xff;
817 proto_word_offset += 8;
819 proto_offset = offset_table[proto_byte] + proto_word_offset;
820 proto_byte = next_table[proto_byte];
821 Proto = &(ProtoSet->
Protos[ProtoNum + proto_offset]);
822 ConfigWord = Proto->
Configs[0];
823 A3 = (((Proto->
A * (Feature->
X - 128)) << 1)
824 - (Proto->
B * (Feature->
Y - 128)) + (Proto->
C << 9));
832 A3 >>= mult_trunc_shift_bits_;
833 M3 >>= mult_trunc_shift_bits_;
834 if (static_cast<uint32_t>(A3) > evidence_mult_mask_)
835 A3 = evidence_mult_mask_;
836 if (static_cast<uint32_t>(M3) > evidence_mult_mask_)
837 M3 = evidence_mult_mask_;
839 A4 = (A3 * A3) + (M3 * M3);
840 A4 >>= table_trunc_shift_bits_;
841 if (A4 > evidence_table_mask_)
844 Evidence = similarity_evidence_table_[A4];
848 ActualProtoNum + proto_offset,
849 Evidence, ConfigMask, ConfigWord);
851 ConfigWord &= *ConfigMask;
855 while (ConfigWord != 0 || config_byte != 0) {
856 while (config_byte == 0) {
857 config_byte = ConfigWord & 0xff;
861 config_offset = offset_table[config_byte];
862 config_byte = next_table[config_byte];
863 if (Evidence > UINT8Pointer[config_offset])
864 UINT8Pointer[config_offset] = Evidence;
870 ClassTemplate->
ProtoLengths[ActualProtoNum + proto_offset];
871 ProtoIndex > 0; ProtoIndex--, UINT8Pointer++) {
872 if (Evidence > *UINT8Pointer) {
873 Temp = *UINT8Pointer;
874 *UINT8Pointer = Evidence;
877 else if (Evidence == 0)
892 int SumOverConfigs = 0;
893 for (ConfigNum = ClassTemplate->
NumConfigs; ConfigNum > 0; ConfigNum--) {
894 int evidence = *UINT8Pointer++;
895 SumOverConfigs += evidence;
896 *IntPointer++ += evidence;
898 return SumOverConfigs;
905 #ifndef GRAPHICS_DISABLED 906 void IntegerMatcher::DebugFeatureProtoError(
918 uint8_t ProtoWordNum;
920 uint16_t ActualProtoNum;
923 cprintf(
"Configuration Mask:\n");
924 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
925 cprintf(
"%1d", (((*ConfigMask) >> ConfigNum) & 1));
928 cprintf(
"Feature Error for Configurations:\n");
929 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++) {
933 / NumFeatures / 256.0));
940 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
943 for (ProtoWordNum = 0; ProtoWordNum < 2;
944 ProtoWordNum++, ProtoMask++) {
947 ((ProtoNum < (PROTOS_PER_PROTO_SET >> 1))
948 && (ActualProtoNum < ClassTemplate->
NumProtos));
949 ProtoNum++, ActualProtoNum++)
950 cprintf (
"%1d", (((*ProtoMask) >> ProtoNum) & 1));
957 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
962 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
964 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
968 (ActualProtoNum < ClassTemplate->NumProtos));
969 ProtoNum++, ActualProtoNum++) {
970 cprintf (
"P %3d =", ActualProtoNum);
972 for (
int j = 0; j < ClassTemplate->
ProtoLengths[ActualProtoNum]; j++) {
979 temp / 256.0 / ClassTemplate->
ProtoLengths[ActualProtoNum]);
984 cprintf (
"%5d", ConfigWord & 1 ? temp : 0);
986 ProtoConfigs[ConfigNum] += temp;
996 cprintf (
"Proto Error for Configurations:\n");
997 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1000 ProtoConfigs[ConfigNum] /
1006 cprintf (
"Proto Sum for Configurations:\n");
1007 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1008 cprintf (
" %4.1f", ProtoConfigs[ConfigNum] / 256.0);
1011 cprintf (
"Proto Length for Configurations:\n");
1012 for (ConfigNum = 0; ConfigNum < ClassTemplate->
NumConfigs; ConfigNum++)
1020 void IntegerMatcher::DisplayProtoDebugInfo(
1025 bool SeparateDebugWindows) {
1027 uint16_t ActualProtoNum;
1032 if (SeparateDebugWindows) {
1038 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1040 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1044 (ActualProtoNum < ClassTemplate->NumProtos));
1045 ProtoNum++, ActualProtoNum++) {
1048 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1053 if ((ProtoSet->
Protos[ProtoNum]).Configs[0] & (*ConfigMask)) {
1061 void IntegerMatcher::DisplayFeatureDebugInfo(
1065 int16_t NumFeatures,
1067 int AdaptFeatureThreshold,
1069 bool SeparateDebugWindows) {
1072 tables->
Clear(ClassTemplate);
1075 if (SeparateDebugWindows) {
1080 for (
int Feature = 0; Feature < NumFeatures; Feature++) {
1081 UpdateTablesForFeature(
1082 ClassTemplate, ProtoMask, ConfigMask, Feature, &Features[Feature],
1087 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++)
1093 if (best < AdaptFeatureThreshold)
1113 uint32_t ConfigWord;
1118 uint16_t ActualProtoNum;
1122 for (ProtoSetIndex = 0; ProtoSetIndex < ClassTemplate->
NumProtoSets;
1124 ProtoSet = ClassTemplate->
ProtoSets[ProtoSetIndex];
1128 ProtoNum++, ActualProtoNum++) {
1130 for (
int i = 0; i < ClassTemplate->
ProtoLengths[ActualProtoNum]; i++)
1134 ConfigWord &= *ConfigMask;
1136 while (ConfigWord) {
1138 *IntPointer += temp;
1151 INT_CLASS ClassTemplate, int16_t NumFeatures, int32_t used_features) {
1153 for (
int i = 0; i < ClassTemplate->
NumConfigs; i++) {
1164 int IntegerMatcher::FindBestMatch(
1170 result->
fonts.truncate(0);
1174 for (
int c = 0; c < class_template->
NumConfigs; ++c) {
1176 if (*classify_debug_level_ > 2)
1177 tprintf(
"Config %d, rating=%d\n", c, rating);
1178 if (rating > best_match) {
1180 best_match = rating;
1186 result->
rating = best_match / 65536.0f;
1196 int normalization_factor,
1197 int matcher_multiplier) {
1198 return (rating * blob_length +
1199 matcher_multiplier * normalization_factor / 256.0) /
1200 (blob_length + matcher_multiplier);
1238 if (j < ir && ra[j] < ra[j + 1])
void NormalizeSums(INT_CLASS ClassTemplate, int16_t NumFeatures, int32_t used_features)
#define DisplayProtoMatchesOn(D)
static const float kSEExponentialMultiplier
int SetupResults(GenericVector< CP_RESULT_STRUCT > *results) const
void NormalizeForXheight(int norm_multiplier, const uint8_t *normalization_factors)
static const int kIntEvidenceTruncBits
void cprintf(const char *format,...)
void IMDebugConfigurationSum(INT_FEATURE FeatureNum, uint8_t *FeatureEvidence, int32_t ConfigCount)
uint32_t Configs[WERDS_PER_CONFIG_VEC]
void DisplayIntFeature(const INT_FEATURE_STRUCT *Feature, float Evidence)
const char * string() const
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)
static const float kSimilarityCenter
static const int kEvidenceTableBits
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
void UpdateSumOfProtoEvidences(INT_CLASS ClassTemplate, BIT_VECTOR ConfigMask, int16_t NumFeatures)
#define MatchDebuggingOn(D)
#define NUM_BITS_PER_CLASS
void ComputeScores(const INT_TEMPLATES_STRUCT *int_templates, int num_features, const INT_FEATURE_STRUCT *features)
void InitProtoDisplayWindowIfReqd()
#define CLASS_PRUNER_CLASS_MASK
uint32_t p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
int PruneClasses(const INT_TEMPLATES_STRUCT *int_templates, int num_features, int keep_this, const INT_FEATURE_STRUCT *features, const uint8_t *normalization_factors, const uint16_t *expected_num_features, GenericVector< CP_RESULT_STRUCT > *results)
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)
void DisableDisabledClasses(const UNICHARSET &unicharset)
void DisableFragments(const UNICHARSET &unicharset)
int classify_class_pruner_multiplier
PROTO_SET ProtoSets[MAX_NUM_PROTO_SETS]
void Clear(const INT_CLASS class_template)
int classify_class_pruner_threshold
#define DisplayFeatureMatchesOn(D)
void ClearFeatureEvidence(const INT_CLASS class_template)
float ApplyCNCorrection(float rating, int blob_length, int normalization_factor, int matcher_multiplier)
void PruneAndSort(int pruning_factor, int keep_this, bool max_of_non_fragments, const UNICHARSET &unicharset)
INT_PROTO_STRUCT Protos[PROTOS_PER_PROTO_SET]
void init_to_size(int size, const T &t)
int RoundUp(int n, int block_size)
#define PrintFeatureMatchesOn(D)
void IMDebugConfiguration(INT_FEATURE FeatureNum, uint16_t ActualProtoNum, uint8_t Evidence, BIT_VECTOR ConfigMask, uint32_t ConfigWord)
uint16_t ConfigLengths[MAX_NUM_CONFIGS]
IntegerMatcher(tesseract::IntParam *classify_debug_level)
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT *templates, int class_id, int config_id) const
#define PrintMatchSummaryOn(D)
bool get_enabled(UNICHAR_ID unichar_id) const
ShapeTable * shape_table_
DLLSYM void tprintf(const char *format,...)
#define PROTOS_PER_PROTO_SET
uint8_t feature_evidence_[MAX_NUM_CONFIGS]
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
bool disable_character_fragments
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
static const int kIntThetaFudge
void InitFeatureDisplayWindowIfReqd()
#define ClipMatchEvidenceOn(D)
#define WERDS_PER_CP_VECTOR
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)
void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, float Evidence)
void InitIntMatchWindowIfReqd()
#define PrintProtoMatchesOn(D)
void DebugMatch(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const INT_FEATURE_STRUCT *features) const
#define next_table_entries
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
void SummarizeResult(const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const uint16_t *expected_num_features, int norm_multiplier, const uint8_t *normalization_factors) const
void AdjustForExpectedNumFeatures(const uint16_t *expected_num_features, int cutoff_strength)
int classify_cp_cutoff_strength
#define INTMATCHER_OFFSET_TABLE_SIZE
int sum_feature_evidence_[MAX_NUM_CONFIGS]
uint8_t proto_evidence_[MAX_NUM_PROTOS][MAX_PROTO_INDEX]
ClassPruner(int max_classes)
void HeapSort(int n, int ra[], int rb[])
#define offset_table_entries
GenericVector< ScoredFont > fonts