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

Method EnumSamples

deps/tesseract/cube/char_samp_set.cpp:135–168  ·  view source on GitHub ↗

Enumerate the Samples in the set one-by-one calling the enumertor's EnumCharSamp method for each sample

Source from the content-addressed store, hash-verified

133// Enumerate the Samples in the set one-by-one calling the enumertor's
134 // EnumCharSamp method for each sample
135bool CharSampSet::EnumSamples(string file_name, CharSampEnum *enum_obj) {
136 CachedFile *fp_in;
137 unsigned int val32;
138 long i64_size,
139 i64_pos;
140 // open the file
141 fp_in = new CachedFile(file_name);
142 i64_size = fp_in->Size();
143 if (i64_size < 1) {
144 return false;
145 }
146 // read and verify marker
147 if (fp_in->Read(&val32, sizeof(val32)) != sizeof(val32)) {
148 return false;
149 }
150 if (val32 != 0xfefeabd0) {
151 return false;
152 }
153 // start loading char samples
154 while (fp_in->eof() == false) {
155 CharSamp *new_samp = CharSamp::FromCharDumpFile(fp_in);
156 i64_pos = fp_in->Tell();
157 if (new_samp != NULL) {
158 bool ret_flag = (enum_obj)->EnumCharSamp(new_samp,
159 (100.0f * i64_pos / i64_size));
160 delete new_samp;
161 if (ret_flag == false) {
162 break;
163 }
164 }
165 }
166 delete fp_in;
167 return true;
168}
169
170} // namespace ocrlib

Callers

nothing calls this directly

Calls 4

SizeMethod · 0.80
eofMethod · 0.80
TellMethod · 0.80
ReadMethod · 0.45

Tested by

no test coverage detected