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

Method ExtractCharDesc

deps/tesseract/classify/trainingsample.cpp:206–273  ·  view source on GitHub ↗

Extracts the needed information from the CHAR_DESC_STRUCT.

Source from the content-addressed store, hash-verified

204
205// Extracts the needed information from the CHAR_DESC_STRUCT.
206void TrainingSample::ExtractCharDesc(int int_feature_type,
207 int micro_type,
208 int cn_type,
209 int geo_type,
210 CHAR_DESC_STRUCT* char_desc) {
211 // Extract the INT features.
212 delete[] features_;
213 FEATURE_SET_STRUCT* char_features = char_desc->FeatureSets[int_feature_type];
214 if (char_features == NULL) {
215 tprintf("Error: no features to train on of type %s\n",
216 kIntFeatureType);
217 num_features_ = 0;
218 features_ = NULL;
219 } else {
220 num_features_ = char_features->NumFeatures;
221 features_ = new INT_FEATURE_STRUCT[num_features_];
222 for (int f = 0; f < num_features_; ++f) {
223 features_[f].X =
224 static_cast<uinT8>(char_features->Features[f]->Params[IntX]);
225 features_[f].Y =
226 static_cast<uinT8>(char_features->Features[f]->Params[IntY]);
227 features_[f].Theta =
228 static_cast<uinT8>(char_features->Features[f]->Params[IntDir]);
229 features_[f].CP_misses = 0;
230 }
231 }
232 // Extract the Micro features.
233 delete[] micro_features_;
234 char_features = char_desc->FeatureSets[micro_type];
235 if (char_features == NULL) {
236 tprintf("Error: no features to train on of type %s\n",
237 kMicroFeatureType);
238 num_micro_features_ = 0;
239 micro_features_ = NULL;
240 } else {
241 num_micro_features_ = char_features->NumFeatures;
242 micro_features_ = new MicroFeature[num_micro_features_];
243 for (int f = 0; f < num_micro_features_; ++f) {
244 for (int d = 0; d < MFCount; ++d) {
245 micro_features_[f][d] = char_features->Features[f]->Params[d];
246 }
247 }
248 }
249 // Extract the CN feature.
250 char_features = char_desc->FeatureSets[cn_type];
251 if (char_features == NULL) {
252 tprintf("Error: no CN feature to train on.\n");
253 } else {
254 ASSERT_HOST(char_features->NumFeatures == 1);
255 cn_feature_[CharNormY] = char_features->Features[0]->Params[CharNormY];
256 cn_feature_[CharNormLength] =
257 char_features->Features[0]->Params[CharNormLength];
258 cn_feature_[CharNormRx] = char_features->Features[0]->Params[CharNormRx];
259 cn_feature_[CharNormRy] = char_features->Features[0]->Params[CharNormRy];
260 }
261 // Extract the Geo feature.
262 char_features = char_desc->FeatureSets[geo_type];
263 if (char_features == NULL) {

Callers 1

ReadTrainingSamplesMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected