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
void AdaptiveClassifier(TBLOB *Blob, const DENORM &denorm, BLOB_CHOICE_LIST *Choices, CLASS_PRUNER_RESULTS cp_results)
Definition: adaptmatch.cpp:178
void Load()
Definition: dict.cpp:219
BLOB_CHOICE_LIST_VECTOR * cc_recog(WERD_RES *word)
Definition: tface.cpp:117
BlobMatchTable blob_match_table
Definition: wordrec.h:501
#define NULL
Definition: host.h:144
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
Definition: featdefs.cpp:121
void SetupExtractors(FEATURE_DEFS_STRUCT *FeatureDefs)
Definition: fxdefs.cpp:42
void program_editup(const char *textbase, bool init_classifier, bool init_permute)
Definition: tface.cpp:50
int inT32
Definition: host.h:102
double chop_ok_split
Definition: wordrec.h:121
void InitAdaptiveClassifier(bool load_pre_trained_templates)
Definition: adaptmatch.cpp:545
void InitChoiceAccum()
Definition: stopper.cpp:435
void set_pass2()
Definition: tface.cpp:105
void EndAdaptiveClassifier()
Definition: adaptmatch.cpp:476
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:122
Dict & getDict()
Definition: classify.h:62
WERD * word
Definition: pageres.h:334
BLOB_CHOICE_LIST_VECTOR * chop_word_main(WERD_RES *word)
Definition: chopper.cpp:583
int wordrec_num_seg_states
Definition: wordrec.h:102
BLOB_CHOICE_LIST * call_matcher(const DENORM *denorm, TBLOB *blob)
Definition: tface.cpp:143
Definition: blobs.h:174
int dict_word(const WERD_CHOICE &word)
Definition: tface.cpp:133
int valid_word(const WERD_CHOICE &word, bool numbers_ok) const
Definition: dict.cpp:807
void reset_hyphen_vars(bool last_word_on_line)
Definition: hyphen.cpp:32
void program_editdown(inT32 elasped_time)
Definition: tface.cpp:80
void set_pass1()
Definition: tface.cpp:93
STRING imagefile
Definition: ccutil.h:74
PRIORITY pass2_ok_split
Definition: wordrec.h:496
void End()
Definition: dict.cpp:335
void DebugWordChoices()
Prints the current choices for this word to stdout.
Definition: stopper.cpp:330
TBLOB * ClassifyNormalizeIfNeeded(const DENORM **denorm) const
Definition: blobs.cpp:281
Definition: werd.h:36
FEATURE_DEFS_STRUCT feature_defs_
Definition: classify.h:459