#include <math.h>
#include <stdio.h>
#include <assert.h>
#include "classify.h"
#include "const.h"
#include "emalloc.h"
#include "fontinfo.h"
#include "genericvector.h"
#include "globals.h"
#include "helpers.h"
#include "intproto.h"
#include "mfoutline.h"
#include "ndminx.h"
#include "picofeat.h"
#include "shapetable.h"
#include "svmnode.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_STRUCT *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 (const INT_FEATURE_STRUCT *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 () |
ScrollView * | CreateFeatureSpaceWindow (const char *name, int xpos, int ypos) |
Variables | |
ScrollView * | IntMatchWindow = NULL |
ScrollView * | FeatureDisplayWindow = NULL |
ScrollView * | ProtoDisplayWindow = 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 AS ANGLE_SHIFT |
#define CircularIncrement | ( | i, | |||
r | ) | (((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, | |||||
N | ) | (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 |
((OLD_MAX_NUM_CONFIGS + BITS_PER_WERD - 1) /\ BITS_PER_WERD)
#define PROTO_PRUNER_SCALE (4.0) |
#define XS X_SHIFT |
#define YS Y_SHIFT |
enum SWITCH_TYPE |
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.
Templates | templates to add new class to | |
ClassId | class id to associate new class with | |
Class | class data structure to add to templates |
Globals: none
int AddIntConfig | ( | INT_CLASS | Class | ) |
This routine returns the index of the next free config in Class.
Class | class to add new configuration to |
Globals: none
int AddIntProto | ( | INT_CLASS | Class | ) |
This routine allocates the next free proto in Class and returns its index.
Class | class to add new proto to |
Globals: none
void AddProtoToClassPruner | ( | PROTO | Proto, | |
CLASS_ID | ClassId, | |||
INT_TEMPLATES | Templates | |||
) |
void ConvertConfig | ( | BIT_VECTOR | Config, | |
int | ConfigId, | |||
INT_CLASS | Class | |||
) |
ScrollView* CreateFeatureSpaceWindow | ( | const char * | name, | |
int | xpos, | |||
int | ypos | |||
) |
void DisplayIntFeature | ( | const INT_FEATURE_STRUCT * | Feature, | |
FLOAT32 | Evidence | |||
) |
void DoFill | ( | FILL_SPEC * | FillSpec, | |
CLASS_PRUNER_STRUCT * | 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 | ) |
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.
EndPad,SidePad,AnglePad | padding to add to proto | |
Proto | proto to create a filler for | |
Filler | place to put table filler |
Globals: none
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.
ShapeList | shape list to append proto rendering onto | |
Class | class that proto is contained in | |
ProtoId | id of proto to be rendered | |
Color | color to render proto in |
Globals: none
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.
Param | parameter value to be truncated | |
Min,Max | parameter limits (inclusive) | |
Id | string id of parameter for error messages |
Globals: none
void UpdateMatchDisplay | ( | ) |
double classify_cp_angle_pad_loose = 45.0 |
"Class Pruner Angle Pad Loose"
double classify_cp_angle_pad_medium = 20.0 |
"Class Pruner Angle Pad Medium"
double classify_cp_angle_pad_tight = 10.0 |
"CLass Pruner Angle Pad Tight"
double classify_cp_end_pad_loose = 0.5 |
"Class Pruner End Pad Loose"
double classify_cp_end_pad_medium = 0.5 |
"Class Pruner End Pad Medium"
double classify_cp_end_pad_tight = 0.5 |
"Class Pruner End Pad Tight"
double classify_cp_side_pad_loose = 2.5 |
"Class Pruner Side Pad Loose"
double classify_cp_side_pad_medium = 1.2 |
"Class Pruner Side Pad Medium"
double classify_cp_side_pad_tight = 0.6 |
"Class Pruner Side Pad Tight"
int classify_num_cp_levels = 3 |
"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"
ScrollView* FeatureDisplayWindow = NULL |
ScrollView* IntMatchWindow = NULL |
ScrollView* ProtoDisplayWindow = NULL |