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

Method LearnBlob

deps/tesseract/classify/blobclass.cpp:69–93  ·  view source on GitHub ↗

---------------------------------------------------------------------------*/ Extracts features from the given blob and saves them in the tr_file_data_ member variable. fontname: Name of font that this blob was printed in. cn_denorm: Character normalization transformation to apply to the blob. fx_info: Character normalization parameters computed with cn_denorm. blob_text: Ground truth text for

Source from the content-addressed store, hash-verified

67// fx_info: Character normalization parameters computed with cn_denorm.
68// blob_text: Ground truth text for the blob.
69void Classify::LearnBlob(const STRING& fontname, TBLOB* blob,
70 const DENORM& cn_denorm,
71 const INT_FX_RESULT_STRUCT& fx_info,
72 const char* blob_text) {
73 CHAR_DESC CharDesc = NewCharDescription(feature_defs_);
74 CharDesc->FeatureSets[0] = ExtractMicros(blob, cn_denorm);
75 CharDesc->FeatureSets[1] = ExtractCharNormFeatures(fx_info);
76 CharDesc->FeatureSets[2] = ExtractIntCNFeatures(*blob, fx_info);
77 CharDesc->FeatureSets[3] = ExtractIntGeoFeatures(*blob, fx_info);
78
79 if (ValidCharDescription(feature_defs_, CharDesc)) {
80 // Label the features with a class name and font name.
81 tr_file_data_ += "\n";
82 tr_file_data_ += fontname;
83 tr_file_data_ += " ";
84 tr_file_data_ += blob_text;
85 tr_file_data_ += "\n";
86
87 // write micro-features to file and clean up
88 WriteCharDescription(feature_defs_, CharDesc, &tr_file_data_);
89 } else {
90 tprintf("Blob learned was invalid!\n");
91 }
92 FreeCharDescription(CharDesc);
93} // LearnBlob
94
95// Writes stored training data to a .tr file based on the given filename.
96// Returns false on error.

Callers

nothing calls this directly

Calls 6

NewCharDescriptionFunction · 0.85
ExtractMicrosFunction · 0.85
ExtractCharNormFeaturesFunction · 0.85
ValidCharDescriptionFunction · 0.85
WriteCharDescriptionFunction · 0.85
FreeCharDescriptionFunction · 0.85

Tested by

no test coverage detected