78
78
// TODO(rays) BlobToTrainingSample must remain a global function until
79
79
// the FlexFx and FeatureDescription code can be removed and LearnBlob
80
80
// made a member of Classify.
81
TrainingSample* BlobToTrainingSample(const TBLOB& blob,
82
tesseract::NormalizationMode mode,
83
bool nonlinear_norm) {
84
INT_FX_RESULT_STRUCT fx_info;
85
GenericVector<INT_FEATURE_STRUCT> bl_features;
81
TrainingSample* BlobToTrainingSample(
82
const TBLOB& blob, bool nonlinear_norm, INT_FX_RESULT_STRUCT* fx_info,
83
GenericVector<INT_FEATURE_STRUCT>* bl_features) {
86
84
GenericVector<INT_FEATURE_STRUCT> cn_features;
87
Classify::ExtractFeatures(blob, nonlinear_norm, &bl_features,
88
&cn_features, &fx_info, NULL);
85
Classify::ExtractFeatures(blob, nonlinear_norm, bl_features,
86
&cn_features, fx_info, NULL);
89
87
// TODO(rays) Use blob->PreciseBoundingBox() instead.
90
88
TBOX box = blob.bounding_box();
91
89
TrainingSample* sample = NULL;
92
if (mode == tesseract::NM_CHAR_ANISOTROPIC) {
93
int num_features = fx_info.NumCN;
94
if (num_features > 0) {
95
sample = TrainingSample::CopyFromFeatures(fx_info, box, &cn_features[0],
98
} else if (mode == tesseract::NM_BASELINE) {
99
int num_features = fx_info.NumBL;
100
if (num_features > 0) {
101
sample = TrainingSample::CopyFromFeatures(fx_info, box, &bl_features[0],
105
ASSERT_HOST(!"Unsupported normalization mode!");
90
int num_features = fx_info->NumCN;
91
if (num_features > 0) {
92
sample = TrainingSample::CopyFromFeatures(*fx_info, box, &cn_features[0],
107
95
if (sample != NULL) {
108
96
// Set the bounding box (in original image coordinates) in the sample.