#include <osdetect.h>
Definition at line 82 of file osdetect.h.
OrientationDetector::OrientationDetector |
( |
const GenericVector< int > * |
allowed_scripts, |
|
|
OSResults * |
results |
|
) |
| |
Definition at line 369 of file osdetect.cpp.
372 allowed_scripts_ = allowed_scripts;
bool OrientationDetector::detect_blob |
( |
BLOB_CHOICE_LIST * |
scores | ) |
|
Definition at line 377 of file osdetect.cpp.
378 float blob_o_score[4] = {0.0f, 0.0f, 0.0f, 0.0f};
379 float total_blob_o_score = 0.0f;
381 for (
int i = 0; i < 4; ++i) {
382 BLOB_CHOICE_IT choice_it(scores + i);
383 if (!choice_it.empty()) {
385 if (allowed_scripts_ !=
NULL && !allowed_scripts_->
empty()) {
387 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list() &&
388 choice ==
NULL; choice_it.forward()) {
389 int choice_script = choice_it.data()->script_id();
391 for (s = 0; s < allowed_scripts_->
size(); ++s) {
392 if ((*allowed_scripts_)[s] == choice_script) {
393 choice = choice_it.data();
399 choice = choice_it.data();
401 if (choice !=
NULL) {
404 blob_o_score[i] = 1 + 0.05 * choice->
certainty();
405 total_blob_o_score += blob_o_score[i];
409 if (total_blob_o_score == 0.0)
return false;
412 float worst_score = 0.0f;
413 int num_good_scores = 0;
414 for (
int i = 0; i < 4; ++i) {
415 if (blob_o_score[i] > 0.0f) {
417 if (worst_score == 0.0f || blob_o_score[i] < worst_score)
418 worst_score = blob_o_score[i];
421 if (num_good_scores == 1) {
425 for (
int i = 0; i < 4; ++i) {
426 if (blob_o_score[i] == 0.0f) {
427 blob_o_score[i] = worst_score;
428 total_blob_o_score += worst_score;
433 for (
int i = 0; total_blob_o_score != 0 && i < 4; ++i) {
434 osr_->
orientations[i] += log(blob_o_score[i] / total_blob_o_score);
int OrientationDetector::get_orientation |
( |
| ) |
|
Definition at line 442 of file osdetect.cpp.
void update_best_orientation()
The documentation for this class was generated from the following files: