isbn 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. data/{README → README.md} +5 -11
  2. data/Rakefile +20 -14
  3. data/isbn.gemspec +23 -0
  4. data/lib/isbn.rb +2 -0
  5. data/test/isbn_spec.rb +1 -1
  6. metadata +29 -316
  7. data/VERSION +0 -1
  8. data/src/gocr-0.48/.cvsignore +0 -6
  9. data/src/gocr-0.48/AUTHORS +0 -7
  10. data/src/gocr-0.48/BUGS +0 -55
  11. data/src/gocr-0.48/CREDITS +0 -17
  12. data/src/gocr-0.48/HISTORY +0 -243
  13. data/src/gocr-0.48/INSTALL +0 -83
  14. data/src/gocr-0.48/Makefile +0 -193
  15. data/src/gocr-0.48/Makefile.in +0 -193
  16. data/src/gocr-0.48/README +0 -165
  17. data/src/gocr-0.48/READMEde.txt +0 -80
  18. data/src/gocr-0.48/REMARK.txt +0 -18
  19. data/src/gocr-0.48/REVIEW +0 -538
  20. data/src/gocr-0.48/TODO +0 -65
  21. data/src/gocr-0.48/bin/.cvsignore +0 -2
  22. data/src/gocr-0.48/bin/create_db +0 -38
  23. data/src/gocr-0.48/bin/gocr.tcl +0 -527
  24. data/src/gocr-0.48/bin/gocr_chk.sh +0 -44
  25. data/src/gocr-0.48/configure +0 -4689
  26. data/src/gocr-0.48/configure.in +0 -71
  27. data/src/gocr-0.48/doc/.#Makefile.1.6 +0 -39
  28. data/src/gocr-0.48/doc/.cvsignore +0 -2
  29. data/src/gocr-0.48/doc/Makefile +0 -39
  30. data/src/gocr-0.48/doc/Makefile.in +0 -39
  31. data/src/gocr-0.48/doc/example.dtd +0 -53
  32. data/src/gocr-0.48/doc/example.xml +0 -21
  33. data/src/gocr-0.48/doc/examples.txt +0 -67
  34. data/src/gocr-0.48/doc/gocr.html +0 -578
  35. data/src/gocr-0.48/doc/unicode.txt +0 -57
  36. data/src/gocr-0.48/examples/.#Makefile.1.22 +0 -166
  37. data/src/gocr-0.48/examples/4x6.png +0 -0
  38. data/src/gocr-0.48/examples/4x6.txt +0 -2
  39. data/src/gocr-0.48/examples/5x7.png +0 -0
  40. data/src/gocr-0.48/examples/5x7.png.txt +0 -2
  41. data/src/gocr-0.48/examples/5x8.png +0 -0
  42. data/src/gocr-0.48/examples/5x8.png.txt +0 -2
  43. data/src/gocr-0.48/examples/Makefile +0 -166
  44. data/src/gocr-0.48/examples/color.fig +0 -20
  45. data/src/gocr-0.48/examples/ex.fig +0 -16
  46. data/src/gocr-0.48/examples/font.tex +0 -22
  47. data/src/gocr-0.48/examples/font1.tex +0 -46
  48. data/src/gocr-0.48/examples/font2.fig +0 -27
  49. data/src/gocr-0.48/examples/font_nw.tex +0 -24
  50. data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
  51. data/src/gocr-0.48/examples/handwrt1.txt +0 -10
  52. data/src/gocr-0.48/examples/inverse.fig +0 -20
  53. data/src/gocr-0.48/examples/matrix.jpg +0 -0
  54. data/src/gocr-0.48/examples/ocr-a-subset.png +0 -0
  55. data/src/gocr-0.48/examples/ocr-a-subset.png.txt +0 -4
  56. data/src/gocr-0.48/examples/ocr-a.png +0 -0
  57. data/src/gocr-0.48/examples/ocr-a.txt +0 -6
  58. data/src/gocr-0.48/examples/ocr-b.png +0 -0
  59. data/src/gocr-0.48/examples/ocr-b.png.txt +0 -4
  60. data/src/gocr-0.48/examples/polish.tex +0 -28
  61. data/src/gocr-0.48/examples/rotate45.fig +0 -14
  62. data/src/gocr-0.48/examples/score +0 -36
  63. data/src/gocr-0.48/examples/text.tex +0 -28
  64. data/src/gocr-0.48/gpl.html +0 -537
  65. data/src/gocr-0.48/include/.cvsignore +0 -2
  66. data/src/gocr-0.48/include/config.h +0 -36
  67. data/src/gocr-0.48/include/config.h.in +0 -36
  68. data/src/gocr-0.48/include/version.h +0 -2
  69. data/src/gocr-0.48/install-sh +0 -3
  70. data/src/gocr-0.48/make.bat +0 -57
  71. data/src/gocr-0.48/man/.cvsignore +0 -2
  72. data/src/gocr-0.48/man/Makefile +0 -29
  73. data/src/gocr-0.48/man/Makefile.in +0 -29
  74. data/src/gocr-0.48/man/man1/gocr.1 +0 -166
  75. data/src/gocr-0.48/src/.cvsignore +0 -4
  76. data/src/gocr-0.48/src/Makefile +0 -132
  77. data/src/gocr-0.48/src/Makefile.in +0 -132
  78. data/src/gocr-0.48/src/amiga.h +0 -31
  79. data/src/gocr-0.48/src/barcode.c +0 -846
  80. data/src/gocr-0.48/src/barcode.c.orig +0 -593
  81. data/src/gocr-0.48/src/barcode.h +0 -11
  82. data/src/gocr-0.48/src/box.c +0 -372
  83. data/src/gocr-0.48/src/database.c +0 -462
  84. data/src/gocr-0.48/src/detect.c +0 -943
  85. data/src/gocr-0.48/src/gocr.c +0 -373
  86. data/src/gocr-0.48/src/gocr.h +0 -288
  87. data/src/gocr-0.48/src/jconv.c +0 -168
  88. data/src/gocr-0.48/src/job.c +0 -84
  89. data/src/gocr-0.48/src/lines.c +0 -350
  90. data/src/gocr-0.48/src/list.c +0 -334
  91. data/src/gocr-0.48/src/list.h +0 -90
  92. data/src/gocr-0.48/src/ocr0.c +0 -6756
  93. data/src/gocr-0.48/src/ocr0.h +0 -63
  94. data/src/gocr-0.48/src/ocr0n.c +0 -1475
  95. data/src/gocr-0.48/src/ocr1.c +0 -85
  96. data/src/gocr-0.48/src/ocr1.h +0 -3
  97. data/src/gocr-0.48/src/otsu.c +0 -289
  98. data/src/gocr-0.48/src/otsu.h +0 -23
  99. data/src/gocr-0.48/src/output.c +0 -289
  100. data/src/gocr-0.48/src/output.h +0 -37
  101. data/src/gocr-0.48/src/pcx.c +0 -153
  102. data/src/gocr-0.48/src/pcx.h +0 -9
  103. data/src/gocr-0.48/src/pgm2asc.c +0 -2893
  104. data/src/gocr-0.48/src/pgm2asc.h +0 -105
  105. data/src/gocr-0.48/src/pixel.c +0 -537
  106. data/src/gocr-0.48/src/pnm.c +0 -533
  107. data/src/gocr-0.48/src/pnm.h +0 -35
  108. data/src/gocr-0.48/src/progress.c +0 -87
  109. data/src/gocr-0.48/src/progress.h +0 -42
  110. data/src/gocr-0.48/src/remove.c +0 -703
  111. data/src/gocr-0.48/src/tga.c +0 -87
  112. data/src/gocr-0.48/src/tga.h +0 -6
  113. data/src/gocr-0.48/src/unicode.c +0 -1314
  114. data/src/gocr-0.48/src/unicode.h +0 -1257
  115. data/src/jpeg-7/Makefile.am +0 -133
  116. data/src/jpeg-7/Makefile.in +0 -1089
  117. data/src/jpeg-7/README +0 -322
  118. data/src/jpeg-7/aclocal.m4 +0 -8990
  119. data/src/jpeg-7/ansi2knr.1 +0 -36
  120. data/src/jpeg-7/ansi2knr.c +0 -739
  121. data/src/jpeg-7/cderror.h +0 -132
  122. data/src/jpeg-7/cdjpeg.c +0 -181
  123. data/src/jpeg-7/cdjpeg.h +0 -187
  124. data/src/jpeg-7/change.log +0 -270
  125. data/src/jpeg-7/cjpeg.1 +0 -325
  126. data/src/jpeg-7/cjpeg.c +0 -616
  127. data/src/jpeg-7/ckconfig.c +0 -402
  128. data/src/jpeg-7/coderules.txt +0 -118
  129. data/src/jpeg-7/config.guess +0 -1561
  130. data/src/jpeg-7/config.sub +0 -1686
  131. data/src/jpeg-7/configure +0 -17139
  132. data/src/jpeg-7/configure.ac +0 -317
  133. data/src/jpeg-7/depcomp +0 -630
  134. data/src/jpeg-7/djpeg.1 +0 -251
  135. data/src/jpeg-7/djpeg.c +0 -617
  136. data/src/jpeg-7/example.c +0 -433
  137. data/src/jpeg-7/filelist.txt +0 -215
  138. data/src/jpeg-7/install-sh +0 -520
  139. data/src/jpeg-7/install.txt +0 -1097
  140. data/src/jpeg-7/jaricom.c +0 -148
  141. data/src/jpeg-7/jcapimin.c +0 -282
  142. data/src/jpeg-7/jcapistd.c +0 -161
  143. data/src/jpeg-7/jcarith.c +0 -921
  144. data/src/jpeg-7/jccoefct.c +0 -453
  145. data/src/jpeg-7/jccolor.c +0 -459
  146. data/src/jpeg-7/jcdctmgr.c +0 -482
  147. data/src/jpeg-7/jchuff.c +0 -1612
  148. data/src/jpeg-7/jcinit.c +0 -65
  149. data/src/jpeg-7/jcmainct.c +0 -293
  150. data/src/jpeg-7/jcmarker.c +0 -667
  151. data/src/jpeg-7/jcmaster.c +0 -770
  152. data/src/jpeg-7/jcomapi.c +0 -106
  153. data/src/jpeg-7/jconfig.bcc +0 -48
  154. data/src/jpeg-7/jconfig.cfg +0 -45
  155. data/src/jpeg-7/jconfig.dj +0 -38
  156. data/src/jpeg-7/jconfig.mac +0 -43
  157. data/src/jpeg-7/jconfig.manx +0 -43
  158. data/src/jpeg-7/jconfig.mc6 +0 -52
  159. data/src/jpeg-7/jconfig.sas +0 -43
  160. data/src/jpeg-7/jconfig.st +0 -42
  161. data/src/jpeg-7/jconfig.txt +0 -155
  162. data/src/jpeg-7/jconfig.vc +0 -45
  163. data/src/jpeg-7/jconfig.vms +0 -37
  164. data/src/jpeg-7/jconfig.wat +0 -38
  165. data/src/jpeg-7/jcparam.c +0 -632
  166. data/src/jpeg-7/jcprepct.c +0 -358
  167. data/src/jpeg-7/jcsample.c +0 -545
  168. data/src/jpeg-7/jctrans.c +0 -381
  169. data/src/jpeg-7/jdapimin.c +0 -396
  170. data/src/jpeg-7/jdapistd.c +0 -275
  171. data/src/jpeg-7/jdarith.c +0 -762
  172. data/src/jpeg-7/jdatadst.c +0 -151
  173. data/src/jpeg-7/jdatasrc.c +0 -212
  174. data/src/jpeg-7/jdcoefct.c +0 -736
  175. data/src/jpeg-7/jdcolor.c +0 -396
  176. data/src/jpeg-7/jdct.h +0 -393
  177. data/src/jpeg-7/jddctmgr.c +0 -382
  178. data/src/jpeg-7/jdhuff.c +0 -1309
  179. data/src/jpeg-7/jdinput.c +0 -384
  180. data/src/jpeg-7/jdmainct.c +0 -512
  181. data/src/jpeg-7/jdmarker.c +0 -1360
  182. data/src/jpeg-7/jdmaster.c +0 -663
  183. data/src/jpeg-7/jdmerge.c +0 -400
  184. data/src/jpeg-7/jdpostct.c +0 -290
  185. data/src/jpeg-7/jdsample.c +0 -361
  186. data/src/jpeg-7/jdtrans.c +0 -136
  187. data/src/jpeg-7/jerror.c +0 -252
  188. data/src/jpeg-7/jerror.h +0 -304
  189. data/src/jpeg-7/jfdctflt.c +0 -174
  190. data/src/jpeg-7/jfdctfst.c +0 -230
  191. data/src/jpeg-7/jfdctint.c +0 -4348
  192. data/src/jpeg-7/jidctflt.c +0 -242
  193. data/src/jpeg-7/jidctfst.c +0 -368
  194. data/src/jpeg-7/jidctint.c +0 -5137
  195. data/src/jpeg-7/jinclude.h +0 -91
  196. data/src/jpeg-7/jmemansi.c +0 -167
  197. data/src/jpeg-7/jmemdos.c +0 -638
  198. data/src/jpeg-7/jmemdosa.asm +0 -379
  199. data/src/jpeg-7/jmemmac.c +0 -289
  200. data/src/jpeg-7/jmemmgr.c +0 -1118
  201. data/src/jpeg-7/jmemname.c +0 -276
  202. data/src/jpeg-7/jmemnobs.c +0 -109
  203. data/src/jpeg-7/jmemsys.h +0 -198
  204. data/src/jpeg-7/jmorecfg.h +0 -369
  205. data/src/jpeg-7/jpegint.h +0 -395
  206. data/src/jpeg-7/jpeglib.h +0 -1135
  207. data/src/jpeg-7/jpegtran.1 +0 -272
  208. data/src/jpeg-7/jpegtran.c +0 -546
  209. data/src/jpeg-7/jquant1.c +0 -856
  210. data/src/jpeg-7/jquant2.c +0 -1310
  211. data/src/jpeg-7/jutils.c +0 -179
  212. data/src/jpeg-7/jversion.h +0 -14
  213. data/src/jpeg-7/libjpeg.map +0 -4
  214. data/src/jpeg-7/libjpeg.txt +0 -3067
  215. data/src/jpeg-7/ltmain.sh +0 -8406
  216. data/src/jpeg-7/makcjpeg.st +0 -36
  217. data/src/jpeg-7/makdjpeg.st +0 -36
  218. data/src/jpeg-7/makeadsw.vc6 +0 -77
  219. data/src/jpeg-7/makeasln.vc9 +0 -33
  220. data/src/jpeg-7/makecdep.vc6 +0 -82
  221. data/src/jpeg-7/makecdsp.vc6 +0 -130
  222. data/src/jpeg-7/makecmak.vc6 +0 -159
  223. data/src/jpeg-7/makecvcp.vc9 +0 -186
  224. data/src/jpeg-7/makeddep.vc6 +0 -82
  225. data/src/jpeg-7/makeddsp.vc6 +0 -130
  226. data/src/jpeg-7/makedmak.vc6 +0 -159
  227. data/src/jpeg-7/makedvcp.vc9 +0 -186
  228. data/src/jpeg-7/makefile.ansi +0 -220
  229. data/src/jpeg-7/makefile.bcc +0 -291
  230. data/src/jpeg-7/makefile.dj +0 -226
  231. data/src/jpeg-7/makefile.manx +0 -220
  232. data/src/jpeg-7/makefile.mc6 +0 -255
  233. data/src/jpeg-7/makefile.mms +0 -224
  234. data/src/jpeg-7/makefile.sas +0 -258
  235. data/src/jpeg-7/makefile.unix +0 -234
  236. data/src/jpeg-7/makefile.vc +0 -217
  237. data/src/jpeg-7/makefile.vms +0 -142
  238. data/src/jpeg-7/makefile.wat +0 -239
  239. data/src/jpeg-7/makejdep.vc6 +0 -423
  240. data/src/jpeg-7/makejdsp.vc6 +0 -285
  241. data/src/jpeg-7/makejdsw.vc6 +0 -29
  242. data/src/jpeg-7/makejmak.vc6 +0 -425
  243. data/src/jpeg-7/makejsln.vc9 +0 -17
  244. data/src/jpeg-7/makejvcp.vc9 +0 -328
  245. data/src/jpeg-7/makeproj.mac +0 -213
  246. data/src/jpeg-7/makerdep.vc6 +0 -6
  247. data/src/jpeg-7/makerdsp.vc6 +0 -78
  248. data/src/jpeg-7/makermak.vc6 +0 -110
  249. data/src/jpeg-7/makervcp.vc9 +0 -133
  250. data/src/jpeg-7/maketdep.vc6 +0 -43
  251. data/src/jpeg-7/maketdsp.vc6 +0 -122
  252. data/src/jpeg-7/maketmak.vc6 +0 -131
  253. data/src/jpeg-7/maketvcp.vc9 +0 -178
  254. data/src/jpeg-7/makewdep.vc6 +0 -6
  255. data/src/jpeg-7/makewdsp.vc6 +0 -78
  256. data/src/jpeg-7/makewmak.vc6 +0 -110
  257. data/src/jpeg-7/makewvcp.vc9 +0 -133
  258. data/src/jpeg-7/makljpeg.st +0 -68
  259. data/src/jpeg-7/maktjpeg.st +0 -30
  260. data/src/jpeg-7/makvms.opt +0 -4
  261. data/src/jpeg-7/missing +0 -376
  262. data/src/jpeg-7/rdbmp.c +0 -439
  263. data/src/jpeg-7/rdcolmap.c +0 -253
  264. data/src/jpeg-7/rdgif.c +0 -38
  265. data/src/jpeg-7/rdjpgcom.1 +0 -63
  266. data/src/jpeg-7/rdjpgcom.c +0 -515
  267. data/src/jpeg-7/rdppm.c +0 -459
  268. data/src/jpeg-7/rdrle.c +0 -387
  269. data/src/jpeg-7/rdswitch.c +0 -365
  270. data/src/jpeg-7/rdtarga.c +0 -500
  271. data/src/jpeg-7/structure.txt +0 -945
  272. data/src/jpeg-7/testimg.bmp +0 -0
  273. data/src/jpeg-7/testimg.jpg +0 -0
  274. data/src/jpeg-7/testimg.ppm +0 -4
  275. data/src/jpeg-7/testimgp.jpg +0 -0
  276. data/src/jpeg-7/testorig.jpg +0 -0
  277. data/src/jpeg-7/testprog.jpg +0 -0
  278. data/src/jpeg-7/transupp.c +0 -1533
  279. data/src/jpeg-7/transupp.h +0 -205
  280. data/src/jpeg-7/usage.txt +0 -605
  281. data/src/jpeg-7/wizard.txt +0 -211
  282. data/src/jpeg-7/wrbmp.c +0 -442
  283. data/src/jpeg-7/wrgif.c +0 -399
  284. data/src/jpeg-7/wrjpgcom.1 +0 -103
  285. data/src/jpeg-7/wrjpgcom.c +0 -583
  286. data/src/jpeg-7/wrppm.c +0 -269
  287. data/src/jpeg-7/wrrle.c +0 -305
  288. data/src/jpeg-7/wrtarga.c +0 -253
@@ -1,132 +0,0 @@
1
- #
2
- # Makefile for ./src path, used by configure
3
- #
4
-
5
- EXEEXT = @EXEEXT@
6
- PROGRAM = gocr$(EXEEXT)
7
- # lib removed for simplification (v0.46)
8
- # but Igor from OSRA an optical chemical structure recognition software
9
- # wants it (v0.47 Mar09)
10
- PGMASCLIB = Pgm2asc
11
- #LIBPGMASCLIB = lib$(PGMASCLIB).a
12
- # ToDo: need a better pgm2asc.h for lib users
13
- #INCLUDEFILES = gocr.h
14
- # avoid german compiler messages
15
- LANG=C
16
-
17
- LIBOBJS=pgm2asc.o \
18
- box.o \
19
- database.o \
20
- detect.o \
21
- barcode.o \
22
- lines.o \
23
- list.o \
24
- ocr0.o \
25
- ocr0n.o \
26
- ocr1.o \
27
- otsu.o \
28
- output.o \
29
- pixel.o \
30
- unicode.o \
31
- remove.o \
32
- pnm.o \
33
- pcx.o \
34
- progress.o \
35
- job.o
36
-
37
- # these two lines are for cross-compiling, not tested
38
- #srcdir = @srcdir@
39
- #VPATH = @srcdir@
40
- bindir = @bindir@
41
- # lib removed for simplification
42
- #libdir = @libdir@
43
- #includedir = @includedir@
44
-
45
- CC=@CC@
46
- # lib removed for simplification
47
- # ar,ranlib detection removed from configure (simplicity)
48
- # but needed by some developpers (linux only) for for (make libs)
49
- # RANLIB = @RANLIB@
50
- # AR = @AR@
51
- RANLIB = ranlib
52
- AR = ar
53
- INSTALL=@INSTALL@
54
- # shell is needed for OS/2 to let if test -r $(PROGRAM) ... work
55
- SHELL=@SHELL@
56
-
57
- DEFS=@DEFS@
58
- CPPFLAGS=@CPPFLAGS@
59
- # to see the config.h
60
- CFLAGS=@CFLAGS@ $(CPPFLAGS) -I../include $(DEFS)
61
- LDFLAGS=@LDFLAGS@
62
- LIBS=@LIBS@
63
- DESTDIR=@prefix@
64
-
65
- .SUFFIXES: .s .o .c .h
66
- # do not look for files if help (etc) is given
67
- .PHONY : doc clean install libs default
68
-
69
- .c.o: gocr.h pgm2asc.h ../include/config.h
70
- $(CC) $(CFLAGS) -c -o $*.o $<
71
-
72
- default: all
73
-
74
- # all: $(PROGRAM) lib$(PGMASCLIB).a
75
- all: $(PROGRAM)
76
-
77
- gocr.o: gocr.h Makefile ../include/version.h
78
-
79
- .c.h:
80
-
81
- #$(PROGRAM): lib$(PGMASCLIB).a gocr.o
82
- $(PROGRAM): $(LIBOBJS) gocr.o
83
- # make it conform to ld --as-needed
84
- #$(CC) -o $@ $(LDFLAGS) gocr.o ./lib$(PGMASCLIB).a $(LIBS)
85
- $(CC) -o $@ $(LDFLAGS) gocr.o $(LIBOBJS) $(LIBS)
86
- if test -r $(PROGRAM); then cp $@ ../bin; fi
87
-
88
- libs: lib$(PGMASCLIB).a lib$(PGMASCLIB).@PACKAGE_VERSION@.so
89
-
90
- lib$(PGMASCLIB).@PACKAGE_VERSION@.so: $(LIBOBJS)
91
- $(CC) -fPIC -shared -Wl,-h$@ -o $@ $(LIBOBJS)
92
- -ln -s $@ lib$(PGMASCLIB).so
93
-
94
- lib$(PGMASCLIB).a: $(LIBOBJS)
95
- # -rm -f $@
96
- $(AR) cru $@ $(LIBOBJS)
97
- $(RANLIB) $@
98
-
99
- $(LIBOBJS): Makefile
100
-
101
- # PHONY = don't look at file clean, -rm = start rm and ignore errors
102
- .PHONY : clean proper install uninstall
103
- install: all
104
- #$(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
105
- $(INSTALL) -d $(DESTDIR)$(bindir)
106
- $(INSTALL) ../bin/$(PROGRAM) $(DESTDIR)$(bindir)
107
- $(INSTALL) ../bin/gocr.tcl $(DESTDIR)$(bindir) # better X11/bin?
108
- if test -f lib$(PGMASCLIB).a; then\
109
- $(INSTALL) lib$(PGMASCLIB).a $(DESTDIR)$(libdir);\
110
- $(INSTALL) lib$(PGMASCLIB).@PACKAGE_VERSION@.so $(DESTDIR)$(libdir);\
111
- $(INSTALL) lib$(PGMASCLIB).so $(DESTDIR)$(libdir);\
112
- fi
113
- # ToDo: not sure that the link will be installed correctly
114
- #$(INSTALL) $(INCLUDEFILES) $(DESTDIR)$(includedir)
115
-
116
- # directories are not removed
117
- uninstall:
118
- -rm -f $(DESTDIR)$(bindir)/$(PROGRAM)
119
- -rm -f $(DESTDIR)$(bindir)/gocr.tcl
120
- -rm -f $(DESTDIR)$(libdir)/lib$(PGMASCLIB).a
121
- -rm -f $(DESTDIR)$(libdir)/lib$(PGMASCLIB).@PACKAGE_VERSION@.so
122
- -rm -f $(DESTDIR)$(libdir)/lib$(PGMASCLIB).so
123
- # ToDo: set to old version.so ?
124
- #for X in $(INCLUDEFILES); do rm -f $(DESTDIR)$(includedir)/$$X; done
125
-
126
- clean:
127
- -rm -f *.o *~
128
-
129
- proper: clean
130
- -rm -f gocr libPgm2asc.*
131
- -rm -f gocr
132
-
@@ -1,31 +0,0 @@
1
- /*
2
- this file was suggested by Uffe Holst Jun05,2000
3
- to compile gocr using SAS/C under AmigaOS
4
-
5
- uhc@post6.tele.dk
6
-
7
- SAS/C propably does not support ANSI C++, therefore this changes
8
-
9
- I am a little bit confused about using declaration and
10
- macro definition of abs(). I think that should not be necessary.
11
- Tell me, if you have an Amiga and you can give answer
12
- to the following questions.
13
-
14
- Joerg Schulenburg, see README for EMAIL-address
15
-
16
- */
17
-
18
- #ifdef _AMIGA
19
- #ifdef __SASC
20
- #if 0
21
- #include <string.h> /* may be this can be removed ??? */
22
- #include <stdlib.h> /* may be this can be removed ??? */
23
- extern int abs(int); /* may be this can be removed ??? */
24
- #endif
25
- #ifndef abs
26
- #define abs(i) ((i) < 0 ? -(i) : (i))
27
- #endif
28
- #endif
29
- #endif
30
-
31
-
@@ -1,846 +0,0 @@
1
- /*
2
- This is a Optical-Character-Recognition program
3
- Copyright (C) 2000-2009 Joerg Schulenburg
4
-
5
- This program is free software; you can redistribute it and/or
6
- modify it under the terms of the GNU General Public License
7
- as published by the Free Software Foundation; either version 2
8
- of the License, or (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License
16
- along with this program; if not, write to the Free Software
17
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
-
19
- see README for email address
20
-
21
- ToDo:
22
- - transform special xml bar code symbols (<>&) to xml symbols (&lt;&gt;&amp;)
23
-
24
- */
25
-
26
- #include <stdlib.h>
27
- #include <stdio.h>
28
- #include <string.h>
29
- /* #include <math.h> -- we do not want unnecessary dependencies */
30
- #include "pgm2asc.h"
31
- #include "gocr.h"
32
- #include "pnm.h"
33
-
34
- #ifndef DO_DEBUG /* can be defined outside (configure --with-debug) */
35
- #define DO_DEBUG 0 /* 0 is the default */
36
- #endif
37
-
38
- #undef g_debug
39
- #if DO_DEBUG
40
- # define g_debug(a) if (JOB->cfg.verbose&1) { a }
41
- #else
42
- # define g_debug(a)
43
- #endif
44
-
45
- /*
46
- detect barcode and add a XML-string to the box (obj-pointer, ToDo)
47
- ToDo: barcode-output stderr->stdout
48
- */
49
-
50
- double sqr(double x) { return(x*x); }
51
-
52
- /* ----------------------------- code128 ---------------------------- *
53
- * "BSBSBS", B=Bar, S=Space, better using 2*6=12bit-integer? */
54
- #define Num128 107
55
- const char *code128[Num128+1]={ /* can be generated by an algorithm? */
56
- /* 00 */"212222","222122","222221","121223","121322","131222","122213","122312",
57
- /* 08 */"132212","221213","221312","231212","112232","122132","122231","113222",
58
- /* 16 */"123122","123221","223211","221132","221231","213212","223112","312131",
59
- /* 24 */"311222","321122","321221","312212","322112","322211","212123","212321",
60
- /* 32 */"232121","111323","131123","131321","112313","132113","132311","211313",
61
- /* 40 */"231113","231311","112133","112331","132131","113123","113321","133121",
62
- /* 48 */"313121","211331","231131","213113","213311","213131","311123","311321",
63
- /* 56 */"331121","312113","312311","332111","314111","221411","431111","111224",
64
- /* 64 */"111422","121124","121421","141122","141221","112214","112412","122114",
65
- /* 72 */"122411","142112","142211","241211","221114","413111","241112","134111",
66
- /* 80 */"111242","121142","121241","114212","124112","124211","411212","421112",
67
- /* 88 */"421211","212141","214121","412121","111143","111341","131141","114113",
68
- /* 96 */"114311","411113","411311","113141","114131","311141","411131","211412",
69
- /*104 */"211214","211232","2331112","???"};
70
-
71
- /*
72
- code128: see code128.tex by Petr Olsak (108 codes)
73
- quiet_zone: size=10 (before and after code128)
74
- num_bars=3*(start+chars[N]+crc+stop)+1
75
- B=bar S=space char=BSBSBS (size=11), stop=BSBSBSB (size=11+2)
76
- Width: Bar,Space=1,[2,3,4] char=11 code=11*(N+3)+2 sumB=even,sumS=odd
77
- startA="211412"=103 startB="211214"=104 startC="211232"=105(2dec_digits)
78
- mode/code 0..95 96 97 98 99 100 101 102 103 104 105 106
79
- 1=A x20-x5f,0-x20 F3 F2 uB mC mB F4 F1 ^A ^B ^C $
80
- 2=B x20-x7f F3 F2 uA mC F4 mA F1 ^A ^B ^C $
81
- 3=C "00"-"95" "96" "97" "98" "99" mB mA F1 ^A ^B ^C $
82
- uA,uB: switch mode for next char, mA,mB: switch mode permanently
83
- crc=(start+1*char1+2*char2+3*char3+...+N*charN) mod 103
84
- $=stop="2331112"=106 (4bars, with=13) => start/end==211
85
- return num of chars or string
86
-
87
- size B+W even-variants odd-variants num_codes
88
- 11 = 8+3 = (1+3+4,2+2+4,2+3+3)+(1+1+1) => (6+3+3)*(1) = 12
89
- = 6+5 = (1+1+4,1+2+3,2+2+2)+(1+1+3,1+2+2) => (3+6+1)*(3+3) = 60
90
- = 4+7 = (1+1+2)+(1+2+4,1+3+3,2+2+3) => (3)*(6+3+3) = 36
91
- sum = 108
92
- */
93
- /* example: barcode -E -e 128c -b 1434600120000884 >a.eps */
94
- /* example: barcode -E -e 128b -b 14Test41 >a.eps */
95
- /* example: barcode -E -e 128raw -b 105 17 14 30 >a.eps */
96
-
97
- char *decode_code128(int *wb, int num_bars){
98
- int i, w, i1, i2, i3=0, i4, i5=0, crc, mode=1;
99
- double dww, dw, err, min_err; char cc, *buf;
100
- char *result=NULL; /* malloc and store the result */
101
-
102
- for(w=i=0;i<2*num_bars-1;i++) w+=wb[i]; /* summ all bars and spaces */
103
-
104
- /* test code128 characteristics, ToDo: look for correct start/stop 211 seq. */
105
- if ((num_bars-1)%3!=0 || num_bars<10 || w<11*(num_bars-1)/3+2)
106
- return 0;
107
- g_debug(fprintf(stderr," code128 b%d s%d b%d\n",wb[0],wb[1],wb[2]);)
108
- if (3*wb[0]<4* wb[1]
109
- || 3*wb[0]<4* wb[2]
110
- || 4*wb[0]<3*(wb[1]+wb[2])
111
- || 3*wb[0]>4*(wb[1]+wb[2])) return 0; /* 211 */
112
- dw=3.0*w/((num_bars-1)*11+6);
113
- /* get enough memory for all digits in longest mode C */
114
- buf =(char *) malloc( (num_bars-7)/3*2+1); if (!buf) return result;
115
- result=(char *) malloc(256+(num_bars-7)/3*2+1);
116
-
117
- dww=crc=0;
118
- for(i4=i1=0;i1<(num_bars-1)/3;i1++) {
119
- for(min_err=1e8,i3=Num128,i5=0;i5<Num128;i5++){ /* get best fit */
120
- for(err=i2=0;i2<6;i2++) err+=sqr(code128[i5][i2]-'0'-wb[i1*6+i2]/dw);
121
- if (err<min_err) { min_err=err; i3=i5; }
122
- } dww+=min_err;
123
- g_debug(fprintf(stderr,"\n %7s %3d err=%.3f ",code128[i3],i3,min_err);)
124
- if(i3<Num128){ /* valid symbol */
125
- if(i1==0){ if (i3>102 && i3<106) mode=i3-103+1; crc=i3; } /* start */
126
- if(i1>0 && i1<(num_bars-1)/3-2){
127
- crc+=i3*(i1); cc=0; /* first * 1 + second * 2 + third * 3 ... */
128
- i5=((mode>3)?mode>>2:mode&3); mode&=3; /* mode can be modified now */
129
- switch (i5) { /* mode=1..3=modeA..modeC */
130
- case 1: if (i3>=64 && i3<96) cc=i3-64; /* modeA: x20-x5f,0-x20 */
131
- else cc=i3+32;
132
- if (i3==101) mode=1; /* switch to mode A */
133
- if (i3== 99) mode=3; /* switch to mode C */
134
- if (i3== 98) mode|=2<<2; /* shift to mode B */
135
- break;
136
- case 2: cc=i3+32; /* modeB: x20-x7f */
137
- if (i3==100) mode=2; /* switch to mode B */
138
- if (i3== 99) mode=3; /* switch to mode C */
139
- if (i3== 98) mode|=1<<2; /* shift to mode A */
140
- break;
141
- case 3:
142
- if (i3==101) mode=1; /* switch to mode A */
143
- if (i3==100) mode=2; /* switch to mode B */
144
- }
145
- if (i5==3) { buf[i4]='0'+i3/10; i4++;
146
- buf[i4]='0'+i3%10; i4++; } /* modeC: two digits */
147
- else {
148
- if (cc>=0x20 && i3<=0x7f) { buf[i4]=cc; i4++; } /* modeA+B: one digit */
149
- if (cc>=0 && cc< 0x20) { buf[i4]='^'; i4++;
150
- buf[i4]=cc+'@'; i4++; }
151
- }
152
- }
153
- if(i1==(num_bars-1)/3-2){ crc=(crc+103-i3)%103; }
154
- if(i1==(num_bars-1)/3-1){ if(i3!=106) i3=-1; } /* stop code */
155
- mode &= 3; /* remove shift */
156
- }
157
- else fprintf(stderr," %s=%02d? ",buf,i5);
158
- }
159
- buf[i4]=0; /* end of string */
160
- if (result)
161
- sprintf(result,"<barcode type=\"128\" chars=\"%d\" code=\"%s\" "
162
- "crc=\"%d\" error=\"%.3f\" />",
163
- i4,buf,crc,dww/((num_bars-1)));
164
- free(buf);
165
- return result;
166
- }
167
-
168
- /* -------------------------------------------------------------------- UPC
169
- EAN 13 (UPC,(1+6+1+6+1)*2bars,size=3+6*7+5+6*7+3=95)
170
- EAN 8 (UPC,(1+4+1+4+1)*2bars,size=3+4*7+5+4*7+3=67)
171
- UPC: (10 codes)
172
- BSB SBSB^n SBSBS BSBS^n BSB
173
- bsb ...... sbsbs ...... bsb
174
- 111 ...... 11111 ...... 111
175
- num_bars=2*(2*6+3) middle=SBSBS=11111 right/left=BSB=111="101"
176
- char: left=SBSB right=BSBS (size=7) only_dec_digits
177
- SS+BB = (S+S) + (B+B) => BB:SS = 5:2 or 3:4
178
- size ev+odd even + odd => variants
179
- 7 = 2 + 5 = (1+1) + (1+4,2+3) => (1)*(2+2) = 4 codes
180
- = 4 + 3 = (1+3,2+2) + (1+3) => (2+1)*(2) = 6 codes += 10 codes
181
- ToDo: make it more robust
182
- - return error as mean deviation
183
- * -------------------------------------------------------------------- */
184
- /* example: barcode -E -e upc -b 12345678901 >a.eps # ok */
185
- /* example: barcode -E -e ean -b 123456789012 >a.eps # ok */
186
- #define NumUPC 20
187
- const char *codeUPC[NumUPC+1]={ /* 0..9, first n = SBSB, last n = BSBS */
188
- "3211","2221","2122","1411","1132", /* 0,1,2,3,4 normal (+0bit) */
189
- "1231","1114","1312","1213","3112", /* 5,6,7,8,9 */
190
- "1123","1222","2212","1141","2311", /* 0,1,2,3,4 mirrored (+1bit) */
191
- "1321","4111","2131","3121","2113", /* 5,6,7,8,9 */
192
- "????"}; /* not found */
193
-
194
- char *decode_UPC(int *wb, int num_bars){ /* ToDo: char *dest, int len */
195
- int i, w, i1, i2, i3, i4, i5, crc, mirrored, ean;
196
- double err, min_err, dw, dww=0.0; char digit;
197
- char *result=NULL, *buf=NULL; /* malloc and store the result */
198
- for(w=i=0;i<2*num_bars-1;i++) w+=wb[i];
199
-
200
- dw=2.0*w/((num_bars-6)*7+2*11); /* or min(wb[]) */
201
- crc=0;
202
- if ((num_bars)%2!=0 || num_bars<10 || w<7*(num_bars-6)/2+11
203
- || ((num_bars-6)/2)%2!=0) return 0; /* should be balanced */
204
- /* check front BSB, middle SBSBS and end BSB */
205
- dww=0;
206
- for (i=0;i<3;i++) { dww=sqr(wb[i ]/dw-1); if (dww>0.4) return 0; }
207
- for (i=0;i<5;i++) { dww=sqr(wb[i+ num_bars-3]/dw-1); if (dww>0.4) return 0; }
208
- for (i=0;i<3;i++) { dww=sqr(wb[i+2*num_bars-4]/dw-1); if (dww>0.4) return 0; }
209
- buf =(char *)malloc( (num_bars-6)/2+1); if (!buf) return result;
210
- result=(char *)malloc(256+(num_bars-6)/2+1);
211
-
212
- for(ean=i5=0,i1=3;i1<2*num_bars-4;i1+=4) { /* each digit (2bars+2spaces) */
213
- if (i1==num_bars-3) { i1++; continue; } /* skip middle sync SBSBS */
214
- for (i4=NumUPC,mirrored=0,digit='?',min_err=16e8,i2=0;i2<NumUPC;i2++) {
215
- for (err=0,i3=0;i3<4;i3++) err+=sqr(codeUPC[i2][i3]-'0'-wb[i1+i3]/dw);
216
- if (err<min_err) { min_err=err; i4=i2; digit='0'+i2%10; mirrored=i2/10; }
217
- } dww+=min_err; crc+=(digit-'0')*((i5&1)?1:3); /* even*3+odd, last char is even */
218
- buf[i5++]=digit; if (i5<7) ean=(ean<<1)|mirrored;
219
- /* ToDo: error as deviation wb from ideal */
220
- g_debug(fprintf(stderr,"\nDBG: UPC digit=%c mirrored=%d err=%.3f err_m=%.3f ",
221
- digit,mirrored,min_err/4,dww/(i5*4));)
222
- }
223
- /* EAN has a 13th leading digit build by 3 of 6 mirorred digits */
224
- if (ean & 0x20) ean^=0x3f; /* UPC-E mirrored 1xxxxx => 0yyyyy */
225
- switch (ean) {
226
- case 11: ean=1; break;
227
- case 13: ean=2; break;
228
- case 14: ean=3; break;
229
- case 19: ean=4; break;
230
- case 25: ean=5; break;
231
- case 28: ean=6; break;
232
- case 21: ean=7; break;
233
- case 22: ean=8; break;
234
- case 26: ean=9; break;
235
- default: ean=0; /* no or invalid EAN digit or UPC-extension */
236
- } crc+=ean*1;
237
- /* ToDo: fix possible buffer OVL, complement crc */
238
- buf[i5]=0;
239
- if (result)
240
- sprintf(result,"<barcode type=\"UPC\" chars=\"%d\" code=\"%d%s\" "
241
- "crc=\"%d\" error=\"%.3f\" />",
242
- i5+1,ean,buf,(10-crc%10)%10,dww/((num_bars-6)*2));
243
- free(buf);
244
- return result;
245
- }
246
-
247
- /* EAN/UPC add-on is either 2 or 5 digits. It always starts with a
248
- * guard bar BSB, followed by ([digit + SB] * (N-1)) + digit. Digit is
249
- * SBSB. Two digit add-on's have 7 bars, and 5 digit add ons have 16.
250
- */
251
- char *decode_UPC_addon(int *wb, int num_bars){ /* ToDo: char *dest, int len */
252
- int i, w, i1, i2, i3, i4, i5, digits=num_bars/3;
253
- double err, min_err, dw, dww=0.0; char digit;
254
- char *result=NULL, *buf=NULL; /* malloc and store the result */
255
- if (num_bars!=7 && num_bars!=16)
256
- return 0;
257
- for(w=i=0;i<2*num_bars-1;i++) w+=wb[i];
258
-
259
- dw=1.0*w/(digits*7+4 + (digits-1)*2);
260
- /* check front BSB, and delineators SB */
261
- dww=0;
262
- for (i=0;i<2;i++) { dww=sqr(wb[i]/dw-1); if (dww>0.4) return 0; }
263
- dww=sqr(wb[i]*0.5/dw-1); if (dww>0.4) return 0;
264
- for (i=1;i<digits; i++) {
265
- for (i1=0; i1<2; i1++) {
266
- dww = sqr(wb[i*6 + 1 + i1]/dw-1);
267
- if (dww > 0.4) return 0;
268
- }
269
- }
270
- buf =(char *)malloc( digits+1); if (!buf) return result;
271
- result=(char *)malloc(256+digits+1);
272
-
273
- for(i5=0,i1=3;i1<2*num_bars-1;i1+=6) { /* each digit (2bars+2spaces) */
274
- for (i4=NumUPC,digit='?',min_err=16e8,i2=0;i2<NumUPC;i2++) {
275
- for (err=0,i3=0;i3<4;i3++) err+=sqr(codeUPC[i2][i3]-'0'-wb[i1+i3]/dw);
276
- if (err<min_err) { min_err=err; i4=i2; digit='0'+i2%10; }
277
- }
278
- dww+=min_err;
279
- buf[i5++]=digit;
280
- /* ToDo: error as deviation wb from ideal */
281
- g_debug(fprintf(stderr,"\nDBG: UPC digit=%c err=%.3f err_m=%.3f ",
282
- digit, min_err/4, dww/(i5*4));)
283
- }
284
- buf[i5]=0;
285
- if (result)
286
- sprintf(result, "<barcode type=\"UPC_addon\" chars=\"%d\" code=\"%s\" "
287
- "error=\"%.3f\" />",
288
- i5, buf, dww/((num_bars-6)*2));
289
- free(buf);
290
- return result;
291
- }
292
-
293
-
294
- /* --------------------------------------------------------- *
295
- * code 3 of 9, 3 thick of 9 bars
296
- * BSBSBSBSB<S> size=7+3*aw aw=2(3), sumS/sumB=2/1?
297
- * two widths: size=1 or size=2or3, digit_width=13(16)
298
- * 5 bars and 4(+1) spaces per digit, last space is not used
299
- * with 2 (or 0) wide bars, 1 (or 3) wide spaces per digit
300
- * => 3 of 9 => max=9*8*7=504
301
- * evenBB=(0of5)+(2of5) oddSS=(1of4)+(3of4) max=44
302
- * ToDo: better code -...-.-.. as 046 or 083 (even,even,odd)
303
- */
304
- #define Num39 (40+4) /* (3of9)=(2of5)(1of4)+(0of5)(3of4), (2of5)(.-..)=0..9 */
305
- const char *code39= /* rearranged to BBBBBSSSS<S> (bars,spaces) */
306
- "0..--..-.."
307
- "1-...-.-..""2.-..-.-..""3--....-..""4..-.-.-..""5-.-...-.."
308
- "6.--...-..""7...--.-..""8-..-..-..""9.-.-..-.."
309
- "A-...-..-.""B.-..-..-.""C--.....-.""D..-.-..-.""E-.-....-."
310
- "F.--....-.""G...--..-.""H-..-...-.""I.-.-...-.""J..--...-."
311
- "K-...-...-""L.-..-...-""M--......-""N..-.-...-""O-.-.....-"
312
- "P.--.....-""Q...--...-""R-..-....-""S.-.-....-""T..--....-"
313
- "U-...--...""V.-..--...""W--...-...""X..-.--...""Y-.-..-..."
314
- "Z.--..-...""-...---..."".-..-.-..."" .-.-.-...""*..--.-..."
315
- /* (0of5)(3of4)=(.....)(3of4) store only 3of4? */
316
- "$.....---.""/.....--.-""+.....-.--""%......---"
317
- "?xxxxxxxxx";
318
-
319
- /* example: barcode -E -e 39 -b 123abc | gs -sDEVICE=pnggray -r100 */
320
-
321
- /* return index[] according to sorted values[], big first */
322
- void sort(int *value, int *idx, int len){
323
- int i,j;
324
- for (j=0;j<len;j++) idx[j]=j; /* initialize */
325
- for(i=1;i;) { /* bubble sort, len...len^2 steps */
326
- for(i=j=0;j<len-1;j++) if(value[idx[j]]<value[idx[j+1]]) {
327
- i=idx[j]; idx[j]=idx[j+1]; idx[j+1]=i; i=1;
328
- }
329
- }
330
- }
331
-
332
- char *decode_39(int *wb, int num_bars){ /* ToDo: char *dest, int len */
333
- int i, w, i1, i3, i5, crc, idx[10];
334
- double dw,dww,err; char *buf;
335
- char *result=NULL; /* malloc and store the result */
336
-
337
- /* check for multiple of 5 bars and minimum start+1char+stop=15 bars */
338
- if ((num_bars)%5!=0 || num_bars<15) return 0;
339
- for(w=i=0; i<2*num_bars-1;i++ ) w+=wb[i]; /* summ width to w */
340
- dw=w*1.0/(16*(num_bars/5)); /* threshold = 1.5..2 */
341
- /* whats best and most rigorosely for dw=threshold_width?
342
- * - (1.5..2)*mean_width of every 5th space
343
- * - (1.5..2)*summ(5bars+5spaces)/(13..16)
344
- * - 3/4*summ(three thickest)/3
345
- */
346
- dww=crc=0; /* error and checksum (not supported yet) */
347
- #if 0 /* should we exclude any non-standard code39? */
348
- /* check for correct start and end symbol * or NwNnWnWnN Narrow+Wide */
349
- i=2*num_bars-2;
350
- if (wb[ 0]>dw*2 || wb[ 1]<=dw*2 || wb[ 2]> dw*2) return 0;
351
- if (wb[i-0]>dw*2 || wb[i-1]> dw*2 || wb[i-2]<=dw*2) return 0;
352
- #endif
353
- g_debug(fprintf(stderr," code39 base=%.3f chars=%2d\n ",dw,(num_bars)/5);)
354
- buf =(char *)malloc( 1+(num_bars)/5); if (!buf) return result;
355
- result=(char *)malloc(256+(num_bars)/5);
356
-
357
- for(i5=i1=0;i1<2*num_bars-3;i1+=10) {
358
- /* ToDo: looking for three widest bars/gaps, 0 or 2 bars, 1 or 3 spaces */
359
- sort(wb+i1,idx,9);
360
- for(err=0,i3=3;i3<9;i3++) // estimate error ??
361
- err+=sqr(wb[i1+idx[i3]]/dw-1.0); /* narrow=1, wide=2..3 */
362
- dww+=err;
363
- for(i3=0;i3<Num39;i3++)
364
- if (code39[10*i3+1+(idx[0]%2)*5+idx[0]/2]=='-'
365
- && code39[10*i3+1+(idx[1]%2)*5+idx[1]/2]=='-'
366
- && code39[10*i3+1+(idx[2]%2)*5+idx[2]/2]=='-') break;
367
- if (i5>0 && i5<num_bars/5-2) crc+=i3;
368
- buf[i5++]=code39[10*i3];
369
-
370
- /* ToDo: check if wee have even number of black bars within 3 biggest */
371
- g_debug(for(i3=0;i3<9;i3++)fprintf(stderr,"%02d ",wb[i1+i3]);
372
- fprintf(stderr," posWide=%d,%d,%d %c err=%.3f\n ",
373
- idx[0],idx[1],idx[2],buf[i5-1],err/6);)
374
- { int num_ws=0; // Jul09 ~codabar
375
- if (idx[0]&1) num_ws++;
376
- if (idx[1]&1) num_ws++;
377
- if (idx[2]&1) num_ws++;
378
- if ((num_ws&1)==0) { // num wide spaces must be 1 or 3
379
- free (buf); free(result);
380
- g_debug(fprintf(stderr," num wide spaces = %d, abort code39\n", num_ws);)
381
- return 0;
382
- }
383
- }
384
- }
385
- buf[i5]=0;
386
- if (result)
387
- sprintf(result,"<barcode type=\"39\" chars=\"%d\" code=\"%s\" "
388
- "crc=\"%c\" error=\"%.3f\" />",
389
- i5,buf,code39[(crc%44)*10],dww/((num_bars/5)*6));
390
- free(buf);
391
- return result;
392
- }
393
-
394
- /* code interleaved 2 of 5 numbers-only (10 bars+spaces = 2 decimal digits)
395
- B B B B B <= digit1 bars=1,3,5,...
396
- S S S S S <= digit2 spaces=2,4,6,...
397
- 1122447700 <= weight digit=sum(bit*weight)%11 (except 7+4=11 means 0)
398
- N = narrow bar, W = wide bar, n = narrow space, w = wide space
399
- "NnNn"+interleaved+"WnN" (odd num W, even num w)
400
- 18 digits/inch
401
- see http://www.barcode-1.net/i25code.html (Jun 2009)
402
- minN=0.19mm=0.0075inch
403
- sizeN>0.02inch: sizeW=2..3*sizeN (but constant)
404
- sizeN<0.02inch: sizeW=2.2..3*sizeN
405
- quite zones 10*sizeN or 0.25inch
406
- heigh=max(0.15*symbol_length,0.25inch)
407
- Len = (numChars*(2*(sizeW/sizeN)+3) + 6 + (sizeW/sizeN)) * sizeN
408
- */
409
- #define Num25 10
410
- const char *code25= /* is the code sorted randomly? */
411
- "1-...-2.-..-3--...4..-.-5-.-..6.--..7...--8-..-.9.-.-.0..--.";
412
-
413
- /* example: barcode -E -e i25 -b 123456 >a.eps */
414
-
415
- /*
416
- add i25, patch by: Chris Lee, 13 Jul 2009
417
- ToDo: check correctness
418
- */
419
- char *decode_i25(int *wb, int num_bars){ /* ToDo: char *dest, int len */
420
- int i, w, i1, i3, i5, crc, idx[7], pos;
421
- double dw, dww, err; char *buf;
422
- char *result=NULL; /* malloc and store the result */
423
-
424
- int *wb_temp;
425
- int *wb_check;
426
- int code_chars;
427
-
428
- if ((num_bars)%5!=4) return 0; /* chars*5bars + 4 start/stop bars */
429
- code_chars = ((num_bars - 4) / 5) * 2;
430
- // dw=w*1.0/(9*(num_bars/3)); /* threshold = 1.5..2 */
431
-
432
- wb_temp = (int *)malloc((code_chars * 5)*sizeof(int)); if (!wb_temp) { return NULL; }
433
- wb_check = (int *)malloc( 7 *sizeof(int)); if (!wb_check) { return NULL; }
434
-
435
- for (i=0; i<(code_chars * 5)+7; i++) {
436
- if (i<4) { wb_check[i] = wb[i]; } /* start sequence NnNn... */
437
- else if (i > ((code_chars*5)+3)) { /* end sequence ...WnN */
438
- wb_check[(int)(i-(code_chars*5))] = wb[i]; }
439
- else {
440
- pos = i - 4;
441
- /* reinterleave 0,5,1,6,2,7,3,8,4,9,... to 0,1,2,3,4,5,6,7,8,9,... */
442
- // pos = (int)(10*(int)(pos/10) + 1.0*(pos%10)/2.0 + 4.5*(pos%2));
443
- pos = 10*(pos/10) + (pos%10)/2 + 5*(pos&1);
444
- wb_temp[pos] = wb[i];
445
- }
446
- }
447
- wb = wb_temp;
448
-
449
- /* check start / finish codes */
450
- sort(wb_check,idx,7);
451
- if (idx[0] != 4 /* widest bar W must be the 4th = 1st of end */
452
- || wb_check[idx[0]]==wb_check[idx[1]]) { /* exact 1 widest */
453
- free(wb_temp);
454
- free(wb_check);
455
- g_debug(fprintf(stderr," need exact 1 widest at start of end, abort\n");)
456
- return 0;
457
- }
458
-
459
- for(w=i=0; i<5*code_chars;i++ ) w+=wb[i]; /* summ width */
460
- dw=w*1.0/(16*(num_bars/5)); /* threshold = 1.5..2 */
461
- /* whats best and most rigorosely for dw=threshold_width?
462
- * - (1.5..2)*mean_width of every 5th space
463
- * - (1.5..2)*summ(5bars+5spaces)/(13..16)
464
- * - 3/4*summ(three thickest)/3
465
- */
466
- dww=crc=0; /* error and checksum (not supported yet) */
467
- #if 0 /* should we exclude any non-standard code39? */
468
- /* check for correct start and end symbol * or NwNnWnWnN Narrow+Wide */
469
- i=2*num_bars-2;
470
- if (wb[ 0]>dw*2 || wb[ 1]<=dw*2 || wb[ 2]> dw*2) return 0;
471
- if (wb[i-0]>dw*2 || wb[i-1]> dw*2 || wb[i-2]<=dw*2) return 0;
472
- #endif
473
- g_debug(fprintf(stderr," code25 base=%.3f chars=%2d\n ",dw,code_chars);)
474
- buf =malloc( code_chars); if (!buf) return result;
475
- result=malloc(256+code_chars);
476
-
477
- for(i5=i1=0;i1<5*code_chars;i1+=5) {
478
- /* ToDo: looking for three widest bars/gaps */
479
- sort(wb+i1,idx,5);
480
- for(err=0,i3=2;i3<5;i3++)
481
- err+=sqr(wb[i1+idx[i3]]/dw-1.0); /* narrow=1, wide=2..3 */
482
- dww+=err;
483
- for(i3=0;i3<Num25;i3++)
484
- if (code25[6*i3+1+idx[0]]=='-'
485
- && code25[6*i3+1+idx[1]]=='-') break;
486
- //if (i5>0 && i5<num_bars/3-2) crc+=i3;
487
- buf[i5++]=code25[6*i3];
488
-
489
- /* ToDo: check if we have even number of black bars within 3 biggest */
490
- g_debug(for(i3=0;i3<5;i3++)fprintf(stderr,"%02d ",wb[i1+i3]);
491
- fprintf(stderr," posWide=%d,%d %c err=%.3f\n ",
492
- idx[0], idx[1], buf[i5-1], err/6);)
493
- {
494
- /* check that we have exact 2 widest bars, 2nd widest > 3th widest */
495
- if (wb[i1+idx[1]]==wb[i1+idx[2]]) {
496
- free(buf); free(result);
497
- g_debug(fprintf(stderr," need exact 2 widest, abort\n");)
498
- return 0;
499
- }
500
- }
501
- }
502
- buf[i5]=0;
503
- if (result) // ToDo: fix CRC (not defined?)
504
- sprintf(result,"<barcode type=\"i25\" chars=\"%d\" code=\"%s\" crc=\"%c\""
505
- " error=\"%.3f\" />", i5,buf,code25[(crc%10)*10],dww/((num_bars/5)*6));
506
-
507
- free(wb_temp);
508
- free(wb_check);
509
- free(buf);
510
- return result;
511
- }
512
-
513
- /* code codabar, numbers only, 4 bars per char (1*wide bar, 1*wide space)
514
- robust code (dot-matrix printer)
515
- characters have same length (distance between 1st bar to 4th space)
516
- ??? codeproject: 6*n+2*w=12 or 5*n+3*w=14
517
- ??? suchymips.de:
518
- variant 1: 18 different bar widths (Monarch code)
519
- variant 2: 2 different bar widths (Codabar Matrix or ABC-Codabar)
520
- 9..11 digits/inch, N=narrow bar, W=wide bar, n=narrow space, w=wide space
521
- see http://www.barcodeman.com/info/codabar.php (Jul 2009)
522
- minN=0.17mm=0.0065inch, 11 digits/inch = 0.0909 = 14*minN
523
- 2of7 + extensions
524
- extensions: 1 wide bar + 2 wide spaces (no narrow space between 2 wide)
525
- 4 start/stop sets = a/t, b/m, c/ *, d/e
526
- - mean wide = thickest of 4 bars
527
- - mean narrow = thinnest of 4 bars, thinnest of 3 (4) spaces or every 4th
528
- wiki-sample: a31117013206375b (wide spaces between chars) schraeg!
529
- barcode: t1234567t n=N=1 w=W=3 c=12,14 (not const.)
530
- */
531
- const char *code27= /* 4bars+3spaces, 12+12 chars */
532
- // 0..11: 3 nbar + 1 wbar + 2 nspace + 1 wspace
533
- "0.....--1....--.2...-..-3--.....4..-..-."
534
- "5-....-.6.-....-7.-..-..8.--....9-..-...-...--..$..--..."
535
- // 12..15: 1 nbar + 3 wbar + 3 nspace + 0 wspace
536
- ":-...-.-/-.-...-.-.-.-..+..-.-.-"
537
- // 16..23: 3 nbar + 1 wbar + 1 nspace + 2 wspace
538
- "a..--.-.b.-.-..-c...-.--d...---.t..--.-.n.-.-..-*...-.--e...---."
539
- // EOS
540
- "????????";
541
-
542
- /* example: barcode -E -e cbr -b 123456 >a.eps */
543
-
544
- char *decode_27(int *wb, int num_bars){ /* ToDo: char *dest, int len */
545
- int i, i1, i2, i3, i4, i5, b_idx[4], s_idx[3], b_w[4], s_w[3],
546
- max_wdiff, err=0;
547
- // double dw, err;
548
- char *buf, char27[8]="......";
549
- char *result=NULL; /* malloc and store the result */
550
-
551
- int code_chars;
552
- #if 0 // ToDo: verifications nb_max < wb_min etc.
553
- int nb_min=99999, nb_max=0, nb_sum=0, nb_num=0; // narrow bar
554
- int ns_min=99999, ns_max=0, ns_sum=0, ns_num=0; // narrow space
555
- int wb_min=99999, wb_max=0, wb_sum=0, wb_num=0; // wide bar
556
- int ws_min=99999, ws_max=0, ws_sum=0, ws_num=0; // wide space
557
- #endif
558
-
559
- if ((num_bars)%4!=0) return 0; /* chars*4bars */
560
- code_chars = num_bars / 4;
561
- // dw=w*1.0/(9*(num_bars/3)); /* threshold = 1.5..2 */
562
-
563
- g_debug(fprintf(stderr," codabar chars= %d\n ", code_chars);)
564
- buf =malloc( code_chars); if (!buf) return result;
565
- result=malloc(256+code_chars);
566
- i5=0; // index output string
567
- for (i=0; i< code_chars; i++) {
568
- b_w[0]=wb[i*8+0]; // 1st bar
569
- b_w[1]=wb[i*8+2]; // 2nd bar
570
- b_w[2]=wb[i*8+4]; // 3th bar
571
- b_w[3]=wb[i*8+6]; // 4th bar
572
- s_w[0]=wb[i*8+1]; // 1st space
573
- s_w[1]=wb[i*8+3]; // 2nd space
574
- s_w[2]=wb[i*8+5]; // 3th space
575
- sort(b_w,b_idx,4); /* idx[0] points to widest bar */
576
- sort(s_w,s_idx,3); /* idx[0] points to widest space */
577
- g_debug(for(i3=0;i3<7;i3++)fprintf(stderr,"%02d ",wb[8*i+i3]);)
578
- if (b_w[b_idx[0]]==b_w[b_idx[3]]) { err=__LINE__; break; } // min. 1 wide + narrow
579
- // search max. diff between sorted widths
580
- i2=b_w[b_idx[0]]-b_w[b_idx[1]]; i1=1; max_wdiff=i2; // diff widest - 2nd wides
581
- i2=b_w[b_idx[1]]-b_w[b_idx[2]]; if (i2>max_wdiff) { i1=2; max_wdiff=i2; }
582
- i2=b_w[b_idx[2]]-b_w[b_idx[3]]; if (i2>max_wdiff) { i1=3; max_wdiff=i2; }
583
- if (i1==2) { err=__LINE__; break; } // 2 wide + 2 narrow bars not allowed
584
- for (i3=0;i3<7;i3++) char27[i3]='.'; // reset char
585
- if (i1==1) { // 1 wide bar (1 or 2 wspaces)
586
- if (s_w[s_idx[0]]-s_w[s_idx[1]]
587
- >s_w[s_idx[1]]-s_w[s_idx[2]]) { // 1 wspace
588
- char27[2*b_idx[0]+0]='-';
589
- char27[2*s_idx[0]+1]='-';
590
- } else { // assume 2 wspaces
591
- if (s_w[s_idx[2]]==s_w[s_idx[1]]) { err=__LINE__; break; }
592
- char27[2*b_idx[0]+0]='-';
593
- char27[2*s_idx[0]+1]='-';
594
- char27[2*s_idx[1]+1]='-';
595
- }
596
- } else { // assume 3 wbars + 0 wspaces
597
- char27[2*s_idx[0]+0]='-';
598
- char27[2*s_idx[1]+0]='-';
599
- char27[2*s_idx[2]+0]='-';
600
- }
601
- for(i4=24,i3=0;i3<24;i3++) {
602
- if (code27[8*i3+1]==char27[0]
603
- && code27[8*i3+2]==char27[1]
604
- && code27[8*i3+3]==char27[2]
605
- && code27[8*i3+4]==char27[3]
606
- && code27[8*i3+5]==char27[4]
607
- && code27[8*i3+6]==char27[5]
608
- && code27[8*i3+7]==char27[6]) {
609
- i4=i3; buf[i5++]=code27[8*i3]; break; }
610
- }
611
- g_debug(fprintf(stderr," %s c27= %c\n ", char27, ((i5)?buf[i5-1]:'?'));)
612
- if (i4==24) { err=__LINE__; break; }
613
- } // each char
614
- if (i>=code_chars) { // else: inconsistent char
615
- g_debug(fprintf(stderr," code27 base=%.3f chars=%2d\n ",0.0,code_chars);)
616
- } else {
617
- g_debug(fprintf(stderr," error %d at char %d, abort\n", err, i);)
618
- free(result); result=0;
619
- }
620
- buf[i5]=0;
621
- if (result) // ToDo: fix CRC (not defined?)
622
- sprintf(result,"<barcode type=\"codabar\" chars=\"%d\" code=\"%s\""
623
- " crc=\"%c\" error=\"%.3f\" />", i5,buf,'?',0.0);
624
-
625
- free(buf);
626
- return result; // free at parent!
627
- }
628
-
629
-
630
- /*
631
- decode barcode
632
- - check main characteristics (num bars, min+max width, etc.)
633
- - detect code type
634
- - the current algorithm measures the width of bars and spaces
635
- called by detect_barcode()
636
- ToDo: - like storing sequence of widths for 1D code
637
- store array of bits for 2D matrix code and decode later
638
- */
639
- char *decode_barcode(struct box *bb){ /* ToDo: char *dest, int len */
640
- int i, num_bars, yy, w, ww, dx, xx, cs=JOB->cfg.cs, *wb;
641
- char *result=NULL; /* store the result */
642
- yy=(bb->y0+bb->y1)/2;
643
- w=ww=bb->x1-bb->x0+1;
644
- num_bars = num_cross(bb->x0,bb->x1,yy,yy,bb->p,JOB->cfg.cs);
645
- if(JOB->cfg.verbose)
646
- fprintf(stderr,"\n# ... detect bars=%3d w=%4d",num_bars,ww);
647
-
648
- /* store width of bars and spaces to buffer wb */
649
- wb=(int *)malloc(2*num_bars*sizeof(int)); if(!wb) return NULL;
650
- xx=bb->x0;
651
- xx-=loop(bb->p,xx,yy, 8,cs,1,LE);
652
- xx+=loop(bb->p,xx,yy,ww,cs,0,RI); /* start with a bar! */
653
- for (i=0;i<2*num_bars;i++) {
654
- dx=loop(bb->p,xx,yy,w,cs,1^(i&1),RI);
655
- xx+=dx;
656
- w-=dx;
657
- wb[i]=dx;
658
- } wb[2*num_bars-1]=0;
659
-
660
- /* ToDo: what about probability? if not unique
661
- * - add argument char *result which can be modified or not,
662
- * - or add box2? (would reuse of this code more difficult)
663
- */
664
- /* test code128 characteristics, ToDo: look for correct start/stop 211 seq. */
665
- if ((num_bars-1)%3==0 && num_bars>=10 && ww>=11*(num_bars-1)/3+2){
666
- if (!result) result=decode_code128(wb,num_bars);
667
- }
668
- /* test UPC/EAN characteristics */
669
- if ((num_bars)%2==0 && num_bars>=8 && ww>=7*(num_bars-6)/2+11
670
- && ((num_bars-6)/2)%2==0){ /* should be balanced */
671
- if (!result) result=decode_UPC(wb,num_bars);
672
- }
673
- /* test UPC_addon by Michael van Rooyen, often on books */
674
- if (num_bars==7 || num_bars==16)
675
- if (!result) result=decode_UPC_addon(wb,num_bars);
676
-
677
- /* test code39 characteristics */
678
- if ((num_bars)%5==0 && num_bars>14){
679
- if (!result) result=decode_39(wb,num_bars);
680
- }
681
- /* test i2of5 chartacteristics */
682
- if ((num_bars)%5==4 && num_bars>3) {
683
- if (!result) result=decode_i25(wb,num_bars);
684
- }
685
-
686
- /* test codabar chartacteristics */
687
- if ((num_bars)%4==0 && num_bars>3) {
688
- if (!result) result=decode_27(wb,num_bars);
689
- }
690
-
691
- free(wb);
692
- return result;
693
- }
694
-
695
- /*
696
- * taking the list of boxes and search for groups of bars (1D-barcodes)
697
- */
698
- int detect_barcode(job_t *job)
699
- {
700
- int j=0, j2=0, bx0, by0, bx1, by1, bdx, bdy, bbx, rm,
701
- x0, y0, dx, dy, cs, y, yl0, yl1, yr0, yr1;
702
- struct box *box2, *box3;
703
-
704
- if(JOB->cfg.verbose)
705
- fprintf(stderr,"# barcode.c detect_barcode ");
706
- x0=y0=0; rm=0; dx=job->src.p.x; dy=job->src.p.y; cs=JOB->cfg.cs;
707
- for_each_data(&(JOB->res.boxlist)) {
708
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
709
- /* detect width (bdx) and height (bdy) of possible bar */
710
- /* ToDo: better check for a line */
711
- bdx=box2->x1-box2->x0+1 /* substract correction for skewed bars */
712
- -loop(box2->p,box2->x1,(box2->y0+box2->y1)/2,box2->x1-box2->x0,cs,0,LE)
713
- -loop(box2->p,box2->x0,(box2->y0+box2->y1)/2,box2->x1-box2->x0,cs,0,RI);
714
- bdy=box2->y1-box2->y0+1;
715
- if (box2->c == PICTURE || box2->c == UNKNOWN)
716
- if (box2->y0 >= y0 && box2->y1 <= y0 + dy /* within frame? */
717
- && box2->x0 >= x0 && box2->x1 <= x0 + dx
718
- && box2->y1 - box2->y0 > 19 /* min. length */
719
- && box2->y1 - box2->y0 > 8 * bdx
720
- ) { /* a bar? */
721
- j=1; /* number of bars */
722
- bx0=box2->x0; bx1=box2->x1; /* initial values for barcode frame */
723
- by0=box2->y0; by1=box2->y1;
724
- bbx=bx1-bx0+2; /* width of bar */
725
- /* this is for scans which are not exactly horizontal */
726
- yl0=yr0=by0; /* left and right upper bound */
727
- yl1=yr1=by1; /* left and right lower bound */
728
- /* --- iteratively take into account next nearest bar ---
729
- * this is important, because bar-boxes are not in right order */
730
- for (j2=1;j2;) {
731
- j2=0;
732
- /* expand a frame around the potential barcode (bx0,by0,bx1,by1) */
733
- for_each_data(&(JOB->res.boxlist)) {
734
- box3 = (struct box *)list_get_current(&(JOB->res.boxlist));
735
- /* bdy=box3->y1-box3->y0+1; */
736
- if (box2!=box3)
737
- if (box3->c == PICTURE || box3->c == UNKNOWN)
738
- if (box3->y0 >= y0 && box3->y1 <= y0 + dy /* within image */
739
- && box3->x0 >= x0 && box3->x1 <= x0 + dx
740
- && box3->y1 - box3->y0 > 19 /* min. length */
741
- && box3->y1 - box3->y0 > 4 * (bdx) /* height > 4*width2 */
742
- && box3->x1 - box3->x0 < 4 * (bdy) /* width < height/4 = bar */
743
- && (( abs(box3->y0-by0)<bdy/16+4 /* within bar-box ? */
744
- && abs(box3->y1-by1)<bdy/2 ) /* lower ends of UPC could be longer */
745
- ||( abs(box3->y0-yl0)<bdy/16+4 /* left side of frame */
746
- && abs(box3->y1-yl1)<bdy/2
747
- && box3->x0 <= bx0 )
748
- ||( abs(box3->y0-yr0)<bdy/16+4 /* right side of frame */
749
- && abs(box3->y1-yr1)<bdy/2
750
- && box3->x0 >= bx1 ) )
751
- && box3->x0 > bx0 - 12*bbx /* startspace=5...10 */
752
- && box3->x1 < bx1 + 12*bbx
753
- && box3->x0 > bx0 - bdy/2 /* dont glue two barcodes together */
754
- && box3->x1 < bx1 + bdy/2 /* ex: ean13a.jpg */
755
- /* dont check bars which already within the frame twice ? */
756
- && ( box3->x1 > bx1 || box3->x0 < bx0 )
757
- ) { /* a bar? -> extend barcode frame only in x direction */
758
- /* take minimum of y to have valid barcode for all y */
759
- if (box3->x0<bx0) { bx0=box3->x0; yl0=box3->y0; yl1=box3->y1; }
760
- if (box3->x1>bx1) { bx1=box3->x1; yr0=box3->y0; yr1=box3->y1; }
761
- if (4*(box3->y1-box3->y0)>3*(by1-by0)) { /* carefull reduce */
762
- if (box3->y0>by0) by0=box3->y0; /* ToDo: fix for non-horizontal */
763
- if (box3->y1<by1) by1=box3->y1;
764
- }
765
- j++; /* found a near bar and count to num bars */
766
- j2=1; /* continue searching (endless loop?) */
767
- }
768
- } end_for_each(&(JOB->res.boxlist));
769
- }
770
- /* j is the num of bars found above, some inner bars are not counted */
771
- /* ToDo: better iterative add next nearest bars from sorted list near bars? */
772
- if (j>5) {
773
- char *code=0;
774
- box2->c=PICTURE; /* BARCODE */
775
- box2->x0=bx0; box2->y0=by0;
776
- box2->x1=bx1; box2->y1=by1;
777
- /* ToDo: add pointer to decoded text */
778
-
779
- y=(box2->y0+box2->y1)/2;
780
- if (JOB->cfg.verbose){
781
- int nbars;
782
- nbars=num_cross(box2->x0,box2->x1,y,y,box2->p,JOB->cfg.cs);
783
- fprintf(stderr,"\n# barcode at %3d %3d size %3d %3d nbars %d (%d)",
784
- bx0,by0,bx1-bx0+1,by1-by0+1,nbars,j);
785
- if (j!=nbars)
786
- fprintf(stderr,"\n# ... trouble: num_found_bars != num_cross");
787
- /* this is because some far bars are detected before near bars */
788
- }
789
- /* transport the info to the gocr-output (development) */
790
- /* ToDo: decode and print/store barcode bars=j */
791
- code=decode_barcode(box2); /* ToDo: char *dest, int len */
792
- if (!code) { /* failed */
793
- code=(char *)malloc(128);
794
- /* ToDo: analyze and output num_bars, width of bars etc. */
795
- if(code) strncpy(code,"<barcode type=\"unknown\" />",128);
796
- }
797
- if (JOB->cfg.verbose)
798
- fprintf(stderr,"\n# ... decoded as: %s", code);
799
- setas(box2,code,99); /* ToDo: set a better weight */
800
- free(code);
801
-
802
- /* remove inner boxes, only if sure!? (ToDo: use cfg.certainty) */
803
- for_each_data(&(JOB->res.boxlist)) {
804
- box3 = (struct box *)list_get_current(&(JOB->res.boxlist));
805
- /* bdy=box3->y1-box3->y0+1; */
806
- if (box2!=box3)
807
- if (box3->c == PICTURE || box3->c == UNKNOWN)
808
- if ( abs(box3->y0-by0)<bdy/16+4 /* within bar-box ? */
809
- && abs(box3->y1-by1)<bdy/2 /* lower ends of UPC could be longer */
810
- && box3->x1 <= bx1
811
- && box3->x0 >= bx0
812
- ) {
813
- rm++; /* count removed boxes */
814
- list_del(&(JOB->res.boxlist),box3);
815
- free_box(box3);
816
- }
817
- } end_for_each(&(JOB->res.boxlist));
818
- if (JOB->cfg.verbose)
819
- fprintf(stderr,"\n# ... removed boxes: %d", rm);
820
- rm=0;
821
- }
822
- }
823
- } end_for_each(&(JOB->res.boxlist));
824
-
825
- /* recalculate averages without bars */
826
- JOB->res.numC=JOB->res.sumX=JOB->res.sumY=j2=0;
827
- for_each_data(&(JOB->res.boxlist)) {
828
- j2++;
829
- box3 = (struct box *)list_get_current(&(JOB->res.boxlist));
830
- if (box3->c==PICTURE) continue;
831
- JOB->res.numC++; /* count remaining boxes */
832
- JOB->res.sumX+=box3->x1-box3->x0+1;
833
- JOB->res.sumY+=box3->y1-box3->y0+1;
834
- } end_for_each(&(JOB->res.boxlist));
835
- if(JOB->cfg.verbose)
836
- fprintf(stderr,"\n# ... boxes %d nC %d\n",
837
- j2, JOB->res.numC);
838
-
839
- /* ToDo: detect DataMatrix = iec16022
840
- * search square of 2 lines and 2 dottet lines (first no rotation)
841
- * output characteristics pixel size, bytes, code type, etc.
842
- */
843
-
844
- return 0;
845
- }
846
-