Tesseract 3.01
/data/source/tesseract-ocr/classify/intproto.cpp File Reference
#include "helpers.h"
#include "intproto.h"
#include "picofeat.h"
#include "mfoutline.h"
#include "emalloc.h"
#include "const.h"
#include "ndminx.h"
#include "svmnode.h"
#include "globals.h"
#include "classify.h"
#include "genericvector.h"
#include <math.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>

Classes

struct  FILL_SWITCH
struct  TABLE_FILLER
struct  FILL_SPEC

Namespaces

namespace  tesseract

Defines

#define PROTO_PRUNER_SCALE   (4.0)
#define INT_DESCENDER   (0.0 * INT_CHAR_NORM_RANGE)
#define INT_BASELINE   (0.25 * INT_CHAR_NORM_RANGE)
#define INT_XHEIGHT   (0.75 * INT_CHAR_NORM_RANGE)
#define INT_CAPHEIGHT   (1.0 * INT_CHAR_NORM_RANGE)
#define INT_XCENTER   (0.5 * INT_CHAR_NORM_RANGE)
#define INT_YCENTER   (0.5 * INT_CHAR_NORM_RANGE)
#define INT_XRADIUS   (0.2 * INT_CHAR_NORM_RANGE)
#define INT_YRADIUS   (0.2 * INT_CHAR_NORM_RANGE)
#define INT_MIN_X   0
#define INT_MIN_Y   0
#define INT_MAX_X   INT_CHAR_NORM_RANGE
#define INT_MAX_Y   INT_CHAR_NORM_RANGE
#define HV_TOLERANCE   (0.0025)
#define MAX_NUM_SWITCHES   3
#define OLD_MAX_NUM_CONFIGS   32
#define OLD_WERDS_PER_CONFIG_VEC
#define CircularIncrement(i, r)   (((i) < (r) - 1)?((i)++):((i) = 0))
#define MapParam(P, O, N)   (floor (((P) + (O)) * (N)))
#define MAX_LEVEL   2
#define XS   X_SHIFT
#define YS   Y_SHIFT
#define AS   ANGLE_SHIFT
#define NB   NUM_CP_BUCKETS

Enumerations

enum  SWITCH_TYPE { StartSwitch, EndSwitch, LastSwitch }

Functions

FLOAT32 BucketStart (int Bucket, FLOAT32 Offset, int NumBuckets)
FLOAT32 BucketEnd (int Bucket, FLOAT32 Offset, int NumBuckets)
void DoFill (FILL_SPEC *FillSpec, CLASS_PRUNER Pruner, register uinT32 ClassMask, register uinT32 ClassCount, register uinT32 WordIndex)
BOOL8 FillerDone (TABLE_FILLER *Filler)
void FillPPCircularBits (uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug)
void FillPPLinearBits (uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], int Bit, FLOAT32 Center, FLOAT32 Spread, bool debug)
void GetCPPadsForLevel (int Level, FLOAT32 *EndPad, FLOAT32 *SidePad, FLOAT32 *AnglePad)
ScrollView::Color GetMatchColorFor (FLOAT32 Evidence)
void GetNextFill (TABLE_FILLER *Filler, FILL_SPEC *Fill)
void InitTableFiller (FLOAT32 EndPad, FLOAT32 SidePad, FLOAT32 AnglePad, PROTO Proto, TABLE_FILLER *Filler)
void RenderIntFeature (ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
void RenderIntProto (ScrollView *window, INT_CLASS Class, PROTO_ID ProtoId, ScrollView::Color color)
int TruncateParam (FLOAT32 Param, int Min, int Max, char *Id)
void AddIntClass (INT_TEMPLATES Templates, CLASS_ID ClassId, INT_CLASS Class)
int AddIntConfig (INT_CLASS Class)
int AddIntProto (INT_CLASS Class)
void AddProtoToClassPruner (PROTO Proto, CLASS_ID ClassId, INT_TEMPLATES Templates)
void AddProtoToProtoPruner (PROTO Proto, int ProtoId, INT_CLASS Class, bool debug)
int BucketFor (FLOAT32 Param, FLOAT32 Offset, int NumBuckets)
int CircBucketFor (FLOAT32 Param, FLOAT32 Offset, int NumBuckets)
void UpdateMatchDisplay ()
void ConvertConfig (BIT_VECTOR Config, int ConfigId, INT_CLASS Class)
void DisplayIntFeature (INT_FEATURE Feature, FLOAT32 Evidence)
void DisplayIntProto (INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence)
INT_CLASS NewIntClass (int MaxNumProtos, int MaxNumConfigs)
void free_int_class (INT_CLASS int_class)
INT_TEMPLATES NewIntTemplates ()
void free_int_templates (INT_TEMPLATES templates)
void tesseract::ClearFeatureSpaceWindow (NORM_METHOD norm_method, ScrollView *window)
void InitIntMatchWindowIfReqd ()
void InitProtoDisplayWindowIfReqd ()
void InitFeatureDisplayWindowIfReqd ()
ScrollViewCreateFeatureSpaceWindow (const char *name, int xpos, int ypos)

Variables

ScrollViewIntMatchWindow = NULL
ScrollViewFeatureDisplayWindow = NULL
ScrollViewProtoDisplayWindow = NULL
int classify_num_cp_levels = 3
double classify_cp_angle_pad_loose = 45.0
double classify_cp_angle_pad_medium = 20.0
double classify_cp_angle_pad_tight = 10.0
double classify_cp_end_pad_loose = 0.5
double classify_cp_end_pad_medium = 0.5
double classify_cp_end_pad_tight = 0.5
double classify_cp_side_pad_loose = 2.5
double classify_cp_side_pad_medium = 1.2
double classify_cp_side_pad_tight = 0.6
double classify_pp_angle_pad = 45.0
double classify_pp_end_pad = 0.5
double classify_pp_side_pad = 2.5

Define Documentation

#define AS   ANGLE_SHIFT
#define CircularIncrement (   i,
 
)    (((i) < (r) - 1)?((i)++):((i) = 0))

macro for performing circular increments of bucket indices

#define HV_TOLERANCE   (0.0025)

define pad used to snap near horiz/vertical protos to horiz/vertical

#define INT_BASELINE   (0.25 * INT_CHAR_NORM_RANGE)
#define INT_CAPHEIGHT   (1.0 * INT_CHAR_NORM_RANGE)
#define INT_DESCENDER   (0.0 * INT_CHAR_NORM_RANGE)
#define INT_MAX_X   INT_CHAR_NORM_RANGE
#define INT_MAX_Y   INT_CHAR_NORM_RANGE
#define INT_MIN_X   0
#define INT_MIN_Y   0
#define INT_XCENTER   (0.5 * INT_CHAR_NORM_RANGE)
#define INT_XHEIGHT   (0.75 * INT_CHAR_NORM_RANGE)
#define INT_XRADIUS   (0.2 * INT_CHAR_NORM_RANGE)
#define INT_YCENTER   (0.5 * INT_CHAR_NORM_RANGE)
#define INT_YRADIUS   (0.2 * INT_CHAR_NORM_RANGE)
#define MapParam (   P,
  O,
 
)    (floor (((P) + (O)) * (N)))

macro for mapping floats to ints without bounds checking

#define MAX_LEVEL   2
#define MAX_NUM_SWITCHES   3
#define NB   NUM_CP_BUCKETS
#define OLD_MAX_NUM_CONFIGS   32
#define OLD_WERDS_PER_CONFIG_VEC
#define PROTO_PRUNER_SCALE   (4.0)
#define XS   X_SHIFT
#define YS   Y_SHIFT

Enumeration Type Documentation

Enumerator:
StartSwitch 
EndSwitch 
LastSwitch 

Function Documentation

void AddIntClass ( INT_TEMPLATES  Templates,
CLASS_ID  ClassId,
INT_CLASS  Class 
)

This routine adds a new class structure to a set of templates. Classes have to be added to Templates in the order of increasing ClassIds.

Parameters:
Templatestemplates to add new class to
ClassIdclass id to associate new class with
Classclass data structure to add to templates

Globals: none

Note:
Exceptions: none
History: Mon Feb 11 11:52:08 1991, DSJ, Created.
int AddIntConfig ( INT_CLASS  Class)

This routine returns the index of the next free config in Class.

Parameters:
Classclass to add new configuration to

Globals: none

Returns:
Index of next free config.
Note:
Exceptions: none
History: Mon Feb 11 14:44:40 1991, DSJ, Created.
int AddIntProto ( INT_CLASS  Class)

This routine allocates the next free proto in Class and returns its index.

Parameters:
Classclass to add new proto to

Globals: none

Returns:
Proto index of new proto.
Note:
Exceptions: none
History: Mon Feb 11 13:26:41 1991, DSJ, Created.
void AddProtoToClassPruner ( PROTO  Proto,
CLASS_ID  ClassId,
INT_TEMPLATES  Templates 
)
void AddProtoToProtoPruner ( PROTO  Proto,
int  ProtoId,
INT_CLASS  Class,
bool  debug 
)
FLOAT32 BucketEnd ( int  Bucket,
FLOAT32  Offset,
int  NumBuckets 
)
int BucketFor ( FLOAT32  Param,
FLOAT32  Offset,
int  NumBuckets 
)
FLOAT32 BucketStart ( int  Bucket,
FLOAT32  Offset,
int  NumBuckets 
)
int CircBucketFor ( FLOAT32  Param,
FLOAT32  Offset,
int  NumBuckets 
)
void ConvertConfig ( BIT_VECTOR  Config,
int  ConfigId,
INT_CLASS  Class 
)
ScrollView* CreateFeatureSpaceWindow ( const char *  name,
int  xpos,
int  ypos 
)
void DisplayIntFeature ( INT_FEATURE  Feature,
FLOAT32  Evidence 
)
void DisplayIntProto ( INT_CLASS  Class,
PROTO_ID  ProtoId,
FLOAT32  Evidence 
)
void DoFill ( FILL_SPEC FillSpec,
CLASS_PRUNER  Pruner,
register uinT32  ClassMask,
register uinT32  ClassCount,
register uinT32  WordIndex 
)
BOOL8 FillerDone ( TABLE_FILLER Filler)
void FillPPCircularBits ( uinT32  ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
int  Bit,
FLOAT32  Center,
FLOAT32  Spread,
bool  debug 
)
void FillPPLinearBits ( uinT32  ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
int  Bit,
FLOAT32  Center,
FLOAT32  Spread,
bool  debug 
)
void free_int_class ( INT_CLASS  int_class)
void free_int_templates ( INT_TEMPLATES  templates)
void GetCPPadsForLevel ( int  Level,
FLOAT32 EndPad,
FLOAT32 SidePad,
FLOAT32 AnglePad 
)
ScrollView::Color GetMatchColorFor ( FLOAT32  Evidence)
void GetNextFill ( TABLE_FILLER Filler,
FILL_SPEC Fill 
)
void InitFeatureDisplayWindowIfReqd ( )

Initializes the feature display window if it is not already initialized.

void InitIntMatchWindowIfReqd ( )

Initializes the int matcher window if it is not already initialized.

void InitProtoDisplayWindowIfReqd ( )

Initializes the proto display window if it is not already initialized.

void InitTableFiller ( FLOAT32  EndPad,
FLOAT32  SidePad,
FLOAT32  AnglePad,
PROTO  Proto,
TABLE_FILLER Filler 
)

This routine computes a data structure (Filler) which can be used to fill in a rectangle surrounding the specified Proto.

Parameters:
EndPad,SidePad,AnglePadpadding to add to proto
Protoproto to create a filler for
Fillerplace to put table filler

Globals: none

Returns:
none (results are returned in Filler)
Note:
Exceptions: none
History: Thu Feb 14 09:27:05 1991, DSJ, Created.
INT_CLASS NewIntClass ( int  MaxNumProtos,
int  MaxNumConfigs 
)
INT_TEMPLATES NewIntTemplates ( )
void RenderIntFeature ( ScrollView window,
const INT_FEATURE_STRUCT Feature,
ScrollView::Color  color 
)
void RenderIntProto ( ScrollView window,
INT_CLASS  Class,
PROTO_ID  ProtoId,
ScrollView::Color  color 
)

This routine extracts the parameters of the specified proto from the class description and adds a rendering of the proto onto the ShapeList.

Parameters:
ShapeListshape list to append proto rendering onto
Classclass that proto is contained in
ProtoIdid of proto to be rendered
Colorcolor to render proto in

Globals: none

Returns:
New shape list with a rendering of one proto added.
Note:
Exceptions: none
History: Thu Mar 21 10:21:09 1991, DSJ, Created.
int TruncateParam ( FLOAT32  Param,
int  Min,
int  Max,
char *  Id 
)

This routine truncates Param to lie within the range of Min-Max inclusive. If a truncation is performed, and Id is not null, an warning message is printed.

Parameters:
Paramparameter value to be truncated
Min,Maxparameter limits (inclusive)
Idstring id of parameter for error messages

Globals: none

Returns:
Truncated parameter.
Note:
Exceptions: none
History: Fri Feb 8 11:54:28 1991, DSJ, Created.
void UpdateMatchDisplay ( )

Variable Documentation

"Class Pruner Angle Pad Loose"

"Class Pruner Angle Pad Medium"

"CLass Pruner Angle Pad Tight"

"Class Pruner End Pad Loose"

"Class Pruner End Pad Medium"

"Class Pruner End Pad Tight"

"Class Pruner Side Pad Loose"

"Class Pruner Side Pad Medium"

"Class Pruner Side Pad Tight"

"Number of Class Pruner Levels"

double classify_pp_angle_pad = 45.0

"Proto Pruner Angle Pad"

double classify_pp_end_pad = 0.5

"Proto Prune End Pad"

double classify_pp_side_pad = 2.5

"Proto Pruner Side Pad"

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines