quirc-rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +32 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ext/quirc/extconf.rb +28 -0
- data/ext/quirc/quirc.c +146 -0
- data/ext/src/Makefile +103 -0
- data/ext/src/lib/decode.c +945 -0
- data/ext/src/lib/identify.c +1139 -0
- data/ext/src/lib/quirc.c +165 -0
- data/ext/src/lib/quirc.h +178 -0
- data/ext/src/lib/quirc_internal.h +129 -0
- data/ext/src/lib/version_db.c +421 -0
- data/lib/quirc.rb +33 -0
- data/lib/quirc/ext/string_camelize.rb +13 -0
- data/lib/quirc/image_processor.rb +25 -0
- data/lib/quirc/image_processor/mini_magick.rb +43 -0
- data/lib/quirc/image_processor/vips.rb +50 -0
- data/lib/quirc/version.rb +5 -0
- data/quirc.gemspec +32 -0
- metadata +90 -0
@@ -0,0 +1,421 @@
|
|
1
|
+
/* quirc -- QR-code recognition library
|
2
|
+
* Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
|
3
|
+
*
|
4
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
7
|
+
*
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include "quirc_internal.h"
|
18
|
+
|
19
|
+
const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1] = {
|
20
|
+
{0},
|
21
|
+
{ /* Version 1 */
|
22
|
+
.data_bytes = 26,
|
23
|
+
.apat = {0},
|
24
|
+
.ecc = {
|
25
|
+
{.bs = 26, .dw = 16, .ns = 1},
|
26
|
+
{.bs = 26, .dw = 19, .ns = 1},
|
27
|
+
{.bs = 26, .dw = 9, .ns = 1},
|
28
|
+
{.bs = 26, .dw = 13, .ns = 1}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{ /* Version 2 */
|
32
|
+
.data_bytes = 44,
|
33
|
+
.apat = {6, 18, 0},
|
34
|
+
.ecc = {
|
35
|
+
{.bs = 44, .dw = 28, .ns = 1},
|
36
|
+
{.bs = 44, .dw = 34, .ns = 1},
|
37
|
+
{.bs = 44, .dw = 16, .ns = 1},
|
38
|
+
{.bs = 44, .dw = 22, .ns = 1}
|
39
|
+
}
|
40
|
+
},
|
41
|
+
{ /* Version 3 */
|
42
|
+
.data_bytes = 70,
|
43
|
+
.apat = {6, 22, 0},
|
44
|
+
.ecc = {
|
45
|
+
{.bs = 70, .dw = 44, .ns = 1},
|
46
|
+
{.bs = 70, .dw = 55, .ns = 1},
|
47
|
+
{.bs = 35, .dw = 13, .ns = 2},
|
48
|
+
{.bs = 35, .dw = 17, .ns = 2}
|
49
|
+
}
|
50
|
+
},
|
51
|
+
{ /* Version 4 */
|
52
|
+
.data_bytes = 100,
|
53
|
+
.apat = {6, 26, 0},
|
54
|
+
.ecc = {
|
55
|
+
{.bs = 50, .dw = 32, .ns = 2},
|
56
|
+
{.bs = 100, .dw = 80, .ns = 1},
|
57
|
+
{.bs = 25, .dw = 9, .ns = 4},
|
58
|
+
{.bs = 50, .dw = 24, .ns = 2}
|
59
|
+
}
|
60
|
+
},
|
61
|
+
{ /* Version 5 */
|
62
|
+
.data_bytes = 134,
|
63
|
+
.apat = {6, 30, 0},
|
64
|
+
.ecc = {
|
65
|
+
{.bs = 67, .dw = 43, .ns = 2},
|
66
|
+
{.bs = 134, .dw = 108, .ns = 1},
|
67
|
+
{.bs = 33, .dw = 11, .ns = 2},
|
68
|
+
{.bs = 33, .dw = 15, .ns = 2}
|
69
|
+
}
|
70
|
+
},
|
71
|
+
{ /* Version 6 */
|
72
|
+
.data_bytes = 172,
|
73
|
+
.apat = {6, 34, 0},
|
74
|
+
.ecc = {
|
75
|
+
{.bs = 43, .dw = 27, .ns = 4},
|
76
|
+
{.bs = 86, .dw = 68, .ns = 2},
|
77
|
+
{.bs = 43, .dw = 15, .ns = 4},
|
78
|
+
{.bs = 43, .dw = 19, .ns = 4}
|
79
|
+
}
|
80
|
+
},
|
81
|
+
{ /* Version 7 */
|
82
|
+
.data_bytes = 196,
|
83
|
+
.apat = {6, 22, 38, 0},
|
84
|
+
.ecc = {
|
85
|
+
{.bs = 49, .dw = 31, .ns = 4},
|
86
|
+
{.bs = 98, .dw = 78, .ns = 2},
|
87
|
+
{.bs = 39, .dw = 13, .ns = 4},
|
88
|
+
{.bs = 32, .dw = 14, .ns = 2}
|
89
|
+
}
|
90
|
+
},
|
91
|
+
{ /* Version 8 */
|
92
|
+
.data_bytes = 242,
|
93
|
+
.apat = {6, 24, 42, 0},
|
94
|
+
.ecc = {
|
95
|
+
{.bs = 60, .dw = 38, .ns = 2},
|
96
|
+
{.bs = 121, .dw = 97, .ns = 2},
|
97
|
+
{.bs = 40, .dw = 14, .ns = 4},
|
98
|
+
{.bs = 40, .dw = 18, .ns = 4}
|
99
|
+
}
|
100
|
+
},
|
101
|
+
{ /* Version 9 */
|
102
|
+
.data_bytes = 292,
|
103
|
+
.apat = {6, 26, 46, 0},
|
104
|
+
.ecc = {
|
105
|
+
{.bs = 58, .dw = 36, .ns = 3},
|
106
|
+
{.bs = 146, .dw = 116, .ns = 2},
|
107
|
+
{.bs = 36, .dw = 12, .ns = 4},
|
108
|
+
{.bs = 36, .dw = 16, .ns = 4}
|
109
|
+
}
|
110
|
+
},
|
111
|
+
{ /* Version 10 */
|
112
|
+
.data_bytes = 346,
|
113
|
+
.apat = {6, 28, 50, 0},
|
114
|
+
.ecc = {
|
115
|
+
{.bs = 69, .dw = 43, .ns = 4},
|
116
|
+
{.bs = 86, .dw = 68, .ns = 2},
|
117
|
+
{.bs = 43, .dw = 15, .ns = 6},
|
118
|
+
{.bs = 43, .dw = 19, .ns = 6}
|
119
|
+
}
|
120
|
+
},
|
121
|
+
{ /* Version 11 */
|
122
|
+
.data_bytes = 404,
|
123
|
+
.apat = {6, 30, 54, 0},
|
124
|
+
.ecc = {
|
125
|
+
{.bs = 80, .dw = 50, .ns = 1},
|
126
|
+
{.bs = 101, .dw = 81, .ns = 4},
|
127
|
+
{.bs = 36, .dw = 12, .ns = 3},
|
128
|
+
{.bs = 50, .dw = 22, .ns = 4}
|
129
|
+
}
|
130
|
+
},
|
131
|
+
{ /* Version 12 */
|
132
|
+
.data_bytes = 466,
|
133
|
+
.apat = {6, 32, 58, 0},
|
134
|
+
.ecc = {
|
135
|
+
{.bs = 58, .dw = 36, .ns = 6},
|
136
|
+
{.bs = 116, .dw = 92, .ns = 2},
|
137
|
+
{.bs = 42, .dw = 14, .ns = 7},
|
138
|
+
{.bs = 46, .dw = 20, .ns = 4}
|
139
|
+
}
|
140
|
+
},
|
141
|
+
{ /* Version 13 */
|
142
|
+
.data_bytes = 532,
|
143
|
+
.apat = {6, 34, 62, 0},
|
144
|
+
.ecc = {
|
145
|
+
{.bs = 59, .dw = 37, .ns = 8},
|
146
|
+
{.bs = 133, .dw = 107, .ns = 4},
|
147
|
+
{.bs = 33, .dw = 11, .ns = 12},
|
148
|
+
{.bs = 44, .dw = 20, .ns = 8}
|
149
|
+
}
|
150
|
+
},
|
151
|
+
{ /* Version 14 */
|
152
|
+
.data_bytes = 581,
|
153
|
+
.apat = {6, 26, 46, 66, 0},
|
154
|
+
.ecc = {
|
155
|
+
{.bs = 64, .dw = 40, .ns = 4},
|
156
|
+
{.bs = 145, .dw = 115, .ns = 3},
|
157
|
+
{.bs = 36, .dw = 12, .ns = 11},
|
158
|
+
{.bs = 36, .dw = 16, .ns = 11}
|
159
|
+
}
|
160
|
+
},
|
161
|
+
{ /* Version 15 */
|
162
|
+
.data_bytes = 655,
|
163
|
+
.apat = {6, 26, 48, 70, 0},
|
164
|
+
.ecc = {
|
165
|
+
{.bs = 65, .dw = 41, .ns = 5},
|
166
|
+
{.bs = 109, .dw = 87, .ns = 5},
|
167
|
+
{.bs = 36, .dw = 12, .ns = 11},
|
168
|
+
{.bs = 54, .dw = 24, .ns = 5}
|
169
|
+
}
|
170
|
+
},
|
171
|
+
{ /* Version 16 */
|
172
|
+
.data_bytes = 733,
|
173
|
+
.apat = {6, 26, 50, 74, 0},
|
174
|
+
.ecc = {
|
175
|
+
{.bs = 73, .dw = 45, .ns = 7},
|
176
|
+
{.bs = 122, .dw = 98, .ns = 5},
|
177
|
+
{.bs = 45, .dw = 15, .ns = 3},
|
178
|
+
{.bs = 43, .dw = 19, .ns = 15}
|
179
|
+
}
|
180
|
+
},
|
181
|
+
{ /* Version 17 */
|
182
|
+
.data_bytes = 815,
|
183
|
+
.apat = {6, 30, 54, 78, 0},
|
184
|
+
.ecc = {
|
185
|
+
{.bs = 74, .dw = 46, .ns = 10},
|
186
|
+
{.bs = 135, .dw = 107, .ns = 1},
|
187
|
+
{.bs = 42, .dw = 14, .ns = 2},
|
188
|
+
{.bs = 50, .dw = 22, .ns = 1}
|
189
|
+
}
|
190
|
+
},
|
191
|
+
{ /* Version 18 */
|
192
|
+
.data_bytes = 901,
|
193
|
+
.apat = {6, 30, 56, 82, 0},
|
194
|
+
.ecc = {
|
195
|
+
{.bs = 69, .dw = 43, .ns = 9},
|
196
|
+
{.bs = 150, .dw = 120, .ns = 5},
|
197
|
+
{.bs = 42, .dw = 14, .ns = 2},
|
198
|
+
{.bs = 50, .dw = 22, .ns = 17}
|
199
|
+
}
|
200
|
+
},
|
201
|
+
{ /* Version 19 */
|
202
|
+
.data_bytes = 991,
|
203
|
+
.apat = {6, 30, 58, 86, 0},
|
204
|
+
.ecc = {
|
205
|
+
{.bs = 70, .dw = 44, .ns = 3},
|
206
|
+
{.bs = 141, .dw = 113, .ns = 3},
|
207
|
+
{.bs = 39, .dw = 13, .ns = 9},
|
208
|
+
{.bs = 47, .dw = 21, .ns = 17}
|
209
|
+
}
|
210
|
+
},
|
211
|
+
{ /* Version 20 */
|
212
|
+
.data_bytes = 1085,
|
213
|
+
.apat = {6, 34, 62, 90, 0},
|
214
|
+
.ecc = {
|
215
|
+
{.bs = 67, .dw = 41, .ns = 3},
|
216
|
+
{.bs = 135, .dw = 107, .ns = 3},
|
217
|
+
{.bs = 43, .dw = 15, .ns = 15},
|
218
|
+
{.bs = 54, .dw = 24, .ns = 15}
|
219
|
+
}
|
220
|
+
},
|
221
|
+
{ /* Version 21 */
|
222
|
+
.data_bytes = 1156,
|
223
|
+
.apat = {6, 28, 50, 72, 92, 0},
|
224
|
+
.ecc = {
|
225
|
+
{.bs = 68, .dw = 42, .ns = 17},
|
226
|
+
{.bs = 144, .dw = 116, .ns = 4},
|
227
|
+
{.bs = 46, .dw = 16, .ns = 19},
|
228
|
+
{.bs = 50, .dw = 22, .ns = 17}
|
229
|
+
}
|
230
|
+
},
|
231
|
+
{ /* Version 22 */
|
232
|
+
.data_bytes = 1258,
|
233
|
+
.apat = {6, 26, 50, 74, 98, 0},
|
234
|
+
.ecc = {
|
235
|
+
{.bs = 74, .dw = 46, .ns = 17},
|
236
|
+
{.bs = 139, .dw = 111, .ns = 2},
|
237
|
+
{.bs = 37, .dw = 13, .ns = 34},
|
238
|
+
{.bs = 54, .dw = 24, .ns = 7}
|
239
|
+
}
|
240
|
+
},
|
241
|
+
{ /* Version 23 */
|
242
|
+
.data_bytes = 1364,
|
243
|
+
.apat = {6, 30, 54, 78, 102, 0},
|
244
|
+
.ecc = {
|
245
|
+
{.bs = 75, .dw = 47, .ns = 4},
|
246
|
+
{.bs = 151, .dw = 121, .ns = 4},
|
247
|
+
{.bs = 45, .dw = 15, .ns = 16},
|
248
|
+
{.bs = 54, .dw = 24, .ns = 11}
|
249
|
+
}
|
250
|
+
},
|
251
|
+
{ /* Version 24 */
|
252
|
+
.data_bytes = 1474,
|
253
|
+
.apat = {6, 28, 54, 80, 106, 0},
|
254
|
+
.ecc = {
|
255
|
+
{.bs = 73, .dw = 45, .ns = 6},
|
256
|
+
{.bs = 147, .dw = 117, .ns = 6},
|
257
|
+
{.bs = 46, .dw = 16, .ns = 30},
|
258
|
+
{.bs = 54, .dw = 24, .ns = 11}
|
259
|
+
}
|
260
|
+
},
|
261
|
+
{ /* Version 25 */
|
262
|
+
.data_bytes = 1588,
|
263
|
+
.apat = {6, 32, 58, 84, 110, 0},
|
264
|
+
.ecc = {
|
265
|
+
{.bs = 75, .dw = 47, .ns = 8},
|
266
|
+
{.bs = 132, .dw = 106, .ns = 8},
|
267
|
+
{.bs = 45, .dw = 15, .ns = 22},
|
268
|
+
{.bs = 54, .dw = 24, .ns = 7}
|
269
|
+
}
|
270
|
+
},
|
271
|
+
{ /* Version 26 */
|
272
|
+
.data_bytes = 1706,
|
273
|
+
.apat = {6, 30, 58, 86, 114, 0},
|
274
|
+
.ecc = {
|
275
|
+
{.bs = 74, .dw = 46, .ns = 19},
|
276
|
+
{.bs = 142, .dw = 114, .ns = 10},
|
277
|
+
{.bs = 46, .dw = 16, .ns = 33},
|
278
|
+
{.bs = 50, .dw = 22, .ns = 28}
|
279
|
+
}
|
280
|
+
},
|
281
|
+
{ /* Version 27 */
|
282
|
+
.data_bytes = 1828,
|
283
|
+
.apat = {6, 34, 62, 90, 118, 0},
|
284
|
+
.ecc = {
|
285
|
+
{.bs = 73, .dw = 45, .ns = 22},
|
286
|
+
{.bs = 152, .dw = 122, .ns = 8},
|
287
|
+
{.bs = 45, .dw = 15, .ns = 12},
|
288
|
+
{.bs = 53, .dw = 23, .ns = 8}
|
289
|
+
}
|
290
|
+
},
|
291
|
+
{ /* Version 28 */
|
292
|
+
.data_bytes = 1921,
|
293
|
+
.apat = {6, 26, 50, 74, 98, 122, 0},
|
294
|
+
.ecc = {
|
295
|
+
{.bs = 73, .dw = 45, .ns = 3},
|
296
|
+
{.bs = 147, .dw = 117, .ns = 3},
|
297
|
+
{.bs = 45, .dw = 15, .ns = 11},
|
298
|
+
{.bs = 54, .dw = 24, .ns = 4}
|
299
|
+
}
|
300
|
+
},
|
301
|
+
{ /* Version 29 */
|
302
|
+
.data_bytes = 2051,
|
303
|
+
.apat = {6, 30, 54, 78, 102, 126, 0},
|
304
|
+
.ecc = {
|
305
|
+
{.bs = 73, .dw = 45, .ns = 21},
|
306
|
+
{.bs = 146, .dw = 116, .ns = 7},
|
307
|
+
{.bs = 45, .dw = 15, .ns = 19},
|
308
|
+
{.bs = 53, .dw = 23, .ns = 1}
|
309
|
+
}
|
310
|
+
},
|
311
|
+
{ /* Version 30 */
|
312
|
+
.data_bytes = 2185,
|
313
|
+
.apat = {6, 26, 52, 78, 104, 130, 0},
|
314
|
+
.ecc = {
|
315
|
+
{.bs = 75, .dw = 47, .ns = 19},
|
316
|
+
{.bs = 145, .dw = 115, .ns = 5},
|
317
|
+
{.bs = 45, .dw = 15, .ns = 23},
|
318
|
+
{.bs = 54, .dw = 24, .ns = 15}
|
319
|
+
}
|
320
|
+
},
|
321
|
+
{ /* Version 31 */
|
322
|
+
.data_bytes = 2323,
|
323
|
+
.apat = {6, 30, 56, 82, 108, 134, 0},
|
324
|
+
.ecc = {
|
325
|
+
{.bs = 74, .dw = 46, .ns = 2},
|
326
|
+
{.bs = 145, .dw = 115, .ns = 13},
|
327
|
+
{.bs = 45, .dw = 15, .ns = 23},
|
328
|
+
{.bs = 54, .dw = 24, .ns = 42}
|
329
|
+
}
|
330
|
+
},
|
331
|
+
{ /* Version 32 */
|
332
|
+
.data_bytes = 2465,
|
333
|
+
.apat = {6, 34, 60, 86, 112, 138, 0},
|
334
|
+
.ecc = {
|
335
|
+
{.bs = 74, .dw = 46, .ns = 10},
|
336
|
+
{.bs = 145, .dw = 115, .ns = 17},
|
337
|
+
{.bs = 45, .dw = 15, .ns = 19},
|
338
|
+
{.bs = 54, .dw = 24, .ns = 10}
|
339
|
+
}
|
340
|
+
},
|
341
|
+
{ /* Version 33 */
|
342
|
+
.data_bytes = 2611,
|
343
|
+
.apat = {6, 30, 58, 86, 114, 142, 0},
|
344
|
+
.ecc = {
|
345
|
+
{.bs = 74, .dw = 46, .ns = 14},
|
346
|
+
{.bs = 145, .dw = 115, .ns = 17},
|
347
|
+
{.bs = 45, .dw = 15, .ns = 11},
|
348
|
+
{.bs = 54, .dw = 24, .ns = 29}
|
349
|
+
}
|
350
|
+
},
|
351
|
+
{ /* Version 34 */
|
352
|
+
.data_bytes = 2761,
|
353
|
+
.apat = {6, 34, 62, 90, 118, 146, 0},
|
354
|
+
.ecc = {
|
355
|
+
{.bs = 74, .dw = 46, .ns = 14},
|
356
|
+
{.bs = 145, .dw = 115, .ns = 13},
|
357
|
+
{.bs = 46, .dw = 16, .ns = 59},
|
358
|
+
{.bs = 54, .dw = 24, .ns = 44}
|
359
|
+
}
|
360
|
+
},
|
361
|
+
{ /* Version 35 */
|
362
|
+
.data_bytes = 2876,
|
363
|
+
.apat = {6, 30, 54, 78, 102, 126, 150},
|
364
|
+
.ecc = {
|
365
|
+
{.bs = 75, .dw = 47, .ns = 12},
|
366
|
+
{.bs = 151, .dw = 121, .ns = 12},
|
367
|
+
{.bs = 45, .dw = 15, .ns = 22},
|
368
|
+
{.bs = 54, .dw = 24, .ns = 39}
|
369
|
+
}
|
370
|
+
},
|
371
|
+
{ /* Version 36 */
|
372
|
+
.data_bytes = 3034,
|
373
|
+
.apat = {6, 24, 50, 76, 102, 128, 154},
|
374
|
+
.ecc = {
|
375
|
+
{.bs = 75, .dw = 47, .ns = 6},
|
376
|
+
{.bs = 151, .dw = 121, .ns = 6},
|
377
|
+
{.bs = 45, .dw = 15, .ns = 2},
|
378
|
+
{.bs = 54, .dw = 24, .ns = 46}
|
379
|
+
}
|
380
|
+
},
|
381
|
+
{ /* Version 37 */
|
382
|
+
.data_bytes = 3196,
|
383
|
+
.apat = {6, 28, 54, 80, 106, 132, 158},
|
384
|
+
.ecc = {
|
385
|
+
{.bs = 74, .dw = 46, .ns = 29},
|
386
|
+
{.bs = 152, .dw = 122, .ns = 17},
|
387
|
+
{.bs = 45, .dw = 15, .ns = 24},
|
388
|
+
{.bs = 54, .dw = 24, .ns = 49}
|
389
|
+
}
|
390
|
+
},
|
391
|
+
{ /* Version 38 */
|
392
|
+
.data_bytes = 3362,
|
393
|
+
.apat = {6, 32, 58, 84, 110, 136, 162},
|
394
|
+
.ecc = {
|
395
|
+
{.bs = 74, .dw = 46, .ns = 13},
|
396
|
+
{.bs = 152, .dw = 122, .ns = 4},
|
397
|
+
{.bs = 45, .dw = 15, .ns = 42},
|
398
|
+
{.bs = 54, .dw = 24, .ns = 48}
|
399
|
+
}
|
400
|
+
},
|
401
|
+
{ /* Version 39 */
|
402
|
+
.data_bytes = 3532,
|
403
|
+
.apat = {6, 26, 54, 82, 110, 138, 166},
|
404
|
+
.ecc = {
|
405
|
+
{.bs = 75, .dw = 47, .ns = 40},
|
406
|
+
{.bs = 147, .dw = 117, .ns = 20},
|
407
|
+
{.bs = 45, .dw = 15, .ns = 10},
|
408
|
+
{.bs = 54, .dw = 24, .ns = 43}
|
409
|
+
}
|
410
|
+
},
|
411
|
+
{ /* Version 40 */
|
412
|
+
.data_bytes = 3706,
|
413
|
+
.apat = {6, 30, 58, 86, 114, 142, 170},
|
414
|
+
.ecc = {
|
415
|
+
{.bs = 75, .dw = 47, .ns = 18},
|
416
|
+
{.bs = 148, .dw = 118, .ns = 19},
|
417
|
+
{.bs = 45, .dw = 15, .ns = 20},
|
418
|
+
{.bs = 54, .dw = 24, .ns = 34}
|
419
|
+
}
|
420
|
+
}
|
421
|
+
};
|
data/lib/quirc.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "quirc/version"
|
2
|
+
require "quirc/quirc"
|
3
|
+
require "quirc/image_processor"
|
4
|
+
|
5
|
+
module Quirc
|
6
|
+
unless "".respond_to?(:camelize)
|
7
|
+
require "quirc/ext/string_camelize"
|
8
|
+
using Quirc::Ext::StringCamelize
|
9
|
+
end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def recognize(path, width: nil, height: nil, image_processor: :vips, **options)
|
13
|
+
processor = lookup_image_processor(image_processor, path)
|
14
|
+
|
15
|
+
processor.to_grayscale(width: width, height: height, **options) do |image_data, width, height|
|
16
|
+
Recognizer.new.recognize(image_data, width, height)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def lookup_image_processor(name, path)
|
22
|
+
retrieve_image_processor_class(name).new(path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def retrieve_image_processor_class(name)
|
26
|
+
require "quirc/image_processor/#{name}"
|
27
|
+
rescue LoadError => e
|
28
|
+
raise "Could not find image processor for #{name} (#{e})"
|
29
|
+
else
|
30
|
+
Quirc::ImageProcessor.const_get(name.to_s.camelize)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|