2009-07-11 10:17:36 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
// File: classify.h
|
|
|
|
// Description: classify class.
|
|
|
|
// Author: Samuel Charron
|
|
|
|
//
|
|
|
|
// (C) Copyright 2006, Google Inc.
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-12-04 21:45:26 +08:00
|
|
|
#ifndef TESSERACT_CLASSIFY_CLASSIFY_H_
|
|
|
|
#define TESSERACT_CLASSIFY_CLASSIFY_H_
|
2009-07-11 10:17:36 +08:00
|
|
|
|
2018-07-03 23:49:42 +08:00
|
|
|
// Include automatically generated configuration file if running autoconf.
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config_auto.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DISABLED_LEGACY_ENGINE
|
|
|
|
|
|
|
|
#include "ccstruct.h"
|
|
|
|
#include "dict.h"
|
|
|
|
|
|
|
|
namespace tesseract {
|
|
|
|
|
|
|
|
class Classify : public CCStruct {
|
|
|
|
public:
|
|
|
|
Classify();
|
|
|
|
virtual ~Classify();
|
|
|
|
virtual Dict& getDict() {
|
|
|
|
return dict_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Member variables.
|
|
|
|
|
|
|
|
INT_VAR_H(classify_debug_level, 0, "Classify debug level");
|
|
|
|
|
|
|
|
BOOL_VAR_H(classify_bln_numeric_mode, 0,
|
|
|
|
"Assume the input is numbers [0-9].");
|
|
|
|
|
|
|
|
double_VAR_H(classify_max_rating_ratio, 1.5,
|
|
|
|
"Veto ratio between classifier ratings");
|
|
|
|
|
|
|
|
double_VAR_H(classify_max_certainty_margin, 5.5,
|
|
|
|
"Veto difference between classifier certainties");
|
|
|
|
|
|
|
|
private:
|
|
|
|
Dict dict_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace tesseract
|
|
|
|
|
|
|
|
|
|
|
|
#else // DISABLED_LEGACY_ENGINE not defined
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
#include "adaptive.h"
|
|
|
|
#include "ccstruct.h"
|
|
|
|
#include "dict.h"
|
2010-11-24 02:34:14 +08:00
|
|
|
#include "featdefs.h"
|
2012-02-02 10:57:42 +08:00
|
|
|
#include "fontinfo.h"
|
2015-05-13 06:22:34 +08:00
|
|
|
#include "imagedata.h"
|
2010-11-24 02:34:14 +08:00
|
|
|
#include "intfx.h"
|
2009-07-11 10:17:36 +08:00
|
|
|
#include "intmatcher.h"
|
2011-03-19 05:53:11 +08:00
|
|
|
#include "normalis.h"
|
2009-07-11 10:17:36 +08:00
|
|
|
#include "ratngs.h"
|
|
|
|
#include "ocrfeatures.h"
|
|
|
|
#include "unicity_table.h"
|
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
class ScrollView;
|
2009-07-11 10:17:36 +08:00
|
|
|
class WERD_CHOICE;
|
2010-11-24 02:34:14 +08:00
|
|
|
class WERD_RES;
|
2009-07-11 10:17:36 +08:00
|
|
|
struct ADAPT_RESULTS;
|
|
|
|
struct NORM_PROTOS;
|
|
|
|
|
2011-03-22 05:45:36 +08:00
|
|
|
static const int kUnknownFontinfoId = -1;
|
|
|
|
static const int kBlankFontinfoId = -2;
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
namespace tesseract {
|
2010-11-24 02:34:14 +08:00
|
|
|
|
2013-09-23 23:15:06 +08:00
|
|
|
class ShapeClassifier;
|
2012-02-02 10:57:42 +08:00
|
|
|
struct ShapeRating;
|
|
|
|
class ShapeTable;
|
2013-09-23 23:15:06 +08:00
|
|
|
struct UnicharRating;
|
2012-02-02 10:57:42 +08:00
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
// How segmented is a blob. In this enum, character refers to a classifiable
|
|
|
|
// unit, but that is too long and character is usually easier to understand.
|
|
|
|
enum CharSegmentationType {
|
|
|
|
CST_FRAGMENT, // A partial character.
|
|
|
|
CST_WHOLE, // A correctly segmented character.
|
|
|
|
CST_IMPROPER, // More than one but less than 2 characters.
|
|
|
|
CST_NGRAM // Multiple characters.
|
|
|
|
};
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
class Classify : public CCStruct {
|
|
|
|
public:
|
|
|
|
Classify();
|
2019-03-26 14:37:52 +08:00
|
|
|
~Classify() override;
|
2017-09-14 19:03:22 +08:00
|
|
|
virtual Dict& getDict() {
|
2009-07-11 10:17:36 +08:00
|
|
|
return dict_;
|
|
|
|
}
|
2010-11-24 02:34:14 +08:00
|
|
|
|
2012-02-02 10:57:42 +08:00
|
|
|
const ShapeTable* shape_table() const {
|
|
|
|
return shape_table_;
|
2010-11-24 02:34:14 +08:00
|
|
|
}
|
|
|
|
|
2013-09-23 23:15:06 +08:00
|
|
|
// Takes ownership of the given classifier, and uses it for future calls
|
|
|
|
// to CharNormClassifier.
|
|
|
|
void SetStaticClassifier(ShapeClassifier* static_classifier);
|
|
|
|
|
|
|
|
// Adds a noise classification result that is a bit worse than the worst
|
|
|
|
// current result, or the worst possible result if no current results.
|
|
|
|
void AddLargeSpeckleTo(int blob_length, BLOB_CHOICE_LIST *choices);
|
|
|
|
|
|
|
|
// Returns true if the blob is small enough to be a large speckle.
|
|
|
|
bool LargeSpeckle(const TBLOB &blob);
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
/* adaptive.cpp ************************************************************/
|
|
|
|
ADAPT_TEMPLATES NewAdaptedTemplates(bool InitFromUnicharset);
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
int GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId);
|
2012-02-02 10:57:42 +08:00
|
|
|
// Runs the class pruner from int_templates on the given features, returning
|
|
|
|
// the number of classes output in results.
|
|
|
|
// int_templates Class pruner tables
|
|
|
|
// num_features Number of features in blob
|
|
|
|
// features Array of features
|
|
|
|
// normalization_factors (input) Array of int_templates->NumClasses fudge
|
|
|
|
// factors from blob normalization process.
|
|
|
|
// (Indexed by CLASS_INDEX)
|
|
|
|
// expected_num_features (input) Array of int_templates->NumClasses
|
|
|
|
// expected number of features for each class.
|
|
|
|
// (Indexed by CLASS_INDEX)
|
|
|
|
// results (output) Sorted Array of pruned classes.
|
|
|
|
// Array must be sized to take the maximum possible
|
|
|
|
// number of outputs : int_templates->NumClasses.
|
2015-05-14 08:07:11 +08:00
|
|
|
int PruneClasses(const INT_TEMPLATES_STRUCT* int_templates, int num_features,
|
|
|
|
int keep_this, const INT_FEATURE_STRUCT* features,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
const uint8_t* normalization_factors,
|
|
|
|
const uint16_t* expected_num_features,
|
2014-01-25 05:12:35 +08:00
|
|
|
GenericVector<CP_RESULT_STRUCT>* results);
|
2017-05-04 07:09:44 +08:00
|
|
|
void ReadNewCutoffs(TFile* fp, CLASS_CUTOFF_ARRAY Cutoffs);
|
2009-07-11 10:17:36 +08:00
|
|
|
void PrintAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates);
|
|
|
|
void WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates);
|
2017-04-28 06:48:23 +08:00
|
|
|
ADAPT_TEMPLATES ReadAdaptedTemplates(TFile* File);
|
2009-07-11 10:17:36 +08:00
|
|
|
/* normmatch.cpp ************************************************************/
|
2018-07-02 18:24:35 +08:00
|
|
|
float ComputeNormMatch(CLASS_ID ClassId,
|
|
|
|
const FEATURE_STRUCT& feature, bool DebugMatch);
|
2009-07-11 10:17:36 +08:00
|
|
|
void FreeNormProtos();
|
2017-04-28 06:48:23 +08:00
|
|
|
NORM_PROTOS* ReadNormProtos(TFile* fp);
|
2009-07-11 10:17:36 +08:00
|
|
|
/* protos.cpp ***************************************************************/
|
2010-11-24 02:34:14 +08:00
|
|
|
void ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class);
|
|
|
|
INT_TEMPLATES CreateIntTemplates(CLASSES FloatProtos,
|
|
|
|
const UNICHARSET& target_unicharset);
|
2009-07-11 10:17:36 +08:00
|
|
|
/* adaptmatch.cpp ***********************************************************/
|
2012-02-02 10:57:42 +08:00
|
|
|
|
2015-05-13 06:22:34 +08:00
|
|
|
// Learns the given word using its chopped_word, seam_array, denorm,
|
2010-11-24 02:34:14 +08:00
|
|
|
// box_word, best_state, and correct_text to learn both correctly and
|
2016-12-13 00:21:24 +08:00
|
|
|
// incorrectly segmented blobs. If fontname is not nullptr, then LearnBlob
|
2015-05-13 06:22:34 +08:00
|
|
|
// is called and the data will be saved in an internal buffer.
|
2010-11-24 02:34:14 +08:00
|
|
|
// Otherwise AdaptToBlob is called for adaption within a document.
|
2015-05-13 06:22:34 +08:00
|
|
|
void LearnWord(const char* fontname, WERD_RES* word);
|
2010-11-24 02:34:14 +08:00
|
|
|
|
|
|
|
// Builds a blob of length fragments, from the word, starting at start,
|
2015-05-13 06:22:34 +08:00
|
|
|
// and then learns it, as having the given correct_text.
|
2016-12-13 00:21:24 +08:00
|
|
|
// If fontname is not nullptr, then LearnBlob is called and the data will be
|
2015-05-13 06:22:34 +08:00
|
|
|
// saved in an internal buffer for static training.
|
2010-11-24 02:34:14 +08:00
|
|
|
// Otherwise AdaptToBlob is called for adaption within a document.
|
|
|
|
// threshold is a magic number required by AdaptToChar and generated by
|
2015-05-13 06:22:34 +08:00
|
|
|
// ComputeAdaptionThresholds.
|
2010-11-24 02:34:14 +08:00
|
|
|
// Although it can be partly inferred from the string, segmentation is
|
|
|
|
// provided to explicitly clarify the character segmentation.
|
2015-05-13 06:22:34 +08:00
|
|
|
void LearnPieces(const char* fontname, int start, int length, float threshold,
|
|
|
|
CharSegmentationType segmentation, const char* correct_text,
|
|
|
|
WERD_RES* word);
|
2017-04-28 06:48:23 +08:00
|
|
|
void InitAdaptiveClassifier(TessdataManager* mgr);
|
2009-07-11 10:17:36 +08:00
|
|
|
void InitAdaptedClass(TBLOB *Blob,
|
|
|
|
CLASS_ID ClassId,
|
2011-03-22 05:45:36 +08:00
|
|
|
int FontinfoId,
|
2009-07-11 10:17:36 +08:00
|
|
|
ADAPT_CLASS Class,
|
|
|
|
ADAPT_TEMPLATES Templates);
|
2013-11-09 04:30:56 +08:00
|
|
|
void AmbigClassifier(const GenericVector<INT_FEATURE_STRUCT>& int_features,
|
|
|
|
const INT_FX_RESULT_STRUCT& fx_info,
|
|
|
|
const TBLOB *blob,
|
|
|
|
INT_TEMPLATES templates,
|
|
|
|
ADAPT_CLASS *classes,
|
|
|
|
UNICHAR_ID *ambiguities,
|
|
|
|
ADAPT_RESULTS *results);
|
2009-07-11 10:17:36 +08:00
|
|
|
void MasterMatcher(INT_TEMPLATES templates,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
int16_t num_features,
|
2012-02-02 10:57:42 +08:00
|
|
|
const INT_FEATURE_STRUCT* features,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
const uint8_t* norm_factors,
|
2009-07-11 10:17:36 +08:00
|
|
|
ADAPT_CLASS* classes,
|
|
|
|
int debug,
|
2013-11-09 04:30:56 +08:00
|
|
|
int matcher_multiplier,
|
2010-11-24 02:34:14 +08:00
|
|
|
const TBOX& blob_box,
|
2014-01-25 05:12:35 +08:00
|
|
|
const GenericVector<CP_RESULT_STRUCT>& results,
|
2009-07-11 10:17:36 +08:00
|
|
|
ADAPT_RESULTS* final_results);
|
2012-02-02 10:57:42 +08:00
|
|
|
// Converts configs to fonts, and if the result is not adapted, and a
|
|
|
|
// shape_table_ is present, the shape is expanded to include all
|
|
|
|
// unichar_ids represented, before applying a set of corrections to the
|
|
|
|
// distance rating in int_result, (see ComputeCorrectedRating.)
|
|
|
|
// The results are added to the final_results output.
|
|
|
|
void ExpandShapesAndApplyCorrections(ADAPT_CLASS* classes,
|
|
|
|
bool debug,
|
|
|
|
int class_id,
|
|
|
|
int bottom, int top,
|
|
|
|
float cp_rating,
|
|
|
|
int blob_length,
|
2013-11-09 04:30:56 +08:00
|
|
|
int matcher_multiplier,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
const uint8_t* cn_factors,
|
2015-05-13 08:24:34 +08:00
|
|
|
UnicharRating* int_result,
|
2012-02-02 10:57:42 +08:00
|
|
|
ADAPT_RESULTS* final_results);
|
|
|
|
// Applies a set of corrections to the distance im_rating,
|
|
|
|
// including the cn_correction, miss penalty and additional penalty
|
|
|
|
// for non-alnums being vertical misfits. Returns the corrected distance.
|
|
|
|
double ComputeCorrectedRating(bool debug, int unichar_id, double cp_rating,
|
|
|
|
double im_rating, int feature_misses,
|
|
|
|
int bottom, int top,
|
2013-11-09 04:30:56 +08:00
|
|
|
int blob_length, int matcher_multiplier,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
const uint8_t* cn_factors);
|
2012-02-02 10:57:42 +08:00
|
|
|
void ConvertMatchesToChoices(const DENORM& denorm, const TBOX& box,
|
|
|
|
ADAPT_RESULTS *Results,
|
2009-07-11 10:17:36 +08:00
|
|
|
BLOB_CHOICE_LIST *Choices);
|
2015-05-13 08:24:34 +08:00
|
|
|
void AddNewResult(const UnicharRating& new_result, ADAPT_RESULTS *results);
|
2010-11-24 02:34:14 +08:00
|
|
|
int GetAdaptiveFeatures(TBLOB *Blob,
|
|
|
|
INT_FEATURE_ARRAY IntFeatures,
|
|
|
|
FEATURE_SET *FloatFeatures);
|
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
#ifndef GRAPHICS_DISABLED
|
|
|
|
void DebugAdaptiveClassifier(TBLOB *Blob,
|
|
|
|
ADAPT_RESULTS *Results);
|
|
|
|
#endif
|
2010-11-24 02:34:14 +08:00
|
|
|
PROTO_ID MakeNewTempProtos(FEATURE_SET Features,
|
|
|
|
int NumBadFeat,
|
|
|
|
FEATURE_ID BadFeat[],
|
|
|
|
INT_CLASS IClass,
|
|
|
|
ADAPT_CLASS Class,
|
|
|
|
BIT_VECTOR TempProtoMask);
|
2009-07-11 10:17:36 +08:00
|
|
|
int MakeNewTemporaryConfig(ADAPT_TEMPLATES Templates,
|
|
|
|
CLASS_ID ClassId,
|
2011-03-22 05:45:36 +08:00
|
|
|
int FontinfoId,
|
2009-07-11 10:17:36 +08:00
|
|
|
int NumFeatures,
|
|
|
|
INT_FEATURE_ARRAY Features,
|
|
|
|
FEATURE_SET FloatFeatures);
|
|
|
|
void MakePermanent(ADAPT_TEMPLATES Templates,
|
|
|
|
CLASS_ID ClassId,
|
|
|
|
int ConfigId,
|
2010-11-24 02:34:14 +08:00
|
|
|
TBLOB *Blob);
|
2015-05-13 08:24:34 +08:00
|
|
|
void PrintAdaptiveMatchResults(const ADAPT_RESULTS& results);
|
2009-07-11 10:17:36 +08:00
|
|
|
void RemoveExtraPuncs(ADAPT_RESULTS *Results);
|
|
|
|
void RemoveBadMatches(ADAPT_RESULTS *Results);
|
2018-07-02 18:24:35 +08:00
|
|
|
void SetAdaptiveThreshold(float Threshold);
|
2013-09-23 23:15:06 +08:00
|
|
|
void ShowBestMatchFor(int shape_id,
|
|
|
|
const INT_FEATURE_STRUCT* features,
|
|
|
|
int num_features);
|
2012-02-02 10:57:42 +08:00
|
|
|
// Returns a string for the classifier class_id: either the corresponding
|
|
|
|
// unicharset debug_str or the shape_table_ debug str.
|
|
|
|
STRING ClassIDToDebugStr(const INT_TEMPLATES_STRUCT* templates,
|
|
|
|
int class_id, int config_id) const;
|
|
|
|
// Converts a classifier class_id index with a config ID to:
|
|
|
|
// shape_table_ present: a shape_table_ index OR
|
|
|
|
// No shape_table_: a font ID.
|
|
|
|
// Without shape training, each class_id, config pair represents a single
|
|
|
|
// unichar id/font combination, so this function looks up the corresponding
|
|
|
|
// font id.
|
|
|
|
// With shape training, each class_id, config pair represents a single
|
|
|
|
// shape table index, so the fontset_table stores the shape table index,
|
|
|
|
// and the shape_table_ must be consulted to obtain the actual unichar_id/
|
|
|
|
// font combinations that the shape represents.
|
|
|
|
int ClassAndConfigIDToFontOrShapeID(int class_id,
|
|
|
|
int int_result_config) const;
|
|
|
|
// Converts a shape_table_ index to a classifier class_id index (not a
|
|
|
|
// unichar-id!). Uses a search, so not fast.
|
|
|
|
int ShapeIDToClassID(int shape_id) const;
|
2013-11-09 04:30:56 +08:00
|
|
|
UNICHAR_ID *BaselineClassifier(
|
|
|
|
TBLOB *Blob, const GenericVector<INT_FEATURE_STRUCT>& int_features,
|
|
|
|
const INT_FX_RESULT_STRUCT& fx_info,
|
|
|
|
ADAPT_TEMPLATES Templates, ADAPT_RESULTS *Results);
|
|
|
|
int CharNormClassifier(TBLOB *blob,
|
|
|
|
const TrainingSample& sample,
|
|
|
|
ADAPT_RESULTS *adapt_results);
|
2012-02-02 10:57:42 +08:00
|
|
|
|
|
|
|
// As CharNormClassifier, but operates on a TrainingSample and outputs to
|
|
|
|
// a GenericVector of ShapeRating without conversion to classes.
|
2013-09-23 23:15:06 +08:00
|
|
|
int CharNormTrainingSample(bool pruner_only, int keep_this,
|
|
|
|
const TrainingSample& sample,
|
|
|
|
GenericVector<UnicharRating>* results);
|
|
|
|
UNICHAR_ID *GetAmbiguities(TBLOB *Blob, CLASS_ID CorrectClass);
|
|
|
|
void DoAdaptiveMatch(TBLOB *Blob, ADAPT_RESULTS *Results);
|
2015-06-13 02:10:53 +08:00
|
|
|
void AdaptToChar(TBLOB* Blob, CLASS_ID ClassId, int FontinfoId,
|
2018-07-02 18:24:35 +08:00
|
|
|
float Threshold, ADAPT_TEMPLATES adaptive_templates);
|
2013-09-23 23:15:06 +08:00
|
|
|
void DisplayAdaptedChar(TBLOB* blob, INT_CLASS_STRUCT* int_class);
|
|
|
|
bool AdaptableWord(WERD_RES* word);
|
2009-07-11 10:17:36 +08:00
|
|
|
void EndAdaptiveClassifier();
|
|
|
|
void SettupPass1();
|
|
|
|
void SettupPass2();
|
2014-01-25 05:12:35 +08:00
|
|
|
void AdaptiveClassifier(TBLOB *Blob, BLOB_CHOICE_LIST *Choices);
|
2009-07-11 10:17:36 +08:00
|
|
|
void ClassifyAsNoise(ADAPT_RESULTS *Results);
|
2012-02-02 10:57:42 +08:00
|
|
|
void ResetAdaptiveClassifierInternal();
|
2015-06-13 02:10:53 +08:00
|
|
|
void SwitchAdaptiveClassifier();
|
|
|
|
void StartBackupAdaptiveClassifier();
|
2009-07-11 10:17:36 +08:00
|
|
|
|
2013-11-09 04:30:56 +08:00
|
|
|
int GetCharNormFeature(const INT_FX_RESULT_STRUCT& fx_info,
|
|
|
|
INT_TEMPLATES templates,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
uint8_t* pruner_norm_array,
|
|
|
|
uint8_t* char_norm_array);
|
2016-12-13 00:21:24 +08:00
|
|
|
// Computes the char_norm_array for the unicharset and, if not nullptr, the
|
2012-02-02 10:57:42 +08:00
|
|
|
// pruner_array as appropriate according to the existence of the shape_table.
|
|
|
|
// The norm_feature is deleted as it is almost certainly no longer needed.
|
|
|
|
void ComputeCharNormArrays(FEATURE_STRUCT* norm_feature,
|
|
|
|
INT_TEMPLATES_STRUCT* templates,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
uint8_t* char_norm_array,
|
|
|
|
uint8_t* pruner_array);
|
2010-11-24 02:34:14 +08:00
|
|
|
|
|
|
|
bool TempConfigReliable(CLASS_ID class_id, const TEMP_CONFIG &config);
|
2013-09-23 23:15:06 +08:00
|
|
|
void UpdateAmbigsGroup(CLASS_ID class_id, TBLOB *Blob);
|
2009-07-11 10:17:36 +08:00
|
|
|
|
2015-06-13 02:10:53 +08:00
|
|
|
bool AdaptiveClassifierIsFull() const { return NumAdaptationsFailed > 0; }
|
|
|
|
bool AdaptiveClassifierIsEmpty() const {
|
|
|
|
return AdaptedTemplates->NumPermClasses == 0;
|
|
|
|
}
|
2013-09-23 23:15:06 +08:00
|
|
|
bool LooksLikeGarbage(TBLOB *blob);
|
2010-11-30 09:00:17 +08:00
|
|
|
void RefreshDebugWindow(ScrollView **win, const char *msg,
|
|
|
|
int y_offset, const TBOX &wbox);
|
2013-09-23 23:15:06 +08:00
|
|
|
// intfx.cpp
|
|
|
|
// Computes the DENORMS for bl(baseline) and cn(character) normalization
|
|
|
|
// during feature extraction. The input denorm describes the current state
|
|
|
|
// of the blob, which is usually a baseline-normalized word.
|
|
|
|
// The Transforms setup are as follows:
|
|
|
|
// Baseline Normalized (bl) Output:
|
|
|
|
// We center the grapheme by aligning the x-coordinate of its centroid with
|
|
|
|
// x=128 and leaving the already-baseline-normalized y as-is.
|
|
|
|
//
|
|
|
|
// Character Normalized (cn) Output:
|
|
|
|
// We align the grapheme's centroid at the origin and scale it
|
|
|
|
// asymmetrically in x and y so that the 2nd moments are a standard value
|
|
|
|
// (51.2) ie the result is vaguely square.
|
|
|
|
// If classify_nonlinear_norm is true:
|
|
|
|
// A non-linear normalization is setup that attempts to evenly distribute
|
|
|
|
// edges across x and y.
|
|
|
|
//
|
|
|
|
// Some of the fields of fx_info are also setup:
|
|
|
|
// Length: Total length of outline.
|
|
|
|
// Rx: Rounded y second moment. (Reversed by convention.)
|
|
|
|
// Ry: rounded x second moment.
|
|
|
|
// Xmean: Rounded x center of mass of the blob.
|
|
|
|
// Ymean: Rounded y center of mass of the blob.
|
|
|
|
static void SetupBLCNDenorms(const TBLOB& blob, bool nonlinear_norm,
|
|
|
|
DENORM* bl_denorm, DENORM* cn_denorm,
|
|
|
|
INT_FX_RESULT_STRUCT* fx_info);
|
|
|
|
|
|
|
|
// Extracts sets of 3-D features of length kStandardFeatureLength (=12.8), as
|
|
|
|
// (x,y) position and angle as measured counterclockwise from the vector
|
|
|
|
// <-1, 0>, from blob using two normalizations defined by bl_denorm and
|
|
|
|
// cn_denorm. See SetpuBLCNDenorms for definitions.
|
2016-12-13 00:21:24 +08:00
|
|
|
// If outline_cn_counts is not nullptr, on return it contains the cumulative
|
2013-09-23 23:15:06 +08:00
|
|
|
// number of cn features generated for each outline in the blob (in order).
|
|
|
|
// Thus after the first outline, there were (*outline_cn_counts)[0] features,
|
|
|
|
// after the second outline, there were (*outline_cn_counts)[1] features etc.
|
|
|
|
static void ExtractFeatures(const TBLOB& blob,
|
|
|
|
bool nonlinear_norm,
|
|
|
|
GenericVector<INT_FEATURE_STRUCT>* bl_features,
|
|
|
|
GenericVector<INT_FEATURE_STRUCT>* cn_features,
|
|
|
|
INT_FX_RESULT_STRUCT* results,
|
|
|
|
GenericVector<int>* outline_cn_counts);
|
2009-07-11 10:17:36 +08:00
|
|
|
/* float2int.cpp ************************************************************/
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
void ClearCharNormArray(uint8_t* char_norm_array);
|
2012-02-02 10:57:42 +08:00
|
|
|
void ComputeIntCharNormArray(const FEATURE_STRUCT& norm_feature,
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
uint8_t* char_norm_array);
|
2010-11-24 02:34:14 +08:00
|
|
|
void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures);
|
2009-07-11 10:17:36 +08:00
|
|
|
/* intproto.cpp *************************************************************/
|
2017-05-04 07:09:44 +08:00
|
|
|
INT_TEMPLATES ReadIntTemplates(TFile* fp);
|
2009-07-11 10:17:36 +08:00
|
|
|
void WriteIntTemplates(FILE *File, INT_TEMPLATES Templates,
|
|
|
|
const UNICHARSET& target_unicharset);
|
2010-11-30 09:00:17 +08:00
|
|
|
CLASS_ID GetClassToDebug(const char *Prompt, bool* adaptive_on,
|
2012-02-02 10:57:42 +08:00
|
|
|
bool* pretrained_on, int* shape_id);
|
2010-11-24 02:34:14 +08:00
|
|
|
void ShowMatchDisplay();
|
2009-07-11 10:17:36 +08:00
|
|
|
/* font detection ***********************************************************/
|
|
|
|
UnicityTable<FontInfo>& get_fontinfo_table() {
|
|
|
|
return fontinfo_table_;
|
|
|
|
}
|
2013-09-23 23:15:06 +08:00
|
|
|
const UnicityTable<FontInfo>& get_fontinfo_table() const {
|
|
|
|
return fontinfo_table_;
|
|
|
|
}
|
2009-07-11 10:17:36 +08:00
|
|
|
UnicityTable<FontSet>& get_fontset_table() {
|
|
|
|
return fontset_table_;
|
|
|
|
}
|
2010-11-24 02:34:14 +08:00
|
|
|
/* mfoutline.cpp ***********************************************************/
|
2018-07-02 18:24:35 +08:00
|
|
|
void NormalizeOutlines(LIST Outlines, float *XScale, float *YScale);
|
2010-11-24 02:34:14 +08:00
|
|
|
/* outfeat.cpp ***********************************************************/
|
|
|
|
FEATURE_SET ExtractOutlineFeatures(TBLOB *Blob);
|
|
|
|
/* picofeat.cpp ***********************************************************/
|
|
|
|
FEATURE_SET ExtractPicoFeatures(TBLOB *Blob);
|
2015-05-13 06:22:34 +08:00
|
|
|
FEATURE_SET ExtractIntCNFeatures(const TBLOB& blob,
|
|
|
|
const INT_FX_RESULT_STRUCT& fx_info);
|
|
|
|
FEATURE_SET ExtractIntGeoFeatures(const TBLOB& blob,
|
|
|
|
const INT_FX_RESULT_STRUCT& fx_info);
|
|
|
|
/* blobclass.cpp ***********************************************************/
|
|
|
|
// Extracts features from the given blob and saves them in the tr_file_data_
|
|
|
|
// member variable.
|
|
|
|
// fontname: Name of font that this blob was printed in.
|
|
|
|
// cn_denorm: Character normalization transformation to apply to the blob.
|
|
|
|
// fx_info: Character normalization parameters computed with cn_denorm.
|
|
|
|
// blob_text: Ground truth text for the blob.
|
|
|
|
void LearnBlob(const STRING& fontname, TBLOB* Blob, const DENORM& cn_denorm,
|
|
|
|
const INT_FX_RESULT_STRUCT& fx_info, const char* blob_text);
|
|
|
|
// Writes stored training data to a .tr file based on the given filename.
|
|
|
|
// Returns false on error.
|
|
|
|
bool WriteTRFile(const STRING& filename);
|
2010-11-24 02:34:14 +08:00
|
|
|
|
|
|
|
// Member variables.
|
|
|
|
|
|
|
|
// Parameters.
|
2015-06-13 01:59:26 +08:00
|
|
|
// Set during training (in lang.config) to indicate whether the divisible
|
|
|
|
// blobs chopper should be used (true for latin script.)
|
|
|
|
BOOL_VAR_H(allow_blob_division, true, "Use divisible blobs chopping");
|
|
|
|
// Set during training (in lang.config) to indicate whether the divisible
|
|
|
|
// blobs chopper should be used in preference to chopping. Set to true for
|
|
|
|
// southern Indic scripts.
|
2012-02-02 10:57:42 +08:00
|
|
|
BOOL_VAR_H(prioritize_division, FALSE,
|
|
|
|
"Prioritize blob division over chopping");
|
2009-07-11 10:17:36 +08:00
|
|
|
INT_VAR_H(tessedit_single_match, FALSE, "Top choice only from CP");
|
2010-11-24 02:34:14 +08:00
|
|
|
BOOL_VAR_H(classify_enable_learning, true, "Enable adaptive classifier");
|
|
|
|
INT_VAR_H(classify_debug_level, 0, "Classify debug level");
|
|
|
|
|
|
|
|
/* mfoutline.cpp ***********************************************************/
|
|
|
|
/* control knobs used to control normalization of outlines */
|
|
|
|
INT_VAR_H(classify_norm_method, character, "Normalization Method ...");
|
|
|
|
double_VAR_H(classify_char_norm_range, 0.2,
|
|
|
|
"Character Normalization Range ...");
|
|
|
|
double_VAR_H(classify_min_norm_scale_x, 0.0, "Min char x-norm scale ...");
|
|
|
|
double_VAR_H(classify_max_norm_scale_x, 0.325, "Max char x-norm scale ...");
|
|
|
|
double_VAR_H(classify_min_norm_scale_y, 0.0, "Min char y-norm scale ...");
|
|
|
|
double_VAR_H(classify_max_norm_scale_y, 0.325, "Max char y-norm scale ...");
|
2013-09-23 23:15:06 +08:00
|
|
|
double_VAR_H(classify_max_rating_ratio, 1.5,
|
|
|
|
"Veto ratio between classifier ratings");
|
|
|
|
double_VAR_H(classify_max_certainty_margin, 5.5,
|
|
|
|
"Veto difference between classifier certainties");
|
2010-11-24 02:34:14 +08:00
|
|
|
|
|
|
|
/* adaptmatch.cpp ***********************************************************/
|
|
|
|
BOOL_VAR_H(tess_cn_matching, 0, "Character Normalized Matching");
|
|
|
|
BOOL_VAR_H(tess_bn_matching, 0, "Baseline Normalized Matching");
|
|
|
|
BOOL_VAR_H(classify_enable_adaptive_matcher, 1, "Enable adaptive classifier");
|
|
|
|
BOOL_VAR_H(classify_use_pre_adapted_templates, 0,
|
|
|
|
"Use pre-adapted classifier templates");
|
|
|
|
BOOL_VAR_H(classify_save_adapted_templates, 0,
|
|
|
|
"Save adapted templates to a file");
|
|
|
|
BOOL_VAR_H(classify_enable_adaptive_debugger, 0, "Enable match debugger");
|
2013-09-23 23:15:06 +08:00
|
|
|
BOOL_VAR_H(classify_nonlinear_norm, 0,
|
|
|
|
"Non-linear stroke-density normalization");
|
2010-11-24 02:34:14 +08:00
|
|
|
INT_VAR_H(matcher_debug_level, 0, "Matcher Debug Level");
|
|
|
|
INT_VAR_H(matcher_debug_flags, 0, "Matcher Debug Flags");
|
|
|
|
INT_VAR_H(classify_learning_debug_level, 0, "Learning Debug Level: ");
|
|
|
|
double_VAR_H(matcher_good_threshold, 0.125, "Good Match (0-1)");
|
2015-06-13 02:10:53 +08:00
|
|
|
double_VAR_H(matcher_reliable_adaptive_result, 0.0, "Great Match (0-1)");
|
2010-11-24 02:34:14 +08:00
|
|
|
double_VAR_H(matcher_perfect_threshold, 0.02, "Perfect Match (0-1)");
|
|
|
|
double_VAR_H(matcher_bad_match_pad, 0.15, "Bad Match Pad (0-1)");
|
|
|
|
double_VAR_H(matcher_rating_margin, 0.1, "New template margin (0-1)");
|
|
|
|
double_VAR_H(matcher_avg_noise_size, 12.0, "Avg. noise blob length: ");
|
|
|
|
INT_VAR_H(matcher_permanent_classes_min, 1, "Min # of permanent classes");
|
|
|
|
INT_VAR_H(matcher_min_examples_for_prototyping, 3,
|
|
|
|
"Reliable Config Threshold");
|
|
|
|
INT_VAR_H(matcher_sufficient_examples_for_prototyping, 5,
|
|
|
|
"Enable adaption even if the ambiguities have not been seen");
|
|
|
|
double_VAR_H(matcher_clustering_max_angle_delta, 0.015,
|
|
|
|
"Maximum angle delta for prototype clustering");
|
|
|
|
double_VAR_H(classify_misfit_junk_penalty, 0.0,
|
|
|
|
"Penalty to apply when a non-alnum is vertically out of "
|
|
|
|
"its expected textline position");
|
|
|
|
double_VAR_H(rating_scale, 1.5, "Rating scaling factor");
|
|
|
|
double_VAR_H(certainty_scale, 20.0, "Certainty scaling factor");
|
|
|
|
double_VAR_H(tessedit_class_miss_scale, 0.00390625,
|
|
|
|
"Scale factor for features not used");
|
2013-09-23 23:15:06 +08:00
|
|
|
double_VAR_H(classify_adapted_pruning_factor, 2.5,
|
|
|
|
"Prune poor adapted results this much worse than best result");
|
|
|
|
double_VAR_H(classify_adapted_pruning_threshold, -1.0,
|
|
|
|
"Threshold at which classify_adapted_pruning_factor starts");
|
2010-11-24 02:34:14 +08:00
|
|
|
INT_VAR_H(classify_adapt_proto_threshold, 230,
|
|
|
|
"Threshold for good protos during adaptive 0-255");
|
|
|
|
INT_VAR_H(classify_adapt_feature_threshold, 230,
|
|
|
|
"Threshold for good features during adaptive 0-255");
|
2010-11-30 09:00:17 +08:00
|
|
|
BOOL_VAR_H(disable_character_fragments, TRUE,
|
2010-11-24 02:34:14 +08:00
|
|
|
"Do not include character fragments in the"
|
|
|
|
" results of the classifier");
|
2010-11-30 09:00:17 +08:00
|
|
|
double_VAR_H(classify_character_fragments_garbage_certainty_threshold, -3.0,
|
|
|
|
"Exclude fragments that do not match any whole character"
|
|
|
|
" with at least this certainty");
|
|
|
|
BOOL_VAR_H(classify_debug_character_fragments, FALSE,
|
|
|
|
"Bring up graphical debugging windows for fragments training");
|
2010-11-24 02:34:14 +08:00
|
|
|
BOOL_VAR_H(matcher_debug_separate_windows, FALSE,
|
|
|
|
"Use two different windows for debugging the matching: "
|
|
|
|
"One for the protos and one for the features.");
|
|
|
|
STRING_VAR_H(classify_learn_debug_str, "", "Class str to debug learning");
|
|
|
|
|
|
|
|
/* intmatcher.cpp **********************************************************/
|
|
|
|
INT_VAR_H(classify_class_pruner_threshold, 229,
|
2012-02-02 10:57:42 +08:00
|
|
|
"Class Pruner Threshold 0-255");
|
2013-09-23 23:15:06 +08:00
|
|
|
INT_VAR_H(classify_class_pruner_multiplier, 15,
|
2010-11-24 02:34:14 +08:00
|
|
|
"Class Pruner Multiplier 0-255: ");
|
|
|
|
INT_VAR_H(classify_cp_cutoff_strength, 7,
|
|
|
|
"Class Pruner CutoffStrength: ");
|
2013-09-23 23:15:06 +08:00
|
|
|
INT_VAR_H(classify_integer_matcher_multiplier, 10,
|
2010-11-24 02:34:14 +08:00
|
|
|
"Integer Matcher Multiplier 0-255: ");
|
|
|
|
|
|
|
|
// Use class variables to hold onto built-in templates and adapted templates.
|
2009-07-11 10:17:36 +08:00
|
|
|
INT_TEMPLATES PreTrainedTemplates;
|
|
|
|
ADAPT_TEMPLATES AdaptedTemplates;
|
2015-06-13 02:10:53 +08:00
|
|
|
// The backup adapted templates are created from the previous page (only)
|
|
|
|
// so they are always ready and reasonably well trained if the primary
|
|
|
|
// adapted templates become full.
|
|
|
|
ADAPT_TEMPLATES BackupAdaptedTemplates;
|
2009-07-11 10:17:36 +08:00
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
// Create dummy proto and config masks for use with the built-in templates.
|
2009-07-11 10:17:36 +08:00
|
|
|
BIT_VECTOR AllProtosOn;
|
|
|
|
BIT_VECTOR AllConfigsOn;
|
|
|
|
BIT_VECTOR AllConfigsOff;
|
|
|
|
BIT_VECTOR TempProtoMask;
|
|
|
|
bool EnableLearning;
|
|
|
|
/* normmatch.cpp */
|
|
|
|
NORM_PROTOS *NormProtos;
|
|
|
|
/* font detection ***********************************************************/
|
|
|
|
UnicityTable<FontInfo> fontinfo_table_;
|
2012-02-02 10:57:42 +08:00
|
|
|
// Without shape training, each class_id, config pair represents a single
|
|
|
|
// unichar id/font combination, so each fontset_table_ entry holds font ids
|
|
|
|
// for each config in the class.
|
|
|
|
// With shape training, each class_id, config pair represents a single
|
|
|
|
// shape_table_ index, so the fontset_table_ stores the shape_table_ index,
|
|
|
|
// and the shape_table_ must be consulted to obtain the actual unichar_id/
|
|
|
|
// font combinations that the shape represents.
|
2009-07-11 10:17:36 +08:00
|
|
|
UnicityTable<FontSet> fontset_table_;
|
2010-11-24 02:34:14 +08:00
|
|
|
|
2015-09-15 04:12:06 +08:00
|
|
|
INT_VAR_H(il1_adaption_test, 0, "Don't adapt to i/I at beginning of word");
|
2010-11-24 02:34:14 +08:00
|
|
|
BOOL_VAR_H(classify_bln_numeric_mode, 0,
|
|
|
|
"Assume the input is numbers [0-9].");
|
2013-09-23 23:15:06 +08:00
|
|
|
double_VAR_H(speckle_large_max_size, 0.30, "Max large speckle size");
|
|
|
|
double_VAR_H(speckle_rating_penalty, 10.0,
|
|
|
|
"Penalty to add to worst rating for noise");
|
2012-02-02 10:57:42 +08:00
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
protected:
|
|
|
|
IntegerMatcher im_;
|
|
|
|
FEATURE_DEFS_STRUCT feature_defs_;
|
2012-02-02 10:57:42 +08:00
|
|
|
// If a shape_table_ is present, it is used to remap classifier output in
|
|
|
|
// ExpandShapesAndApplyCorrections. font_ids referenced by configs actually
|
|
|
|
// mean an index to the shape_table_ and the choices returned are *all* the
|
|
|
|
// shape_table_ entries at that index.
|
|
|
|
ShapeTable* shape_table_;
|
2010-11-24 02:34:14 +08:00
|
|
|
|
2009-07-11 10:17:36 +08:00
|
|
|
private:
|
|
|
|
Dict dict_;
|
2013-09-23 23:15:06 +08:00
|
|
|
// The currently active static classifier.
|
|
|
|
ShapeClassifier* static_classifier_;
|
2010-11-24 02:34:14 +08:00
|
|
|
|
|
|
|
/* variables used to hold performance statistics */
|
|
|
|
int NumAdaptationsFailed;
|
|
|
|
|
2015-05-13 06:22:34 +08:00
|
|
|
// Training data gathered here for all the images in a document.
|
|
|
|
STRING tr_file_data_;
|
|
|
|
|
2012-02-02 10:57:42 +08:00
|
|
|
// Expected number of features in the class pruner, used to penalize
|
|
|
|
// unknowns that have too few features (like a c being classified as e) so
|
|
|
|
// it doesn't recognize everything as '@' or '#'.
|
|
|
|
// CharNormCutoffs is for the static classifier (with no shapetable).
|
|
|
|
// BaselineCutoffs gets a copy of CharNormCutoffs as an estimate of the real
|
|
|
|
// value in the adaptive classifier. Both are indexed by unichar_id.
|
|
|
|
// shapetable_cutoffs_ provides a similar value for each shape in the
|
|
|
|
// shape_table_
|
Use POSIX data types and macros (#878)
* api: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* cutil: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* training: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract data types by POSIX data types
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract data types by POSIX data types
Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX
Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix build error caused by ambiguous ClipToRange
Error message vom Appveyor CI:
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or 'int'
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-03-14 04:36:30 +08:00
|
|
|
uint16_t CharNormCutoffs[MAX_NUM_CLASSES];
|
|
|
|
uint16_t BaselineCutoffs[MAX_NUM_CLASSES];
|
|
|
|
GenericVector<uint16_t> shapetable_cutoffs_;
|
2010-11-24 02:34:14 +08:00
|
|
|
ScrollView* learn_debug_win_;
|
2010-11-30 09:00:17 +08:00
|
|
|
ScrollView* learn_fragmented_word_debug_win_;
|
|
|
|
ScrollView* learn_fragments_debug_win_;
|
2009-07-11 10:17:36 +08:00
|
|
|
};
|
|
|
|
} // namespace tesseract
|
|
|
|
|
2018-07-03 23:49:42 +08:00
|
|
|
#endif // DISABLED_LEGACY_ENGINE
|
|
|
|
|
2016-12-04 21:45:26 +08:00
|
|
|
#endif // TESSERACT_CLASSIFY_CLASSIFY_H_
|