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
data/src/gocr-0.48/TODO DELETED
@@ -1,65 +0,0 @@
1
- TODO LIST
2
-
3
- Please send any ideas.
4
-
5
- Next release (0.4x)
6
- - quality test script for groups of samples (to ensure improvement in recognition)
7
- single chars or single chars in words, clean and difficult sets,
8
- formatted texts
9
- false negative + false positive
10
- start with numbers? option numbers only?
11
- output: find fname.{jpg,png} + fname.txt + compare output gocr against txt
12
- options: [testpath] [testchars]
13
- bin/gocr_chk.sh testbase/free/{clean,glued,dusty}/{numbers,text}/
14
- bin/gocr_chk.sh jocr/examples tmp09
15
- - fix problem with cutting melted chars (using vector frames)
16
- - better detection of agglutinated serifs (Gutenberg scans 086.png+171.png)
17
- - vectorize recognition (big step!, relation to other OSS?)
18
- (find min distance to ideal vector patterns, start with <>())
19
- - frame_nn is marking only the borders like frame_vector and removed later
20
- - handle broken and glueed chars by the database algorithm (-m 256 -m 130)
21
- - improve get_line2(), implement distance_to_point and distance_to_line
22
- - dot-matrix printouts (examples/matrix.jpg) (german: Nadeldrucker)
23
- - examples/inverse.pcx + examples/rotate45.pcx by nearest-box-to-line alg.
24
- or mean nearest box (or its 4 edges) directions,
25
- rotate only boxes (by creating new greater boxes and tread as new image)
26
- - proof replacement of getTextLine by getXMLline via pipe(?) or stdout
27
- is pipe available on all platforms?
28
- - docu about ispell using via XML (what needed, test in gocr.tcl)
29
- - replace rest of UNDEFINED in unicode.c by its correct strings
30
- - add probability for box->m1..m4 (to reduce errors caused by bad line-scan)
31
- call line detection function second time to improve unsure line data
32
-
33
- Next release (0.5x)
34
- - reduce pixel data by vectorization (big change, faster)
35
- - writing images through pipes (like reading)
36
- - using dictionary (optional) for replacing not recognized chars
37
- - Karsten.Hilbert@gmx.net: use ORChie WordBox-format
38
- see http://http.cs.berkeley.edu/~fateman/kathey/ocrchie.html
39
- aspell instead of ispell
40
-
41
- Near future: (planned version)
42
- - rewrite install-routine
43
- - perspective distortion (for cameras)
44
- - genetic algorithms engine (already in development, 0.8?). It includes
45
- feature extraction and classification
46
- - support for other languages (may affect context_correction(), etc) (0.6?)
47
- - support for diagramation. Can be done using the Unicode+new stuff. I (bbg)
48
- have some ideas.
49
-
50
- Far future:
51
- - gimp plugin
52
- - color support
53
- - Braille detection (usefull for blinds?)
54
- see: American Journal of Physics Vol. 70, No. 7, p 684-688 (2002)
55
- or use special foils
56
- - read image in smaller parts, to reduce memory usage.
57
- - frames should be recognized
58
- - better distance function (comparision of characters)
59
- - detection of orientation (i.a. 90,180,270deg rotation)
60
- - picture extraction
61
- - math formula detection, font type detection
62
- - handwritten texts (blockletters)
63
- --- uff, really a lot of work ---
64
- - Feel free and add your suggestions and wishes,
65
- or tell me, what is the most important point for you.
@@ -1,2 +0,0 @@
1
- .cvsignore
2
- gocr
@@ -1,38 +0,0 @@
1
- #! /bin/bash
2
- # v0.1 1st release
3
- # v0.2 0 added
4
- # v0.2a1 convert renamed to jconv
5
- # v0.3 jconv replaced by convert (ImageMagick)
6
- #
7
- echo "create database ./db/db.lst ./db/db.log ./db/db_XXXX.pbm"
8
- if ! test -d db; then mkdir db; fi
9
- if test -r db/db.lst; then echo "database exist";exit; fi
10
- if ! test -x ./jconv; then make jconv; fi
11
- nc=0
12
- # roman typewriter italic bold-face slanted small caps sans-serif
13
- for font in "\rm" "\tt" "\it" "\bf" "\sl" "\sc" "\sf"; do
14
- echo -n " font: $font "
15
- for c in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9; do
16
- echo -n "$c"
17
- cat << END >a.tex
18
- \documentclass[12pt]{article}\pagestyle{empty}
19
- \topmargin=-50mm \textheight=20mm \textwidth=20mm
20
- \oddsidemargin=-20mm \evensidemargin=-20mm
21
- \begin{document}
22
- $font $c
23
- \end{document}
24
- END
25
- ns=$(printf "%04d" $nc)
26
- echo "db_$ns.pbm $c $font" >>db/db.lst
27
- latex a.tex >>db/db.log
28
- # shift to left,bottom edge
29
- dvips -E -O -0.3in,11.0in -T 4.0in,4.0in -o a.ps a.dvi 2>>db/db.log
30
- # -q gs (0,0)=left,bottom
31
- gs -dNOPAUSE -r600 -sPAPERSIZE=a10 -sDEVICE=pbmraw -sOutputFile=db/db_$ns.pbm - <a.ps >>db/db.log
32
- convert -crop 0x0+1+1 db/db_$ns.pbm db/db_$ns.pbm 2>>db/db.log
33
- nc=$(($nc + 1))
34
- done
35
- echo ". ok"
36
- done
37
- #rm -f a.tex
38
- echo "finished"
@@ -1,527 +0,0 @@
1
- #!/bin/sh
2
- # --- tcl/tk-GUI for gocr --- (c) Joerg Schulenburg
3
- # start: wish gocr.tcl
4
- #
5
- # tested on: tk8.0 (linux,win95)
6
- #
7
- # ToDo:
8
- # - better using wishx with extended Tcl? (for pipe etc.)
9
- # - Reading from stderr of child???
10
- #
11
- # this is a multiline comment in wish, but not in sh \
12
- exec wish -f $0 $@
13
-
14
- set ver 0.3.6
15
- set gocrver 0.3.5
16
-
17
- # v0.3.6
18
- # - adaption to gocr v0.3, new options
19
- # ToDo:
20
- # - xviewer as option (xli), proc view { image } { handle it }
21
- # image gif ppm pgm (use xli -geometry WxH[{+-}X{+-}Y] out30.bmp #!)
22
- # - output file as option, colored text (bad chars red)
23
- # - last/current command on status line (at bottom)
24
- # - capture error channel from gocr seperately
25
- # - use -f inifile as option
26
- #
27
- # Thanks to famous tk/tcl developper! Realy good language for x11 beginner.
28
- #
29
- wm title . "GOCR Tcl frontend $ver"
30
-
31
- set spacewidth 0
32
- set graylevel 160
33
- set dustsize 20
34
- set imgviewer "xli -geometry 400x400 "
35
- set gocrpath "gocr"
36
- set gocraddopt "-e - -f UTF8"
37
- set file "../examples/text.pbm"
38
- set ofile "out01.txt"
39
- # entry out{n+1}.txt can automaticly generated!
40
- if $argc {
41
- puts " ignore $argc arguments: $argv"
42
- }
43
-
44
- frame .mbar -borderwidth 1 -relief raised
45
- pack .mbar -fill x
46
-
47
- menubutton .mbar.file -text "File" -menu .mbar.file.m
48
- pack .mbar.file -side left
49
- menu .mbar.file.m
50
- # .mbar.file.m add command -label "create font1.pbm" -command exit
51
- .mbar.file.m add command -label "Clear output" -command {$log delete 0.0 end}
52
- .mbar.file.m add command -label "Save output" -command {ofileDialog .mbar.file.m; SaveText $ofile}
53
- .mbar.file.m add command -label "Exit" -command exit
54
-
55
-
56
- menubutton .mbar.options -text "Options" -menu .mbar.options.m
57
- pack .mbar.options -side left
58
- menu .mbar.options.m
59
- .mbar.options.m add command -label "set Options" -command Option
60
- .mbar.options.m add command -label "Save options" -command SaveOpt
61
- .mbar.options.m add command -label "Load options" -command LoadOpt
62
- set m1 0
63
- set m2 0
64
- set m3 0
65
- set m4 0
66
- set m5 0
67
- set m6 0
68
- set v0 0
69
- set v1 0
70
- set v2 0
71
- set v3 0
72
- set v4 0
73
- set v5 0
74
- # set for automatic detection
75
- set autos 1
76
- set autol 1
77
- set autod 1
78
-
79
-
80
- menubutton .mbar.help -text "Help" -menu .mbar.help.m
81
- pack .mbar.help -side right
82
- menu .mbar.help.m
83
- .mbar.help.m add command -label "About" -command aboutBox
84
- # .mbar.help.m add command -label "Version"
85
-
86
- # --------------------- action frame -----------------------
87
- frame .abar -borderwidth 1 -relief sunken
88
- pack .abar -fill x
89
-
90
- set but [button .abar.go -text "Run it" -command Run]
91
- #button .abar.go -text "Run it" -command { Run }
92
- pack .abar.go -side left
93
-
94
- set f .abar
95
- set w .abar
96
- label .abar.labf -text "File:"
97
- button .abar.file -text "Browse" -command "fileDialog $w $f.entf open"
98
- button .abar.show -text "Show" -command "Show"
99
- button .abar.spell -text "Spell" -command "Spell"
100
- button .abar.scan -text "Scan" -command "Scan"
101
- entry .abar.entf -width 40
102
- pack .abar.labf -side left
103
- pack .abar.entf -side left
104
- pack .abar.file -side left
105
- pack .abar.show -side left
106
- pack .abar.spell -side left
107
- pack .abar.scan -side left
108
- .abar.entf insert 0 $file
109
-
110
- label .abar.status -text "ready"
111
- pack .abar.status -side right
112
-
113
- # ------------------ canvas, text ? -----------------
114
- #canvas .pad -background white
115
- #pack .pad
116
-
117
- frame .t
118
- #text .t
119
- #pack .t
120
- ##.t insert end "history:"
121
- ##.t configure -state disabled
122
-
123
-
124
- set log [text .t.log -width 80 -height 30 \
125
- -borderwidth 2 -relief raised -setgrid true\
126
- -yscrollcommand {.t.scroll set}]
127
- scrollbar .t.scroll -command {.t.log yview}
128
- pack .t.scroll -side right -fill y
129
- pack .t.log -side left -fill both -expand true
130
- # pack .t -side top -fill both -expand true
131
- #####################################################
132
-
133
- frame .tmsg
134
- set log2 [text .tmsg.log -width 80 -height 5 \
135
- -borderwidth 2 -relief raised -setgrid true\
136
- -yscrollcommand {.tmsg.scroll set}]
137
- scrollbar .tmsg.scroll -command {.tmsg.log yview}
138
- pack .tmsg.scroll -side right -fill y
139
- pack .tmsg.log -side left -fill both -expand true
140
- pack .t .tmsg -side top -fill both -expand true
141
- #####################################################
142
-
143
- bind .abar.entf <Return> Run
144
- bind .abar.entf <Control-c> Stop
145
- focus .abar.entf
146
-
147
-
148
- $log2 insert end "\n ! ! ! This program is in development. Use carefully ! ! !\n\n"
149
-
150
- # tk_messageBox -icon info -type ok -title "Info" -message \
151
- # "This program is in development!\nUse carefully!\n"
152
-
153
-
154
- # --------------------- File ---------------------
155
- # see /usr/lib/tk8.0/demos/filebox.tcl
156
- proc fileDialog {w ent operation} {
157
- # Type names Extension(s) Mac File Type(s)
158
- #
159
- #---------------------------------------------------------
160
- set types {
161
- {"PNM files" {.pnm .pbm .pgm .ppm} }
162
- {"Image Files" {.tga .pcx} }
163
- {"Image Files" {.gif .bmp .tiff .png} }
164
- {"Image Files" {.jpeg .jpg} }
165
- {"Image Files" "" {GIFF JPEG}}
166
- {"All files" *}
167
- }
168
- if {$operation == "open"} {
169
- set file [tk_getOpenFile -filetypes $types -parent $w]
170
- } else {
171
- set file [tk_getSaveFile -filetypes $types -parent $w \
172
- -initialfile Untitled -defaultextension .txt]
173
- }
174
- if [string compare $file ""] {
175
- $ent delete 0 end
176
- $ent insert 0 $file
177
- $ent xview end
178
- }
179
- }
180
-
181
- # --------------------- oFile ---------------------
182
- # see /usr/lib/tk8.0/demos/filebox.tcl
183
- proc ofileDialog {w} {
184
- global ofile
185
- # Type names Extension(s)
186
- set types {
187
- {"text files" {.txt .text .asc} }
188
- {"HTML files" {.html .htm} }
189
- {"All files" *}
190
- }
191
- set ofile [tk_getSaveFile -filetypes $types -parent $w \
192
- -initialfile $ofile -defaultextension .txt]
193
- update
194
- }
195
-
196
- # --------------------- Show Picture ---------------------
197
- proc Show {} {
198
- global file, imgviewer
199
- set file [.abar.entf get]
200
- eval exec $imgviewer $file &
201
- }
202
-
203
- # --------------------- Spell check ---------------------
204
- proc Spell {} {
205
- global ofile
206
- # WARNING: this clobbers out.txt (fixme)
207
- SaveText $ofile
208
- exec tkispell $ofile &
209
- }
210
-
211
- # --------------------- Scan ---------------------
212
- proc Scan {} {
213
- exec xsane -s -n &
214
- }
215
-
216
- # --------------------- Options ---------------------
217
- proc SaveOpt {} {
218
- global v0 v1 v2 v3 v4 v5 m1 m2 m3 m4 m5 m6 spacewidth graylevel dustsize imgviewer ofile
219
- global autos autod autol gocrpath gocraddopt
220
- if [catch {open .gocr w} out] {
221
- puts "open .gocr failed"
222
- return
223
- }
224
- set file [.abar.entf get]
225
- set vvv [expr $v0 + $v1 + $v2 + $v3 + $v4 + $v5 ]
226
- set mode [expr $m1 + $m2 + $m3 + $m4 + $m5 + $m6 ]
227
- puts $out "vvv $vvv"
228
- puts $out "mode $mode"
229
- puts $out "file $file"
230
- puts $out "ofile $ofile"
231
- puts $out "spacewidth $spacewidth"
232
- puts $out "graylevel $graylevel"
233
- puts $out "dustsize $dustsize"
234
- puts $out "imgviewer $imgviewer"
235
- puts $out "autos $autos"
236
- puts $out "autod $autod"
237
- puts $out "autol $autol"
238
- puts $out "gocrpath $gocrpath"
239
- puts $out "gocraddopt $gocraddopt"
240
- close $out
241
- }
242
-
243
- proc LoadOpt {} {
244
- global v0 v1 v2 v3 v4 v5 m1 m2 m3 m4 m5 m6 spacewidth graylevel dustsize imgviewer ofile
245
- global autos autod autol gocrpath gocraddopt
246
- set file [.abar.entf get]
247
- set vvv [expr $v0 + $v1 + $v2 + $v3 + $v4 + $v5 ]
248
- set mode [expr $m1 + $m2 + $m3 + $m4 + $m5 + $m6 ]
249
- if [catch {open .gocr r} in] {
250
- puts "open .gocr failed"
251
- return
252
- }
253
- while {[ gets $in line] >=0} {
254
- if { [string first "vvv" "$line"] == 0 } { scan $line "%s%d" buf vvv }
255
- if { [string first "mode" "$line"] == 0 } { scan $line "%s%d" buf mode }
256
- if { [string first "file" "$line"] == 0 } { scan $line "%s%s" buf file }
257
- if { [string first "ofile" "$line"] == 0 } { scan $line "%s%s" buf ofile }
258
- if { [string first "gray" "$line"] == 0 } { scan $line "%s%d" buf graylevel }
259
- if { [string first "dust" "$line"] == 0 } { scan $line "%s%d" buf dustsize }
260
- if { [string first "imgv" "$line"] == 0 } { scan $line "%s%d" buf imgviewer }
261
- if { [string first "autos" "$line"] == 0 } { scan $line "%s%d" buf autos }
262
- if { [string first "autod" "$line"] == 0 } { scan $line "%s%d" buf autod }
263
- if { [string first "autol" "$line"] == 0 } { scan $line "%s%d" buf autol }
264
- if { [string first "gocrpath" "$line"] == 0 } { scan $line "%s%s" buf gocrpath }
265
- if { [string first "gocraddopt" "$line"] == 0 } { set gocraddopt [ string range "$line" 11 256 ] }
266
- }
267
- close $in
268
- .abar.entf delete 0 end
269
- .abar.entf insert 0 $file
270
- .abar.entf xview end
271
- set v0 [expr $vvv & 1 ]
272
- set v1 [expr $vvv & 2 ]
273
- set v2 [expr $vvv & 4 ]
274
- set v3 [expr $vvv & 8 ]
275
- set v4 [expr $vvv & 16 ]
276
- set v5 [expr $vvv & 32 ]
277
- set m6 [expr $mode & 64 ]
278
- set m1 [expr $mode & 2 ]
279
- set m2 [expr $mode & 4 ]
280
- set m3 [expr $mode & 8 ]
281
- set m4 [expr $mode & 16 ]
282
- set m5 [expr $mode & 32 ]
283
- }
284
-
285
- # call it once
286
- LoadOpt
287
-
288
- # see /usr/lib/tk8.0/demos/check.tcl
289
- proc Option {} {
290
- global v0 v1 v2 v3 v4 m1 m2 m3 m4 m5 m6 spacewidth graylevel dustsize imgviewer
291
- global autos autod autol gocrpath gocraddopt
292
- set w .woption
293
- catch {destroy $w}
294
- toplevel $w
295
- wm title $w "GOCR Options"
296
-
297
-
298
- set ww $w
299
-
300
-
301
- label $ww.msg -wraplength 4i -justify left -text "Here you can set several options for GOCR."
302
- pack $ww.msg -side top
303
-
304
- frame $w.buttons
305
- pack $w.buttons -side bottom -fill x -pady 2m
306
- button $w.buttons.ok -text "Ok" -command "destroy $w"
307
- button $w.buttons.vars -text "See Variables" -command "showVars"
308
- pack $w.buttons.vars $w.buttons.ok -side left -expand 1
309
-
310
- frame $ww.sep1 -relief ridge -bd 1 -height 2
311
- pack $ww.sep1 -side top -fill x
312
- # -expand no
313
-
314
- frame $ww.scale1
315
- pack $ww.scale1 -side top -fill x
316
- label $ww.scale1.label -text "spacewidth:" -width 16
317
- scale $ww.scale1.scale -orient horizontal -length 200 -from 0 -to 60 \
318
- -variable spacewidth
319
- checkbutton $ww.scale1.check -text "auto" -variable autos -onvalue 1 -offvalue 0
320
- pack $ww.scale1.label $ww.scale1.scale $ww.scale1.check -side left
321
-
322
- frame $ww.scale2
323
- pack $ww.scale2 -side top -fill x
324
- label $ww.scale2.label -text "graylevel:" -width 16
325
- scale $ww.scale2.scale -orient horizontal -length 200 -from 0 -to 255 \
326
- -variable graylevel
327
- checkbutton $ww.scale2.check -text "auto" -variable autol -onvalue 1 -offvalue 0
328
- pack $ww.scale2.label $ww.scale2.scale $ww.scale2.check -side left
329
-
330
- frame $ww.scale3
331
- pack $ww.scale3 -side top -fill x
332
- label $ww.scale3.label -text "dustsize:" -width 16
333
- scale $ww.scale3.scale -orient horizontal -length 200 -from 0 -to 60 \
334
- -variable dustsize
335
- checkbutton $ww.scale3.check -text "auto" -variable autod -onvalue 1 -offvalue 0
336
- pack $ww.scale3.label $ww.scale3.scale $ww.scale3.check -side left
337
-
338
- frame $ww.sep2 -relief ridge -bd 1 -height 2
339
- pack $ww.sep2 -side top -fill x
340
- # -expand no
341
-
342
- # place the checkbuttons in two columns
343
- frame $ww.cb
344
- pack $ww.cb -side top -fill x
345
- frame $ww.cb.cb1 -relief ridge -bd 1 -height 2
346
- pack $ww.cb.cb1 -side left -fill y
347
- frame $ww.cb.sep3 -relief ridge -bd 1 -height 2
348
- pack $ww.cb.sep3 -side left -fill y
349
- frame $ww.cb.cb2 -relief ridge -bd 1 -height 2
350
- pack $ww.cb.cb2 -side left -fill y
351
-
352
- set ww $w.cb.cb1
353
-
354
- label $ww.msg1 -text "Mode options (work mode):"
355
- pack $ww.msg1 -side top
356
- checkbutton $ww.b1 -text "use database" -variable m1 -onvalue 2 -offvalue 0
357
- checkbutton $ww.b2 -text "layout analysis" -variable m2 -onvalue 4 -offvalue 0
358
- checkbutton $ww.b3 -text "compare _ mode" -variable m3 -onvalue 0 -offvalue 8
359
- checkbutton $ww.b4 -text "divide _ mode" -variable m4 -onvalue 0 -offvalue 16
360
- checkbutton $ww.b5 -text "context correction" -variable m5 -onvalue 0 -offvalue 32
361
- checkbutton $ww.b6 -text "char packing" -variable m6 -onvalue 64 -offvalue 0
362
- pack $ww.b1 $ww.b2 $ww.b3 $ww.b4 $ww.b5 $ww.b6 -side top -pady 2 -anchor w
363
-
364
-
365
- set ww $w.cb.cb2
366
-
367
- label $ww.msg2 -text "Verbose options (output mode):"
368
- pack $ww.msg2 -side top
369
- checkbutton $ww.c1 -text "more info" -variable v0 -onvalue 1 -offvalue 0
370
- checkbutton $ww.c2 -text "list chapes" -variable v1 -onvalue 2 -offvalue 0
371
- checkbutton $ww.c3 -text "list pattern" -variable v2 -onvalue 4 -offvalue 0
372
- checkbutton $ww.c4 -text "list all pattern" -variable v3 -onvalue 8 -offvalue 0
373
- checkbutton $ww.c5 -text "line infos" -variable v4 -onvalue 16 -offvalue 0
374
- checkbutton $ww.c6 -text "debug mode" -variable v5 -onvalue 32 -offvalue 0
375
- pack $ww.c1 $ww.c2 $ww.c3 $ww.c4 $ww.c5 $ww.c6 -side top -pady 2 -anchor w
376
-
377
- set ww $w
378
-
379
- frame $ww.sep4 -relief ridge -bd 1 -height 2
380
- pack $ww.sep4 -side top -fill x
381
-
382
- set ww $w.l1
383
- frame $ww
384
- pack $ww -side top -fill x
385
-
386
- label $ww.d1 -text "Image Viewer:" -width 16
387
- entry $ww.d2 -textvariable imgviewer
388
- pack $ww.d1 -side left -pady 2 -padx 2 -anchor w
389
- pack $ww.d2 -side left -pady 2 -padx 2 -fill x -expand 1 -anchor w
390
-
391
- set ww $w.l2
392
- frame $ww
393
- pack $ww -side top -fill x
394
-
395
- label $ww.e1 -text "GOCR PATH:" -width 16
396
- entry $ww.e2 -textvariable gocrpath
397
- pack $ww.e1 -side left -pady 2 -padx 2 -anchor w
398
- pack $ww.e2 -side left -pady 2 -padx 2 -fill x -expand 1 -anchor w
399
-
400
- set ww $w.l3
401
- frame $ww
402
- pack $ww -side top -fill x
403
-
404
- label $ww.f1 -text "add OPTIONS:" -width 16
405
- entry $ww.f2 -textvariable gocraddopt
406
- pack $ww.f1 -side left -pady 2 -padx 2 -anchor w
407
- pack $ww.f2 -side left -pady 2 -padx 2 -fill x -expand 1 -anchor w
408
-
409
-
410
- }
411
-
412
- # ----------------------------- showVars -----------------------------
413
- proc showVars {} {
414
- global fid but log2 file v0 v1 v2 v3 v4 v5 m1 m2 m3 m4 m5 m6 spacewidth graylevel dustsize imgviewer
415
- global autos autod autol gocrpath gocraddopt
416
- set file [.abar.entf get]
417
- set vvv [expr $v0 + $v1 + $v2 + $v3 + $v4 + $v5 ]
418
- set mode [expr $m1 + $m2 + $m3 + $m4 + $m5 + $m6 ]
419
- set run "$gocrpath -v $vvv -m $mode"
420
- if [ expr $autos == 0 ] { set run "$run -s $spacewidth" }
421
- if [ expr $autol == 0 ] { set run "$run -l $graylevel" }
422
- if [ expr $autod == 0 ] { set run "$run -d $dustsize" }
423
- set run "$run $gocraddopt $file"
424
- $log2 insert end "run = $run\n"
425
- update
426
- }
427
-
428
-
429
- # ----------------------------- saveLog -----------------------------
430
- proc SaveText { txtfile } {
431
- global log
432
- if [catch {open $txtfile w} out] {
433
- puts "open $txtfile failed"
434
- return
435
- }
436
- puts $out [$log get 0.0 end]
437
- close $out
438
- }
439
-
440
-
441
- # ----------------------------- RUN -----------------------------
442
- proc Run {} {
443
- global fid but log log2 file v0 v1 v2 v3 v4 v5 m1 m2 m3 m4 m5 m6 spacewidth graylevel dustsize imgviewer
444
- global autos autod autol gocrpath gocraddopt
445
- set file [.abar.entf get]
446
- set pin ""
447
- if [ string match *.p?m.gz $file ] {
448
- set pin "gzip -cd $file |"
449
- set file -
450
- } elseif [ string match *.gif $file ] {
451
- set pin "giftopnm $file |"
452
- set file -
453
- } elseif { [ string match *.tif $file ] || [ string match *.tiff $file ] } {
454
- set pin "tifftopnm $file |"
455
- set file -
456
- } elseif { [ string match *.bmp $file ] } {
457
- set pin "bmptopnm $file |"
458
- set file -
459
- } elseif { [ string match *.png $file ] } {
460
- set pin "pngtopnm $file |"
461
- set file -
462
- } elseif { [ string match *.jpg $file ] || [ string match *.jpeg $file ] } {
463
- set pin "djpeg -gray -pnm $file |"
464
- set file -
465
- }
466
- set vvv [expr $v0 + $v1 + $v2 + $v3 + $v4 + $v5 ]
467
- set mode [expr $m1 + $m2 + $m3 + $m4 + $m5 + $m6 ]
468
- set run "$pin $gocrpath -v $vvv -m $mode"
469
- if [ expr $autos == 0 ] { set run "$run -s $spacewidth" }
470
- if [ expr $autol == 0 ] { set run "$run -l $graylevel" }
471
- if [ expr $autod == 0 ] { set run "$run -d $dustsize" }
472
- set run "$run $gocraddopt $file"
473
- $log2 insert end $run\n
474
- $log2 see end
475
- if [catch {open "| $run" } fid] {
476
- $log2 insert end $fid\n
477
- } else {
478
- # puts "listening on $fid (file4)"
479
- fileevent $fid readable Log
480
- # How to read from stderr of child???
481
- .abar.status configure -text "progress"
482
- update
483
- # $log insert end $run\n
484
- $but config -text "Stop !" -command Stop
485
- }
486
- ## gets $fid ; # ead headerline
487
- # fileevent $fid readable "get_samples $fid"
488
- }
489
-
490
- proc Log {} {
491
- global fid log
492
- if [eof $fid] { Stop } else {
493
- gets $fid line
494
- $log insert end $line\n
495
- $log see end
496
- }
497
- }
498
-
499
- proc Log2 {} {
500
- global log2 fid2
501
- # read from stderr-child???
502
- if [eof $fid2] { Stop } else {
503
- gets $fid2 line
504
- $log2 insert end $line\n
505
- $log2 see end
506
- }
507
- }
508
-
509
- proc Stop {} {
510
- global fid but v5
511
- catch {close $fid}
512
- $but config -text "Run it" -command Run
513
- .abar.status configure -text "ready"
514
- update
515
- }
516
-
517
-
518
- # aboutBox --
519
- #
520
- # Pops up a message box with an "about" message
521
- #
522
- proc aboutBox {} {
523
- global ver gocrver
524
- tk_messageBox -icon info -type ok -title "About" -message \
525
- "Tcl/Tk front end\nto GOCR $gocrver\n\nversion $ver (c) 2002 Joerg Schulenburg"
526
- }
527
-