#include <lm_pain_points.h>
|
| LMPainPoints (int max, float rat, bool fp, const Dict *d, int deb) |
|
| ~LMPainPoints () |
|
bool | HasPainPoints (LMPainPointsType pp_type) const |
|
LMPainPointsType | Deque (MATRIX_COORD *pp, float *priority) |
|
void | Clear () |
|
void | GenerateInitial (WERD_RES *word_res) |
|
void | GenerateFromPath (float rating_cert_scale, ViterbiStateEntry *vse, WERD_RES *word_res) |
|
void | GenerateFromAmbigs (const DANGERR &fixpt, ViterbiStateEntry *vse, WERD_RES *word_res) |
|
bool | GeneratePainPoint (int col, int row, LMPainPointsType pp_type, float special_priority, bool ok_to_extend, float max_char_wh_ratio, WERD_RES *word_res) |
|
void | RemapForSplit (int index) |
|
Definition at line 56 of file lm_pain_points.h.
◆ LMPainPoints()
tesseract::LMPainPoints::LMPainPoints |
( |
int |
max, |
|
|
float |
rat, |
|
|
bool |
fp, |
|
|
const Dict * |
d, |
|
|
int |
deb |
|
) |
| |
|
inline |
Definition at line 69 of file lm_pain_points.h.
70 max_heap_size_(max), max_char_wh_ratio_(rat), fixed_pitch_(fp),
71 dict_(d), debug_level_(deb) {}
◆ ~LMPainPoints()
tesseract::LMPainPoints::~LMPainPoints |
( |
| ) |
|
|
inline |
◆ Clear()
void tesseract::LMPainPoints::Clear |
( |
| ) |
|
|
inline |
Definition at line 85 of file lm_pain_points.h.
86 for (
auto & pain_points_heap : pain_points_heaps_) pain_points_heap.clear();
◆ Deque()
Definition at line 39 of file lm_pain_points.cpp.
41 if (pain_points_heaps_[h].empty())
continue;
42 *priority = pain_points_heaps_[h].
PeekTop().
key;
44 pain_points_heaps_[h].
Pop(
nullptr);
45 return static_cast<LMPainPointsType>(h);
◆ GenerateFromAmbigs()
◆ GenerateFromPath()
Definition at line 70 of file lm_pain_points.cpp.
73 ViterbiStateEntry *curr_vse = vse;
91 while (curr_vse->parent_vse !=
nullptr) {
92 ViterbiStateEntry* parent_vse = curr_vse->parent_vse;
94 const MATRIX_COORD& parent_cell = parent_vse->curr_b->matrix_cell();
96 if (!pain_coord.Valid(*word_res->
ratings) ||
102 float rat_subtr = curr_b->
rating() + parent_vse->curr_b->rating();
107 *(parent_vse->curr_b));
109 float ol_dif = vse->outline_length - ol_subtr;
112 float priority = ol_dif > 0 ? (vse->ratings_sum-rat_subtr)/ol_dif : 0.0;
114 priority,
true, max_char_wh_ratio_, word_res);
115 }
else if (debug_level_ > 3) {
116 tprintf(
"NO pain point (Classified) for col=%d row=%d type=%s\n",
117 pain_coord.col, pain_coord.row,
119 BLOB_CHOICE_IT b_it(word_res->
ratings->
get(pain_coord.col,
121 for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
127 curr_vse = parent_vse;
128 curr_b = curr_vse->curr_b;
◆ GenerateInitial()
void tesseract::LMPainPoints::GenerateInitial |
( |
WERD_RES * |
word_res | ) |
|
Definition at line 50 of file lm_pain_points.cpp.
52 AssociateStats associate_stats;
53 for (
int col = 0; col < ratings->
dimension(); ++col) {
55 for (
int row = col + 1; row < row_end; ++row) {
57 if (coord.Valid(*ratings) &&
64 true, max_char_wh_ratio_, word_res);
◆ GeneratePainPoint()
bool tesseract::LMPainPoints::GeneratePainPoint |
( |
int |
col, |
|
|
int |
row, |
|
|
LMPainPointsType |
pp_type, |
|
|
float |
special_priority, |
|
|
bool |
ok_to_extend, |
|
|
float |
max_char_wh_ratio, |
|
|
WERD_RES * |
word_res |
|
) |
| |
Definition at line 148 of file lm_pain_points.cpp.
153 if (coord.Valid(*word_res->
ratings) &&
157 if (debug_level_ > 3) {
158 tprintf(
"Generating pain point for col=%d row=%d type=%s\n",
159 col, row, LMPainPointsTypeName[pp_type]);
162 AssociateStats associate_stats;
164 max_char_wh_ratio, word_res, debug_level_,
171 while (associate_stats.bad_fixed_pitch_right_gap &&
173 !associate_stats.bad_fixed_pitch_wh_ratio) {
175 max_char_wh_ratio, word_res, debug_level_,
179 if (associate_stats.bad_shape) {
180 if (debug_level_ > 3) {
181 tprintf(
"Discarded pain point with a bad shape\n");
187 if (pain_points_heaps_[pp_type].size() < max_heap_size_) {
191 priority = special_priority;
193 priority = associate_stats.gap_sum;
196 pain_points_heaps_[pp_type].
Push(&pain_point);
198 tprintf(
"Added pain point with priority %g\n", priority);
202 if (debug_level_)
tprintf(
"Pain points heap is full\n");
◆ HasPainPoints()
◆ PainPointDescription()
static const char* tesseract::LMPainPoints::PainPointDescription |
( |
LMPainPointsType |
type | ) |
|
|
inlinestatic |
◆ RemapForSplit()
void tesseract::LMPainPoints::RemapForSplit |
( |
int |
index | ) |
|
Adjusts the pain point coordinates to cope with expansion of the ratings matrix due to a split of the blob with the given index.
Definition at line 211 of file lm_pain_points.cpp.
212 for (
auto & pain_points_heap : pain_points_heaps_) {
214 for (
int j = 0; j < heap->
size(); ++j)
215 (*heap)[j].data.MapForSplit(index);
◆ kDefaultPainPointPriorityAdjustment
const float tesseract::LMPainPoints::kDefaultPainPointPriorityAdjustment = 2.0f |
|
static |
◆ kLooseMaxCharWhRatio
const float tesseract::LMPainPoints::kLooseMaxCharWhRatio = 2.5f |
|
static |
The documentation for this class was generated from the following files: