All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tesseract::WordFeature Class Reference

#include <imagedata.h>

Public Member Functions

 WordFeature ()
 
 WordFeature (const FCOORD &fcoord, uinT8 dir)
 
int x () const
 
int y () const
 
int dir () const
 
bool Serialize (FILE *fp) const
 
bool DeSerialize (bool swap, FILE *fp)
 

Static Public Member Functions

static void ComputeSize (const GenericVector< WordFeature > &features, int *max_x, int *max_y)
 
static void Draw (const GenericVector< WordFeature > &features, ScrollView *window)
 

Detailed Description

Definition at line 40 of file imagedata.h.

Constructor & Destructor Documentation

tesseract::WordFeature::WordFeature ( )

Definition at line 31 of file imagedata.cpp.

31  : x_(0), y_(0), dir_(0) {
32 }
tesseract::WordFeature::WordFeature ( const FCOORD fcoord,
uinT8  dir 
)

Definition at line 34 of file imagedata.cpp.

35  : x_(IntCastRounded(fcoord.x())),
36  y_(ClipToRange(IntCastRounded(fcoord.y()), 0, MAX_UINT8)),
37  dir_(dir) {
38 }
float x() const
Definition: points.h:209
int dir() const
Definition: imagedata.h:55
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:115
#define MAX_UINT8
Definition: host.h:121
int IntCastRounded(double x)
Definition: helpers.h:172
float y() const
Definition: points.h:212

Member Function Documentation

void tesseract::WordFeature::ComputeSize ( const GenericVector< WordFeature > &  features,
int *  max_x,
int *  max_y 
)
static

Definition at line 41 of file imagedata.cpp.

42  {
43  *max_x = 0;
44  *max_y = 0;
45  for (int f = 0; f < features.size(); ++f) {
46  if (features[f].x_ > *max_x) *max_x = features[f].x_;
47  if (features[f].y_ > *max_y) *max_y = features[f].y_;
48  }
49 }
int size() const
Definition: genericvector.h:72
bool tesseract::WordFeature::DeSerialize ( bool  swap,
FILE *  fp 
)

Definition at line 77 of file imagedata.cpp.

77  {
78  if (fread(&x_, sizeof(x_), 1, fp) != 1) return false;
79  if (swap) ReverseN(&x_, sizeof(x_));
80  if (fread(&y_, sizeof(y_), 1, fp) != 1) return false;
81  if (fread(&dir_, sizeof(dir_), 1, fp) != 1) return false;
82  return true;
83 }
void ReverseN(void *ptr, int num_bytes)
Definition: helpers.h:177
int tesseract::WordFeature::dir ( ) const
inline

Definition at line 55 of file imagedata.h.

55 { return dir_; }
void tesseract::WordFeature::Draw ( const GenericVector< WordFeature > &  features,
ScrollView window 
)
static

Definition at line 52 of file imagedata.cpp.

53  {
54 #ifndef GRAPHICS_DISABLED
55  for (int f = 0; f < features.size(); ++f) {
56  FCOORD pos(features[f].x_, features[f].y_);
57  FCOORD dir;
58  dir.from_direction(features[f].dir_);
59  dir *= 8.0f;
60  window->SetCursor(IntCastRounded(pos.x() - dir.x()),
61  IntCastRounded(pos.y() - dir.y()));
62  window->DrawTo(IntCastRounded(pos.x() + dir.x()),
63  IntCastRounded(pos.y() + dir.y()));
64  }
65 #endif
66 }
int size() const
Definition: genericvector.h:72
float x() const
Definition: points.h:209
void DrawTo(int x, int y)
Definition: scrollview.cpp:531
int dir() const
Definition: imagedata.h:55
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
void from_direction(uinT8 direction)
Definition: points.cpp:115
int IntCastRounded(double x)
Definition: helpers.h:172
float y() const
Definition: points.h:212
Definition: points.h:189
bool tesseract::WordFeature::Serialize ( FILE *  fp) const

Definition at line 69 of file imagedata.cpp.

69  {
70  if (fwrite(&x_, sizeof(x_), 1, fp) != 1) return false;
71  if (fwrite(&y_, sizeof(y_), 1, fp) != 1) return false;
72  if (fwrite(&dir_, sizeof(dir_), 1, fp) != 1) return false;
73  return true;
74 }
int tesseract::WordFeature::x ( ) const
inline

Definition at line 53 of file imagedata.h.

53 { return x_; }
int tesseract::WordFeature::y ( ) const
inline

Definition at line 54 of file imagedata.h.

54 { return y_; }

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