tesseract  3.03
BLOB_CHOICE Class Reference

#include <ratngs.h>

Inheritance diagram for BLOB_CHOICE:
ELIST_LINK

List of all members.

Public Member Functions

 BLOB_CHOICE ()
 BLOB_CHOICE (UNICHAR_ID src_unichar_id, float src_rating, float src_cert, inT16 src_fontinfo_id, inT16 src_fontinfo_id2, int script_id, float min_xheight, float max_xheight, float yshift, BlobChoiceClassifier c)
 BLOB_CHOICE (const BLOB_CHOICE &other)
 ~BLOB_CHOICE ()
UNICHAR_ID unichar_id () const
float rating () const
float certainty () const
inT16 fontinfo_id () const
inT16 fontinfo_id2 () const
int script_id () const
const MATRIX_COORDmatrix_cell ()
inT16 xgap_before () const
inT16 xgap_after () const
float min_xheight () const
float max_xheight () const
float yshift () const
BlobChoiceClassifier classifier () const
bool IsAdapted () const
bool IsClassified () const
void set_unichar_id (UNICHAR_ID newunichar_id)
void set_rating (float newrat)
void set_certainty (float newrat)
void set_fontinfo_id (inT16 newfont)
void set_fontinfo_id2 (inT16 newfont)
void set_script (int newscript_id)
void set_matrix_cell (int col, int row)
void set_xgap_before (inT16 gap)
void set_xgap_after (inT16 gap)
void set_classifier (BlobChoiceClassifier classifier)
bool PosAndSizeAgree (const BLOB_CHOICE &other, float x_height, bool debug) const
void print (const UNICHARSET *unicharset) const
void print_full () const

Static Public Member Functions

static BLOB_CHOICEdeep_copy (const BLOB_CHOICE *src)
static int SortByRating (const void *p1, const void *p2)

Detailed Description

Definition at line 47 of file ratngs.h.


Constructor & Destructor Documentation

Definition at line 50 of file ratngs.h.

                  {
      unichar_id_ = INVALID_UNICHAR_ID;
      fontinfo_id_ = -1;
      fontinfo_id2_ = -1;
      rating_ = MAX_FLOAT32;
      certainty_ = -MAX_FLOAT32;
      script_id_ = -1;
      xgap_before_ = 0;
      xgap_after_ = 0;
      min_xheight_ = 0.0f;
      max_xheight_ = 0.0f;
      yshift_ = 0.0f;
      classifier_ = BCC_FAKE;
    }
BLOB_CHOICE::BLOB_CHOICE ( UNICHAR_ID  src_unichar_id,
float  src_rating,
float  src_cert,
inT16  src_fontinfo_id,
inT16  src_fontinfo_id2,
int  src_script_id,
float  min_xheight,
float  max_xheight,
float  yshift,
BlobChoiceClassifier  c 
)

BLOB_CHOICE::BLOB_CHOICE

Constructor to build a BLOB_CHOICE from a char, rating and certainty.

Definition at line 90 of file ratngs.cpp.

                                                 {  // adapted match or other
  unichar_id_ = src_unichar_id;
  rating_ = src_rating;
  certainty_ = src_cert;
  fontinfo_id_ = src_fontinfo_id;
  fontinfo_id2_ = src_fontinfo_id2;
  script_id_ = src_script_id;
  min_xheight_ = min_xheight;
  max_xheight_ = max_xheight;
  yshift_ = yshift;
  classifier_ = c;
}

BLOB_CHOICE::BLOB_CHOICE

Constructor to build a BLOB_CHOICE from another BLOB_CHOICE.

Definition at line 117 of file ratngs.cpp.

                                                 {
  unichar_id_ = other.unichar_id();
  rating_ = other.rating();
  certainty_ = other.certainty();
  fontinfo_id_ = other.fontinfo_id();
  fontinfo_id2_ = other.fontinfo_id2();
  script_id_ = other.script_id();
  matrix_cell_ = other.matrix_cell_;
  min_xheight_ = other.min_xheight_;
  max_xheight_ = other.max_xheight_;
  yshift_ = other.yshift();
  classifier_ = other.classifier_;
}

Definition at line 75 of file ratngs.h.

{}

Member Function Documentation

float BLOB_CHOICE::certainty ( ) const [inline]

Definition at line 83 of file ratngs.h.

                            {
      return certainty_;
    }

Definition at line 113 of file ratngs.h.

                                            {
      return classifier_;
    }
static BLOB_CHOICE* BLOB_CHOICE::deep_copy ( const BLOB_CHOICE src) [inline, static]

Definition at line 156 of file ratngs.h.

                                                          {
      BLOB_CHOICE* choice = new BLOB_CHOICE;
      *choice = *src;
      return choice;
    }
inT16 BLOB_CHOICE::fontinfo_id ( ) const [inline]

Definition at line 86 of file ratngs.h.

                              {
      return fontinfo_id_;
    }
inT16 BLOB_CHOICE::fontinfo_id2 ( ) const [inline]

Definition at line 89 of file ratngs.h.

                               {
      return fontinfo_id2_;
    }
bool BLOB_CHOICE::IsAdapted ( ) const [inline]

Definition at line 116 of file ratngs.h.

                           {
      return classifier_ == BCC_ADAPTED_CLASSIFIER;
    }
bool BLOB_CHOICE::IsClassified ( ) const [inline]

Definition at line 119 of file ratngs.h.

                              {
      return classifier_ == BCC_STATIC_CLASSIFIER ||
             classifier_ == BCC_ADAPTED_CLASSIFIER ||
             classifier_ == BCC_SPECKLE_CLASSIFIER;
    }

Definition at line 95 of file ratngs.h.

                                      {
      return matrix_cell_;
    }
float BLOB_CHOICE::max_xheight ( ) const [inline]

Definition at line 107 of file ratngs.h.

                              {
      return max_xheight_;
    }
float BLOB_CHOICE::min_xheight ( ) const [inline]

Definition at line 104 of file ratngs.h.

                              {
      return min_xheight_;
    }
bool BLOB_CHOICE::PosAndSizeAgree ( const BLOB_CHOICE other,
float  x_height,
bool  debug 
) const

Definition at line 133 of file ratngs.cpp.

                                                    {
  double baseline_diff = fabs(yshift() - other.yshift());
  if (baseline_diff > kMaxBaselineDrift * x_height) {
    if (debug) {
      tprintf("Baseline diff %g for %d v %d\n",
              baseline_diff, unichar_id_, other.unichar_id_);
    }
    return false;
  }
  double this_range = max_xheight() - min_xheight();
  double other_range = other.max_xheight() - other.min_xheight();
  double denominator = ClipToRange(MIN(this_range, other_range),
                                   1.0, kMaxOverlapDenominator * x_height);
  double overlap = MIN(max_xheight(), other.max_xheight()) -
                   MAX(min_xheight(), other.min_xheight());
  overlap /= denominator;
  if (debug) {
    tprintf("PosAndSize for %d v %d: bl diff = %g, ranges %g, %g / %g ->%g\n",
            unichar_id_, other.unichar_id_, baseline_diff,
            this_range, other_range, denominator, overlap);
  }

  return overlap >= kMinXHeightMatch;
}
void BLOB_CHOICE::print ( const UNICHARSET unicharset) const [inline]

Definition at line 166 of file ratngs.h.

                                                   {
      tprintf("r%.2f c%.2f x[%g,%g]: %d %s",
              rating_, certainty_,
              min_xheight_, max_xheight_, unichar_id_,
              (unicharset == NULL) ? "" :
              unicharset->debug_str(unichar_id_).string());
    }
void BLOB_CHOICE::print_full ( ) const [inline]

Definition at line 173 of file ratngs.h.

                            {
      print(NULL);
      tprintf(" script=%d, font1=%d, font2=%d, yshift=%g, classifier=%d\n",
              script_id_, fontinfo_id_, fontinfo_id2_, yshift_, classifier_);
    }
float BLOB_CHOICE::rating ( ) const [inline]

Definition at line 80 of file ratngs.h.

                         {
      return rating_;
    }
int BLOB_CHOICE::script_id ( ) const [inline]

Definition at line 92 of file ratngs.h.

                          {
      return script_id_;
    }
void BLOB_CHOICE::set_certainty ( float  newrat) [inline]

Definition at line 131 of file ratngs.h.

                                     {
      certainty_ = newrat;
    }
void BLOB_CHOICE::set_classifier ( BlobChoiceClassifier  classifier) [inline]

Definition at line 153 of file ratngs.h.

                                                         {
      classifier_ = classifier;
    }
void BLOB_CHOICE::set_fontinfo_id ( inT16  newfont) [inline]

Definition at line 134 of file ratngs.h.

                                        {
      fontinfo_id_ = newfont;
    }
void BLOB_CHOICE::set_fontinfo_id2 ( inT16  newfont) [inline]

Definition at line 137 of file ratngs.h.

                                         {
      fontinfo_id2_ = newfont;
    }
void BLOB_CHOICE::set_matrix_cell ( int  col,
int  row 
) [inline]

Definition at line 143 of file ratngs.h.

                                           {
      matrix_cell_.col = col;
      matrix_cell_.row = row;
    }
void BLOB_CHOICE::set_rating ( float  newrat) [inline]

Definition at line 128 of file ratngs.h.

                                  {
      rating_ = newrat;
    }
void BLOB_CHOICE::set_script ( int  newscript_id) [inline]

Definition at line 140 of file ratngs.h.

                                      {
      script_id_ = newscript_id;
    }
void BLOB_CHOICE::set_unichar_id ( UNICHAR_ID  newunichar_id) [inline]

Definition at line 125 of file ratngs.h.

                                                  {
      unichar_id_ = newunichar_id;
    }
void BLOB_CHOICE::set_xgap_after ( inT16  gap) [inline]

Definition at line 150 of file ratngs.h.

                                   {
      xgap_after_ = gap;
    }
void BLOB_CHOICE::set_xgap_before ( inT16  gap) [inline]

Definition at line 147 of file ratngs.h.

                                    {
      xgap_before_ = gap;
    }
static int BLOB_CHOICE::SortByRating ( const void *  p1,
const void *  p2 
) [inline, static]

Definition at line 179 of file ratngs.h.

                                                            {
      const BLOB_CHOICE *bc1 =
          *reinterpret_cast<const BLOB_CHOICE * const *>(p1);
      const BLOB_CHOICE *bc2 =
          *reinterpret_cast<const BLOB_CHOICE * const *>(p2);
      return (bc1->rating_ < bc2->rating_) ? -1 : 1;
    }
UNICHAR_ID BLOB_CHOICE::unichar_id ( ) const [inline]

Definition at line 77 of file ratngs.h.

                                  {
      return unichar_id_;
    }
inT16 BLOB_CHOICE::xgap_after ( ) const [inline]

Definition at line 101 of file ratngs.h.

                             {
      return xgap_after_;
    }
inT16 BLOB_CHOICE::xgap_before ( ) const [inline]

Definition at line 98 of file ratngs.h.

                              {
      return xgap_before_;
    }
float BLOB_CHOICE::yshift ( ) const [inline]

Definition at line 110 of file ratngs.h.

                         {
      return yshift_;
    }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines