16 #ifndef TESSERACT_TRAINING_TRAININGSAMPLESET_H_ 17 #define TESSERACT_TRAINING_TRAININGSAMPLESET_H_ 33 class IntFeatureSpace;
35 struct UnicharAndFonts;
56 return samples_.size();
59 return num_raw_samples_;
68 return unicharset_size_;
71 return fontinfo_table_;
125 int font_id2,
int class_id2,
130 int font_id2,
int class_id2,
144 int font_id2,
int class_id2,
146 bool thorough)
const;
162 return samples_[index];
167 samples_[index] =
nullptr;
225 struct FontClassDistance {
231 struct FontClassInfo {
243 int32_t canonical_sample;
245 float canonical_dist;
253 BitVector cloud_features;
266 PointerVector<TrainingSample> samples_;
268 int num_raw_samples_;
272 int unicharset_size_;
276 IndexMapBiDi font_id_map_;
283 const FontInfoTable& fontinfo_table_;
289 #endif // TRAININGSAMPLESETSET_H_
void KillSample(TrainingSample *sample)
void LoadUnicharset(const char *filename)
float UnicharDistance(const UnicharAndFonts &uf1, const UnicharAndFonts &uf2, bool matched_fonts, const IntFeatureMap &feature_map)
void ComputeCloudFeatures(int feature_space_size)
const GenericVector< int > & GetCanonicalFeatures(int font_id, int class_id) const
TrainingSampleSet(const FontInfoTable &fontinfo_table)
float GetCanonicalDist(int font_id, int class_id) const
virtual int SparseSize() const
int AddSample(const char *unichar, TrainingSample *sample)
TrainingSample * extract_sample(int index)
const FontInfoTable & fontinfo_table() const
bool Serialize(FILE *fp) const
void AddAllFontsForClass(int class_id, Shape *shape) const
TrainingSample * MutableSample(int font_id, int class_id, int index)
int num_raw_samples() const
bool DeSerialize(bool swap, FILE *fp)
void ComputeCanonicalFeatures()
int GlobalSampleIndex(int font_id, int class_id, int index) const
bool DeleteableSample(const TrainingSample *sample)
void ComputeCanonicalSamples(const IntFeatureMap &map, bool debug)
int NumClassSamples(int font_id, int class_id, bool randomize) const
void IndexFeatures(const IntFeatureSpace &feature_space)
const BitVector & GetCloudFeatures(int font_id, int class_id) const
const TrainingSample * GetSample(int index) const
const UNICHARSET & unicharset() const
float ComputeClusterDistance(int font_id1, int class_id1, int font_id2, int class_id2, const IntFeatureMap &feature_map) const
const TrainingSample * GetCanonicalSample(int font_id, int class_id) const
STRING SampleToString(const TrainingSample &sample) const
void DisplaySamplesWithFeature(int f_index, const Shape &shape, const IntFeatureSpace &feature_space, ScrollView::Color color, ScrollView *window) const
TrainingSample * mutable_sample(int index)
float ClusterDistance(int font_id1, int class_id1, int font_id2, int class_id2, const IntFeatureMap &feature_map)
int ReliablySeparable(int font_id1, int class_id1, int font_id2, int class_id2, const IntFeatureMap &feature_map, bool thorough) const
void ReplicateAndRandomizeSamples()
void OrganizeByFontAndClass()