Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
adaptive.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Filename: adaptive.h
3 ** Purpose: Interface to adaptive matcher.
4 ** Author: Dan Johnson
5 ** History: Fri Mar 8 10:00:49 1991, DSJ, Created.
6 **
7 ** (c) Copyright Hewlett-Packard Company, 1988.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 ******************************************************************************/
18 #ifndef ADAPTIVE_H
19 #define ADAPTIVE_H
20
21 /*----------------------------------------------------------------------------
22 Include Files and Type Defines
23 ----------------------------------------------------------------------------*/
24 #include "oldlist.h"
25 #include "intproto.h"
26 #include <stdio.h>
27
28 typedef struct
29 {
30 uinT16 ProtoId;
31 uinT16 dummy;
32 PROTO_STRUCT Proto;
33 }
34
35
36 TEMP_PROTO_STRUCT;
37 typedef TEMP_PROTO_STRUCT *TEMP_PROTO;
38
39 typedef struct
40 {
41 uinT8 NumTimesSeen;
42 uinT8 ProtoVectorSize;
43 PROTO_ID MaxProtoId;
44 LIST ContextsSeen;
45 BIT_VECTOR Protos;
46 int FontinfoId; // font information inferred from pre-trained templates
47 } TEMP_CONFIG_STRUCT;
48 typedef TEMP_CONFIG_STRUCT *TEMP_CONFIG;
49
50 typedef struct
51 {
52 UNICHAR_ID *Ambigs;
53 int FontinfoId; // font information inferred from pre-trained templates
54 } PERM_CONFIG_STRUCT;
55 typedef PERM_CONFIG_STRUCT *PERM_CONFIG;
56
57 typedef union
58 {
59 TEMP_CONFIG Temp;
60 PERM_CONFIG Perm;
61 } ADAPTED_CONFIG;
62
63 typedef struct
64 {
65 uinT8 NumPermConfigs;
66 uinT8 MaxNumTimesSeen; // maximum number of times any TEMP_CONFIG was seen
67 uinT8 dummy[2]; // (cut at matcher_min_examples_for_prototyping)
68 BIT_VECTOR PermProtos;
69 BIT_VECTOR PermConfigs;
70 LIST TempProtos;
71 ADAPTED_CONFIG Config[MAX_NUM_CONFIGS];
72 } ADAPT_CLASS_STRUCT;
73 typedef ADAPT_CLASS_STRUCT *ADAPT_CLASS;
74
75 typedef struct
76 {
77 INT_TEMPLATES Templates;
78 int NumNonEmptyClasses;
79 uinT8 NumPermClasses;
80 uinT8 dummy[3];
81 ADAPT_CLASS Class[MAX_NUM_CLASSES];
82 } ADAPT_TEMPLATES_STRUCT;
83 typedef ADAPT_TEMPLATES_STRUCT *ADAPT_TEMPLATES;
84
85 /*----------------------------------------------------------------------------
86 Public Function Prototypes
87 ----------------------------------------------------------------------------*/
88 #define NumNonEmptyClassesIn(Template) ((Template)->NumNonEmptyClasses)
89
90 #define IsEmptyAdaptedClass(Class) ((Class)->NumPermConfigs == 0 && \
91 (Class)->TempProtos == NIL_LIST)
92
93 #define ConfigIsPermanent(Class,ConfigId) \
94 (test_bit ((Class)->PermConfigs, ConfigId))
95
96 #define MakeConfigPermanent(Class,ConfigId) \
97 (SET_BIT ((Class)->PermConfigs, ConfigId))
98
99 #define MakeProtoPermanent(Class,ProtoId) \
100 (SET_BIT ((Class)->PermProtos, ProtoId))
101
102 #define TempConfigFor(Class,ConfigId) \
103 ((Class)->Config[ConfigId].Temp)
104
105 #define PermConfigFor(Class,ConfigId) \
106 ((Class)->Config[ConfigId].Perm)
107
108 #define IncreaseConfidence(TempConfig) \
109 ((TempConfig)->NumTimesSeen++)
110
111 void AddAdaptedClass(ADAPT_TEMPLATES Templates,
112 ADAPT_CLASS Class,
113 CLASS_ID ClassId);
114
115 void FreeTempProto(void *arg);
116
117 void FreeTempConfig(TEMP_CONFIG Config);
118
119 ADAPT_CLASS NewAdaptedClass();
120
121 void free_adapted_class(ADAPT_CLASS adapt_class);
122
123 void free_adapted_templates(ADAPT_TEMPLATES templates);
124
125 TEMP_CONFIG NewTempConfig(int MaxProtoId, int FontinfoId);
126
127 TEMP_PROTO NewTempProto();
128
129 ADAPT_CLASS ReadAdaptedClass(FILE *File);
130
131 PERM_CONFIG ReadPermConfig(FILE *File);
132
133 TEMP_CONFIG ReadTempConfig(FILE *File);
134
135 void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs);
136
137 void WritePermConfig(FILE *File, PERM_CONFIG Config);
138
139 void WriteTempConfig(FILE *File, TEMP_CONFIG Config);
140
141 #endif