#include <recodebeam.h>
Classes | |
struct | RecodeBeam |
Public Member Functions | |
RecodeBeamSearch (const UnicharCompress &recoder, int null_char, bool simple_text, Dict *dict) | |
void | Decode (const NetworkIO &output, double dict_ratio, double cert_offset, double worst_dict_cert, const UNICHARSET *charset, int lstm_choice_mode=0) |
void | Decode (const GENERIC_2D_ARRAY< float > &output, double dict_ratio, double cert_offset, double worst_dict_cert, const UNICHARSET *charset) |
void | ExtractBestPathAsLabels (GenericVector< int > *labels, GenericVector< int > *xcoords) const |
void | ExtractBestPathAsUnicharIds (bool debug, const UNICHARSET *unicharset, GenericVector< int > *unichar_ids, GenericVector< float > *certs, GenericVector< float > *ratings, GenericVector< int > *xcoords) const |
void | ExtractBestPathAsWords (const TBOX &line_box, float scale_factor, bool debug, const UNICHARSET *unicharset, PointerVector< WERD_RES > *words, int lstm_choice_mode=0) |
void | DebugBeams (const UNICHARSET &unicharset) const |
Static Public Member Functions | |
static int | LengthFromBeamsIndex (int index) |
static NodeContinuation | ContinuationFromBeamsIndex (int index) |
static bool | IsDawgFromBeamsIndex (int index) |
static int | BeamIndex (bool is_dawg, NodeContinuation cont, int length) |
Public Attributes | |
std::vector< std::vector< std::pair< const char *, float > > > | timesteps |
Static Public Attributes | |
static const float | kMinCertainty = -20.0f |
static const int | kNumLengths = RecodedCharID::kMaxCodeLen + 1 |
static const int | kNumBeams = 2 * NC_COUNT * kNumLengths |
Private Types | |
using | TopPair = KDPairInc< float, int > |
Private Member Functions | |
void | DebugBeamPos (const UNICHARSET &unicharset, const RecodeHeap &heap) const |
WERD_RES * | InitializeWord (bool leading_space, const TBOX &line_box, int word_start, int word_end, float space_certainty, const UNICHARSET *unicharset, const GenericVector< int > &xcoords, float scale_factor) |
void | ComputeTopN (const float *outputs, int num_outputs, int top_n) |
void | DecodeStep (const float *outputs, int t, double dict_ratio, double cert_offset, double worst_dict_cert, const UNICHARSET *charset, bool debug=false) |
void | SaveMostCertainChoices (const float *outputs, int num_outputs, const UNICHARSET *charset, int xCoord) |
void | ContinueContext (const RecodeNode *prev, int index, const float *outputs, TopNState top_n_flag, double dict_ratio, double cert_offset, double worst_dict_cert, RecodeBeam *step) |
void | ContinueUnichar (int code, int unichar_id, float cert, float worst_dict_cert, float dict_ratio, bool use_dawgs, NodeContinuation cont, const RecodeNode *prev, RecodeBeam *step) |
void | ContinueDawg (int code, int unichar_id, float cert, NodeContinuation cont, const RecodeNode *prev, RecodeBeam *step) |
void | PushInitialDawgIfBetter (int code, int unichar_id, PermuterType permuter, bool start, bool end, float cert, NodeContinuation cont, const RecodeNode *prev, RecodeBeam *step) |
void | PushDupOrNoDawgIfBetter (int length, bool dup, int code, int unichar_id, float cert, float worst_dict_cert, float dict_ratio, bool use_dawgs, NodeContinuation cont, const RecodeNode *prev, RecodeBeam *step) |
void | PushHeapIfBetter (int max_size, int code, int unichar_id, PermuterType permuter, bool dawg_start, bool word_start, bool end, bool dup, float cert, const RecodeNode *prev, DawgPositionVector *d, RecodeHeap *heap) |
void | PushHeapIfBetter (int max_size, RecodeNode *node, RecodeHeap *heap) |
bool | UpdateHeapIfMatched (RecodeNode *new_node, RecodeHeap *heap) |
uint64_t | ComputeCodeHash (int code, bool dup, const RecodeNode *prev) const |
void | ExtractBestPaths (GenericVector< const RecodeNode *> *best_nodes, GenericVector< const RecodeNode *> *second_nodes) const |
void | ExtractPath (const RecodeNode *node, GenericVector< const RecodeNode *> *path) const |
void | DebugPath (const UNICHARSET *unicharset, const GenericVector< const RecodeNode *> &path) const |
void | DebugUnicharPath (const UNICHARSET *unicharset, const GenericVector< const RecodeNode *> &path, const GenericVector< int > &unichar_ids, const GenericVector< float > &certs, const GenericVector< float > &ratings, const GenericVector< int > &xcoords) const |
Static Private Member Functions | |
static void | ExtractPathAsUnicharIds (const GenericVector< const RecodeNode *> &best_nodes, GenericVector< int > *unichar_ids, GenericVector< float > *certs, GenericVector< float > *ratings, GenericVector< int > *xcoords, std::deque< std::pair< int, int >> *best_choices=nullptr) |
Private Attributes | |
const UnicharCompress & | recoder_ |
PointerVector< RecodeBeam > | beam_ |
int | beam_size_ |
GenericVector< TopNState > | top_n_flags_ |
int | top_code_ |
int | second_code_ |
GenericHeap< TopPair > | top_heap_ |
Dict * | dict_ |
bool | space_delimited_ |
bool | is_simple_text_ |
int | null_char_ |
Static Private Attributes | |
static const int | kBeamWidths [RecodedCharID::kMaxCodeLen+1] |
|
private |
tesseract::RecodeBeamSearch::RecodeBeamSearch | ( | const UnicharCompress & | recoder, |
int | null_char, | ||
bool | simple_text, | ||
Dict * | dict | ||
) |
|
inlinestatic |
|
private |
|
private |
|
inlinestatic |
|
private |
|
private |
|
private |
|
private |
void tesseract::RecodeBeamSearch::DebugBeams | ( | const UNICHARSET & | unicharset | ) | const |
|
private |
|
private |
void tesseract::RecodeBeamSearch::Decode | ( | const NetworkIO & | output, |
double | dict_ratio, | ||
double | cert_offset, | ||
double | worst_dict_cert, | ||
const UNICHARSET * | charset, | ||
int | lstm_choice_mode = 0 |
||
) |
void tesseract::RecodeBeamSearch::Decode | ( | const GENERIC_2D_ARRAY< float > & | output, |
double | dict_ratio, | ||
double | cert_offset, | ||
double | worst_dict_cert, | ||
const UNICHARSET * | charset | ||
) |
|
private |
void tesseract::RecodeBeamSearch::ExtractBestPathAsLabels | ( | GenericVector< int > * | labels, |
GenericVector< int > * | xcoords | ||
) | const |
void tesseract::RecodeBeamSearch::ExtractBestPathAsUnicharIds | ( | bool | debug, |
const UNICHARSET * | unicharset, | ||
GenericVector< int > * | unichar_ids, | ||
GenericVector< float > * | certs, | ||
GenericVector< float > * | ratings, | ||
GenericVector< int > * | xcoords | ||
) | const |
void tesseract::RecodeBeamSearch::ExtractBestPathAsWords | ( | const TBOX & | line_box, |
float | scale_factor, | ||
bool | debug, | ||
const UNICHARSET * | unicharset, | ||
PointerVector< WERD_RES > * | words, | ||
int | lstm_choice_mode = 0 |
||
) |
|
private |
|
private |
|
staticprivate |
|
private |
|
inlinestatic |
|
inlinestatic |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
static |
|
static |
|
static |
|
private |
|
private |
|
private |
|
private |
std::vector< std::vector<std::pair<const char*, float> > > tesseract::RecodeBeamSearch::timesteps |
|
private |
|
private |
|
private |