tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
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");
436 "Character Normalization Range ...");
438 "Veto ratio between classifier ratings");
440 "Veto difference between classifier certainties");
447 "Use pre-adapted classifier templates");
449 "Save adapted templates to a file");
452 "Non-linear stroke-density normalization");
464 "Reliable Config Threshold");
466 "Enable adaption even if the ambiguities have not been seen");
468 "Maximum angle delta for prototype clustering");
470 "Penalty to apply when a non-alnum is vertically out of "
471 "its expected textline position");
475 "Scale factor for features not used");
477 "Prune poor adapted results this much worse than best result");
479 "Threshold at which classify_adapted_pruning_factor starts");
481 "Threshold for good protos during adaptive 0-255");
483 "Threshold for good features during adaptive 0-255");
485 "Do not include character fragments in the"
486 " results of the classifier");
488 "Exclude fragments that do not match any whole character"
489 " with at least this certainty");
491 "Bring up graphical debugging windows for fragments training");
493 "Use two different windows for debugging the matching: "
494 "One for the protos and one for the features.");
499 "Class Pruner Threshold 0-255");
501 "Class Pruner Multiplier 0-255: ");
503 "Class Pruner CutoffStrength: ");
505 "Integer Matcher Multiplier 0-255: ");
508 "Assume the input is numbers [0-9].");
511 "Penalty to add to worst rating for noise");
552 ScrollView* learn_fragmented_word_debug_win_ =
nullptr;
553 ScrollView* learn_fragments_debug_win_ =
nullptr;
563 int NumAdaptationsFailed = 0;
581 #endif // DISABLED_LEGACY_ENGINE
583 #endif // TESSERACT_CLASSIFY_CLASSIFY_H_
double tessedit_class_miss_scale
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 classify_enable_adaptive_matcher
void SetStaticClassifier(ShapeClassifier *static_classifier)
void ClearCharNormArray(uint8_t *char_norm_array)
double matcher_clustering_max_angle_delta
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)
int classify_class_pruner_threshold
UnicityTable< FontInfo > fontinfo_table_
int classify_adapt_proto_threshold
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)
int MakeNewTemporaryConfig(ADAPT_TEMPLATES Templates, CLASS_ID ClassId, int FontinfoId, int NumFeatures, INT_FEATURE_ARRAY Features, FEATURE_SET FloatFeatures)
bool classify_enable_learning
int CharNormClassifier(TBLOB *blob, const TrainingSample &sample, ADAPT_RESULTS *adapt_results)
bool classify_enable_adaptive_debugger
void EndAdaptiveClassifier()
float ComputeNormMatch(CLASS_ID ClassId, const FEATURE_STRUCT &feature, bool DebugMatch)
CLASS_ID GetClassToDebug(const char *Prompt, bool *adaptive_on, bool *pretrained_on, int *shape_id)
bool AdaptableWord(WERD_RES *word)
double matcher_good_threshold
double classify_adapted_pruning_threshold
int matcher_permanent_classes_min
void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
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)
int classify_cp_cutoff_strength
void UpdateAmbigsGroup(CLASS_ID class_id, TBLOB *Blob)
void NormalizeOutlines(LIST Outlines, float *XScale, float *YScale)
void ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class)
void ConvertMatchesToChoices(const DENORM &denorm, const TBOX &box, ADAPT_RESULTS *Results, BLOB_CHOICE_LIST *Choices)
double classify_max_certainty_margin
void LearnWord(const char *fontname, WERD_RES *word)
int classify_learning_debug_level
const ShapeTable * shape_table() const
int classify_class_pruner_multiplier
static void SetupBLCNDenorms(const TBLOB &blob, bool nonlinear_norm, DENORM *bl_denorm, DENORM *cn_denorm, INT_FX_RESULT_STRUCT *fx_info)
bool LooksLikeGarbage(TBLOB *blob)
void RemoveBadMatches(ADAPT_RESULTS *Results)
void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures)
INT_TEMPLATES CreateIntTemplates(CLASSES FloatProtos, const UNICHARSET &target_unicharset)
void InitAdaptedClass(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, ADAPT_CLASS Class, ADAPT_TEMPLATES Templates)
void PrintAdaptiveMatchResults(const ADAPT_RESULTS &results)
#define double_VAR_H(name, val, comment)
FEATURE_SET ExtractIntGeoFeatures(const TBLOB &blob, const INT_FX_RESULT_STRUCT &fx_info)
void SetAdaptiveThreshold(float Threshold)
double matcher_reliable_adaptive_result
void DisplayAdaptedChar(TBLOB *blob, INT_CLASS_STRUCT *int_class)
void ClassifyAsNoise(ADAPT_RESULTS *Results)
double matcher_avg_noise_size
UnicityTable< FontInfo > & get_fontinfo_table()
int matcher_min_examples_for_prototyping
double matcher_perfect_threshold
ADAPT_TEMPLATES ReadAdaptedTemplates(TFile *File)
ShapeTable * shape_table_
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)
double speckle_large_max_size
bool disable_character_fragments
void MakePermanent(ADAPT_TEMPLATES Templates, CLASS_ID ClassId, int ConfigId, TBLOB *Blob)
int ShapeIDToClassID(int shape_id) const
ADAPT_TEMPLATES BackupAdaptedTemplates
bool classify_save_adapted_templates
bool classify_nonlinear_norm
void StartBackupAdaptiveClassifier()
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
double classify_max_rating_ratio
double classify_char_norm_range
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)
NORM_PROTOS * ReadNormProtos(TFile *fp)
FEATURE_DEFS_STRUCT feature_defs_
ADAPT_TEMPLATES AdaptedTemplates
int matcher_sufficient_examples_for_prototyping
char * classify_learn_debug_str
FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob)
void AddLargeSpeckleTo(int blob_length, BLOB_CHOICE_LIST *choices)
void InitAdaptiveClassifier(TessdataManager *mgr)
void WriteIntTemplates(FILE *File, INT_TEMPLATES Templates, const UNICHARSET &target_unicharset)
#define INT_VAR_H(name, val, comment)
void LearnPieces(const char *fontname, int start, int length, float threshold, CharSegmentationType segmentation, const char *correct_text, WERD_RES *word)
int GetCharNormFeature(const INT_FX_RESULT_STRUCT &fx_info, INT_TEMPLATES templates, uint8_t *pruner_norm_array, uint8_t *char_norm_array)
void DoAdaptiveMatch(TBLOB *Blob, ADAPT_RESULTS *Results)
FEATURE_SET ExtractIntCNFeatures(const TBLOB &blob, const INT_FX_RESULT_STRUCT &fx_info)
int GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId)
double speckle_rating_penalty
void ComputeCharNormArrays(FEATURE_STRUCT *norm_feature, INT_TEMPLATES_STRUCT *templates, uint8_t *char_norm_array, uint8_t *pruner_array)
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
bool classify_use_pre_adapted_templates
bool WriteTRFile(const STRING &filename)
FEATURE_SET ExtractPicoFeatures(TBLOB *Blob)
int classify_adapt_feature_threshold
void ReadNewCutoffs(TFile *fp, uint16_t *Cutoffs)
double classify_adapted_pruning_factor
bool AdaptiveClassifierIsEmpty() const
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)
double classify_misfit_junk_penalty
UnicityTable< FontSet > & get_fontset_table()
#define BOOL_VAR_H(name, val, comment)
int CharNormTrainingSample(bool pruner_only, int keep_this, const TrainingSample &sample, GenericVector< UnicharRating > *results)
void RemoveExtraPuncs(ADAPT_RESULTS *Results)
int GetAdaptiveFeatures(TBLOB *Blob, INT_FEATURE_ARRAY IntFeatures, FEATURE_SET *FloatFeatures)
void DebugAdaptiveClassifier(TBLOB *Blob, ADAPT_RESULTS *Results)
void AddNewResult(const UnicharRating &new_result, ADAPT_RESULTS *results)
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)
bool TempConfigReliable(CLASS_ID class_id, const TEMP_CONFIG &config)
const UnicityTable< FontInfo > & get_fontinfo_table() const
bool LargeSpeckle(const TBLOB &blob)
INT_TEMPLATES ReadIntTemplates(TFile *fp)
INT_TEMPLATES PreTrainedTemplates
bool matcher_debug_separate_windows
UNICHAR_ID * GetAmbiguities(TBLOB *Blob, CLASS_ID CorrectClass)
int classify_integer_matcher_multiplier
bool classify_debug_character_fragments
double matcher_rating_margin
void ResetAdaptiveClassifierInternal()
void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
bool classify_bln_numeric_mode
double matcher_bad_match_pad
UnicityTable< FontSet > fontset_table_
void ShowBestMatchFor(int shape_id, const INT_FEATURE_STRUCT *features, int num_features)
double classify_character_fragments_garbage_certainty_threshold
void AdaptToChar(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, float Threshold, ADAPT_TEMPLATES adaptive_templates)
int ClassAndConfigIDToFontOrShapeID(int class_id, int int_result_config) const
PROTO_ID MakeNewTempProtos(FEATURE_SET Features, int NumBadFeat, FEATURE_ID BadFeat[], INT_CLASS IClass, ADAPT_CLASS Class, BIT_VECTOR TempProtoMask)
void SwitchAdaptiveClassifier()
#define STRING_VAR_H(name, val, comment)
void RefreshDebugWindow(ScrollView **win, const char *msg, int y_offset, const TBOX &wbox)
ADAPT_TEMPLATES NewAdaptedTemplates(bool InitFromUnicharset)
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT *templates, int class_id, int config_id) const
bool AdaptiveClassifierIsFull() const