Tesseract
3.02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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;
54
InitFeatureDefs
(&
feature_defs_
);
55
SetupExtractors
(&
feature_defs_
);
56
InitAdaptiveClassifier
(init_classifier);
57
if
(init_dict)
getDict
().
Load
();
58
pass2_ok_split
=
chop_ok_split
;
59
pass2_seg_states
=
wordrec_num_seg_states
;
60
}
61
67
int
Wordrec::end_recog
() {
68
program_editdown
(0);
69
70
return
(0);
71
}
72
73
80
void
Wordrec::program_editdown
(
inT32
elasped_time) {
81
EndAdaptiveClassifier
();
82
blob_match_table
.
end_match_table
();
83
getDict
().
InitChoiceAccum
();
84
getDict
().
End
();
85
}
86
87
93
void
Wordrec::set_pass1
() {
94
chop_ok_split
.set_value(70.0);
95
wordrec_num_seg_states
.set_value(15);
96
SettupPass1
();
97
}
98
99
105
void
Wordrec::set_pass2
() {
106
chop_ok_split
.set_value(
pass2_ok_split
);
107
wordrec_num_seg_states
.set_value(
pass2_seg_states
);
108
SettupPass2
();
109
}
110
111
117
BLOB_CHOICE_LIST_VECTOR
*
Wordrec::cc_recog
(
WERD_RES
*word) {
118
getDict
().
InitChoiceAccum
();
119
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;
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
mnt
data
src
tesseract-ocr
wordrec
tface.cpp
Generated on Thu Nov 1 2012 20:19:52 for Tesseract by
1.8.1