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

Method ComputeCloudFeatures

deps/tesseract/classify/trainingsampleset.cpp:809–828  ·  view source on GitHub ↗

Computes the combined set of features used by all the samples of each font/class combination. Use after ReplicateAndRandomizeSamples.

Source from the content-addressed store, hash-verified

807// Computes the combined set of features used by all the samples of each
808// font/class combination. Use after ReplicateAndRandomizeSamples.
809void TrainingSampleSet::ComputeCloudFeatures(int feature_space_size) {
810 ASSERT_HOST(font_class_array_ != NULL);
811 int font_size = font_id_map_.CompactSize();
812 for (int font_index = 0; font_index < font_size; ++font_index) {
813 int font_id = font_id_map_.CompactToSparse(font_index);
814 for (int c = 0; c < unicharset_size_; ++c) {
815 int num_samples = NumClassSamples(font_id, c, false);
816 if (num_samples == 0)
817 continue;
818 FontClassInfo& fcinfo = (*font_class_array_)(font_index, c);
819 fcinfo.cloud_features.Init(feature_space_size);
820 for (int s = 0; s < num_samples; ++s) {
821 const TrainingSample* sample = GetSample(font_id, c, s);
822 const GenericVector<int>& sample_features = sample->indexed_features();
823 for (int i = 0; i < sample_features.size(); ++i)
824 fcinfo.cloud_features.SetBit(sample_features[i]);
825 }
826 }
827 }
828}
829
830// Adds all fonts of the given class to the shape.
831void TrainingSampleSet::AddAllFontsForClass(int class_id, Shape* shape) const {

Callers 1

PreTrainingSetupMethod · 0.80

Calls 5

CompactSizeMethod · 0.80
CompactToSparseMethod · 0.80
SetBitMethod · 0.80
InitMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected