tesseract  3.03
tesseract::BoxChar Class Reference

#include <boxchar.h>

List of all members.

Public Member Functions

 BoxChar (const char *utf8_str, int len)
 ~BoxChar ()
const string & ch () const
const Box * box () const
const int & page () const
void AddBox (int x, int y, int width, int height)
void set_page (int page)
string * mutable_ch ()
Box * mutable_box ()

Static Public Member Functions

static void TranslateBoxes (int xshift, int yshift, vector< BoxChar * > *boxes)
static void RotateBoxes (float rotation, int xcenter, int ycenter, int start_box, int end_box, vector< BoxChar * > *boxes)
static void WriteTesseractBoxFile (const string &name, int height, const vector< BoxChar * > &boxes)

Detailed Description

Definition at line 40 of file boxchar.h.


Constructor & Destructor Documentation

tesseract::BoxChar::BoxChar ( const char *  utf8_str,
int  len 
)

Definition at line 31 of file boxchar.cpp.

                                              : ch_(utf8_str, len) {
  box_ = NULL;
}

Definition at line 35 of file boxchar.cpp.

                  {
  boxDestroy(&box_);
}

Member Function Documentation

void tesseract::BoxChar::AddBox ( int  x,
int  y,
int  width,
int  height 
)

Definition at line 39 of file boxchar.cpp.

                                                        {
  box_ = boxCreate(x, y, width, height);
}
const Box* tesseract::BoxChar::box ( ) const [inline]

Definition at line 48 of file boxchar.h.

{ return box_; }
const string& tesseract::BoxChar::ch ( ) const [inline]

Definition at line 47 of file boxchar.h.

{ return ch_; }

Definition at line 58 of file boxchar.h.

{ return box_; }
string* tesseract::BoxChar::mutable_ch ( ) [inline]

Definition at line 57 of file boxchar.h.

{ return &ch_; }
const int& tesseract::BoxChar::page ( ) const [inline]

Definition at line 49 of file boxchar.h.

{ return page_; }
void tesseract::BoxChar::RotateBoxes ( float  rotation,
int  xcenter,
int  ycenter,
int  start_box,
int  end_box,
vector< BoxChar * > *  boxes 
) [static]

Definition at line 58 of file boxchar.cpp.

                                                   {
  Boxa* orig = boxaCreate(0);
  for (int i = start_box; i < end_box; ++i) {
    BOX* box = (*boxes)[i]->box_;
    if (box) boxaAddBox(orig, box, L_CLONE);
  }
  Boxa* rotated = boxaRotate(orig, xcenter, ycenter, rotation);
  boxaDestroy(&orig);
  for (int i = start_box, box_ind = 0; i < end_box; ++i) {
    if ((*boxes)[i]->box_) {
      boxDestroy(&((*boxes)[i]->box_));
      (*boxes)[i]->box_ = boxaGetBox(rotated, box_ind++, L_CLONE);
    }
  }
  boxaDestroy(&rotated);
}
void tesseract::BoxChar::set_page ( int  page) [inline]

Definition at line 55 of file boxchar.h.

{ page_ = page; }
void tesseract::BoxChar::TranslateBoxes ( int  xshift,
int  yshift,
vector< BoxChar * > *  boxes 
) [static]

Definition at line 44 of file boxchar.cpp.

                                                      {
  for (int i = 0; i < boxes->size(); ++i) {
    BOX* box = (*boxes)[i]->box_;
    if (box != NULL) {
      box->x += xshift;
      box->y += yshift;
    }
  }
}
void tesseract::BoxChar::WriteTesseractBoxFile ( const string &  name,
int  height,
const vector< BoxChar * > &  boxes 
) [static]

Definition at line 81 of file boxchar.cpp.

                                                                   {
  string output;
  const int kMaxLineLength = 1024;
  char buffer[kMaxLineLength];
  for (int i = 0; i < boxes.size(); ++i) {
    if (boxes[i]->box_ != NULL) {
      int nbytes = snprintf(buffer, kMaxLineLength,
                            "%s %d %d %d %d %d\n",
                            boxes[i]->ch_.c_str(),
                            boxes[i]->box_->x,
                            height - boxes[i]->box_->y - boxes[i]->box_->h,
                            boxes[i]->box_->x + boxes[i]->box_->w,
                            height - boxes[i]->box_->y,
                            boxes[i]->page_);
      output.append(buffer, nbytes);
    }
  }
  File::WriteStringToFileOrDie(output, filename);
}

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