---------------------------------------------------------------------------*/ 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
| 67 | // fx_info: Character normalization parameters computed with cn_denorm. |
| 68 | // blob_text: Ground truth text for the blob. |
| 69 | void 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. |
nothing calls this directly
no test coverage detected