#include <sampleiterator.h>
Definition at line 92 of file sampleiterator.h.
tesseract::SampleIterator::SampleIterator |
( |
| ) |
|
tesseract::SampleIterator::~SampleIterator |
( |
| ) |
|
bool tesseract::SampleIterator::AtEnd |
( |
| ) |
const |
void tesseract::SampleIterator::Begin |
( |
| ) |
|
Definition at line 87 of file sampleiterator.cpp.
89 shape_char_index_ = 0;
91 shape_font_index_ = 0;
const IndexMapBiDi& tesseract::SampleIterator::charset_map |
( |
| ) |
const |
|
inline |
void tesseract::SampleIterator::Clear |
( |
| ) |
|
int tesseract::SampleIterator::CompactCharsetSize |
( |
| ) |
const |
int tesseract::SampleIterator::GetCompactClassID |
( |
| ) |
const |
Definition at line 142 of file sampleiterator.cpp.
virtual int SparseToCompact(int sparse_index) const
int GetSparseClassID() const
Definition at line 103 of file sampleiterator.cpp.
104 if (shape_table_ !=
NULL) {
105 const UnicharAndFonts* shape_entry = GetShapeEntry();
106 int char_id = shape_entry->unichar_id;
107 int font_id = shape_entry->font_ids[shape_font_index_];
108 return *sample_set_->
GetSample(font_id, char_id, sample_index_);
110 return *sample_set_->
GetSample(shape_index_);
const TrainingSample * GetSample(int index) const
int tesseract::SampleIterator::GetSparseClassID |
( |
| ) |
const |
Definition at line 150 of file sampleiterator.cpp.
const TrainingSample & GetSample() const
UNICHAR_ID class_id() const
int tesseract::SampleIterator::GlobalSampleIndex |
( |
| ) |
const |
Definition at line 127 of file sampleiterator.cpp.
128 if (shape_table_ !=
NULL) {
129 const UnicharAndFonts* shape_entry = GetShapeEntry();
130 int char_id = shape_entry->unichar_id;
131 int font_id = shape_entry->font_ids[shape_font_index_];
int GlobalSampleIndex(int font_id, int class_id, int index) const
Definition at line 47 of file sampleiterator.cpp.
55 randomize_ = randomize;
56 if (shape_table_ ==
NULL && charset_map_ !=
NULL) {
59 int num_fonts = sample_set_->
NumFonts();
60 owned_shape_table_ =
new ShapeTable(sample_set_->
unicharset());
62 for (
int c = 0; c < charsetsize; ++c) {
65 int shape_id = owned_shape_table_->
AddShape(c, 0);
66 for (
int f = 1; f < num_fonts; ++f) {
68 owned_shape_table_->
AddToShape(shape_id, c, f);
72 shape_table_ = owned_shape_table_;
74 if (shape_table_ !=
NULL) {
77 num_shapes_ = randomize ? sample_set_->
num_samples()
const ShapeTable * shape_table() const
const IndexMapBiDi & charset_map() const
int NumClassSamples(int font_id, int class_id, bool randomize) const
int num_raw_samples() const
const UNICHARSET & unicharset() const
const TrainingSampleSet * sample_set() const
int AddShape(int unichar_id, int font_id)
void AddToShape(int shape_id, int unichar_id, int font_id)
void tesseract::SampleIterator::MapSampleFeatures |
( |
const IntFeatureMap & |
feature_map | ) |
|
Definition at line 211 of file sampleiterator.cpp.
214 sample->MapFeatures(feature_map);
TrainingSample * MutableSample() const
Definition at line 114 of file sampleiterator.cpp.
115 if (shape_table_ !=
NULL) {
116 const UnicharAndFonts* shape_entry = GetShapeEntry();
117 int char_id = shape_entry->unichar_id;
118 int font_id = shape_entry->font_ids[shape_font_index_];
119 return sample_set_->
MutableSample(font_id, char_id, sample_index_);
TrainingSample * MutableSample(int font_id, int class_id, int index)
TrainingSample * mutable_sample(int index)
void tesseract::SampleIterator::Next |
( |
| ) |
|
Definition at line 156 of file sampleiterator.cpp.
157 if (shape_table_ !=
NULL) {
160 if (sample_index_ < num_samples_)
166 if (shape_font_index_ >= num_shape_fonts_) {
168 shape_font_index_ = 0;
170 if (shape_char_index_ >= num_shape_chars_) {
172 shape_char_index_ = 0;
175 }
while (shape_index_ < num_shapes_ &&
176 charset_map_ !=
NULL &&
178 if (shape_index_ >= num_shapes_)
180 num_shape_chars_ = shape_table_->
GetShape(shape_index_).
size();
183 const UnicharAndFonts* shape_entry = GetShapeEntry();
184 num_shape_fonts_ = shape_entry->font_ids.size();
185 int char_id = shape_entry->unichar_id;
186 int font_id = shape_entry->font_ids[shape_font_index_];
187 num_samples_ = sample_set_->
NumClassSamples(font_id, char_id, randomize_);
188 }
while (num_samples_ == 0);
virtual int SparseToCompact(int sparse_index) const
int NumClassSamples(int font_id, int class_id, bool randomize) const
const Shape & GetShape(int shape_id) const
double tesseract::SampleIterator::NormalizeSamples |
( |
| ) |
|
Definition at line 233 of file sampleiterator.cpp.
234 double total_weight = 0.0;
235 int sample_count = 0;
238 total_weight += sample.weight();
242 double min_assigned_sample_weight = 1.0;
243 if (total_weight > 0.0) {
246 double weight = sample->weight() / total_weight;
247 if (weight < min_assigned_sample_weight)
248 min_assigned_sample_weight = weight;
249 sample->set_weight(weight);
252 return min_assigned_sample_weight;
TrainingSample * MutableSample() const
const TrainingSample & GetSample() const
const ShapeTable* tesseract::SampleIterator::shape_table |
( |
| ) |
const |
|
inline |
int tesseract::SampleIterator::SparseCharsetSize |
( |
| ) |
const |
int tesseract::SampleIterator::UniformSamples |
( |
| ) |
|
Definition at line 220 of file sampleiterator.cpp.
221 int num_good_samples = 0;
224 sample->set_weight(1.0);
228 return num_good_samples;
TrainingSample * MutableSample() const
double NormalizeSamples()
The documentation for this class was generated from the following files: