~ubuntu-branches/ubuntu/vivid/tesseract/vivid

« back to all changes in this revision

Viewing changes to wordrec/tface.cpp

  • Committer: Package Import Robot
  • Author(s): Jeff Breidenbach
  • Date: 2014-02-03 11:10:20 UTC
  • mfrom: (1.3.1) (19.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140203111020-igquodd7pjlp3uri
Tags: 3.03.01-1
* New upstream release, includes critical fix to PDF rendering
* Complete leptonlib transition (see bug #735509)
* Promote from experimental to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *
18
18
 **********************************************************************/
19
19
 
20
 
#include "bestfirst.h"
21
20
#include "callcpp.h"
22
21
#include "chop.h"
23
22
#include "chopper.h"
25
24
#include "fxdefs.h"
26
25
#include "globals.h"
27
26
#include "gradechop.h"
28
 
#include "matchtab.h"
29
27
#include "pageres.h"
30
 
#include "permute.h"
31
 
#include "wordclass.h"
32
28
#include "wordrec.h"
33
29
#include "featdefs.h"
 
30
#include "params_model.h"
34
31
 
35
32
#include <math.h>
36
33
#ifdef __UNIX__
54
51
  InitFeatureDefs(&feature_defs_);
55
52
  SetupExtractors(&feature_defs_);
56
53
  InitAdaptiveClassifier(init_classifier);
57
 
  if (init_dict) getDict().Load();
 
54
  if (init_dict) getDict().Load(Dict::GlobalDawgCache());
58
55
  pass2_ok_split = chop_ok_split;
59
 
  pass2_seg_states = wordrec_num_seg_states;
60
56
}
61
57
 
62
58
/**
79
75
 */
80
76
void Wordrec::program_editdown(inT32 elasped_time) {
81
77
  EndAdaptiveClassifier();
82
 
  blob_match_table.end_match_table();
83
 
  getDict().InitChoiceAccum();
84
78
  getDict().End();
85
79
}
86
80
 
92
86
 */
93
87
void Wordrec::set_pass1() {
94
88
  chop_ok_split.set_value(70.0);
95
 
  wordrec_num_seg_states.set_value(15);
 
89
  language_model_->getParamsModel().SetPass(ParamsModel::PTRAIN_PASS1);
96
90
  SettupPass1();
97
91
}
98
92
 
104
98
 */
105
99
void Wordrec::set_pass2() {
106
100
  chop_ok_split.set_value(pass2_ok_split);
107
 
  wordrec_num_seg_states.set_value(pass2_seg_states);
 
101
  language_model_->getParamsModel().SetPass(ParamsModel::PTRAIN_PASS2);
108
102
  SettupPass2();
109
103
}
110
104
 
114
108
 *
115
109
 * Recognize a word.
116
110
 */
117
 
BLOB_CHOICE_LIST_VECTOR *Wordrec::cc_recog(WERD_RES *word) {
118
 
  getDict().InitChoiceAccum();
 
111
void Wordrec::cc_recog(WERD_RES *word) {
119
112
  getDict().reset_hyphen_vars(word->word->flag(W_EOL));
120
 
  blob_match_table.init_match_table();
121
 
  BLOB_CHOICE_LIST_VECTOR *results = chop_word_main(word);
122
 
  getDict().DebugWordChoices();
123
 
  return results;
 
113
  chop_word_main(word);
 
114
  word->DebugWordChoices(getDict().stopper_debug_level >= 1,
 
115
                         getDict().word_to_debug.string());
 
116
  ASSERT_HOST(word->StatesAllValid());
124
117
}
125
118
 
126
119
 
140
133
 * Called from Tess with a blob in tess form.
141
134
 * The blob may need rotating to the correct orientation for classification.
142
135
 */
143
 
BLOB_CHOICE_LIST *Wordrec::call_matcher(const DENORM* denorm, TBLOB *tessblob) {
 
136
BLOB_CHOICE_LIST *Wordrec::call_matcher(TBLOB *tessblob) {
144
137
  // Rotate the blob for classification if necessary.
145
 
  TBLOB* rotated_blob = tessblob->ClassifyNormalizeIfNeeded(&denorm);
 
138
  TBLOB* rotated_blob = tessblob->ClassifyNormalizeIfNeeded();
146
139
  if (rotated_blob == NULL) {
147
140
    rotated_blob = tessblob;
148
141
  }
149
142
  BLOB_CHOICE_LIST *ratings = new BLOB_CHOICE_LIST();  // matcher result
150
 
  AdaptiveClassifier(rotated_blob, *denorm, ratings, NULL);
 
143
  AdaptiveClassifier(rotated_blob, ratings);
151
144
  if (rotated_blob != tessblob) {
152
145
    delete rotated_blob;
153
 
    delete denorm;
154
146
  }
155
147
  return ratings;
156
148
}