tesseract  4.0.0-1-g2a2b
tesseract::WordFeature Class Reference

#include <imagedata.h>

Public Member Functions

 WordFeature ()
 
 WordFeature (const FCOORD &fcoord, uint8_t 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 57 of file imagedata.h.

Constructor & Destructor Documentation

◆ WordFeature() [1/2]

tesseract::WordFeature::WordFeature ( )

Definition at line 48 of file imagedata.cpp.

48  : x_(0), y_(0), dir_(0) {
49 }

◆ WordFeature() [2/2]

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

Definition at line 51 of file imagedata.cpp.

52  : x_(IntCastRounded(fcoord.x())),
53  y_(ClipToRange<int>(IntCastRounded(fcoord.y()), 0, UINT8_MAX)),
54  dir_(dir) {
55 }
int IntCastRounded(double x)
Definition: helpers.h:168
float x() const
Definition: points.h:208
float y() const
Definition: points.h:211

Member Function Documentation

◆ ComputeSize()

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

Definition at line 58 of file imagedata.cpp.

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

◆ DeSerialize()

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

Definition at line 93 of file imagedata.cpp.

93  {
94  if (!tesseract::DeSerialize(fp, &x_)) return false;
95  if (swap) ReverseN(&x_, sizeof(x_));
96  return tesseract::DeSerialize(fp, &y_) &&
97  tesseract::DeSerialize(fp, &dir_);
98 }
void ReverseN(void *ptr, int num_bytes)
Definition: helpers.h:178
bool DeSerialize(FILE *fp, char *data, size_t n)
Definition: serialis.cpp:27

◆ dir()

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

Definition at line 72 of file imagedata.h.

72 { return dir_; }

◆ Draw()

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

Definition at line 69 of file imagedata.cpp.

70  {
71 #ifndef GRAPHICS_DISABLED
72  for (int f = 0; f < features.size(); ++f) {
73  FCOORD pos(features[f].x_, features[f].y_);
74  FCOORD dir;
75  dir.from_direction(features[f].dir_);
76  dir *= 8.0f;
77  window->SetCursor(IntCastRounded(pos.x() - dir.x()),
78  IntCastRounded(pos.y() - dir.y()));
79  window->DrawTo(IntCastRounded(pos.x() + dir.x()),
80  IntCastRounded(pos.y() + dir.y()));
81  }
82 #endif
83 }
void DrawTo(int x, int y)
Definition: scrollview.cpp:527
int size() const
Definition: genericvector.h:71
void SetCursor(int x, int y)
Definition: scrollview.cpp:521
int IntCastRounded(double x)
Definition: helpers.h:168
Definition: points.h:189

◆ Serialize()

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

Definition at line 86 of file imagedata.cpp.

86  {
87  return tesseract::Serialize(fp, &x_) &&
88  tesseract::Serialize(fp, &y_) &&
89  tesseract::Serialize(fp, &dir_);
90 }
bool Serialize(FILE *fp, const char *data, size_t n)
Definition: serialis.cpp:59

◆ x()

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

Definition at line 70 of file imagedata.h.

70 { return x_; }

◆ y()

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

Definition at line 71 of file imagedata.h.

71 { return y_; }

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