All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OSResults Struct Reference

#include <osdetect.h>

Public Member Functions

 OSResults ()
 
void update_best_orientation ()
 
void set_best_orientation (int orientation_id)
 
void update_best_script (int orientation_id)
 
TESS_API int get_best_script (int orientation_id) const
 
void accumulate (const OSResults &osr)
 
void print_scores (void) const
 
void print_scores (int orientation_id) const
 

Public Attributes

float orientations [4]
 
float scripts_na [4][kMaxNumberOfScripts]
 
UNICHARSETunicharset
 
OSBestResult best_result
 

Detailed Description

Definition at line 47 of file osdetect.h.

Constructor & Destructor Documentation

OSResults::OSResults ( )
inline

Definition at line 48 of file osdetect.h.

48  : unicharset(NULL) {
49  for (int i = 0; i < 4; ++i) {
50  for (int j = 0; j < kMaxNumberOfScripts; ++j)
51  scripts_na[i][j] = 0;
52  orientations[i] = 0;
53  }
54  }
float scripts_na[4][kMaxNumberOfScripts]
Definition: osdetect.h:76
const int kMaxNumberOfScripts
Definition: osdetect.h:36
float orientations[4]
Definition: osdetect.h:74
UNICHARSET * unicharset
Definition: osdetect.h:78
#define NULL
Definition: host.h:144

Member Function Documentation

void OSResults::accumulate ( const OSResults osr)

Definition at line 149 of file osdetect.cpp.

149  {
150  for (int i = 0; i < 4; ++i) {
151  orientations[i] += osr.orientations[i];
152  for (int j = 0; j < kMaxNumberOfScripts; ++j)
153  scripts_na[i][j] += osr.scripts_na[i][j];
154  }
155  unicharset = osr.unicharset;
158 }
void update_best_orientation()
Definition: osdetect.cpp:67
float scripts_na[4][kMaxNumberOfScripts]
Definition: osdetect.h:76
const int kMaxNumberOfScripts
Definition: osdetect.h:36
float orientations[4]
Definition: osdetect.h:74
int orientation_id
Definition: osdetect.h:41
UNICHARSET * unicharset
Definition: osdetect.h:78
void update_best_script(int orientation_id)
Definition: osdetect.cpp:94
OSBestResult best_result
Definition: osdetect.h:79
int OSResults::get_best_script ( int  orientation_id) const

Definition at line 117 of file osdetect.cpp.

117  {
118  int max_id = -1;
119  for (int j = 0; j < kMaxNumberOfScripts; ++j) {
120  const char *script = unicharset->get_script_from_script_id(j);
121  if (strcmp(script, "Common") && strcmp(script, "NULL")) {
122  if (max_id == -1 ||
123  scripts_na[orientation_id][j] > scripts_na[orientation_id][max_id])
124  max_id = j;
125  }
126  }
127  return max_id;
128 }
float scripts_na[4][kMaxNumberOfScripts]
Definition: osdetect.h:76
const int kMaxNumberOfScripts
Definition: osdetect.h:36
UNICHARSET * unicharset
Definition: osdetect.h:78
const char * get_script_from_script_id(int id) const
Definition: unicharset.h:802
void OSResults::print_scores ( void  ) const

Definition at line 131 of file osdetect.cpp.

131  {
132  for (int i = 0; i < 4; ++i) {
133  tprintf("Orientation id #%d", i);
134  print_scores(i);
135  }
136 }
#define tprintf(...)
Definition: tprintf.h:31
void print_scores(void) const
Definition: osdetect.cpp:131
void OSResults::print_scores ( int  orientation_id) const

Definition at line 139 of file osdetect.cpp.

139  {
140  for (int j = 0; j < kMaxNumberOfScripts; ++j) {
141  if (scripts_na[orientation_id][j]) {
142  tprintf("%12s\t: %f\n", unicharset->get_script_from_script_id(j),
143  scripts_na[orientation_id][j]);
144  }
145  }
146 }
float scripts_na[4][kMaxNumberOfScripts]
Definition: osdetect.h:76
#define tprintf(...)
Definition: tprintf.h:31
const int kMaxNumberOfScripts
Definition: osdetect.h:36
UNICHARSET * unicharset
Definition: osdetect.h:78
const char * get_script_from_script_id(int id) const
Definition: unicharset.h:802
void OSResults::set_best_orientation ( int  orientation_id)

Definition at line 89 of file osdetect.cpp.

89  {
90  best_result.orientation_id = orientation_id;
92 }
int orientation_id
Definition: osdetect.h:41
float oconfidence
Definition: osdetect.h:44
OSBestResult best_result
Definition: osdetect.h:79
void OSResults::update_best_orientation ( )

Definition at line 67 of file osdetect.cpp.

67  {
68  float first = orientations[0];
69  float second = orientations[1];
71  if (orientations[0] < orientations[1]) {
72  first = orientations[1];
73  second = orientations[0];
75  }
76  for (int i = 2; i < 4; ++i) {
77  if (orientations[i] > first) {
78  second = first;
79  first = orientations[i];
81  } else if (orientations[i] > second) {
82  second = orientations[i];
83  }
84  }
85  // Store difference of top two orientation scores.
86  best_result.oconfidence = first - second;
87 }
float orientations[4]
Definition: osdetect.h:74
int orientation_id
Definition: osdetect.h:41
float oconfidence
Definition: osdetect.h:44
OSBestResult best_result
Definition: osdetect.h:79
void OSResults::update_best_script ( int  orientation_id)

Definition at line 94 of file osdetect.cpp.

94  {
95  // We skip index 0 to ignore the "Common" script.
96  float first = scripts_na[orientation][1];
97  float second = scripts_na[orientation][2];
99  if (scripts_na[orientation][1] < scripts_na[orientation][2]) {
100  first = scripts_na[orientation][2];
101  second = scripts_na[orientation][1];
103  }
104  for (int i = 3; i < kMaxNumberOfScripts; ++i) {
105  if (scripts_na[orientation][i] > first) {
107  second = first;
108  first = scripts_na[orientation][i];
109  } else if (scripts_na[orientation][i] > second) {
110  second = scripts_na[orientation][i];
111  }
112  }
114  (first / second - 1.0) / (kScriptAcceptRatio - 1.0);
115 }
int script_id
Definition: osdetect.h:42
float scripts_na[4][kMaxNumberOfScripts]
Definition: osdetect.h:76
const int kMaxNumberOfScripts
Definition: osdetect.h:36
float sconfidence
Definition: osdetect.h:43
const float kScriptAcceptRatio
Definition: osdetect.cpp:43
OSBestResult best_result
Definition: osdetect.h:79

Member Data Documentation

OSBestResult OSResults::best_result

Definition at line 79 of file osdetect.h.

float OSResults::orientations[4]

Definition at line 74 of file osdetect.h.

float OSResults::scripts_na[4][kMaxNumberOfScripts]

Definition at line 76 of file osdetect.h.

UNICHARSET* OSResults::unicharset

Definition at line 78 of file osdetect.h.


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