Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
adaptmatch.cpp File Reference
#include <ctype.h>
#include "ambigs.h"
#include "blobclass.h"
#include "blobs.h"
#include "helpers.h"
#include "normfeat.h"
#include "mfoutline.h"
#include "picofeat.h"
#include "float2int.h"
#include "outfeat.h"
#include "emalloc.h"
#include "intfx.h"
#include "speckle.h"
#include "efio.h"
#include "normmatch.h"
#include "permute.h"
#include "ndminx.h"
#include "intproto.h"
#include "const.h"
#include "globals.h"
#include "werd.h"
#include "callcpp.h"
#include "pageres.h"
#include "params.h"
#include "classify.h"
#include "shapetable.h"
#include "tessclassifier.h"
#include "trainingsample.h"
#include "unicharset.h"
#include "dict.h"
#include "featdefs.h"
#include "genericvector.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

Go to the source code of this file.

Classes

struct  ScoredClass
 
struct  ADAPT_RESULTS
 
struct  PROTO_KEY
 

Namespaces

 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   (1.0)
 
#define MarginalMatch(Rating)   ((Rating) > matcher_great_threshold)
 
#define InitIntFX()   (FeaturesHaveBeenExtracted = FALSE)
 

Functions

int CompareByRating (const void *arg1, const void *arg2)
 
ScoredClassFindScoredUnichar (ADAPT_RESULTS *results, UNICHAR_ID id)
 
ScoredClass ScoredUnichar (ADAPT_RESULTS *results, UNICHAR_ID id)
 
void InitMatcherRatings (register FLOAT32 *Rating)
 
int MakeTempProtoPerm (void *item1, void *item2)
 
void SetAdaptiveThreshold (FLOAT32 Threshold)
 

Macro Definition Documentation

#define ADAPT_TEMPLATE_SUFFIX   ".a"

Definition at line 68 of file adaptmatch.cpp.

#define ADAPTABLE_WERD_ADJUSTMENT   (0.05)

Definition at line 75 of file adaptmatch.cpp.

#define InitIntFX ( )    (FeaturesHaveBeenExtracted = FALSE)

Definition at line 127 of file adaptmatch.cpp.

#define MarginalMatch (   Rating)    ((Rating) > matcher_great_threshold)

Definition at line 124 of file adaptmatch.cpp.

#define MAX_ADAPTABLE_WERD_SIZE   40

Definition at line 73 of file adaptmatch.cpp.

#define MAX_MATCHES   10

Definition at line 70 of file adaptmatch.cpp.

#define NO_DEBUG   0

Definition at line 72 of file adaptmatch.cpp.

#define UNLIKELY_NUM_FEAT   200

Definition at line 71 of file adaptmatch.cpp.

#define WORST_POSSIBLE_RATING   (1.0)

Definition at line 79 of file adaptmatch.cpp.

#define Y_DIM_OFFSET   (Y_SHIFT - BASELINE_Y_SHIFT)

Definition at line 77 of file adaptmatch.cpp.

Function Documentation

int CompareByRating ( const void *  arg1,
const void *  arg2 
)

Definition at line 1650 of file adaptmatch.cpp.

1651  { // ScoredClass *class2
1652  const ScoredClass *class1 = (const ScoredClass *)arg1;
1653  const ScoredClass *class2 = (const ScoredClass *)arg2;
1654 
1655  if (class1->rating < class2->rating)
1656  return -1;
1657  else if (class1->rating > class2->rating)
1658  return 1;
1659 
1660  if (class1->unichar_id < class2->unichar_id)
1661  return -1;
1662  else if (class1->unichar_id > class2->unichar_id)
1663  return 1;
1664  return 0;
1665 }
CLASS_ID unichar_id
Definition: adaptmatch.cpp:82
FLOAT32 rating
Definition: adaptmatch.cpp:84
ScoredClass * FindScoredUnichar ( ADAPT_RESULTS results,
UNICHAR_ID  id 
)

Definition at line 1630 of file adaptmatch.cpp.

1630  {
1631  for (int i = 0; i < results->NumMatches; i++) {
1632  if (results->match[i].unichar_id == id)
1633  return &results->match[i];
1634  }
1635  return NULL;
1636 }
#define NULL
Definition: host.h:144
CLASS_ID unichar_id
Definition: adaptmatch.cpp:82
ScoredClass match[MAX_NUM_CLASSES]
Definition: adaptmatch.cpp:95
void InitMatcherRatings ( register FLOAT32 Rating)
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
Note
Exceptions: none
History: Thu Mar 14 18:49:54 1991, DSJ, Created.

Definition at line 2387 of file adaptmatch.cpp.

2387  {
2388  ADAPT_CLASS Class;
2390  TEMP_PROTO TempProto;
2391  PROTO_KEY *ProtoKey;
2392 
2393  TempProto = (TEMP_PROTO) item1;
2394  ProtoKey = (PROTO_KEY *) item2;
2395 
2396  Class = ProtoKey->Templates->Class[ProtoKey->ClassId];
2397  Config = TempConfigFor(Class, ProtoKey->ConfigId);
2398 
2399  if (TempProto->ProtoId > Config->MaxProtoId ||
2400  !test_bit (Config->Protos, TempProto->ProtoId))
2401  return FALSE;
2402 
2403  MakeProtoPermanent(Class, TempProto->ProtoId);
2404  AddProtoToClassPruner(&(TempProto->Proto), ProtoKey->ClassId,
2405  ProtoKey->Templates->Templates);
2406  FreeTempProto(TempProto);
2407 
2408  return TRUE;
2409 } /* MakeTempProtoPerm */
PROTO_STRUCT Proto
Definition: adaptive.h:32
PROTO_ID MaxProtoId
Definition: adaptive.h:43
CLASS_ID ClassId
Definition: adaptmatch.cpp:117
ADAPT_TEMPLATES Templates
Definition: adaptmatch.cpp:116
#define FALSE
Definition: capi.h:28
INT_TEMPLATES Templates
Definition: adaptive.h:77
#define test_bit(array, bit)
Definition: bitvec.h:61
CLUSTERCONFIG Config
#define MakeProtoPermanent(Class, ProtoId)
Definition: adaptive.h:99
void AddProtoToClassPruner(PROTO Proto, CLASS_ID ClassId, INT_TEMPLATES Templates)
Definition: intproto.cpp:320
uinT16 ProtoId
Definition: adaptive.h:30
TEMP_PROTO_STRUCT * TEMP_PROTO
Definition: adaptive.h:37
ADAPT_CLASS Class[MAX_NUM_CLASSES]
Definition: adaptive.h:81
void FreeTempProto(void *arg)
Definition: adaptive.cpp:90
#define TempConfigFor(Class, ConfigId)
Definition: adaptive.h:102
BIT_VECTOR Protos
Definition: adaptive.h:45
#define TRUE
Definition: capi.h:27
ScoredClass ScoredUnichar ( ADAPT_RESULTS results,
UNICHAR_ID  id 
)

Definition at line 1640 of file adaptmatch.cpp.

1640  {
1641  ScoredClass poor_result =
1642  {id, -1, WORST_POSSIBLE_RATING, false, -1,
1643  kBlankFontinfoId, kBlankFontinfoId};
1644  ScoredClass *entry = FindScoredUnichar(results, id);
1645  return (entry == NULL) ? poor_result : *entry;
1646 }
#define WORST_POSSIBLE_RATING
Definition: adaptmatch.cpp:79
#define NULL
Definition: host.h:144
ScoredClass * FindScoredUnichar(ADAPT_RESULTS *results, UNICHAR_ID id)
void SetAdaptiveThreshold ( FLOAT32  Threshold)