Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OSResults Struct Reference

#include <osdetect.h>

List of all members.

Public Member Functions

 OSResults ()
void update_best_orientation ()
void set_best_orientation (int orientation_id)
void update_best_script (int orientation_id)
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.

for (int i = 0; i < 4; ++i) {
for (int j = 0; j < kMaxNumberOfScripts; ++j)
scripts_na[i][j] = 0;
orientations[i] = 0;
}
}

Member Function Documentation

void OSResults::accumulate ( const OSResults osr)

Definition at line 149 of file osdetect.cpp.

{
for (int i = 0; i < 4; ++i) {
orientations[i] += osr.orientations[i];
for (int j = 0; j < kMaxNumberOfScripts; ++j)
scripts_na[i][j] += osr.scripts_na[i][j];
}
}
int OSResults::get_best_script ( int  orientation_id) const

Definition at line 117 of file osdetect.cpp.

{
int max_id = -1;
for (int j = 0; j < kMaxNumberOfScripts; ++j) {
const char *script = unicharset->get_script_from_script_id(j);
if (strcmp(script, "Common") && strcmp(script, "NULL")) {
if (max_id == -1 ||
scripts_na[orientation_id][j] > scripts_na[orientation_id][max_id])
max_id = j;
}
}
return max_id;
}
void OSResults::print_scores ( void  ) const

Definition at line 131 of file osdetect.cpp.

{
for (int i = 0; i < 4; ++i) {
printf("Orientation id #%d", i);
}
}
void OSResults::print_scores ( int  orientation_id) const

Definition at line 139 of file osdetect.cpp.

{
for (int j = 0; j < kMaxNumberOfScripts; ++j) {
if (scripts_na[orientation_id][j]) {
printf("%12s\t: %f\n", unicharset->get_script_from_script_id(j),
scripts_na[orientation_id][j]);
}
}
}
void OSResults::set_best_orientation ( int  orientation_id)

Definition at line 89 of file osdetect.cpp.

{
best_result.orientation_id = orientation_id;
}
void OSResults::update_best_orientation ( )

Definition at line 67 of file osdetect.cpp.

{
float first = orientations[0];
float second = orientations[1];
if (orientations[0] < orientations[1]) {
first = orientations[1];
second = orientations[0];
}
for (int i = 2; i < 4; ++i) {
if (orientations[i] > first) {
second = first;
first = orientations[i];
} else if (orientations[i] > second) {
second = orientations[i];
}
}
// Store difference of top two orientation scores.
best_result.oconfidence = first - second;
}
void OSResults::update_best_script ( int  orientation_id)

Definition at line 94 of file osdetect.cpp.

{
// We skip index 0 to ignore the "Common" script.
float first = scripts_na[orientation][1];
float second = scripts_na[orientation][2];
if (scripts_na[orientation][1] < scripts_na[orientation][2]) {
first = scripts_na[orientation][2];
second = scripts_na[orientation][1];
}
for (int i = 3; i < kMaxNumberOfScripts; ++i) {
if (scripts_na[orientation][i] > first) {
second = first;
first = scripts_na[orientation][i];
} else if (scripts_na[orientation][i] > second) {
second = scripts_na[orientation][i];
}
}
(first / second - 1.0) / (kScriptAcceptRatio - 1.0);
}

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: