tesseract 4.1.1
Loading...
Searching...
No Matches
adaptmatch.cpp File Reference
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "adaptive.h"
#include "ambigs.h"
#include "bitvec.h"
#include "blobs.h"
#include "callcpp.h"
#include "classify.h"
#include "dict.h"
#include "errcode.h"
#include "featdefs.h"
#include "float2int.h"
#include "fontinfo.h"
#include "genericvector.h"
#include "helpers.h"
#include "intfx.h"
#include "intmatcher.h"
#include "intproto.h"
#include "matchdefs.h"
#include "mfoutline.h"
#include "normalis.h"
#include "normfeat.h"
#include "ocrfeatures.h"
#include "oldlist.h"
#include "outfeat.h"
#include "pageres.h"
#include "params.h"
#include "picofeat.h"
#include "protos.h"
#include "ratngs.h"
#include "rect.h"
#include "scrollview.h"
#include "seam.h"
#include "serialis.h"
#include "shapeclassifier.h"
#include "shapetable.h"
#include "strngs.h"
#include "tessclassifier.h"
#include "tessdatamanager.h"
#include "tprintf.h"
#include "trainingsample.h"
#include "unichar.h"
#include "unicharset.h"
#include "unicity_table.h"

Go to the source code of this file.

Classes

struct  ADAPT_RESULTS
 
struct  PROTO_KEY
 

Namespaces

namespace  tesseract
 

Macros

#define ADAPT_TEMPLATE_SUFFIX   ".a"
 
#define MAX_MATCHES   10
 
#define UNLIKELY_NUM_FEAT   200
 
#define NO_DEBUG   0
 
#define MAX_ADAPTABLE_WERD_SIZE   40
 
#define ADAPTABLE_WERD_ADJUSTMENT   (0.05)
 
#define Y_DIM_OFFSET   (Y_SHIFT - BASELINE_Y_SHIFT)
 
#define WORST_POSSIBLE_RATING   (0.0f)
 

Functions

bool MarginalMatch (float confidence, float matcher_great_threshold)
 
void InitMatcherRatings (float *Rating)
 
int MakeTempProtoPerm (void *item1, void *item2)
 
void SetAdaptiveThreshold (float Threshold)
 

Macro Definition Documentation

◆ ADAPT_TEMPLATE_SUFFIX

#define ADAPT_TEMPLATE_SUFFIX   ".a"

Definition at line 75 of file adaptmatch.cpp.

◆ ADAPTABLE_WERD_ADJUSTMENT

#define ADAPTABLE_WERD_ADJUSTMENT   (0.05)

Definition at line 82 of file adaptmatch.cpp.

◆ MAX_ADAPTABLE_WERD_SIZE

#define MAX_ADAPTABLE_WERD_SIZE   40

Definition at line 80 of file adaptmatch.cpp.

◆ MAX_MATCHES

#define MAX_MATCHES   10

Definition at line 77 of file adaptmatch.cpp.

◆ NO_DEBUG

#define NO_DEBUG   0

Definition at line 79 of file adaptmatch.cpp.

◆ UNLIKELY_NUM_FEAT

#define UNLIKELY_NUM_FEAT   200

Definition at line 78 of file adaptmatch.cpp.

◆ WORST_POSSIBLE_RATING

#define WORST_POSSIBLE_RATING   (0.0f)

Definition at line 86 of file adaptmatch.cpp.

◆ Y_DIM_OFFSET

#define Y_DIM_OFFSET   (Y_SHIFT - BASELINE_Y_SHIFT)

Definition at line 84 of file adaptmatch.cpp.

Function Documentation

◆ InitMatcherRatings()

void InitMatcherRatings ( float *  Rating)

◆ MakeTempProtoPerm()

int MakeTempProtoPerm ( void *  item1,
void *  item2 
)

This routine converts TempProto to be permanent if its proto id is used by the configuration specified in ProtoKey.

Parameters
item1(TEMP_PROTO) temporary proto to compare to key
item2(PROTO_KEY) defines which protos to make permanent

Globals: none

Returns
true if TempProto is converted, false otherwise

Definition at line 1980 of file adaptmatch.cpp.

1980 {
1981 ADAPT_CLASS Class;
1983 TEMP_PROTO TempProto;
1984 PROTO_KEY *ProtoKey;
1985
1986 TempProto = static_cast<TEMP_PROTO>(item1);
1987 ProtoKey = static_cast<PROTO_KEY *>(item2);
1988
1989 Class = ProtoKey->Templates->Class[ProtoKey->ClassId];
1990 Config = TempConfigFor(Class, ProtoKey->ConfigId);
1991
1992 if (TempProto->ProtoId > Config->MaxProtoId ||
1993 !test_bit (Config->Protos, TempProto->ProtoId))
1994 return false;
1995
1996 MakeProtoPermanent(Class, TempProto->ProtoId);
1997 AddProtoToClassPruner(&(TempProto->Proto), ProtoKey->ClassId,
1998 ProtoKey->Templates->Templates);
1999 FreeTempProto(TempProto);
2000
2001 return true;
2002} /* MakeTempProtoPerm */
void FreeTempProto(void *arg)
Definition: adaptive.cpp:81
#define MakeProtoPermanent(Class, ProtoId)
Definition: adaptive.h:88
#define TempConfigFor(Class, ConfigId)
Definition: adaptive.h:91
void AddProtoToClassPruner(PROTO Proto, CLASS_ID ClassId, INT_TEMPLATES Templates)
Definition: intproto.cpp:328
#define test_bit(array, bit)
Definition: bitvec.h:59
CLUSTERCONFIG Config
uint16_t ProtoId
Definition: adaptive.h:28
PROTO_STRUCT Proto
Definition: adaptive.h:29
ADAPT_CLASS Class[MAX_NUM_CLASSES]
Definition: adaptive.h:70
INT_TEMPLATES Templates
Definition: adaptive.h:67
CLASS_ID ClassId
Definition: adaptmatch.cpp:124
ADAPT_TEMPLATES Templates
Definition: adaptmatch.cpp:123

◆ MarginalMatch()

bool MarginalMatch ( float  confidence,
float  matcher_great_threshold 
)
inline

Definition at line 131 of file adaptmatch.cpp.

131 {
132 return (1.0f - confidence) > matcher_great_threshold;
133}

◆ SetAdaptiveThreshold()

void SetAdaptiveThreshold ( float  Threshold)