Computes the combined set of features used by all the samples of each font/class combination. Use after ReplicateAndRandomizeSamples.
| 807 | // Computes the combined set of features used by all the samples of each |
| 808 | // font/class combination. Use after ReplicateAndRandomizeSamples. |
| 809 | void 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. |
| 831 | void TrainingSampleSet::AddAllFontsForClass(int class_id, Shape* shape) const { |
no test coverage detected