tesseract  4.0.0-1-g2a2b
tesseract Namespace Reference

Classes

class  AlignedBlob
 
struct  AlignedBlobParams
 
class  AmbigSpec
 
struct  AssociateStats
 
class  AssociateUtils
 
class  BaselineBlock
 
class  BaselineDetect
 
class  BaselineRow
 
class  BBGrid
 
struct  BestChoiceBundle
 Bundle together all the things pertaining to the best choice/state. More...
 
class  BitVector
 
struct  BlobData
 
class  BlobGrid
 
struct  BlockGroup
 
class  BoolParam
 
class  BoxChar
 
struct  BoxCharPtrSort
 
class  BoxWord
 
class  CCNonTextDetect
 
class  CCStruct
 
class  CCUtil
 
class  CCUtilMutex
 
class  ChoiceIterator
 
class  Classify
 
class  ClassPruner
 
struct  ClipFFunc
 
struct  ClipFPrime
 
struct  ClipGFunc
 
struct  ClipGPrime
 
struct  Cluster
 
class  ColPartition
 
class  ColPartitionGrid
 
class  ColPartitionSet
 
class  ColSegment
 
class  ColumnFinder
 
class  Convolve
 
class  CTC
 
class  CUtil
 
class  Dawg
 
struct  DawgArgs
 
class  DawgCache
 
struct  DawgLoader
 
struct  DawgPosition
 
class  DawgPositionVector
 
class  DebugPixa
 
class  DetLineFit
 
class  Dict
 
struct  DocQualCallbacks
 
class  DocumentCache
 
class  DocumentData
 
class  DoubleParam
 
class  DoublePtr
 
class  DPPoint
 
class  EquationDetect
 
class  EquationDetectBase
 
class  ErrorCounter
 
struct  FFunc
 
class  File
 
struct  FloatWordFeature
 
struct  FontInfo
 
class  FontInfoTable
 
struct  FontSet
 
struct  FontSpacingInfo
 
class  FontUtils
 
struct  FPrime
 
class  FRAGMENT
 
class  FullyConnected
 
class  GenericHeap
 
struct  GeometricClassifierState
 
struct  GFunc
 
struct  GPrime
 
class  GridBase
 
class  GridSearch
 
struct  HFunc
 
struct  HPrime
 
class  IcuErrorCode
 
struct  IdentityFunc
 
class  ImageData
 
class  ImageFind
 
class  ImageThresholder
 
class  IndexMap
 
class  IndexMapBiDi
 
class  Input
 
class  InputBuffer
 
struct  Interval
 
class  IntFeatureDist
 
class  IntFeatureMap
 
class  IntFeatureSpace
 
class  IntGrid
 
class  IntParam
 
class  IntSimdMatrix
 
class  IntSimdMatrixAVX2
 
class  IntSimdMatrixSSE
 
struct  KDPair
 
struct  KDPairDec
 
struct  KDPairInc
 
class  KDPtrPair
 
struct  KDPtrPairDec
 
struct  KDPtrPairInc
 
class  KDVector
 
class  LanguageModel
 
struct  LanguageModelDawgInfo
 
struct  LanguageModelNgramInfo
 
struct  LanguageModelState
 Struct to store information maintained by various language model components. More...
 
class  LigatureTable
 
class  LineFinder
 
struct  LineHypothesis
 
struct  LMConsistencyInfo
 
class  LMPainPoints
 
class  LSTM
 
class  LSTMRecognizer
 
class  LSTMTester
 
class  LSTMTrainer
 
class  LTRResultIterator
 
class  MasterTrainer
 
class  Maxpool
 
class  MutableIterator
 
class  Network
 
class  NetworkBuilder
 
class  NetworkIO
 
class  NetworkScratch
 
struct  NodeChild
 
class  ObjectCache
 
class  OutputBuffer
 
class  PageIterator
 
class  PangoFontInfo
 
class  ParagraphModelSmearer
 
class  ParagraphTheory
 
class  Parallel
 
class  Param
 
class  ParamsModel
 
class  ParamsTrainingBundle
 
struct  ParamsTrainingHypothesis
 
struct  ParamsVectors
 
class  ParamUtils
 
class  PixelHistogram
 
class  Plumbing
 
class  PointerVector
 
struct  PtrHash
 
class  RecodeBeamSearch
 
class  RecodedCharID
 
struct  RecodeNode
 
class  Reconfig
 
struct  Relu
 
struct  ReluPrime
 
class  ResultIterator
 
class  Reversed
 
class  RowInfo
 
class  RowScratchRegisters
 
class  SampleIterator
 
struct  ScoredFont
 
class  SegSearchPending
 
class  Series
 
class  Shape
 
class  ShapeClassifier
 
struct  ShapeDist
 
struct  ShapeQueueEntry
 
struct  ShapeRating
 
class  ShapeTable
 
class  ShiroRekhaSplitter
 
class  SimpleClusterer
 
struct  SpacingProperties
 
class  SquishedDawg
 
class  StaticShape
 
class  StrideMap
 
class  StringParam
 
class  StringRenderer
 
class  StrokeWidth
 
class  StructuredTable
 
class  TabConstraint
 
class  TabEventHandler
 
class  TabFind
 
class  TableFinder
 
class  TableRecognizer
 
class  TabVector
 
struct  TESS_CHAR
 
class  TessBaseAPI
 
class  TessBoxTextRenderer
 
class  TessClassifier
 
class  TessdataManager
 
class  Tesseract
 
struct  TesseractStats
 
class  TessHOcrRenderer
 
class  TessOsdRenderer
 
class  TessPDFRenderer
 
class  TessResultRenderer
 
class  TessTextRenderer
 
class  TessTsvRenderer
 
class  TessUnlvRenderer
 
class  TextlineProjection
 
class  Textord
 
class  TFile
 
class  TrainingSample
 
class  TrainingSampleSet
 
class  TRand
 
class  TransposedArray
 
class  Trie
 
class  UNICHAR
 
class  UnicharAmbigs
 
struct  UnicharAndFonts
 
class  UnicharCompress
 
class  UnicharIdArrayUtils
 
struct  UnicharRating
 
class  UnicodeSpanSkipper
 
struct  UnityFunc
 
class  ValidateGrapheme
 
class  ValidateIndic
 
class  ValidateJavanese
 
class  ValidateKhmer
 
class  ValidateMyanmar
 
class  Validator
 
struct  ViterbiStateEntry
 
class  WeightMatrix
 
struct  WordData
 
class  WordFeature
 
class  Wordrec
 
class  WordWithBox
 
class  WorkingPartSet
 

Typedefs

typedef int(Dict::* DictFunc) (void *void_dawg_args, const UNICHARSET &unicharset, UNICHAR_ID unichar_id, bool word_end) const
 
typedef double(Dict::* ProbabilityInContextFunc) (const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)
 
typedef float(Dict::* ParamsModelClassifyFunc) (const char *lang, void *path)
 
typedef void(Wordrec::* FillLatticeFunc) (const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
 
typedef TessCallback4< const UNICHARSET &, int, PageIterator *, Pix * > TruthCallback
 
using SetOfModels = GenericVectorEqEq< const ParagraphModel * >
 
typedef void(Tesseract::* WordRecognizer) (const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
 
using ParamsTrainingHypothesisList = GenericVector< ParamsTrainingHypothesis >
 
using UnicharIdVector = GenericVector< UNICHAR_ID >
 
using UnicharAmbigsVector = GenericVector< AmbigSpec_LIST * >
 
typedef bool(* FileReader) (const STRING &filename, GenericVector< char > *data)
 
typedef bool(* FileWriter) (const GenericVector< char > &data, const STRING &filename)
 
using IntKDPair = KDPairInc< int, int >
 
using char32 = signed int
 
using RSMap = std::unordered_map< int, std::unique_ptr< std::vector< int > >>
 
using RSCounts = std::unordered_map< int, int >
 
using ShapeQueue = GenericHeap< ShapeQueueEntry >
 
using NodeChildVector = GenericVector< NodeChild >
 
using SuccessorList = GenericVector< int >
 
using SuccessorListsVector = GenericVector< SuccessorList * >
 
using DawgVector = GenericVector< Dawg * >
 
typedef TessResultCallback2< bool, const GenericVector< char > &, LSTMTrainer * > * CheckPointReader
 
typedef TessResultCallback3< bool, SerializeAmount, const LSTMTrainer *, GenericVector< char > * > * CheckPointWriter
 
typedef TessResultCallback4< STRING, int, const double *, const TessdataManager &, int > * TestCallback
 
using RecodePair = KDPairInc< double, RecodeNode >
 
using RecodeHeap = GenericHeap< RecodePair >
 
using BlobGridSearch = GridSearch< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT >
 
using ColPartitionGridSearch = GridSearch< ColPartition, ColPartition_CLIST, ColPartition_C_IT >
 
using PartSetVector = GenericVector< ColPartitionSet * >
 
using WidthCallback = TessResultCallback1< bool, int >
 
using ColSegmentGrid = BBGrid< ColSegment, ColSegment_CLIST, ColSegment_C_IT >
 
using ColSegmentGridSearch = GridSearch< ColSegment, ColSegment_CLIST, ColSegment_C_IT >
 
using WordGrid = BBGrid< WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT >
 
using WordSearch = GridSearch< WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT >
 
using LigHash = std::unordered_map< std::string, std::string, StringHash >
 
using PainPointHeap = GenericHeap< MatrixCoordPair >
 
using LanguageModelFlagsType = unsigned char
 Used for expressing various language model flags. More...
 

Enumerations

enum  LineType { LT_START = 'S', LT_BODY = 'C', LT_UNKNOWN = 'U', LT_MULTIPLE = 'M' }
 
enum  CMD_EVENTS { ACTION_1_CMD_EVENT, RECOG_WERDS, RECOG_PSEUDO, ACTION_2_CMD_EVENT }
 
enum  CachingStrategy { CS_SEQUENTIAL, CS_ROUND_ROBIN }
 
enum  NormalizationMode { NM_BASELINE = -3, NM_CHAR_ISOTROPIC = -2, NM_CHAR_ANISOTROPIC = -1 }
 
enum  kParamsTrainingFeatureType {
  PTRAIN_DIGITS_SHORT, PTRAIN_DIGITS_MED, PTRAIN_DIGITS_LONG, PTRAIN_NUM_SHORT,
  PTRAIN_NUM_MED, PTRAIN_NUM_LONG, PTRAIN_DOC_SHORT, PTRAIN_DOC_MED,
  PTRAIN_DOC_LONG, PTRAIN_DICT_SHORT, PTRAIN_DICT_MED, PTRAIN_DICT_LONG,
  PTRAIN_FREQ_SHORT, PTRAIN_FREQ_MED, PTRAIN_FREQ_LONG, PTRAIN_SHAPE_COST_PER_CHAR,
  PTRAIN_NGRAM_COST_PER_CHAR, PTRAIN_NUM_BAD_PUNC, PTRAIN_NUM_BAD_CASE, PTRAIN_XHEIGHT_CONSISTENCY,
  PTRAIN_NUM_BAD_CHAR_TYPE, PTRAIN_NUM_BAD_SPACING, PTRAIN_NUM_BAD_FONT, PTRAIN_RATING_PER_CHAR,
  PTRAIN_NUM_FEATURE_TYPES
}
 
enum  Orientation { ORIENTATION_PAGE_UP = 0, ORIENTATION_PAGE_RIGHT = 1, ORIENTATION_PAGE_DOWN = 2, ORIENTATION_PAGE_LEFT = 3 }
 
enum  WritingDirection { WRITING_DIRECTION_LEFT_TO_RIGHT = 0, WRITING_DIRECTION_RIGHT_TO_LEFT = 1, WRITING_DIRECTION_TOP_TO_BOTTOM = 2 }
 
enum  TextlineOrder { TEXTLINE_ORDER_LEFT_TO_RIGHT = 0, TEXTLINE_ORDER_RIGHT_TO_LEFT = 1, TEXTLINE_ORDER_TOP_TO_BOTTOM = 2 }
 
enum  PageSegMode {
  PSM_OSD_ONLY, PSM_AUTO_OSD, PSM_AUTO_ONLY, PSM_AUTO,
  PSM_SINGLE_COLUMN, PSM_SINGLE_BLOCK_VERT_TEXT, PSM_SINGLE_BLOCK, PSM_SINGLE_LINE,
  PSM_SINGLE_WORD, PSM_CIRCLE_WORD, PSM_SINGLE_CHAR, PSM_SPARSE_TEXT,
  PSM_SPARSE_TEXT_OSD, PSM_RAW_LINE, PSM_COUNT
}
 
enum  PageIteratorLevel {
  RIL_BLOCK, RIL_PARA, RIL_TEXTLINE, RIL_WORD,
  RIL_SYMBOL
}
 
enum  ParagraphJustification { JUSTIFICATION_UNKNOWN, JUSTIFICATION_LEFT, JUSTIFICATION_CENTER, JUSTIFICATION_RIGHT }
 
enum  OcrEngineMode {
  OEM_TESSERACT_ONLY, OEM_LSTM_ONLY, OEM_TESSERACT_LSTM_COMBINED, OEM_DEFAULT,
  OEM_COUNT
}
 
enum  ScriptPos { SP_NORMAL, SP_SUBSCRIPT, SP_SUPERSCRIPT, SP_DROPCAP }
 
enum  AmbigType {
  NOT_AMBIG, REPLACE_AMBIG, DEFINITE_AMBIG, SIMILAR_AMBIG,
  CASE_AMBIG, AMBIG_TYPE_COUNT
}
 
enum  SetParamConstraint { SET_PARAM_CONSTRAINT_NONE, SET_PARAM_CONSTRAINT_DEBUG_ONLY, SET_PARAM_CONSTRAINT_NON_DEBUG_ONLY, SET_PARAM_CONSTRAINT_NON_INIT_ONLY }
 
enum  TessdataType {
  TESSDATA_LANG_CONFIG, TESSDATA_UNICHARSET, TESSDATA_AMBIGS, TESSDATA_INTTEMP,
  TESSDATA_PFFMTABLE, TESSDATA_NORMPROTO, TESSDATA_PUNC_DAWG, TESSDATA_SYSTEM_DAWG,
  TESSDATA_NUMBER_DAWG, TESSDATA_FREQ_DAWG, TESSDATA_FIXED_LENGTH_DAWGS, TESSDATA_CUBE_UNICHARSET,
  TESSDATA_CUBE_SYSTEM_DAWG, TESSDATA_SHAPE_TABLE, TESSDATA_BIGRAM_DAWG, TESSDATA_UNAMBIG_DAWG,
  TESSDATA_PARAMS_MODEL, TESSDATA_LSTM, TESSDATA_LSTM_PUNC_DAWG, TESSDATA_LSTM_SYSTEM_DAWG,
  TESSDATA_LSTM_NUMBER_DAWG, TESSDATA_LSTM_UNICHARSET, TESSDATA_LSTM_RECODER, TESSDATA_VERSION,
  TESSDATA_NUM_ENTRIES
}
 
enum  CharSegmentationType { CST_FRAGMENT, CST_WHOLE, CST_IMPROPER, CST_NGRAM }
 
enum  CountTypes {
  CT_UNICHAR_TOP_OK, CT_UNICHAR_TOP1_ERR, CT_UNICHAR_TOP2_ERR, CT_UNICHAR_TOPN_ERR,
  CT_UNICHAR_TOPTOP_ERR, CT_OK_MULTI_UNICHAR, CT_OK_JOINED, CT_OK_BROKEN,
  CT_REJECT, CT_FONT_ATTR_ERR, CT_OK_MULTI_FONT, CT_NUM_RESULTS,
  CT_RANK, CT_REJECTED_JUNK, CT_ACCEPTED_JUNK, CT_SIZE
}
 
enum  DawgType {
  DAWG_TYPE_PUNCTUATION, DAWG_TYPE_WORD, DAWG_TYPE_NUMBER, DAWG_TYPE_PATTERN,
  DAWG_TYPE_COUNT
}
 
enum  XHeightConsistencyEnum { XH_GOOD, XH_SUBNORMAL, XH_INCONSISTENT }
 
enum  TrainingFlags { TF_INT_MODE = 1, TF_COMPRESS_UNICHARSET = 64 }
 
enum  ErrorTypes {
  ET_RMS, ET_DELTA, ET_WORD_RECERR, ET_CHAR_ERROR,
  ET_SKIP_RATIO, ET_COUNT
}
 
enum  Trainability {
  TRAINABLE, PERFECT, UNENCODABLE, HI_PRECISION_ERR,
  NOT_BOXED
}
 
enum  SerializeAmount { LIGHT, NO_BEST_TRAINER, FULL }
 
enum  SubTrainerResult { STR_NONE, STR_UPDATED, STR_REPLACED }
 
enum  NetworkType {
  NT_NONE, NT_INPUT, NT_CONVOLVE, NT_MAXPOOL,
  NT_PARALLEL, NT_REPLICATED, NT_PAR_RL_LSTM, NT_PAR_UD_LSTM,
  NT_PAR_2D_LSTM, NT_SERIES, NT_RECONFIG, NT_XREVERSED,
  NT_YREVERSED, NT_XYTRANSPOSE, NT_LSTM, NT_LSTM_SUMMARY,
  NT_LOGISTIC, NT_POSCLIP, NT_SYMCLIP, NT_TANH,
  NT_RELU, NT_LINEAR, NT_SOFTMAX, NT_SOFTMAX_NO_CTC,
  NT_LSTM_SOFTMAX, NT_LSTM_SOFTMAX_ENCODED, NT_TENSORFLOW, NT_COUNT
}
 
enum  NetworkFlags { NF_LAYER_SPECIFIC_LR = 64, NF_ADAM = 128 }
 
enum  TrainingState { TS_DISABLED, TS_ENABLED, TS_TEMP_DISABLE, TS_RE_ENABLE }
 
enum  NodeContinuation { NC_ANYTHING, NC_ONLY_DUP, NC_NO_DUP, NC_COUNT }
 
enum  TopNState { TN_TOP2, TN_TOPN, TN_ALSO_RAN, TN_COUNT }
 
enum  LossType { LT_NONE, LT_CTC, LT_SOFTMAX, LT_LOGISTIC }
 
enum  FlexDimensions { FD_BATCH, FD_HEIGHT, FD_WIDTH, FD_DIMSIZE }
 
enum  ColumnSpanningType {
  CST_NOISE, CST_FLOWING, CST_HEADING, CST_PULLOUT,
  CST_COUNT
}
 
enum  NeighbourPartitionType {
  NPT_HTEXT, NPT_VTEXT, NPT_WEAK_HTEXT, NPT_WEAK_VTEXT,
  NPT_IMAGE, NPT_COUNT
}
 
enum  LeftOrRight { LR_LEFT, LR_RIGHT }
 
enum  PartitionFindResult { PFR_OK, PFR_SKEW, PFR_NOISE }
 
enum  ColSegType {
  COL_UNKNOWN, COL_TEXT, COL_TABLE, COL_MIXED,
  COL_COUNT
}
 
enum  TabAlignment {
  TA_LEFT_ALIGNED, TA_LEFT_RAGGED, TA_CENTER_JUSTIFIED, TA_RIGHT_ALIGNED,
  TA_RIGHT_RAGGED, TA_SEPARATOR, TA_COUNT
}
 
enum  FactorNames {
  FN_INCOLOR, FN_Y0, FN_Y1, FN_Y2,
  FN_Y3, FN_X0, FN_X1, FN_SHEAR,
  FN_NUM_FACTORS
}
 
enum  UnicodeNormMode { UnicodeNormMode::kNFD, UnicodeNormMode::kNFC, UnicodeNormMode::kNFKD, UnicodeNormMode::kNFKC }
 
enum  OCRNorm { OCRNorm::kNone, OCRNorm::kNormalize }
 
enum  GraphemeNorm { GraphemeNorm::kNone, GraphemeNorm::kNormalize }
 
enum  GraphemeNormMode { GraphemeNormMode::kSingleString, GraphemeNormMode::kCombined, GraphemeNormMode::kGlyphSplit, GraphemeNormMode::kIndividualUnicodes }
 
enum  ViramaScript : char32 {
  ViramaScript::kNonVirama = 0, ViramaScript::kDevanagari = 0x900, ViramaScript::kBengali = 0x980, ViramaScript::kGurmukhi = 0xa00,
  ViramaScript::kGujarati = 0xa80, ViramaScript::kOriya = 0xb00, ViramaScript::kTamil = 0xb80, ViramaScript::kTelugu = 0xc00,
  ViramaScript::kKannada = 0xc80, ViramaScript::kMalayalam = 0xd00, ViramaScript::kSinhala = 0xd80, ViramaScript::kMyanmar = 0x1000,
  ViramaScript::kKhmer = 0x1780, ViramaScript::kJavanese = 0xa980
}
 
enum  LMPainPointsType {
  LM_PPTYPE_BLAMER, LM_PPTYPE_AMBIG, LM_PPTYPE_PATH, LM_PPTYPE_SHAPE,
  LM_PPTYPE_NUM
}
 

Functions

STRING HOcrEscape (const char *text)
 
double DotProductAVX (const double *u, const double *v, int n)
 
double DotProductSSE (const double *u, const double *v, int n)
 
int32_t IntDotProductSSE (const int8_t *u, const int8_t *v, int n)
 
bool IsTextOrEquationType (PolyBlockType type)
 
bool IsLeftIndented (const EquationDetect::IndentType type)
 
bool IsRightIndented (const EquationDetect::IndentType type)
 
bool AsciiLikelyListItem (const STRING &word)
 
int UnicodeFor (const UNICHARSET *u, const WERD_CHOICE *werd, int pos)
 
void LeftWordAttributes (const UNICHARSET *unicharset, const WERD_CHOICE *werd, const STRING &utf8, bool *is_list, bool *starts_idea, bool *ends_idea)
 
void RightWordAttributes (const UNICHARSET *unicharset, const WERD_CHOICE *werd, const STRING &utf8, bool *is_list, bool *starts_idea, bool *ends_idea)
 
bool ValidFirstLine (const GenericVector< RowScratchRegisters > *rows, int row, const ParagraphModel *model)
 
bool ValidBodyLine (const GenericVector< RowScratchRegisters > *rows, int row, const ParagraphModel *model)
 
bool CrownCompatible (const GenericVector< RowScratchRegisters > *rows, int a, int b, const ParagraphModel *model)
 
void RecomputeMarginsAndClearHypotheses (GenericVector< RowScratchRegisters > *rows, int start, int end, int percentile)
 
int InterwordSpace (const GenericVector< RowScratchRegisters > &rows, int row_start, int row_end)
 
bool FirstWordWouldHaveFit (const RowScratchRegisters &before, const RowScratchRegisters &after, tesseract::ParagraphJustification justification)
 
bool FirstWordWouldHaveFit (const RowScratchRegisters &before, const RowScratchRegisters &after)
 
bool RowsFitModel (const GenericVector< RowScratchRegisters > *rows, int start, int end, const ParagraphModel *model)
 
void CanonicalizeDetectionResults (GenericVector< PARA *> *row_owners, PARA_LIST *paragraphs)
 
void DetectParagraphs (int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA *> *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel *> *models)
 
void DetectParagraphs (int debug_level, bool after_text_recognition, const MutableIterator *block_start, GenericVector< ParagraphModel *> *models)
 
bool StrongModel (const ParagraphModel *model)
 
bool CompareFontInfo (const FontInfo &fi1, const FontInfo &fi2)
 
bool CompareFontSet (const FontSet &fs1, const FontSet &fs2)
 
void FontInfoDeleteCallback (FontInfo f)
 
void FontSetDeleteCallback (FontSet fs)
 
bool read_info (TFile *f, FontInfo *fi)
 
bool write_info (FILE *f, const FontInfo &fi)
 
bool read_spacing_info (TFile *f, FontInfo *fi)
 
bool write_spacing_info (FILE *f, const FontInfo &fi)
 
bool read_set (TFile *f, FontSet *fs)
 
bool write_set (FILE *f, const FontSet &fs)
 
void * ReCachePagesFunc (void *data)
 
int OtsuThreshold (Pix *src_pix, int left, int top, int width, int height, int **thresholds, int **hi_values)
 
void HistogramRect (Pix *src_pix, int channel, int left, int top, int width, int height, int *histogram)
 
int OtsuStats (const int *histogram, int *H_out, int *omega0_out)
 
int ParamsTrainingFeatureByName (const char *name)
 
bool PSM_OSD_ENABLED (int pageseg_mode)
 
bool PSM_ORIENTATION_ENABLED (int pageseg_mode)
 
bool PSM_COL_FIND_ENABLED (int pageseg_mode)
 
bool PSM_SPARSE (int pageseg_mode)
 
bool PSM_BLOCK_FIND_ENABLED (int pageseg_mode)
 
bool PSM_LINE_FIND_ENABLED (int pageseg_mode)
 
bool PSM_WORD_FIND_ENABLED (int pageseg_mode)
 
const char * ScriptPosToString (enum ScriptPos script_pos)
 
bool LoadDataFromFile (const char *filename, GenericVector< char > *data)
 
bool LoadDataFromFile (const STRING &filename, GenericVector< char > *data)
 
bool SaveDataToFile (const GenericVector< char > &data, const STRING &filename)
 
bool LoadFileLinesToStrings (const STRING &filename, GenericVector< STRING > *lines)
 
template<typename T >
bool cmp_eq (T const &t1, T const &t2)
 
template<typename T >
int sort_cmp (const void *t1, const void *t2)
 
template<typename T >
int sort_ptr_cmp (const void *t1, const void *t2)
 
bool DeSerialize (FILE *fp, char *data, size_t n)
 
bool DeSerialize (FILE *fp, float *data, size_t n)
 
bool DeSerialize (FILE *fp, int8_t *data, size_t n)
 
bool DeSerialize (FILE *fp, int16_t *data, size_t n)
 
bool DeSerialize (FILE *fp, int32_t *data, size_t n)
 
bool DeSerialize (FILE *fp, uint8_t *data, size_t n)
 
bool DeSerialize (FILE *fp, uint16_t *data, size_t n)
 
bool DeSerialize (FILE *fp, uint32_t *data, size_t n)
 
bool Serialize (FILE *fp, const char *data, size_t n)
 
bool Serialize (FILE *fp, const float *data, size_t n)
 
bool Serialize (FILE *fp, const int8_t *data, size_t n)
 
bool Serialize (FILE *fp, const int16_t *data, size_t n)
 
bool Serialize (FILE *fp, const int32_t *data, size_t n)
 
bool Serialize (FILE *fp, const uint8_t *data, size_t n)
 
bool Serialize (FILE *fp, const uint16_t *data, size_t n)
 
bool Serialize (FILE *fp, const uint32_t *data, size_t n)
 
template<typename T , size_t N>
constexpr size_t countof (T const (&)[N]) noexcept
 
void ExtractFontName (const STRING &filename, STRING *fontname)
 
TrainingSampleBlobToTrainingSample (const TBLOB &blob, bool nonlinear_norm, INT_FX_RESULT_STRUCT *fx_info, GenericVector< INT_FEATURE_STRUCT > *bl_features)
 
void ClearFeatureSpaceWindow (NORM_METHOD norm_method, ScrollView *window)
 
double Tanh (double x)
 
double Logistic (double x)
 
template<class Func >
void FuncInplace (int n, double *inout)
 
template<class Func >
void FuncMultiply (const double *u, const double *v, int n, double *out)
 
template<typename T >
void SoftmaxInPlace (int n, T *inout)
 
void CopyVector (int n, const double *src, double *dest)
 
void AccumulateVector (int n, const double *src, double *dest)
 
void MultiplyVectorsInPlace (int n, const double *src, double *inout)
 
void MultiplyAccumulate (int n, const double *u, const double *v, double *out)
 
void SumVectors (int n, const double *v1, const double *v2, const double *v3, const double *v4, const double *v5, double *sum)
 
template<typename T >
void ZeroVector (int n, T *vec)
 
template<typename T >
void ClipVector (int n, T lower, T upper, T *vec)
 
void CodeInBinary (int n, int nf, double *vec)
 
Pix * TraceOutlineOnReducedPix (C_OUTLINE *outline, int gridsize, ICOORD bleft, int *left, int *bottom)
 
Pix * TraceBlockOnReducedPix (BLOCK *block, int gridsize, ICOORD bleft, int *left, int *bottom)
 
template<class BBC >
int SortByBoxLeft (const void *void1, const void *void2)
 
template<class BBC >
int SortRightToLeft (const void *void1, const void *void2)
 
template<class BBC >
int SortByBoxBottom (const void *void1, const void *void2)
 
template<typename T >
void DeleteObject (T *object)
 
void SetBlobStrokeWidth (Pix *pix, BLOBNBOX *blob)
 
void assign_blobs_to_blocks2 (Pix *pix, BLOCK_LIST *blocks, TO_BLOCK_LIST *port_blocks)
 
void ParseCommandLineFlags (const char *usage, int *argc, char ***argv, const bool remove_flags)
 
ShapeTableLoadShapeTable (const STRING &file_prefix)
 
void WriteShapeTable (const STRING &file_prefix, const ShapeTable &shape_table)
 
MasterTrainerLoadTrainingData (int argc, const char *const *argv, bool replication, ShapeTable **shape_table, STRING *file_prefix)
 
Pix * DegradeImage (Pix *input, int exposure, TRand *randomizer, float *rotation)
 
Pix * PrepareDistortedPix (const Pix *pix, bool perspective, bool invert, bool white_noise, bool smooth_noise, bool blur, int box_reduction, TRand *randomizer, GenericVector< TBOX > *boxes)
 
void GeneratePerspectiveDistortion (int width, int height, TRand *randomizer, Pix **pix, GenericVector< TBOX > *boxes)
 
int ProjectiveCoeffs (int width, int height, TRand *randomizer, float **im_coeffs, float **box_coeffs)
 
bool WriteFile (const std::string &output_dir, const std::string &lang, const std::string &suffix, const GenericVector< char > &data, FileWriter writer)
 
STRING ReadFile (const std::string &filename, FileReader reader)
 
bool WriteUnicharset (const UNICHARSET &unicharset, const std::string &output_dir, const std::string &lang, FileWriter writer, TessdataManager *traineddata)
 
bool WriteRecoder (const UNICHARSET &unicharset, bool pass_through, const std::string &output_dir, const std::string &lang, FileWriter writer, STRING *radical_table_data, TessdataManager *traineddata)
 
int CombineLangModel (const UNICHARSET &unicharset, const std::string &script_dir, const std::string &version_str, const std::string &output_dir, const std::string &lang, bool pass_through_recoder, const GenericVector< STRING > &words, const GenericVector< STRING > &puncs, const GenericVector< STRING > &numbers, bool lang_is_rtl, FileReader reader, FileWriter writer)
 
bool NormalizeUTF8String (UnicodeNormMode u_mode, OCRNorm ocr_normalize, GraphemeNorm grapheme_normalize, const char *str8, std::string *normalized)
 
bool NormalizeCleanAndSegmentUTF8 (UnicodeNormMode u_mode, OCRNorm ocr_normalize, GraphemeNormMode g_mode, bool report_errors, const char *str8, std::vector< std::string > *graphemes)
 
char32 OCRNormalize (char32 ch)
 
bool IsOCREquivalent (char32 ch1, char32 ch2)
 
bool IsValidCodepoint (const char32 ch)
 
bool IsWhitespace (const char32 ch)
 
bool IsUTF8Whitespace (const char *text)
 
unsigned int SpanUTF8Whitespace (const char *text)
 
unsigned int SpanUTF8NotWhitespace (const char *text)
 
bool IsInterchangeValid (const char32 ch)
 
bool IsInterchangeValid7BitAscii (const char32 ch)
 
char32 FullwidthToHalfwidth (const char32 ch)
 
void SetupBasicProperties (bool report_errors, bool decompose, UNICHARSET *unicharset)
 
void SetScriptProperties (const std::string &script_dir, UNICHARSET *unicharset)
 
std::string GetXheightString (const std::string &script_dir, const UNICHARSET &unicharset)
 
void SetPropertiesForInputFile (const std::string &script_dir, const std::string &input_unicharset_file, const std::string &output_unicharset_file, const std::string &output_xheights_file)
 
void SetupBasicProperties (bool report_errors, UNICHARSET *unicharset)
 
template<class BLOB_CHOICE >
int SortByUnicharID (const void *void1, const void *void2)
 
template<class BLOB_CHOICE >
int SortByRating (const void *void1, const void *void2)
 

Variables

const int kMinRectSize = 10
 
const char kTesseractReject = '~'
 
const char kUNLVReject = '~'
 
const char kUNLVSuspect = '^'
 
const char * kInputFile = "noname.tif"
 
const char * kOldVarsFile = "failed_vars.txt"
 
const int kMaxIntSize = 22
 
const int kNumbersPerBlob = 5
 
const int kBytesPerNumber = 5
 
const int kBytesPerBoxFileLine = (kBytesPerNumber + 1) * kNumbersPerBlob + 1
 
const int kBytesPer64BitNumber = 20
 
const int kMaxBytesPerLine
 
const int kUniChs []
 
const int kLatinChs []
 
const float kMathDigitDensityTh1 = 0.25
 
const float kMathDigitDensityTh2 = 0.1
 
const float kMathItalicDensityTh = 0.5
 
const float kUnclearDensityTh = 0.25
 
const int kSeedBlobsCountTh = 10
 
const int kLeftIndentAlignmentCountTh = 1
 
const int kMaxCharTopRange = 48
 
const float kCertaintyScale = 7.0f
 
const float kWorstDictCertainty = -25.0f
 
const int kMaxCircleErosions = 8
 
const ParagraphModelkCrownLeft = reinterpret_cast<ParagraphModel *>(0xDEAD111F)
 
const ParagraphModelkCrownRight = reinterpret_cast<ParagraphModel *>(0xDEAD888F)
 
const int16_t kMaxBoxEdgeDiff = 2
 
const int kBoxClipTolerance = 2
 
const int kNumEndPoints = 3
 
const int kMinPointsForErrorCount = 16
 
const int kMaxRealDistance = 2.0
 
const int kFeaturePadding = 2
 
const int kImagePadding = 4
 
const int kHistogramSize = 256
 
const int kMaxAmbigStringSize = UNICHAR_LEN * (MAX_AMBIG_SIZE + 1)
 
CCUtilMutex tprintfMutex
 
const char * kNullChar = "<nul>"
 
const int kRadicalRadix = 29
 
const char * kUTF8LineSeparator = "\u2028"
 
const char * kUTF8ParagraphSeparator = "\u2029"
 
const char * kLRM = "\u200E"
 
const char * kRLM = "\u200F"
 
const char * kRLE = "\u202A"
 
const char * kPDF = "\u202C"
 
const char * kHyphenLikeUTF8 []
 
const char * kApostropheLikeUTF8 []
 
const char kUniversalAmbigsFile []
 
const int ksizeofUniversalAmbigsFile = sizeof(kUniversalAmbigsFile)
 
const double kRatingEpsilon = 1.0 / 32
 
const int kMaxOffsetDist = 32
 
const int kMinClusteredShapes = 1
 
const int kMaxUnicharsPerCluster = 2000
 
const float kFontMergeDistance = 0.025
 
const float kInfiniteDist = 999.0f
 
const int kRandomizingCenter = 128
 
const int kTestChar = -1
 
const int kSquareLimit = 25
 
const int kPrime1 = 17
 
const int kPrime2 = 13
 
const int case_state_table [6][4]
 
const char kDoNotReverse [] = "RRP_DO_NO_REVERSE"
 
const char kReverseIfHasRTL [] = "RRP_REVERSE_IF_HAS_RTL"
 
const char kForceReverse [] = "RRP_FORCE_REVERSE"
 
const char *const RTLReversePolicyNames []
 
double TanhTable [kTableSize]
 
double LogisticTable [kTableSize]
 
const int kTableSize = 4096
 
const double kScaleFactor = 256.0
 
const int kMaxInputHeight = 48
 
const double kStateClip = 100.0
 
const double kErrClip = 1.0f
 
const double kDictRatio = 2.25
 
const double kCertOffset = -0.085
 
const double kMinDivergenceRate = 50.0
 
const int kMinStallIterations = 10000
 
const double kSubTrainerMarginFraction = 3.0 / 128
 
const double kLearningRateDecay = sqrt(0.5)
 
const int kNumAdjustmentIterations = 100
 
const int kErrorGraphInterval = 1000
 
const int kNumPagesPerBatch = 100
 
const int kMinStartedErrorRate = 75
 
const double kStageTransitionThreshold = 10.0
 
const double kHighConfidence = 0.9375
 
const double kImprovementFraction = 15.0 / 16.0
 
const double kBestCheckpointFraction = 31.0 / 32.0
 
const int kTargetXScale = 5
 
const int kTargetYScale = 100
 
const int kMinWinSize = 500
 
const int kMaxWinSize = 2000
 
const int kXWinFrameSize = 30
 
const int kYWinFrameSize = 80
 
const float kMinCertainty = -20.0f
 
const float kMinProb = exp(kMinCertainty)
 
const char * kNodeContNames [] = {"Anything", "OnlyDup", "NoDup"}
 
const int kAdamCorrectionIterations = 200000
 
const double kAdamEpsilon = 1e-8
 
const int kInt8Flag = 1
 
const int kAdamFlag = 4
 
const int kDoubleFlag = 128
 
const int kHistogramBuckets = 16
 
const double kAlignedFraction = 0.03125
 
const double kRaggedFraction = 2.5
 
const double kAlignedGapFraction = 0.75
 
const double kRaggedGapFraction = 1.0
 
const int kVLineAlignment = 3
 
const int kVLineGutter = 1
 
const int kVLineSearchSize = 150
 
const int kMinRaggedTabs = 5
 
const int kMinAlignedTabs = 4
 
const int kVLineMinLength = 500
 
const double kMinTabGradient = 4.0
 
const int kMaxSkewFactor = 15
 
const double kMaxSmallNeighboursPerPix = 1.0 / 32
 
const int kMaxLargeOverlapsWithSmall = 3
 
const int kMaxMediumOverlapsWithSmall = 12
 
const int kMaxLargeOverlapsWithMedium = 12
 
const int kOriginalNoiseMultiple = 8
 
const int kNoisePadding = 4
 
const double kPhotoOffsetFraction = 0.375
 
const double kMinGoodTextPARatio = 1.5
 
const int kMaxIncompatibleColumnCount = 2
 
const double kHorizontalGapMergeFraction = 0.5
 
const double kMinGutterWidthGrid = 0.5
 
const double kMaxDistToPartSizeRatio = 1.5
 
bool textord_tabfind_show_initial_partitions = false
 
bool textord_tabfind_show_reject_blobs = false
 
int textord_tabfind_show_partitions = 0
 
bool textord_tabfind_show_columns = false
 
bool textord_tabfind_show_blocks = false
 
bool textord_tabfind_find_tables = true
 
const double kMaxSpacingDrift = 1.0 / 72
 
const double kMaxTopSpacingFraction = 0.25
 
const double kMaxSameBlockLineSpacing = 3
 
const double kMaxSizeRatio = 1.5
 
const double kMaxLeaderGapFractionOfMax = 0.25
 
const double kMaxLeaderGapFractionOfMin = 0.5
 
const int kMinLeaderCount = 5
 
const int kMinStrongTextValue = 6
 
const int kMinChainTextValue = 3
 
const int kHorzStrongTextlineCount = 8
 
const int kHorzStrongTextlineHeight = 10
 
const int kHorzStrongTextlineAspect = 5
 
const double kMaxBaselineError = 0.4375
 
const double kMinBaselineCoverage = 0.5
 
const int kMaxRMSColorNoise = 128
 
const int kMaxColorDistance = 900
 
const int kRGBRMSColors = 4
 
bool textord_tabfind_show_color_fit = false
 
const int kMaxPadFactor = 6
 
const int kMaxNeighbourDistFactor = 4
 
const int kMaxCaptionLines = 7
 
const double kMinCaptionGapRatio = 2.0
 
const double kMinCaptionGapHeightRatio = 0.5
 
const double kMarginOverlapFraction = 0.25
 
const double kBigPartSizeRatio = 1.75
 
const double kTinyEnoughTextlineOverlapFraction = 0.25
 
const double kMaxPartitionSpacing = 1.75
 
const int kSmoothDecisionMargin = 4
 
const double kMinColumnWidth = 2.0 / 3
 
const double kMinRectangularFraction = 0.125
 
const double kMaxRectangularFraction = 0.75
 
const double kMaxRectangularGradient = 0.1
 
const int kMinImageFindSize = 100
 
const double kRMSFitScaling = 8.0
 
const int kMinColorDifference = 16
 
const int kThinLineFraction = 20
 Denominator of resolution makes max pixel width to allow thin lines. More...
 
const int kMinLineLengthFraction = 4
 Denominator of resolution makes min pixels to demand line lengths to be. More...
 
const int kCrackSpacing = 100
 Spacing of cracks across the page to break up tall vertical lines. More...
 
const int kLineFindGridSize = 50
 Grid size used by line finder. Not very critical. More...
 
const int kMinThickLineWidth = 12
 
const int kMaxLineResidue = 6
 
const double kThickLengthMultiple = 0.75
 
const double kMaxNonLineDensity = 0.25
 
const double kMaxStaveHeight = 1.0
 
const double kMinMusicPixelFraction = 0.75
 
int textord_tabfind_show_strokewidths = 0
 
bool textord_tabfind_only_strokewidths = false
 
const double kStrokeWidthFractionTolerance = 0.125
 
const double kStrokeWidthTolerance = 1.5
 
const double kStrokeWidthFractionCJK = 0.25
 
const double kStrokeWidthCJK = 2.0
 
const int kCJKRadius = 2
 
const double kCJKBrokenDistanceFraction = 0.25
 
const int kCJKMaxComponents = 8
 
const double kCJKAspectRatio = 1.25
 
const double kCJKAspectRatioIncrease = 1.0625
 
const int kMaxCJKSizeRatio = 5
 
const double kBrokenCJKIterationFraction = 0.125
 
const double kDiacriticXPadRatio = 7.0
 
const double kDiacriticYPadRatio = 1.75
 
const double kMinDiacriticSizeRatio = 1.0625
 
const double kMaxDiacriticDistanceRatio = 1.25
 
const double kMaxDiacriticGapToBaseCharHeight = 1.0
 
const int kLineTrapLongest = 4
 
const int kLineTrapShortest = 2
 
const int kMostlyOneDirRatio = 3
 
const double kLineResidueAspectRatio = 8.0
 
const int kLineResiduePadRatio = 3
 
const double kLineResidueSizeRatio = 1.75
 
const float kSizeRatioToReject = 2.0
 
const double kNeighbourSearchFactor = 2.5
 
const double kNoiseOverlapGrowthFactor = 4.0
 
const double kNoiseOverlapAreaFactor = 1.0 / 512
 
const int kTabRadiusFactor = 5
 
const int kMinVerticalSearch = 3
 
const int kMaxVerticalSearch = 12
 
const int kMaxRaggedSearch = 25
 
const int kMinLinesInColumn = 10
 
const double kMinFractionalLinesInColumn = 0.125
 
const double kMaxGutterWidthAbsolute = 2.00
 
const int kRaggedGutterMultiple = 5
 
const double kLineFragmentAspectRatio = 10.0
 
const int kMinEvaluatedTabs = 3
 
const double kCosMaxSkewAngle = 0.866025
 
bool textord_tabfind_show_initialtabs = false
 
bool textord_tabfind_show_finaltabs = false
 
const int kColumnWidthFactor = 20
 
const int kMaxVerticalSpacing = 500
 
const int kMaxBlobWidth = 500
 
const double kSplitPartitionSize = 2.0
 
const double kAllowTextHeight = 0.5
 
const double kAllowTextWidth = 0.6
 
const double kAllowTextArea = 0.8
 
const double kAllowBlobHeight = 0.3
 
const double kAllowBlobWidth = 0.4
 
const double kAllowBlobArea = 0.05
 
const int kMinBoxesInTextPartition = 10
 
const int kMaxBoxesInDataPartition = 20
 
const double kMaxGapInTextPartition = 4.0
 
const double kMinMaxGapInTextPartition = 0.5
 
const double kMaxBlobOverlapFactor = 4.0
 
const double kMaxTableCellXheight = 2.0
 
const int kMaxColumnHeaderDistance = 4
 
const double kTableColumnThreshold = 3.0
 
const int kRulingVerticalMargin = 3
 
const double kMinOverlapWithTable = 0.6
 
const int kSideSpaceMargin = 10
 
const double kSmallTableProjectionThreshold = 0.35
 
const double kLargeTableProjectionThreshold = 0.45
 
const int kLargeTableRowCount = 6
 
const int kMinRowsInTable = 3
 
const int kAdjacentLeaderSearchPadding = 2
 
const double kParagraphEndingPreviousLineRatio = 1.3
 
const double kMaxParagraphEndingLeftSpaceMultiple = 3.0
 
const double kMinParagraphEndingTextToWhitespaceRatio = 3.0
 
const double kMaxXProjectionGapFactor = 2.0
 
const double kStrokeWidthFractionalTolerance = 0.25
 
const double kStrokeWidthConstantTolerance = 2.0
 
bool textord_show_tables = false
 
bool textord_tablefind_show_mark = false
 
bool textord_tablefind_show_stats = false
 
bool textord_tablefind_recognize_tables = false
 
const double kHorizontalSpacing = 0.30
 
const double kVerticalSpacing = -0.2
 
const int kCellSplitRowThreshold = 0
 
const int kCellSplitColumnThreshold = 0
 
const int kLinedTableMinVerticalLines = 3
 
const int kLinedTableMinHorizontalLines = 3
 
const double kRequiredColumns = 0.7
 
const double kMarginFactor = 1.1
 
const double kMaxRowSize = 2.5
 
const double kGoodRowNumberOfColumnsSmall [] = { 2, 2, 2, 2, 2, 3, 3 }
 
const int kGoodRowNumberOfColumnsSmallSize
 
const double kGoodRowNumberOfColumnsLarge = 0.7
 
const double kMinFilledArea = 0.35
 
const int kGutterMultiple = 4
 
const int kGutterToNeighbourRatio = 3
 
const int kSimilarVectorDist = 10
 
const int kSimilarRaggedDist = 50
 
const int kMaxFillinMultiple = 11
 
const double kMinGutterFraction = 0.5
 
const double kLineCountReciprocal = 4.0
 
const double kMinAlignedGutter = 0.25
 
const double kMinRaggedGutter = 1.5
 
double textord_tabvector_vertical_gap_fraction = 0.5
 
double textord_tabvector_vertical_box_ratio = 0.5
 
const char * kAlignmentNames []
 
const int kMaxLineLength = 1024
 
const float kRotationRange = 0.02f
 
const int kExposureFactor = 16
 
const int kSaltnPepper = 5
 
const int kMinRampSize = 1000
 
const int kMinLigature = 0xfb00
 
const int kMaxLigature = 0xfb17
 
const int kDefaultResolution = 300
 

Detailed Description

Make a word from the selected blobs and run Tess on them.

Parameters
page_resrecognise blobs
selection_boxwithin this box

fp_eval_word_spacing() Evaluation function for fixed pitch word lists.

Basically, count the number of "nice" characters - those which are in tess acceptable words or in dict words and are not rejected. Penalise any potential noise chars

build_menu()

Construct the menu tree used by the command window

process_cmd_win_event()

Process a command returned from the command window (Just call the appropriate command handler)

word_blank_and_set_display() Word processor

Blank display of word then redisplay word according to current display mode settings


Public Function Prototypes


Include Files and Type Defines

Typedef Documentation

◆ BlobGridSearch

using tesseract::BlobGridSearch = typedef GridSearch<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT>

Definition at line 31 of file blobgrid.h.

◆ char32

using tesseract::char32 = typedef signed int

Definition at line 52 of file unichar.h.

◆ CheckPointReader

Definition at line 69 of file lstmtrainer.h.

◆ CheckPointWriter

Definition at line 78 of file lstmtrainer.h.

◆ ColPartitionGridSearch

using tesseract::ColPartitionGridSearch = typedef GridSearch<ColPartition, ColPartition_CLIST, ColPartition_C_IT>

Definition at line 936 of file colpartition.h.

◆ ColSegmentGrid

using tesseract::ColSegmentGrid = typedef BBGrid<ColSegment, ColSegment_CLIST, ColSegment_C_IT>

Definition at line 118 of file tablefind.h.

◆ ColSegmentGridSearch

using tesseract::ColSegmentGridSearch = typedef GridSearch<ColSegment, ColSegment_CLIST, ColSegment_C_IT>

Definition at line 121 of file tablefind.h.

◆ DawgVector

Definition at line 50 of file dict.h.

◆ DictFunc

typedef int(Dict::* tesseract::DictFunc) (void *void_dawg_args, const UNICHARSET &unicharset, UNICHAR_ID unichar_id, bool word_end) const

Definition at line 76 of file baseapi.h.

◆ FileReader

typedef bool(* tesseract::FileReader)(const STRING &filename, GenericVector< char > *data)

Definition at line 360 of file genericvector.h.

◆ FileWriter

typedef bool(* tesseract::FileWriter)(const GenericVector< char > &data, const STRING &filename)

Definition at line 363 of file genericvector.h.

◆ FillLatticeFunc

typedef void(Wordrec::* tesseract::FillLatticeFunc) (const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)

Definition at line 86 of file baseapi.h.

◆ IntKDPair

using tesseract::IntKDPair = typedef KDPairInc<int, int>

Definition at line 179 of file kdpair.h.

◆ LanguageModelFlagsType

using tesseract::LanguageModelFlagsType = typedef unsigned char

Used for expressing various language model flags.

Definition at line 39 of file lm_state.h.

◆ LigHash

using tesseract::LigHash = typedef std::unordered_map<std::string, std::string, StringHash>

Definition at line 36 of file ligature_table.h.

◆ NodeChildVector

Definition at line 68 of file dawg.h.

◆ PainPointHeap

Definition at line 38 of file lm_pain_points.h.

◆ ParamsModelClassifyFunc

typedef float(Dict::* tesseract::ParamsModelClassifyFunc) (const char *lang, void *path)

Definition at line 84 of file baseapi.h.

◆ ParamsTrainingHypothesisList

◆ PartSetVector

Definition at line 34 of file colpartitionset.h.

◆ ProbabilityInContextFunc

typedef double(Dict::* tesseract::ProbabilityInContextFunc) (const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)

Definition at line 79 of file baseapi.h.

◆ RecodeHeap

Definition at line 176 of file recodebeam.h.

◆ RecodePair

using tesseract::RecodePair = typedef KDPairInc<double, RecodeNode>

Definition at line 175 of file recodebeam.h.

◆ RSCounts

using tesseract::RSCounts = typedef std::unordered_map<int, int>

Definition at line 49 of file unicharcompress.cpp.

◆ RSMap

using tesseract::RSMap = typedef std::unordered_map<int, std::unique_ptr<std::vector<int> >>

Definition at line 47 of file unicharcompress.cpp.

◆ SetOfModels

Definition at line 99 of file paragraphs_internal.h.

◆ ShapeQueue

Definition at line 156 of file shapetable.h.

◆ SuccessorList

Definition at line 69 of file dawg.h.

◆ SuccessorListsVector

Definition at line 70 of file dawg.h.

◆ TestCallback

typedef TessResultCallback4<STRING, int, const double*, const TessdataManager&, int>* tesseract::TestCallback

Definition at line 83 of file lstmtrainer.h.

◆ TruthCallback

Definition at line 91 of file baseapi.h.

◆ UnicharAmbigsVector

using tesseract::UnicharAmbigsVector = typedef GenericVector<AmbigSpec_LIST *>

Definition at line 141 of file ambigs.h.

◆ UnicharIdVector

Definition at line 34 of file ambigs.h.

◆ WidthCallback

using tesseract::WidthCallback = typedef TessResultCallback1<bool, int>

Definition at line 36 of file tabfind.h.

◆ WordGrid

using tesseract::WordGrid = typedef BBGrid<WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT>

Definition at line 65 of file textord.h.

◆ WordRecognizer

typedef void(Tesseract::* tesseract::WordRecognizer) (const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)

Definition at line 169 of file tesseractclass.h.

◆ WordSearch

using tesseract::WordSearch = typedef GridSearch<WordWithBox, WordWithBox_CLIST, WordWithBox_C_IT>

Definition at line 66 of file textord.h.

Enumeration Type Documentation

◆ AmbigType

Enumerator
NOT_AMBIG 
REPLACE_AMBIG 
DEFINITE_AMBIG 
SIMILAR_AMBIG 
CASE_AMBIG 
AMBIG_TYPE_COUNT 

Definition at line 44 of file ambigs.h.

44  {
45  NOT_AMBIG, // the ngram pair is not ambiguous
46  REPLACE_AMBIG, // ocred ngram should always be substituted with correct
47  DEFINITE_AMBIG, // add correct ngram to the classifier results (1-1)
48  SIMILAR_AMBIG, // use pairwise classifier for ocred/correct pair (1-1)
49  CASE_AMBIG, // this is a case ambiguity (1-1)
50 
51  AMBIG_TYPE_COUNT // number of enum entries
52 };

◆ CachingStrategy

Enumerator
CS_SEQUENTIAL 
CS_ROUND_ROBIN 

Definition at line 42 of file imagedata.h.

42  {
43  // Reads all of one file before moving on to the next. Requires samples to be
44  // shuffled across files. Uses the count of samples in the first file as
45  // the count in all the files to achieve high-speed random access. As a
46  // consequence, if subsequent files are smaller, they get entries used more
47  // than once, and if subsequent files are larger, some entries are not used.
48  // Best for larger data sets that don't fit in memory.
50  // Reads one sample from each file in rotation. Does not require shuffled
51  // samples, but is extremely disk-intensive. Samples in smaller files also
52  // get used more often than samples in larger files.
53  // Best for smaller data sets that mostly fit in memory.
55 };

◆ CharSegmentationType

Enumerator
CST_FRAGMENT 
CST_WHOLE 
CST_IMPROPER 
CST_NGRAM 

Definition at line 96 of file classify.h.

96  {
97  CST_FRAGMENT, // A partial character.
98  CST_WHOLE, // A correctly segmented character.
99  CST_IMPROPER, // More than one but less than 2 characters.
100  CST_NGRAM // Multiple characters.
101 };

◆ CMD_EVENTS

Enumerator
ACTION_1_CMD_EVENT 
RECOG_WERDS 
RECOG_PSEUDO 
ACTION_2_CMD_EVENT 

Definition at line 481 of file tessedit.cpp.

◆ ColSegType

Enumerator
COL_UNKNOWN 
COL_TEXT 
COL_TABLE 
COL_MIXED 
COL_COUNT 

Definition at line 30 of file tablefind.h.

◆ ColumnSpanningType

Enumerator
CST_NOISE 
CST_FLOWING 
CST_HEADING 
CST_PULLOUT 
CST_COUNT 

Definition at line 48 of file colpartition.h.

48  {
49  CST_NOISE, // Strictly between columns.
50  CST_FLOWING, // Strictly within a single column.
51  CST_HEADING, // Spans multiple columns.
52  CST_PULLOUT, // Touches multiple columns, but doesn't span them.
53  CST_COUNT // Number of entries.
54 };

◆ CountTypes

Enumerator
CT_UNICHAR_TOP_OK 
CT_UNICHAR_TOP1_ERR 
CT_UNICHAR_TOP2_ERR 
CT_UNICHAR_TOPN_ERR 
CT_UNICHAR_TOPTOP_ERR 
CT_OK_MULTI_UNICHAR 
CT_OK_JOINED 
CT_OK_BROKEN 
CT_REJECT 
CT_FONT_ATTR_ERR 
CT_OK_MULTI_FONT 
CT_NUM_RESULTS 
CT_RANK 
CT_REJECTED_JUNK 
CT_ACCEPTED_JUNK 
CT_SIZE 

Definition at line 69 of file errorcounter.h.

69  {
70  CT_UNICHAR_TOP_OK, // Top shape contains correct unichar id.
71  // The rank of the results in TOP1, TOP2, TOPN is determined by a gap of
72  // kRatingEpsilon from the first result in each group. The real top choice
73  // is measured using TOPTOP.
74  CT_UNICHAR_TOP1_ERR, // Top shape does not contain correct unichar id.
75  CT_UNICHAR_TOP2_ERR, // Top 2 shapes don't contain correct unichar id.
76  CT_UNICHAR_TOPN_ERR, // No output shape contains correct unichar id.
77  CT_UNICHAR_TOPTOP_ERR, // Very top choice not correct.
78  CT_OK_MULTI_UNICHAR, // Top shape id has correct unichar id, and others.
79  CT_OK_JOINED, // Top shape id is correct but marked joined.
80  CT_OK_BROKEN, // Top shape id is correct but marked broken.
81  CT_REJECT, // Classifier hates this.
82  CT_FONT_ATTR_ERR, // Top unichar OK, but font attributes incorrect.
83  CT_OK_MULTI_FONT, // CT_FONT_ATTR_OK but there are multiple font attrs.
84  CT_NUM_RESULTS, // Number of answers produced.
85  CT_RANK, // Rank of correct answer.
86  CT_REJECTED_JUNK, // Junk that was correctly rejected.
87  CT_ACCEPTED_JUNK, // Junk that was incorrectly classified otherwise.
88 
89  CT_SIZE // Number of types for array sizing.
90 };

◆ DawgType

Enumerator
DAWG_TYPE_PUNCTUATION 
DAWG_TYPE_WORD 
DAWG_TYPE_NUMBER 
DAWG_TYPE_PATTERN 
DAWG_TYPE_COUNT 

Definition at line 72 of file dawg.h.

◆ ErrorTypes

Enumerator
ET_RMS 
ET_DELTA 
ET_WORD_RECERR 
ET_CHAR_ERROR 
ET_SKIP_RATIO 
ET_COUNT 

Definition at line 37 of file lstmtrainer.h.

37  {
38  ET_RMS, // RMS activation error.
39  ET_DELTA, // Number of big errors in deltas.
40  ET_WORD_RECERR, // Output text string word recall error.
41  ET_CHAR_ERROR, // Output text string total char error.
42  ET_SKIP_RATIO, // Fraction of samples skipped.
43  ET_COUNT // For array sizing.
44 };

◆ FactorNames

Enumerator
FN_INCOLOR 
FN_Y0 
FN_Y1 
FN_Y2 
FN_Y3 
FN_X0 
FN_X1 
FN_SHEAR 
FN_NUM_FACTORS 

Definition at line 41 of file degradeimage.cpp.

◆ FlexDimensions

Enumerator
FD_BATCH 
FD_HEIGHT 
FD_WIDTH 
FD_DIMSIZE 

Definition at line 34 of file stridemap.h.

34  {
35  FD_BATCH, // Index of multiple images.
36  FD_HEIGHT, // y-coordinate in image.
37  FD_WIDTH, // x-coordinate in image.
38  FD_DIMSIZE, // Number of flexible non-depth dimensions.
39 };

◆ GraphemeNorm

Enumerator
kNone 
kNormalize 

Definition at line 49 of file normstrngs.h.

◆ GraphemeNormMode

Enumerator
kSingleString 
kCombined 
kGlyphSplit 
kIndividualUnicodes 

Definition at line 34 of file validator.h.

34  {
35  // Validation result is a single string, even if input is multi-word.
37  // Standard unicode graphemes are validated and output as grapheme units.
38  kCombined,
39  // Graphemes are validated and sub-divided. For virama-using scripts, units
40  // that correspond to repeatable glyphs are generated. (Mostly single unicodes
41  // but viramas and joiners are paired with the most sensible neighbor.)
42  // For non-virama scripts, this means that base/accent pairs are separated,
43  // ie the output is individual unicodes.
45  // The output is always single unicodes, regardless of the script.
47 };

◆ kParamsTrainingFeatureType

Enumerator
PTRAIN_DIGITS_SHORT 
PTRAIN_DIGITS_MED 
PTRAIN_DIGITS_LONG 
PTRAIN_NUM_SHORT 
PTRAIN_NUM_MED 
PTRAIN_NUM_LONG 
PTRAIN_DOC_SHORT 
PTRAIN_DOC_MED 
PTRAIN_DOC_LONG 
PTRAIN_DICT_SHORT 
PTRAIN_DICT_MED 
PTRAIN_DICT_LONG 
PTRAIN_FREQ_SHORT 
PTRAIN_FREQ_MED 
PTRAIN_FREQ_LONG 
PTRAIN_SHAPE_COST_PER_CHAR 
PTRAIN_NGRAM_COST_PER_CHAR 
PTRAIN_NUM_BAD_PUNC 
PTRAIN_NUM_BAD_CASE 
PTRAIN_XHEIGHT_CONSISTENCY 
PTRAIN_NUM_BAD_CHAR_TYPE 
PTRAIN_NUM_BAD_SPACING 
PTRAIN_NUM_BAD_FONT 
PTRAIN_RATING_PER_CHAR 
PTRAIN_NUM_FEATURE_TYPES 

Definition at line 39 of file params_training_featdef.h.

39  {
40  // Digits
42  PTRAIN_DIGITS_MED, // 1
43  PTRAIN_DIGITS_LONG, // 2
44  // Number or pattern (NUMBER_PERM, USER_PATTERN_PERM)
45  PTRAIN_NUM_SHORT, // 3
46  PTRAIN_NUM_MED, // 4
47  PTRAIN_NUM_LONG, // 5
48  // Document word (DOC_DAWG_PERM)
49  PTRAIN_DOC_SHORT, // 6
50  PTRAIN_DOC_MED, // 7
51  PTRAIN_DOC_LONG, // 8
52  // Word (SYSTEM_DAWG_PERM, USER_DAWG_PERM, COMPOUND_PERM)
53  PTRAIN_DICT_SHORT, // 9
54  PTRAIN_DICT_MED, // 10
55  PTRAIN_DICT_LONG, // 11
56  // Frequent word (FREQ_DAWG_PERM)
57  PTRAIN_FREQ_SHORT, // 12
58  PTRAIN_FREQ_MED, // 13
59  PTRAIN_FREQ_LONG, // 14
62  PTRAIN_NUM_BAD_PUNC, // 17
63  PTRAIN_NUM_BAD_CASE, // 18
67  PTRAIN_NUM_BAD_FONT, // 22
69 
71 };

◆ LeftOrRight

Enumerator
LR_LEFT 
LR_RIGHT 

Definition at line 39 of file strokewidth.h.

◆ LineType

Enumerator
LT_START 
LT_BODY 
LT_UNKNOWN 
LT_MULTIPLE 

Definition at line 50 of file paragraphs_internal.h.

50  {
51  LT_START = 'S', // First line of a paragraph.
52  LT_BODY = 'C', // Continuation line of a paragraph.
53  LT_UNKNOWN = 'U', // No clues.
54  LT_MULTIPLE = 'M', // Matches for both LT_START and LT_BODY.
55 };

◆ LMPainPointsType

Enumerator
LM_PPTYPE_BLAMER 
LM_PPTYPE_AMBIG 
LM_PPTYPE_PATH 
LM_PPTYPE_SHAPE 
LM_PPTYPE_NUM 

Definition at line 41 of file lm_pain_points.h.

◆ LossType

Enumerator
LT_NONE 
LT_CTC 
LT_SOFTMAX 
LT_LOGISTIC 

Definition at line 29 of file static_shape.h.

29  {
30  LT_NONE, // Undefined.
31  LT_CTC, // Softmax with standard CTC for training/decoding.
32  LT_SOFTMAX, // Outputs sum to 1 in fixed positions.
33  LT_LOGISTIC, // Logistic outputs with independent values.
34 };

◆ NeighbourPartitionType

Enumerator
NPT_HTEXT 
NPT_VTEXT 
NPT_WEAK_HTEXT 
NPT_WEAK_VTEXT 
NPT_IMAGE 
NPT_COUNT 

Definition at line 1508 of file colpartitiongrid.cpp.

1508  {
1509  NPT_HTEXT, // Definite horizontal text.
1510  NPT_VTEXT, // Definite vertical text.
1511  NPT_WEAK_HTEXT, // Weakly horizontal text. Counts as HTEXT for HTEXT, but
1512  // image for image and VTEXT.
1513  NPT_WEAK_VTEXT, // Weakly vertical text. Counts as VTEXT for VTEXT, but
1514  // image for image and HTEXT.
1515  NPT_IMAGE, // Defininte non-text.
1516  NPT_COUNT // Number of array elements.
1517 };

◆ NetworkFlags

Enumerator
NF_LAYER_SPECIFIC_LR 
NF_ADAM 

Definition at line 85 of file network.h.

85  {
86  // Network forward/backprop behavior.
87  NF_LAYER_SPECIFIC_LR = 64, // Separate learning rate for each layer.
88  NF_ADAM = 128, // Weight-specific learning rate.
89 };

◆ NetworkType

Enumerator
NT_NONE 
NT_INPUT 
NT_CONVOLVE 
NT_MAXPOOL 
NT_PARALLEL 
NT_REPLICATED 
NT_PAR_RL_LSTM 
NT_PAR_UD_LSTM 
NT_PAR_2D_LSTM 
NT_SERIES 
NT_RECONFIG 
NT_XREVERSED 
NT_YREVERSED 
NT_XYTRANSPOSE 
NT_LSTM 
NT_LSTM_SUMMARY 
NT_LOGISTIC 
NT_POSCLIP 
NT_SYMCLIP 
NT_TANH 
NT_RELU 
NT_LINEAR 
NT_SOFTMAX 
NT_SOFTMAX_NO_CTC 
NT_LSTM_SOFTMAX 
NT_LSTM_SOFTMAX_ENCODED 
NT_TENSORFLOW 
NT_COUNT 

Definition at line 43 of file network.h.

43  {
44  NT_NONE, // The naked base class.
45  NT_INPUT, // Inputs from an image.
46  // Plumbing networks combine other networks or rearrange the inputs.
47  NT_CONVOLVE, // Duplicates inputs in a sliding window neighborhood.
48  NT_MAXPOOL, // Chooses the max result from a rectangle.
49  NT_PARALLEL, // Runs networks in parallel.
50  NT_REPLICATED, // Runs identical networks in parallel.
51  NT_PAR_RL_LSTM, // Runs LTR and RTL LSTMs in parallel.
52  NT_PAR_UD_LSTM, // Runs Up and Down LSTMs in parallel.
53  NT_PAR_2D_LSTM, // Runs 4 LSTMs in parallel.
54  NT_SERIES, // Executes a sequence of layers.
55  NT_RECONFIG, // Scales the time/y size but makes the output deeper.
56  NT_XREVERSED, // Reverses the x direction of the inputs/outputs.
57  NT_YREVERSED, // Reverses the y-direction of the inputs/outputs.
58  NT_XYTRANSPOSE, // Transposes x and y (for just a single op).
59  // Functional networks actually calculate stuff.
60  NT_LSTM, // Long-Short-Term-Memory block.
61  NT_LSTM_SUMMARY, // LSTM that only keeps its last output.
62  NT_LOGISTIC, // Fully connected logistic nonlinearity.
63  NT_POSCLIP, // Fully connected rect lin version of logistic.
64  NT_SYMCLIP, // Fully connected rect lin version of tanh.
65  NT_TANH, // Fully connected with tanh nonlinearity.
66  NT_RELU, // Fully connected with rectifier nonlinearity.
67  NT_LINEAR, // Fully connected with no nonlinearity.
68  NT_SOFTMAX, // Softmax uses exponential normalization, with CTC.
69  NT_SOFTMAX_NO_CTC, // Softmax uses exponential normalization, no CTC.
70  // The SOFTMAX LSTMs both have an extra softmax layer on top, but inside, with
71  // the outputs fed back to the input of the LSTM at the next timestep.
72  // The ENCODED version binary encodes the softmax outputs, providing log2 of
73  // the number of outputs as additional inputs, and the other version just
74  // provides all the softmax outputs as additional inputs.
75  NT_LSTM_SOFTMAX, // 1-d LSTM with built-in fully connected softmax.
76  NT_LSTM_SOFTMAX_ENCODED, // 1-d LSTM with built-in binary encoded softmax.
77  // A TensorFlow graph encapsulated as a Tesseract network.
79 
80  NT_COUNT // Array size.
81 };

◆ NodeContinuation

Enumerator
NC_ANYTHING 
NC_ONLY_DUP 
NC_NO_DUP 
NC_COUNT 

Definition at line 72 of file recodebeam.h.

72  {
73  NC_ANYTHING, // This node used just its own score, so anything can follow.
74  NC_ONLY_DUP, // The current node combined another score with the score for
75  // itself, without a stand-alone duplicate before, so must be
76  // followed by a stand-alone duplicate.
77  NC_NO_DUP, // The current node combined another score with the score for
78  // itself, after a stand-alone, so can only be followed by
79  // something other than a duplicate of the current node.
80  NC_COUNT
81 };

◆ NormalizationMode

Enumerator
NM_BASELINE 
NM_CHAR_ISOTROPIC 
NM_CHAR_ANISOTROPIC 

Definition at line 42 of file normalis.h.

42  {
43  NM_BASELINE = -3, // The original BL normalization mode.
44  NM_CHAR_ISOTROPIC = -2, // Character normalization but isotropic.
45  NM_CHAR_ANISOTROPIC = -1 // The original CN normalization mode.
46 };

◆ OcrEngineMode

When Tesseract/Cube is initialized we can choose to instantiate/load/run only the Tesseract part, only the Cube part or both along with the combiner. The preference of which engine to use is stored in tessedit_ocr_engine_mode.

ATTENTION: When modifying this enum, please make sure to make the appropriate changes to all the enums mirroring it (e.g. OCREngine in cityblock/workflow/detection/detection_storage.proto). Such enums will mention the connection to OcrEngineMode in the comments.

Enumerator
OEM_TESSERACT_ONLY 
OEM_LSTM_ONLY 
OEM_TESSERACT_LSTM_COMBINED 
OEM_DEFAULT 
OEM_COUNT 

Definition at line 268 of file publictypes.h.

268  {
269  OEM_TESSERACT_ONLY, // Run Tesseract only - fastest; deprecated
270  OEM_LSTM_ONLY, // Run just the LSTM line recognizer.
271  OEM_TESSERACT_LSTM_COMBINED, // Run the LSTM recognizer, but allow fallback
272  // to Tesseract when things get difficult.
273  // deprecated
274  OEM_DEFAULT, // Specify this mode when calling init_*(),
275  // to indicate that any of the above modes
276  // should be automatically inferred from the
277  // variables in the language-specific config,
278  // command-line configs, or if not specified
279  // in any of the above should be set to the
280  // default OEM_TESSERACT_ONLY.
281  OEM_COUNT // Number of OEMs
282 };

◆ OCRNorm

enum tesseract::OCRNorm
strong
Enumerator
kNone 
kNormalize 

Definition at line 41 of file normstrngs.h.

◆ Orientation

+---------------—+ Orientation Example: | 1 Aaaa Aaaa Aaaa | ==================== | Aaa aa aaa aa | To left is a diagram of some (1) English and | aaaaaa A aa aaa. | (2) Chinese text and a (3) photo credit. | 2 | | ####### c c C | Upright Latin characters are represented as A and a. | ####### c c c | '<' represents a latin character rotated | < ####### c c c | anti-clockwise 90 degrees. | < ####### c c | | < ####### . c | Upright Chinese characters are represented C and c. | 3 ####### c | +---------------—+ NOTA BENE: enum values here should match goodoc.proto

If you orient your head so that "up" aligns with Orientation, then the characters will appear "right side up" and readable.

In the example above, both the English and Chinese paragraphs are oriented so their "up" is the top of the page (page up). The photo credit is read with one's head turned leftward ("up" is to page left).

The values of this enum match the convention of Tesseract's osdetect.h

Enumerator
ORIENTATION_PAGE_UP 
ORIENTATION_PAGE_RIGHT 
ORIENTATION_PAGE_DOWN 
ORIENTATION_PAGE_LEFT 

Definition at line 120 of file publictypes.h.

◆ PageIteratorLevel

enum of the elements of the page hierarchy, used in ResultIterator to provide functions that operate on each level without having to have 5x as many functions.

Enumerator
RIL_BLOCK 
RIL_PARA 
RIL_TEXTLINE 
RIL_WORD 
RIL_SYMBOL 

Definition at line 219 of file publictypes.h.

219  {
220  RIL_BLOCK, // Block of text/image/separator line.
221  RIL_PARA, // Paragraph within a block.
222  RIL_TEXTLINE, // Line within a paragraph.
223  RIL_WORD, // Word within a textline.
224  RIL_SYMBOL // Symbol/character within a word.
225 };
Definition: capi.h:98
Definition: capi.h:98
Definition: capi.h:98

◆ PageSegMode

Possible modes for page layout analysis. These must be kept in order of decreasing amount of layout analysis to be done, except for OSD_ONLY, so that the inequality test macros below work.

Enumerator
PSM_OSD_ONLY 

Orientation and script detection only.

PSM_AUTO_OSD 

Automatic page segmentation with orientation and script detection. (OSD)

PSM_AUTO_ONLY 

Automatic page segmentation, but no OSD, or OCR.

PSM_AUTO 

Fully automatic page segmentation, but no OSD.

PSM_SINGLE_COLUMN 

Assume a single column of text of variable sizes.

PSM_SINGLE_BLOCK_VERT_TEXT 

Assume a single uniform block of vertically aligned text.

PSM_SINGLE_BLOCK 

Assume a single uniform block of text. (Default.)

PSM_SINGLE_LINE 

Treat the image as a single text line.

PSM_SINGLE_WORD 

Treat the image as a single word.

PSM_CIRCLE_WORD 

Treat the image as a single word in a circle.

PSM_SINGLE_CHAR 

Treat the image as a single character.

PSM_SPARSE_TEXT 

Find as much text as possible in no particular order.

PSM_SPARSE_TEXT_OSD 

Sparse text with orientation and script det.

PSM_RAW_LINE 

Treat the image as a single text line, bypassing hacks that are Tesseract-specific.

PSM_COUNT 

Number of enum entries.

Definition at line 163 of file publictypes.h.

◆ ParagraphJustification

JUSTIFICATION_UNKNOWN The alignment is not clearly one of the other options. This could happen for example if there are only one or two lines of text or the text looks like source code or poetry.

NOTA BENE: Fully justified paragraphs (text aligned to both left and right margins) are marked by Tesseract with JUSTIFICATION_LEFT if their text is written with a left-to-right script and with JUSTIFICATION_RIGHT if their text is written in a right-to-left script.

Interpretation for text read in vertical lines: "Left" is wherever the starting reading position is.

JUSTIFICATION_LEFT Each line, except possibly the first, is flush to the same left tab stop.

JUSTIFICATION_CENTER The text lines of the paragraph are centered about a line going down through their middle of the text lines.

JUSTIFICATION_RIGHT Each line, except possibly the first, is flush to the same right tab stop.

Enumerator
JUSTIFICATION_UNKNOWN 
JUSTIFICATION_LEFT 
JUSTIFICATION_CENTER 
JUSTIFICATION_RIGHT 

Definition at line 251 of file publictypes.h.

◆ PartitionFindResult

Enumerator
PFR_OK 
PFR_SKEW 
PFR_NOISE 

Definition at line 46 of file strokewidth.h.

46  {
47  PFR_OK, // Everything is OK.
48  PFR_SKEW, // Skew was detected and rotated.
49  PFR_NOISE // Noise was detected and removed.
50 };

◆ ScriptPos

Enumerator
SP_NORMAL 
SP_SUBSCRIPT 
SP_SUPERSCRIPT 
SP_DROPCAP 

Definition at line 262 of file ratngs.h.

◆ SerializeAmount

Enumerator
LIGHT 
NO_BEST_TRAINER 
FULL 

Definition at line 56 of file lstmtrainer.h.

56  {
57  LIGHT, // Minimal data for remote training.
58  NO_BEST_TRAINER, // Save an empty vector in place of best_trainer_.
59  FULL, // All data including best_trainer_.
60 };

◆ SetParamConstraint

Enumerator
SET_PARAM_CONSTRAINT_NONE 
SET_PARAM_CONSTRAINT_DEBUG_ONLY 
SET_PARAM_CONSTRAINT_NON_DEBUG_ONLY 
SET_PARAM_CONSTRAINT_NON_INIT_ONLY 

Definition at line 36 of file params.h.

◆ SubTrainerResult

Enumerator
STR_NONE 
STR_UPDATED 
STR_REPLACED 

Definition at line 63 of file lstmtrainer.h.

63  {
64  STR_NONE, // Did nothing as not good enough.
65  STR_UPDATED, // Subtrainer was updated, but didn't replace *this.
66  STR_REPLACED // Subtrainer replaced *this.
67 };

◆ TabAlignment

Enumerator
TA_LEFT_ALIGNED 
TA_LEFT_RAGGED 
TA_CENTER_JUSTIFIED 
TA_RIGHT_ALIGNED 
TA_RIGHT_RAGGED 
TA_SEPARATOR 
TA_COUNT 

Definition at line 45 of file tabvector.h.

◆ TessdataType

Enumerator
TESSDATA_LANG_CONFIG 
TESSDATA_UNICHARSET 
TESSDATA_AMBIGS 
TESSDATA_INTTEMP 
TESSDATA_PFFMTABLE 
TESSDATA_NORMPROTO 
TESSDATA_PUNC_DAWG 
TESSDATA_SYSTEM_DAWG 
TESSDATA_NUMBER_DAWG 
TESSDATA_FREQ_DAWG 
TESSDATA_FIXED_LENGTH_DAWGS 
TESSDATA_CUBE_UNICHARSET 
TESSDATA_CUBE_SYSTEM_DAWG 
TESSDATA_SHAPE_TABLE 
TESSDATA_BIGRAM_DAWG 
TESSDATA_UNAMBIG_DAWG 
TESSDATA_PARAMS_MODEL 
TESSDATA_LSTM 
TESSDATA_LSTM_PUNC_DAWG 
TESSDATA_LSTM_SYSTEM_DAWG 
TESSDATA_LSTM_NUMBER_DAWG 
TESSDATA_LSTM_UNICHARSET 
TESSDATA_LSTM_RECODER 
TESSDATA_VERSION 
TESSDATA_NUM_ENTRIES 

Definition at line 56 of file tessdatamanager.h.

56  {
59  TESSDATA_AMBIGS, // 2
60  TESSDATA_INTTEMP, // 3
61  TESSDATA_PFFMTABLE, // 4
62  TESSDATA_NORMPROTO, // 5
63  TESSDATA_PUNC_DAWG, // 6
66  TESSDATA_FREQ_DAWG, // 9
67  TESSDATA_FIXED_LENGTH_DAWGS, // 10 // deprecated
68  TESSDATA_CUBE_UNICHARSET, // 11 // deprecated
69  TESSDATA_CUBE_SYSTEM_DAWG, // 12 // deprecated
74  TESSDATA_LSTM, // 17
80  TESSDATA_VERSION, // 23
81 
83 };

◆ TextlineOrder

The text lines are read in the given sequence.

In English, the order is top-to-bottom. In Chinese, vertical text lines are read right-to-left. Mongolian is written in vertical columns top to bottom like Chinese, but the lines order left-to right.

Note that only some combinations make sense. For example, WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM

Enumerator
TEXTLINE_ORDER_LEFT_TO_RIGHT 
TEXTLINE_ORDER_RIGHT_TO_LEFT 
TEXTLINE_ORDER_TOP_TO_BOTTOM 

Definition at line 152 of file publictypes.h.

◆ TopNState

Enumerator
TN_TOP2 
TN_TOPN 
TN_ALSO_RAN 
TN_COUNT 

Definition at line 84 of file recodebeam.h.

84  {
85  TN_TOP2, // Winner or 2nd.
86  TN_TOPN, // Runner up in top-n, but not 1st or 2nd.
87  TN_ALSO_RAN, // Not in the top-n.
88  TN_COUNT
89 };

◆ Trainability

Enumerator
TRAINABLE 
PERFECT 
UNENCODABLE 
HI_PRECISION_ERR 
NOT_BOXED 

Definition at line 47 of file lstmtrainer.h.

47  {
48  TRAINABLE, // Non-zero delta error.
49  PERFECT, // Zero delta error.
50  UNENCODABLE, // Not trainable due to coding/alignment trouble.
51  HI_PRECISION_ERR, // Hi confidence disagreement.
52  NOT_BOXED, // Early in training and has no character boxes.
53 };

◆ TrainingFlags

Enumerator
TF_INT_MODE 
TF_COMPRESS_UNICHARSET 

Definition at line 46 of file lstmrecognizer.h.

◆ TrainingState

Enumerator
TS_DISABLED 
TS_ENABLED 
TS_TEMP_DISABLE 
TS_RE_ENABLE 

Definition at line 92 of file network.h.

92  {
93  // Valid states of training_.
94  TS_DISABLED, // Disabled permanently.
95  TS_ENABLED, // Enabled for backprop and to write a training dump.
96  // Re-enable from ANY disabled state.
97  TS_TEMP_DISABLE, // Temporarily disabled to write a recognition dump.
98  // Valid only for SetEnableTraining.
99  TS_RE_ENABLE, // Re-Enable from TS_TEMP_DISABLE, but not TS_DISABLED.
100 };

◆ UnicodeNormMode

Enumerator
kNFD 
kNFC 
kNFKD 
kNFKC 

Definition at line 32 of file normstrngs.h.

◆ ViramaScript

Enumerator
kNonVirama 
kDevanagari 
kBengali 
kGurmukhi 
kGujarati 
kOriya 
kTamil 
kTelugu 
kKannada 
kMalayalam 
kSinhala 
kMyanmar 
kKhmer 
kJavanese 

Definition at line 53 of file validator.h.

◆ WritingDirection

The grapheme clusters within a line of text are laid out logically in this direction, judged when looking at the text line rotated so that its Orientation is "page up".

For English text, the writing direction is left-to-right. For the Chinese text in the above example, the writing direction is top-to-bottom.

Enumerator
WRITING_DIRECTION_LEFT_TO_RIGHT 
WRITING_DIRECTION_RIGHT_TO_LEFT 
WRITING_DIRECTION_TOP_TO_BOTTOM 

Definition at line 135 of file publictypes.h.

◆ XHeightConsistencyEnum

Enumerator
XH_GOOD 
XH_SUBNORMAL 
XH_INCONSISTENT 

Definition at line 75 of file dict.h.

Function Documentation

◆ AccumulateVector()

void tesseract::AccumulateVector ( int  n,
const double *  src,
double *  dest 
)
inline

Definition at line 191 of file functions.h.

191  {
192  for (int i = 0; i < n; ++i) dest[i] += src[i];
193 }

◆ AsciiLikelyListItem()

bool tesseract::AsciiLikelyListItem ( const STRING word)

Definition at line 282 of file paragraphs.cpp.

282  {
283  return LikelyListMark(word) || LikelyListNumeral(word);
284 }

◆ assign_blobs_to_blocks2()

void tesseract::assign_blobs_to_blocks2 ( Pix *  pix,
BLOCK_LIST *  blocks,
TO_BLOCK_LIST *  port_blocks 
)

Definition at line 168 of file tordmain.cpp.

170  { // output list
171  BLOCK *block; // current block
172  BLOBNBOX *newblob; // created blob
173  C_BLOB *blob; // current blob
174  BLOCK_IT block_it = blocks;
175  C_BLOB_IT blob_it; // iterator
176  BLOBNBOX_IT port_box_it; // iterator
177  // destination iterator
178  TO_BLOCK_IT port_block_it = port_blocks;
179  TO_BLOCK *port_block; // created block
180 
181  for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
182  block = block_it.data();
183  port_block = new TO_BLOCK(block);
184 
185  // Convert the good outlines to block->blob_list
186  port_box_it.set_to_list(&port_block->blobs);
187  blob_it.set_to_list(block->blob_list());
188  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
189  blob = blob_it.extract();
190  newblob = new BLOBNBOX(blob); // Convert blob to BLOBNBOX.
191  SetBlobStrokeWidth(pix, newblob);
192  port_box_it.add_after_then_move(newblob);
193  }
194 
195  // Put the rejected outlines in block->noise_blobs, which allows them to
196  // be reconsidered and sorted back into rows and recover outlines mistakenly
197  // rejected.
198  port_box_it.set_to_list(&port_block->noise_blobs);
199  blob_it.set_to_list(block->reject_blobs());
200  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
201  blob = blob_it.extract();
202  newblob = new BLOBNBOX(blob); // Convert blob to BLOBNBOX.
203  SetBlobStrokeWidth(pix, newblob);
204  port_box_it.add_after_then_move(newblob);
205  }
206 
207  port_block_it.add_after_then_move(port_block);
208  }
209 }
C_BLOB_LIST * reject_blobs()
Definition: ocrblock.h:133
C_BLOB_LIST * blob_list()
get blobs
Definition: ocrblock.h:130
void SetBlobStrokeWidth(Pix *pix, BLOBNBOX *blob)
Definition: tordmain.cpp:69
Definition: ocrblock.h:30
BLOBNBOX_LIST blobs
Definition: blobbox.h:785
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:787

◆ BlobToTrainingSample()

TrainingSample * tesseract::BlobToTrainingSample ( const TBLOB blob,
bool  nonlinear_norm,
INT_FX_RESULT_STRUCT fx_info,
GenericVector< INT_FEATURE_STRUCT > *  bl_features 
)

Definition at line 79 of file intfx.cpp.

81  {
83  Classify::ExtractFeatures(blob, nonlinear_norm, bl_features,
84  &cn_features, fx_info, nullptr);
85  // TODO(rays) Use blob->PreciseBoundingBox() instead.
86  TBOX box = blob.bounding_box();
87  TrainingSample* sample = nullptr;
88  int num_features = fx_info->NumCN;
89  if (num_features > 0) {
90  sample = TrainingSample::CopyFromFeatures(*fx_info, box, &cn_features[0],
91  num_features);
92  }
93  if (sample != nullptr) {
94  // Set the bounding box (in original image coordinates) in the sample.
95  TPOINT topleft, botright;
96  topleft.x = box.left();
97  topleft.y = box.top();
98  botright.x = box.right();
99  botright.y = box.bottom();
100  TPOINT original_topleft, original_botright;
101  blob.denorm().DenormTransform(nullptr, topleft, &original_topleft);
102  blob.denorm().DenormTransform(nullptr, botright, &original_botright);
103  sample->set_bounding_box(TBOX(original_topleft.x, original_botright.y,
104  original_botright.x, original_topleft.y));
105  }
106  return sample;
107 }
Definition: cluster.h:32
Definition: rect.h:34
int16_t left() const
Definition: rect.h:72
void DenormTransform(const DENORM *last_denorm, const TPOINT &pt, TPOINT *original) const
Definition: normalis.cpp:390
int16_t top() const
Definition: rect.h:58
TBOX bounding_box() const
Definition: blobs.cpp:478
int16_t x
Definition: blobs.h:78
const DENORM & denorm() const
Definition: blobs.h:347
int16_t right() const
Definition: rect.h:79
int16_t NumCN
Definition: intfx.h:39
Definition: blobs.h:57
int16_t y
Definition: blobs.h:79
int16_t bottom() const
Definition: rect.h:65

◆ CanonicalizeDetectionResults()

void tesseract::CanonicalizeDetectionResults ( GenericVector< PARA *> *  row_owners,
PARA_LIST *  paragraphs 
)

Definition at line 2239 of file paragraphs.cpp.

2241  {
2242  GenericVector<PARA *> &rows = *row_owners;
2243  paragraphs->clear();
2244  PARA_IT out(paragraphs);
2245  PARA *formerly_null = nullptr;
2246  for (int i = 0; i < rows.size(); i++) {
2247  if (rows[i] == nullptr) {
2248  if (i == 0 || rows[i - 1] != formerly_null) {
2249  rows[i] = formerly_null = new PARA();
2250  } else {
2251  rows[i] = formerly_null;
2252  continue;
2253  }
2254  } else if (i > 0 && rows[i - 1] == rows[i]) {
2255  continue;
2256  }
2257  out.add_after_then_move(rows[i]);
2258  }
2259 }
int size() const
Definition: genericvector.h:71
Definition: ocrpara.h:29

◆ ClearFeatureSpaceWindow()

void tesseract::ClearFeatureSpaceWindow ( NORM_METHOD  norm_method,
ScrollView window 
)

Clears the given window and draws the featurespace guides for the appropriate normalization method.

Definition at line 998 of file intproto.cpp.

998  {
999  window->Clear();
1000 
1001  window->Pen(ScrollView::GREY);
1002  // Draw the feature space limit rectangle.
1003  window->Rectangle(0, 0, INT_MAX_X, INT_MAX_Y);
1004  if (norm_method == baseline) {
1005  window->SetCursor(0, INT_DESCENDER);
1006  window->DrawTo(INT_MAX_X, INT_DESCENDER);
1007  window->SetCursor(0, INT_BASELINE);
1008  window->DrawTo(INT_MAX_X, INT_BASELINE);
1009  window->SetCursor(0, INT_XHEIGHT);
1010  window->DrawTo(INT_MAX_X, INT_XHEIGHT);
1011  window->SetCursor(0, INT_CAPHEIGHT);
1012  window->DrawTo(INT_MAX_X, INT_CAPHEIGHT);
1013  } else {
1016  }
1017 }
void DrawTo(int x, int y)
Definition: scrollview.cpp:527
#define INT_CAPHEIGHT
Definition: intproto.cpp:54
#define INT_YRADIUS
Definition: intproto.cpp:59
#define INT_XCENTER
Definition: intproto.cpp:56
void SetCursor(int x, int y)
Definition: scrollview.cpp:521
#define INT_XRADIUS
Definition: intproto.cpp:58
#define INT_XHEIGHT
Definition: intproto.cpp:53
#define INT_YCENTER
Definition: intproto.cpp:57
#define INT_MAX_X
Definition: intproto.cpp:62
#define INT_BASELINE
Definition: intproto.cpp:52
void Clear()
Definition: scrollview.cpp:591
#define INT_DESCENDER
Definition: intproto.cpp:51
void Rectangle(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:602
void Pen(Color color)
Definition: scrollview.cpp:722
#define INT_MAX_Y
Definition: intproto.cpp:63

◆ ClipVector()

template<typename T >
void tesseract::ClipVector ( int  n,
lower,
upper,
T *  vec 
)
inline

Definition at line 225 of file functions.h.

225  {
226  for (int i = 0; i < n; ++i) vec[i] = ClipToRange(vec[i], lower, upper);
227 }
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:111

◆ cmp_eq()

template<typename T >
bool tesseract::cmp_eq ( T const &  t1,
T const &  t2 
)

Definition at line 415 of file genericvector.h.

415  {
416  return t1 == t2;
417 }

◆ CodeInBinary()

void tesseract::CodeInBinary ( int  n,
int  nf,
double *  vec 
)
inline

Definition at line 231 of file functions.h.

231  {
232  if (nf <= 0 || n < nf) return;
233  int index = 0;
234  double best_score = vec[0];
235  for (int i = 1; i < n; ++i) {
236  if (vec[i] > best_score) {
237  best_score = vec[i];
238  index = i;
239  }
240  }
241  int mask = 1;
242  for (int i = 0; i < nf; ++i, mask *= 2) {
243  vec[i] = (index & mask) ? 1.0 : 0.0;
244  }
245 }

◆ CombineLangModel()

int tesseract::CombineLangModel ( const UNICHARSET unicharset,
const std::string &  script_dir,
const std::string &  version_str,
const std::string &  output_dir,
const std::string &  lang,
bool  pass_through_recoder,
const GenericVector< STRING > &  words,
const GenericVector< STRING > &  puncs,
const GenericVector< STRING > &  numbers,
bool  lang_is_rtl,
FileReader  reader,
FileWriter  writer 
)

Definition at line 185 of file lang_model_helpers.cpp.

191  {
192  // Build the traineddata file.
193  TessdataManager traineddata;
194  if (!version_str.empty()) {
195  traineddata.SetVersionString(traineddata.VersionString() + ":" +
196  version_str);
197  }
198  // Unicharset and recoder.
199  if (!WriteUnicharset(unicharset, output_dir, lang, writer, &traineddata)) {
200  tprintf("Error writing unicharset!!\n");
201  return EXIT_FAILURE;
202  } else {
203  tprintf("Config file is optional, continuing...\n");
204  }
205  // If there is a config file, read it and add to traineddata.
206  std::string config_filename = script_dir + "/" + lang + "/" + lang + ".config";
207  STRING config_file = ReadFile(config_filename, reader);
208  if (config_file.length() > 0) {
209  traineddata.OverwriteEntry(TESSDATA_LANG_CONFIG, &config_file[0],
210  config_file.length());
211  }
212  std::string radical_filename = script_dir + "/radical-stroke.txt";
213  STRING radical_data = ReadFile(radical_filename, reader);
214  if (radical_data.length() == 0) {
215  tprintf("Error reading radical code table %s\n", radical_filename.c_str());
216  return EXIT_FAILURE;
217  }
218  if (!WriteRecoder(unicharset, pass_through_recoder, output_dir, lang, writer,
219  &radical_data, &traineddata)) {
220  tprintf("Error writing recoder!!\n");
221  }
222  if (!words.empty() || !puncs.empty() || !numbers.empty()) {
223  if (!WriteDawgs(words, puncs, numbers, lang_is_rtl, unicharset,
224  &traineddata)) {
225  tprintf("Error during conversion of wordlists to DAWGs!!\n");
226  return EXIT_FAILURE;
227  }
228  }
229 
230  // Traineddata file.
231  GenericVector<char> traineddata_data;
232  traineddata.Serialize(&traineddata_data);
233  if (!WriteFile(output_dir, lang, ".traineddata", traineddata_data, writer)) {
234  tprintf("Error writing output traineddata file!!\n");
235  return EXIT_FAILURE;
236  }
237  return EXIT_SUCCESS;
238 }
bool Serialize(FILE *fp) const
bool empty() const
Definition: genericvector.h:90
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
bool WriteFile(const std::string &output_dir, const std::string &lang, const std::string &suffix, const GenericVector< char > &data, FileWriter writer)
Definition: strngs.h:45
bool WriteUnicharset(const UNICHARSET &unicharset, const std::string &output_dir, const std::string &lang, FileWriter writer, TessdataManager *traineddata)
STRING ReadFile(const std::string &filename, FileReader reader)
bool WriteRecoder(const UNICHARSET &unicharset, bool pass_through, const std::string &output_dir, const std::string &lang, FileWriter writer, STRING *radical_table_data, TessdataManager *traineddata)
int32_t length() const
Definition: strngs.cpp:191

◆ CompareFontInfo()

bool tesseract::CompareFontInfo ( const FontInfo fi1,
const FontInfo fi2 
)

Definition at line 120 of file fontinfo.cpp.

120  {
121  // The font properties are required to be the same for two font with the same
122  // name, so there is no need to test them.
123  // Consequently, querying the table with only its font name as information is
124  // enough to retrieve its properties.
125  return strcmp(fi1.name, fi2.name) == 0;
126 }

◆ CompareFontSet()

bool tesseract::CompareFontSet ( const FontSet fs1,
const FontSet fs2 
)

Definition at line 128 of file fontinfo.cpp.

128  {
129  if (fs1.size != fs2.size)
130  return false;
131  for (int i = 0; i < fs1.size; ++i) {
132  if (fs1.configs[i] != fs2.configs[i])
133  return false;
134  }
135  return true;
136 }

◆ CopyVector()

void tesseract::CopyVector ( int  n,
const double *  src,
double *  dest 
)
inline

Definition at line 186 of file functions.h.

186  {
187  memcpy(dest, src, n * sizeof(dest[0]));
188 }

◆ countof()

template<typename T , size_t N>
constexpr size_t tesseract::countof ( T   const(&)[N])
noexcept

Definition at line 43 of file serialis.h.

43  {
44  return N;
45 }

◆ CrownCompatible()

bool tesseract::CrownCompatible ( const GenericVector< RowScratchRegisters > *  rows,
int  a,
int  b,
const ParagraphModel model 
)

Definition at line 1301 of file paragraphs.cpp.

1302  {
1303  if (model != kCrownRight && model != kCrownLeft) {
1304  tprintf("CrownCompatible() should only be called with crown models!\n");
1305  return false;
1306  }
1307  RowScratchRegisters &row_a = (*rows)[a];
1308  RowScratchRegisters &row_b = (*rows)[b];
1309  if (model == kCrownRight) {
1310  return NearlyEqual(row_a.rindent_ + row_a.rmargin_,
1311  row_b.rindent_ + row_b.rmargin_,
1312  Epsilon(row_a.ri_->average_interword_space));
1313  }
1314  return NearlyEqual(row_a.lindent_ + row_a.lmargin_,
1315  row_b.lindent_ + row_b.lmargin_,
1316  Epsilon(row_a.ri_->average_interword_space));
1317 }
const ParagraphModel * kCrownRight
Definition: paragraphs.cpp:57
bool NearlyEqual(T x, T y, T tolerance)
Definition: host.h:60
const ParagraphModel * kCrownLeft
Definition: paragraphs.cpp:55
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37

◆ DegradeImage()

struct Pix * tesseract::DegradeImage ( Pix *  input,
int  exposure,
TRand randomizer,
float *  rotation 
)

Definition at line 91 of file degradeimage.cpp.

92  {
93  Pix* pix = pixConvertTo8(input, false);
94  pixDestroy(&input);
95  input = pix;
96  int width = pixGetWidth(input);
97  int height = pixGetHeight(input);
98  if (exposure >= 2) {
99  // An erosion simulates the spreading darkening of a dark copy.
100  // This is backwards to binary morphology,
101  // see http://www.leptonica.com/grayscale-morphology.html
102  pix = input;
103  input = pixErodeGray(pix, 3, 3);
104  pixDestroy(&pix);
105  }
106  // A convolution is essential to any mode as no scanner produces an
107  // image as sharp as the electronic image.
108  pix = pixBlockconv(input, 1, 1);
109  pixDestroy(&input);
110  // A small random rotation helps to make the edges jaggy in a realistic way.
111  if (rotation != nullptr) {
112  float radians_clockwise = 0.0f;
113  if (*rotation) {
114  radians_clockwise = *rotation;
115  } else if (randomizer != nullptr) {
116  radians_clockwise = randomizer->SignedRand(kRotationRange);
117  }
118 
119  input = pixRotate(pix, radians_clockwise,
120  L_ROTATE_AREA_MAP, L_BRING_IN_WHITE,
121  0, 0);
122  // Rotate the boxes to match.
123  *rotation = radians_clockwise;
124  pixDestroy(&pix);
125  } else {
126  input = pix;
127  }
128 
129  if (exposure >= 3 || exposure == 1) {
130  // Erosion after the convolution is not as heavy as before, so it is
131  // good for level 1 and in addition as a level 3.
132  // This is backwards to binary morphology,
133  // see http://www.leptonica.com/grayscale-morphology.html
134  pix = input;
135  input = pixErodeGray(pix, 3, 3);
136  pixDestroy(&pix);
137  }
138  // The convolution really needed to be 2x2 to be realistic enough, but
139  // we only have 3x3, so we have to bias the image darker or lose thin
140  // strokes.
141  int erosion_offset = 0;
142  // For light and 0 exposure, there is no dilation, so compensate for the
143  // convolution with a big darkening bias which is undone for lighter
144  // exposures.
145  if (exposure <= 0)
146  erosion_offset = -3 * kExposureFactor;
147  // Add in a general offset of the greyscales for the exposure level so
148  // a threshold of 128 gives a reasonable binary result.
149  erosion_offset -= exposure * kExposureFactor;
150  // Add a gradual fade over the page and a small amount of salt and pepper
151  // noise to simulate noise in the sensor/paper fibres and varying
152  // illumination.
153  l_uint32* data = pixGetData(input);
154  for (int y = 0; y < height; ++y) {
155  for (int x = 0; x < width; ++x) {
156  int pixel = GET_DATA_BYTE(data, x);
157  if (randomizer != nullptr)
158  pixel += randomizer->IntRand() % (kSaltnPepper*2 + 1) - kSaltnPepper;
159  if (height + width > kMinRampSize)
160  pixel -= (2*x + y) * 32 / (height + width);
161  pixel += erosion_offset;
162  if (pixel < 0)
163  pixel = 0;
164  if (pixel > 255)
165  pixel = 255;
166  SET_DATA_BYTE(data, x, pixel);
167  }
168  data += input->wpl;
169  }
170  return input;
171 }
const int kExposureFactor
const int kMinRampSize
const int kSaltnPepper
const float kRotationRange

◆ DeleteObject()

template<typename T >
void tesseract::DeleteObject ( T *  object)

Definition at line 156 of file tablefind.cpp.

156  {
157  delete object;
158 }

◆ DeSerialize() [1/8]

bool tesseract::DeSerialize ( FILE *  fp,
char *  data,
size_t  n 
)

Definition at line 27 of file serialis.cpp.

27  {
28  return fread(data, sizeof(*data), n, fp) == n;
29 }

◆ DeSerialize() [2/8]

bool tesseract::DeSerialize ( FILE *  fp,
float *  data,
size_t  n 
)

Definition at line 31 of file serialis.cpp.

31  {
32  return fread(data, sizeof(*data), n, fp) == n;
33 }

◆ DeSerialize() [3/8]

bool tesseract::DeSerialize ( FILE *  fp,
int8_t *  data,
size_t  n 
)

Definition at line 35 of file serialis.cpp.

35  {
36  return fread(data, sizeof(*data), n, fp) == n;
37 }

◆ DeSerialize() [4/8]

bool tesseract::DeSerialize ( FILE *  fp,
int16_t *  data,
size_t  n 
)

Definition at line 39 of file serialis.cpp.

39  {
40  return fread(data, sizeof(*data), n, fp) == n;
41 }

◆ DeSerialize() [5/8]

bool tesseract::DeSerialize ( FILE *  fp,
int32_t *  data,
size_t  n 
)

Definition at line 43 of file serialis.cpp.

43  {
44  return fread(data, sizeof(*data), n, fp) == n;
45 }

◆ DeSerialize() [6/8]

bool tesseract::DeSerialize ( FILE *  fp,
uint8_t *  data,
size_t  n 
)

Definition at line 47 of file serialis.cpp.

47  {
48  return fread(data, sizeof(*data), n, fp) == n;
49 }

◆ DeSerialize() [7/8]

bool tesseract::DeSerialize ( FILE *  fp,
uint16_t *  data,
size_t  n 
)

Definition at line 51 of file serialis.cpp.

51  {
52  return fread(data, sizeof(*data), n, fp) == n;
53 }

◆ DeSerialize() [8/8]

bool tesseract::DeSerialize ( FILE *  fp,
uint32_t *  data,
size_t  n 
)

Definition at line 55 of file serialis.cpp.

55  {
56  return fread(data, sizeof(*data), n, fp) == n;
57 }

◆ DetectParagraphs() [1/2]

void tesseract::DetectParagraphs ( int  debug_level,
GenericVector< RowInfo > *  row_infos,
GenericVector< PARA *> *  row_owners,
PARA_LIST *  paragraphs,
GenericVector< ParagraphModel *> *  models 
)

Definition at line 2271 of file paragraphs.cpp.

2275  {
2277  ParagraphTheory theory(models);
2278 
2279  // Initialize row_owners to be a bunch of nullptr pointers.
2280  row_owners->init_to_size(row_infos->size(), nullptr);
2281 
2282  // Set up row scratch registers for the main algorithm.
2283  rows.init_to_size(row_infos->size(), RowScratchRegisters());
2284  for (int i = 0; i < row_infos->size(); i++) {
2285  rows[i].Init((*row_infos)[i]);
2286  }
2287 
2288  // Pass 1:
2289  // Detect sequences of lines that all contain leader dots (.....)
2290  // These are likely Tables of Contents. If there are three text lines in
2291  // a row with leader dots, it's pretty safe to say the middle one should
2292  // be a paragraph of its own.
2293  SeparateSimpleLeaderLines(&rows, 0, rows.size(), &theory);
2294 
2295  DebugDump(debug_level > 1, "End of Pass 1", theory, rows);
2296 
2297  GenericVector<Interval> leftovers;
2298  LeftoverSegments(rows, &leftovers, 0, rows.size());
2299  for (int i = 0; i < leftovers.size(); i++) {
2300  // Pass 2a:
2301  // Find any strongly evidenced start-of-paragraph lines. If they're
2302  // followed by two lines that look like body lines, make a paragraph
2303  // model for that and see if that model applies throughout the text
2304  // (that is, "smear" it).
2305  StrongEvidenceClassify(debug_level, &rows,
2306  leftovers[i].begin, leftovers[i].end, &theory);
2307 
2308  // Pass 2b:
2309  // If we had any luck in pass 2a, we got part of the page and didn't
2310  // know how to classify a few runs of rows. Take the segments that
2311  // didn't find a model and reprocess them individually.
2312  GenericVector<Interval> leftovers2;
2313  LeftoverSegments(rows, &leftovers2, leftovers[i].begin, leftovers[i].end);
2314  bool pass2a_was_useful = leftovers2.size() > 1 ||
2315  (leftovers2.size() == 1 &&
2316  (leftovers2[0].begin != 0 || leftovers2[0].end != rows.size()));
2317  if (pass2a_was_useful) {
2318  for (int j = 0; j < leftovers2.size(); j++) {
2319  StrongEvidenceClassify(debug_level, &rows,
2320  leftovers2[j].begin, leftovers2[j].end,
2321  &theory);
2322  }
2323  }
2324  }
2325 
2326  DebugDump(debug_level > 1, "End of Pass 2", theory, rows);
2327 
2328  // Pass 3:
2329  // These are the dregs for which we didn't have enough strong textual
2330  // and geometric clues to form matching models for. Let's see if
2331  // the geometric clues are simple enough that we could just use those.
2332  LeftoverSegments(rows, &leftovers, 0, rows.size());
2333  for (int i = 0; i < leftovers.size(); i++) {
2334  GeometricClassify(debug_level, &rows,
2335  leftovers[i].begin, leftovers[i].end, &theory);
2336  }
2337 
2338  // Undo any flush models for which there's little evidence.
2339  DowngradeWeakestToCrowns(debug_level, &theory, &rows);
2340 
2341  DebugDump(debug_level > 1, "End of Pass 3", theory, rows);
2342 
2343  // Pass 4:
2344  // Take everything that's still not marked up well and clear all markings.
2345  LeftoverSegments(rows, &leftovers, 0, rows.size());
2346  for (int i = 0; i < leftovers.size(); i++) {
2347  for (int j = leftovers[i].begin; j < leftovers[i].end; j++) {
2348  rows[j].SetUnknown();
2349  }
2350  }
2351 
2352  DebugDump(debug_level > 1, "End of Pass 4", theory, rows);
2353 
2354  // Convert all of the unique hypothesis runs to PARAs.
2355  ConvertHypothesizedModelRunsToParagraphs(debug_level, rows, row_owners,
2356  &theory);
2357 
2358  DebugDump(debug_level > 0, "Final Paragraph Segmentation", theory, rows);
2359 
2360  // Finally, clean up any dangling nullptr row paragraph parents.
2361  CanonicalizeDetectionResults(row_owners, paragraphs);
2362 }
int size() const
Definition: genericvector.h:71
void CanonicalizeDetectionResults(GenericVector< PARA *> *row_owners, PARA_LIST *paragraphs)
void init_to_size(int size, const T &t)

◆ DetectParagraphs() [2/2]

void tesseract::DetectParagraphs ( int  debug_level,
bool  after_text_recognition,
const MutableIterator block_start,
GenericVector< ParagraphModel *> *  models 
)

Definition at line 2514 of file paragraphs.cpp.

2517  {
2518  // Clear out any preconceived notions.
2519  if (block_start->Empty(RIL_TEXTLINE)) {
2520  return;
2521  }
2522  BLOCK *block = block_start->PageResIt()->block()->block;
2523  block->para_list()->clear();
2524  bool is_image_block = block->pdblk.poly_block() && !block->pdblk.poly_block()->IsText();
2525 
2526  // Convert the Tesseract structures to RowInfos
2527  // for the paragraph detection algorithm.
2528  MutableIterator row(*block_start);
2529  if (row.Empty(RIL_TEXTLINE))
2530  return; // end of input already.
2531 
2532  GenericVector<RowInfo> row_infos;
2533  do {
2534  if (!row.PageResIt()->row())
2535  continue; // empty row.
2536  row.PageResIt()->row()->row->set_para(nullptr);
2537  row_infos.push_back(RowInfo());
2538  RowInfo &ri = row_infos.back();
2539  InitializeRowInfo(after_text_recognition, row, &ri);
2540  } while (!row.IsAtFinalElement(RIL_BLOCK, RIL_TEXTLINE) &&
2541  row.Next(RIL_TEXTLINE));
2542 
2543  // If we're called before text recognition, we might not have
2544  // tight block bounding boxes, so trim by the minimum on each side.
2545  if (!row_infos.empty()) {
2546  int min_lmargin = row_infos[0].pix_ldistance;
2547  int min_rmargin = row_infos[0].pix_rdistance;
2548  for (int i = 1; i < row_infos.size(); i++) {
2549  if (row_infos[i].pix_ldistance < min_lmargin)
2550  min_lmargin = row_infos[i].pix_ldistance;
2551  if (row_infos[i].pix_rdistance < min_rmargin)
2552  min_rmargin = row_infos[i].pix_rdistance;
2553  }
2554  if (min_lmargin > 0 || min_rmargin > 0) {
2555  for (int i = 0; i < row_infos.size(); i++) {
2556  row_infos[i].pix_ldistance -= min_lmargin;
2557  row_infos[i].pix_rdistance -= min_rmargin;
2558  }
2559  }
2560  }
2561 
2562  // Run the paragraph detection algorithm.
2563  GenericVector<PARA *> row_owners;
2564  GenericVector<PARA *> the_paragraphs;
2565  if (!is_image_block) {
2566  DetectParagraphs(debug_level, &row_infos, &row_owners, block->para_list(),
2567  models);
2568  } else {
2569  row_owners.init_to_size(row_infos.size(), nullptr);
2570  CanonicalizeDetectionResults(&row_owners, block->para_list());
2571  }
2572 
2573  // Now stitch in the row_owners into the rows.
2574  row = *block_start;
2575  for (int i = 0; i < row_owners.size(); i++) {
2576  while (!row.PageResIt()->row())
2577  row.Next(RIL_TEXTLINE);
2578  row.PageResIt()->row()->row->set_para(row_owners[i]);
2579  row.Next(RIL_TEXTLINE);
2580  }
2581 }
int size() const
Definition: genericvector.h:71
T & back() const
void CanonicalizeDetectionResults(GenericVector< PARA *> *row_owners, PARA_LIST *paragraphs)
void init_to_size(int size, const T &t)
POLY_BLOCK * poly_block() const
Definition: pdblock.h:56
bool empty() const
Definition: genericvector.h:90
bool IsText() const
Definition: polyblk.h:49
Definition: ocrblock.h:30
int push_back(T object)
PARA_LIST * para_list()
Definition: ocrblock.h:126
Definition: capi.h:98
PDBLK pdblk
Definition: ocrblock.h:192
void DetectParagraphs(int debug_level, bool after_text_recognition, const MutableIterator *block_start, GenericVector< ParagraphModel *> *models)

◆ DotProductAVX()

double tesseract::DotProductAVX ( const double *  u,
const double *  v,
int  n 
)

Definition at line 27 of file dotproductavx.cpp.

27  {
28  fprintf(stderr, "DotProductAVX can't be used on Android\n");
29  abort();
30 }

◆ DotProductSSE()

double tesseract::DotProductSSE ( const double *  u,
const double *  v,
int  n 
)

Definition at line 27 of file dotproductsse.cpp.

27  {
28  fprintf(stderr, "DotProductSSE can't be used on Android\n");
29  abort();
30 }

◆ ExtractFontName()

void tesseract::ExtractFontName ( const STRING filename,
STRING fontname 
)

Public Code

Definition at line 47 of file blobclass.cpp.

47  {
48  *fontname = classify_font_name;
49  if (*fontname == kUnknownFontName) {
50  // filename is expected to be of the form [lang].[fontname].exp[num]
51  // The [lang], [fontname] and [num] fields should not have '.' characters.
52  const char *basename = strrchr(filename.string(), '/');
53  const char *firstdot = strchr(basename ? basename : filename.string(), '.');
54  const char *lastdot = strrchr(filename.string(), '.');
55  if (firstdot != lastdot && firstdot != nullptr && lastdot != nullptr) {
56  ++firstdot;
57  *fontname = firstdot;
58  fontname->truncate_at(lastdot - firstdot);
59  }
60  }
61 }
const char * string() const
Definition: strngs.cpp:196
void truncate_at(int32_t index)
Definition: strngs.cpp:267
char * classify_font_name
Definition: blobclass.cpp:36

◆ FirstWordWouldHaveFit() [1/2]

bool tesseract::FirstWordWouldHaveFit ( const RowScratchRegisters before,
const RowScratchRegisters after,
tesseract::ParagraphJustification  justification 
)

Definition at line 1633 of file paragraphs.cpp.

1635  {
1636  if (before.ri_->num_words == 0 || after.ri_->num_words == 0)
1637  return true;
1638 
1639  if (justification == JUSTIFICATION_UNKNOWN) {
1640  tprintf("Don't call FirstWordWouldHaveFit(r, s, JUSTIFICATION_UNKNOWN).\n");
1641  }
1642  int available_space;
1643  if (justification == JUSTIFICATION_CENTER) {
1644  available_space = before.lindent_ + before.rindent_;
1645  } else {
1646  available_space = before.OffsideIndent(justification);
1647  }
1648  available_space -= before.ri_->average_interword_space;
1649 
1650  if (before.ri_->ltr)
1651  return after.ri_->lword_box.width() < available_space;
1652  return after.ri_->rword_box.width() < available_space;
1653 }
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37

◆ FirstWordWouldHaveFit() [2/2]

bool tesseract::FirstWordWouldHaveFit ( const RowScratchRegisters before,
const RowScratchRegisters after 
)

Definition at line 1658 of file paragraphs.cpp.

1659  {
1660  if (before.ri_->num_words == 0 || after.ri_->num_words == 0)
1661  return true;
1662 
1663  int available_space = before.lindent_;
1664  if (before.rindent_ > available_space)
1665  available_space = before.rindent_;
1666  available_space -= before.ri_->average_interword_space;
1667 
1668  if (before.ri_->ltr)
1669  return after.ri_->lword_box.width() < available_space;
1670  return after.ri_->rword_box.width() < available_space;
1671 }

◆ FontInfoDeleteCallback()

void tesseract::FontInfoDeleteCallback ( FontInfo  f)

Definition at line 139 of file fontinfo.cpp.

139  {
140  if (f.spacing_vec != nullptr) {
141  f.spacing_vec->delete_data_pointers();
142  delete f.spacing_vec;
143  }
144  delete[] f.name;
145 }

◆ FontSetDeleteCallback()

void tesseract::FontSetDeleteCallback ( FontSet  fs)

Definition at line 146 of file fontinfo.cpp.

146  {
147  delete[] fs.configs;
148 }

◆ FullwidthToHalfwidth()

char32 tesseract::FullwidthToHalfwidth ( const char32  ch)

Definition at line 282 of file normstrngs.cpp.

282  {
283  // Return unchanged if not in the fullwidth-halfwidth Unicode block.
284  if (ch < 0xFF00 || ch > 0xFFEF || !IsValidCodepoint(ch)) {
285  if (ch != 0x3000) return ch;
286  }
287  // Special case for fullwidth left and right "white parentheses".
288  if (ch == 0xFF5F) return 0x2985;
289  if (ch == 0xFF60) return 0x2986;
290  // Construct a full-to-half width transliterator.
291  IcuErrorCode error_code;
292  icu::UnicodeString uch_str(static_cast<UChar32>(ch));
293  const icu::Transliterator* fulltohalf = icu::Transliterator::createInstance(
294  "Fullwidth-Halfwidth", UTRANS_FORWARD, error_code);
295  error_code.assertSuccess();
296  error_code.reset();
297 
298  fulltohalf->transliterate(uch_str);
299  delete fulltohalf;
300  ASSERT_HOST(uch_str.length() != 0);
301  return uch_str[0];
302 }
bool IsValidCodepoint(const char32 ch)
Definition: normstrngs.cpp:218
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ FuncInplace()

template<class Func >
void tesseract::FuncInplace ( int  n,
double *  inout 
)
inline

Definition at line 146 of file functions.h.

146  {
147  Func f;
148  for (int i = 0; i < n; ++i) {
149  inout[i] = f(inout[i]);
150  }
151 }

◆ FuncMultiply()

template<class Func >
void tesseract::FuncMultiply ( const double *  u,
const double *  v,
int  n,
double *  out 
)
inline

Definition at line 155 of file functions.h.

155  {
156  Func f;
157  for (int i = 0; i < n; ++i) {
158  out[i] = f(u[i]) * v[i];
159  }
160 }

◆ GeneratePerspectiveDistortion()

void tesseract::GeneratePerspectiveDistortion ( int  width,
int  height,
TRand randomizer,
Pix **  pix,
GenericVector< TBOX > *  boxes 
)

Definition at line 219 of file degradeimage.cpp.

220  {
221  if (pix != nullptr && *pix != nullptr) {
222  width = pixGetWidth(*pix);
223  height = pixGetHeight(*pix);
224  }
225  float* im_coeffs = nullptr;
226  float* box_coeffs = nullptr;
227  l_int32 incolor =
228  ProjectiveCoeffs(width, height, randomizer, &im_coeffs, &box_coeffs);
229  if (pix != nullptr && *pix != nullptr) {
230  // Transform the image.
231  Pix* transformed = pixProjective(*pix, im_coeffs, incolor);
232  if (transformed == nullptr) {
233  tprintf("Projective transformation failed!!\n");
234  return;
235  }
236  pixDestroy(pix);
237  *pix = transformed;
238  }
239  if (boxes != nullptr) {
240  // Transform the boxes.
241  for (int b = 0; b < boxes->size(); ++b) {
242  int x1, y1, x2, y2;
243  const TBOX& box = (*boxes)[b];
244  projectiveXformSampledPt(box_coeffs, box.left(), height - box.top(), &x1,
245  &y1);
246  projectiveXformSampledPt(box_coeffs, box.right(), height - box.bottom(),
247  &x2, &y2);
248  TBOX new_box1(x1, height - y2, x2, height - y1);
249  projectiveXformSampledPt(box_coeffs, box.left(), height - box.bottom(),
250  &x1, &y1);
251  projectiveXformSampledPt(box_coeffs, box.right(), height - box.top(), &x2,
252  &y2);
253  TBOX new_box2(x1, height - y1, x2, height - y2);
254  (*boxes)[b] = new_box1.bounding_union(new_box2);
255  }
256  }
257  free(im_coeffs);
258  free(box_coeffs);
259 }
int size() const
Definition: genericvector.h:71
Definition: rect.h:34
int16_t left() const
Definition: rect.h:72
int16_t top() const
Definition: rect.h:58
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
int16_t right() const
Definition: rect.h:79
int ProjectiveCoeffs(int width, int height, TRand *randomizer, float **im_coeffs, float **box_coeffs)
int16_t bottom() const
Definition: rect.h:65

◆ GetXheightString()

std::string tesseract::GetXheightString ( const std::string &  script_dir,
const UNICHARSET unicharset 
)

Definition at line 164 of file unicharset_training_utils.cpp.

165  {
166  std::string xheights_str;
167  for (int s = 0; s < unicharset.get_script_table_size(); ++s) {
168  // Load the xheights for the script if available.
169  std::string filename = script_dir + "/" +
170  unicharset.get_script_from_script_id(s) + ".xheights";
171  std::string script_heights;
172  if (File::ReadFileToString(filename, &script_heights))
173  xheights_str += script_heights;
174  }
175  return xheights_str;
176 }
const char * get_script_from_script_id(int id) const
Definition: unicharset.h:849
int get_script_table_size() const
Definition: unicharset.h:844

◆ HistogramRect()

void tesseract::HistogramRect ( Pix *  src_pix,
int  channel,
int  left,
int  top,
int  width,
int  height,
int *  histogram 
)

Definition at line 151 of file otsuthr.cpp.

153  {
154  PERF_COUNT_START("HistogramRect")
155  int num_channels = pixGetDepth(src_pix) / 8;
156  channel = ClipToRange(channel, 0, num_channels - 1);
157  int bottom = top + height;
158  memset(histogram, 0, sizeof(*histogram) * kHistogramSize);
159  int src_wpl = pixGetWpl(src_pix);
160  l_uint32* srcdata = pixGetData(src_pix);
161  for (int y = top; y < bottom; ++y) {
162  const l_uint32* linedata = srcdata + y * src_wpl;
163  for (int x = 0; x < width; ++x) {
164  int pixel = GET_DATA_BYTE(linedata, (x + left) * num_channels + channel);
165  ++histogram[pixel];
166  }
167  }
169 }
#define PERF_COUNT_START(FUNCT_NAME)
const int kHistogramSize
Definition: otsuthr.h:27
#define PERF_COUNT_END
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:111

◆ HOcrEscape()

STRING tesseract::HOcrEscape ( const char *  text)

Escape a char string - remove <>&"' with HTML codes.

Escape a char string - remove &<>"' with HTML codes.

Definition at line 2632 of file baseapi.cpp.

2632  {
2633  STRING ret;
2634  const char *ptr;
2635  for (ptr = text; *ptr; ptr++) {
2636  switch (*ptr) {
2637  case '<': ret += "&lt;"; break;
2638  case '>': ret += "&gt;"; break;
2639  case '&': ret += "&amp;"; break;
2640  case '"': ret += "&quot;"; break;
2641  case '\'': ret += "&#39;"; break;
2642  default: ret += *ptr;
2643  }
2644  }
2645  return ret;
2646 }
Definition: strngs.h:45

◆ IntDotProductSSE()

int32_t tesseract::IntDotProductSSE ( const int8_t *  u,
const int8_t *  v,
int  n 
)

Definition at line 31 of file dotproductsse.cpp.

31  {
32  fprintf(stderr, "IntDotProductSSE can't be used on Android\n");
33  abort();
34 }

◆ InterwordSpace()

int tesseract::InterwordSpace ( const GenericVector< RowScratchRegisters > &  rows,
int  row_start,
int  row_end 
)

Definition at line 1610 of file paragraphs.cpp.

1611  {
1612  if (row_end < row_start + 1) return 1;
1613  int word_height = (rows[row_start].ri_->lword_box.height() +
1614  rows[row_end - 1].ri_->lword_box.height()) / 2;
1615  int word_width = (rows[row_start].ri_->lword_box.width() +
1616  rows[row_end - 1].ri_->lword_box.width()) / 2;
1617  STATS spacing_widths(0, 5 + word_width);
1618  for (int i = row_start; i < row_end; i++) {
1619  if (rows[i].ri_->num_words > 1) {
1620  spacing_widths.add(rows[i].ri_->average_interword_space, 1);
1621  }
1622  }
1623  int minimum_reasonable_space = word_height / 3;
1624  if (minimum_reasonable_space < 2)
1625  minimum_reasonable_space = 2;
1626  int median = spacing_widths.median();
1627  return (median > minimum_reasonable_space)
1628  ? median : minimum_reasonable_space;
1629 }
Definition: statistc.h:33

◆ IsInterchangeValid()

bool tesseract::IsInterchangeValid ( const char32  ch)

Definition at line 253 of file normstrngs.cpp.

253  {
254  return IsValidCodepoint(ch) &&
255  !(ch >= 0xFDD0 && ch <= 0xFDEF) && // Noncharacters.
256  !(ch >= 0xFFFE && ch <= 0xFFFF) && !(ch >= 0x1FFFE && ch <= 0x1FFFF) &&
257  !(ch >= 0x2FFFE && ch <= 0x2FFFF) &&
258  !(ch >= 0x3FFFE && ch <= 0x3FFFF) &&
259  !(ch >= 0x4FFFE && ch <= 0x4FFFF) &&
260  !(ch >= 0x5FFFE && ch <= 0x5FFFF) &&
261  !(ch >= 0x6FFFE && ch <= 0x6FFFF) &&
262  !(ch >= 0x7FFFE && ch <= 0x7FFFF) &&
263  !(ch >= 0x8FFFE && ch <= 0x8FFFF) &&
264  !(ch >= 0x9FFFE && ch <= 0x9FFFF) &&
265  !(ch >= 0xAFFFE && ch <= 0xAFFFF) &&
266  !(ch >= 0xBFFFE && ch <= 0xBFFFF) &&
267  !(ch >= 0xCFFFE && ch <= 0xCFFFF) &&
268  !(ch >= 0xDFFFE && ch <= 0xDFFFF) &&
269  !(ch >= 0xEFFFE && ch <= 0xEFFFF) &&
270  !(ch >= 0xFFFFE && ch <= 0xFFFFF) &&
271  !(ch >= 0x10FFFE && ch <= 0x10FFFF) &&
272  (!u_isISOControl(static_cast<UChar32>(ch)) || ch == '\n' ||
273  ch == '\f' || ch == '\t' || ch == '\r');
274 }
bool IsValidCodepoint(const char32 ch)
Definition: normstrngs.cpp:218

◆ IsInterchangeValid7BitAscii()

bool tesseract::IsInterchangeValid7BitAscii ( const char32  ch)

Definition at line 276 of file normstrngs.cpp.

276  {
277  return IsValidCodepoint(ch) && ch <= 128 &&
278  (!u_isISOControl(static_cast<UChar32>(ch)) || ch == '\n' ||
279  ch == '\f' || ch == '\t' || ch == '\r');
280 }
bool IsValidCodepoint(const char32 ch)
Definition: normstrngs.cpp:218

◆ IsLeftIndented()

bool tesseract::IsLeftIndented ( const EquationDetect::IndentType  type)
inline

Definition at line 93 of file equationdetect.cpp.

93  {
94  return type == EquationDetect::LEFT_INDENT ||
95  type == EquationDetect::BOTH_INDENT;
96 }

◆ IsOCREquivalent()

bool tesseract::IsOCREquivalent ( char32  ch1,
char32  ch2 
)

Definition at line 214 of file normstrngs.cpp.

214  {
215  return OCRNormalize(ch1) == OCRNormalize(ch2);
216 }
char32 OCRNormalize(char32 ch)
Definition: normstrngs.cpp:204

◆ IsRightIndented()

bool tesseract::IsRightIndented ( const EquationDetect::IndentType  type)
inline

Definition at line 98 of file equationdetect.cpp.

98  {
99  return type == EquationDetect::RIGHT_INDENT ||
100  type == EquationDetect::BOTH_INDENT;
101 }

◆ IsTextOrEquationType()

bool tesseract::IsTextOrEquationType ( PolyBlockType  type)
inline

Definition at line 89 of file equationdetect.cpp.

89  {
90  return PTIsTextType(type) || type == PT_EQUATION;
91 }
bool PTIsTextType(PolyBlockType type)
Definition: publictypes.h:82

◆ IsUTF8Whitespace()

bool tesseract::IsUTF8Whitespace ( const char *  text)

Definition at line 229 of file normstrngs.cpp.

229  {
230  return SpanUTF8Whitespace(text) == strlen(text);
231 }
unsigned int SpanUTF8Whitespace(const char *text)
Definition: normstrngs.cpp:233

◆ IsValidCodepoint()

bool tesseract::IsValidCodepoint ( const char32  ch)

Definition at line 218 of file normstrngs.cpp.

218  {
219  // In the range [0, 0xD800) or [0xE000, 0x10FFFF]
220  return (static_cast<uint32_t>(ch) < 0xD800) || (ch >= 0xE000 && ch <= 0x10FFFF);
221 }

◆ IsWhitespace()

bool tesseract::IsWhitespace ( const char32  ch)

Definition at line 223 of file normstrngs.cpp.

223  {
224  ASSERT_HOST_MSG(IsValidCodepoint(ch), "Invalid Unicode codepoint: 0x%x\n",
225  ch);
226  return u_isUWhiteSpace(static_cast<UChar32>(ch));
227 }
bool IsValidCodepoint(const char32 ch)
Definition: normstrngs.cpp:218
#define ASSERT_HOST_MSG(x,...)
Definition: errcode.h:90

◆ LeftWordAttributes()

void tesseract::LeftWordAttributes ( const UNICHARSET unicharset,
const WERD_CHOICE werd,
const STRING utf8,
bool *  is_list,
bool *  starts_idea,
bool *  ends_idea 
)

Definition at line 409 of file paragraphs.cpp.

411  {
412  *is_list = false;
413  *starts_idea = false;
414  *ends_idea = false;
415  if (utf8.size() == 0 || (werd != nullptr && werd->length() == 0)) { // Empty
416  *ends_idea = true;
417  return;
418  }
419 
420  if (unicharset && werd) { // We have a proper werd and unicharset so use it.
421  if (UniLikelyListItem(unicharset, werd)) {
422  *is_list = true;
423  *starts_idea = true;
424  *ends_idea = true;
425  }
426  if (unicharset->get_isupper(werd->unichar_id(0))) {
427  *starts_idea = true;
428  }
429  if (unicharset->get_ispunctuation(werd->unichar_id(0))) {
430  *starts_idea = true;
431  *ends_idea = true;
432  }
433  } else { // Assume utf8 is mostly ASCII
434  if (AsciiLikelyListItem(utf8)) {
435  *is_list = true;
436  *starts_idea = true;
437  }
438  int start_letter = utf8[0];
439  if (IsOpeningPunct(start_letter)) {
440  *starts_idea = true;
441  }
442  if (IsTerminalPunct(start_letter)) {
443  *ends_idea = true;
444  }
445  if (start_letter >= 'A' && start_letter <= 'Z') {
446  *starts_idea = true;
447  }
448  }
449 }
bool get_ispunctuation(UNICHAR_ID unichar_id) const
Definition: unicharset.h:514
UNICHAR_ID unichar_id(int index) const
Definition: ratngs.h:315
int length() const
Definition: ratngs.h:303
bool AsciiLikelyListItem(const STRING &word)
Definition: paragraphs.cpp:282
int32_t size() const
Definition: strngs.h:69
bool get_isupper(UNICHAR_ID unichar_id) const
Definition: unicharset.h:500

◆ LoadDataFromFile() [1/2]

bool tesseract::LoadDataFromFile ( const char *  filename,
GenericVector< char > *  data 
)
inline

Definition at line 367 of file genericvector.h.

367  {
368  bool result = false;
369  FILE* fp = fopen(filename, "rb");
370  if (fp != nullptr) {
371  fseek(fp, 0, SEEK_END);
372  long size = ftell(fp);
373  fseek(fp, 0, SEEK_SET);
374  // Trying to open a directory on Linux sets size to LONG_MAX. Catch it here.
375  if (size > 0 && size < LONG_MAX) {
376  // reserve an extra byte in case caller wants to append a '\0' character
377  data->reserve(size + 1);
378  data->resize_no_init(size);
379  result = static_cast<long>(fread(&(*data)[0], 1, size, fp)) == size;
380  }
381  fclose(fp);
382  }
383  return result;
384 }
void resize_no_init(int size)
Definition: genericvector.h:65
void reserve(int size)

◆ LoadDataFromFile() [2/2]

bool tesseract::LoadDataFromFile ( const STRING filename,
GenericVector< char > *  data 
)
inline

Definition at line 386 of file genericvector.h.

387  {
388  return LoadDataFromFile(filename.string(), data);
389 }
bool LoadDataFromFile(const STRING &filename, GenericVector< char > *data)
const char * string() const
Definition: strngs.cpp:196

◆ LoadFileLinesToStrings()

bool tesseract::LoadFileLinesToStrings ( const STRING filename,
GenericVector< STRING > *  lines 
)
inline

Definition at line 403 of file genericvector.h.

404  {
405  GenericVector<char> data;
406  if (!LoadDataFromFile(filename.string(), &data)) {
407  return false;
408  }
409  STRING lines_str(&data[0], data.size());
410  lines_str.split('\n', lines);
411  return true;
412 }
bool LoadDataFromFile(const STRING &filename, GenericVector< char > *data)
int size() const
Definition: genericvector.h:71
const char * string() const
Definition: strngs.cpp:196
void split(const char c, GenericVector< STRING > *splited)
Definition: strngs.cpp:284
Definition: strngs.h:45

◆ LoadShapeTable()

ShapeTable * tesseract::LoadShapeTable ( const STRING file_prefix)

Definition at line 162 of file commontraining.cpp.

162  {
163  ShapeTable* shape_table = nullptr;
164  STRING shape_table_file = file_prefix;
165  shape_table_file += kShapeTableFileSuffix;
166  TFile shape_fp;
167  if (shape_fp.Open(shape_table_file.string(), nullptr)) {
168  shape_table = new ShapeTable;
169  if (!shape_table->DeSerialize(&shape_fp)) {
170  delete shape_table;
171  shape_table = nullptr;
172  tprintf("Error: Failed to read shape table %s\n",
173  shape_table_file.string());
174  } else {
175  int num_shapes = shape_table->NumShapes();
176  tprintf("Read shape table %s of %d shapes\n",
177  shape_table_file.string(), num_shapes);
178  }
179  } else {
180  tprintf("Warning: No shape table file present: %s\n",
181  shape_table_file.string());
182  }
183  return shape_table;
184 }
const char * string() const
Definition: strngs.cpp:196
bool DeSerialize(TFile *fp)
Definition: shapetable.cpp:246
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
Definition: strngs.h:45
int NumShapes() const
Definition: shapetable.h:275

◆ LoadTrainingData()

MasterTrainer * tesseract::LoadTrainingData ( int  argc,
const char *const *  argv,
bool  replication,
ShapeTable **  shape_table,
STRING file_prefix 
)

Creates a MasterTrainer and loads the training data into it: Initializes feature_defs and IntegerFX. Loads the shape_table if shape_table != nullptr. Loads initial unicharset from -U command-line option. If FLAGS_T is set, loads the majority of data from there, else:

  • Loads font info from -F option.
  • Loads xheights from -X option.
  • Loads samples from .tr files in remaining command-line args.
  • Deletes outliers and computes canonical samples.
  • If FLAGS_output_trainer is set, saves the trainer for future use. TODO: Who uses that? There is currently no code which reads it. Computes canonical and cloud features. If shape_table is not nullptr, but failed to load, make a fake flat one, as shape clustering was not run.

Definition at line 219 of file commontraining.cpp.

222  {
224  InitIntegerFX();
225  *file_prefix = "";
226  if (!FLAGS_D.empty()) {
227  *file_prefix += FLAGS_D.c_str();
228  *file_prefix += "/";
229  }
230  // If we are shape clustering (nullptr shape_table) or we successfully load
231  // a shape_table written by a previous shape clustering, then
232  // shape_analysis will be true, meaning that the MasterTrainer will replace
233  // some members of the unicharset with their fragments.
234  bool shape_analysis = false;
235  if (shape_table != nullptr) {
236  *shape_table = LoadShapeTable(*file_prefix);
237  if (*shape_table != nullptr) shape_analysis = true;
238  } else {
239  shape_analysis = true;
240  }
241  MasterTrainer* trainer = new MasterTrainer(NM_CHAR_ANISOTROPIC,
242  shape_analysis,
243  replication,
244  FLAGS_debug_level);
245  IntFeatureSpace fs;
247  trainer->LoadUnicharset(FLAGS_U.c_str());
248  // Get basic font information from font_properties.
249  if (!FLAGS_F.empty()) {
250  if (!trainer->LoadFontInfo(FLAGS_F.c_str())) {
251  delete trainer;
252  return nullptr;
253  }
254  }
255  if (!FLAGS_X.empty()) {
256  if (!trainer->LoadXHeights(FLAGS_X.c_str())) {
257  delete trainer;
258  return nullptr;
259  }
260  }
261  trainer->SetFeatureSpace(fs);
262  const char* page_name;
263  // Load training data from .tr files on the command line.
264  while ((page_name = GetNextFilename(argc, argv)) != nullptr) {
265  tprintf("Reading %s ...\n", page_name);
266  trainer->ReadTrainingSamples(page_name, feature_defs, false);
267 
268  // If there is a file with [lang].[fontname].exp[num].fontinfo present,
269  // read font spacing information in to fontinfo_table.
270  int pagename_len = strlen(page_name);
271  char* fontinfo_file_name = new char[pagename_len + 7];
272  strncpy(fontinfo_file_name, page_name, pagename_len - 2); // remove "tr"
273  strcpy(fontinfo_file_name + pagename_len - 2, "fontinfo"); // +"fontinfo"
274  trainer->AddSpacingInfo(fontinfo_file_name);
275  delete[] fontinfo_file_name;
276 
277  // Load the images into memory if required by the classifier.
278  if (FLAGS_load_images) {
279  STRING image_name = page_name;
280  // Chop off the tr and replace with tif. Extension must be tif!
281  image_name.truncate_at(image_name.length() - 2);
282  image_name += "tif";
283  trainer->LoadPageImages(image_name.string());
284  }
285  }
286  trainer->PostLoadCleanup();
287  // Write the master trainer if required.
288  if (!FLAGS_output_trainer.empty()) {
289  FILE* fp = fopen(FLAGS_output_trainer.c_str(), "wb");
290  if (fp == nullptr) {
291  tprintf("Can't create saved trainer data!\n");
292  } else {
293  trainer->Serialize(fp);
294  fclose(fp);
295  }
296  }
297  trainer->PreTrainingSetup();
298  if (!FLAGS_O.empty() &&
299  !trainer->unicharset().save_to_file(FLAGS_O.c_str())) {
300  fprintf(stderr, "Failed to save unicharset to file %s\n", FLAGS_O.c_str());
301  delete trainer;
302  return nullptr;
303  }
304  if (shape_table != nullptr) {
305  // If we previously failed to load a shapetable, then shape clustering
306  // wasn't run so make a flat one now.
307  if (*shape_table == nullptr) {
308  *shape_table = new ShapeTable;
309  trainer->SetupFlatShapeTable(*shape_table);
310  tprintf("Flat shape table summary: %s\n",
311  (*shape_table)->SummaryStr().string());
312  }
313  (*shape_table)->set_unicharset(trainer->unicharset());
314  }
315  return trainer;
316 }
const int kBoostXYBuckets
void Init(uint8_t xbuckets, uint8_t ybuckets, uint8_t thetabuckets)
const char * string() const
Definition: strngs.cpp:196
void InitIntegerFX()
Definition: intfx.cpp:53
const int kBoostDirBuckets
FEATURE_DEFS_STRUCT feature_defs
const char * c_str() const
Definition: strngs.cpp:207
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
Definition: featdefs.cpp:112
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
void truncate_at(int32_t index)
Definition: strngs.cpp:267
Definition: strngs.h:45
const char * GetNextFilename(int argc, const char *const *argv)
int32_t length() const
Definition: strngs.cpp:191
ShapeTable * LoadShapeTable(const STRING &file_prefix)

◆ Logistic()

double tesseract::Logistic ( double  x)
inline

Definition at line 63 of file functions.h.

63  {
64  if (x < 0.0) return 1.0 - Logistic(-x);
65  if (x >= (kTableSize - 1) / kScaleFactor) return 1.0;
66  x *= kScaleFactor;
67  int index = static_cast<int>(floor(x));
68  if (LogisticTable[index] == 0.0) {
69  // Generate the entry.
70  LogisticTable[index] = 1.0 / (1.0 + exp(-index / kScaleFactor));
71  }
72  if (index == kTableSize - 1) return LogisticTable[kTableSize - 1];
73  if (LogisticTable[index + 1] == 0.0) {
74  // Generate the entry.
75  LogisticTable[index + 1] = 1.0 / (1.0 + exp(-(index + 1) / kScaleFactor));
76  }
77  double offset = x - index;
78  return LogisticTable[index] * (1.0 - offset) +
79  LogisticTable[index + 1] * offset;
80 }
double LogisticTable[kTableSize]
Definition: functions.cpp:24
const double kScaleFactor
Definition: functions.h:39
double Logistic(double x)
Definition: functions.h:63
const int kTableSize
Definition: functions.h:37

◆ MultiplyAccumulate()

void tesseract::MultiplyAccumulate ( int  n,
const double *  u,
const double *  v,
double *  out 
)
inline

Definition at line 201 of file functions.h.

202  {
203  for (int i = 0; i < n; i++) {
204  out[i] += u[i] * v[i];
205  }
206 }

◆ MultiplyVectorsInPlace()

void tesseract::MultiplyVectorsInPlace ( int  n,
const double *  src,
double *  inout 
)
inline

Definition at line 196 of file functions.h.

196  {
197  for (int i = 0; i < n; ++i) inout[i] *= src[i];
198 }

◆ NormalizeCleanAndSegmentUTF8()

bool tesseract::NormalizeCleanAndSegmentUTF8 ( UnicodeNormMode  u_mode,
OCRNorm  ocr_normalize,
GraphemeNormMode  g_mode,
bool  report_errors,
const char *  str8,
std::vector< std::string > *  graphemes 
)

Definition at line 172 of file normstrngs.cpp.

175  {
176  std::vector<char32> normed32;
177  NormalizeUTF8ToUTF32(u_mode, ocr_normalize, str8, &normed32);
178  StripJoiners(&normed32);
179  std::vector<std::vector<char32>> graphemes32;
180  bool success = Validator::ValidateCleanAndSegment(g_mode, report_errors,
181  normed32, &graphemes32);
182  if (g_mode != GraphemeNormMode::kSingleString && success) {
183  // If we modified the string to clean it up, the segmentation may not be
184  // correct, so check for changes and do it again.
185  std::vector<char32> cleaned32;
186  for (const auto& g : graphemes32) {
187  cleaned32.insert(cleaned32.end(), g.begin(), g.end());
188  }
189  if (cleaned32 != normed32) {
190  graphemes32.clear();
191  success = Validator::ValidateCleanAndSegment(g_mode, report_errors,
192  cleaned32, &graphemes32);
193  }
194  }
195  graphemes->clear();
196  graphemes->reserve(graphemes32.size());
197  for (const auto& grapheme : graphemes32) {
198  graphemes->push_back(UNICHAR::UTF32ToUTF8(grapheme));
199  }
200  return success;
201 }

◆ NormalizeUTF8String()

bool tesseract::NormalizeUTF8String ( UnicodeNormMode  u_mode,
OCRNorm  ocr_normalize,
GraphemeNorm  grapheme_normalize,
const char *  str8,
std::string *  normalized 
)

Definition at line 147 of file normstrngs.cpp.

149  {
150  std::vector<char32> normed32;
151  NormalizeUTF8ToUTF32(u_mode, ocr_normalize, str8, &normed32);
152  if (grapheme_normalize == GraphemeNorm::kNormalize) {
153  StripJoiners(&normed32);
154  std::vector<std::vector<char32>> graphemes;
155  bool success = Validator::ValidateCleanAndSegment(
156  GraphemeNormMode::kSingleString, false, normed32, &graphemes);
157  if (graphemes.empty() || graphemes[0].empty()) {
158  success = false;
159  } else if (normalized != nullptr) {
160  *normalized = UNICHAR::UTF32ToUTF8(graphemes[0]);
161  }
162  return success;
163  }
164  if (normalized != nullptr) *normalized = UNICHAR::UTF32ToUTF8(normed32);
165  return true;
166 }

◆ OCRNormalize()

char32 tesseract::OCRNormalize ( char32  ch)

Definition at line 204 of file normstrngs.cpp.

204  {
205  if (is_hyphen_punc(ch))
206  return '-';
207  else if (is_single_quote(ch))
208  return '\'';
209  else if (is_double_quote(ch))
210  return '"';
211  return ch;
212 }

◆ OtsuStats()

int tesseract::OtsuStats ( const int *  histogram,
int *  H_out,
int *  omega0_out 
)

Definition at line 174 of file otsuthr.cpp.

174  {
175  int H = 0;
176  double mu_T = 0.0;
177  for (int i = 0; i < kHistogramSize; ++i) {
178  H += histogram[i];
179  mu_T += static_cast<double>(i) * histogram[i];
180  }
181 
182  // Now maximize sig_sq_B over t.
183  // http://www.ctie.monash.edu.au/hargreave/Cornall_Terry_328.pdf
184  int best_t = -1;
185  int omega_0, omega_1;
186  int best_omega_0 = 0;
187  double best_sig_sq_B = 0.0;
188  double mu_0, mu_1, mu_t;
189  omega_0 = 0;
190  mu_t = 0.0;
191  for (int t = 0; t < kHistogramSize - 1; ++t) {
192  omega_0 += histogram[t];
193  mu_t += t * static_cast<double>(histogram[t]);
194  if (omega_0 == 0)
195  continue;
196  omega_1 = H - omega_0;
197  if (omega_1 == 0)
198  break;
199  mu_0 = mu_t / omega_0;
200  mu_1 = (mu_T - mu_t) / omega_1;
201  double sig_sq_B = mu_1 - mu_0;
202  sig_sq_B *= sig_sq_B * omega_0 * omega_1;
203  if (best_t < 0 || sig_sq_B > best_sig_sq_B) {
204  best_sig_sq_B = sig_sq_B;
205  best_t = t;
206  best_omega_0 = omega_0;
207  }
208  }
209  if (H_out != nullptr) *H_out = H;
210  if (omega0_out != nullptr) *omega0_out = best_omega_0;
211  return best_t;
212 }
const int kHistogramSize
Definition: otsuthr.h:27

◆ OtsuThreshold()

int tesseract::OtsuThreshold ( Pix *  src_pix,
int  left,
int  top,
int  width,
int  height,
int **  thresholds,
int **  hi_values 
)

Definition at line 39 of file otsuthr.cpp.

40  {
41  int num_channels = pixGetDepth(src_pix) / 8;
42  // Of all channels with no good hi_value, keep the best so we can always
43  // produce at least one answer.
44  PERF_COUNT_START("OtsuThreshold")
45  int best_hi_value = 1;
46  int best_hi_index = 0;
47  bool any_good_hivalue = false;
48  double best_hi_dist = 0.0;
49  *thresholds = new int[num_channels];
50  *hi_values = new int[num_channels];
51 
52  // only use opencl if compiled w/ OpenCL and selected device is opencl
53 #ifdef USE_OPENCL
54  // all of channel 0 then all of channel 1...
55  int* histogramAllChannels = new int[kHistogramSize * num_channels];
56 
57  // Calculate Histogram on GPU
58  OpenclDevice od;
59  if (od.selectedDeviceIsOpenCL() && (num_channels == 1 || num_channels == 4) &&
60  top == 0 && left == 0) {
61  od.HistogramRectOCL(pixGetData(src_pix), num_channels,
62  pixGetWpl(src_pix) * 4, left, top, width, height,
63  kHistogramSize, histogramAllChannels);
64 
65  // Calculate Threshold from Histogram on cpu
66  for (int ch = 0; ch < num_channels; ++ch) {
67  (*thresholds)[ch] = -1;
68  (*hi_values)[ch] = -1;
69  int *histogram = &histogramAllChannels[kHistogramSize * ch];
70  int H;
71  int best_omega_0;
72  int best_t = OtsuStats(histogram, &H, &best_omega_0);
73  if (best_omega_0 == 0 || best_omega_0 == H) {
74  // This channel is empty.
75  continue;
76  }
77  // To be a convincing foreground we must have a small fraction of H
78  // or to be a convincing background we must have a large fraction of H.
79  // In between we assume this channel contains no thresholding information.
80  int hi_value = best_omega_0 < H * 0.5;
81  (*thresholds)[ch] = best_t;
82  if (best_omega_0 > H * 0.75) {
83  any_good_hivalue = true;
84  (*hi_values)[ch] = 0;
85  } else if (best_omega_0 < H * 0.25) {
86  any_good_hivalue = true;
87  (*hi_values)[ch] = 1;
88  } else {
89  // In case all channels are like this, keep the best of the bad lot.
90  double hi_dist = hi_value ? (H - best_omega_0) : best_omega_0;
91  if (hi_dist > best_hi_dist) {
92  best_hi_dist = hi_dist;
93  best_hi_value = hi_value;
94  best_hi_index = ch;
95  }
96  }
97  }
98  } else {
99 #endif
100  for (int ch = 0; ch < num_channels; ++ch) {
101  (*thresholds)[ch] = -1;
102  (*hi_values)[ch] = -1;
103  // Compute the histogram of the image rectangle.
104  int histogram[kHistogramSize];
105  HistogramRect(src_pix, ch, left, top, width, height, histogram);
106  int H;
107  int best_omega_0;
108  int best_t = OtsuStats(histogram, &H, &best_omega_0);
109  if (best_omega_0 == 0 || best_omega_0 == H) {
110  // This channel is empty.
111  continue;
112  }
113  // To be a convincing foreground we must have a small fraction of H
114  // or to be a convincing background we must have a large fraction of H.
115  // In between we assume this channel contains no thresholding information.
116  int hi_value = best_omega_0 < H * 0.5;
117  (*thresholds)[ch] = best_t;
118  if (best_omega_0 > H * 0.75) {
119  any_good_hivalue = true;
120  (*hi_values)[ch] = 0;
121  } else if (best_omega_0 < H * 0.25) {
122  any_good_hivalue = true;
123  (*hi_values)[ch] = 1;
124  } else {
125  // In case all channels are like this, keep the best of the bad lot.
126  double hi_dist = hi_value ? (H - best_omega_0) : best_omega_0;
127  if (hi_dist > best_hi_dist) {
128  best_hi_dist = hi_dist;
129  best_hi_value = hi_value;
130  best_hi_index = ch;
131  }
132  }
133  }
134 #ifdef USE_OPENCL
135  }
136  delete[] histogramAllChannels;
137 #endif // USE_OPENCL
138 
139  if (!any_good_hivalue) {
140  // Use the best of the ones that were not good enough.
141  (*hi_values)[best_hi_index] = best_hi_value;
142  }
144  return num_channels;
145 }
int OtsuStats(const int *histogram, int *H_out, int *omega0_out)
Definition: otsuthr.cpp:174
#define PERF_COUNT_START(FUNCT_NAME)
const int kHistogramSize
Definition: otsuthr.h:27
void HistogramRect(Pix *src_pix, int channel, int left, int top, int width, int height, int *histogram)
Definition: otsuthr.cpp:151
#define PERF_COUNT_END

◆ ParamsTrainingFeatureByName()

int tesseract::ParamsTrainingFeatureByName ( const char *  name)

Definition at line 26 of file params_training_featdef.cpp.

26  {
27  if (name == nullptr)
28  return -1;
29  int array_size = sizeof(kParamsTrainingFeatureTypeName) /
30  sizeof(kParamsTrainingFeatureTypeName[0]);
31  for (int i = 0; i < array_size; i++) {
32  if (kParamsTrainingFeatureTypeName[i] == nullptr)
33  continue;
34  if (strcmp(name, kParamsTrainingFeatureTypeName[i]) == 0)
35  return i;
36  }
37  return -1;
38 }

◆ ParseCommandLineFlags()

void tesseract::ParseCommandLineFlags ( const char *  usage,
int *  argc,
char ***  argv,
const bool  remove_flags 
)

Definition at line 154 of file commandlineflags.cpp.

156  {
157  if (*argc == 1) {
158  printf("USAGE: %s\n", usage);
159  PrintCommandLineFlags();
160  exit(0);
161  }
162 
163  if (*argc > 1 && (!strcmp((*argv)[1], "-v") || !strcmp((*argv)[1], "--version"))) {
164  printf("%s\n", TessBaseAPI::Version());
165  exit(0);
166  }
167 
168  unsigned int i = 1;
169  for (i = 1; i < *argc; ++i) {
170  const char* current_arg = (*argv)[i];
171  // If argument does not start with a hyphen then break.
172  if (current_arg[0] != '-') {
173  break;
174  }
175  // Position current_arg after startings hyphens. We treat a sequence of
176  // one or two consecutive hyphens identically.
177  ++current_arg;
178  if (current_arg[0] == '-') {
179  ++current_arg;
180  }
181  // If this is asking for usage, print the help message and abort.
182  if (!strcmp(current_arg, "help")) {
183  printf("Usage:\n %s [OPTION ...]\n\n", usage);
184  PrintCommandLineFlags();
185  exit(0);
186  }
187  // Find the starting position of the value if it was specified in this
188  // string.
189  const char* equals_position = strchr(current_arg, '=');
190  const char* rhs = nullptr;
191  if (equals_position != nullptr) {
192  rhs = equals_position + 1;
193  }
194  // Extract the flag name.
195  STRING lhs;
196  if (equals_position == nullptr) {
197  lhs = current_arg;
198  } else {
199  lhs.assign(current_arg, equals_position - current_arg);
200  }
201  if (!lhs.length()) {
202  tprintf("ERROR: Bad argument: %s\n", (*argv)[i]);
203  exit(1);
204  }
205 
206  // Find the flag name in the list of global flags.
207  // int32_t flag
208  int32_t int_val;
209  if (IntFlagExists(lhs.string(), &int_val)) {
210  if (rhs != nullptr) {
211  if (!strlen(rhs)) {
212  // Bad input of the format --int_flag=
213  tprintf("ERROR: Bad argument: %s\n", (*argv)[i]);
214  exit(1);
215  }
216  if (!SafeAtoi(rhs, &int_val)) {
217  tprintf("ERROR: Could not parse int from %s in flag %s\n",
218  rhs, (*argv)[i]);
219  exit(1);
220  }
221  } else {
222  // We need to parse the next argument
223  if (i + 1 >= *argc) {
224  tprintf("ERROR: Could not find value argument for flag %s\n",
225  lhs.string());
226  exit(1);
227  } else {
228  ++i;
229  if (!SafeAtoi((*argv)[i], &int_val)) {
230  tprintf("ERROR: Could not parse int32_t from %s\n", (*argv)[i]);
231  exit(1);
232  }
233  }
234  }
235  SetIntFlagValue(lhs.string(), int_val);
236  continue;
237  }
238 
239  // double flag
240  double double_val;
241  if (DoubleFlagExists(lhs.string(), &double_val)) {
242  if (rhs != nullptr) {
243  if (!strlen(rhs)) {
244  // Bad input of the format --double_flag=
245  tprintf("ERROR: Bad argument: %s\n", (*argv)[i]);
246  exit(1);
247  }
248  if (!SafeAtod(rhs, &double_val)) {
249  tprintf("ERROR: Could not parse double from %s in flag %s\n",
250  rhs, (*argv)[i]);
251  exit(1);
252  }
253  } else {
254  // We need to parse the next argument
255  if (i + 1 >= *argc) {
256  tprintf("ERROR: Could not find value argument for flag %s\n",
257  lhs.string());
258  exit(1);
259  } else {
260  ++i;
261  if (!SafeAtod((*argv)[i], &double_val)) {
262  tprintf("ERROR: Could not parse double from %s\n", (*argv)[i]);
263  exit(1);
264  }
265  }
266  }
267  SetDoubleFlagValue(lhs.string(), double_val);
268  continue;
269  }
270 
271  // Bool flag. Allow input forms --flag (equivalent to --flag=true),
272  // --flag=false, --flag=true, --flag=0 and --flag=1
273  bool bool_val;
274  if (BoolFlagExists(lhs.string(), &bool_val)) {
275  if (rhs == nullptr) {
276  // --flag form
277  bool_val = true;
278  } else {
279  if (!strlen(rhs)) {
280  // Bad input of the format --bool_flag=
281  tprintf("ERROR: Bad argument: %s\n", (*argv)[i]);
282  exit(1);
283  }
284  if (!strcmp(rhs, "false") || !strcmp(rhs, "0")) {
285  bool_val = false;
286  } else if (!strcmp(rhs, "true") || !strcmp(rhs, "1")) {
287  bool_val = true;
288  } else {
289  tprintf("ERROR: Could not parse bool from flag %s\n", (*argv)[i]);
290  exit(1);
291  }
292  }
293  SetBoolFlagValue(lhs.string(), bool_val);
294  continue;
295  }
296 
297  // string flag
298  const char* string_val;
299  if (StringFlagExists(lhs.string(), &string_val)) {
300  if (rhs != nullptr) {
301  string_val = rhs;
302  } else {
303  // Pick the next argument
304  if (i + 1 >= *argc) {
305  tprintf("ERROR: Could not find string value for flag %s\n",
306  lhs.string());
307  exit(1);
308  } else {
309  string_val = (*argv)[++i];
310  }
311  }
312  SetStringFlagValue(lhs.string(), string_val);
313  continue;
314  }
315 
316  // Flag was not found. Exit with an error message.
317  tprintf("ERROR: Non-existent flag %s\n", (*argv)[i]);
318  exit(1);
319  } // for each argv
320  if (remove_flags) {
321  (*argv)[i - 1] = (*argv)[0];
322  (*argv) += (i - 1);
323  (*argc) -= (i - 1);
324  }
325 }
const char * string() const
Definition: strngs.cpp:196
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
Definition: strngs.h:45
int32_t length() const
Definition: strngs.cpp:191
void assign(const char *cstr, int len)
Definition: strngs.cpp:420

◆ PrepareDistortedPix()

Pix * tesseract::PrepareDistortedPix ( const Pix *  pix,
bool  perspective,
bool  invert,
bool  white_noise,
bool  smooth_noise,
bool  blur,
int  box_reduction,
TRand randomizer,
GenericVector< TBOX > *  boxes 
)

Definition at line 178 of file degradeimage.cpp.

181  {
182  Pix* distorted = pixCopy(nullptr, const_cast<Pix*>(pix));
183  // Things to do to synthetic training data.
184  if (invert && randomizer->SignedRand(1.0) < 0)
185  pixInvert(distorted, distorted);
186  if ((white_noise || smooth_noise) && randomizer->SignedRand(1.0) > 0.0) {
187  // TODO(rays) Cook noise in a more thread-safe manner than rand().
188  // Attempt to make the sequences reproducible.
189  srand(randomizer->IntRand());
190  Pix* pixn = pixAddGaussianNoise(distorted, 8.0);
191  pixDestroy(&distorted);
192  if (smooth_noise) {
193  distorted = pixBlockconv(pixn, 1, 1);
194  pixDestroy(&pixn);
195  } else {
196  distorted = pixn;
197  }
198  }
199  if (blur && randomizer->SignedRand(1.0) > 0.0) {
200  Pix* blurred = pixBlockconv(distorted, 1, 1);
201  pixDestroy(&distorted);
202  distorted = blurred;
203  }
204  if (perspective)
205  GeneratePerspectiveDistortion(0, 0, randomizer, &distorted, boxes);
206  if (boxes != nullptr) {
207  for (int b = 0; b < boxes->size(); ++b) {
208  (*boxes)[b].scale(1.0f / box_reduction);
209  if ((*boxes)[b].width() <= 0)
210  (*boxes)[b].set_right((*boxes)[b].left() + 1);
211  }
212  }
213  return distorted;
214 }
int size() const
Definition: genericvector.h:71
void GeneratePerspectiveDistortion(int width, int height, TRand *randomizer, Pix **pix, GenericVector< TBOX > *boxes)

◆ ProjectiveCoeffs()

int tesseract::ProjectiveCoeffs ( int  width,
int  height,
TRand randomizer,
float **  im_coeffs,
float **  box_coeffs 
)

Definition at line 265 of file degradeimage.cpp.

266  {
267  // Setup "from" points.
268  Pta* src_pts = ptaCreate(4);
269  ptaAddPt(src_pts, 0.0f, 0.0f);
270  ptaAddPt(src_pts, width, 0.0f);
271  ptaAddPt(src_pts, width, height);
272  ptaAddPt(src_pts, 0.0f, height);
273  // Extract factors from pseudo-random sequence.
274  float factors[FN_NUM_FACTORS];
275  float shear = 0.0f; // Shear is signed.
276  for (int i = 0; i < FN_NUM_FACTORS; ++i) {
277  // Everything is squared to make wild values rarer.
278  if (i == FN_SHEAR) {
279  // Shear is signed.
280  shear = randomizer->SignedRand(0.5 / 3.0);
281  shear = shear >= 0.0 ? shear * shear : -shear * shear;
282  // Keep the sheared points within the original rectangle.
283  if (shear < -factors[FN_X0]) shear = -factors[FN_X0];
284  if (shear > factors[FN_X1]) shear = factors[FN_X1];
285  factors[i] = shear;
286  } else if (i != FN_INCOLOR) {
287  factors[i] = fabs(randomizer->SignedRand(1.0));
288  if (i <= FN_Y3)
289  factors[i] *= 5.0 / 8.0;
290  else
291  factors[i] *= 0.5;
292  factors[i] *= factors[i];
293  }
294  }
295  // Setup "to" points.
296  Pta* dest_pts = ptaCreate(4);
297  ptaAddPt(dest_pts, factors[FN_X0] * width, factors[FN_Y0] * height);
298  ptaAddPt(dest_pts, (1.0f - factors[FN_X1]) * width, factors[FN_Y1] * height);
299  ptaAddPt(dest_pts, (1.0f - factors[FN_X1] + shear) * width,
300  (1 - factors[FN_Y2]) * height);
301  ptaAddPt(dest_pts, (factors[FN_X0] + shear) * width,
302  (1 - factors[FN_Y3]) * height);
303  getProjectiveXformCoeffs(dest_pts, src_pts, im_coeffs);
304  getProjectiveXformCoeffs(src_pts, dest_pts, box_coeffs);
305  ptaDestroy(&src_pts);
306  ptaDestroy(&dest_pts);
307  return factors[FN_INCOLOR] > 0.5f ? L_BRING_IN_WHITE : L_BRING_IN_BLACK;
308 }

◆ PSM_BLOCK_FIND_ENABLED()

bool tesseract::PSM_BLOCK_FIND_ENABLED ( int  pageseg_mode)
inline

Definition at line 203 of file publictypes.h.

203  {
204  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_COLUMN;
205 }

◆ PSM_COL_FIND_ENABLED()

bool tesseract::PSM_COL_FIND_ENABLED ( int  pageseg_mode)
inline

Definition at line 197 of file publictypes.h.

197  {
198  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_AUTO;
199 }
Definition: capi.h:95

◆ PSM_LINE_FIND_ENABLED()

bool tesseract::PSM_LINE_FIND_ENABLED ( int  pageseg_mode)
inline

Definition at line 206 of file publictypes.h.

206  {
207  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_BLOCK;
208 }

◆ PSM_ORIENTATION_ENABLED()

bool tesseract::PSM_ORIENTATION_ENABLED ( int  pageseg_mode)
inline

Definition at line 194 of file publictypes.h.

194  {
195  return pageseg_mode <= PSM_AUTO || pageseg_mode == PSM_SPARSE_TEXT_OSD;
196 }
Definition: capi.h:95

◆ PSM_OSD_ENABLED()

bool tesseract::PSM_OSD_ENABLED ( int  pageseg_mode)
inline

Inline functions that act on a PageSegMode to determine whether components of layout analysis are enabled. Depend critically on the order of elements of PageSegMode. NOTE that arg is an int for compatibility with INT_PARAM.

Definition at line 191 of file publictypes.h.

191  {
192  return pageseg_mode <= PSM_AUTO_OSD || pageseg_mode == PSM_SPARSE_TEXT_OSD;
193 }

◆ PSM_SPARSE()

bool tesseract::PSM_SPARSE ( int  pageseg_mode)
inline

Definition at line 200 of file publictypes.h.

200  {
201  return pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
202 }

◆ PSM_WORD_FIND_ENABLED()

bool tesseract::PSM_WORD_FIND_ENABLED ( int  pageseg_mode)
inline

Definition at line 209 of file publictypes.h.

209  {
210  return (pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_LINE) ||
211  pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
212 }

◆ read_info()

bool tesseract::read_info ( TFile f,
FontInfo fi 
)

Definition at line 152 of file fontinfo.cpp.

152  {
153  uint32_t size;
154  if (!f->DeSerialize(&size)) return false;
155  char* font_name = new char[size + 1];
156  fi->name = font_name;
157  if (!f->DeSerialize(font_name, size)) return false;
158  font_name[size] = '\0';
159  return f->DeSerialize(&fi->properties);
160 }

◆ read_set()

bool tesseract::read_set ( TFile f,
FontSet fs 
)

Definition at line 225 of file fontinfo.cpp.

225  {
226  if (!f->DeSerialize(&fs->size)) return false;
227  fs->configs = new int[fs->size];
228  return f->DeSerialize(&fs->configs[0], fs->size);
229 }

◆ read_spacing_info()

bool tesseract::read_spacing_info ( TFile f,
FontInfo fi 
)

Definition at line 169 of file fontinfo.cpp.

169  {
170  int32_t vec_size, kern_size;
171  if (!f->DeSerialize(&vec_size)) return false;
172  ASSERT_HOST(vec_size >= 0);
173  if (vec_size == 0) return true;
174  fi->init_spacing(vec_size);
175  for (int i = 0; i < vec_size; ++i) {
176  FontSpacingInfo *fs = new FontSpacingInfo();
177  if (!f->DeSerialize(&fs->x_gap_before) ||
178  !f->DeSerialize(&fs->x_gap_after) ||
179  !f->DeSerialize(&kern_size)) {
180  delete fs;
181  return false;
182  }
183  if (kern_size < 0) { // indication of a nullptr entry in fi->spacing_vec
184  delete fs;
185  continue;
186  }
187  if (kern_size > 0 && (!fs->kerned_unichar_ids.DeSerialize(f) ||
188  !fs->kerned_x_gaps.DeSerialize(f))) {
189  delete fs;
190  return false;
191  }
192  fi->add_spacing(i, fs);
193  }
194  return true;
195 }
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ ReadFile()

STRING tesseract::ReadFile ( const std::string &  filename,
FileReader  reader 
)

Definition at line 57 of file lang_model_helpers.cpp.

57  {
58  if (filename.empty()) return STRING();
60  bool read_result;
61  if (reader == nullptr)
62  read_result = LoadDataFromFile(filename.c_str(), &data);
63  else
64  read_result = (*reader)(filename.c_str(), &data);
65  if (read_result) return STRING(&data[0], data.size());
66  tprintf("Failed to read data from: %s\n", filename.c_str());
67  return STRING();
68 }
int size() const
Definition: genericvector.h:71
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
Definition: strngs.h:45
bool LoadDataFromFile(const char *filename, GenericVector< char > *data)

◆ ReCachePagesFunc()

void* tesseract::ReCachePagesFunc ( void *  data)

Definition at line 369 of file imagedata.cpp.

369  {
370  DocumentData* document_data = static_cast<DocumentData*>(data);
371  document_data->ReCachePages();
372  return nullptr;
373 }

◆ RecomputeMarginsAndClearHypotheses()

void tesseract::RecomputeMarginsAndClearHypotheses ( GenericVector< RowScratchRegisters > *  rows,
int  start,
int  end,
int  percentile 
)

Definition at line 1570 of file paragraphs.cpp.

1572  {
1573  if (!AcceptableRowArgs(0, 0, __func__, rows, start, end))
1574  return;
1575 
1576  int lmin, lmax, rmin, rmax;
1577  lmin = lmax = (*rows)[start].lmargin_ + (*rows)[start].lindent_;
1578  rmin = rmax = (*rows)[start].rmargin_ + (*rows)[start].rindent_;
1579  for (int i = start; i < end; i++) {
1580  RowScratchRegisters &sr = (*rows)[i];
1581  sr.SetUnknown();
1582  if (sr.ri_->num_words == 0)
1583  continue;
1584  UpdateRange(sr.lmargin_ + sr.lindent_, &lmin, &lmax);
1585  UpdateRange(sr.rmargin_ + sr.rindent_, &rmin, &rmax);
1586  }
1587  STATS lefts(lmin, lmax + 1);
1588  STATS rights(rmin, rmax + 1);
1589  for (int i = start; i < end; i++) {
1590  RowScratchRegisters &sr = (*rows)[i];
1591  if (sr.ri_->num_words == 0)
1592  continue;
1593  lefts.add(sr.lmargin_ + sr.lindent_, 1);
1594  rights.add(sr.rmargin_ + sr.rindent_, 1);
1595  }
1596  int ignorable_left = lefts.ile(ClipToRange(percentile, 0, 100) / 100.0);
1597  int ignorable_right = rights.ile(ClipToRange(percentile, 0, 100) / 100.0);
1598  for (int i = start; i < end; i++) {
1599  RowScratchRegisters &sr = (*rows)[i];
1600  int ldelta = ignorable_left - sr.lmargin_;
1601  sr.lmargin_ += ldelta;
1602  sr.lindent_ -= ldelta;
1603  int rdelta = ignorable_right - sr.rmargin_;
1604  sr.rmargin_ += rdelta;
1605  sr.rindent_ -= rdelta;
1606  }
1607 }
Definition: statistc.h:33
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:111
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:121

◆ RightWordAttributes()

void tesseract::RightWordAttributes ( const UNICHARSET unicharset,
const WERD_CHOICE werd,
const STRING utf8,
bool *  is_list,
bool *  starts_idea,
bool *  ends_idea 
)

Definition at line 456 of file paragraphs.cpp.

458  {
459  *is_list = false;
460  *starts_idea = false;
461  *ends_idea = false;
462  if (utf8.size() == 0 || (werd != nullptr && werd->length() == 0)) { // Empty
463  *ends_idea = true;
464  return;
465  }
466 
467  if (unicharset && werd) { // We have a proper werd and unicharset so use it.
468  if (UniLikelyListItem(unicharset, werd)) {
469  *is_list = true;
470  *starts_idea = true;
471  }
472  UNICHAR_ID last_letter = werd->unichar_id(werd->length() - 1);
473  if (unicharset->get_ispunctuation(last_letter)) {
474  *ends_idea = true;
475  }
476  } else { // Assume utf8 is mostly ASCII
477  if (AsciiLikelyListItem(utf8)) {
478  *is_list = true;
479  *starts_idea = true;
480  }
481  int last_letter = utf8[utf8.size() - 1];
482  if (IsOpeningPunct(last_letter) || IsTerminalPunct(last_letter)) {
483  *ends_idea = true;
484  }
485  }
486 }
int UNICHAR_ID
Definition: unichar.h:35
bool get_ispunctuation(UNICHAR_ID unichar_id) const
Definition: unicharset.h:514
UNICHAR_ID unichar_id(int index) const
Definition: ratngs.h:315
int length() const
Definition: ratngs.h:303
bool AsciiLikelyListItem(const STRING &word)
Definition: paragraphs.cpp:282
int32_t size() const
Definition: strngs.h:69

◆ RowsFitModel()

bool tesseract::RowsFitModel ( const GenericVector< RowScratchRegisters > *  rows,
int  start,
int  end,
const ParagraphModel model 
)

Definition at line 1813 of file paragraphs.cpp.

1814  {
1815  if (!AcceptableRowArgs(0, 1, __func__, rows, start, end))
1816  return false;
1817  if (!ValidFirstLine(rows, start, model)) return false;
1818  for (int i = start + 1 ; i < end; i++) {
1819  if (!ValidBodyLine(rows, i, model)) return false;
1820  }
1821  return true;
1822 }
bool ValidFirstLine(const GenericVector< RowScratchRegisters > *rows, int row, const ParagraphModel *model)
bool ValidBodyLine(const GenericVector< RowScratchRegisters > *rows, int row, const ParagraphModel *model)

◆ SaveDataToFile()

bool tesseract::SaveDataToFile ( const GenericVector< char > &  data,
const STRING filename 
)
inline

Definition at line 393 of file genericvector.h.

394  {
395  FILE* fp = fopen(filename.string(), "wb");
396  if (fp == nullptr) return false;
397  bool result =
398  static_cast<int>(fwrite(&data[0], 1, data.size(), fp)) == data.size();
399  fclose(fp);
400  return result;
401 }
int size() const
Definition: genericvector.h:71
const char * string() const
Definition: strngs.cpp:196

◆ ScriptPosToString()

const char * tesseract::ScriptPosToString ( enum ScriptPos  script_pos)

Definition at line 200 of file ratngs.cpp.

200  {
201  switch (script_pos) {
202  case SP_NORMAL: return "NORM";
203  case SP_SUBSCRIPT: return "SUB";
204  case SP_SUPERSCRIPT: return "SUPER";
205  case SP_DROPCAP: return "DROPC";
206  }
207  return "SP_UNKNOWN";
208 }

◆ Serialize() [1/8]

bool tesseract::Serialize ( FILE *  fp,
const char *  data,
size_t  n 
)

Definition at line 59 of file serialis.cpp.

59  {
60  return fwrite(data, sizeof(*data), n, fp) == n;
61 }

◆ Serialize() [2/8]

bool tesseract::Serialize ( FILE *  fp,
const float *  data,
size_t  n 
)

Definition at line 63 of file serialis.cpp.

63  {
64  return fwrite(data, sizeof(*data), n, fp) == n;
65 }

◆ Serialize() [3/8]

bool tesseract::Serialize ( FILE *  fp,
const int8_t *  data,
size_t  n 
)

Definition at line 67 of file serialis.cpp.

67  {
68  return fwrite(data, sizeof(*data), n, fp) == n;
69 }

◆ Serialize() [4/8]

bool tesseract::Serialize ( FILE *  fp,
const int16_t *  data,
size_t  n 
)

Definition at line 71 of file serialis.cpp.

71  {
72  return fwrite(data, sizeof(*data), n, fp) == n;
73 }

◆ Serialize() [5/8]

bool tesseract::Serialize ( FILE *  fp,
const int32_t *  data,
size_t  n 
)

Definition at line 75 of file serialis.cpp.

75  {
76  return fwrite(data, sizeof(*data), n, fp) == n;
77 }

◆ Serialize() [6/8]

bool tesseract::Serialize ( FILE *  fp,
const uint8_t *  data,
size_t  n 
)

Definition at line 79 of file serialis.cpp.

79  {
80  return fwrite(data, sizeof(*data), n, fp) == n;
81 }

◆ Serialize() [7/8]

bool tesseract::Serialize ( FILE *  fp,
const uint16_t *  data,
size_t  n 
)

Definition at line 83 of file serialis.cpp.

83  {
84  return fwrite(data, sizeof(*data), n, fp) == n;
85 }

◆ Serialize() [8/8]

bool tesseract::Serialize ( FILE *  fp,
const uint32_t *  data,
size_t  n 
)

Definition at line 87 of file serialis.cpp.

87  {
88  return fwrite(data, sizeof(*data), n, fp) == n;
89 }

◆ SetBlobStrokeWidth()

void tesseract::SetBlobStrokeWidth ( Pix *  pix,
BLOBNBOX blob 
)

Definition at line 69 of file tordmain.cpp.

69  {
70  // Cut the blob rectangle into a Pix.
71  int pix_height = pixGetHeight(pix);
72  const TBOX& box = blob->bounding_box();
73  int width = box.width();
74  int height = box.height();
75  Box* blob_pix_box = boxCreate(box.left(), pix_height - box.top(),
76  width, height);
77  Pix* pix_blob = pixClipRectangle(pix, blob_pix_box, nullptr);
78  boxDestroy(&blob_pix_box);
79  Pix* dist_pix = pixDistanceFunction(pix_blob, 4, 8, L_BOUNDARY_BG);
80  pixDestroy(&pix_blob);
81  // Compute the stroke widths.
82  uint32_t* data = pixGetData(dist_pix);
83  int wpl = pixGetWpl(dist_pix);
84  // Horizontal width of stroke.
85  STATS h_stats(0, width + 1);
86  for (int y = 0; y < height; ++y) {
87  uint32_t* pixels = data + y*wpl;
88  int prev_pixel = 0;
89  int pixel = GET_DATA_BYTE(pixels, 0);
90  for (int x = 1; x < width; ++x) {
91  int next_pixel = GET_DATA_BYTE(pixels, x);
92  // We are looking for a pixel that is equal to its vertical neighbours,
93  // yet greater than its left neighbour.
94  if (prev_pixel < pixel &&
95  (y == 0 || pixel == GET_DATA_BYTE(pixels - wpl, x - 1)) &&
96  (y == height - 1 || pixel == GET_DATA_BYTE(pixels + wpl, x - 1))) {
97  if (pixel > next_pixel) {
98  // Single local max, so an odd width.
99  h_stats.add(pixel * 2 - 1, 1);
100  } else if (pixel == next_pixel && x + 1 < width &&
101  pixel > GET_DATA_BYTE(pixels, x + 1)) {
102  // Double local max, so an even width.
103  h_stats.add(pixel * 2, 1);
104  }
105  }
106  prev_pixel = pixel;
107  pixel = next_pixel;
108  }
109  }
110  // Vertical width of stroke.
111  STATS v_stats(0, height + 1);
112  for (int x = 0; x < width; ++x) {
113  int prev_pixel = 0;
114  int pixel = GET_DATA_BYTE(data, x);
115  for (int y = 1; y < height; ++y) {
116  uint32_t* pixels = data + y*wpl;
117  int next_pixel = GET_DATA_BYTE(pixels, x);
118  // We are looking for a pixel that is equal to its horizontal neighbours,
119  // yet greater than its upper neighbour.
120  if (prev_pixel < pixel &&
121  (x == 0 || pixel == GET_DATA_BYTE(pixels - wpl, x - 1)) &&
122  (x == width - 1 || pixel == GET_DATA_BYTE(pixels - wpl, x + 1))) {
123  if (pixel > next_pixel) {
124  // Single local max, so an odd width.
125  v_stats.add(pixel * 2 - 1, 1);
126  } else if (pixel == next_pixel && y + 1 < height &&
127  pixel > GET_DATA_BYTE(pixels + wpl, x)) {
128  // Double local max, so an even width.
129  v_stats.add(pixel * 2, 1);
130  }
131  }
132  prev_pixel = pixel;
133  pixel = next_pixel;
134  }
135  }
136  pixDestroy(&dist_pix);
137  // Store the horizontal and vertical width in the blob, keeping both
138  // widths if there is enough information, otherwse only the one with
139  // the most samples.
140  // If there are insufficient samples, store zero, rather than using
141  // 2*area/perimeter, as the numbers that gives do not match the numbers
142  // from the distance method.
143  if (h_stats.get_total() >= (width + height) / 4) {
144  blob->set_horz_stroke_width(h_stats.ile(0.5f));
145  if (v_stats.get_total() >= (width + height) / 4)
146  blob->set_vert_stroke_width(v_stats.ile(0.5f));
147  else
148  blob->set_vert_stroke_width(0.0f);
149  } else {
150  if (v_stats.get_total() >= (width + height) / 4 ||
151  v_stats.get_total() > h_stats.get_total()) {
152  blob->set_horz_stroke_width(0.0f);
153  blob->set_vert_stroke_width(v_stats.ile(0.5f));
154  } else {
155  blob->set_horz_stroke_width(h_stats.get_total() > 2 ? h_stats.ile(0.5f)
156  : 0.0f);
157  blob->set_vert_stroke_width(0.0f);
158  }
159  }
160 }
void set_horz_stroke_width(float width)
Definition: blobbox.h:341
Definition: rect.h:34
void set_vert_stroke_width(float width)
Definition: blobbox.h:347
Definition: statistc.h:33
int16_t width() const
Definition: rect.h:115
int16_t left() const
Definition: rect.h:72
int16_t top() const
Definition: rect.h:58
const TBOX & bounding_box() const
Definition: blobbox.h:231
int16_t height() const
Definition: rect.h:108

◆ SetPropertiesForInputFile()

void tesseract::SetPropertiesForInputFile ( const std::string &  script_dir,
const std::string &  input_unicharset_file,
const std::string &  output_unicharset_file,
const std::string &  output_xheights_file 
)

Definition at line 183 of file unicharset_training_utils.cpp.

186  {
187  UNICHARSET unicharset;
188 
189  // Load the input unicharset
190  unicharset.load_from_file(input_unicharset_file.c_str());
191  tprintf("Loaded unicharset of size %d from file %s\n", unicharset.size(),
192  input_unicharset_file.c_str());
193 
194  // Set unichar properties
195  tprintf("Setting unichar properties\n");
196  SetupBasicProperties(true, false, &unicharset);
197  tprintf("Setting script properties\n");
198  SetScriptProperties(script_dir, &unicharset);
199  if (!output_xheights_file.empty()) {
200  std::string xheights_str = GetXheightString(script_dir, unicharset);
201  File::WriteStringToFileOrDie(xheights_str, output_xheights_file);
202  }
203 
204  // Write the output unicharset
205  tprintf("Writing unicharset to file %s\n", output_unicharset_file.c_str());
206  unicharset.save_to_file(output_unicharset_file.c_str());
207 }
void SetupBasicProperties(bool report_errors, bool decompose, UNICHARSET *unicharset)
std::string GetXheightString(const std::string &script_dir, const UNICHARSET &unicharset)
bool save_to_file(const char *const filename) const
Definition: unicharset.h:345
int size() const
Definition: unicharset.h:336
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
void SetScriptProperties(const std::string &script_dir, UNICHARSET *unicharset)
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:383

◆ SetScriptProperties()

void tesseract::SetScriptProperties ( const std::string &  script_dir,
UNICHARSET unicharset 
)

Definition at line 143 of file unicharset_training_utils.cpp.

143  {
144  for (int s = 0; s < unicharset->get_script_table_size(); ++s) {
145  // Load the unicharset for the script if available.
146  std::string filename = script_dir + "/" +
147  unicharset->get_script_from_script_id(s) + ".unicharset";
148  UNICHARSET script_set;
149  if (script_set.load_from_file(filename.c_str())) {
150  unicharset->SetPropertiesFromOther(script_set);
151  } else if (s != unicharset->common_sid() && s != unicharset->null_sid()) {
152  tprintf("Failed to load script unicharset from:%s\n", filename.c_str());
153  }
154  }
155  for (int c = SPECIAL_UNICHAR_CODES_COUNT; c < unicharset->size(); ++c) {
156  if (unicharset->PropertiesIncomplete(c)) {
157  tprintf("Warning: properties incomplete for index %d = %s\n", c,
158  unicharset->id_to_unichar(c));
159  }
160  }
161 }
int common_sid() const
Definition: unicharset.h:879
const char * get_script_from_script_id(int id) const
Definition: unicharset.h:849
int get_script_table_size() const
Definition: unicharset.h:844
bool PropertiesIncomplete(UNICHAR_ID unichar_id) const
Definition: unicharset.h:641
int size() const
Definition: unicharset.h:336
void SetPropertiesFromOther(const UNICHARSET &src)
Definition: unicharset.h:540
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
int null_sid() const
Definition: unicharset.h:878
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:290
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:383

◆ SetupBasicProperties() [1/2]

void tesseract::SetupBasicProperties ( bool  report_errors,
UNICHARSET unicharset 
)
inline

Definition at line 38 of file unicharset_training_utils.h.

38  {
39  SetupBasicProperties(report_errors, false, unicharset);
40 }
void SetupBasicProperties(bool report_errors, UNICHARSET *unicharset)

◆ SetupBasicProperties() [2/2]

void tesseract::SetupBasicProperties ( bool  report_errors,
bool  decompose,
UNICHARSET unicharset 
)

Definition at line 40 of file unicharset_training_utils.cpp.

41  {
42  for (int unichar_id = 0; unichar_id < unicharset->size(); ++unichar_id) {
43  // Convert any custom ligatures.
44  const char* unichar_str = unicharset->id_to_unichar(unichar_id);
45  for (int i = 0; UNICHARSET::kCustomLigatures[i][0] != nullptr; ++i) {
46  if (!strcmp(UNICHARSET::kCustomLigatures[i][1], unichar_str)) {
47  unichar_str = UNICHARSET::kCustomLigatures[i][0];
48  break;
49  }
50  }
51 
52  // Convert the unichar to UTF32 representation
53  std::vector<char32> uni_vector = UNICHAR::UTF8ToUTF32(unichar_str);
54 
55  // Assume that if the property is true for any character in the string,
56  // then it holds for the whole "character".
57  bool unichar_isalpha = false;
58  bool unichar_islower = false;
59  bool unichar_isupper = false;
60  bool unichar_isdigit = false;
61  bool unichar_ispunct = false;
62 
63  for (char32 u_ch : uni_vector) {
64  if (u_isalpha(u_ch)) unichar_isalpha = true;
65  if (u_islower(u_ch)) unichar_islower = true;
66  if (u_isupper(u_ch)) unichar_isupper = true;
67  if (u_isdigit(u_ch)) unichar_isdigit = true;
68  if (u_ispunct(u_ch)) unichar_ispunct = true;
69  }
70 
71  unicharset->set_isalpha(unichar_id, unichar_isalpha);
72  unicharset->set_islower(unichar_id, unichar_islower);
73  unicharset->set_isupper(unichar_id, unichar_isupper);
74  unicharset->set_isdigit(unichar_id, unichar_isdigit);
75  unicharset->set_ispunctuation(unichar_id, unichar_ispunct);
76 
78  unicharset->set_script(unichar_id, uscript_getName(
79  uscript_getScript(uni_vector[0], err)));
80 
81  const int num_code_points = uni_vector.size();
82  // Obtain the lower/upper case if needed and record it in the properties.
83  unicharset->set_other_case(unichar_id, unichar_id);
84  if (unichar_islower || unichar_isupper) {
85  std::vector<char32> other_case(num_code_points, 0);
86  for (int i = 0; i < num_code_points; ++i) {
87  // TODO(daria): Ideally u_strToLower()/ustrToUpper() should be used.
88  // However since they deal with UChars (so need a conversion function
89  // from char32 or UTF8string) and require a meaningful locale string,
90  // for now u_tolower()/u_toupper() are used.
91  other_case[i] = unichar_islower ? u_toupper(uni_vector[i]) :
92  u_tolower(uni_vector[i]);
93  }
94  std::string other_case_uch = UNICHAR::UTF32ToUTF8(other_case);
95  UNICHAR_ID other_case_id =
96  unicharset->unichar_to_id(other_case_uch.c_str());
97  if (other_case_id != INVALID_UNICHAR_ID) {
98  unicharset->set_other_case(unichar_id, other_case_id);
99  } else if (unichar_id >= SPECIAL_UNICHAR_CODES_COUNT && report_errors) {
100  tprintf("Other case %s of %s is not in unicharset\n",
101  other_case_uch.c_str(), unichar_str);
102  }
103  }
104 
105  // Set RTL property and obtain mirror unichar ID from ICU.
106  std::vector<char32> mirrors(num_code_points, 0);
107  for (int i = 0; i < num_code_points; ++i) {
108  mirrors[i] = u_charMirror(uni_vector[i]);
109  if (i == 0) { // set directionality to that of the 1st code point
110  unicharset->set_direction(unichar_id,
111  static_cast<UNICHARSET::Direction>(
112  u_charDirection(uni_vector[i])));
113  }
114  }
115  std::string mirror_uch = UNICHAR::UTF32ToUTF8(mirrors);
116  UNICHAR_ID mirror_uch_id = unicharset->unichar_to_id(mirror_uch.c_str());
117  if (mirror_uch_id != INVALID_UNICHAR_ID) {
118  unicharset->set_mirror(unichar_id, mirror_uch_id);
119  } else if (report_errors) {
120  tprintf("Mirror %s of %s is not in unicharset\n",
121  mirror_uch.c_str(), unichar_str);
122  }
123 
124  // Record normalized version of this unichar.
125  std::string normed_str;
126  if (unichar_id != 0 &&
131  unichar_str, &normed_str) &&
132  !normed_str.empty()) {
133  unicharset->set_normed(unichar_id, normed_str.c_str());
134  } else {
135  unicharset->set_normed(unichar_id, unichar_str);
136  }
137  ASSERT_HOST(unicharset->get_other_case(unichar_id) < unicharset->size());
138  }
139  unicharset->post_load_setup();
140 }
void set_isalpha(UNICHAR_ID unichar_id, bool value)
Definition: unicharset.h:426
signed int char32
int UNICHAR_ID
Definition: unichar.h:35
bool NormalizeUTF8String(UnicodeNormMode u_mode, OCRNorm ocr_normalize, GraphemeNorm grapheme_normalize, const char *str8, std::string *normalized)
Definition: normstrngs.cpp:147
static TESS_API const char * kCustomLigatures[][2]
Definition: unicharset.h:151
void set_ispunctuation(UNICHAR_ID unichar_id, bool value)
Definition: unicharset.h:446
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
Definition: unicharset.cpp:209
int size() const
Definition: unicharset.h:336
void set_other_case(UNICHAR_ID unichar_id, UNICHAR_ID other_case)
Definition: unicharset.h:462
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
void set_isupper(UNICHAR_ID unichar_id, bool value)
Definition: unicharset.h:436
void set_normed(UNICHAR_ID unichar_id, const char *normed)
Definition: unicharset.h:477
void set_islower(UNICHAR_ID unichar_id, bool value)
Definition: unicharset.h:431
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:290
void set_direction(UNICHAR_ID unichar_id, UNICHARSET::Direction value)
Definition: unicharset.h:467
void set_isdigit(UNICHAR_ID unichar_id, bool value)
Definition: unicharset.h:441
UNICHAR_ID get_other_case(UNICHAR_ID unichar_id) const
Definition: unicharset.h:678
void set_mirror(UNICHAR_ID unichar_id, UNICHAR_ID mirror)
Definition: unicharset.h:472
void set_script(UNICHAR_ID unichar_id, const char *value)
Definition: unicharset.h:457
void post_load_setup()
Definition: unicharset.cpp:896
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ SoftmaxInPlace()

template<typename T >
void tesseract::SoftmaxInPlace ( int  n,
T *  inout 
)
inline

Definition at line 163 of file functions.h.

163  {
164  if (n <= 0) return;
165  // A limit on the negative range input to exp to guarantee non-zero output.
166  const T kMaxSoftmaxActivation = 86.0f;
167 
168  T max_output = inout[0];
169  for (int i = 1; i < n; i++) {
170  T output = inout[i];
171  if (output > max_output) max_output = output;
172  }
173  T prob_total = 0.0;
174  for (int i = 0; i < n; i++) {
175  T prob = inout[i] - max_output;
176  prob = exp(ClipToRange(prob, -kMaxSoftmaxActivation, static_cast<T>(0)));
177  prob_total += prob;
178  inout[i] = prob;
179  }
180  if (prob_total > 0.0) {
181  for (int i = 0; i < n; i++) inout[i] /= prob_total;
182  }
183 }
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:111

◆ sort_cmp()

template<typename T >
int tesseract::sort_cmp ( const void *  t1,
const void *  t2 
)

Definition at line 424 of file genericvector.h.

424  {
425  const T* a = static_cast<const T *> (t1);
426  const T* b = static_cast<const T *> (t2);
427  if (*a < *b) {
428  return -1;
429  } else if (*b < *a) {
430  return 1;
431  } else {
432  return 0;
433  }
434 }

◆ sort_ptr_cmp()

template<typename T >
int tesseract::sort_ptr_cmp ( const void *  t1,
const void *  t2 
)

Definition at line 441 of file genericvector.h.

441  {
442  const T* a = *static_cast<T* const*>(t1);
443  const T* b = *static_cast<T* const*>(t2);
444  if (*a < *b) {
445  return -1;
446  } else if (*b < *a) {
447  return 1;
448  } else {
449  return 0;
450  }
451 }

◆ SortByBoxBottom()

template<class BBC >
int tesseract::SortByBoxBottom ( const void *  void1,
const void *  void2 
)

Definition at line 409 of file bbgrid.h.

409  {
410  // The void*s are actually doubly indirected, so get rid of one level.
411  const BBC* p1 = *static_cast<const BBC* const*>(void1);
412  const BBC* p2 = *static_cast<const BBC* const*>(void2);
413  int result = p1->bounding_box().bottom() - p2->bounding_box().bottom();
414  if (result != 0)
415  return result;
416  result = p1->bounding_box().top() - p2->bounding_box().top();
417  if (result != 0)
418  return result;
419  result = p1->bounding_box().left() - p2->bounding_box().left();
420  if (result != 0)
421  return result;
422  return p1->bounding_box().right() - p2->bounding_box().right();
423 }

◆ SortByBoxLeft()

template<class BBC >
int tesseract::SortByBoxLeft ( const void *  void1,
const void *  void2 
)

Definition at line 373 of file bbgrid.h.

373  {
374  // The void*s are actually doubly indirected, so get rid of one level.
375  const BBC* p1 = *static_cast<const BBC* const*>(void1);
376  const BBC* p2 = *static_cast<const BBC* const*>(void2);
377  int result = p1->bounding_box().left() - p2->bounding_box().left();
378  if (result != 0)
379  return result;
380  result = p1->bounding_box().right() - p2->bounding_box().right();
381  if (result != 0)
382  return result;
383  result = p1->bounding_box().bottom() - p2->bounding_box().bottom();
384  if (result != 0)
385  return result;
386  return p1->bounding_box().top() - p2->bounding_box().top();
387 }

◆ SortByRating()

template<class BLOB_CHOICE >
int tesseract::SortByRating ( const void *  void1,
const void *  void2 
)

Definition at line 84 of file pieces.cpp.

84  {
85  const BLOB_CHOICE *p1 = *static_cast<const BLOB_CHOICE *const *>(void1);
86  const BLOB_CHOICE *p2 = *static_cast<const BLOB_CHOICE *const *>(void2);
87 
88  if (p1->rating() < p2->rating())
89  return 1;
90  return -1;
91 }
float rating() const
Definition: ratngs.h:80

◆ SortByUnicharID()

template<class BLOB_CHOICE >
int tesseract::SortByUnicharID ( const void *  void1,
const void *  void2 
)

Definition at line 76 of file pieces.cpp.

76  {
77  const BLOB_CHOICE *p1 = *static_cast<const BLOB_CHOICE *const *>(void1);
78  const BLOB_CHOICE *p2 = *static_cast<const BLOB_CHOICE *const *>(void2);
79 
80  return p1->unichar_id() - p2->unichar_id();
81 }
UNICHAR_ID unichar_id() const
Definition: ratngs.h:77

◆ SortRightToLeft()

template<class BBC >
int tesseract::SortRightToLeft ( const void *  void1,
const void *  void2 
)

Definition at line 391 of file bbgrid.h.

391  {
392  // The void*s are actually doubly indirected, so get rid of one level.
393  const BBC* p1 = *static_cast<const BBC* const*>(void1);
394  const BBC* p2 = *static_cast<const BBC* const*>(void2);
395  int result = p2->bounding_box().right() - p1->bounding_box().right();
396  if (result != 0)
397  return result;
398  result = p2->bounding_box().left() - p1->bounding_box().left();
399  if (result != 0)
400  return result;
401  result = p1->bounding_box().bottom() - p2->bounding_box().bottom();
402  if (result != 0)
403  return result;
404  return p1->bounding_box().top() - p2->bounding_box().top();
405 }

◆ SpanUTF8NotWhitespace()

unsigned int tesseract::SpanUTF8NotWhitespace ( const char *  text)

Definition at line 243 of file normstrngs.cpp.

243  {
244  int n_notwhite = 0;
245  for (UNICHAR::const_iterator it = UNICHAR::begin(text, strlen(text));
246  it != UNICHAR::end(text, strlen(text)); ++it) {
247  if (IsWhitespace(*it)) break;
248  n_notwhite += it.utf8_len();
249  }
250  return n_notwhite;
251 }
bool IsWhitespace(const char32 ch)
Definition: normstrngs.cpp:223

◆ SpanUTF8Whitespace()

unsigned int tesseract::SpanUTF8Whitespace ( const char *  text)

Definition at line 233 of file normstrngs.cpp.

233  {
234  int n_white = 0;
235  for (UNICHAR::const_iterator it = UNICHAR::begin(text, strlen(text));
236  it != UNICHAR::end(text, strlen(text)); ++it) {
237  if (!IsWhitespace(*it)) break;
238  n_white += it.utf8_len();
239  }
240  return n_white;
241 }
bool IsWhitespace(const char32 ch)
Definition: normstrngs.cpp:223

◆ StrongModel()

bool tesseract::StrongModel ( const ParagraphModel model)
inline

Definition at line 71 of file paragraphs_internal.h.

71  {
72  return model != nullptr && model != kCrownLeft && model != kCrownRight;
73 }
const ParagraphModel * kCrownRight
Definition: paragraphs.cpp:57
const ParagraphModel * kCrownLeft
Definition: paragraphs.cpp:55

◆ SumVectors()

void tesseract::SumVectors ( int  n,
const double *  v1,
const double *  v2,
const double *  v3,
const double *  v4,
const double *  v5,
double *  sum 
)
inline

Definition at line 209 of file functions.h.

211  {
212  for (int i = 0; i < n; ++i) {
213  sum[i] = v1[i] + v2[i] + v3[i] + v4[i] + v5[i];
214  }
215 }

◆ Tanh()

double tesseract::Tanh ( double  x)
inline

Definition at line 45 of file functions.h.

45  {
46  if (x < 0.0) return -Tanh(-x);
47  if (x >= (kTableSize - 1) / kScaleFactor) return 1.0;
48  x *= kScaleFactor;
49  int index = static_cast<int>(floor(x));
50  if (TanhTable[index] == 0.0 && index > 0) {
51  // Generate the entry.
52  TanhTable[index] = tanh(index / kScaleFactor);
53  }
54  if (index == kTableSize - 1) return TanhTable[kTableSize - 1];
55  if (TanhTable[index + 1] == 0.0) {
56  // Generate the entry.
57  TanhTable[index + 1] = tanh((index + 1) / kScaleFactor);
58  }
59  double offset = x - index;
60  return TanhTable[index] * (1.0 - offset) + TanhTable[index + 1] * offset;
61 }
double TanhTable[kTableSize]
Definition: functions.cpp:23
const double kScaleFactor
Definition: functions.h:39
double Tanh(double x)
Definition: functions.h:45
const int kTableSize
Definition: functions.h:37

◆ TraceBlockOnReducedPix()

Pix * tesseract::TraceBlockOnReducedPix ( BLOCK block,
int  gridsize,
ICOORD  bleft,
int *  left,
int *  bottom 
)

Definition at line 255 of file bbgrid.cpp.

256  {
257  const TBOX& box = block->pdblk.bounding_box();
258  Pix* pix = GridReducedPix(box, gridsize, bleft, left, bottom);
259  int wpl = pixGetWpl(pix);
260  l_uint32* data = pixGetData(pix);
261  ICOORDELT_IT it(block->pdblk.poly_block()->points());
262  for (it.mark_cycle_pt(); !it.cycled_list();) {
263  ICOORD pos = *it.data();
264  it.forward();
265  ICOORD next_pos = *it.data();
266  ICOORD line_vector = next_pos - pos;
267  int major, minor;
268  ICOORD major_step, minor_step;
269  line_vector.setup_render(&major_step, &minor_step, &major, &minor);
270  int accumulator = major / 2;
271  while (pos != next_pos) {
272  int grid_x = (pos.x() - bleft.x()) / gridsize - *left;
273  int grid_y = (pos.y() - bleft.y()) / gridsize - *bottom;
274  SET_DATA_BIT(data + grid_y * wpl, grid_x);
275  pos += major_step;
276  accumulator += minor;
277  if (accumulator >= major) {
278  accumulator -= major;
279  pos += minor_step;
280  }
281  }
282  }
283  return pix;
284 }
int16_t y() const
access_function
Definition: points.h:57
Definition: rect.h:34
void setup_render(ICOORD *major_step, ICOORD *minor_step, int *major, int *minor) const
Definition: points.cpp:85
integer coordinate
Definition: points.h:32
int16_t x() const
access function
Definition: points.h:53
POLY_BLOCK * poly_block() const
Definition: pdblock.h:56
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:60
ICOORDELT_LIST * points()
Definition: polyblk.h:39
PDBLK pdblk
Definition: ocrblock.h:192

◆ TraceOutlineOnReducedPix()

Pix * tesseract::TraceOutlineOnReducedPix ( C_OUTLINE outline,
int  gridsize,
ICOORD  bleft,
int *  left,
int *  bottom 
)

Definition at line 229 of file bbgrid.cpp.

230  {
231  const TBOX& box = outline->bounding_box();
232  Pix* pix = GridReducedPix(box, gridsize, bleft, left, bottom);
233  int wpl = pixGetWpl(pix);
234  l_uint32* data = pixGetData(pix);
235  int length = outline->pathlength();
236  ICOORD pos = outline->start_pos();
237  for (int i = 0; i < length; ++i) {
238  int grid_x = (pos.x() - bleft.x()) / gridsize - *left;
239  int grid_y = (pos.y() - bleft.y()) / gridsize - *bottom;
240  SET_DATA_BIT(data + grid_y * wpl, grid_x);
241  pos += outline->step(i);
242  }
243  return pix;
244 }
int16_t y() const
access_function
Definition: points.h:57
Definition: rect.h:34
const ICOORD & start_pos() const
Definition: coutln.h:148
integer coordinate
Definition: points.h:32
int16_t x() const
access function
Definition: points.h:53
int32_t pathlength() const
Definition: coutln.h:135
const TBOX & bounding_box() const
Definition: coutln.h:113
ICOORD step(int index) const
Definition: coutln.h:144

◆ UnicodeFor()

int tesseract::UnicodeFor ( const UNICHARSET u,
const WERD_CHOICE werd,
int  pos 
)

Definition at line 289 of file paragraphs.cpp.

289  {
290  if (!u || !werd || pos > werd->length())
291  return 0;
292  return UNICHAR(u->id_to_unichar(werd->unichar_id(pos)), -1).first_uni();
293 }
UNICHAR_ID unichar_id(int index) const
Definition: ratngs.h:315
int length() const
Definition: ratngs.h:303
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:290

◆ ValidBodyLine()

bool tesseract::ValidBodyLine ( const GenericVector< RowScratchRegisters > *  rows,
int  row,
const ParagraphModel model 
)

Definition at line 1290 of file paragraphs.cpp.

1291  {
1292  if (!StrongModel(model)) {
1293  tprintf("ValidBodyLine() should only be called with strong models!\n");
1294  }
1295  return StrongModel(model) &&
1296  model->ValidBodyLine(
1297  (*rows)[row].lmargin_, (*rows)[row].lindent_,
1298  (*rows)[row].rindent_, (*rows)[row].rmargin_);
1299 }
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
bool StrongModel(const ParagraphModel *model)
bool ValidBodyLine(int lmargin, int lindent, int rindent, int rmargin) const
Definition: ocrpara.cpp:63

◆ ValidFirstLine()

bool tesseract::ValidFirstLine ( const GenericVector< RowScratchRegisters > *  rows,
int  row,
const ParagraphModel model 
)

Definition at line 1279 of file paragraphs.cpp.

1280  {
1281  if (!StrongModel(model)) {
1282  tprintf("ValidFirstLine() should only be called with strong models!\n");
1283  }
1284  return StrongModel(model) &&
1285  model->ValidFirstLine(
1286  (*rows)[row].lmargin_, (*rows)[row].lindent_,
1287  (*rows)[row].rindent_, (*rows)[row].rmargin_);
1288 }
bool ValidFirstLine(int lmargin, int lindent, int rindent, int rmargin) const
Definition: ocrpara.cpp:46
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
bool StrongModel(const ParagraphModel *model)

◆ write_info()

bool tesseract::write_info ( FILE *  f,
const FontInfo fi 
)

Definition at line 162 of file fontinfo.cpp.

162  {
163  int32_t size = strlen(fi.name);
164  return tesseract::Serialize(f, &size) &&
165  tesseract::Serialize(f, &fi.name[0], size) &&
166  tesseract::Serialize(f, &fi.properties);
167 }
bool Serialize(FILE *fp, const char *data, size_t n)
Definition: serialis.cpp:59

◆ write_set()

bool tesseract::write_set ( FILE *  f,
const FontSet fs 
)

Definition at line 231 of file fontinfo.cpp.

231  {
232  return tesseract::Serialize(f, &fs.size) &&
233  tesseract::Serialize(f, &fs.configs[0], fs.size);
234 }
bool Serialize(FILE *fp, const char *data, size_t n)
Definition: serialis.cpp:59

◆ write_spacing_info()

bool tesseract::write_spacing_info ( FILE *  f,
const FontInfo fi 
)

Definition at line 197 of file fontinfo.cpp.

197  {
198  int32_t vec_size = (fi.spacing_vec == nullptr) ? 0 : fi.spacing_vec->size();
199  if (!tesseract::Serialize(f, &vec_size)) return false;
200  int16_t x_gap_invalid = -1;
201  for (int i = 0; i < vec_size; ++i) {
202  FontSpacingInfo *fs = fi.spacing_vec->get(i);
203  int32_t kern_size = (fs == nullptr) ? -1 : fs->kerned_x_gaps.size();
204  if (fs == nullptr) {
205  // Writing two invalid x-gaps.
206  if (!tesseract::Serialize(f, &x_gap_invalid, 2) ||
207  !tesseract::Serialize(f, &kern_size)) {
208  return false;
209  }
210  } else {
211  if (!tesseract::Serialize(f, &fs->x_gap_before) ||
212  !tesseract::Serialize(f, &fs->x_gap_after) ||
213  !tesseract::Serialize(f, &kern_size)) {
214  return false;
215  }
216  }
217  if (kern_size > 0 && (!fs->kerned_unichar_ids.Serialize(f) ||
218  !fs->kerned_x_gaps.Serialize(f))) {
219  return false;
220  }
221  }
222  return true;
223 }
bool Serialize(FILE *fp, const char *data, size_t n)
Definition: serialis.cpp:59

◆ WriteFile()

bool tesseract::WriteFile ( const std::string &  output_dir,
const std::string &  lang,
const std::string &  suffix,
const GenericVector< char > &  data,
FileWriter  writer 
)

Definition at line 36 of file lang_model_helpers.cpp.

38  {
39  if (lang.empty()) return true;
40  std::string dirname = output_dir + "/" + lang;
41  // Attempt to make the directory, but ignore errors, as it may not be a
42  // standard filesystem, and the writer will complain if not successful.
43 #if defined(_WIN32)
44  _mkdir(dirname.c_str());
45 #else
46  mkdir(dirname.c_str(), S_IRWXU | S_IRWXG);
47 #endif
48  std::string filename = dirname + "/" + lang + suffix;
49  if (writer == nullptr)
50  return SaveDataToFile(data, filename.c_str());
51  else
52  return (*writer)(data, filename.c_str());
53 }
bool SaveDataToFile(const GenericVector< char > &data, const STRING &filename)

◆ WriteRecoder()

bool tesseract::WriteRecoder ( const UNICHARSET unicharset,
bool  pass_through,
const std::string &  output_dir,
const std::string &  lang,
FileWriter  writer,
STRING radical_table_data,
TessdataManager traineddata 
)

Definition at line 85 of file lang_model_helpers.cpp.

88  {
89  UnicharCompress recoder;
90  // Where the unicharset is carefully setup already to contain a good
91  // compact encoding, use a pass-through recoder that does nothing.
92  // For scripts that have a large number of unicodes (Han, Hangul) we want
93  // to use the recoder to compress the symbol space by re-encoding each
94  // unicode as multiple codes from a smaller 'alphabet' that are related to the
95  // shapes in the character. Hangul Jamo is a perfect example of this.
96  // See the Hangul Syllables section, sub-section "Equivalence" in:
97  // http://www.unicode.org/versions/Unicode10.0.0/ch18.pdf
98  if (pass_through) {
99  recoder.SetupPassThrough(unicharset);
100  } else {
101  int null_char =
102  unicharset.has_special_codes() ? UNICHAR_BROKEN : unicharset.size();
103  tprintf("Null char=%d\n", null_char);
104  if (!recoder.ComputeEncoding(unicharset, null_char, radical_table_data)) {
105  tprintf("Creation of encoded unicharset failed!!\n");
106  return false;
107  }
108  }
109  TFile fp;
110  GenericVector<char> recoder_data;
111  fp.OpenWrite(&recoder_data);
112  if (!recoder.Serialize(&fp)) return false;
113  traineddata->OverwriteEntry(TESSDATA_LSTM_RECODER, &recoder_data[0],
114  recoder_data.size());
115  STRING encoding = recoder.GetEncodingAsString(unicharset);
116  recoder_data.init_to_size(encoding.length(), 0);
117  memcpy(&recoder_data[0], &encoding[0], encoding.length());
118  STRING suffix;
119  suffix.add_str_int(".charset_size=", recoder.code_range());
120  suffix += ".txt";
121  return WriteFile(output_dir, lang, suffix.string(), recoder_data, writer);
122 }
int size() const
Definition: genericvector.h:71
int size() const
Definition: unicharset.h:336
void init_to_size(int size, const T &t)
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
bool WriteFile(const std::string &output_dir, const std::string &lang, const std::string &suffix, const GenericVector< char > &data, FileWriter writer)
void add_str_int(const char *str, int number)
Definition: strngs.cpp:379
Definition: strngs.h:45
bool has_special_codes() const
Definition: unicharset.h:717
int32_t length() const
Definition: strngs.cpp:191

◆ WriteShapeTable()

void tesseract::WriteShapeTable ( const STRING file_prefix,
const ShapeTable shape_table 
)

Definition at line 187 of file commontraining.cpp.

187  {
188  STRING shape_table_file = file_prefix;
189  shape_table_file += kShapeTableFileSuffix;
190  FILE* fp = fopen(shape_table_file.string(), "wb");
191  if (fp != nullptr) {
192  if (!shape_table.Serialize(fp)) {
193  fprintf(stderr, "Error writing shape table: %s\n",
194  shape_table_file.string());
195  }
196  fclose(fp);
197  } else {
198  fprintf(stderr, "Error creating shape table: %s\n",
199  shape_table_file.string());
200  }
201 }
bool Serialize(FILE *fp) const
Definition: shapetable.cpp:241
const char * string() const
Definition: strngs.cpp:196
Definition: strngs.h:45

◆ WriteUnicharset()

bool tesseract::WriteUnicharset ( const UNICHARSET unicharset,
const std::string &  output_dir,
const std::string &  lang,
FileWriter  writer,
TessdataManager traineddata 
)

Definition at line 71 of file lang_model_helpers.cpp.

73  {
74  GenericVector<char> unicharset_data;
75  TFile fp;
76  fp.OpenWrite(&unicharset_data);
77  if (!unicharset.save_to_file(&fp)) return false;
78  traineddata->OverwriteEntry(TESSDATA_LSTM_UNICHARSET, &unicharset_data[0],
79  unicharset_data.size());
80  return WriteFile(output_dir, lang, ".unicharset", unicharset_data, writer);
81 }
int size() const
Definition: genericvector.h:71
bool save_to_file(const char *const filename) const
Definition: unicharset.h:345
bool WriteFile(const std::string &output_dir, const std::string &lang, const std::string &suffix, const GenericVector< char > &data, FileWriter writer)

◆ ZeroVector()

template<typename T >
void tesseract::ZeroVector ( int  n,
T *  vec 
)
inline

Definition at line 219 of file functions.h.

219  {
220  memset(vec, 0, n * sizeof(*vec));
221 }

Variable Documentation

◆ case_state_table

const int tesseract::case_state_table[6][4]
Initial value:
= {
{
0, 1, 5, 4},
{
0, 3, 2, 4},
{
0, -1, 2, -1},
{
0, 3, -1, 4},
{
0, -1, -1, 4},
{
5, -1, 2, -1},
}

Definition at line 35 of file context.cpp.

◆ kAdamCorrectionIterations

const int tesseract::kAdamCorrectionIterations = 200000

Definition at line 37 of file weightmatrix.cpp.

◆ kAdamEpsilon

const double tesseract::kAdamEpsilon = 1e-8

Definition at line 39 of file weightmatrix.cpp.

◆ kAdamFlag

const int tesseract::kAdamFlag = 4

Definition at line 144 of file weightmatrix.cpp.

◆ kAdjacentLeaderSearchPadding

const int tesseract::kAdjacentLeaderSearchPadding = 2

Definition at line 117 of file tablefind.cpp.

◆ kAlignedFraction

const double tesseract::kAlignedFraction = 0.03125

Definition at line 39 of file alignedblob.cpp.

◆ kAlignedGapFraction

const double tesseract::kAlignedGapFraction = 0.75

Definition at line 43 of file alignedblob.cpp.

◆ kAlignmentNames

const char* tesseract::kAlignmentNames[]
Initial value:
= {
"Left Aligned",
"Left Ragged",
"Center",
"Right Aligned",
"Right Ragged",
"Separator"
}

Definition at line 510 of file tabvector.cpp.

◆ kAllowBlobArea

const double tesseract::kAllowBlobArea = 0.05

Definition at line 58 of file tablefind.cpp.

◆ kAllowBlobHeight

const double tesseract::kAllowBlobHeight = 0.3

Definition at line 56 of file tablefind.cpp.

◆ kAllowBlobWidth

const double tesseract::kAllowBlobWidth = 0.4

Definition at line 57 of file tablefind.cpp.

◆ kAllowTextArea

const double tesseract::kAllowTextArea = 0.8

Definition at line 51 of file tablefind.cpp.

◆ kAllowTextHeight

const double tesseract::kAllowTextHeight = 0.5

Definition at line 49 of file tablefind.cpp.

◆ kAllowTextWidth

const double tesseract::kAllowTextWidth = 0.6

Definition at line 50 of file tablefind.cpp.

◆ kApostropheLikeUTF8

const char * tesseract::kApostropheLikeUTF8
Initial value:
= {
"'",
"`",
"\u2018",
"\u2019",
"\u2032",
nullptr,
}

Definition at line 48 of file unicodes.cpp.

◆ kBestCheckpointFraction

const double tesseract::kBestCheckpointFraction = 31.0 / 32.0

Definition at line 68 of file lstmtrainer.cpp.

◆ kBigPartSizeRatio

const double tesseract::kBigPartSizeRatio = 1.75

Definition at line 49 of file colpartitiongrid.cpp.

◆ kBoxClipTolerance

const int tesseract::kBoxClipTolerance = 2

Definition at line 31 of file boxword.cpp.

◆ kBrokenCJKIterationFraction

const double tesseract::kBrokenCJKIterationFraction = 0.125

Definition at line 68 of file strokewidth.cpp.

◆ kBytesPer64BitNumber

const int tesseract::kBytesPer64BitNumber = 20

Max bytes in the decimal representation of int64_t.

Definition at line 1828 of file baseapi.cpp.

◆ kBytesPerBoxFileLine

const int tesseract::kBytesPerBoxFileLine = (kBytesPerNumber + 1) * kNumbersPerBlob + 1

Multiplier for max expected textlength assumes (kBytesPerNumber + space)

  • kNumbersPerBlob plus the newline. Add to this the original UTF8 characters, and one kMaxBytesPerLine for safety.

Definition at line 1826 of file baseapi.cpp.

◆ kBytesPerNumber

const int tesseract::kBytesPerNumber = 5

The number of bytes taken by each number. Since we use int16_t for ICOORD, assume only 5 digits max.

Definition at line 1820 of file baseapi.cpp.

◆ kCellSplitColumnThreshold

const int tesseract::kCellSplitColumnThreshold = 0

Definition at line 42 of file tablerecog.cpp.

◆ kCellSplitRowThreshold

const int tesseract::kCellSplitRowThreshold = 0

Definition at line 41 of file tablerecog.cpp.

◆ kCertaintyScale

const float tesseract::kCertaintyScale = 7.0f

Definition at line 36 of file linerec.cpp.

◆ kCertOffset

const double tesseract::kCertOffset = -0.085

Definition at line 47 of file lstmrecognizer.cpp.

◆ kCJKAspectRatio

const double tesseract::kCJKAspectRatio = 1.25

Definition at line 62 of file strokewidth.cpp.

◆ kCJKAspectRatioIncrease

const double tesseract::kCJKAspectRatioIncrease = 1.0625

Definition at line 64 of file strokewidth.cpp.

◆ kCJKBrokenDistanceFraction

const double tesseract::kCJKBrokenDistanceFraction = 0.25

Definition at line 58 of file strokewidth.cpp.

◆ kCJKMaxComponents

const int tesseract::kCJKMaxComponents = 8

Definition at line 60 of file strokewidth.cpp.

◆ kCJKRadius

const int tesseract::kCJKRadius = 2

Definition at line 56 of file strokewidth.cpp.

◆ kColumnWidthFactor

const int tesseract::kColumnWidthFactor = 20

Pixel resolution of column width estimates.

Definition at line 42 of file tabfind.h.

◆ kCosMaxSkewAngle

const double tesseract::kCosMaxSkewAngle = 0.866025

Definition at line 61 of file tabfind.cpp.

◆ kCrackSpacing

const int tesseract::kCrackSpacing = 100

Spacing of cracks across the page to break up tall vertical lines.

Definition at line 43 of file linefind.cpp.

◆ kCrownLeft

const ParagraphModel * tesseract::kCrownLeft = reinterpret_cast<ParagraphModel *>(0xDEAD111F)

Definition at line 55 of file paragraphs.cpp.

◆ kCrownRight

const ParagraphModel * tesseract::kCrownRight = reinterpret_cast<ParagraphModel *>(0xDEAD888F)

Definition at line 57 of file paragraphs.cpp.

◆ kDefaultResolution

const int tesseract::kDefaultResolution = 300

Definition at line 71 of file pango_font_info.cpp.

◆ kDiacriticXPadRatio

const double tesseract::kDiacriticXPadRatio = 7.0

Definition at line 71 of file strokewidth.cpp.

◆ kDiacriticYPadRatio

const double tesseract::kDiacriticYPadRatio = 1.75

Definition at line 74 of file strokewidth.cpp.

◆ kDictRatio

const double tesseract::kDictRatio = 2.25

Definition at line 45 of file lstmrecognizer.cpp.

◆ kDoNotReverse

const char tesseract::kDoNotReverse[] = "RRP_DO_NO_REVERSE"

Definition at line 40 of file trie.cpp.

◆ kDoubleFlag

const int tesseract::kDoubleFlag = 128

Definition at line 148 of file weightmatrix.cpp.

◆ kErrClip

const double tesseract::kErrClip = 1.0f

Definition at line 72 of file lstm.cpp.

◆ kErrorGraphInterval

const int tesseract::kErrorGraphInterval = 1000

Definition at line 56 of file lstmtrainer.cpp.

◆ kExposureFactor

const int tesseract::kExposureFactor = 16

Definition at line 58 of file degradeimage.cpp.

◆ kFeaturePadding

const int tesseract::kFeaturePadding = 2

Definition at line 37 of file imagedata.h.

◆ kFontMergeDistance

const float tesseract::kFontMergeDistance = 0.025

Definition at line 49 of file mastertrainer.cpp.

◆ kForceReverse

const char tesseract::kForceReverse[] = "RRP_FORCE_REVERSE"

Definition at line 42 of file trie.cpp.

◆ kGoodRowNumberOfColumnsLarge

const double tesseract::kGoodRowNumberOfColumnsLarge = 0.7

Definition at line 60 of file tablerecog.cpp.

◆ kGoodRowNumberOfColumnsSmall

const double tesseract::kGoodRowNumberOfColumnsSmall[] = { 2, 2, 2, 2, 2, 3, 3 }

Definition at line 56 of file tablerecog.cpp.

◆ kGoodRowNumberOfColumnsSmallSize

const int tesseract::kGoodRowNumberOfColumnsSmallSize
Initial value:
=
sizeof(kGoodRowNumberOfColumnsSmall) / sizeof(double) - 1
const double kGoodRowNumberOfColumnsSmall[]
Definition: tablerecog.cpp:56

Definition at line 57 of file tablerecog.cpp.

◆ kGutterMultiple

const int tesseract::kGutterMultiple = 4

Definition at line 36 of file tabvector.cpp.

◆ kGutterToNeighbourRatio

const int tesseract::kGutterToNeighbourRatio = 3

Definition at line 38 of file tabvector.cpp.

◆ kHighConfidence

const double tesseract::kHighConfidence = 0.9375

Definition at line 64 of file lstmtrainer.cpp.

◆ kHistogramBuckets

const int tesseract::kHistogramBuckets = 16

Definition at line 341 of file weightmatrix.cpp.

◆ kHistogramSize

const int tesseract::kHistogramSize = 256

Definition at line 27 of file otsuthr.h.

◆ kHorizontalGapMergeFraction

const double tesseract::kHorizontalGapMergeFraction = 0.5

Definition at line 50 of file colfind.cpp.

◆ kHorizontalSpacing

const double tesseract::kHorizontalSpacing = 0.30

Definition at line 35 of file tablerecog.cpp.

◆ kHorzStrongTextlineAspect

const int tesseract::kHorzStrongTextlineAspect = 5

Definition at line 67 of file colpartition.cpp.

◆ kHorzStrongTextlineCount

const int tesseract::kHorzStrongTextlineCount = 8

Definition at line 63 of file colpartition.cpp.

◆ kHorzStrongTextlineHeight

const int tesseract::kHorzStrongTextlineHeight = 10

Definition at line 65 of file colpartition.cpp.

◆ kHyphenLikeUTF8

const char * tesseract::kHyphenLikeUTF8
Initial value:
= {
"-",
"\u05BE",
"\u2010",
"\u2011",
"\u2012",
"\u2013",
"\u2014",
"\u2015",
"\u2212",
"\uFE58",
"\uFE63",
"\uFF0D",
nullptr,
}

The following are confusable internal word punctuation symbols which we normalize to the first variant when matching in dawgs.

Definition at line 32 of file unicodes.cpp.

◆ kImagePadding

const int tesseract::kImagePadding = 4

Definition at line 39 of file imagedata.h.

◆ kImprovementFraction

const double tesseract::kImprovementFraction = 15.0 / 16.0

Definition at line 66 of file lstmtrainer.cpp.

◆ kInfiniteDist

const float tesseract::kInfiniteDist = 999.0f

Definition at line 906 of file mastertrainer.cpp.

◆ kInputFile

const char* tesseract::kInputFile = "noname.tif"

Filename used for input image file, from which to derive a name to search for a possible UNLV zone file, if none is specified by SetInputName.

Definition at line 108 of file baseapi.cpp.

◆ kInt8Flag

const int tesseract::kInt8Flag = 1

Definition at line 142 of file weightmatrix.cpp.

◆ kLargeTableProjectionThreshold

const double tesseract::kLargeTableProjectionThreshold = 0.45

Definition at line 107 of file tablefind.cpp.

◆ kLargeTableRowCount

const int tesseract::kLargeTableRowCount = 6

Definition at line 109 of file tablefind.cpp.

◆ kLatinChs

const int tesseract::kLatinChs[]
Initial value:
= {
0x00a2, 0x0022, 0x0022, 0x0027, 0x0027, 0x00b7, 0x002d, 0
}

Latin chars corresponding to the unicode chars above.

Definition at line 1889 of file baseapi.cpp.

◆ kLearningRateDecay

const double tesseract::kLearningRateDecay = sqrt(0.5)

Definition at line 52 of file lstmtrainer.cpp.

◆ kLeftIndentAlignmentCountTh

const int tesseract::kLeftIndentAlignmentCountTh = 1

Definition at line 86 of file equationdetect.cpp.

◆ kLineCountReciprocal

const double tesseract::kLineCountReciprocal = 4.0

Definition at line 49 of file tabvector.cpp.

◆ kLinedTableMinHorizontalLines

const int tesseract::kLinedTableMinHorizontalLines = 3

Definition at line 45 of file tablerecog.cpp.

◆ kLinedTableMinVerticalLines

const int tesseract::kLinedTableMinVerticalLines = 3

Definition at line 44 of file tablerecog.cpp.

◆ kLineFindGridSize

const int tesseract::kLineFindGridSize = 50

Grid size used by line finder. Not very critical.

Definition at line 45 of file linefind.cpp.

◆ kLineFragmentAspectRatio

const double tesseract::kLineFragmentAspectRatio = 10.0

Definition at line 55 of file tabfind.cpp.

◆ kLineResidueAspectRatio

const double tesseract::kLineResidueAspectRatio = 8.0

Definition at line 95 of file strokewidth.cpp.

◆ kLineResiduePadRatio

const int tesseract::kLineResiduePadRatio = 3

Definition at line 97 of file strokewidth.cpp.

◆ kLineResidueSizeRatio

const double tesseract::kLineResidueSizeRatio = 1.75

Definition at line 99 of file strokewidth.cpp.

◆ kLineTrapLongest

const int tesseract::kLineTrapLongest = 4

Definition at line 88 of file strokewidth.cpp.

◆ kLineTrapShortest

const int tesseract::kLineTrapShortest = 2

Definition at line 90 of file strokewidth.cpp.

◆ kLRM

const char * tesseract::kLRM = "\u200E"

Definition at line 27 of file unicodes.cpp.

◆ kMarginFactor

const double tesseract::kMarginFactor = 1.1

Definition at line 50 of file tablerecog.cpp.

◆ kMarginOverlapFraction

const double tesseract::kMarginOverlapFraction = 0.25

Definition at line 47 of file colpartitiongrid.cpp.

◆ kMathDigitDensityTh1

const float tesseract::kMathDigitDensityTh1 = 0.25

Definition at line 81 of file equationdetect.cpp.

◆ kMathDigitDensityTh2

const float tesseract::kMathDigitDensityTh2 = 0.1

Definition at line 82 of file equationdetect.cpp.

◆ kMathItalicDensityTh

const float tesseract::kMathItalicDensityTh = 0.5

Definition at line 83 of file equationdetect.cpp.

◆ kMaxAmbigStringSize

const int tesseract::kMaxAmbigStringSize = UNICHAR_LEN * (MAX_AMBIG_SIZE + 1)

Definition at line 36 of file ambigs.cpp.

◆ kMaxBaselineError

const double tesseract::kMaxBaselineError = 0.4375

Definition at line 70 of file colpartition.cpp.

◆ kMaxBlobOverlapFactor

const double tesseract::kMaxBlobOverlapFactor = 4.0

Definition at line 77 of file tablefind.cpp.

◆ kMaxBlobWidth

const int tesseract::kMaxBlobWidth = 500

Definition at line 40 of file tablefind.cpp.

◆ kMaxBoxEdgeDiff

const int16_t tesseract::kMaxBoxEdgeDiff = 2

Definition at line 31 of file recogtraining.cpp.

◆ kMaxBoxesInDataPartition

const int tesseract::kMaxBoxesInDataPartition = 20

Definition at line 66 of file tablefind.cpp.

◆ kMaxBytesPerLine

const int tesseract::kMaxBytesPerLine
Initial value:
#define UNICHAR_LEN
Definition: unichar.h:31
const int kBytesPer64BitNumber
Definition: baseapi.cpp:1828
const int kNumbersPerBlob
Definition: baseapi.cpp:1815

A maximal single box could occupy kNumbersPerBlob numbers at kBytesPer64BitNumber digits (if someone sneaks in a 64 bit value) and a space plus the newline and the maximum length of a UNICHAR. Test against this on each iteration for safety.

Definition at line 1835 of file baseapi.cpp.

◆ kMaxCaptionLines

const int tesseract::kMaxCaptionLines = 7

Definition at line 41 of file colpartitiongrid.cpp.

◆ kMaxCharTopRange

const int tesseract::kMaxCharTopRange = 48

Definition at line 67 of file fixxht.cpp.

◆ kMaxCircleErosions

const int tesseract::kMaxCircleErosions = 8

Definition at line 53 of file pagesegmain.cpp.

◆ kMaxCJKSizeRatio

const int tesseract::kMaxCJKSizeRatio = 5

Definition at line 66 of file strokewidth.cpp.

◆ kMaxColorDistance

const int tesseract::kMaxColorDistance = 900

Definition at line 77 of file colpartition.cpp.

◆ kMaxColumnHeaderDistance

const int tesseract::kMaxColumnHeaderDistance = 4

Definition at line 85 of file tablefind.cpp.

◆ kMaxDiacriticDistanceRatio

const double tesseract::kMaxDiacriticDistanceRatio = 1.25

Definition at line 80 of file strokewidth.cpp.

◆ kMaxDiacriticGapToBaseCharHeight

const double tesseract::kMaxDiacriticGapToBaseCharHeight = 1.0

Definition at line 83 of file strokewidth.cpp.

◆ kMaxDistToPartSizeRatio

const double tesseract::kMaxDistToPartSizeRatio = 1.5

Definition at line 55 of file colfind.cpp.

◆ kMaxFillinMultiple

const int tesseract::kMaxFillinMultiple = 11

Definition at line 45 of file tabvector.cpp.

◆ kMaxGapInTextPartition

const double tesseract::kMaxGapInTextPartition = 4.0

Definition at line 69 of file tablefind.cpp.

◆ kMaxGutterWidthAbsolute

const double tesseract::kMaxGutterWidthAbsolute = 2.00

Definition at line 50 of file tabfind.cpp.

◆ kMaxIncompatibleColumnCount

const int tesseract::kMaxIncompatibleColumnCount = 2

Definition at line 47 of file colfind.cpp.

◆ kMaxInputHeight

const int tesseract::kMaxInputHeight = 48

Definition at line 29 of file input.cpp.

◆ kMaxIntSize

const int tesseract::kMaxIntSize = 22

Max string length of an int.

Definition at line 114 of file baseapi.cpp.

◆ kMaxLargeOverlapsWithMedium

const int tesseract::kMaxLargeOverlapsWithMedium = 12

Definition at line 44 of file ccnontextdetect.cpp.

◆ kMaxLargeOverlapsWithSmall

const int tesseract::kMaxLargeOverlapsWithSmall = 3

Definition at line 35 of file ccnontextdetect.cpp.

◆ kMaxLeaderGapFractionOfMax

const double tesseract::kMaxLeaderGapFractionOfMax = 0.25

Definition at line 53 of file colpartition.cpp.

◆ kMaxLeaderGapFractionOfMin

const double tesseract::kMaxLeaderGapFractionOfMin = 0.5

Definition at line 55 of file colpartition.cpp.

◆ kMaxLigature

const int tesseract::kMaxLigature = 0xfb17

Definition at line 46 of file ligature_table.cpp.

◆ kMaxLineLength

const int tesseract::kMaxLineLength = 1024

Definition at line 318 of file boxchar.cpp.

◆ kMaxLineResidue

const int tesseract::kMaxLineResidue = 6

Definition at line 51 of file linefind.cpp.

◆ kMaxMediumOverlapsWithSmall

const int tesseract::kMaxMediumOverlapsWithSmall = 12

Definition at line 40 of file ccnontextdetect.cpp.

◆ kMaxNeighbourDistFactor

const int tesseract::kMaxNeighbourDistFactor = 4

Definition at line 39 of file colpartitiongrid.cpp.

◆ kMaxNonLineDensity

const double tesseract::kMaxNonLineDensity = 0.25

Definition at line 56 of file linefind.cpp.

◆ kMaxOffsetDist

const int tesseract::kMaxOffsetDist = 32

Definition at line 32 of file intfeaturemap.cpp.

◆ kMaxPadFactor

const int tesseract::kMaxPadFactor = 6

Definition at line 36 of file colpartitiongrid.cpp.

◆ kMaxParagraphEndingLeftSpaceMultiple

const double tesseract::kMaxParagraphEndingLeftSpaceMultiple = 3.0

Definition at line 126 of file tablefind.cpp.

◆ kMaxPartitionSpacing

const double tesseract::kMaxPartitionSpacing = 1.75

Definition at line 64 of file colpartitiongrid.cpp.

◆ kMaxRaggedSearch

const int tesseract::kMaxRaggedSearch = 25

Definition at line 40 of file tabfind.cpp.

◆ kMaxRealDistance

const int tesseract::kMaxRealDistance = 2.0

Definition at line 39 of file detlinefit.cpp.

◆ kMaxRectangularFraction

const double tesseract::kMaxRectangularFraction = 0.75

Definition at line 43 of file imagefind.cpp.

◆ kMaxRectangularGradient

const double tesseract::kMaxRectangularGradient = 0.1

Definition at line 46 of file imagefind.cpp.

◆ kMaxRMSColorNoise

const int tesseract::kMaxRMSColorNoise = 128

Definition at line 74 of file colpartition.cpp.

◆ kMaxRowSize

const double tesseract::kMaxRowSize = 2.5

Definition at line 53 of file tablerecog.cpp.

◆ kMaxSameBlockLineSpacing

const double tesseract::kMaxSameBlockLineSpacing = 3

Definition at line 49 of file colpartition.cpp.

◆ kMaxSizeRatio

const double tesseract::kMaxSizeRatio = 1.5

Definition at line 51 of file colpartition.cpp.

◆ kMaxSkewFactor

const int tesseract::kMaxSkewFactor = 15

Definition at line 65 of file alignedblob.cpp.

◆ kMaxSmallNeighboursPerPix

const double tesseract::kMaxSmallNeighboursPerPix = 1.0 / 32

Definition at line 32 of file ccnontextdetect.cpp.

◆ kMaxSpacingDrift

const double tesseract::kMaxSpacingDrift = 1.0 / 72

Definition at line 43 of file colpartition.cpp.

◆ kMaxStaveHeight

const double tesseract::kMaxStaveHeight = 1.0

Definition at line 58 of file linefind.cpp.

◆ kMaxTableCellXheight

const double tesseract::kMaxTableCellXheight = 2.0

Definition at line 81 of file tablefind.cpp.

◆ kMaxTopSpacingFraction

const double tesseract::kMaxTopSpacingFraction = 0.25

Definition at line 46 of file colpartition.cpp.

◆ kMaxUnicharsPerCluster

const int tesseract::kMaxUnicharsPerCluster = 2000

Definition at line 47 of file mastertrainer.cpp.

◆ kMaxVerticalSearch

const int tesseract::kMaxVerticalSearch = 12

Definition at line 39 of file tabfind.cpp.

◆ kMaxVerticalSpacing

const int tesseract::kMaxVerticalSpacing = 500

Definition at line 38 of file tablefind.cpp.

◆ kMaxWinSize

const int tesseract::kMaxWinSize = 2000

Definition at line 51 of file network.cpp.

◆ kMaxXProjectionGapFactor

const double tesseract::kMaxXProjectionGapFactor = 2.0

Definition at line 136 of file tablefind.cpp.

◆ kMinAlignedGutter

const double tesseract::kMinAlignedGutter = 0.25

Definition at line 51 of file tabvector.cpp.

◆ kMinAlignedTabs

const int tesseract::kMinAlignedTabs = 4

Definition at line 55 of file alignedblob.cpp.

◆ kMinBaselineCoverage

const double tesseract::kMinBaselineCoverage = 0.5

Definition at line 72 of file colpartition.cpp.

◆ kMinBoxesInTextPartition

const int tesseract::kMinBoxesInTextPartition = 10

Definition at line 63 of file tablefind.cpp.

◆ kMinCaptionGapHeightRatio

const double tesseract::kMinCaptionGapHeightRatio = 0.5

Definition at line 45 of file colpartitiongrid.cpp.

◆ kMinCaptionGapRatio

const double tesseract::kMinCaptionGapRatio = 2.0

Definition at line 43 of file colpartitiongrid.cpp.

◆ kMinCertainty

const float tesseract::kMinCertainty = -20.0f

Definition at line 30 of file networkio.cpp.

◆ kMinChainTextValue

const int tesseract::kMinChainTextValue = 3

Definition at line 61 of file colpartition.cpp.

◆ kMinClusteredShapes

const int tesseract::kMinClusteredShapes = 1

Definition at line 45 of file mastertrainer.cpp.

◆ kMinColorDifference

const int tesseract::kMinColorDifference = 16

Definition at line 52 of file imagefind.cpp.

◆ kMinColumnWidth

const int tesseract::kMinColumnWidth = 2.0 / 3

Definition at line 32 of file colpartitionset.cpp.

◆ kMinDiacriticSizeRatio

const double tesseract::kMinDiacriticSizeRatio = 1.0625

Definition at line 77 of file strokewidth.cpp.

◆ kMinDivergenceRate

const double tesseract::kMinDivergenceRate = 50.0

Definition at line 45 of file lstmtrainer.cpp.

◆ kMinEvaluatedTabs

const int tesseract::kMinEvaluatedTabs = 3

Definition at line 57 of file tabfind.cpp.

◆ kMinFilledArea

const double tesseract::kMinFilledArea = 0.35

Definition at line 63 of file tablerecog.cpp.

◆ kMinFractionalLinesInColumn

const double tesseract::kMinFractionalLinesInColumn = 0.125

Definition at line 46 of file tabfind.cpp.

◆ kMinGoodTextPARatio

const double tesseract::kMinGoodTextPARatio = 1.5

Definition at line 60 of file ccnontextdetect.cpp.

◆ kMinGutterFraction

const double tesseract::kMinGutterFraction = 0.5

Definition at line 47 of file tabvector.cpp.

◆ kMinGutterWidthGrid

const double tesseract::kMinGutterWidthGrid = 0.5

Definition at line 52 of file colfind.cpp.

◆ kMinImageFindSize

const int tesseract::kMinImageFindSize = 100

Definition at line 48 of file imagefind.cpp.

◆ kMinLeaderCount

const int tesseract::kMinLeaderCount = 5

Definition at line 57 of file colpartition.cpp.

◆ kMinLigature

const int tesseract::kMinLigature = 0xfb00

Definition at line 45 of file ligature_table.cpp.

◆ kMinLineLengthFraction

const int tesseract::kMinLineLengthFraction = 4

Denominator of resolution makes min pixels to demand line lengths to be.

Definition at line 41 of file linefind.cpp.

◆ kMinLinesInColumn

const int tesseract::kMinLinesInColumn = 10

Definition at line 42 of file tabfind.cpp.

◆ kMinMaxGapInTextPartition

const double tesseract::kMinMaxGapInTextPartition = 0.5

Definition at line 73 of file tablefind.cpp.

◆ kMinMusicPixelFraction

const double tesseract::kMinMusicPixelFraction = 0.75

Definition at line 60 of file linefind.cpp.

◆ kMinOverlapWithTable

const double tesseract::kMinOverlapWithTable = 0.6

Definition at line 97 of file tablefind.cpp.

◆ kMinParagraphEndingTextToWhitespaceRatio

const double tesseract::kMinParagraphEndingTextToWhitespaceRatio = 3.0

Definition at line 132 of file tablefind.cpp.

◆ kMinPointsForErrorCount

const int tesseract::kMinPointsForErrorCount = 16

Definition at line 36 of file detlinefit.cpp.

◆ kMinProb

const float tesseract::kMinProb = exp(kMinCertainty)

Definition at line 32 of file networkio.cpp.

◆ kMinRaggedGutter

const double tesseract::kMinRaggedGutter = 1.5

Definition at line 53 of file tabvector.cpp.

◆ kMinRaggedTabs

const int tesseract::kMinRaggedTabs = 5

Definition at line 53 of file alignedblob.cpp.

◆ kMinRampSize

const int tesseract::kMinRampSize = 1000

Definition at line 62 of file degradeimage.cpp.

◆ kMinRectangularFraction

const double tesseract::kMinRectangularFraction = 0.125

Definition at line 41 of file imagefind.cpp.

◆ kMinRectSize

const int tesseract::kMinRectSize = 10

Minimum sensible image size to be worth running tesseract.

Definition at line 97 of file baseapi.cpp.

◆ kMinRowsInTable

const int tesseract::kMinRowsInTable = 3

Definition at line 112 of file tablefind.cpp.

◆ kMinStallIterations

const int tesseract::kMinStallIterations = 10000

Definition at line 47 of file lstmtrainer.cpp.

◆ kMinStartedErrorRate

const int tesseract::kMinStartedErrorRate = 75

Definition at line 60 of file lstmtrainer.cpp.

◆ kMinStrongTextValue

const int tesseract::kMinStrongTextValue = 6

Definition at line 59 of file colpartition.cpp.

◆ kMinTabGradient

const double tesseract::kMinTabGradient = 4.0

Definition at line 61 of file alignedblob.cpp.

◆ kMinThickLineWidth

const int tesseract::kMinThickLineWidth = 12

Definition at line 47 of file linefind.cpp.

◆ kMinVerticalSearch

const int tesseract::kMinVerticalSearch = 3

Definition at line 38 of file tabfind.cpp.

◆ kMinWinSize

const int tesseract::kMinWinSize = 500

Definition at line 50 of file network.cpp.

◆ kMostlyOneDirRatio

const int tesseract::kMostlyOneDirRatio = 3

Definition at line 93 of file strokewidth.cpp.

◆ kNeighbourSearchFactor

const double tesseract::kNeighbourSearchFactor = 2.5

Definition at line 103 of file strokewidth.cpp.

◆ kNodeContNames

const char* tesseract::kNodeContNames[] = {"Anything", "OnlyDup", "NoDup"}

Definition at line 45 of file recodebeam.cpp.

◆ kNoiseOverlapAreaFactor

const double tesseract::kNoiseOverlapAreaFactor = 1.0 / 512

Definition at line 108 of file strokewidth.cpp.

◆ kNoiseOverlapGrowthFactor

const double tesseract::kNoiseOverlapGrowthFactor = 4.0

Definition at line 105 of file strokewidth.cpp.

◆ kNoisePadding

const int tesseract::kNoisePadding = 4

Definition at line 51 of file ccnontextdetect.cpp.

◆ kNullChar

const char* tesseract::kNullChar = "<nul>"

Definition at line 30 of file unicharcompress.cpp.

◆ kNumAdjustmentIterations

const int tesseract::kNumAdjustmentIterations = 100

Definition at line 54 of file lstmtrainer.cpp.

◆ kNumbersPerBlob

const int tesseract::kNumbersPerBlob = 5

The 5 numbers output for each box (the usual 4 and a page number.)

Definition at line 1815 of file baseapi.cpp.

◆ kNumEndPoints

const int tesseract::kNumEndPoints = 3

Definition at line 30 of file detlinefit.cpp.

◆ kNumPagesPerBatch

const int tesseract::kNumPagesPerBatch = 100

Definition at line 58 of file lstmtrainer.cpp.

◆ kOldVarsFile

const char* tesseract::kOldVarsFile = "failed_vars.txt"

Temp file used for storing current parameters before applying retry values.

Definition at line 112 of file baseapi.cpp.

◆ kOriginalNoiseMultiple

const int tesseract::kOriginalNoiseMultiple = 8

Definition at line 47 of file ccnontextdetect.cpp.

◆ kParagraphEndingPreviousLineRatio

const double tesseract::kParagraphEndingPreviousLineRatio = 1.3

Definition at line 122 of file tablefind.cpp.

◆ kPDF

const char * tesseract::kPDF = "\u202C"

Definition at line 30 of file unicodes.cpp.

◆ kPhotoOffsetFraction

const double tesseract::kPhotoOffsetFraction = 0.375

Definition at line 54 of file ccnontextdetect.cpp.

◆ kPrime1

const int tesseract::kPrime1 = 17

Definition at line 36 of file trainingsampleset.cpp.

◆ kPrime2

const int tesseract::kPrime2 = 13

Definition at line 37 of file trainingsampleset.cpp.

◆ kRadicalRadix

const int tesseract::kRadicalRadix = 29

Definition at line 32 of file unicharcompress.cpp.

◆ kRaggedFraction

const double tesseract::kRaggedFraction = 2.5

Definition at line 41 of file alignedblob.cpp.

◆ kRaggedGapFraction

const double tesseract::kRaggedGapFraction = 1.0

Definition at line 45 of file alignedblob.cpp.

◆ kRaggedGutterMultiple

const int tesseract::kRaggedGutterMultiple = 5

Definition at line 52 of file tabfind.cpp.

◆ kRandomizingCenter

const int tesseract::kRandomizingCenter = 128

Definition at line 35 of file trainingsample.cpp.

◆ kRatingEpsilon

const double tesseract::kRatingEpsilon = 1.0 / 32

Definition at line 31 of file errorcounter.cpp.

◆ kRequiredColumns

const double tesseract::kRequiredColumns = 0.7

Definition at line 48 of file tablerecog.cpp.

◆ kReverseIfHasRTL

const char tesseract::kReverseIfHasRTL[] = "RRP_REVERSE_IF_HAS_RTL"

Definition at line 41 of file trie.cpp.

◆ kRGBRMSColors

const int tesseract::kRGBRMSColors = 4

Definition at line 37 of file colpartition.h.

◆ kRLE

const char * tesseract::kRLE = "\u202A"

Definition at line 29 of file unicodes.cpp.

◆ kRLM

const char * tesseract::kRLM = "\u200F"

Definition at line 28 of file unicodes.cpp.

◆ kRMSFitScaling

const double tesseract::kRMSFitScaling = 8.0

Definition at line 50 of file imagefind.cpp.

◆ kRotationRange

const float tesseract::kRotationRange = 0.02f

Definition at line 56 of file degradeimage.cpp.

◆ kRulingVerticalMargin

const int tesseract::kRulingVerticalMargin = 3

Definition at line 93 of file tablefind.cpp.

◆ kSaltnPepper

const int tesseract::kSaltnPepper = 5

Definition at line 60 of file degradeimage.cpp.

◆ kScaleFactor

const double tesseract::kScaleFactor = 256.0

Definition at line 39 of file functions.h.

◆ kSeedBlobsCountTh

const int tesseract::kSeedBlobsCountTh = 10

Definition at line 85 of file equationdetect.cpp.

◆ kSideSpaceMargin

const int tesseract::kSideSpaceMargin = 10

Definition at line 102 of file tablefind.cpp.

◆ kSimilarRaggedDist

const int tesseract::kSimilarRaggedDist = 50

Definition at line 43 of file tabvector.cpp.

◆ kSimilarVectorDist

const int tesseract::kSimilarVectorDist = 10

Definition at line 40 of file tabvector.cpp.

◆ ksizeofUniversalAmbigsFile

const int tesseract::ksizeofUniversalAmbigsFile = sizeof(kUniversalAmbigsFile)

Definition at line 27 of file universalambigs.h.

◆ kSizeRatioToReject

const float tesseract::kSizeRatioToReject = 2.0

Definition at line 101 of file strokewidth.cpp.

◆ kSmallTableProjectionThreshold

const double tesseract::kSmallTableProjectionThreshold = 0.35

Definition at line 106 of file tablefind.cpp.

◆ kSmoothDecisionMargin

const int tesseract::kSmoothDecisionMargin = 4

Definition at line 67 of file colpartitiongrid.cpp.

◆ kSplitPartitionSize

const double tesseract::kSplitPartitionSize = 2.0

Definition at line 44 of file tablefind.cpp.

◆ kSquareLimit

const int tesseract::kSquareLimit = 25

Definition at line 34 of file trainingsampleset.cpp.

◆ kStageTransitionThreshold

const double tesseract::kStageTransitionThreshold = 10.0

Definition at line 62 of file lstmtrainer.cpp.

◆ kStateClip

const double tesseract::kStateClip = 100.0

Definition at line 70 of file lstm.cpp.

◆ kStrokeWidthCJK

const double tesseract::kStrokeWidthCJK = 2.0

Definition at line 53 of file strokewidth.cpp.

◆ kStrokeWidthConstantTolerance

const double tesseract::kStrokeWidthConstantTolerance = 2.0

Definition at line 141 of file tablefind.cpp.

◆ kStrokeWidthFractionalTolerance

const double tesseract::kStrokeWidthFractionalTolerance = 0.25

Definition at line 140 of file tablefind.cpp.

◆ kStrokeWidthFractionCJK

const double tesseract::kStrokeWidthFractionCJK = 0.25

Definition at line 52 of file strokewidth.cpp.

◆ kStrokeWidthFractionTolerance

const double tesseract::kStrokeWidthFractionTolerance = 0.125

Allowed proportional change in stroke width to be the same font.

Definition at line 45 of file strokewidth.cpp.

◆ kStrokeWidthTolerance

const double tesseract::kStrokeWidthTolerance = 1.5

Allowed constant change in stroke width to be the same font. Really 1.5 pixels.

Definition at line 50 of file strokewidth.cpp.

◆ kSubTrainerMarginFraction

const double tesseract::kSubTrainerMarginFraction = 3.0 / 128

Definition at line 50 of file lstmtrainer.cpp.

◆ kTableColumnThreshold

const double tesseract::kTableColumnThreshold = 3.0

Definition at line 89 of file tablefind.cpp.

◆ kTableSize

const int tesseract::kTableSize = 4096

Definition at line 37 of file functions.h.

◆ kTabRadiusFactor

const int tesseract::kTabRadiusFactor = 5

Definition at line 36 of file tabfind.cpp.

◆ kTargetXScale

const int tesseract::kTargetXScale = 5

Definition at line 70 of file lstmtrainer.cpp.

◆ kTargetYScale

const int tesseract::kTargetYScale = 100

Definition at line 71 of file lstmtrainer.cpp.

◆ kTesseractReject

const char tesseract::kTesseractReject = '~'

Character returned when Tesseract couldn't recognize as anything.

Definition at line 99 of file baseapi.cpp.

◆ kTestChar

const int tesseract::kTestChar = -1

Definition at line 32 of file trainingsampleset.cpp.

◆ kThickLengthMultiple

const double tesseract::kThickLengthMultiple = 0.75

Definition at line 54 of file linefind.cpp.

◆ kThinLineFraction

const int tesseract::kThinLineFraction = 20

Denominator of resolution makes max pixel width to allow thin lines.

Definition at line 39 of file linefind.cpp.

◆ kTinyEnoughTextlineOverlapFraction

const double tesseract::kTinyEnoughTextlineOverlapFraction = 0.25

Definition at line 51 of file colpartitiongrid.cpp.

◆ kUnclearDensityTh

const float tesseract::kUnclearDensityTh = 0.25

Definition at line 84 of file equationdetect.cpp.

◆ kUniChs

const int tesseract::kUniChs[]
Initial value:
= {
0x20ac, 0x201c, 0x201d, 0x2018, 0x2019, 0x2022, 0x2014, 0
}

Conversion table for non-latin characters. Maps characters out of the latin set into the latin set. TODO(rays) incorporate this translation into unicharset.

Definition at line 1885 of file baseapi.cpp.

◆ kUniversalAmbigsFile

const char tesseract::kUniversalAmbigsFile

Definition at line 26 of file universalambigs.h.

◆ kUNLVReject

const char tesseract::kUNLVReject = '~'

Character used by UNLV error counter as a reject.

Definition at line 101 of file baseapi.cpp.

◆ kUNLVSuspect

const char tesseract::kUNLVSuspect = '^'

Character used by UNLV as a suspect marker.

Definition at line 103 of file baseapi.cpp.

◆ kUTF8LineSeparator

const char * tesseract::kUTF8LineSeparator = "\u2028"

Definition at line 25 of file unicodes.cpp.

◆ kUTF8ParagraphSeparator

const char * tesseract::kUTF8ParagraphSeparator = "\u2029"

Definition at line 26 of file unicodes.cpp.

◆ kVerticalSpacing

const double tesseract::kVerticalSpacing = -0.2

Definition at line 38 of file tablerecog.cpp.

◆ kVLineAlignment

const int tesseract::kVLineAlignment = 3

Definition at line 47 of file alignedblob.cpp.

◆ kVLineGutter

const int tesseract::kVLineGutter = 1

Definition at line 49 of file alignedblob.cpp.

◆ kVLineMinLength

const int tesseract::kVLineMinLength = 500

Definition at line 57 of file alignedblob.cpp.

◆ kVLineSearchSize

const int tesseract::kVLineSearchSize = 150

Definition at line 51 of file alignedblob.cpp.

◆ kWorstDictCertainty

const float tesseract::kWorstDictCertainty = -25.0f

Definition at line 38 of file linerec.cpp.

◆ kXWinFrameSize

const int tesseract::kXWinFrameSize = 30

Definition at line 53 of file network.cpp.

◆ kYWinFrameSize

const int tesseract::kYWinFrameSize = 80

Definition at line 54 of file network.cpp.

◆ LogisticTable

double tesseract::LogisticTable

Definition at line 24 of file functions.cpp.

◆ RTLReversePolicyNames

const char* const tesseract::RTLReversePolicyNames[]
Initial value:
= {
}
const char kForceReverse[]
Definition: trie.cpp:42
const char kDoNotReverse[]
Definition: trie.cpp:40
const char kReverseIfHasRTL[]
Definition: trie.cpp:41

Definition at line 44 of file trie.cpp.

◆ TanhTable

double tesseract::TanhTable

Definition at line 23 of file functions.cpp.

◆ textord_show_tables

bool tesseract::textord_show_tables = false

"Show table regions"

Definition at line 143 of file tablefind.cpp.

◆ textord_tabfind_find_tables

bool tesseract::textord_tabfind_find_tables = true

"run table detection"

Definition at line 65 of file colfind.cpp.

◆ textord_tabfind_only_strokewidths

bool tesseract::textord_tabfind_only_strokewidths = false

"Only run stroke widths"

Definition at line 42 of file strokewidth.cpp.

◆ textord_tabfind_show_blocks

bool tesseract::textord_tabfind_show_blocks = false

"Show final block bounds"

Definition at line 64 of file colfind.cpp.

◆ textord_tabfind_show_color_fit

bool tesseract::textord_tabfind_show_color_fit = false

"Show stroke widths"

Definition at line 32 of file colpartitiongrid.cpp.

◆ textord_tabfind_show_columns

bool tesseract::textord_tabfind_show_columns = false

"Show column bounds"

Definition at line 63 of file colfind.cpp.

◆ textord_tabfind_show_finaltabs

bool tesseract::textord_tabfind_show_finaltabs = false

"Show tab vectors"

Definition at line 64 of file tabfind.cpp.

◆ textord_tabfind_show_initial_partitions

bool tesseract::textord_tabfind_show_initial_partitions = false

"Show partition bounds"

Definition at line 58 of file colfind.cpp.

◆ textord_tabfind_show_initialtabs

bool tesseract::textord_tabfind_show_initialtabs = false

"Show tab candidates"

Definition at line 63 of file tabfind.cpp.

◆ textord_tabfind_show_partitions

int tesseract::textord_tabfind_show_partitions = 0

"Show partition bounds, waiting if >1"

Definition at line 62 of file colfind.cpp.

◆ textord_tabfind_show_reject_blobs

bool tesseract::textord_tabfind_show_reject_blobs = false

"Show blobs rejected as noise"

Definition at line 60 of file colfind.cpp.

◆ textord_tabfind_show_strokewidths

int tesseract::textord_tabfind_show_strokewidths = 0

"Show stroke widths"

Definition at line 41 of file strokewidth.cpp.

◆ textord_tablefind_recognize_tables

bool tesseract::textord_tablefind_recognize_tables = false

"Enables the table recognizer for table layout and filtering."

Definition at line 149 of file tablefind.cpp.

◆ textord_tablefind_show_mark

bool tesseract::textord_tablefind_show_mark = false

"Debug table marking steps in detail"

Definition at line 145 of file tablefind.cpp.

◆ textord_tablefind_show_stats

bool tesseract::textord_tablefind_show_stats = false

"Show page stats used in table finding"

Definition at line 147 of file tablefind.cpp.

◆ textord_tabvector_vertical_box_ratio

double tesseract::textord_tabvector_vertical_box_ratio = 0.5

"Fraction of box matches required to declare a line vertical"

Definition at line 59 of file tabvector.cpp.

◆ textord_tabvector_vertical_gap_fraction

double tesseract::textord_tabvector_vertical_gap_fraction = 0.5

"max fraction of mean blob width allowed for vertical gaps in vertical text"

"Max fraction of mean blob width allowed for vertical gaps in vertical text"

Definition at line 56 of file tabvector.cpp.

◆ tprintfMutex

CCUtilMutex tesseract::tprintfMutex

Definition at line 59 of file ccutil.cpp.