tesseract
5.0.0-alpha-619-ge9db
|
#include <mastertrainer.h>
|
| MasterTrainer (NormalizationMode norm_mode, bool shape_analysis, bool replicate_samples, int debug_level) |
|
| ~MasterTrainer () |
|
bool | Serialize (FILE *fp) const |
|
void | LoadUnicharset (const char *filename) |
|
void | SetFeatureSpace (const IntFeatureSpace &fs) |
|
void | ReadTrainingSamples (const char *page_name, const FEATURE_DEFS_STRUCT &feature_defs, bool verification) |
|
void | AddSample (bool verification, const char *unichar_str, TrainingSample *sample) |
|
void | LoadPageImages (const char *filename) |
|
void | PostLoadCleanup () |
|
void | PreTrainingSetup () |
|
void | SetupMasterShapes () |
|
void | IncludeJunk () |
|
void | ReplicateAndRandomizeSamplesIfRequired () |
|
bool | LoadFontInfo (const char *filename) |
|
bool | LoadXHeights (const char *filename) |
|
bool | AddSpacingInfo (const char *filename) |
|
int | GetFontInfoId (const char *font_name) |
|
int | GetBestMatchingFontInfoId (const char *filename) |
|
const STRING & | GetTRFileName (int index) const |
|
void | SetupFlatShapeTable (ShapeTable *shape_table) |
|
CLUSTERER * | SetupForClustering (const ShapeTable &shape_table, const FEATURE_DEFS_STRUCT &feature_defs, int shape_id, int *num_samples) |
|
void | WriteInttempAndPFFMTable (const UNICHARSET &unicharset, const UNICHARSET &shape_set, const ShapeTable &shape_table, CLASS_STRUCT *float_classes, const char *inttemp_file, const char *pffmtable_file) |
|
const UNICHARSET & | unicharset () const |
|
TrainingSampleSet * | GetSamples () |
|
const ShapeTable & | master_shapes () const |
|
void | DebugCanonical (const char *unichar_str1, const char *unichar_str2) |
|
void | DisplaySamples (const char *unichar_str1, int cloud_font, const char *unichar_str2, int canonical_font) |
|
void | TestClassifierVOld (bool replicate_samples, ShapeClassifier *test_classifier, ShapeClassifier *old_classifier) |
|
void | TestClassifierOnSamples (CountTypes error_mode, int report_level, bool replicate_samples, ShapeClassifier *test_classifier, STRING *report_string) |
|
double | TestClassifier (CountTypes error_mode, int report_level, bool replicate_samples, TrainingSampleSet *samples, ShapeClassifier *test_classifier, STRING *report_string) |
|
float | ShapeDistance (const ShapeTable &shapes, int s1, int s2) |
|
Definition at line 69 of file mastertrainer.h.
◆ MasterTrainer()
tesseract::MasterTrainer::MasterTrainer |
( |
NormalizationMode |
norm_mode, |
|
|
bool |
shape_analysis, |
|
|
bool |
replicate_samples, |
|
|
int |
debug_level |
|
) |
| |
Definition at line 50 of file mastertrainer.cpp.
54 : norm_mode_(norm_mode), samples_(fontinfo_table_),
55 junk_samples_(fontinfo_table_), verify_samples_(fontinfo_table_),
57 enable_shape_analysis_(shape_analysis),
58 enable_replication_(replicate_samples),
59 fragments_(
nullptr), prev_unichar_id_(-1), debug_level_(debug_level) {
◆ ~MasterTrainer()
tesseract::MasterTrainer::~MasterTrainer |
( |
| ) |
|
Definition at line 62 of file mastertrainer.cpp.
64 for (
int p = 0; p < page_images_.
size(); ++p)
65 pixDestroy(&page_images_[p]);
◆ AddSample()
void tesseract::MasterTrainer::AddSample |
( |
bool |
verification, |
|
|
const char * |
unichar_str, |
|
|
TrainingSample * |
sample |
|
) |
| |
Definition at line 162 of file mastertrainer.cpp.
166 prev_unichar_id_ = -1;
168 if (prev_unichar_id_ >= 0)
169 fragments_[prev_unichar_id_] = -1;
175 if (prev_unichar_id_ >= 0) {
178 if (fragments_[prev_unichar_id_] == 0)
179 fragments_[prev_unichar_id_] = junk_id;
180 else if (fragments_[prev_unichar_id_] != junk_id)
181 fragments_[prev_unichar_id_] = -1;
185 prev_unichar_id_ = -1;
◆ AddSpacingInfo()
bool tesseract::MasterTrainer::AddSpacingInfo |
( |
const char * |
filename | ) |
|
Definition at line 411 of file mastertrainer.cpp.
412 FILE* fontinfo_file = fopen(filename,
"rb");
413 if (fontinfo_file ==
nullptr)
417 if (fontinfo_id < 0) {
418 tprintf(
"No font found matching fontinfo filename %s\n", filename);
419 fclose(fontinfo_file);
422 tprintf(
"Reading spacing from %s for font %d...\n", filename, fontinfo_id);
429 int x_gap, x_gap_before, x_gap_after, num_kerned;
431 FontInfo *fi = &fontinfo_table_.
get(fontinfo_id);
433 FontSpacingInfo *spacing =
nullptr;
434 for (
int l = 0; l < num_unichars; ++l) {
435 if (
tfscanf(fontinfo_file,
"%s %d %d %d",
436 uch, &x_gap_before, &x_gap_after, &num_kerned) != 4) {
437 tprintf(
"Bad format of font spacing file %s\n", filename);
438 fclose(fontinfo_file);
443 spacing =
new FontSpacingInfo();
444 spacing->x_gap_before = static_cast<int16_t>(x_gap_before * scale);
445 spacing->x_gap_after = static_cast<int16_t>(x_gap_after * scale);
447 for (
int k = 0; k < num_kerned; ++k) {
448 if (
tfscanf(fontinfo_file,
"%s %d", kerned_uch, &x_gap) != 2) {
449 tprintf(
"Bad format of font spacing file %s\n", filename);
450 fclose(fontinfo_file);
455 spacing->kerned_unichar_ids.push_back(
457 spacing->kerned_x_gaps.push_back(static_cast<int16_t>(x_gap * scale));
461 fclose(fontinfo_file);
◆ DebugCanonical()
void tesseract::MasterTrainer::DebugCanonical |
( |
const char * |
unichar_str1, |
|
|
const char * |
unichar_str2 |
|
) |
| |
Definition at line 635 of file mastertrainer.cpp.
639 if (class_id2 == INVALID_UNICHAR_ID)
640 class_id2 = class_id1;
641 if (class_id1 == INVALID_UNICHAR_ID) {
642 tprintf(
"No unicharset entry found for %s\n", unichar_str1);
645 tprintf(
"Font ambiguities for unichar %d = %s and %d = %s\n",
646 class_id1, unichar_str1, class_id2, unichar_str2);
648 int num_fonts = samples_.
NumFonts();
649 const IntFeatureMap& feature_map = feature_map_;
653 for (
int f = 0; f < num_fonts; ++f) {
659 for (
int f1 = 0; f1 < num_fonts; ++f1) {
664 for (
int f2 = 0; f2 < num_fonts; ++f2) {
675 for (
int f = 0; f < num_fonts; ++f) {
677 shapes.AddShape(class_id1, f);
678 if (class_id1 != class_id2 &&
680 shapes.AddShape(class_id2, f);
◆ DisplaySamples()
void tesseract::MasterTrainer::DisplaySamples |
( |
const char * |
unichar_str1, |
|
|
int |
cloud_font, |
|
|
const char * |
unichar_str2, |
|
|
int |
canonical_font |
|
) |
| |
Definition at line 695 of file mastertrainer.cpp.
698 const IntFeatureMap& feature_map = feature_map_;
699 const IntFeatureSpace& feature_space = feature_map.
feature_space();
704 if (class_id2 != INVALID_UNICHAR_ID && canonical_font >= 0) {
707 for (uint32_t f = 0; f <
sample->num_features(); ++f) {
712 if (class_id1 != INVALID_UNICHAR_ID && cloud_font >= 0) {
714 for (
int f = 0; f < cloud.size(); ++f) {
717 feature_map.InverseIndexFeature(f);
731 int feature_index = feature_space.XYToFeatureIndex(ev->
x, ev->
y);
732 if (feature_index >= 0) {
735 shape.AddToShape(class_id1, cloud_font);
◆ GetBestMatchingFontInfoId()
int tesseract::MasterTrainer::GetBestMatchingFontInfoId |
( |
const char * |
filename | ) |
|
Definition at line 478 of file mastertrainer.cpp.
479 int fontinfo_id = -1;
481 for (
int f = 0; f < fontinfo_table_.
size(); ++f) {
482 if (strstr(filename, fontinfo_table_.
get(f).name) !=
nullptr) {
483 int len = strlen(fontinfo_table_.
get(f).name);
485 if (len > best_len) {
◆ GetFontInfoId()
int tesseract::MasterTrainer::GetFontInfoId |
( |
const char * |
font_name | ) |
|
Definition at line 467 of file mastertrainer.cpp.
470 fontinfo.name = const_cast<char*>(font_name);
471 fontinfo.properties = 0;
472 fontinfo.universal_id = 0;
473 return fontinfo_table_.
get_index(fontinfo);
◆ GetSamples()
◆ GetTRFileName()
const STRING& tesseract::MasterTrainer::GetTRFileName |
( |
int |
index | ) |
const |
|
inline |
◆ IncludeJunk()
void tesseract::MasterTrainer::IncludeJunk |
( |
| ) |
|
Definition at line 294 of file mastertrainer.cpp.
299 tprintf(
"Moving %d junk samples to master sample set.\n", num_junks);
300 for (
int s = 0; s < num_junks; ++s) {
302 int junk_id =
sample->class_id();
305 if (sample_id == INVALID_UNICHAR_ID)
307 sample->set_class_id(sample_id);
◆ LoadFontInfo()
bool tesseract::MasterTrainer::LoadFontInfo |
( |
const char * |
filename | ) |
|
Definition at line 332 of file mastertrainer.cpp.
333 FILE* fp = fopen(filename,
"rb");
335 fprintf(stderr,
"Failed to load font_properties from %s\n", filename);
338 int italic, bold, fixed, serif, fraktur;
341 char* font_name =
new char[1024];
342 fontinfo.name = font_name;
343 fontinfo.properties = 0;
344 fontinfo.universal_id = 0;
345 if (
tfscanf(fp,
"%1024s %i %i %i %i %i\n", font_name, &italic, &bold,
346 &fixed, &serif, &fraktur) != 6) {
350 fontinfo.properties =
356 if (!fontinfo_table_.
contains(fontinfo)) {
◆ LoadPageImages()
void tesseract::MasterTrainer::LoadPageImages |
( |
const char * |
filename | ) |
|
Definition at line 192 of file mastertrainer.cpp.
196 for (page = 0;; page++) {
197 pix = pixReadFromMultipageTiff(filename, &offset);
202 tprintf(
"Loaded %d page images from %s\n", page, filename);
◆ LoadUnicharset()
void tesseract::MasterTrainer::LoadUnicharset |
( |
const char * |
filename | ) |
|
Definition at line 87 of file mastertrainer.cpp.
89 tprintf(
"Failed to load unicharset from file %s\n"
90 "Building unicharset for training from scratch...\n",
100 fragments_ =
new int[charsetsize_];
101 memset(fragments_, 0,
sizeof(*fragments_) * charsetsize_);
◆ LoadXHeights()
bool tesseract::MasterTrainer::LoadXHeights |
( |
const char * |
filename | ) |
|
Definition at line 368 of file mastertrainer.cpp.
369 tprintf(
"fontinfo table is of size %d\n", fontinfo_table_.
size());
371 if (filename ==
nullptr)
return true;
372 FILE *f = fopen(filename,
"rb");
374 fprintf(stderr,
"Failed to load font xheights from %s\n", filename);
377 tprintf(
"Reading x-heights from %s ...\n", filename);
379 fontinfo.properties = 0;
380 fontinfo.universal_id = 0;
383 int total_xheight = 0;
384 int xheight_count = 0;
386 if (
tfscanf(f,
"%1023s %d\n", buffer, &xht) != 2)
389 fontinfo.name = buffer;
390 if (!fontinfo_table_.
contains(fontinfo))
continue;
391 int fontinfo_id = fontinfo_table_.
get_index(fontinfo);
392 xheights_[fontinfo_id] = xht;
393 total_xheight += xht;
396 if (xheight_count == 0) {
397 fprintf(stderr,
"No valid xheights in %s!\n", filename);
401 int mean_xheight =
DivRounded(total_xheight, xheight_count);
402 for (
int i = 0; i < fontinfo_table_.
size(); ++i) {
403 if (xheights_[i] < 0)
404 xheights_[i] = mean_xheight;
◆ master_shapes()
const ShapeTable& tesseract::MasterTrainer::master_shapes |
( |
| ) |
const |
|
inline |
◆ PostLoadCleanup()
void tesseract::MasterTrainer::PostLoadCleanup |
( |
| ) |
|
Definition at line 210 of file mastertrainer.cpp.
211 if (debug_level_ > 0)
212 tprintf(
"PostLoadCleanup...\n");
213 if (enable_shape_analysis_)
214 ReplaceFragmentedSamples();
215 SampleIterator sample_it;
216 sample_it.Init(
nullptr,
nullptr,
true, &verify_samples_);
217 sample_it.NormalizeSamples();
225 if (debug_level_ > 0)
226 tprintf(
"ComputeCanonicalSamples...\n");
◆ PreTrainingSetup()
void tesseract::MasterTrainer::PreTrainingSetup |
( |
| ) |
|
Definition at line 233 of file mastertrainer.cpp.
234 if (debug_level_ > 0)
235 tprintf(
"PreTrainingSetup...\n");
238 if (debug_level_ > 0)
239 tprintf(
"ComputeCloudFeatures...\n");
◆ ReadTrainingSamples()
void tesseract::MasterTrainer::ReadTrainingSamples |
( |
const char * |
page_name, |
|
|
const FEATURE_DEFS_STRUCT & |
feature_defs, |
|
|
bool |
verification |
|
) |
| |
Definition at line 111 of file mastertrainer.cpp.
121 FILE* fp = fopen(page_name,
"rb");
123 tprintf(
"Failed to open tr file: %s\n", page_name);
127 while (fgets(buffer,
sizeof(buffer), fp) !=
nullptr) {
128 if (buffer[0] ==
'\n')
131 char* space = strchr(buffer,
' ');
132 if (space ==
nullptr) {
133 tprintf(
"Bad format in tr file, reading fontname, unichar\n");
138 if (font_id < 0) font_id = 0;
143 tprintf(
"Bad format in tr file, reading box coords\n");
147 auto*
sample =
new TrainingSample;
148 sample->set_font_id(font_id);
149 sample->set_page_num(page_number + page_images_.
size());
150 sample->set_bounding_box(bounding_box);
151 sample->ExtractCharDesc(int_feature_type, micro_feature_type,
152 cn_feature_type, geo_feature_type, char_desc);
◆ ReplicateAndRandomizeSamplesIfRequired()
void tesseract::MasterTrainer::ReplicateAndRandomizeSamplesIfRequired |
( |
| ) |
|
Definition at line 320 of file mastertrainer.cpp.
321 if (enable_replication_) {
322 if (debug_level_ > 0)
323 tprintf(
"ReplicateAndRandomize...\n");
◆ Serialize()
bool tesseract::MasterTrainer::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 71 of file mastertrainer.cpp.
72 uint32_t value = norm_mode_;
75 if (!feature_space_.
Serialize(fp))
return false;
76 if (!samples_.
Serialize(fp))
return false;
77 if (!junk_samples_.
Serialize(fp))
return false;
78 if (!verify_samples_.
Serialize(fp))
return false;
79 if (!master_shapes_.
Serialize(fp))
return false;
80 if (!flat_shapes_.
Serialize(fp))
return false;
81 if (!fontinfo_table_.
Serialize(fp))
return false;
82 if (!xheights_.
Serialize(fp))
return false;
◆ SetFeatureSpace()
void tesseract::MasterTrainer::SetFeatureSpace |
( |
const IntFeatureSpace & |
fs | ) |
|
|
inline |
◆ SetupFlatShapeTable()
void tesseract::MasterTrainer::SetupFlatShapeTable |
( |
ShapeTable * |
shape_table | ) |
|
Definition at line 495 of file mastertrainer.cpp.
501 int num_shapes = flat_shapes_.
NumShapes();
502 for (
int s = 0; s < num_shapes; ++s) {
503 int font = flat_shapes_.
GetShape(s)[0].font_ids[0];
505 for (f = 0; f < active_fonts.
size(); ++f) {
506 if (active_fonts[f] == font)
509 if (f == active_fonts.
size())
513 int num_fonts = active_fonts.
size();
514 for (
int f = 0; f < num_fonts; ++f) {
515 for (
int s = num_shapes - 1; s >= 0; --s) {
516 int font = flat_shapes_.
GetShape(s)[0].font_ids[0];
517 if (font == active_fonts[f]) {
◆ SetupForClustering()
Definition at line 526 of file mastertrainer.cpp.
539 IndexMapBiDi shape_map;
540 shape_map.Init(shape_table.NumShapes(),
false);
541 shape_map.SetMap(shape_id,
true);
546 it.Init(&shape_map, &shape_table,
false, &samples_);
547 for (it.Begin(); !it.AtEnd(); it.Next()) {
551 for (
int i = sample_ptrs.
size() - 1; i >= 0; --i) {
552 const TrainingSample*
sample = sample_ptrs[i];
553 uint32_t num_features =
sample->num_micro_features();
554 for (uint32_t f = 0; f < num_features; ++f)
558 *num_samples = sample_id;
◆ SetupMasterShapes()
void tesseract::MasterTrainer::SetupMasterShapes |
( |
| ) |
|
Definition at line 245 of file mastertrainer.cpp.
246 tprintf(
"Building master shape table\n");
247 const int num_fonts = samples_.
NumFonts();
249 ShapeTable char_shapes_begin_fragment(samples_.
unicharset());
250 ShapeTable char_shapes_end_fragment(samples_.
unicharset());
251 ShapeTable char_shapes(samples_.
unicharset());
254 for (
int f = 0; f < num_fonts; ++f) {
256 shapes.AddShape(c, f);
262 if (fragment ==
nullptr)
263 char_shapes.AppendMasterShapes(shapes,
nullptr);
265 char_shapes_begin_fragment.AppendMasterShapes(shapes,
nullptr);
267 char_shapes_end_fragment.AppendMasterShapes(shapes,
nullptr);
269 char_shapes.AppendMasterShapes(shapes,
nullptr);
273 char_shapes.AppendMasterShapes(char_shapes_begin_fragment,
nullptr);
276 char_shapes.AppendMasterShapes(char_shapes_end_fragment,
nullptr);
◆ ShapeDistance()
float tesseract::MasterTrainer::ShapeDistance |
( |
const ShapeTable & |
shapes, |
|
|
int |
s1, |
|
|
int |
s2 |
|
) |
| |
Definition at line 809 of file mastertrainer.cpp.
810 const IntFeatureMap& feature_map = feature_map_;
811 const Shape& shape1 = shapes.GetShape(s1);
812 const Shape& shape2 = shapes.GetShape(s2);
813 int num_chars1 = shape1.size();
814 int num_chars2 = shape2.size();
815 float dist_sum = 0.0f;
817 if (num_chars1 > 1 || num_chars2 > 1) {
820 for (
int c1 = 0; c1 < num_chars1; ++c1) {
821 for (
int c2 = 0; c2 < num_chars2; ++c2) {
834 return dist_sum / dist_count;
◆ TestClassifier()
Definition at line 782 of file mastertrainer.cpp.
788 SampleIterator sample_it;
789 sample_it.Init(
nullptr,
nullptr, replicate_samples, samples);
790 if (report_level > 0) {
792 for (sample_it.Begin(); !sample_it.AtEnd(); sample_it.Next())
794 tprintf(
"Iterator has charset size of %d/%d, %d shapes, %d samples\n",
795 sample_it.SparseCharsetSize(), sample_it.CompactCharsetSize(),
796 test_classifier->GetShapeTable()->NumShapes(), num_samples);
797 tprintf(
"Testing %sREPLICATED:\n", replicate_samples ?
"" :
"NON-");
799 double unichar_error = 0.0;
801 error_mode, fontinfo_table_,
802 page_images_, &sample_it, &unichar_error,
803 nullptr, report_string);
804 return unichar_error;
◆ TestClassifierOnSamples()
void tesseract::MasterTrainer::TestClassifierOnSamples |
( |
CountTypes |
error_mode, |
|
|
int |
report_level, |
|
|
bool |
replicate_samples, |
|
|
ShapeClassifier * |
test_classifier, |
|
|
STRING * |
report_string |
|
) |
| |
◆ TestClassifierVOld()
Definition at line 748 of file mastertrainer.cpp.
751 SampleIterator sample_it;
752 sample_it.Init(
nullptr,
nullptr, replicate_samples, &samples_);
755 page_images_, &sample_it);
◆ unicharset()
const UNICHARSET& tesseract::MasterTrainer::unicharset |
( |
| ) |
const |
|
inline |
◆ WriteInttempAndPFFMTable()
void tesseract::MasterTrainer::WriteInttempAndPFFMTable |
( |
const UNICHARSET & |
unicharset, |
|
|
const UNICHARSET & |
shape_set, |
|
|
const ShapeTable & |
shape_table, |
|
|
CLASS_STRUCT * |
float_classes, |
|
|
const char * |
inttemp_file, |
|
|
const char * |
pffmtable_file |
|
) |
| |
Definition at line 566 of file mastertrainer.cpp.
574 fontinfo_table_.
MoveTo(&classify->get_fontinfo_table());
575 INT_TEMPLATES int_templates = classify->CreateIntTemplates(float_classes,
577 FILE* fp = fopen(inttemp_file,
"wb");
579 tprintf(
"Error, failed to open file \"%s\"\n", inttemp_file);
581 classify->WriteIntTemplates(fp, int_templates, shape_set);
594 for (
int i = 0; i < int_templates->
NumClasses; ++i) {
598 uint16_t max_length = 0;
599 for (
int config_id = 0; config_id < Class->
NumConfigs; config_id++) {
603 if (length > max_length)
605 int shape_id = float_classes[i].
font_set.
get(config_id);
606 const Shape& shape = shape_table.GetShape(shape_id);
607 for (
int c = 0; c < shape.size(); ++c) {
608 int unichar_id = shape[c].unichar_id;
609 if (length > unichar_cutoffs[unichar_id])
610 unichar_cutoffs[unichar_id] = length;
613 shapetable_cutoffs.
push_back(max_length);
615 fp = fopen(pffmtable_file,
"wb");
617 tprintf(
"Error, failed to open file \"%s\"\n", pffmtable_file);
622 if (strcmp(unichar,
" ") == 0) {
625 fprintf(fp,
"%s %d\n", unichar, unichar_cutoffs[c]);
The documentation for this class was generated from the following files:
bool load_from_file(const char *const filename, bool skip_fragments)
uint16_t ConfigLengths[MAX_NUM_CONFIGS]
bool Serialize(FILE *fp) const
TrainingSample * extract_sample(int index)
float ClusterDistance(int font_id1, int class_id1, int font_id2, int class_id2, const IntFeatureMap &feature_map)
void AppendOtherUnicharset(const UNICHARSET &src)
const char *const kGeoFeatureType
int tfscanf(FILE *stream, const char *format,...)
static void DebugNewErrors(ShapeClassifier *new_classifier, ShapeClassifier *old_classifier, CountTypes boosting_mode, const FontInfoTable &fontinfo_table, const GenericVector< Pix * > &page_images, SampleIterator *it)
uint32_t ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs, const char *ShortName)
void AddSample(bool verification, const char *unichar_str, TrainingSample *sample)
void AppendMasterShapes(const ShapeTable &other, GenericVector< int > *shape_map)
TrainingSample * mutable_sample(int index)
void LoadUnicharset(const char *filename)
void Init(const IntFeatureSpace &feature_space)
int NumClassSamples(int font_id, int class_id, bool randomize) const
void AddShape(const Shape &other)
bool contains(const T &object) const
bool Serialize(FILE *fp) const
bool Serialize(FILE *fp) const
const int kMinClusteredShapes
bool Serialize(FILE *fp) const
const char *const kIntFeatureType
bool save_to_file(const char *const filename) const
const BitVector & GetCloudFeatures(int font_id, int class_id) const
const FEATURE_DESC_STRUCT * FeatureDesc[NUM_FEATURE_TYPES]
double TestClassifier(CountTypes error_mode, int report_level, bool replicate_samples, TrainingSampleSet *samples, ShapeClassifier *test_classifier, STRING *report_string)
static CHAR_FRAGMENT * parse_from_string(const char *str)
bool ParseBoxFileStr(const char *boxfile_str, int *page_number, STRING *utf8_str, TBOX *bounding_box)
int GetFontInfoId(const char *font_name)
void ComputeCanonicalFeatures()
const char * c_str() const
float UnicharDistance(const UnicharAndFonts &uf1, const UnicharAndFonts &uf2, bool matched_fonts, const IntFeatureMap &feature_map)
const UNICHARSET & unicharset() const
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
int GetBestMatchingFontInfoId(const char *filename)
void MoveTo(UnicityTable< FontInfo > *target)
UnicityTableEqEq< int > font_set
const Shape & GetShape(int shape_id) const
FEATURE_DEFS_STRUCT feature_defs
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
CLUSTERER * MakeClusterer(int16_t SampleSize, const PARAM_DESC ParamDesc[])
int get_index(const T &object) const
const T & get(int id) const
Return the object from an id.
void OrganizeByFontAndClass()
int DivRounded(int a, int b)
const PARAM_DESC * ParamDesc
static double ComputeErrorRate(ShapeClassifier *classifier, int report_level, CountTypes boosting_mode, const FontInfoTable &fontinfo_table, const GenericVector< Pix * > &page_images, SampleIterator *it, double *unichar_error, double *scaled_error, STRING *fonts_report)
const char *const kMicroFeatureType
void ComputeCloudFeatures(int feature_space_size)
const IntFeatureSpace & feature_space() const
const int kMaxUnicharsPerCluster
SVEvent * AwaitEvent(SVEventType type)
int AddSample(const char *unichar, TrainingSample *sample)
const float kFontMergeDistance
bool contains_unichar(const char *const unichar_repr) const
const char *const kCNFeatureType
void init_to_size(int size, const T &t)
int FindShape(int unichar_id, int font_id) const
DLLSYM void tprintf(const char *format,...)
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
STRING SummaryStr() const
void free_int_templates(INT_TEMPLATES templates)
int AddShape(int unichar_id, int font_id)
void IndexFeatures(const IntFeatureSpace &feature_space)
const char * id_to_unichar(UNICHAR_ID id) const
bool is_beginning() const
void DisplaySamplesWithFeature(int f_index, const Shape &shape, const IntFeatureSpace &feature_space, ScrollView::Color color, ScrollView *window) const
bool Serialize(FILE *fp) const
void ReplicateAndRandomizeSamples()
bool Serialize(FILE *fp, const char *data, size_t n=1)
#define ClassForClassId(T, c)
const UNICHARSET & unicharset() const
void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView *window)
SAMPLE * MakeSample(CLUSTERER *Clusterer, const float *Feature, int32_t CharID)
CHAR_DESC ReadCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, FILE *File)
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
void FreeCharDescription(CHAR_DESC CharDesc)
const TrainingSample * GetCanonicalSample(int font_id, int class_id) const
void ComputeCanonicalSamples(const IntFeatureMap &map, bool debug)