-
Notifications
You must be signed in to change notification settings - Fork 38
/
defines.h
212 lines (180 loc) · 6.4 KB
/
defines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/* Seven Segment Optical Character Recognition Constant Definitions */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Copyright (C) 2004-2024 Erik Auerswald <auerswal@unix-ag.uni-kl.de> */
/* Copyright (C) 2013 Cristiano Fontana <fontanacl@ornl.gov> */
#define PROG "ssocr"
#ifndef SSOCR2_DEFINES_H
#define SSOCR2_DEFINES_H
/* version number */
#define VERSION "2.24.0+"
/* states */
#define FIND_DARK 0
#define FIND_LIGHT 1
/* boarder between dark and light */
#define THRESHOLD 50.0
#define DARK 0
#define LIGHT 1
#define UNKNOWN 2
/* segments
*
* 1 -
* 2 3 | |
* 4 -
* 5 6 | |
* 7 -
*
* */
#define HORIZ_UP 1
#define VERT_LEFT_UP 2
#define VERT_RIGHT_UP 4
#define HORIZ_MID 8
#define VERT_LEFT_DOWN 16
#define VERT_RIGHT_DOWN 32
#define HORIZ_DOWN 64
#define ALL_SEGS 127
#define DECIMAL 128
#define MINUS HORIZ_MID
/* maximum number used for a character #define */
#define CHARSET_MAX 128
/* digits */
#define D_ZERO (ALL_SEGS & ~HORIZ_MID)
#define D_ONE (VERT_RIGHT_UP | VERT_RIGHT_DOWN)
#define D_TWO (ALL_SEGS & ~(VERT_LEFT_UP | VERT_RIGHT_DOWN))
#define D_THREE (ALL_SEGS & ~(VERT_LEFT_UP | VERT_LEFT_DOWN))
#define D_FOUR (ALL_SEGS & ~(HORIZ_UP | VERT_LEFT_DOWN | HORIZ_DOWN))
#define D_FIVE (ALL_SEGS & ~(VERT_RIGHT_UP | VERT_LEFT_DOWN))
#define D_SIX (ALL_SEGS & ~VERT_RIGHT_UP)
#define D_SEVEN (HORIZ_UP | VERT_RIGHT_UP | VERT_RIGHT_DOWN)
#define D_ALTSEVEN (VERT_LEFT_UP | D_SEVEN)
#define D_EIGHT ALL_SEGS
#define D_NINE (ALL_SEGS & ~VERT_LEFT_DOWN)
#define D_ALTNINE (ALL_SEGS & ~(VERT_LEFT_DOWN | HORIZ_DOWN))
#define D_DECIMAL DECIMAL
#define D_MINUS MINUS
#define D_HEX_A (ALL_SEGS & ~HORIZ_DOWN)
#define D_HEX_b (ALL_SEGS & ~(HORIZ_UP | VERT_RIGHT_UP))
#define D_HEX_C (ALL_SEGS & ~(VERT_RIGHT_UP | HORIZ_MID | VERT_RIGHT_DOWN))
/* a C in the lower half can only happen when digit boundary detection fails */
#define D_HEX_c (HORIZ_MID | VERT_LEFT_DOWN | HORIZ_DOWN)
#define D_HEX_d (ALL_SEGS & ~(HORIZ_UP | VERT_LEFT_UP))
#define D_HEX_E (ALL_SEGS & ~(VERT_RIGHT_UP | VERT_RIGHT_DOWN))
#define D_HEX_F (ALL_SEGS & ~(VERT_RIGHT_UP | VERT_RIGHT_DOWN | HORIZ_DOWN))
#define D_U (D_ZERO & ~HORIZ_UP)
#define D_T (ALL_SEGS & ~(HORIZ_UP | VERT_RIGHT_UP | VERT_RIGHT_DOWN))
#define D_L (D_T & ~HORIZ_MID)
#define D_H (ALL_SEGS & ~(HORIZ_UP | HORIZ_DOWN))
#define D_h (VERT_LEFT_UP | VERT_LEFT_DOWN | HORIZ_MID | VERT_RIGHT_DOWN)
#define D_R (D_ZERO & ~(VERT_RIGHT_DOWN | HORIZ_DOWN))
#define D_ALT_R (VERT_LEFT_UP | VERT_LEFT_DOWN | HORIZ_UP)
/* an r in the lower half can only happen when digit boundary detection fails */
#define D_r (VERT_LEFT_DOWN | HORIZ_MID)
#define D_P (D_HEX_F | VERT_RIGHT_UP)
#define D_N (D_ZERO & ~HORIZ_DOWN)
/* an N in the lower half can only happen when digit boundary detection fails */
#define D_n (VERT_LEFT_DOWN | VERT_RIGHT_DOWN | HORIZ_MID)
#define D_Y (ALL_SEGS & ~(HORIZ_UP | VERT_LEFT_DOWN))
#define D_J (HORIZ_DOWN | VERT_RIGHT_UP | VERT_RIGHT_DOWN)
/* add two "wrong" 7 definitions used in a character set for a Chinese
* table tennis robot */
#define D_TT_WRONG_SEVEN_1 (D_SEVEN | VERT_LEFT_DOWN | HORIZ_DOWN)
#define D_TT_WRONG_SEVEN_2 (D_SEVEN | HORIZ_DOWN)
#define D_UNKNOWN 0
#define NUMBER_OF_DIGITS 6 /* in this special case */
/* a decimal point (or thousands separator) is recognized by height less
* than <maximum digit height> / DEC_H_RATIO and width less than
* <maximum digit width> / DEC_W_RATIO */
#define DEC_H_RATIO 5
#define DEC_W_RATIO 2 /* needs to work with just ones in the display, too */
/* a one is recognized by a height/width ratio > ONE_RATIO (as ints) */
#define ONE_RATIO 3
/* a minus sign is recognized by a width/height ratio > MINUS_RATIO (as ints) */
#define MINUS_RATIO 2
/* add space characters if digit distance is greater than SPC_FAC * min dist */
#define SPC_FAC 1.4
/* number of set pixels needed in a scanline to recognize a segment */
#define NEED_PIXELS 1
/* minimum number of pixels required for a segment
* this generalizes to both scanline and ratio based digit detection,
* but only when the digit is built using segments, i.e., this is not
* used for decimal separators */
#define MIN_SEGMENT 1
/* minimum width of a character respectively digit */
#define MIN_CHAR_W 1
/* minimum height of a character respectively digit */
#define MIN_CHAR_H 1
/* ignore # of pixels when checking a column fo black or white */
#define IGNORE_PIXELS 0
#define DIR_SEP "/"
#define TMP_FILE_DIR "/tmp"
#define TMP_FILE_PATTERN "ssocr.img.XXXXXX"
#define DEBUG_IMAGE_NAME "testbild.png"
/* flags set by options */
#define ABSOLUTE_THRESHOLD 1
#define DO_ITERATIVE_THRESHOLD (1<<1)
#define VERBOSE (1<<2)
#define USE_DEBUG_IMAGE (1<<3)
#define PROCESS_ONLY (1<<4)
#define PRINT_INFO (1<<5)
#define ADJUST_GRAY (1<<6)
#define DEBUG_OUTPUT (1<<7)
#define ASCII_ART_SEGMENTS (1<<8)
#define PRINT_AS_HEX (1<<9)
#define OMIT_DECIMAL (1<<10)
#define PRINT_SPACES (1<<11)
#define SPC_USE_AVG_DST (1<<12)
/* colors used by ssocr */
#define SSOCR_BLACK 0
#define SSOCR_WHITE 255
#define SSOCR_DEFAULT_FOREGROUND SSOCR_BLACK
#define SSOCR_DEFAULT_BACKGROUND SSOCR_WHITE
/* maximum RGB component value */
#define MAXRGB 255
/* doubles are assumed equal when they differ less than EPSILON */
#define EPSILON 0.0000001
/* default luminance formula */
#define DEFAULT_LUM_FORMULA REC709
/* foreground and background */
typedef enum fg_bg_e {
FG,
BG
} fg_bg_t;
/* luminance types resp. formulas */
typedef enum luminance_e {
REC601,
REC709,
LINEAR,
MINIMUM,
MAXIMUM,
RED,
GREEN,
BLUE,
LUM_PARSE_ERROR
} luminance_t;
/* direction, to mirror horizontally or vertically, or for a scanline */
typedef enum direction_e {
HORIZONTAL,
VERTICAL
} direction_t;
/* character sets to choose from */
typedef enum charset_e {
CS_FULL,
CS_DIGITS,
CS_DECIMAL,
CS_HEXADECIMAL,
CS_TT_ROBOT,
CS_PARSE_ERROR
} charset_t;
#define DEFAULT_CHARSET CS_FULL
#endif /* SSOCR2_DEFINES_H */