#include <osdetect.h>
Definition at line 85 of file osdetect.h.
◆ OrientationDetector()
tesseract::OrientationDetector::OrientationDetector |
( |
const std::vector< int > * |
allowed_scripts, |
|
|
OSResults * |
results |
|
) |
| |
Definition at line 364 of file osdetect.cpp.
366 allowed_scripts_ = allowed_scripts;
◆ detect_blob()
bool tesseract::OrientationDetector::detect_blob |
( |
BLOB_CHOICE_LIST * |
scores | ) |
|
Definition at line 371 of file osdetect.cpp.
372 float blob_o_score[4] = {0.0f, 0.0f, 0.0f, 0.0f};
373 float total_blob_o_score = 0.0f;
375 for (
int i = 0; i < 4; ++i) {
376 BLOB_CHOICE_IT choice_it(scores + i);
377 if (!choice_it.empty()) {
378 BLOB_CHOICE *choice =
nullptr;
379 if (allowed_scripts_ !=
nullptr && !allowed_scripts_->empty()) {
381 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list() && choice ==
nullptr;
382 choice_it.forward()) {
383 int choice_script = choice_it.data()->script_id();
385 for (s = 0; s < allowed_scripts_->size(); ++s) {
386 if ((*allowed_scripts_)[s] == choice_script) {
387 choice = choice_it.data();
393 choice = choice_it.data();
395 if (choice !=
nullptr) {
398 blob_o_score[i] = 1 + 0.05 * choice->certainty();
399 total_blob_o_score += blob_o_score[i];
403 if (total_blob_o_score == 0.0) {
408 float worst_score = 0.0f;
409 int num_good_scores = 0;
410 for (
float f : blob_o_score) {
413 if (worst_score == 0.0f || f < worst_score) {
418 if (num_good_scores == 1) {
422 for (
float &f : blob_o_score) {
425 total_blob_o_score += worst_score;
430 for (
int i = 0; total_blob_o_score != 0 && i < 4; ++i) {
431 osr_->
orientations[i] += std::log(blob_o_score[i] / total_blob_o_score);
◆ get_orientation()
int tesseract::OrientationDetector::get_orientation |
( |
| ) |
|
Definition at line 439 of file osdetect.cpp.
void update_best_orientation()
The documentation for this class was generated from the following files: