tesseract  5.0.0-alpha-619-ge9db
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 56 of file imagedata.h.

Constructor & Destructor Documentation

◆ WordFeature() [1/2]

tesseract::WordFeature::WordFeature ( )

Definition at line 44 of file imagedata.cpp.

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

◆ WordFeature() [2/2]

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

Definition at line 47 of file imagedata.cpp.

48  : x_(IntCastRounded(fcoord.x())),
49  y_(ClipToRange<int>(IntCastRounded(fcoord.y()), 0, UINT8_MAX)),
50  dir_(dir) {
51 }

Member Function Documentation

◆ ComputeSize()

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

Definition at line 54 of file imagedata.cpp.

55  {
56  *max_x = 0;
57  *max_y = 0;
58  for (int f = 0; f < features.size(); ++f) {
59  if (features[f].x_ > *max_x) *max_x = features[f].x_;
60  if (features[f].y_ > *max_y) *max_y = features[f].y_;
61  }
62 }

◆ DeSerialize()

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

Definition at line 89 of file imagedata.cpp.

89  {
90  if (!tesseract::DeSerialize(fp, &x_)) return false;
91  if (swap) ReverseN(&x_, sizeof(x_));
92  return tesseract::DeSerialize(fp, &y_) &&
93  tesseract::DeSerialize(fp, &dir_);
94 }

◆ dir()

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

Definition at line 71 of file imagedata.h.

71 { return dir_; }

◆ Draw()

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

Definition at line 65 of file imagedata.cpp.

66  {
67 #ifndef GRAPHICS_DISABLED
68  for (int f = 0; f < features.size(); ++f) {
69  FCOORD pos(features[f].x_, features[f].y_);
70  FCOORD dir;
71  dir.from_direction(features[f].dir_);
72  dir *= 8.0f;
73  window->SetCursor(IntCastRounded(pos.x() - dir.x()),
74  IntCastRounded(pos.y() - dir.y()));
75  window->DrawTo(IntCastRounded(pos.x() + dir.x()),
76  IntCastRounded(pos.y() + dir.y()));
77  }
78 #endif
79 }

◆ Serialize()

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

Definition at line 82 of file imagedata.cpp.

82  {
83  return tesseract::Serialize(fp, &x_) &&
84  tesseract::Serialize(fp, &y_) &&
85  tesseract::Serialize(fp, &dir_);
86 }

◆ x()

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

Definition at line 69 of file imagedata.h.

69 { return x_; }

◆ y()

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

Definition at line 70 of file imagedata.h.

70 { return y_; }

The documentation for this class was generated from the following files:
FCOORD::y
float y() const
Definition: points.h:209
FCOORD::x
float x() const
Definition: points.h:206
tesseract::WordFeature::dir
int dir() const
Definition: imagedata.h:71
ScrollView::DrawTo
void DrawTo(int x, int y)
Definition: scrollview.cpp:524
IntCastRounded
int IntCastRounded(double x)
Definition: helpers.h:173
FCOORD
Definition: points.h:187
ScrollView::SetCursor
void SetCursor(int x, int y)
Definition: scrollview.cpp:518
ReverseN
void ReverseN(void *ptr, int num_bytes)
Definition: helpers.h:183
tesseract::DeSerialize
bool DeSerialize(FILE *fp, char *data, size_t n=1)
Definition: serialis.cpp:41
GenericVector::size
int size() const
Definition: genericvector.h:71
tesseract::Serialize
bool Serialize(FILE *fp, const char *data, size_t n=1)
Definition: serialis.cpp:73