Tesseract  3.02
tesseract-ocr/classify/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>
#include <assert.h>

Go to the source code of this file.

Classes

struct  ScoredClass
struct  ADAPT_RESULTS
struct  PROTO_KEY

Namespaces

namespace  tesseract

Defines

#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)

Define 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 1645 of file adaptmatch.cpp.

                                      {  // ScoredClass *class2
  const ScoredClass *class1 = (const ScoredClass *)arg1;
  const ScoredClass *class2 = (const ScoredClass *)arg2;

  if (class1->rating < class2->rating)
    return -1;
  else if (class1->rating > class2->rating)
    return 1;

  if (class1->unichar_id < class2->unichar_id)
    return -1;
  else if (class1->unichar_id > class2->unichar_id)
    return 1;
  return 0;
}
ScoredClass * FindScoredUnichar ( ADAPT_RESULTS results,
UNICHAR_ID  id 
)

Definition at line 1625 of file adaptmatch.cpp.

                                                                      {
  for (int i = 0; i < results->NumMatches; i++) {
    if (results->match[i].unichar_id == id)
      return &results->match[i];
  }
  return NULL;
}
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 2382 of file adaptmatch.cpp.

                                                {
  ADAPT_CLASS Class;
  TEMP_CONFIG Config;
  TEMP_PROTO TempProto;
  PROTO_KEY *ProtoKey;

  TempProto = (TEMP_PROTO) item1;
  ProtoKey = (PROTO_KEY *) item2;

  Class = ProtoKey->Templates->Class[ProtoKey->ClassId];
  Config = TempConfigFor(Class, ProtoKey->ConfigId);

  if (TempProto->ProtoId > Config->MaxProtoId ||
      !test_bit (Config->Protos, TempProto->ProtoId))
    return FALSE;

  MakeProtoPermanent(Class, TempProto->ProtoId);
  AddProtoToClassPruner(&(TempProto->Proto), ProtoKey->ClassId,
                         ProtoKey->Templates->Templates);
  FreeTempProto(TempProto);

  return TRUE;
}                              /* MakeTempProtoPerm */
ScoredClass ScoredUnichar ( ADAPT_RESULTS results,
UNICHAR_ID  id 
)

Definition at line 1635 of file adaptmatch.cpp.

                                                                 {
  ScoredClass poor_result =
      {id, -1, WORST_POSSIBLE_RATING, false, -1,
          kBlankFontinfoId, kBlankFontinfoId};
  ScoredClass *entry = FindScoredUnichar(results, id);
  return (entry == NULL) ? poor_result : *entry;
}
void SetAdaptiveThreshold ( FLOAT32  Threshold)