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

Method NumClassSamples

deps/tesseract/classify/trainingsampleset.cpp:156–171  ·  view source on GitHub ↗

Returns the number of samples for the given font,class pair. If randomize is true, returns the number of samples accessible with randomizing on. (Increases the number of samples if small.) OrganizeByFontAndClass must have been already called.

Source from the content-addressed store, hash-verified

154// with randomizing on. (Increases the number of samples if small.)
155// OrganizeByFontAndClass must have been already called.
156int TrainingSampleSet::NumClassSamples(int font_id, int class_id,
157 bool randomize) const {
158 ASSERT_HOST(font_class_array_ != NULL);
159 if (font_id < 0 || class_id < 0 ||
160 font_id >= font_id_map_.SparseSize() || class_id >= unicharset_size_) {
161 // There are no samples because the font or class doesn't exist.
162 return 0;
163 }
164 int font_index = font_id_map_.SparseToCompact(font_id);
165 if (font_index < 0)
166 return 0; // The font has no samples.
167 if (randomize)
168 return (*font_class_array_)(font_index, class_id).samples.size();
169 else
170 return (*font_class_array_)(font_index, class_id).num_raw_samples;
171}
172
173// Gets a sample by its index.
174const TrainingSample* TrainingSampleSet::GetSample(int index) const {

Callers 4

SetupMasterShapesMethod · 0.80
DebugCanonicalMethod · 0.80
InitMethod · 0.80
NextMethod · 0.80

Calls 3

SparseSizeMethod · 0.45
SparseToCompactMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected