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
@@ -2,49 +2,45 @@ require 'spec_helper'
2
2
 
3
3
  module Mork
4
4
  describe NPatch do
5
- let(:rm) { NPatch.new 'spec/samples/rm01.jpeg', 134, 104 }
6
-
7
- describe ".new" do
8
- it "should create an NPatch" do
9
- expect(rm).to be_an NPatch
5
+ describe '#centroid' do
6
+ it 'computes centers for rm0X' do
7
+ np = make 'spec/samples/rm01.jpeg', 134, 104
8
+ expect(np.centroid[0]).to eq 50
9
+ expect(np.centroid[1]).to eq 60
10
+ np = make 'spec/samples/rm02.jpeg', 114, 117
11
+ expect(np.centroid[0]).to eq 69
12
+ expect(np.centroid[1]).to eq 71
13
+ np = make 'spec/samples/rm03.jpeg', 124, 105
14
+ expect(np.centroid[0]).to eq 71
15
+ expect(np.centroid[1]).to eq 61
16
+ np = make 'spec/samples/rm04.jpeg', 144, 117
17
+ expect(np.centroid[0]).to eq 84
18
+ expect(np.centroid[1]).to eq 52
19
+ np = make 'spec/samples/rm05.jpeg', 144, 117
20
+ expect(np.centroid[0]).to eq 84
21
+ expect(np.centroid[1]).to eq 52
10
22
  end
11
23
  end
12
-
13
- describe '#dark_centroid' do
14
- it 'computes centers for rm01' do
15
- np = NPatch.new 'spec/samples/rm01.jpeg', 134, 104
16
- expect(np.dark_centroid).to eq [50, 60]
17
- np = NPatch.new 'spec/samples/rm02.jpeg', 114, 117
18
- expect(np.dark_centroid).to eq [69, 71]
19
- np = NPatch.new 'spec/samples/rm03.jpeg', 124, 105
20
- expect(np.dark_centroid).to eq [71, 61]
21
- np = NPatch.new 'spec/samples/rm04.jpeg', 144, 117
22
- expect(np.dark_centroid).to eq [84, 52]
23
- np = NPatch.new 'spec/samples/rm05.jpeg', 144, 117
24
- expect(np.dark_centroid).to eq [84, 52]
24
+
25
+ describe '#average' do
26
+ it 'works' do
27
+ np = make 'spec/samples/rm00.jpeg', 100, 100
28
+ expect(np.average Coord.new(100)).to be_within(1).of(234)
25
29
  end
26
30
  end
27
-
28
- describe '#average' do
31
+
32
+ describe '#stddev' do
29
33
  it 'works' do
30
- c = {x: 30, y: 35, w: 46, h: 46}
31
- puts rm.average c
32
- c = {x: 85, y: 10, w: 46, h: 46}
33
- puts rm.average c
34
+ np = make 'spec/samples/rm00.jpeg', 100, 100
35
+ expect(np.stddev Coord.new(100)).to be_within(1).of(53)
34
36
  end
35
37
  end
36
-
37
- # describe "#dark_centroid" do
38
- # it "should return the correct X" do
39
- # x, y = NPatch.new(mim).dark_centroid
40
- # x.should == rgm.info["centroid_x"]
41
- # end
42
- #
43
- # it "should return the correct Y" do
44
- # x, y = NPatch.new(mim).dark_centroid
45
- # y.should == rgm.info["centroid_y"]
46
- # end
47
- # end
38
+
39
+ def make(fname, w, h)
40
+ b = IO.read("|convert #{fname} gray:-").unpack 'C*'
41
+ NPatch.new b, w, h
42
+ end
43
+
48
44
  end
49
45
  end
50
46
 
@@ -54,22 +50,33 @@ end
54
50
  # x.should be_within(2).of(smp.reg_marks["tl_x"])
55
51
  # y.should be_within(2).of(smp.reg_marks["tl_y"])
56
52
  # end
57
- #
53
+ #
58
54
  # it "returns the actual xy offset of the tr registration mark" do
59
55
  # x, y = mim.dark_centroid_on({x: smp.width-180, y: 0, w: 180, h: 180})
60
56
  # x.should be_within(2).of(smp.reg_marks["tr_x"])
61
57
  # y.should be_within(2).of(smp.reg_marks["tr_y"])
62
58
  # end
63
- #
59
+ #
64
60
  # it "returns the actual xy offset of the br registration mark" do
65
61
  # x, y = mim.dark_centroid_on({x: smp.width-180, y: smp.height-180, w: 180, h: 180})
66
62
  # x.should be_within(2).of(smp.reg_marks["br_x"])
67
63
  # y.should be_within(2).of(smp.reg_marks["br_y"])
68
64
  # end
69
- #
65
+ #
70
66
  # it "returns the actual xy offset of the bl registration mark" do
71
67
  # x, y = mim.dark_centroid_on({x: 0, y: smp.height-180, w: 180, h: 180})
72
68
  # x.should be_within(2).of(smp.reg_marks["bl_x"])
73
69
  # y.should be_within(2).of(smp.reg_marks["bl_y"])
74
70
  # end
75
71
  # end
72
+
73
+ # let(:impath) { 'spec/samples/rm01.jpeg' }
74
+ # let(:imbytes) { IO.read("|convert #{impath} gray:-").unpack 'C*' }
75
+ # let(:rm) { NPatch.new imbytes, 134, 104 }
76
+
77
+ # describe ".new" do
78
+ # it "should create an NPatch" do
79
+ # expect(rm).to be_an NPatch
80
+ # end
81
+ # end
82
+
@@ -3,6 +3,23 @@ require 'fileutils'
3
3
 
4
4
  module Mork
5
5
  describe SheetOMR do
6
+ context 'basic object generation' do
7
+ let(:img) { sample_img 'slanted' }
8
+ let(:omr) { SheetOMR.new img.filename, [5] * 120, img.grid_file }
9
+ describe '#new' do
10
+ it 'raises an error if the provided path is invalid' do
11
+ expect { SheetOMR.new 'non_existing_file.jpg'}.to raise_error IOError
12
+ end
13
+
14
+ it 'creates a SheetOMR object' do
15
+ expect(omr).to be_a SheetOMR
16
+ end
17
+
18
+ it 'registers correctly' do
19
+ expect(omr.valid?).to be_truthy
20
+ end
21
+ end
22
+ end
6
23
  # context 'problematic' do
7
24
  # let(:shinfo) { sample_img 'bianchi' }
8
25
  # let(:sheet) { SheetOMR.new shinfo.filename, shinfo.grid_file }
@@ -27,23 +44,40 @@ module Mork
27
44
  # end
28
45
  #
29
46
  # end
30
-
47
+ #
48
+ context 'slanted' do
49
+ let(:sh) { sample_img 'slanted' }
50
+ let(:sheet) { SheetOMR.new sh.filename, [5]*120, sh.grid_file }
51
+
52
+ it 'gets in trouble' do
53
+ sheet.write_registration 'spec/out/laurout.jpg'
54
+ end
55
+
56
+ it 'gets more in trouble' do
57
+ sheet.highlight_marked
58
+ sheet.write 'spec/out/lauraout2.jpg'
59
+ end
60
+
61
+ it 'should be valid' do
62
+ expect(sheet.valid?).to be_truthy
63
+ end
64
+ end
65
+
31
66
  context 'highlighting' do
32
67
  # since these specs change the @crop, they must be run in isolation
33
68
  # with the SheetOMR rebuilt each time, even though it is time consuming!
34
69
  let(:shinfo) { sample_img 'sample-gray' }
35
- let(:sheet) { SheetOMR.new shinfo.filename, [5]*100, shinfo.grid_file }
36
-
37
- it 'highlights the registration areas and frame' do
38
- sheet.highlight_registration
39
- sheet.write_raw 'spec/out/reg_areas.jpg'
70
+ let(:sheet) { SheetOMR.new shinfo.filename, [5]*120, shinfo.grid_file }
71
+
72
+ it 'writes the sheet with registrations highlighted' do
73
+ sheet.write_registration 'spec/out/sample_gray_registered.jpg'
40
74
  end
41
-
75
+
42
76
  it 'highlights all choice cells' do
43
77
  sheet.highlight_all_choices
44
78
  sheet.write 'spec/out/all_highlights.jpg'
45
79
  end
46
-
80
+
47
81
  it 'highlights marked cells' do
48
82
  sheet.highlight_marked
49
83
  sheet.write 'spec/out/marked_highlights.jpg'
@@ -83,7 +117,7 @@ module Mork
83
117
  s.highlight_marked
84
118
  s.write 'spec/out/problem.jpg'
85
119
  end
86
-
120
+
87
121
  it 'highlights the barcode' do
88
122
  si = sample_img 'sample-gray'
89
123
  s = SheetOMR.new si.filename, [5]*100, si.grid_file
@@ -91,26 +125,26 @@ module Mork
91
125
  s.write 'spec/out/code_bits.jpg'
92
126
  end
93
127
  end
94
-
128
+
95
129
  context 'marking a nicely printed and scanned sheet' do
96
130
  before(:all) do
97
131
  @shinfo = sample_img 'sample-gray'
98
132
  @sheet = SheetOMR.new @shinfo.filename, [5]*120, @shinfo.grid_file
99
133
  end
100
-
134
+
101
135
  describe '#valid?' do
102
136
  it 'returns true' do
103
137
  @sheet.valid?.should be_truthy
104
138
  end
105
139
  end
106
-
140
+
107
141
  describe '#marked?' do
108
142
  it 'returns true for some darkened choices' do
109
143
  expect(@sheet.marked?(0,0)).to be_truthy
110
144
  expect(@sheet.marked?(1,1)).to be_truthy
111
145
  expect(@sheet.marked?(2,2)).to be_truthy
112
146
  end
113
-
147
+
114
148
  it 'return false for some blank choices' do
115
149
  expect(@sheet.marked?(0,1)).to be_falsy
116
150
  expect(@sheet.marked?(1,0)).to be_falsy
@@ -154,13 +188,13 @@ module Mork
154
188
  ]
155
189
  end
156
190
  end
157
-
191
+
158
192
  describe 'barcodes' do
159
193
  it 'should read the bit string as all ones' do
160
194
  @sheet.barcode_string.should == '1111111111111111111111111111111111111111'
161
195
  @sheet.barcode.should == 1099511627775
162
196
  end
163
-
197
+
164
198
  it 'should read another bit string' do
165
199
  barcode_string = '0000000000000000000000000010000110100000'
166
200
  s2 = SheetOMR.new('spec/samples/sample02.jpg', [5]*100)
@@ -174,18 +208,16 @@ module Mork
174
208
  s2.barcode.should == sh.barcode_int
175
209
  end
176
210
  end
177
-
211
+
178
212
  end
179
-
213
+
180
214
  context 'marking a problematic sheet' do
181
215
  let(:sheet) { SheetOMR.new 'spec/samples/out-1.jpg', [5]*100, 'spec/samples/grid.yml' }
182
-
183
- it 'highlights marked cells and outline correct responses' do
184
- sheet.cross_marked
185
- sheet.outline [[0,1,2,3,4]] * 100
186
- sheet.write 'spec/out/marks_and_outs.jpg'
216
+
217
+ it 'highlights the registration' do
218
+ sheet.write_registration 'spec/out/problematic.jpg'
187
219
  end
188
-
220
+
189
221
  it 'highlights the barcode' do
190
222
  sheet.highlight_barcode
191
223
  sheet.write 'spec/out/barcode.jpg'
@@ -194,32 +226,38 @@ module Mork
194
226
 
195
227
  context 'systematic tests' do
196
228
  let(:bila) { 'CCEBEBCEEACCDCABDBEBCADEADDCCCACCACDBBDAECDDABDEEBCEEDCBAAADEEEEDCADEABCBDECCCCDDDCABBECAADADBBEEABA'.split '' }
197
- let(:bila0) { SheetOMR.new 'spec/samples/syst/bila0.jpg', [5]*100, 'spec/samples/grid.yml'}
198
- let(:bila1) { SheetOMR.new 'spec/samples/syst/bila1.jpg', [5]*100, 'spec/samples/grid.yml'}
199
- let(:bila2) { SheetOMR.new 'spec/samples/syst/bila2.jpg', [5]*100, 'spec/samples/grid.yml'}
200
- let(:bila3) { SheetOMR.new 'spec/samples/syst/bila3.jpg', [5]*100, 'spec/samples/grid.yml'}
229
+ let(:bila0) { SheetOMR.new 'spec/samples/syst/bila0.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
230
+ let(:bila1) { SheetOMR.new 'spec/samples/syst/bila1.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
231
+ let(:bila2) { SheetOMR.new 'spec/samples/syst/bila2.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
232
+ let(:bila3) { SheetOMR.new 'spec/samples/syst/bila3.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
233
+ let(:bila4) { SheetOMR.new 'spec/samples/syst/bila4.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
201
234
  let(:dald) { 'DDDBECAAADBAEEEAEEEBAACAEDBDECDBDCDCDDEDCCDCDBDCADEEDBCCBEBBAADDCDBBECBBBDEABADABADADBABAEABACBDADDA'.split '' }
202
- let(:dald0) { SheetOMR.new 'spec/samples/syst/dald0.jpg', [5]*100, 'spec/samples/grid.yml'}
203
- let(:dald1) { SheetOMR.new 'spec/samples/syst/dald1.jpg', [5]*100, 'spec/samples/grid.yml'}
204
- let(:dald2) { SheetOMR.new 'spec/samples/syst/dald2.jpg', [5]*100, 'spec/samples/grid.yml'}
205
- let(:dald3) { SheetOMR.new 'spec/samples/syst/dald3.jpg', [5]*100, 'spec/samples/grid.yml'}
235
+ let(:dald0) { SheetOMR.new 'spec/samples/syst/dald0.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
236
+ let(:dald1) { SheetOMR.new 'spec/samples/syst/dald1.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
237
+ let(:dald2) { SheetOMR.new 'spec/samples/syst/dald2.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
238
+ let(:dald3) { SheetOMR.new 'spec/samples/syst/dald3.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
239
+ let(:dald4) { SheetOMR.new 'spec/samples/syst/dald4.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
206
240
  let(:cost) { 'ABBDDBAEAEBAADEAAECBCDBBDABABADEECCACBCAEDDAEBEABBCDABECAACEEEBADECBBEAADBBBEABDAEBDEEABBABEBEDDAEEC'.split '' }
207
- let(:cost0) { SheetOMR.new 'spec/samples/syst/cost0.jpg', [5]*100, 'spec/samples/grid.yml'}
208
- let(:cost1) { SheetOMR.new 'spec/samples/syst/cost1.jpg', [5]*100, 'spec/samples/grid.yml'}
209
- let(:cost2) { SheetOMR.new 'spec/samples/syst/cost2.jpg', [5]*100, 'spec/samples/grid.yml'}
210
- let(:cost3) { SheetOMR.new 'spec/samples/syst/cost3.jpg', [5]*100, 'spec/samples/grid.yml'}
241
+ let(:cost0) { SheetOMR.new 'spec/samples/syst/cost0.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
242
+ let(:cost1) { SheetOMR.new 'spec/samples/syst/cost1.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
243
+ let(:cost2) { SheetOMR.new 'spec/samples/syst/cost2.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
244
+ let(:cost3) { SheetOMR.new 'spec/samples/syst/cost3.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
245
+ let(:cost4) { SheetOMR.new 'spec/samples/syst/cost4.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
211
246
  let(:bone) { 'CECBBABAECADEDCACBBDEECBADBECDCEDECABCAADCBDEDACAEEDCCADBEDCEBCCBBDCCACDEDDAAECEBDBADCBAAEBAEDABCBDC'.split '' }
212
- let(:bone0) { SheetOMR.new 'spec/samples/syst/bone0.jpg', [5]*100, 'spec/samples/grid.yml'}
213
- let(:bone1) { SheetOMR.new 'spec/samples/syst/bone1.jpg', [5]*100, 'spec/samples/grid.yml'}
247
+ let(:bone0) { SheetOMR.new 'spec/samples/syst/bone0.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
248
+ let(:bone1) { SheetOMR.new 'spec/samples/syst/bone1.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
249
+ let(:bone2) { SheetOMR.new 'spec/samples/syst/bone2.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
214
250
  let(:barr) { 'ACECAAADDBCECCCDBEBECDEDAECEDDEEDCDEADDCCBCCCBBEACBCAEDEEDDDABBBBABEBDCEADEEDEBCBADBCEDCDBACEBCBDCDA'.split '' }
215
- let(:barr0) { SheetOMR.new 'spec/samples/syst/barr0.jpg', [5]*100, 'spec/samples/grid.yml'}
216
- let(:barr1) { SheetOMR.new 'spec/samples/syst/barr1.jpg', [5]*100, 'spec/samples/grid.yml'}
217
-
251
+ let(:barr0) { SheetOMR.new 'spec/samples/syst/barr0.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
252
+ let(:barr1) { SheetOMR.new 'spec/samples/syst/barr1.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
253
+ let(:barr2) { SheetOMR.new 'spec/samples/syst/barr2.jpg', [5]*100, 'spec/samples/syst_grid.yml'}
254
+
218
255
  it 'checks bila' do
219
256
  expect(bila0.mark_char_array.flatten).to eq(bila)
220
257
  expect(bila1.mark_char_array.flatten).to eq(bila)
221
258
  expect(bila2.mark_char_array.flatten).to eq(bila)
222
259
  expect(bila3.mark_char_array.flatten).to eq(bila)
260
+ expect(bila4.mark_char_array.flatten).to eq(bila)
223
261
  end
224
262
 
225
263
  it 'checks dald' do
@@ -227,6 +265,7 @@ module Mork
227
265
  expect(dald1.mark_char_array.flatten).to eq(dald)
228
266
  expect(dald2.mark_char_array.flatten).to eq(dald)
229
267
  expect(dald3.mark_char_array.flatten).to eq(dald)
268
+ expect(dald4.mark_char_array.flatten).to eq(dald)
230
269
  end
231
270
 
232
271
  it 'checks cost' do
@@ -234,16 +273,19 @@ module Mork
234
273
  expect(cost1.mark_char_array.flatten).to eq(cost)
235
274
  expect(cost2.mark_char_array.flatten).to eq(cost)
236
275
  expect(cost3.mark_char_array.flatten).to eq(cost)
276
+ expect(cost4.mark_char_array.flatten).to eq(cost)
237
277
  end
238
278
 
239
279
  it 'checks bone' do
240
280
  expect(bone0.mark_char_array.flatten).to eq(bone)
241
281
  expect(bone1.mark_char_array.flatten).to eq(bone)
282
+ expect(bone2.mark_char_array.flatten).to eq(bone)
242
283
  end
243
284
 
244
285
  it 'checks barr' do
245
286
  expect(barr0.mark_char_array.flatten).to eq(barr)
246
287
  expect(barr1.mark_char_array.flatten).to eq(barr)
288
+ expect(barr2.mark_char_array.flatten).to eq(barr)
247
289
  end
248
290
 
249
291
  end
@@ -19,16 +19,16 @@ module Mork
19
19
  s = SheetPDF.new(content)
20
20
  s.instance_variable_get('@grip').should be_a GridPDF
21
21
  end
22
-
22
+
23
23
  it 'creates a grid by loading the specified file' do
24
24
  s = SheetPDF.new(content, 'spec/samples/layout.yml')
25
25
  s.instance_variable_get('@grip').should be_a GridPDF
26
26
  end
27
-
27
+
28
28
  it 'raises an error with an invalid init parameter' do
29
- lambda { SheetPDF.new(content, 2) }.should raise_error 'Invalid initialization parameter'
29
+ lambda { SheetPDF.new(content, 2) }.should raise_error ArgumentError
30
30
  end
31
-
31
+
32
32
  it 'assigns an array to @content' do
33
33
  s = SheetPDF.new(content)
34
34
  s.instance_variable_get('@content').should be_an Array
@@ -43,17 +43,17 @@ module Mork
43
43
  s = SheetPDF.new(content)
44
44
  s.save('spec/out/sheet.pdf')
45
45
  end
46
-
46
+
47
47
  it 'creates a basic PDF sheet with a code of 15' do
48
48
  s = SheetPDF.new(content.merge({barcode: 15}))
49
49
  s.save('spec/out/sheet16.pdf')
50
50
  end
51
-
51
+
52
52
  it 'creates a basic PDF sheet with a code of 666666666666' do
53
53
  s = SheetPDF.new(content.merge({barcode: 666666666666}))
54
54
  s.save('spec/out/sheet666.pdf')
55
55
  end
56
-
56
+
57
57
  it 'creates a PDF sheet with the maximum possible barcode' do
58
58
  s = SheetPDF.new(content.merge({barcode: 1099511627775}))
59
59
  s.save('spec/out/maxcode.pdf')
@@ -62,7 +62,7 @@ module Mork
62
62
  it 'creates a PDF sheet with 160 items' do
63
63
  s = SheetPDF.new(content.merge({choices: [5] * 160}), 'spec/samples/grid160.yml')
64
64
  s.save('spec/out/i160.pdf')
65
- system 'open spec/out/i160.pdf'
65
+ # system 'open spec/out/i160.pdf'
66
66
  end
67
67
 
68
68
  it 'creates a PDF sheet with unequal choices per item' do
Binary file
@@ -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: 12
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
@@ -1,3 +1,13 @@
1
+ slanted:
2
+ filename: spec/samples/slanted.jpg
3
+ grid-file: spec/samples/slanted.yml
4
+ width: 1241
5
+ height: 1754
6
+ tl: [63, 67]
7
+ tr: [1172, 68]
8
+ br: [1169, 1704]
9
+ bl: [55, 1702]
10
+
1
11
  code666:
2
12
  filename: spec/samples/sheet666.jpg
3
13
  grid-file: spec/samples/layout.yml
@@ -13,15 +23,6 @@ sample-gray:
13
23
  width: 1654
14
24
  height: 2339
15
25
 
16
- bianchi:
17
- # filename: spec/samples/IMG_20150104_0005.jpg
18
- # filename: spec/samples/out0000.jpg
19
- # filename: spec/samples/SCN_0001.jpg
20
- # filename: spec/samples/IMG_20150104_0011.jpg
21
- # filename: spec/samples/IMG_20150104_0009.jpg
22
- grid-file: spec/samples/bianchi.yml
23
- barcode-int: 9350
24
-
25
26
  reg-mark:
26
27
  filename: spec/samples/reg_mark.jpg
27
28
  centroid-x: 92
@@ -32,7 +33,7 @@ small:
32
33
 
33
34
  code-sample:
34
35
  filename: spec/samples/code_sample.png
35
- code-string: "0000000000000000000000000000000000000000000000000001110001010001"
36
+ code-string: "0000000000000000000000000000000000000000000000000001110001010001"
36
37
  code-int: 7249
37
38
 
38
39
  code-zero:
@@ -41,4 +42,4 @@ code-zero:
41
42
  two-pages:
42
43
  filename: spec/samples/two_pages.pdf
43
44
  code-int: 17382938642823887837
44
-
45
+
@@ -1,13 +1,17 @@
1
1
  page_size: # all measurements in mm
2
2
  width: 210 # width of the paper sheet
3
3
  height: 297 # height of the paper sheet
4
- reg_marks:
4
+ reg_marks:
5
5
  margin: 10 # distance from each page border to registration mark center
6
6
  radius: 2.5 # registration mark radius
7
- search: 12 # initial size of the registration mark search area (*)
8
7
  offset: 2 # distance between the search area and each page border (*)
8
+ crop: 12
9
+ offset: 2
10
+ blur: 2
11
+ dilate: 5
9
12
 
10
- header:
13
+
14
+ header:
11
15
  name: # ‘name’ is just a label; you can add arbitrary header elements
12
16
  top: 5 # margin relative to registration frame top side
13
17
  left: 7.5 # margin relative to registration frame left side
@@ -35,14 +39,14 @@ items:
35
39
  left: 10.5 # response area margin, relative to reg frame
36
40
  rows: 30 # number of items per column
37
41
  columns: 4 # number of columns
38
- column_width: 44 #
42
+ column_width: 44 #
39
43
  x_spacing: 7 # horizontal distance between ajacent cell centers
40
44
  y_spacing: 7 # vertical distance between ajacent cell centers
41
45
  cell_width: 6 # width of each choice and calibration cell
42
46
  cell_height: 5 # height of each choice and calibration cell
43
47
  max_cells: 5 # maximum number of choices per item
44
48
  font_size: 9 # size of both the item number and choice cell letter
45
- number_width: 8 #
49
+ number_width: 8 #
46
50
  number_margin: 2 # margin between
47
51
  barcode:
48
52
  bits: 40 # the maximum sheet identifier is 2 to the power or bits
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,54 @@
1
+ page_size:
2
+ width: 210
3
+ height: 297
4
+ reg_marks:
5
+ margin: 10
6
+ radius: 2.5
7
+ crop: 12
8
+ offset: 2
9
+ blur: 2
10
+ dilate: 5
11
+
12
+ header:
13
+ name:
14
+ top: 5
15
+ left: 7.5
16
+ width: 170
17
+ size: 14
18
+ title:
19
+ top: 15
20
+ left: 7.5
21
+ width: 180
22
+ size: 12
23
+ code:
24
+ top: 5
25
+ left: 165
26
+ width: 20
27
+ size: 14
28
+ signature:
29
+ top: 30
30
+ left: 7.5
31
+ width: 120
32
+ height: 15
33
+ size: 7
34
+ box: true
35
+ items:
36
+ top: 55.5
37
+ left: 10.5
38
+ columns: 4
39
+ column_width: 44
40
+ rows: 30
41
+ x_spacing: 7
42
+ y_spacing: 7
43
+ cell_width: 6
44
+ cell_height: 5
45
+ max_cells: 5
46
+ font_size: 9
47
+ number_width: 8
48
+ number_margin: 2
49
+ barcode:
50
+ bits: 40
51
+ left: 15
52
+ width: 3
53
+ height: 2.5
54
+ spacing: 4