mork 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -3
  3. data/lib/mork/coord.rb +58 -0
  4. data/lib/mork/grid.rb +44 -35
  5. data/lib/mork/grid_const.rb +11 -6
  6. data/lib/mork/grid_omr.rb +76 -62
  7. data/lib/mork/magicko.rb +162 -0
  8. data/lib/mork/mimage.rb +102 -177
  9. data/lib/mork/npatch.rb +38 -56
  10. data/lib/mork/sheet_omr.rb +45 -43
  11. data/lib/mork/sheet_pdf.rb +16 -16
  12. data/lib/mork/version.rb +1 -1
  13. data/mork.gemspec +2 -2
  14. data/mork.sublime-project +9 -0
  15. data/spec/mork/coord_spec.rb +55 -0
  16. data/spec/mork/grid_omr_spec.rb +62 -85
  17. data/spec/mork/grid_spec.rb +7 -7
  18. data/spec/mork/magicko_spec.rb +46 -0
  19. data/spec/mork/mimage_spec.rb +30 -20
  20. data/spec/mork/npatch_spec.rb +46 -39
  21. data/spec/mork/sheet_omr_spec.rb +82 -40
  22. data/spec/mork/sheet_pdf_spec.rb +8 -8
  23. data/spec/samples/angolo.jpg +0 -0
  24. data/spec/samples/grid.yml +53 -0
  25. data/spec/samples/info.yml +12 -11
  26. data/spec/samples/layout.yml +9 -5
  27. data/spec/samples/lucrezia/border1.pdf +0 -0
  28. data/spec/samples/lucrezia/border2.pdf +0 -0
  29. data/spec/samples/lucrezia/bw1.pdf +0 -0
  30. data/spec/samples/lucrezia/bw2.pdf +0 -0
  31. data/spec/samples/lucrezia/gray1.pdf +0 -0
  32. data/spec/samples/lucrezia/gray2.pdf +0 -0
  33. data/spec/samples/out-1.jpg +0 -0
  34. data/spec/samples/rm00.jpeg +0 -0
  35. data/spec/samples/slanted.jpg +0 -0
  36. data/spec/samples/slanted.yml +54 -0
  37. data/spec/samples/syst/IMG_20150104_0004.jpg +0 -0
  38. data/spec/samples/syst/IMG_20150104_0004.txt +4955 -0
  39. data/spec/samples/syst/IMG_20150104_0009.jpg +0 -0
  40. data/spec/samples/syst/IMG_20150104_0009.txt +4955 -0
  41. data/spec/samples/syst/IMG_20150104_0011.jpg +0 -0
  42. data/spec/samples/syst/IMG_20150104_0011.txt +4955 -0
  43. data/spec/samples/syst/SCN_0001.jpg +0 -0
  44. data/spec/samples/syst/SCN_0001.txt +4955 -0
  45. data/spec/samples/syst/barr0.jpg +0 -0
  46. data/spec/samples/syst/barr0.txt +4955 -0
  47. data/spec/samples/syst/barr1.jpg +0 -0
  48. data/spec/samples/syst/barr1.txt +4955 -0
  49. data/spec/samples/syst/barr2.jpg +0 -0
  50. data/spec/samples/syst/barr2.txt +4955 -0
  51. data/spec/samples/syst/bell0.jpg +0 -0
  52. data/spec/samples/syst/bell0.txt +4955 -0
  53. data/spec/samples/syst/bell1.jpg +0 -0
  54. data/spec/samples/syst/bell1.txt +4955 -0
  55. data/spec/samples/syst/bell2.jpg +0 -0
  56. data/spec/samples/syst/bell2.txt +4955 -0
  57. data/spec/samples/syst/bila0.jpg +0 -0
  58. data/spec/samples/syst/bila0.txt +4955 -0
  59. data/spec/samples/syst/bila1.jpg +0 -0
  60. data/spec/samples/syst/bila1.txt +4955 -0
  61. data/spec/samples/syst/bila2.jpg +0 -0
  62. data/spec/samples/syst/bila2.txt +4955 -0
  63. data/spec/samples/syst/bila3.jpg +0 -0
  64. data/spec/samples/syst/bila3.txt +4955 -0
  65. data/spec/samples/syst/bila4.jpg +0 -0
  66. data/spec/samples/syst/bila4.txt +4955 -0
  67. data/spec/samples/syst/bone0.jpg +0 -0
  68. data/spec/samples/syst/bone0.txt +4955 -0
  69. data/spec/samples/syst/bone1.jpg +0 -0
  70. data/spec/samples/syst/bone1.txt +4955 -0
  71. data/spec/samples/syst/bone2.jpg +0 -0
  72. data/spec/samples/syst/bone2.txt +4955 -0
  73. data/spec/samples/syst/cost0.jpg +0 -0
  74. data/spec/samples/syst/cost0.txt +4955 -0
  75. data/spec/samples/syst/cost1.jpg +0 -0
  76. data/spec/samples/syst/cost1.txt +4955 -0
  77. data/spec/samples/syst/cost2.jpg +0 -0
  78. data/spec/samples/syst/cost2.txt +4955 -0
  79. data/spec/samples/syst/cost3.jpg +0 -0
  80. data/spec/samples/syst/cost3.txt +4955 -0
  81. data/spec/samples/syst/cost4.jpg +0 -0
  82. data/spec/samples/syst/cost4.txt +4955 -0
  83. data/spec/samples/syst/dald0.jpg +0 -0
  84. data/spec/samples/syst/dald0.txt +4955 -0
  85. data/spec/samples/syst/dald1.jpg +0 -0
  86. data/spec/samples/syst/dald1.txt +4955 -0
  87. data/spec/samples/syst/dald2.jpg +0 -0
  88. data/spec/samples/syst/dald2.txt +4955 -0
  89. data/spec/samples/syst/dald3.jpg +0 -0
  90. data/spec/samples/syst/dald3.txt +4955 -0
  91. data/spec/samples/syst/dald4.jpg +0 -0
  92. data/spec/samples/syst/dald4.txt +4955 -0
  93. data/spec/samples/syst/dign0.jpg +0 -0
  94. data/spec/samples/syst/dign0.txt +4955 -0
  95. data/spec/samples/syst/dign1.jpg +0 -0
  96. data/spec/samples/syst/dign1.txt +4955 -0
  97. data/spec/samples/syst/dign2.jpg +0 -0
  98. data/spec/samples/syst/dign2.txt +4955 -0
  99. data/spec/samples/syst/dive0.jpg +0 -0
  100. data/spec/samples/syst/dive0.txt +4955 -0
  101. data/spec/samples/syst/dive1.jpg +0 -0
  102. data/spec/samples/syst/dive1.txt +4955 -0
  103. data/spec/samples/syst/dive2.jpg +0 -0
  104. data/spec/samples/syst/dive2.txt +4955 -0
  105. data/spec/samples/syst/histo.m +42 -0
  106. data/spec/samples/syst/out0000.jpg +0 -0
  107. data/spec/samples/syst/out0000.txt +4955 -0
  108. data/spec/samples/syst/out0001.jpg +0 -0
  109. data/spec/samples/syst/out0001.txt +4955 -0
  110. data/spec/samples/syst/out0002.jpg +0 -0
  111. data/spec/samples/syst/out0002.txt +4955 -0
  112. data/spec/samples/syst/qzc013.jpg +0 -0
  113. data/spec/samples/syst/qzc013.txt +4955 -0
  114. data/spec/samples/syst/sample_gray.jpg +0 -0
  115. data/spec/samples/syst/sample_gray.txt +4955 -0
  116. data/spec/samples/syst_grid.yml +53 -0
  117. data/spec/spec_helper.rb +18 -10
  118. data/test_reg.m +39 -0
  119. metadata +105 -8
  120. data/spec/samples/io.jpg +0 -0
@@ -0,0 +1,53 @@
1
+ page_size:
2
+ width: 210
3
+ height: 297
4
+ reg_marks:
5
+ margin: 10
6
+ radius: 2.5
7
+ offset: 2
8
+ crop: 30
9
+ blur: 2
10
+ dilate: 5
11
+ header:
12
+ name:
13
+ top: 5
14
+ left: 7.5
15
+ width: 170
16
+ size: 14
17
+ title:
18
+ top: 15
19
+ left: 7.5
20
+ width: 180
21
+ size: 12
22
+ code:
23
+ top: 5
24
+ left: 165
25
+ width: 20
26
+ size: 14
27
+ signature:
28
+ top: 30
29
+ left: 7.5
30
+ width: 120
31
+ height: 15
32
+ size: 7
33
+ box: true
34
+ items:
35
+ top: 55.5
36
+ left: 10.5
37
+ columns: 4
38
+ column_width: 44
39
+ rows: 30
40
+ x_spacing: 7
41
+ y_spacing: 7
42
+ cell_width: 6
43
+ cell_height: 5
44
+ max_cells: 5
45
+ font_size: 9
46
+ number_width: 8
47
+ number_margin: 2
48
+ barcode:
49
+ bits: 40
50
+ left: 15
51
+ width: 3
52
+ height: 2.5
53
+ spacing: 4
data/spec/spec_helper.rb CHANGED
@@ -2,55 +2,63 @@ require 'mork'
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.filter_run focus: true
5
+ config.filter_run_excluding exclude: true
5
6
  config.run_all_when_everything_filtered = true
6
7
  config.expect_with :rspec do |c|
7
8
  c.syntax = [:should, :expect]
8
9
  end
9
10
  end
10
11
 
12
+ RSpec::Matchers.define :have_coords do |x, y, w, h|
13
+ match do |coord|
14
+ coord.x == x and coord.y == y and coord.w == w and coord.h == h
15
+ end
16
+ end
17
+
11
18
  class SampleImager
12
19
  attr_reader :info
13
-
20
+
14
21
  def initialize(which)
15
22
  ya = YAML.load_file("./spec/samples/info.yml")
16
23
  @info = ya[which.to_s]
17
24
  end
18
-
25
+
19
26
  def grid_file
20
27
  @info["grid-file"]
21
28
  end
22
-
29
+
23
30
  def reg_marks
24
31
  @info["reg-marks"]
25
32
  end
26
-
33
+
27
34
  def q_boxes
28
35
  @info["q-boxes"]
29
36
  end
30
-
37
+
31
38
  def barcode_string
32
39
  @info["barcode-string"]
33
40
  end
34
-
41
+
35
42
  def barcode_int
36
43
  @info["barcode-int"]
37
44
  end
38
-
45
+
39
46
  def filename
40
47
  @info["filename"]
41
48
  end
42
-
49
+
43
50
  def width
44
51
  @info["width"]
45
52
  end
46
-
53
+
47
54
  def height
48
55
  @info["height"]
49
56
  end
50
-
57
+
51
58
  def pages
52
59
  @info["pages"]
53
60
  end
61
+
54
62
  end
55
63
 
56
64
  def sample_img(which)
data/test_reg.m ADDED
@@ -0,0 +1,39 @@
1
+ clear
2
+
3
+ i = imread('./spec/samples/angolo.jpg');
4
+ ig = 255 - rgb2gray(i);
5
+
6
+ % the horizontal signal
7
+ hs = sum(ig, 1);
8
+ % the vertical signal
9
+ vs = sum(ig, 2);
10
+
11
+ % kernel half size, to be determined
12
+ khs = 15;
13
+ % kernel X axis
14
+ x = -khs:khs;
15
+ % kernel full size
16
+ ksize = length(x);
17
+ % KERNEL
18
+ y=sqrt(khs^2 - x.^2);
19
+
20
+ % image YX sizes
21
+ [vp, hp] = size(ig);
22
+
23
+ xmin = nan(1, hp);
24
+ ymin = nan(1, vp);
25
+
26
+ for i = 1:hp-ksize;
27
+ tx = hs(i:i+ksize-1); % the X values for the current step
28
+ y=sqrt(khs^2 - x.^2)/khs*max(tx);
29
+ xmin(i+khs) = sum((hs(i:i+ksize-1)-y ) .^ 2);
30
+ % ymin(i+khs) = sum((vs(i:i+ksize-1)-y') .^ 2);
31
+ end
32
+
33
+ % plot(1:hp, [hs; xmin])
34
+ plot(1:hp, xmin)
35
+
36
+ cx = find(xmin==nanmin(xmin));
37
+ cy = find(ymin==nanmin(ymin));
38
+ fprintf('X: %d; Y: %d\n', cx, cy);
39
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giuseppe Bertini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '4.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '4.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: prawn
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '2.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -153,11 +153,13 @@ files:
153
153
  - Rakefile
154
154
  - auto.txt
155
155
  - lib/mork.rb
156
+ - lib/mork/coord.rb
156
157
  - lib/mork/extensions.rb
157
158
  - lib/mork/grid.rb
158
159
  - lib/mork/grid_const.rb
159
160
  - lib/mork/grid_omr.rb
160
161
  - lib/mork/grid_pdf.rb
162
+ - lib/mork/magicko.rb
161
163
  - lib/mork/mimage.rb
162
164
  - lib/mork/mimage_list.rb
163
165
  - lib/mork/npatch.rb
@@ -165,21 +167,33 @@ files:
165
167
  - lib/mork/sheet_pdf.rb
166
168
  - lib/mork/version.rb
167
169
  - mork.gemspec
170
+ - mork.sublime-project
171
+ - spec/mork/coord_spec.rb
168
172
  - spec/mork/extensions_spec.rb
169
173
  - spec/mork/grid_omr_spec.rb
170
174
  - spec/mork/grid_spec.rb
175
+ - spec/mork/magicko_spec.rb
171
176
  - spec/mork/mimage_list_spec.rb
172
177
  - spec/mork/mimage_spec.rb
173
178
  - spec/mork/npatch_spec.rb
174
179
  - spec/mork/sheet_omr_spec.rb
175
180
  - spec/mork/sheet_pdf_spec.rb
176
181
  - spec/out/.gitignore
182
+ - spec/samples/angolo.jpg
183
+ - spec/samples/grid.yml
177
184
  - spec/samples/grid160.yml
178
185
  - spec/samples/info.yml
179
- - spec/samples/io.jpg
180
186
  - spec/samples/layout.yml
187
+ - spec/samples/lucrezia/border1.pdf
188
+ - spec/samples/lucrezia/border2.pdf
189
+ - spec/samples/lucrezia/bw1.pdf
190
+ - spec/samples/lucrezia/bw2.pdf
191
+ - spec/samples/lucrezia/gray1.pdf
192
+ - spec/samples/lucrezia/gray2.pdf
193
+ - spec/samples/out-1.jpg
181
194
  - spec/samples/qzc013.jpg
182
195
  - spec/samples/reg_mark.jpg
196
+ - spec/samples/rm00.jpeg
183
197
  - spec/samples/rm01.jpeg
184
198
  - spec/samples/rm02.jpeg
185
199
  - spec/samples/rm03.jpeg
@@ -189,8 +203,91 @@ files:
189
203
  - spec/samples/sample_gray.jpg
190
204
  - spec/samples/sheet.jpg
191
205
  - spec/samples/sheet666.jpg
206
+ - spec/samples/slanted.jpg
207
+ - spec/samples/slanted.yml
208
+ - spec/samples/syst/IMG_20150104_0004.jpg
209
+ - spec/samples/syst/IMG_20150104_0004.txt
210
+ - spec/samples/syst/IMG_20150104_0009.jpg
211
+ - spec/samples/syst/IMG_20150104_0009.txt
212
+ - spec/samples/syst/IMG_20150104_0011.jpg
213
+ - spec/samples/syst/IMG_20150104_0011.txt
214
+ - spec/samples/syst/SCN_0001.jpg
215
+ - spec/samples/syst/SCN_0001.txt
216
+ - spec/samples/syst/barr0.jpg
217
+ - spec/samples/syst/barr0.txt
218
+ - spec/samples/syst/barr1.jpg
219
+ - spec/samples/syst/barr1.txt
220
+ - spec/samples/syst/barr2.jpg
221
+ - spec/samples/syst/barr2.txt
222
+ - spec/samples/syst/bell0.jpg
223
+ - spec/samples/syst/bell0.txt
224
+ - spec/samples/syst/bell1.jpg
225
+ - spec/samples/syst/bell1.txt
226
+ - spec/samples/syst/bell2.jpg
227
+ - spec/samples/syst/bell2.txt
228
+ - spec/samples/syst/bila0.jpg
229
+ - spec/samples/syst/bila0.txt
230
+ - spec/samples/syst/bila1.jpg
231
+ - spec/samples/syst/bila1.txt
232
+ - spec/samples/syst/bila2.jpg
233
+ - spec/samples/syst/bila2.txt
234
+ - spec/samples/syst/bila3.jpg
235
+ - spec/samples/syst/bila3.txt
236
+ - spec/samples/syst/bila4.jpg
237
+ - spec/samples/syst/bila4.txt
238
+ - spec/samples/syst/bone0.jpg
239
+ - spec/samples/syst/bone0.txt
240
+ - spec/samples/syst/bone1.jpg
241
+ - spec/samples/syst/bone1.txt
242
+ - spec/samples/syst/bone2.jpg
243
+ - spec/samples/syst/bone2.txt
244
+ - spec/samples/syst/cost0.jpg
245
+ - spec/samples/syst/cost0.txt
246
+ - spec/samples/syst/cost1.jpg
247
+ - spec/samples/syst/cost1.txt
248
+ - spec/samples/syst/cost2.jpg
249
+ - spec/samples/syst/cost2.txt
250
+ - spec/samples/syst/cost3.jpg
251
+ - spec/samples/syst/cost3.txt
252
+ - spec/samples/syst/cost4.jpg
253
+ - spec/samples/syst/cost4.txt
254
+ - spec/samples/syst/dald0.jpg
255
+ - spec/samples/syst/dald0.txt
256
+ - spec/samples/syst/dald1.jpg
257
+ - spec/samples/syst/dald1.txt
258
+ - spec/samples/syst/dald2.jpg
259
+ - spec/samples/syst/dald2.txt
260
+ - spec/samples/syst/dald3.jpg
261
+ - spec/samples/syst/dald3.txt
262
+ - spec/samples/syst/dald4.jpg
263
+ - spec/samples/syst/dald4.txt
264
+ - spec/samples/syst/dign0.jpg
265
+ - spec/samples/syst/dign0.txt
266
+ - spec/samples/syst/dign1.jpg
267
+ - spec/samples/syst/dign1.txt
268
+ - spec/samples/syst/dign2.jpg
269
+ - spec/samples/syst/dign2.txt
270
+ - spec/samples/syst/dive0.jpg
271
+ - spec/samples/syst/dive0.txt
272
+ - spec/samples/syst/dive1.jpg
273
+ - spec/samples/syst/dive1.txt
274
+ - spec/samples/syst/dive2.jpg
275
+ - spec/samples/syst/dive2.txt
276
+ - spec/samples/syst/histo.m
277
+ - spec/samples/syst/out0000.jpg
278
+ - spec/samples/syst/out0000.txt
279
+ - spec/samples/syst/out0001.jpg
280
+ - spec/samples/syst/out0001.txt
281
+ - spec/samples/syst/out0002.jpg
282
+ - spec/samples/syst/out0002.txt
283
+ - spec/samples/syst/qzc013.jpg
284
+ - spec/samples/syst/qzc013.txt
285
+ - spec/samples/syst/sample_gray.jpg
286
+ - spec/samples/syst/sample_gray.txt
287
+ - spec/samples/syst_grid.yml
192
288
  - spec/samples/two_pages.pdf
193
289
  - spec/spec_helper.rb
290
+ - test_reg.m
194
291
  homepage: https://github.com/giuseb/mork
195
292
  licenses:
196
293
  - MIT
@@ -211,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
308
  version: '0'
212
309
  requirements: []
213
310
  rubyforge_project:
214
- rubygems_version: 2.2.2
311
+ rubygems_version: 2.5.1
215
312
  signing_key:
216
313
  specification_version: 4
217
314
  summary: Optical mark recognition of multiple-choice tests and surveys
data/spec/samples/io.jpg DELETED
Binary file