Tesseract
3.02
|
#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) |
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] |
UNICHARSET * | unicharset |
OSBestResult | best_result |
Definition at line 47 of file osdetect.h.
OSResults::OSResults | ( | ) | [inline] |
Definition at line 48 of file osdetect.h.
: unicharset(NULL) { for (int i = 0; i < 4; ++i) { for (int j = 0; j < kMaxNumberOfScripts; ++j) scripts_na[i][j] = 0; orientations[i] = 0; } }
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]; } unicharset = osr.unicharset; update_best_orientation(); update_best_script(best_result.orientation_id); }
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); print_scores(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; best_result.oconfidence = 0; }
void OSResults::update_best_orientation | ( | ) |
Definition at line 67 of file osdetect.cpp.
{ float first = orientations[0]; float second = orientations[1]; best_result.orientation_id = 0; if (orientations[0] < orientations[1]) { first = orientations[1]; second = orientations[0]; best_result.orientation_id = 1; } for (int i = 2; i < 4; ++i) { if (orientations[i] > first) { second = first; first = orientations[i]; best_result.orientation_id = 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]; best_result.script_id = 1; if (scripts_na[orientation][1] < scripts_na[orientation][2]) { first = scripts_na[orientation][2]; second = scripts_na[orientation][1]; best_result.script_id = 2; } for (int i = 3; i < kMaxNumberOfScripts; ++i) { if (scripts_na[orientation][i] > first) { best_result.script_id = i; second = first; first = scripts_na[orientation][i]; } else if (scripts_na[orientation][i] > second) { second = scripts_na[orientation][i]; } } best_result.sconfidence = (first / second - 1.0) / (kScriptAcceptRatio - 1.0); }
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.
Definition at line 78 of file osdetect.h.