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