All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tface.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * File: tface.c (Formerly tface.c)
3  * Description: C side of the Tess/tessedit C/C++ interface.
4  * Author: Ray Smith
5  * Created: Mon Apr 27 11:57:06 BST 1992
6  *
7  * (C) Copyright 1992, Hewlett-Packard Ltd.
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 #include "callcpp.h"
21 #include "chop.h"
22 #include "chopper.h"
23 #include "danerror.h"
24 #include "globals.h"
25 #include "gradechop.h"
26 #include "pageres.h"
27 #include "wordrec.h"
28 #include "featdefs.h"
29 #include "params_model.h"
30 
31 #include <math.h>
32 #ifdef __UNIX__
33 #include <unistd.h>
34 #endif
35 
36 
37 namespace tesseract {
38 
46 void Wordrec::program_editup(const char *textbase,
47  bool init_classifier,
48  bool init_dict) {
49  if (textbase != NULL) imagefile = textbase;
51  InitAdaptiveClassifier(init_classifier);
52  if (init_dict) getDict().Load(Dict::GlobalDawgCache());
54 }
55 
62  program_editdown (0);
63 
64  return (0);
65 }
66 
67 
74 void Wordrec::program_editdown(inT32 elasped_time) {
76  getDict().End();
77 }
78 
79 
86  chop_ok_split.set_value(70.0);
88  SettupPass1();
89 }
90 
91 
98  chop_ok_split.set_value(pass2_ok_split);
100  SettupPass2();
101 }
102 
103 
111  chop_word_main(word);
112  word->DebugWordChoices(getDict().stopper_debug_level >= 1,
113  getDict().word_to_debug.string());
114  ASSERT_HOST(word->StatesAllValid());
115 }
116 
117 
124 int Wordrec::dict_word(const WERD_CHOICE &word) {
125  return getDict().valid_word(word);
126 }
127 
134 BLOB_CHOICE_LIST *Wordrec::call_matcher(TBLOB *tessblob) {
135  // Rotate the blob for classification if necessary.
136  TBLOB* rotated_blob = tessblob->ClassifyNormalizeIfNeeded();
137  if (rotated_blob == NULL) {
138  rotated_blob = tessblob;
139  }
140  BLOB_CHOICE_LIST *ratings = new BLOB_CHOICE_LIST(); // matcher result
141  AdaptiveClassifier(rotated_blob, ratings);
142  if (rotated_blob != tessblob) {
143  delete rotated_blob;
144  }
145  return ratings;
146 }
147 
148 
149 } // namespace tesseract
bool StatesAllValid()
Definition: pageres.cpp:449
Definition: blobs.h:261
void DebugWordChoices(bool debug, const char *word_to_debug)
Definition: pageres.cpp:471
void set_pass1()
Definition: tface.cpp:85
void chop_word_main(WERD_RES *word)
Definition: chopper.cpp:394
void program_editdown(inT32 elasped_time)
Definition: tface.cpp:74
double chop_ok_split
Definition: wordrec.h:156
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
Definition: featdefs.cpp:121
int valid_word(const WERD_CHOICE &word, bool numbers_ok) const
Definition: dict.cpp:705
void reset_hyphen_vars(bool last_word_on_line)
Definition: hyphen.cpp:32
STRING imagefile
Definition: ccutil.h:74
int dict_word(const WERD_CHOICE &word)
Definition: tface.cpp:124
#define ASSERT_HOST(x)
Definition: errcode.h:84
void End()
Definition: dict.cpp:310
static DawgCache * GlobalDawgCache()
Definition: dict.cpp:186
Definition: werd.h:36
LanguageModel * language_model_
Definition: wordrec.h:411
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices)
Definition: adaptmatch.cpp:185
PRIORITY pass2_ok_split
Definition: wordrec.h:412
Dict & getDict()
Definition: classify.h:65
TBLOB * ClassifyNormalizeIfNeeded() const
Definition: blobs.cpp:363
WERD * word
Definition: pageres.h:175
void cc_recog(WERD_RES *word)
Definition: tface.cpp:109
FEATURE_DEFS_STRUCT feature_defs_
Definition: classify.h:507
void Load(DawgCache *dawg_cache)
Definition: dict.cpp:194
void program_editup(const char *textbase, bool init_classifier, bool init_permute)
Definition: tface.cpp:46
ParamsModel & getParamsModel()
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:128
BLOB_CHOICE_LIST * call_matcher(TBLOB *blob)
Definition: tface.cpp:134
void EndAdaptiveClassifier()
Definition: adaptmatch.cpp:456
void SetPass(PassEnum pass)
Definition: params_model.h:72
#define NULL
Definition: host.h:144
void InitAdaptiveClassifier(bool load_pre_trained_templates)
Definition: adaptmatch.cpp:527
void set_pass2()
Definition: tface.cpp:97
int inT32
Definition: host.h:102