19 #ifndef TESSERACT_CLASSIFY_CLASSIFY_H__ 20 #define TESSERACT_CLASSIFY_CLASSIFY_H__ 42 static const int kUnknownFontinfoId = -1;
43 static const int kBlankFontinfoId = -2;
47 class ShapeClassifier;
103 const uinT8* normalization_factors,
104 const uinT16* expected_num_features,
138 void LearnPieces(
const char* fontname,
int start,
int length,
float threshold,
157 const uinT8* norm_factors,
160 int matcher_multiplier,
161 const TBOX& blob_box,
175 int matcher_multiplier,
176 const uinT8* cn_factors,
183 double im_rating,
int feature_misses,
185 int blob_length,
int matcher_multiplier,
186 const uinT8* cn_factors);
189 BLOB_CHOICE_LIST *Choices);
195 #ifndef GRAPHICS_DISABLED 225 int class_id,
int config_id)
const;
237 int int_result_config)
const;
271 uinT8* pruner_norm_array,
272 uinT8* char_norm_array);
278 uinT8* char_norm_array,
279 uinT8* pruner_array);
290 int y_offset,
const TBOX &wbox);
335 uinT8* char_norm_array);
342 bool* pretrained_on,
int* shape_id);
387 "Prioritize blob division over chopping");
396 "Character Normalization Range ...");
402 "Veto ratio between classifier ratings");
404 "Veto difference between classifier certainties");
411 "Use pre-adapted classifier templates");
413 "Save adapted templates to a file");
416 "Non-linear stroke-density normalization");
428 "Reliable Config Threshold");
430 "Enable adaption even if the ambiguities have not been seen");
432 "Maximum angle delta for prototype clustering");
434 "Penalty to apply when a non-alnum is vertically out of " 435 "its expected textline position");
439 "Scale factor for features not used");
441 "Prune poor adapted results this much worse than best result");
443 "Threshold at which classify_adapted_pruning_factor starts");
445 "Threshold for good protos during adaptive 0-255");
447 "Threshold for good features during adaptive 0-255");
449 "Do not include character fragments in the" 450 " results of the classifier");
452 "Exclude fragments that do not match any whole character" 453 " with at least this certainty");
455 "Bring up graphical debugging windows for fragments training");
457 "Use two different windows for debugging the matching: " 458 "One for the protos and one for the features.");
463 "Class Pruner Threshold 0-255");
465 "Class Pruner Multiplier 0-255: ");
467 "Class Pruner CutoffStrength: ");
469 "Integer Matcher Multiplier 0-255: ");
500 "Assume the input is numbers [0-9].");
503 "Penalty to add to worst rating for noise");
520 int NumAdaptationsFailed;
542 #endif // TESSERACT_CLASSIFY_CLASSIFY_H__ double matcher_rating_margin
UnicityTable< FontSet > fontset_table_
bool classify_enable_adaptive_debugger
INT_TEMPLATES ReadIntTemplates(FILE *File)
int MakeNewTemporaryConfig(ADAPT_TEMPLATES Templates, CLASS_ID ClassId, int FontinfoId, int NumFeatures, INT_FEATURE_ARRAY Features, FEATURE_SET FloatFeatures)
double matcher_good_threshold
double classify_character_fragments_garbage_certainty_threshold
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)
int tessedit_single_match
double matcher_clustering_max_angle_delta
void ComputeCharNormArrays(FEATURE_STRUCT *norm_feature, INT_TEMPLATES_STRUCT *templates, uinT8 *char_norm_array, uinT8 *pruner_array)
void StartBackupAdaptiveClassifier()
double classify_min_norm_scale_x
#define STRING_VAR_H(name, val, comment)
bool classify_enable_learning
int GetFontinfoId(ADAPT_CLASS Class, uinT8 ConfigId)
bool LargeSpeckle(const TBLOB &blob)
bool classify_enable_adaptive_matcher
ADAPT_TEMPLATES AdaptedTemplates
FEATURE_DEFS_STRUCT feature_defs_
PROTO_ID MakeNewTempProtos(FEATURE_SET Features, int NumBadFeat, FEATURE_ID BadFeat[], INT_CLASS IClass, ADAPT_CLASS Class, BIT_VECTOR TempProtoMask)
void LearnPieces(const char *fontname, int start, int length, float threshold, CharSegmentationType segmentation, const char *correct_text, WERD_RES *word)
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
void ClearCharNormArray(uinT8 *char_norm_array)
#define INT_VAR_H(name, val, comment)
void DoAdaptiveMatch(TBLOB *Blob, ADAPT_RESULTS *Results)
static void SetupBLCNDenorms(const TBLOB &blob, bool nonlinear_norm, DENORM *bl_denorm, DENORM *cn_denorm, INT_FX_RESULT_STRUCT *fx_info)
CLASS_ID GetClassToDebug(const char *Prompt, bool *adaptive_on, bool *pretrained_on, int *shape_id)
double matcher_bad_match_pad
void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
void RefreshDebugWindow(ScrollView **win, const char *msg, int y_offset, const TBOX &wbox)
INT_TEMPLATES PreTrainedTemplates
FEATURE_SET ExtractIntCNFeatures(const TBLOB &blob, const INT_FX_RESULT_STRUCT &fx_info)
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 *cn_factors)
void ResetAdaptiveClassifierInternal()
void LearnWord(const char *fontname, WERD_RES *word)
char * classify_learn_debug_str
double tessedit_class_miss_scale
int ShapeIDToClassID(int shape_id) const
void ReadNewCutoffs(FILE *CutoffFile, bool swap, inT64 end_offset, CLASS_CUTOFF_ARRAY Cutoffs)
int classify_adapt_feature_threshold
int matcher_permanent_classes_min
bool classify_use_pre_adapted_templates
double matcher_perfect_threshold
void MakePermanent(ADAPT_TEMPLATES Templates, CLASS_ID ClassId, int ConfigId, TBLOB *Blob)
UnicityTable< FontInfo > fontinfo_table_
const UnicityTable< FontInfo > & get_fontinfo_table() const
double classify_min_norm_scale_y
bool LooksLikeGarbage(TBLOB *blob)
void RemoveExtraPuncs(ADAPT_RESULTS *Results)
bool classify_debug_character_fragments
int matcher_sufficient_examples_for_prototyping
#define BOOL_VAR_H(name, val, comment)
int GetCharNormFeature(const INT_FX_RESULT_STRUCT &fx_info, INT_TEMPLATES templates, uinT8 *pruner_norm_array, uinT8 *char_norm_array)
NORM_PROTOS * ReadNormProtos(FILE *File, inT64 end_offset)
ADAPT_TEMPLATES ReadAdaptedTemplates(FILE *File)
void AddNewResult(const UnicharRating &new_result, ADAPT_RESULTS *results)
FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob)
UnicityTable< FontSet > & get_fontset_table()
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 *cn_factors, UnicharRating *int_result, ADAPT_RESULTS *final_results)
FLOAT32 ComputeNormMatch(CLASS_ID ClassId, const FEATURE_STRUCT &feature, BOOL8 DebugMatch)
void RemoveBadMatches(ADAPT_RESULTS *Results)
FEATURE_SET ExtractIntGeoFeatures(const TBLOB &blob, const INT_FX_RESULT_STRUCT &fx_info)
void UpdateAmbigsGroup(CLASS_ID class_id, TBLOB *Blob)
bool matcher_debug_separate_windows
void LearnBlob(const STRING &fontname, TBLOB *Blob, const DENORM &cn_denorm, const INT_FX_RESULT_STRUCT &fx_info, const char *blob_text)
const ShapeTable * shape_table() const
double classify_adapted_pruning_factor
bool AdaptiveClassifierIsEmpty() const
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
int CharNormClassifier(TBLOB *blob, const TrainingSample &sample, ADAPT_RESULTS *adapt_results)
double classify_misfit_junk_penalty
FEATURE_SET ExtractPicoFeatures(TBLOB *Blob)
bool classify_nonlinear_norm
int ClassAndConfigIDToFontOrShapeID(int class_id, int int_result_config) const
double classify_max_norm_scale_y
int classify_adapt_proto_threshold
int matcher_min_examples_for_prototyping
void ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class)
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)
int classify_learning_debug_level
ShapeTable * shape_table_
double classify_max_certainty_margin
int CharNormTrainingSample(bool pruner_only, int keep_this, const TrainingSample &sample, GenericVector< UnicharRating > *results)
bool WriteTRFile(const STRING &filename)
bool disable_character_fragments
uinT16 CLASS_CUTOFF_ARRAY[MAX_NUM_CLASSES]
double classify_adapted_pruning_threshold
void AddLargeSpeckleTo(int blob_length, BLOB_CHOICE_LIST *choices)
void MasterMatcher(INT_TEMPLATES templates, inT16 num_features, const INT_FEATURE_STRUCT *features, const uinT8 *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 classify_integer_matcher_multiplier
void WriteIntTemplates(FILE *File, INT_TEMPLATES Templates, const UNICHARSET &target_unicharset)
int classify_class_pruner_multiplier
void DisplayAdaptedChar(TBLOB *blob, INT_CLASS_STRUCT *int_class)
void EndAdaptiveClassifier()
double speckle_large_max_size
int GetAdaptiveFeatures(TBLOB *Blob, INT_FEATURE_ARRAY IntFeatures, FEATURE_SET *FloatFeatures)
double classify_max_norm_scale_x
bool TempConfigReliable(CLASS_ID class_id, const TEMP_CONFIG &config)
bool AdaptiveClassifierIsFull() const
void DebugAdaptiveClassifier(TBLOB *Blob, ADAPT_RESULTS *Results)
void PrintAdaptiveMatchResults(const ADAPT_RESULTS &results)
UNICHAR_ID * GetAmbiguities(TBLOB *Blob, CLASS_ID CorrectClass)
void ShowBestMatchFor(int shape_id, const INT_FEATURE_STRUCT *features, int num_features)
int classify_class_pruner_threshold
void SetAdaptiveThreshold(FLOAT32 Threshold)
bool classify_bln_numeric_mode
void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures)
void NormalizeOutlines(LIST Outlines, FLOAT32 *XScale, FLOAT32 *YScale)
double classify_max_rating_ratio
void ConvertMatchesToChoices(const DENORM &denorm, const TBOX &box, ADAPT_RESULTS *Results, BLOB_CHOICE_LIST *Choices)
UnicityTable< FontInfo > & get_fontinfo_table()
void AdaptToChar(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, FLOAT32 Threshold, ADAPT_TEMPLATES adaptive_templates)
double matcher_reliable_adaptive_result
void SetStaticClassifier(ShapeClassifier *static_classifier)
void InitAdaptiveClassifier(bool load_pre_trained_templates)
bool classify_save_adapted_templates
ADAPT_TEMPLATES BackupAdaptedTemplates
int classify_cp_cutoff_strength
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)
ADAPT_TEMPLATES NewAdaptedTemplates(bool InitFromUnicharset)
#define double_VAR_H(name, val, comment)
void ClassifyAsNoise(ADAPT_RESULTS *Results)
double classify_char_norm_range
double speckle_rating_penalty
void ComputeIntCharNormArray(const FEATURE_STRUCT &norm_feature, uinT8 *char_norm_array)
void SwitchAdaptiveClassifier()
void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates)
void InitAdaptedClass(TBLOB *Blob, CLASS_ID ClassId, int FontinfoId, ADAPT_CLASS Class, ADAPT_TEMPLATES Templates)
double matcher_avg_noise_size
bool AdaptableWord(WERD_RES *word)
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_TEMPLATES CreateIntTemplates(CLASSES FloatProtos, const UNICHARSET &target_unicharset)
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT *templates, int class_id, int config_id) const