tesseract  5.0.0-alpha-619-ge9db
matchdefs.h
Go to the documentation of this file.
1 /******************************************************************************
2  ** Filename: matchdefs.h
3  ** Purpose: Generic interface definitions for feature matchers.
4  ** Author: Dan Johnson
5  **
6  ** (c) Copyright Hewlett-Packard Company, 1988.
7  ** Licensed under the Apache License, Version 2.0 (the "License");
8  ** you may not use this file except in compliance with the License.
9  ** You may obtain a copy of the License at
10  ** http://www.apache.org/licenses/LICENSE-2.0
11  ** Unless required by applicable law or agreed to in writing, software
12  ** distributed under the License is distributed on an "AS IS" BASIS,
13  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  ** See the License for the specific language governing permissions and
15  ** limitations under the License.
16  ******************************************************************************/
17 
18 #ifndef MATCHDEFS_H
19 #define MATCHDEFS_H
20 
24 #include <cstdio>
25 #include <tesseract/unichar.h>
26 
27 /* define the maximum number of classes defined for any matcher
28  and the maximum class id for any matcher. This must be changed
29  if more different classes need to be classified */
30 #define MAX_NUM_CLASSES INT16_MAX
31 #define MAX_CLASS_ID (MAX_NUM_CLASSES - 1)
32 
35 #define NO_CLASS (0)
36 
40 using PROTO_ID = int16_t;
41 #define NO_PROTO (-1)
42 
46 using FEATURE_ID = uint8_t;
47 #define NO_FEATURE 255
48 #define NOISE_FEATURE 254
49 #define MISSING_PROTO 254
50 #define MAX_NUM_FEAT 40
51 #define MAX_FEATURE_ID 250
52 
55 using RATING = float;
56 
61 using CERTAINTY = float;
62 
64 typedef struct
65 {
66  CLASS_ID Class;
67  RATING Rating;
68  CERTAINTY Certainty;
69 }
70 
71 
73 
76 
77 /*----------------------------------------------------------------------------
78  Public Function Prototypes
79 ----------------------------------------------------------------------------*/
88 /* misc test functions for proto id's and feature id's */
89 #define IsValidFeature(Fid) ((Fid) < MAX_FEATURE_ID)
90 #define IsValidProto(Pid) ((Pid) >= 0)
91 
92 #if defined(__STDC__) || defined(__cplusplus)
93 # define _ARGS(s) s
94 #else
95 # define _ARGS(s) ()
96 #endif
97 
98 /* matchdefs.c */
99 int CompareMatchResults
100 _ARGS ((MATCH_RESULT * Result1, MATCH_RESULT * Result2));
101 
102 void PrintMatchResult _ARGS ((FILE * File, MATCH_RESULT * MatchResult));
103 
104 void PrintMatchResults
105 _ARGS ((FILE * File, int N, MATCH_RESULT MatchResults[]));
106 
107 #undef _ARGS
108 
109 /*----------------------------------------------------------------------------
110  Global Data Definitions and Declarations
111 ----------------------------------------------------------------------------*/
112 #endif
CLASS_ID
UNICHAR_ID CLASS_ID
Definition: matchdefs.h:33
PROTO_ID
int16_t PROTO_ID
Definition: matchdefs.h:39
MATCH_RESULT
Definition: matchdefs.h:63
RATING
float RATING
Definition: matchdefs.h:54
UNICHAR_ID
int UNICHAR_ID
Definition: unichar.h:36
SORTED_CLASSES
MATCH_RESULT SORTED_CLASSES[MAX_CLASS_ID+1]
Definition: matchdefs.h:74
unichar.h
MAX_CLASS_ID
#define MAX_CLASS_ID
Definition: matchdefs.h:30
FEATURE_ID
uint8_t FEATURE_ID
Definition: matchdefs.h:45
CERTAINTY
float CERTAINTY
Definition: matchdefs.h:60
_ARGS
#define _ARGS(s)
Definition: matchdefs.h:94