MCPcopy Create free account
hub / github.com/creatale/node-dv / SetupFontIdMap

Method SetupFontIdMap

deps/tesseract/classify/trainingsampleset.cpp:640–654  ·  view source on GitHub ↗

Constructs the font_id_map_ which maps real font_ids (sparse) to a compact index for the font_class_array_.

Source from the content-addressed store, hash-verified

638// Constructs the font_id_map_ which maps real font_ids (sparse) to a compact
639// index for the font_class_array_.
640void TrainingSampleSet::SetupFontIdMap() {
641 // Number of samples for each font_id.
642 GenericVector<int> font_counts;
643 for (int s = 0; s < samples_.size(); ++s) {
644 int font_id = samples_[s]->font_id();
645 while (font_id >= font_counts.size())
646 font_counts.push_back(0);
647 ++font_counts[font_id];
648 }
649 font_id_map_.Init(font_counts.size(), false);
650 for (int f = 0; f < font_counts.size(); ++f) {
651 font_id_map_.SetMap(f, font_counts[f] > 0);
652 }
653 font_id_map_.Setup();
654}
655
656
657// Finds the sample for each font, class pair that has least maximum

Callers

nothing calls this directly

Calls 6

font_idMethod · 0.80
SetMapMethod · 0.80
SetupMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected