tesseract v5.3.3.20231005
tesseract::FPSEGPT Class Reference

#include <pitsync1.h>

Inheritance diagram for tesseract::FPSEGPT:
tesseract::ELIST_LINK

Public Member Functions

 FPSEGPT ()=default
 
 FPSEGPT (int16_t x)
 
 FPSEGPT (int16_t x, bool faking, int16_t offset, int16_t region_index, int16_t pitch, int16_t pitch_error, FPSEGPT_LIST *prev_list)
 
 FPSEGPT (FPCUTPT *cutpt)
 
int32_t position ()
 
double cost_function ()
 
double squares ()
 
double sum ()
 
FPSEGPTprevious ()
 
int16_t cheap_cuts () const
 
- Public Member Functions inherited from tesseract::ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Public Attributes

bool faked
 
bool terminal
 
int16_t fake_count
 

Detailed Description

Definition at line 34 of file pitsync1.h.

Constructor & Destructor Documentation

◆ FPSEGPT() [1/4]

tesseract::FPSEGPT::FPSEGPT ( )
default

◆ FPSEGPT() [2/4]

tesseract::FPSEGPT::FPSEGPT ( int16_t  x)

Definition at line 57 of file pitsync1.cpp.

60 : xpos(x) {
61 pred = nullptr;
62 mean_sum = 0;
63 sq_sum = 0;
64 cost = 0;
65 faked = false;
66 terminal = false;
67 fake_count = 0;
68 mid_cuts = 0;
69}
int16_t fake_count
Definition: pitsync1.h:70

◆ FPSEGPT() [3/4]

tesseract::FPSEGPT::FPSEGPT ( int16_t  x,
bool  faking,
int16_t  offset,
int16_t  region_index,
int16_t  pitch,
int16_t  pitch_error,
FPSEGPT_LIST *  prev_list 
)

Definition at line 77 of file pitsync1.cpp.

86 : fake_count(0), xpos(x), mean_sum(0.0), sq_sum(0.0) {
87 int16_t best_fake; // on previous
88 FPSEGPT *segpt; // segment point
89 int32_t dist; // from prev segment
90 double sq_dist; // squared distance
91 double mean; // mean pitch
92 double total; // total dists
93 double factor; // cost function
94 FPSEGPT_IT pred_it = prev_list; // for previuos segment
95
96 cost = FLT_MAX;
97 pred = nullptr;
98 faked = faking;
99 terminal = false;
100 best_fake = INT16_MAX;
101 mid_cuts = 0;
102 for (pred_it.mark_cycle_pt(); !pred_it.cycled_list(); pred_it.forward()) {
103 segpt = pred_it.data();
104 if (segpt->fake_count < best_fake) {
105 best_fake = segpt->fake_count;
106 }
107 dist = x - segpt->xpos;
108 if (dist >= pitch - pitch_error && dist <= pitch + pitch_error && !segpt->terminal) {
109 total = segpt->mean_sum + dist;
110 sq_dist = dist * dist + segpt->sq_sum + offset * offset;
111 // sum of squarees
112 mean = total / region_index;
113 factor = mean - pitch;
114 factor *= factor;
115 factor += sq_dist / (region_index)-mean * mean;
116 if (factor < cost) {
117 cost = factor; // find least cost
118 pred = segpt; // save path
119 mean_sum = total;
120 sq_sum = sq_dist;
121 fake_count = segpt->fake_count + faked;
122 }
123 }
124 }
125 if (fake_count > best_fake + 1) {
126 pred = nullptr; // fail it
127 }
128}

◆ FPSEGPT() [4/4]

tesseract::FPSEGPT::FPSEGPT ( FPCUTPT cutpt)

Definition at line 37 of file pitsync1.cpp.

39 {
40 pred = nullptr;
41 mean_sum = cutpt->sum();
42 sq_sum = cutpt->squares();
43 cost = cutpt->cost_function();
44 faked = cutpt->faked;
45 terminal = cutpt->terminal;
46 fake_count = cutpt->fake_count;
47 xpos = cutpt->position();
48 mid_cuts = cutpt->cheap_cuts();
49}

Member Function Documentation

◆ cheap_cuts()

int16_t tesseract::FPSEGPT::cheap_cuts ( ) const
inline

Definition at line 64 of file pitsync1.h.

64 { // no of cheap cuts
65 return mid_cuts;
66 }

◆ cost_function()

double tesseract::FPSEGPT::cost_function ( )
inline

Definition at line 52 of file pitsync1.h.

52 {
53 return cost;
54 }

◆ position()

int32_t tesseract::FPSEGPT::position ( )
inline

Definition at line 49 of file pitsync1.h.

49 { // access func
50 return xpos;
51 }

◆ previous()

FPSEGPT * tesseract::FPSEGPT::previous ( )
inline

Definition at line 61 of file pitsync1.h.

61 {
62 return pred;
63 }

◆ squares()

double tesseract::FPSEGPT::squares ( )
inline

Definition at line 55 of file pitsync1.h.

55 {
56 return sq_sum;
57 }

◆ sum()

double tesseract::FPSEGPT::sum ( )
inline

Definition at line 58 of file pitsync1.h.

58 {
59 return mean_sum;
60 }

Member Data Documentation

◆ fake_count

int16_t tesseract::FPSEGPT::fake_count

Definition at line 70 of file pitsync1.h.

◆ faked

bool tesseract::FPSEGPT::faked

Definition at line 68 of file pitsync1.h.

◆ terminal

bool tesseract::FPSEGPT::terminal

Definition at line 69 of file pitsync1.h.


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