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