Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "bestfirst.h"
21 #include "callcpp.h"
22 #include "chop.h"
23 #include "chopper.h"
24 #include "danerror.h"
25 #include "fxdefs.h"
26 #include "globals.h"
27 #include "gradechop.h"
28 #include "matchtab.h"
29 #include "pageres.h"
30 #include "permute.h"
31 #include "wordclass.h"
32 #include "wordrec.h"
33 #include "featdefs.h"
34 
35 #include <math.h>
36 #ifdef __UNIX__
37 #include <unistd.h>
38 #endif
39 
40 
41 namespace tesseract {
42 
50 void Wordrec::program_editup(const char *textbase,
51  bool init_classifier,
52  bool init_dict) {
53  if (textbase != NULL) imagefile = textbase;
56  InitAdaptiveClassifier(init_classifier);
57  if (init_dict) getDict().Load();
60 }
61 
68  program_editdown (0);
69 
70  return (0);
71 }
72 
73 
80 void Wordrec::program_editdown(inT32 elasped_time) {
84  getDict().End();
85 }
86 
87 
94  chop_ok_split.set_value(70.0);
95  wordrec_num_seg_states.set_value(15);
96  SettupPass1();
97 }
98 
99 
106  chop_ok_split.set_value(pass2_ok_split);
108  SettupPass2();
109 }
110 
111 
121  BLOB_CHOICE_LIST_VECTOR *results = chop_word_main(word);
123  return results;
124 }
125 
126 
133 int Wordrec::dict_word(const WERD_CHOICE &word) {
134  return getDict().valid_word(word);
135 }
136 
143 BLOB_CHOICE_LIST *Wordrec::call_matcher(const DENORM* denorm, TBLOB *tessblob) {
144  // Rotate the blob for classification if necessary.
145  TBLOB* rotated_blob = tessblob->ClassifyNormalizeIfNeeded(&denorm);
146  if (rotated_blob == NULL) {
147  rotated_blob = tessblob;
148  }
149  BLOB_CHOICE_LIST *ratings = new BLOB_CHOICE_LIST(); // matcher result
150  AdaptiveClassifier(rotated_blob, *denorm, ratings, NULL);
151  if (rotated_blob != tessblob) {
152  delete rotated_blob;
153  delete denorm;
154  }
155  return ratings;
156 }
157 
158 
159 } // namespace tesseract