~vcs-imports/tesseract-ocr/trunk

« back to all changes in this revision

Viewing changes to classify/intfx.cpp

  • Committer: theraysmith at gmail
  • Date: 2013-11-08 20:30:56 UTC
  • Revision ID: svn-v4:d0cd1f9f-072b-0410-8dd7-cf729c803f20:trunk:904
Refactorerd control functions to enable parallel blob classification

Show diffs side-by-side

added added

removed removed

Lines of Context:
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],
96
 
                                                num_features);
97
 
    }
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],
102
 
                                                num_features);
103
 
    }
104
 
  } else {
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],
 
93
                                              num_features);
106
94
  }
107
95
  if (sample != NULL) {
108
96
    // Set the bounding box (in original image coordinates) in the sample.