tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
matchdefs.h
1 /******************************************************************************
2  ** Filename: matchdefs.h
3  ** Purpose: Generic interface definitions for feature matchers.
4  ** Author: Dan Johnson
5  ** History: Fri Jan 19 09:21:25 1990, 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 
19 #ifndef MATCHDEFS_H
20 #define MATCHDEFS_H
21 
25 #include "host.h"
26 #include <cstdio>
27 #include "unichar.h"
28 
29 /* define the maximum number of classes defined for any matcher
30  and the maximum class id for any matcher. This must be changed
31  if more different classes need to be classified */
32 #define MAX_NUM_CLASSES INT16_MAX
33 #define MAX_CLASS_ID (MAX_NUM_CLASSES - 1)
34 
36 using CLASS_ID = UNICHAR_ID;
37 #define NO_CLASS (0)
38 
42 using PROTO_ID = int16_t;
43 #define NO_PROTO (-1)
44 
48 using FEATURE_ID = uint8_t;
49 #define NO_FEATURE 255
50 #define NOISE_FEATURE 254
51 #define MISSING_PROTO 254
52 #define MAX_NUM_FEAT 40
53 #define MAX_FEATURE_ID 250
54 
57 using RATING = float;
58 
63 using CERTAINTY = float;
64 
66 typedef struct
67 {
68  CLASS_ID Class;
69  RATING Rating;
70  CERTAINTY Certainty;
71 }
72 
73 
75 
77 typedef MATCH_RESULT SORTED_CLASSES[MAX_CLASS_ID + 1];
78 
79 /*----------------------------------------------------------------------------
80  Public Function Prototypes
81 ----------------------------------------------------------------------------*/
90 /* misc test functions for proto id's and feature id's */
91 #define IsValidFeature(Fid) ((Fid) < MAX_FEATURE_ID)
92 #define IsValidProto(Pid) ((Pid) >= 0)
93 
94 #if defined(__STDC__) || defined(__cplusplus)
95 # define _ARGS(s) s
96 #else
97 # define _ARGS(s) ()
98 #endif
99 
100 /* matchdefs.c */
101 int CompareMatchResults
102 _ARGS ((MATCH_RESULT * Result1, MATCH_RESULT * Result2));
103 
104 void PrintMatchResult _ARGS ((FILE * File, MATCH_RESULT * MatchResult));
105 
106 void PrintMatchResults
107 _ARGS ((FILE * File, int N, MATCH_RESULT MatchResults[]));
108 
109 #undef _ARGS
110 
111 /*----------------------------------------------------------------------------
112  Global Data Definitions and Declarations
113 ----------------------------------------------------------------------------*/
114 #endif
CERTAINTY Certainty
Definition: matchdefs.h:70
RATING Rating
Definition: matchdefs.h:69
CLASS_ID Class
Definition: matchdefs.h:68
Definition: matchdefs.h:66