~ubuntu-branches/ubuntu/vivid/tesseract/vivid

« back to all changes in this revision

Viewing changes to classify/intmatcher.cpp

  • Committer: Package Import Robot
  • Author(s): Jeff Breidenbach
  • Date: 2014-02-03 11:10:20 UTC
  • mfrom: (1.3.1) (19.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140203111020-igquodd7pjlp3uri
Tags: 3.03.01-1
* New upstream release, includes critical fix to PDF rendering
* Complete leptonlib transition (see bug #735509)
* Promote from experimental to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
357
357
 
358
358
  // Copies the pruned, sorted classes into the output results and returns
359
359
  // the number of classes.
360
 
  int SetupResults(CP_RESULT_STRUCT* results) const {
 
360
  int SetupResults(GenericVector<CP_RESULT_STRUCT>* results) const {
 
361
    CP_RESULT_STRUCT empty;
 
362
    results->init_to_size(num_classes_, empty);
361
363
    for (int c = 0; c < num_classes_; ++c) {
362
 
      results[c].Class = sort_index_[num_classes_ - c];
363
 
      results[c].Rating = 1.0 - sort_key_[num_classes_ - c] /
 
364
      (*results)[c].Class = sort_index_[num_classes_ - c];
 
365
      (*results)[c].Rating = 1.0 - sort_key_[num_classes_ - c] /
364
366
        (static_cast<float>(CLASS_PRUNER_CLASS_MASK) * num_features_);
365
367
    }
366
368
    return num_classes_;
408
410
                           const INT_FEATURE_STRUCT* features,
409
411
                           const uinT8* normalization_factors,
410
412
                           const uinT16* expected_num_features,
411
 
                           CP_RESULT_STRUCT* results) {
 
413
                           GenericVector<CP_RESULT_STRUCT>* results) {
412
414
/*
413
415
 **  Operation:
414
416
 **    Prunes the classes using a modified fast match table.
693
695
 
694
696
 
695
697
/*---------------------------------------------------------------------------*/
696
 
void IntegerMatcher::Init(tesseract::IntParam *classify_debug_level,
697
 
                          int classify_integer_matcher_multiplier) {
 
698
void IntegerMatcher::Init(tesseract::IntParam *classify_debug_level) {
698
699
  classify_debug_level_ = classify_debug_level;
699
700
 
700
 
  /* Set default mode of operation of IntegerMatcher */
701
 
  SetCharNormMatch(classify_integer_matcher_multiplier);
702
 
 
703
701
  /* Initialize table for evidence to similarity lookup */
704
702
  for (int i = 0; i < SE_TABLE_SIZE; i++) {
705
703
    uinT32 IntSimilarity = i << (27 - SE_TABLE_BITS);
724
722
  evidence_mult_mask_ = ((1 << kIntEvidenceTruncBits) - 1);
725
723
}
726
724
 
727
 
/*--------------------------------------------------------------------------*/
728
 
void IntegerMatcher::SetBaseLineMatch() {
729
 
  local_matcher_multiplier_ = 0;
730
 
}
731
 
 
732
 
 
733
 
/*--------------------------------------------------------------------------*/
734
 
void IntegerMatcher::SetCharNormMatch(int integer_matcher_multiplier) {
735
 
  local_matcher_multiplier_ = integer_matcher_multiplier;
736
 
}
737
 
 
738
725
 
739
726
/**----------------------------------------------------------------------------
740
727
              Private Code
1283
1270
// Applies the CN normalization factor to the given rating and returns
1284
1271
// the modified rating.
1285
1272
float IntegerMatcher::ApplyCNCorrection(float rating, int blob_length,
1286
 
                                        int normalization_factor) {
 
1273
                                        int normalization_factor,
 
1274
                                        int matcher_multiplier) {
1287
1275
  return (rating * blob_length +
1288
 
    local_matcher_multiplier_ * normalization_factor / 256.0) /
1289
 
    (blob_length + local_matcher_multiplier_);
 
1276
          matcher_multiplier * normalization_factor / 256.0) /
 
1277
      (blob_length + matcher_multiplier);
1290
1278
}
1291
1279
 
1292
1280
/*---------------------------------------------------------------------------*/