tesseract v5.3.3.20231005
wordclass.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * File: wordclass.cpp (Formerly wordclass.c)
4 * Description: Word classifier
5 * Author: Mark Seaman, OCR Technology
6 *
7 * (c) Copyright 1990, Hewlett-Packard Company.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 *
18 *****************************************************************************/
19/*----------------------------------------------------------------------
20 I N C L U D E S
21----------------------------------------------------------------------*/
22
23#include "blamer.h" // for blamer_bundle
24#include "params.h" // for BoolParam
25#include "render.h" // for display_blob, blob_window, wordrec_blob_pause
26#include "wordrec.h" // for Wordrec
27
28struct TBLOB;
29
30// Include automatically generated configuration file if running autoconf.
31#ifdef HAVE_CONFIG_H
32# include "config_auto.h"
33#endif
34
35/*----------------------------------------------------------------------
36 F u n c t i o n s
37----------------------------------------------------------------------*/
38namespace tesseract {
50BLOB_CHOICE_LIST *Wordrec::classify_blob(TBLOB *blob, const char *string, ScrollView::Color color,
51 BlamerBundle *blamer_bundle) {
52#ifndef GRAPHICS_DISABLED
54 display_blob(blob, color);
55 }
56#endif
57 // TODO(rays) collapse with call_matcher and move all to wordrec.cpp.
58 BLOB_CHOICE_LIST *choices = call_matcher(blob);
59 // If a blob with the same bounding box as one of the truth character
60 // bounding boxes is not classified as the corresponding truth character
61 // blame character classifier for incorrect answer.
62 if (blamer_bundle != nullptr) {
63 blamer_bundle->BlameClassifier(getDict().getUnicharset(), blob->bounding_box(), *choices,
64 wordrec_debug_blamer);
65 }
66#ifndef GRAPHICS_DISABLED
67 if (classify_debug_level && string) {
68 print_ratings_list(string, choices, getDict().getUnicharset());
69 }
70
73 }
74#endif
75
76 return choices;
77}
78
79} // namespace tesseract
ScrollView * blob_window
Definition: render.cpp:36
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET &current_unicharset)
Definition: ratngs.cpp:804
bool wordrec_display_all_blobs
Definition: render.cpp:41
bool wordrec_blob_pause
Definition: render.cpp:43
void display_blob(TBLOB *blob, ScrollView::Color color)
Definition: render.cpp:54
void BlameClassifier(const UNICHARSET &unicharset, const TBOX &blob_box, const BLOB_CHOICE_LIST &choices, bool debug)
Definition: blamer.cpp:260
TBOX bounding_box() const
Definition: blobs.cpp:466
virtual Dict & getDict()
Definition: classify.h:98
BLOB_CHOICE_LIST * call_matcher(TBLOB *blob)
Definition: tface.cpp:132
BLOB_CHOICE_LIST * classify_blob(TBLOB *blob, const char *string, ScrollView::Color color, BlamerBundle *blamer_bundle)
Definition: wordclass.cpp:50