Tesseract  3.02
OrientationDetector Class Reference

#include <osdetect.h>

List of all members.

Public Member Functions

 OrientationDetector (OSResults *)
bool detect_blob (BLOB_CHOICE_LIST *scores)
int get_orientation ()

Detailed Description

Definition at line 82 of file osdetect.h.


Constructor & Destructor Documentation

OrientationDetector::OrientationDetector ( OSResults osr)

Definition at line 370 of file osdetect.cpp.

                                                       {
  osr_ = osr;
}

Member Function Documentation

bool OrientationDetector::detect_blob ( BLOB_CHOICE_LIST *  scores)

Definition at line 376 of file osdetect.cpp.

                                                              {
  float blob_o_score[4] = {0.0, 0.0, 0.0, 0.0};
  float total_blob_o_score = 0.0;

  for (int i = 0; i < 4; ++i) {
    BLOB_CHOICE_IT choice_it;
    choice_it.set_to_list(scores + i);
    if (!choice_it.empty()) {
      // The certainty score ranges between [-20,0]. This is converted here to
      // [0,1], with 1 indicating best match.
      blob_o_score[i] = 1 + 0.05 * choice_it.data()->certainty();
      total_blob_o_score += blob_o_score[i];
    }
  }
  // Normalize the orientation scores for the blob and use them to
  // update the aggregated orientation score.
  for (int i = 0; total_blob_o_score != 0 && i < 4; ++i) {
    osr_->orientations[i] += log(blob_o_score[i] / total_blob_o_score);
  }

  float first = -1;
  float second = -1;

  int idx = -1;
  for (int i = 0; i < 4; ++i) {
    if (osr_->orientations[i] > first) {
      idx = i;
      second = first;
      first = osr_->orientations[i];
    } else if (osr_->orientations[i] > second) {
      second = osr_->orientations[i];
    }
  }

  return first / second > kOrientationAcceptRatio;
}
int OrientationDetector::get_orientation ( )

Definition at line 413 of file osdetect.cpp.


The documentation for this class was generated from the following files: