Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Static Public Member Functions
tesseract::ErrorCounter Class Reference

`#include <errorcounter.h>`

List of all members.

## Classes
struct | Counts

## Static Public Member Functions
static double | ComputeErrorRate (ShapeClassifier *classifier, int report_level, CountTypes boosting_mode, const UnicityTable< FontInfo > &fontinfo_table, const GenericVector< Pix * > &page_images, SampleIterator *it, double *unichar_error, double *scaled_error, STRING *fonts_report)

## Detailed Description

Definition at line 88 of file errorcounter.h.

## Member Function Documentation

double tesseract::ErrorCounter::ComputeErrorRate | ( | ShapeClassifier * | classifier,
|  | int | report_level,
|  | CountTypes | boosting_mode,
|  | const UnicityTable< FontInfo > & | fontinfo_table,
|  | const GenericVector< Pix * > & | page_images,
|  | SampleIterator * | it,
|  | double * | unichar_error,
|  | double * | scaled_error,
|  | STRING * | fonts_report
| ) |  |
| static

Definition at line 36 of file errorcounter.cpp.

{
int charsetsize = it->shape_table()->unicharset().size();
int shapesize = it->CompactCharsetSize();
int fontsize = it->sample_set()->NumFonts();
ErrorCounter counter(charsetsize, shapesize, fontsize);
GenericVector<ShapeRating> results;
clock_t start = clock();
int total_samples = 0;
double unscaled_error = 0.0;
// Set a number of samples on which to run the classify debug mode.
int error_samples = report_level > 3 ? report_level * report_level : 0;
// Iterate over all the samples, accumulating errors.
for (it->Begin(); !it->AtEnd(); it->Next()) {
TrainingSample* mutable_sample = it->MutableSample();
int page_index = mutable_sample->page_num();
Pix* page_pix = 0 <= page_index && page_index < page_images.size()
? page_images[page_index] : NULL;
// No debug, no keep this.
classifier->ClassifySample(*mutable_sample, page_pix, 0, INVALID_UNICHAR_ID,
&results);
if (mutable_sample->class_id() == 0) {
// This is junk so use the special counter.
counter.AccumulateJunk(*it->shape_table(), results, mutable_sample);
} else if (counter.AccumulateErrors(report_level > 3, boosting_mode,
fontinfo_table, *it->shape_table(),
results, mutable_sample) &&
error_samples > 0) {
// Running debug, keep the correct answer, and debug the classifier.
tprintf("Error on sample %d: Classifier debug output:\n",
it->GlobalSampleIndex());
int keep_this = it->GetSparseClassID();
classifier->ClassifySample(*mutable_sample, page_pix, 1, keep_this,
&results);
--error_samples;
}
++total_samples;
}
double total_time = 1.0 * (clock() - start) / CLOCKS_PER_SEC;
// Create the appropriate error report.
unscaled_error = counter.ReportErrors(report_level, boosting_mode,
fontinfo_table,
*it, unichar_error, fonts_report);
if (scaled_error != NULL) *scaled_error = counter.scaled_error_;
if (report_level > 1) {
// It is useful to know the time in microseconds/char.
tprintf("Errors computed in %.2fs at %.1f μs/char\n",
total_time, 1000000.0 * total_time / total_samples);
}
return unscaled_error;
}

The documentation for this class was generated from the following files:

- /mnt/data/src/tesseract-ocr/classify/errorcounter.h
- /mnt/data/src/tesseract-ocr/classify/errorcounter.cpp