#include <cube_object.h>
Definition at line 90 of file cube_object.h.
tesseract::CubeObject::CubeObject |
( |
CubeRecoContext * |
cntxt, |
|
|
Pix * |
pix, |
|
|
int |
left, |
|
|
int |
top, |
|
|
int |
wid, |
|
|
int |
hgt |
|
) |
| |
Definition at line 32 of file cube_object.cpp.
36 own_char_samp_ =
true;
static CharSamp * CharSampleFromPix(Pix *pix, int left, int top, int wid, int hgt)
tesseract::CubeObject::~CubeObject |
( |
| ) |
|
Definition at line 68 of file cube_object.cpp.
69 if (char_samp_ !=
NULL && own_char_samp_ ==
true) {
74 if (srch_obj_ !=
NULL) {
79 if (deslanted_srch_obj_ !=
NULL) {
80 delete deslanted_srch_obj_;
81 deslanted_srch_obj_ =
NULL;
84 if (beam_obj_ !=
NULL) {
89 if (deslanted_beam_obj_ !=
NULL) {
90 delete deslanted_beam_obj_;
91 deslanted_beam_obj_ =
NULL;
94 if (deslanted_char_samp_ !=
NULL) {
95 delete deslanted_char_samp_;
96 deslanted_char_samp_ =
NULL;
WordAltList* tesseract::CubeObject::AlternateList |
( |
| ) |
const |
|
inline |
Definition at line 119 of file cube_object.h.
120 return (deslanted_ ==
true ? deslanted_alt_list_ : alt_list_);
BeamSearch* tesseract::CubeObject::BeamObj |
( |
| ) |
const |
|
inline |
Definition at line 114 of file cube_object.h.
115 return (deslanted_ ==
true ? deslanted_beam_obj_ : beam_obj_);
CharSamp* tesseract::CubeObject::CharSample |
( |
| ) |
const |
|
inline |
Definition at line 130 of file cube_object.h.
131 return (deslanted_ ==
true ? deslanted_char_samp_ : char_samp_);
bool tesseract::CubeObject::Normalize |
( |
| ) |
|
|
protected |
Definition at line 256 of file cube_object.cpp.
258 CubeSearchObject *srch_obj =
new CubeSearchObject(cntxt_, char_samp_);
259 if (srch_obj ==
NULL) {
263 int seg_cnt = srch_obj->SegPtCnt();
265 if (seg_cnt < kMinNormalizationSegmentCnt) {
270 double ar_mean = 0.0;
271 for (
int seg_idx = 0; seg_idx <= seg_cnt; seg_idx++) {
272 CharSamp *seg_samp = srch_obj->CharSample(seg_idx - 1, seg_idx);
273 if (seg_samp !=
NULL && seg_samp->Width() > 0) {
274 ar_mean += (1.0 * seg_samp->Height() / seg_samp->Width());
277 ar_mean /= (seg_cnt + 1);
279 if (ar_mean > kMinNormalizationAspectRatio) {
281 CharSamp *new_samp = char_samp_->
Scale(char_samp_->
Width(),
282 2.0 * char_samp_->
Height() / ar_mean,
284 if (new_samp !=
NULL) {
286 if (own_char_samp_) {
290 char_samp_ = new_samp;
291 own_char_samp_ =
true;
unsigned short Width() const
CharSamp * Scale(int wid, int hgt, bool isotropic=true)
unsigned short Height() const
Definition at line 246 of file cube_object.cpp.
247 if (char_samp_ ==
NULL)
return NULL;
248 CharAltList* alt_list =
NULL;
249 CharClassifier *char_classifier = cntxt_->
Classifier();
251 alt_list = char_classifier->Classify(char_samp_);
CharClassifier * Classifier() const
Recognize the member char sample as a phrase
Definition at line 212 of file cube_object.cpp.
213 return Recognize(lang_mod,
false);
Recognize the member char sample as a word
Definition at line 205 of file cube_object.cpp.
206 return Recognize(lang_mod,
true);
void tesseract::CubeObject::SetCharSampOwnership |
( |
bool |
own_char_samp | ) |
|
|
inline |
Definition at line 135 of file cube_object.h.
136 own_char_samp_ = own_char_samp;
Definition at line 124 of file cube_object.h.
125 return (deslanted_ ==
true ? deslanted_srch_obj_ : srch_obj_);
int tesseract::CubeObject::WordCost |
( |
const char * |
str | ) |
|
Computes the cost of a specific string. This is done by performing recognition of a language model that allows only the specified word
Definition at line 220 of file cube_object.cpp.
221 WordListLangModel *lang_mod =
new WordListLangModel(cntxt_);
222 if (lang_mod ==
NULL) {
226 if (lang_mod->AddString(str) ==
false) {
236 if (alt_list !=
NULL) {
237 if (alt_list->AltCount() > 0) {
238 cost = alt_list->AltCost(0);
WordAltList * RecognizeWord(LangModel *lang_mod=NULL)
The documentation for this class was generated from the following files: