tesseract  4.0.0-1-g2a2b
FPSEGPT Class Reference

#include <pitsync1.h>

Inheritance diagram for FPSEGPT:
ELIST_LINK

Public Member Functions

 FPSEGPT ()=default
 
 FPSEGPT (int16_t x)
 
 FPSEGPT (int16_t x, BOOL8 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 ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Public Attributes

BOOL8 faked
 
BOOL8 terminal
 
int16_t fake_count
 

Detailed Description

Definition at line 32 of file pitsync1.h.

Constructor & Destructor Documentation

◆ FPSEGPT() [1/4]

FPSEGPT::FPSEGPT ( )
default

◆ FPSEGPT() [2/4]

FPSEGPT::FPSEGPT ( int16_t  x)

Definition at line 60 of file pitsync1.cpp.

62  :xpos (x) {
63  pred = nullptr;
64  mean_sum = 0;
65  sq_sum = 0;
66  cost = 0;
67  faked = FALSE;
68  terminal = FALSE;
69  fake_count = 0;
70  mid_cuts = 0;
71 }
int16_t fake_count
Definition: pitsync1.h:70
#define FALSE
Definition: capi.h:52
BOOL8 faked
Definition: pitsync1.h:68
BOOL8 terminal
Definition: pitsync1.h:69

◆ FPSEGPT() [3/4]

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

Definition at line 80 of file pitsync1.cpp.

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

◆ FPSEGPT() [4/4]

FPSEGPT::FPSEGPT ( FPCUTPT cutpt)

Definition at line 39 of file pitsync1.cpp.

41  {
42  pred = nullptr;
43  mean_sum = cutpt->sum ();
44  sq_sum = cutpt->squares ();
45  cost = cutpt->cost_function ();
46  faked = cutpt->faked;
47  terminal = cutpt->terminal;
48  fake_count = cutpt->fake_count;
49  xpos = cutpt->position ();
50  mid_cuts = cutpt->cheap_cuts ();
51 }
int16_t cheap_cuts() const
Definition: pithsync.h:83
int32_t position()
Definition: pithsync.h:68
double squares()
Definition: pithsync.h:74
bool terminal
Definition: pithsync.h:91
int16_t fake_count
Definition: pitsync1.h:70
double cost_function()
Definition: pithsync.h:71
double sum()
Definition: pithsync.h:77
int16_t fake_count
Definition: pithsync.h:92
bool faked
Definition: pithsync.h:90
BOOL8 faked
Definition: pitsync1.h:68
BOOL8 terminal
Definition: pitsync1.h:69

Member Function Documentation

◆ cheap_cuts()

int16_t FPSEGPT::cheap_cuts ( ) const
inline

Definition at line 63 of file pitsync1.h.

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

◆ cost_function()

double FPSEGPT::cost_function ( )
inline

Definition at line 51 of file pitsync1.h.

51  {
52  return cost;
53  }

◆ position()

int32_t FPSEGPT::position ( )
inline

Definition at line 48 of file pitsync1.h.

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

◆ previous()

FPSEGPT* FPSEGPT::previous ( )
inline

Definition at line 60 of file pitsync1.h.

60  {
61  return pred;
62  }

◆ squares()

double FPSEGPT::squares ( )
inline

Definition at line 54 of file pitsync1.h.

54  {
55  return sq_sum;
56  }

◆ sum()

double FPSEGPT::sum ( )
inline

Definition at line 57 of file pitsync1.h.

57  {
58  return mean_sum;
59  }

Member Data Documentation

◆ fake_count

int16_t FPSEGPT::fake_count

Definition at line 70 of file pitsync1.h.

◆ faked

BOOL8 FPSEGPT::faked

Definition at line 68 of file pitsync1.h.

◆ terminal

BOOL8 FPSEGPT::terminal

Definition at line 69 of file pitsync1.h.


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