|
| | ClassPruner (int max_classes) |
| |
| | ~ClassPruner () |
| |
| void | ComputeScores (const INT_TEMPLATES_STRUCT *int_templates, int num_features, const INT_FEATURE_STRUCT *features) |
| |
| void | AdjustForExpectedNumFeatures (const uinT16 *expected_num_features, int cutoff_strength) |
| |
| void | DisableDisabledClasses (const UNICHARSET &unicharset) |
| |
| void | DisableFragments (const UNICHARSET &unicharset) |
| |
| void | NormalizeForXheight (int norm_multiplier, const uinT8 *normalization_factors) |
| |
| void | NoNormalization () |
| |
| void | PruneAndSort (int pruning_factor, bool max_of_non_fragments, const UNICHARSET &unicharset) |
| |
| void | DebugMatch (const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const INT_FEATURE_STRUCT *features) const |
| |
| void | SummarizeResult (const Classify &classify, const INT_TEMPLATES_STRUCT *int_templates, const uinT16 *expected_num_features, int norm_multiplier, const uinT8 *normalization_factors) const |
| |
| int | SetupResults (CP_RESULT_STRUCT *results) const |
| |
Definition at line 109 of file intmatcher.cpp.
| tesseract::ClassPruner::ClassPruner |
( |
int |
max_classes | ) |
|
|
inline |
Definition at line 111 of file intmatcher.cpp.
118 max_classes_ = max_classes;
121 class_count_ =
new int[rounded_classes_];
122 norm_count_ =
new int[rounded_classes_];
123 sort_key_ =
new int[rounded_classes_ + 1];
124 sort_index_ =
new int[rounded_classes_ + 1];
125 for (
int i = 0; i < rounded_classes_; i++) {
128 pruning_threshold_ = 0;
int RoundUp(int n, int block_size)
#define WERDS_PER_CP_VECTOR
#define NUM_BITS_PER_CLASS
| tesseract::ClassPruner::~ClassPruner |
( |
| ) |
|
|
inline |
Definition at line 133 of file intmatcher.cpp.
134 delete []class_count_;
135 delete []norm_count_;
137 delete []sort_index_;
| void tesseract::ClassPruner::AdjustForExpectedNumFeatures |
( |
const uinT16 * |
expected_num_features, |
|
|
int |
cutoff_strength |
|
) |
| |
|
inline |
Definition at line 213 of file intmatcher.cpp.
215 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
216 if (num_features_ < expected_num_features[class_id]) {
217 int deficit = expected_num_features[class_id] - num_features_;
218 class_count_[class_id] -= class_count_[class_id] * deficit /
219 (num_features_ * cutoff_strength + deficit);
Definition at line 142 of file intmatcher.cpp.
144 num_features_ = num_features;
146 for (
int f = 0;
f < num_features; ++
f) {
155 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
158 const uinT32* pruner_word_ptr =
161 uinT32 pruner_word = *pruner_word_ptr++;
#define WERDS_PER_CP_VECTOR
uinT32 p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
#define NUM_BITS_PER_CLASS
#define CLASS_PRUNER_CLASS_MASK
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
Definition at line 300 of file intmatcher.cpp.
304 int max_num_classes = int_templates->
NumClasses;
305 for (
int f = 0;
f < num_features_; ++
f) {
307 tprintf(
"F=%3d(%d,%d,%d),",
f, feature->
X, feature->
Y, feature->
Theta);
313 for (
int pruner_set = 0; pruner_set < num_pruners; ++pruner_set) {
316 const uinT32* pruner_word_ptr =
319 uinT32 pruner_word = *pruner_word_ptr++;
320 for (
int word_class = 0; word_class < 16 &&
321 class_id < max_num_classes; ++word_class, ++class_id) {
322 if (norm_count_[class_id] >= pruning_threshold_) {
324 classify.ClassIDToDebugStr(int_templates,
325 class_id, 0).string(),
#define WERDS_PER_CP_VECTOR
uinT32 p[NUM_CP_BUCKETS][NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]
#define NUM_BITS_PER_CLASS
#define CLASS_PRUNER_CLASS_MASK
DLLSYM void tprintf(const char *format,...)
CLASS_PRUNER_STRUCT * ClassPruners[MAX_NUM_CLASS_PRUNERS]
| void tesseract::ClassPruner::DisableDisabledClasses |
( |
const UNICHARSET & |
unicharset | ) |
|
|
inline |
Definition at line 226 of file intmatcher.cpp.
227 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
229 class_count_[class_id] = 0;
bool get_enabled(UNICHAR_ID unichar_id) const
| void tesseract::ClassPruner::DisableFragments |
( |
const UNICHARSET & |
unicharset | ) |
|
|
inline |
Definition at line 234 of file intmatcher.cpp.
235 for (
int class_id = 0; class_id < max_classes_; ++class_id) {
239 class_count_[class_id] = 0;
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
| void tesseract::ClassPruner::NoNormalization |
( |
| ) |
|
|
inline |
Definition at line 257 of file intmatcher.cpp.
258 for (
int class_id = 0; class_id < max_classes_; class_id++) {
259 norm_count_[class_id] = class_count_[class_id];
| void tesseract::ClassPruner::NormalizeForXheight |
( |
int |
norm_multiplier, |
|
|
const uinT8 * |
normalization_factors |
|
) |
| |
|
inline |
Definition at line 248 of file intmatcher.cpp.
250 for (
int class_id = 0; class_id < max_classes_; class_id++) {
251 norm_count_[class_id] = class_count_[class_id] -
252 ((norm_multiplier * normalization_factors[class_id]) >> 8);
| void tesseract::ClassPruner::PruneAndSort |
( |
int |
pruning_factor, |
|
|
bool |
max_of_non_fragments, |
|
|
const UNICHARSET & |
unicharset |
|
) |
| |
|
inline |
Definition at line 266 of file intmatcher.cpp.
269 for (
int c = 0; c < max_classes_; ++c) {
270 if (norm_count_[c] > max_count &&
276 (!max_of_non_fragments || !unicharset.
get_fragment(c))) {
277 max_count = norm_count_[c];
281 pruning_threshold_ = (max_count * pruning_factor) >> 8;
283 if (pruning_threshold_ < 1)
284 pruning_threshold_ = 1;
286 for (
int class_id = 0; class_id < max_classes_; class_id++) {
287 if (norm_count_[class_id] >= pruning_threshold_) {
289 sort_index_[num_classes_] = class_id;
290 sort_key_[num_classes_] = norm_count_[class_id];
295 if (num_classes_ > 1)
296 HeapSort(num_classes_, sort_key_, sort_index_);
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
void HeapSort(int n, register int ra[], register int rb[])
Definition at line 360 of file intmatcher.cpp.
361 for (
int c = 0; c < num_classes_; ++c) {
362 results[c].
Class = sort_index_[num_classes_ - c];
363 results[c].
Rating = 1.0 - sort_key_[num_classes_ - c] /
#define CLASS_PRUNER_CLASS_MASK
| void tesseract::ClassPruner::SummarizeResult |
( |
const Classify & |
classify, |
|
|
const INT_TEMPLATES_STRUCT * |
int_templates, |
|
|
const uinT16 * |
expected_num_features, |
|
|
int |
norm_multiplier, |
|
|
const uinT8 * |
normalization_factors |
|
) |
| const |
|
inline |
Definition at line 337 of file intmatcher.cpp.
342 tprintf(
"CP:%d classes, %d features:\n", num_classes_, num_features_);
343 for (
int i = 0; i < num_classes_; ++i) {
344 int class_id = sort_index_[num_classes_ - i];
345 STRING class_string = classify.ClassIDToDebugStr(int_templates,
347 tprintf(
"%s:Initial=%d, E=%d, Xht-adj=%d, N=%d, Rat=%.2f\n",
349 class_count_[class_id],
350 expected_num_features[class_id],
351 (norm_multiplier * normalization_factors[class_id]) >> 8,
352 sort_key_[num_classes_ - i],
353 100.0 - 100.0 * sort_key_[num_classes_ - i] /
const char * string() const
#define CLASS_PRUNER_CLASS_MASK
DLLSYM void tprintf(const char *format,...)
The documentation for this class was generated from the following file:
- /home/abuild/rpmbuild/BUILD/tesseract-ocr-3.02.02/classify/intmatcher.cpp