tesseract  4.00.00dev
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 55 of file imagedata.h.

Constructor & Destructor Documentation

◆ WordFeature() [1/2]

tesseract::WordFeature::WordFeature ( )

Definition at line 45 of file imagedata.cpp.

45  : x_(0), y_(0), dir_(0) {
46 }

◆ WordFeature() [2/2]

tesseract::WordFeature::WordFeature ( const FCOORD fcoord,
uinT8  dir 
)

Definition at line 48 of file imagedata.cpp.

49  : x_(IntCastRounded(fcoord.x())),
50  y_(ClipToRange(IntCastRounded(fcoord.y()), 0, MAX_UINT8)),
51  dir_(dir) {
52 }
#define MAX_UINT8
Definition: host.h:63
int IntCastRounded(double x)
Definition: helpers.h:179
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:122
float y() const
Definition: points.h:212
float x() const
Definition: points.h:209

Member Function Documentation

◆ ComputeSize()

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

Definition at line 55 of file imagedata.cpp.

56  {
57  *max_x = 0;
58  *max_y = 0;
59  for (int f = 0; f < features.size(); ++f) {
60  if (features[f].x_ > *max_x) *max_x = features[f].x_;
61  if (features[f].y_ > *max_y) *max_y = features[f].y_;
62  }
63 }
int size() const
Definition: genericvector.h:72

◆ DeSerialize()

bool tesseract::WordFeature::DeSerialize ( bool  swap,
FILE *  fp 
)

Definition at line 91 of file imagedata.cpp.

91  {
92  if (fread(&x_, sizeof(x_), 1, fp) != 1) return false;
93  if (swap) ReverseN(&x_, sizeof(x_));
94  if (fread(&y_, sizeof(y_), 1, fp) != 1) return false;
95  if (fread(&dir_, sizeof(dir_), 1, fp) != 1) return false;
96  return true;
97 }
void ReverseN(void *ptr, int num_bytes)
Definition: helpers.h:184

◆ dir()

int tesseract::WordFeature::dir ( ) const
inline

Definition at line 70 of file imagedata.h.

70 { return dir_; }

◆ Draw()

void tesseract::WordFeature::Draw ( const GenericVector< WordFeature > &  features,
ScrollView window 
)
static

Definition at line 66 of file imagedata.cpp.

67  {
68 #ifndef GRAPHICS_DISABLED
69  for (int f = 0; f < features.size(); ++f) {
70  FCOORD pos(features[f].x_, features[f].y_);
71  FCOORD dir;
72  dir.from_direction(features[f].dir_);
73  dir *= 8.0f;
74  window->SetCursor(IntCastRounded(pos.x() - dir.x()),
75  IntCastRounded(pos.y() - dir.y()));
76  window->DrawTo(IntCastRounded(pos.x() + dir.x()),
77  IntCastRounded(pos.y() + dir.y()));
78  }
79 #endif
80 }
Definition: points.h:189
void from_direction(uinT8 direction)
Definition: points.cpp:115
int IntCastRounded(double x)
Definition: helpers.h:179
int size() const
Definition: genericvector.h:72
void SetCursor(int x, int y)
Definition: scrollview.cpp:525
float y() const
Definition: points.h:212
float x() const
Definition: points.h:209
void DrawTo(int x, int y)
Definition: scrollview.cpp:531

◆ Serialize()

bool tesseract::WordFeature::Serialize ( FILE *  fp) const

Definition at line 83 of file imagedata.cpp.

83  {
84  if (fwrite(&x_, sizeof(x_), 1, fp) != 1) return false;
85  if (fwrite(&y_, sizeof(y_), 1, fp) != 1) return false;
86  if (fwrite(&dir_, sizeof(dir_), 1, fp) != 1) return false;
87  return true;
88 }

◆ x()

int tesseract::WordFeature::x ( ) const
inline

Definition at line 68 of file imagedata.h.

68 { return x_; }

◆ y()

int tesseract::WordFeature::y ( ) const
inline

Definition at line 69 of file imagedata.h.

69 { return y_; }

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