19 #ifndef TESSERACT_CLASSIFY_CLASSIFY_H_ 20 #define TESSERACT_CLASSIFY_CLASSIFY_H_ 24 #include "config_auto.h" 28 #ifdef DISABLED_LEGACY_ENGINE 35 class Classify :
public CCStruct {
48 "Assume the input is numbers [0-9].");
51 "Veto ratio between classifier ratings");
54 "Veto difference between classifier certainties");
63 #else // DISABLED_LEGACY_ENGINE not defined 84 static const int kUnknownFontinfoId = -1;
85 static const int kBlankFontinfoId = -2;
89 class ShapeClassifier;
145 const uint8_t* normalization_factors,
146 const uint16_t* expected_num_features,
179 void LearnPieces(
const char* fontname,
int start,
int length,
float threshold,
196 int16_t num_features,
198 const uint8_t* norm_factors,
201 int matcher_multiplier,
202 const TBOX& blob_box,
216 int matcher_multiplier,
217 const uint8_t* cn_factors,
224 double im_rating,
int feature_misses,
226 int blob_length,
int matcher_multiplier,
227 const uint8_t* cn_factors);
230 BLOB_CHOICE_LIST *Choices);
236 #ifndef GRAPHICS_DISABLED 266 int class_id,
int config_id)
const;
278 int int_result_config)
const;
312 uint8_t* pruner_norm_array,
313 uint8_t* char_norm_array);
319 uint8_t* char_norm_array,
320 uint8_t* pruner_array);
331 int y_offset,
const TBOX &wbox);
376 uint8_t* char_norm_array);
383 bool* pretrained_on,
int* shape_id);
428 "Prioritize blob division over chopping");
437 "Character Normalization Range ...");
443 "Veto ratio between classifier ratings");
445 "Veto difference between classifier certainties");
452 "Use pre-adapted classifier templates");
454 "Save adapted templates to a file");
457 "Non-linear stroke-density normalization");
469 "Reliable Config Threshold");
471 "Enable adaption even if the ambiguities have not been seen");
473 "Maximum angle delta for prototype clustering");
475 "Penalty to apply when a non-alnum is vertically out of " 476 "its expected textline position");
480 "Scale factor for features not used");
482 "Prune poor adapted results this much worse than best result");
484 "Threshold at which classify_adapted_pruning_factor starts");
486 "Threshold for good protos during adaptive 0-255");
488 "Threshold for good features during adaptive 0-255");
490 "Do not include character fragments in the" 491 " results of the classifier");
493 "Exclude fragments that do not match any whole character" 494 " with at least this certainty");
496 "Bring up graphical debugging windows for fragments training");
498 "Use two different windows for debugging the matching: " 499 "One for the protos and one for the features.");
504 "Class Pruner Threshold 0-255");
506 "Class Pruner Multiplier 0-255: ");
508 "Class Pruner CutoffStrength: ");
510 "Integer Matcher Multiplier 0-255: ");
541 "Assume the input is numbers [0-9].");
544 "Penalty to add to worst rating for noise");
561 int NumAdaptationsFailed;
583 #endif // DISABLED_LEGACY_ENGINE 585 #endif // TESSERACT_CLASSIFY_CLASSIFY_H_
void ClassifyAsNoise(ADAPT_RESULTS *Results)
const UnicityTable< FontInfo > & get_fontinfo_table() const
double classify_max_certainty_margin
bool LargeSpeckle(const TBLOB &blob)
#define INT_VAR_H(name, val, comment)
static void SetupBLCNDenorms(const TBLOB &blob, bool nonlinear_norm, DENORM *bl_denorm, DENORM *cn_denorm, INT_FX_RESULT_STRUCT *fx_info)
double tessedit_class_miss_scale
float ComputeNormMatch(CLASS_ID ClassId, const FEATURE_STRUCT &feature, bool DebugMatch)
ADAPT_TEMPLATES ReadAdaptedTemplates(TFile *File)
double classify_max_norm_scale_x
double classify_min_norm_scale_y
void SetStaticClassifier(ShapeClassifier *static_classifier)
void InitAdaptiveClassifier(TessdataManager *mgr)
void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures)
int matcher_permanent_classes_min
void RefreshDebugWindow(ScrollView **win, const char *msg, int y_offset, const TBOX &wbox)
int GetCharNormFeature(const INT_FX_RESULT_STRUCT &fx_info, INT_TEMPLATES templates, uint8_t *pruner_norm_array, uint8_t *char_norm_array)
static void ExtractFeatures(const TBLOB &blob, bool nonlinear_norm, GenericVector< INT_FEATURE_STRUCT > *bl_features, GenericVector< INT_FEATURE_STRUCT > *cn_features, INT_FX_RESULT_STRUCT *results, GenericVector< int > *outline_cn_counts)
void NormalizeOutlines(LIST Outlines, float *XScale, float *YScale)
FEATURE_SET ExtractIntCNFeatures(const TBLOB &blob, const INT_FX_RESULT_STRUCT &fx_info)
FEATURE_SET ExtractIntGeoFeatures(const TBLOB &blob, const INT_FX_RESULT_STRUCT &fx_info)
void LearnPieces(const char *fontname, int start, int length, float threshold, CharSegmentationType segmentation, const char *correct_text, WERD_RES *word)
bool classify_enable_adaptive_debugger
void DisplayAdaptedChar(TBLOB *blob, INT_CLASS_STRUCT *int_class)
UnicityTable< FontInfo > & get_fontinfo_table()
#define BOOL_VAR_H(name, val, comment)
void DebugAdaptiveClassifier(TBLOB *Blob, ADAPT_RESULTS *Results)
void ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class)
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
void MasterMatcher(INT_TEMPLATES templates, int16_t num_features, const INT_FEATURE_STRUCT *features, const uint8_t *norm_factors, ADAPT_CLASS *classes, int debug, int matcher_multiplier, const TBOX &blob_box, const GenericVector< CP_RESULT_STRUCT > &results, ADAPT_RESULTS *final_results)
bool classify_bln_numeric_mode
bool TempConfigReliable(CLASS_ID class_id, const TEMP_CONFIG &config)
int GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId)
#define double_VAR_H(name, val, comment)
UNICHAR_ID * BaselineClassifier(TBLOB *Blob, const GenericVector< INT_FEATURE_STRUCT > &int_features, const INT_FX_RESULT_STRUCT &fx_info, ADAPT_TEMPLATES Templates, ADAPT_RESULTS *Results)
bool AdaptableWord(WERD_RES *word)
bool matcher_debug_separate_windows
void ClearCharNormArray(uint8_t *char_norm_array)
double matcher_rating_margin
void AddNewResult(const UnicharRating &new_result, ADAPT_RESULTS *results)
int MakeNewTemporaryConfig(ADAPT_TEMPLATES Templates, CLASS_ID ClassId, int FontinfoId, int NumFeatures, INT_FEATURE_ARRAY Features, FEATURE_SET FloatFeatures)
ADAPT_TEMPLATES NewAdaptedTemplates(bool InitFromUnicharset)
#define STRING_VAR_H(name, val, comment)
void UpdateAmbigsGroup(CLASS_ID class_id, TBLOB *Blob)
bool AdaptiveClassifierIsEmpty() const
void ShowBestMatchFor(int shape_id, const INT_FEATURE_STRUCT *features, int num_features)
UnicityTable< FontSet > & get_fontset_table()
bool AdaptiveClassifierIsFull() const
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)
INT_TEMPLATES CreateIntTemplates(CLASSES FloatProtos, const UNICHARSET &target_unicharset)
double classify_min_norm_scale_x
void AddLargeSpeckleTo(int blob_length, BLOB_CHOICE_LIST *choices)
bool classify_nonlinear_norm
int classify_adapt_proto_threshold
int classify_class_pruner_multiplier
NORM_PROTOS * ReadNormProtos(TFile *fp)
double classify_character_fragments_garbage_certainty_threshold
void ComputeCharNormArrays(FEATURE_STRUCT *norm_feature, INT_TEMPLATES_STRUCT *templates, uint8_t *char_norm_array, uint8_t *pruner_array)
int tessedit_single_match
int classify_class_pruner_threshold
bool classify_debug_character_fragments
double classify_adapted_pruning_threshold
void AmbigClassifier(const GenericVector< INT_FEATURE_STRUCT > &int_features, const INT_FX_RESULT_STRUCT &fx_info, const TBLOB *blob, INT_TEMPLATES templates, ADAPT_CLASS *classes, UNICHAR_ID *ambiguities, ADAPT_RESULTS *results)
int classify_learning_debug_level
INT_TEMPLATES PreTrainedTemplates
int ClassAndConfigIDToFontOrShapeID(int class_id, int int_result_config) const
double matcher_good_threshold
double speckle_large_max_size
void WriteIntTemplates(FILE *File, INT_TEMPLATES Templates, const UNICHARSET &target_unicharset)
double ComputeCorrectedRating(bool debug, int unichar_id, double cp_rating, double im_rating, int feature_misses, int bottom, int top, int blob_length, int matcher_multiplier, const uint8_t *cn_factors)
void SetAdaptiveThreshold(float Threshold)
double matcher_reliable_adaptive_result
double classify_adapted_pruning_factor
double classify_max_rating_ratio
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT *templates, int class_id, int config_id) const
double matcher_clustering_max_angle_delta
double classify_misfit_junk_penalty
ShapeTable * shape_table_
PROTO_ID MakeNewTempProtos(FEATURE_SET Features, int NumBadFeat, FEATURE_ID BadFeat[], INT_CLASS IClass, ADAPT_CLASS Class, BIT_VECTOR TempProtoMask)
bool LooksLikeGarbage(TBLOB *blob)
ADAPT_TEMPLATES BackupAdaptedTemplates
ADAPT_TEMPLATES AdaptedTemplates
void MakePermanent(ADAPT_TEMPLATES Templates, CLASS_ID ClassId, int ConfigId, TBLOB *Blob)
void PrintAdaptiveMatchResults(const ADAPT_RESULTS &results)
uint16_t CLASS_CUTOFF_ARRAY[MAX_NUM_CLASSES]
void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
void ResetAdaptiveClassifierInternal()
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
void ExpandShapesAndApplyCorrections(ADAPT_CLASS *classes, bool debug, int class_id, int bottom, int top, float cp_rating, int blob_length, int matcher_multiplier, const uint8_t *cn_factors, UnicharRating *int_result, ADAPT_RESULTS *final_results)
void ConvertMatchesToChoices(const DENORM &denorm, const TBOX &box, ADAPT_RESULTS *Results, BLOB_CHOICE_LIST *Choices)
int CharNormClassifier(TBLOB *blob, const TrainingSample &sample, ADAPT_RESULTS *adapt_results)
void EndAdaptiveClassifier()
double matcher_perfect_threshold
double matcher_avg_noise_size
int matcher_sufficient_examples_for_prototyping
FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob)
bool disable_character_fragments
void RemoveExtraPuncs(ADAPT_RESULTS *Results)
bool classify_enable_adaptive_matcher
int classify_adapt_feature_threshold
void SwitchAdaptiveClassifier()
int classify_integer_matcher_multiplier
UnicityTable< FontInfo > fontinfo_table_
void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
int matcher_min_examples_for_prototyping
double matcher_bad_match_pad
INT_TEMPLATES ReadIntTemplates(TFile *fp)
const ShapeTable * shape_table() const
int CharNormTrainingSample(bool pruner_only, int keep_this, const TrainingSample &sample, GenericVector< UnicharRating > *results)
bool WriteTRFile(const STRING &filename)
void InitAdaptedClass(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, ADAPT_CLASS Class, ADAPT_TEMPLATES Templates)
char * classify_learn_debug_str
UNICHAR_ID * GetAmbiguities(TBLOB *Blob, CLASS_ID CorrectClass)
double classify_max_norm_scale_y
void StartBackupAdaptiveClassifier()
void ComputeIntCharNormArray(const FEATURE_STRUCT &norm_feature, uint8_t *char_norm_array)
void LearnBlob(const STRING &fontname, TBLOB *Blob, const DENORM &cn_denorm, const INT_FX_RESULT_STRUCT &fx_info, const char *blob_text)
void DoAdaptiveMatch(TBLOB *Blob, ADAPT_RESULTS *Results)
double classify_char_norm_range
double speckle_rating_penalty
int GetAdaptiveFeatures(TBLOB *Blob, INT_FEATURE_ARRAY IntFeatures, FEATURE_SET *FloatFeatures)
void RemoveBadMatches(ADAPT_RESULTS *Results)
void AdaptToChar(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, float Threshold, ADAPT_TEMPLATES adaptive_templates)
void ReadNewCutoffs(TFile *fp, CLASS_CUTOFF_ARRAY Cutoffs)
int classify_cp_cutoff_strength
bool classify_enable_learning
UnicityTable< FontSet > fontset_table_
void LearnWord(const char *fontname, WERD_RES *word)
FEATURE_DEFS_STRUCT feature_defs_
CLASS_ID GetClassToDebug(const char *Prompt, bool *adaptive_on, bool *pretrained_on, int *shape_id)
int ShapeIDToClassID(int shape_id) const
bool classify_use_pre_adapted_templates
FEATURE_SET ExtractPicoFeatures(TBLOB *Blob)
bool classify_save_adapted_templates