tesseract  3.04.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 35 of file imagedata.cpp.

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

Definition at line 38 of file imagedata.cpp.

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

Member Function Documentation

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

Definition at line 45 of file imagedata.cpp.

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

Definition at line 81 of file imagedata.cpp.

81  {
82  if (fread(&x_, sizeof(x_), 1, fp) != 1) return false;
83  if (swap) ReverseN(&x_, sizeof(x_));
84  if (fread(&y_, sizeof(y_), 1, fp) != 1) return false;
85  if (fread(&dir_, sizeof(dir_), 1, fp) != 1) return false;
86  return true;
87 }
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 56 of file imagedata.cpp.

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

Definition at line 73 of file imagedata.cpp.

73  {
74  if (fwrite(&x_, sizeof(x_), 1, fp) != 1) return false;
75  if (fwrite(&y_, sizeof(y_), 1, fp) != 1) return false;
76  if (fwrite(&dir_, sizeof(dir_), 1, fp) != 1) return false;
77  return true;
78 }
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: