mork 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/auto.txt +0 -0
- data/lib/mork/grid_omr.rb +12 -5
- data/lib/mork/mimage.rb +163 -98
- data/lib/mork/mimage_list.rb +1 -1
- data/lib/mork/npatch.rb +56 -32
- data/lib/mork/sheet_omr.rb +23 -125
- data/lib/mork/version.rb +1 -1
- data/mork.gemspec +3 -3
- data/spec/mork/grid_omr_spec.rb +26 -23
- data/spec/mork/mimage_list_spec.rb +33 -33
- data/spec/mork/mimage_spec.rb +33 -32
- data/spec/mork/npatch_spec.rb +34 -11
- data/spec/mork/sheet_omr_spec.rb +34 -57
- data/spec/samples/info.yml +39 -39
- data/spec/samples/io.jpg +0 -0
- data/spec/samples/rm01.jpeg +0 -0
- data/spec/samples/rm02.jpeg +0 -0
- data/spec/samples/rm03.jpeg +0 -0
- data/spec/samples/rm04.jpeg +0 -0
- data/spec/samples/rm05.jpeg +0 -0
- data/spec/spec_helper.rb +22 -6
- metadata +12 -11
data/mork.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
# dependencies:
|
21
|
-
s.add_dependency 'narray',
|
22
|
-
s.add_dependency '
|
23
|
-
s.
|
21
|
+
s.add_dependency 'narray', '~> 0.6'
|
22
|
+
s.add_dependency 'mini_magick', '~> 3.8'
|
23
|
+
s.add_dependency 'prawn', '~> 1.3'
|
24
24
|
s.add_development_dependency 'rake', '~> 10.3'
|
25
25
|
s.add_development_dependency 'rspec', '~> 3.1'
|
26
26
|
s.add_development_dependency 'guard', '~> 2.6'
|
data/spec/mork/grid_omr_spec.rb
CHANGED
@@ -2,73 +2,76 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Mork
|
4
4
|
describe GridOMR do
|
5
|
-
|
5
|
+
before(:each) do
|
6
|
+
@grom = GridOMR.new 'spec/samples/layout.yml'
|
7
|
+
@grom.set_page_size 1601, 2281
|
8
|
+
end
|
6
9
|
|
7
10
|
describe '#choice_cell_area' do
|
8
11
|
it 'returns the coordinates of the first choice cell' do
|
9
|
-
grom.choice_cell_area(0,0).should == {x: 63, y: 436, w: 51, h: 41}
|
12
|
+
@grom.choice_cell_area(0,0).should == {x: 63, y: 436, w: 51, h: 41}
|
10
13
|
end
|
11
14
|
|
12
15
|
it 'returns the coordinates of the last choice cell' do
|
13
|
-
grom.choice_cell_area(119,4).should == {x: 1411, y: 2108, w: 51, h: 41}
|
16
|
+
@grom.choice_cell_area(119,4).should == {x: 1411, y: 2108, w: 51, h: 41}
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
describe '#barcode_bit_area' do
|
18
21
|
# it 'returns the coordinates of the first barcode bit area' do
|
19
|
-
# grom.barcode_bit_area(0).should == {x: 160, y: 2260, w: 25, h: 21}
|
22
|
+
# @grom.barcode_bit_area(0).should == {x: 160, y: 2260, w: 25, h: 21}
|
20
23
|
# end
|
21
24
|
#
|
22
25
|
# it 'returns the coordinates of the last barcode bit area' do
|
23
|
-
# grom.barcode_bit_area(39).should == {x: 1475, y: 2260, w: 25, h: 21}
|
26
|
+
# @grom.barcode_bit_area(39).should == {x: 1475, y: 2260, w: 25, h: 21}
|
24
27
|
# end
|
25
28
|
#
|
26
29
|
# it 'fails if an invalid barcode bit is requested' do
|
27
|
-
# lambda { grom.barcode_bit_area(40) }.should raise_error
|
30
|
+
# lambda { @grom.barcode_bit_area(40) }.should raise_error
|
28
31
|
# end
|
29
32
|
end
|
30
33
|
|
31
34
|
describe '#rm_search_area' do
|
32
35
|
context 'on the first iteration' do
|
33
36
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tl reg_mark corner' do
|
34
|
-
c = grom.rm_search_area :tl, 0
|
37
|
+
c = @grom.rm_search_area :tl, 0
|
35
38
|
c.should == {x: 15, y: 15, w: 91, h: 92}
|
36
39
|
end
|
37
40
|
|
38
41
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tr reg_mark corner' do
|
39
|
-
c = grom.rm_search_area :tr, 0
|
42
|
+
c = @grom.rm_search_area :tr, 0
|
40
43
|
c.should == { x: 1494, y: 15, w: 91, h: 92 }
|
41
44
|
end
|
42
45
|
|
43
46
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :br reg_mark corner' do
|
44
|
-
c = grom.rm_search_area :br, 0
|
47
|
+
c = @grom.rm_search_area :br, 0
|
45
48
|
c.should == { x: 1494, y: 2173, w: 91, h: 92 }
|
46
49
|
end
|
47
50
|
|
48
51
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :bl reg_mark corner' do
|
49
|
-
c = grom.rm_search_area :bl, 0
|
52
|
+
c = @grom.rm_search_area :bl, 0
|
50
53
|
c.should == { x: 15, y: 2173, w: 91, h: 92 }
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
57
|
context 'on the third iteration' do
|
55
58
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tl reg_mark corner' do
|
56
|
-
c = grom.rm_search_area :tl, 2
|
59
|
+
c = @grom.rm_search_area :tl, 2
|
57
60
|
c.should == { x: 15, y: 15, w: 130, h: 131 }
|
58
61
|
end
|
59
62
|
|
60
63
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tr reg_mark corner' do
|
61
|
-
c = grom.rm_search_area :tr, 2
|
64
|
+
c = @grom.rm_search_area :tr, 2
|
62
65
|
c.should == { x: 1456, y: 15, w: 130, h: 131 }
|
63
66
|
end
|
64
67
|
|
65
68
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :br reg_mark corner' do
|
66
|
-
c = grom.rm_search_area :br, 2
|
69
|
+
c = @grom.rm_search_area :br, 2
|
67
70
|
c.should == { x: 1456, y: 2135, w: 130, h: 131 }
|
68
71
|
end
|
69
72
|
|
70
73
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :bl reg_mark corner' do
|
71
|
-
c = grom.rm_search_area :bl, 2
|
74
|
+
c = @grom.rm_search_area :bl, 2
|
72
75
|
c.should == { x: 15, y: 2135, w: 130, h: 131 }
|
73
76
|
end
|
74
77
|
end
|
@@ -76,46 +79,46 @@ module Mork
|
|
76
79
|
|
77
80
|
describe '#rm_edgy_x' do
|
78
81
|
it 'returns the minimum acceptable number of pixels from the regmark center to the edge of the rm_search_area' do
|
79
|
-
grom.rm_edgy_x.should == 24
|
82
|
+
@grom.rm_edgy_x.should == 24
|
80
83
|
end
|
81
84
|
it 'returns an integer' do
|
82
|
-
grom.rm_edgy_x.should be_a Fixnum
|
85
|
+
@grom.rm_edgy_x.should be_a Fixnum
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
86
89
|
describe '#rm_edgy_y' do
|
87
90
|
it 'returns the minimum acceptable number of pixels from the regmark center to the edge of the rm_search_area' do
|
88
|
-
grom.rm_edgy_y.should == 24
|
91
|
+
@grom.rm_edgy_y.should == 24
|
89
92
|
end
|
90
93
|
it 'returns an integer' do
|
91
|
-
grom.rm_edgy_y.should be_a Fixnum
|
94
|
+
@grom.rm_edgy_y.should be_a Fixnum
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
95
98
|
describe '#rm_max_search_area_side' do
|
96
99
|
it 'returns the maximum extent of the regmark search area, 1/4 of the raw image horizontal pixels' do
|
97
|
-
grom.rm_max_search_area_side.should == 400
|
100
|
+
@grom.rm_max_search_area_side.should == 400
|
98
101
|
end
|
99
102
|
it 'returns an integer' do
|
100
|
-
grom.rm_max_search_area_side.should be_a Fixnum
|
103
|
+
@grom.rm_max_search_area_side.should be_a Fixnum
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
104
107
|
describe '#max_choices_per_question' do
|
105
108
|
it 'returns the maximum number of choice cells per question' do
|
106
|
-
grom.max_choices_per_question.should == 5
|
109
|
+
@grom.max_choices_per_question.should == 5
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
110
113
|
describe '#paper_white_area' do
|
111
114
|
it 'returns the coordinates of the white area used for barcode calibration' do
|
112
|
-
grom.paper_white_area.should == {x: 93, y: 2260, w: 25, h: 21}
|
115
|
+
@grom.paper_white_area.should == {x: 93, y: 2260, w: 25, h: 21}
|
113
116
|
end
|
114
117
|
end
|
115
118
|
|
116
119
|
describe '#ink_black_area' do
|
117
120
|
it 'returns the coordinates of the barcode calibration bar' do
|
118
|
-
grom.ink_black_area.should == {x: 126, y: 2260, w: 25, h: 21}
|
121
|
+
@grom.ink_black_area.should == {x: 126, y: 2260, w: 25, h: 21}
|
119
122
|
end
|
120
123
|
end
|
121
124
|
end
|
@@ -1,37 +1,37 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Mork
|
4
|
-
describe MimageList do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
4
|
+
# describe MimageList do
|
5
|
+
# before(:all) do
|
6
|
+
# tpg = sample_img(:two_pages)
|
7
|
+
# @mlist = MimageList.new(tpg.filename)
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# describe ".new" do
|
11
|
+
# it "should raise an error unless called with a string" do
|
12
|
+
# lambda {
|
13
|
+
# MimageList.new(666)
|
14
|
+
# }.should raise_error
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# describe "[]" do
|
19
|
+
# it "should return the 1st mimage in the stack" do
|
20
|
+
# @mlist[0].should be_a(Mimage)
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# it "should return the last mimage in the stack" do
|
24
|
+
# @mlist[1].should be_a(Mimage)
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# describe "each" do
|
29
|
+
# it "should loop over all images" do
|
30
|
+
# @mlist.each do |m|
|
31
|
+
# puts m.inspect
|
32
|
+
# m.should be_a(Mimage)
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
# end
|
37
37
|
end
|
data/spec/mork/mimage_spec.rb
CHANGED
@@ -2,46 +2,47 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Mork
|
4
4
|
describe Mimage do
|
5
|
-
let(:
|
6
|
-
let(:
|
5
|
+
let(:sgi) { sample_img 'sample-gray' }
|
6
|
+
let(:sg) { Mimage.new sgi.filename, GridOMR.new(sgi.grid_file) }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
|
8
|
+
describe 'basics' do
|
9
|
+
it 'returns the width' do
|
10
|
+
expect(sg.width).to eq sgi.width
|
11
11
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
it 'returns the height' do
|
14
|
+
expect(sg.height).to eq sgi.height
|
15
15
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
|
17
|
+
it 'returns the pixels as an array' do
|
18
|
+
expect(sg.send :raw_pixels).to be_a NPatch
|
19
19
|
end
|
20
|
-
|
21
|
-
|
20
|
+
|
21
|
+
it 'returns the correct number of pixels' do
|
22
|
+
expect(sg.send(:raw_pixels).length).to eq sgi.width * sgi.height
|
22
23
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
it "should return a Mimage" do
|
27
|
-
mim.crop({x: 0, y: 0, w: 10, h: 10}).should be_a(Mimage)
|
28
|
-
end
|
29
|
-
it "should return a Mimage of the correct width" do
|
30
|
-
i = mim.crop({x: 0, y: 0, w: 20, h: 10})
|
31
|
-
i.width.should == 20
|
24
|
+
|
25
|
+
it 'returns the stretched array' do
|
26
|
+
expect(sg.send(:reg_pixels).length).to eq sgi.width * sgi.height
|
32
27
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
|
29
|
+
it 'raises an error if the file is not found' do
|
30
|
+
expect { Mimage.new 'non_existing_file' }.to raise_error
|
36
31
|
end
|
37
32
|
end
|
38
|
-
|
39
|
-
describe
|
40
|
-
it
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
|
34
|
+
describe 'inspecting' do
|
35
|
+
it 'writes out average whiteness of choice cells' do
|
36
|
+
qz = sample_img 'silvia'
|
37
|
+
s = Mimage.new qz.filename, GridOMR.new(qz.grid_file)
|
38
|
+
File.open('spec/out/choices.txt', 'w') do |f|
|
39
|
+
120.times do |q|
|
40
|
+
t = (0..4).collect do |c|
|
41
|
+
s.send(:shade_of, q, c).round
|
42
|
+
end
|
43
|
+
f.puts "#{q+1}: #{t.join(' ')}"
|
44
|
+
end
|
45
|
+
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
data/spec/mork/npatch_spec.rb
CHANGED
@@ -2,26 +2,49 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Mork
|
4
4
|
describe NPatch do
|
5
|
-
let(:
|
6
|
-
let(:mim) { Mimage.new(rgm.filename) }
|
5
|
+
let(:rm) { NPatch.new 'spec/samples/rm01.jpeg', 134, 104 }
|
7
6
|
|
8
7
|
describe ".new" do
|
9
8
|
it "should create an NPatch" do
|
10
|
-
|
9
|
+
expect(rm).to be_an NPatch
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
|
-
describe
|
15
|
-
it
|
16
|
-
|
17
|
-
|
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]
|
18
25
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#average' do
|
29
|
+
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
|
23
34
|
end
|
24
35
|
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
|
25
48
|
end
|
26
49
|
end
|
27
50
|
|
data/spec/mork/sheet_omr_spec.rb
CHANGED
@@ -2,61 +2,58 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Mork
|
4
4
|
describe SheetOMR do
|
5
|
+
|
5
6
|
context 'highlighting' do
|
6
7
|
# since these specs change the @crop, they must be run in isolation
|
7
8
|
# with the SheetOMR rebuilt each time, even though it is time consuming!
|
8
|
-
let(:
|
9
|
+
let(:shinfo) { sample_img 'sample-gray' }
|
10
|
+
let(:sheet) { SheetOMR.new shinfo.filename, shinfo.grid_file }
|
9
11
|
|
10
12
|
it 'highlights the registration areas and frame' do
|
11
|
-
sheet.
|
13
|
+
sheet.highlight_registration
|
12
14
|
sheet.write_raw 'spec/out/reg_areas.jpg'
|
13
15
|
end
|
14
16
|
|
15
|
-
it '
|
16
|
-
sheet.
|
17
|
+
it 'highlights all choice cells' do
|
18
|
+
sheet.highlight_all_choices
|
17
19
|
sheet.write 'spec/out/all_highlights.jpg'
|
18
20
|
end
|
19
21
|
|
20
|
-
it '
|
22
|
+
it 'highlights marked cells' do
|
21
23
|
sheet.highlight_marked
|
22
|
-
sheet.outline [[1],[1],[2],[2],[3,4],[],[0,1,2,3,4]]
|
23
24
|
sheet.write 'spec/out/marked_highlights.jpg'
|
24
25
|
end
|
26
|
+
|
27
|
+
it 'outlines some responses' do
|
28
|
+
sheet.outline [[1],[1],[2],[2],[3,4],[],[0,1,2,3,4], [],[1],[2],[2],[3,4],[],[0,1,2,3,4]]
|
29
|
+
sheet.write 'spec/out/outlines.jpg'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'highlights marked cells and outline correct responses', focus: true do
|
33
|
+
sheet.highlight_marked
|
34
|
+
sheet.outline [[1],[1],[2],[2],[3,4],[],[0,1,2,3,4], [],[1],[2],[2],[3,4],[],[0,1,2,3,4]]
|
35
|
+
sheet.write 'spec/out/marks_and_outs.jpg'
|
36
|
+
end
|
25
37
|
|
26
38
|
it 'highlights marked cells of a problematic one' do
|
27
|
-
|
39
|
+
si = sample_img 'silvia'
|
40
|
+
s = SheetOMR.new si.filename, si.grid_file
|
28
41
|
s.highlight_marked
|
29
42
|
s.write 'spec/out/problem.jpg'
|
30
43
|
end
|
31
44
|
|
32
|
-
it '
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
t = (0..4).collect do |c|
|
38
|
-
s.send(:shade_of, q, c).round
|
39
|
-
end
|
40
|
-
f.puts "#{q+1}: #{t.join(' ')}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
mf = File.open('spec/out/marked.txt', 'w')
|
45
|
-
uf = File.open('spec/out/unmarked.txt', 'w')
|
46
|
-
120.times do |q|
|
47
|
-
5.times do |c|
|
48
|
-
shade = s.send(:shade_of, q, c)
|
49
|
-
s.marked?(q,c) ? mf.puts(shade) : uf.puts(shade)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
mf.close
|
53
|
-
uf.close
|
45
|
+
it 'highlights the barcode' do
|
46
|
+
si = sample_img 'sample-gray'
|
47
|
+
s = SheetOMR.new si.filename, si.grid_file
|
48
|
+
s.highlight_barcode
|
49
|
+
s.write 'spec/out/code_bits.jpg'
|
54
50
|
end
|
55
51
|
end
|
56
52
|
|
57
53
|
context 'marking a nicely printed and scanned sheet' do
|
58
54
|
before(:all) do
|
59
|
-
@
|
55
|
+
@shinfo = sample_img 'sample-gray'
|
56
|
+
@sheet = SheetOMR.new @shinfo.filename, @shinfo.grid_file
|
60
57
|
end
|
61
58
|
|
62
59
|
describe '#valid?' do
|
@@ -78,27 +75,16 @@ module Mork
|
|
78
75
|
expect(@sheet.marked?(2,3)).to be_falsy
|
79
76
|
end
|
80
77
|
|
81
|
-
it 'writes out
|
78
|
+
it 'writes out markedness' do
|
82
79
|
puts "Choice threshold: #{@sheet.send :choice_threshold}"
|
83
|
-
File.open('spec/out/choices.txt', 'w') do |f|
|
84
|
-
120.times do |q|
|
85
|
-
t = (0..4).collect do |c|
|
86
|
-
@sheet.send(:shade_of, q, c).round
|
87
|
-
end
|
88
|
-
f.puts "#{q+1}: #{t.join(' ')}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
80
|
mf = File.open('spec/out/marked.txt', 'w')
|
93
|
-
uf = File.open('spec/out/unmarked.txt', 'w')
|
94
81
|
120.times do |q|
|
95
|
-
5.times do |c|
|
96
|
-
|
97
|
-
@sheet.marked?(q,c) ? mf.puts(shade) : uf.puts(shade)
|
82
|
+
x = 5.times.collect do |c|
|
83
|
+
@sheet.marked?(q,c) ? '1' : '0'
|
98
84
|
end
|
85
|
+
mf.puts x.join(' ')
|
99
86
|
end
|
100
87
|
mf.close
|
101
|
-
uf.close
|
102
88
|
end
|
103
89
|
end
|
104
90
|
|
@@ -139,25 +125,16 @@ module Mork
|
|
139
125
|
s2 = SheetOMR.new('spec/samples/sample02.jpg')
|
140
126
|
s2.barcode_string.should == barcode_string
|
141
127
|
s2.barcode.should == 8608
|
142
|
-
s2.highlight_barcode
|
143
|
-
s2.write 'spec/out/code_bits.jpg'
|
144
128
|
end
|
145
129
|
|
146
130
|
it 'should read the 666 bit string' do
|
147
|
-
|
148
|
-
s2.
|
149
|
-
s2.
|
150
|
-
s2.write 'spec/out/code_bits666.jpg'
|
131
|
+
sh = sample_img 'code666'
|
132
|
+
s2 = SheetOMR.new sh.filename, sh.grid_file
|
133
|
+
s2.barcode.should == sh.barcode_int
|
151
134
|
end
|
152
135
|
end
|
153
136
|
|
154
137
|
end
|
155
|
-
|
156
|
-
context 'a faded, b&w, distorted sheet' do
|
157
|
-
it 'should return the correct barcode' do
|
158
|
-
SheetOMR.new('spec/samples/sample03.jpg').barcode.should == 8608
|
159
|
-
end
|
160
|
-
end
|
161
138
|
|
162
139
|
# context "multi-page pdf" do
|
163
140
|
# before(:all) do
|
data/spec/samples/info.yml
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
|
2
|
-
filename: spec/samples/
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
filename: spec/samples/
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
code666:
|
2
|
+
filename: spec/samples/sheet666.jpg
|
3
|
+
grid-file: spec/samples/layout.yml
|
4
|
+
barcode-int: 666666666666
|
5
|
+
|
6
|
+
silvia:
|
7
|
+
filename: spec/samples/qzc013.jpg
|
8
|
+
grid-file: spec/samples/layout.yml
|
9
|
+
|
10
|
+
sample-gray:
|
11
|
+
filename: spec/samples/sample_gray.jpg
|
12
|
+
grid-file: spec/samples/layout.yml
|
13
|
+
width: 1654
|
14
|
+
height: 2339
|
15
|
+
|
16
|
+
|
11
17
|
sample01:
|
12
18
|
filename: spec/samples/sample01.jpg
|
13
19
|
pages: 1
|
14
20
|
width: 2334
|
15
21
|
height: 3291
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
reg-marks: # registration marks
|
24
|
+
tl-x: 92
|
25
|
+
tl-y: 90
|
26
|
+
tr-x: 2245
|
27
|
+
tr-y: 97
|
28
|
+
br-x: 2230
|
29
|
+
br-y: 3217
|
30
|
+
bl-x: 78
|
31
|
+
bl-y: 3205
|
32
|
+
q-boxes:
|
27
33
|
q001:
|
28
|
-
|
29
|
-
|
34
|
+
tl-x: 175
|
35
|
+
tl-y: 379
|
30
36
|
q160:
|
31
|
-
|
32
|
-
|
33
|
-
bw_faded_sample:
|
34
|
-
filename: spec/samples/qzc006.jpg
|
35
|
-
pages: 1
|
36
|
-
width: 1196
|
37
|
-
height: 1682
|
38
|
-
code_int: 5512
|
37
|
+
tl-x: 1818
|
38
|
+
tl-y: 2974
|
39
39
|
|
40
|
-
|
40
|
+
reg-mark:
|
41
41
|
filename: spec/samples/reg_mark.jpg
|
42
|
-
|
43
|
-
|
42
|
+
centroid-x: 92
|
43
|
+
centroid-y: 91
|
44
44
|
|
45
45
|
small:
|
46
46
|
filename: spec/samples/small.jpg
|
47
47
|
|
48
|
-
|
48
|
+
code-sample:
|
49
49
|
filename: spec/samples/code_sample.png
|
50
|
-
|
51
|
-
|
50
|
+
code-string: "0000000000000000000000000000000000000000000000000001110001010001"
|
51
|
+
code-int: 7249
|
52
52
|
|
53
|
-
|
53
|
+
code-zero:
|
54
54
|
filename: spec/samples/code_zero.png
|
55
55
|
|
56
|
-
|
56
|
+
two-pages:
|
57
57
|
filename: spec/samples/two_pages.pdf
|
58
|
-
|
58
|
+
code-int: 17382938642823887837
|
59
59
|
|
data/spec/samples/io.jpg
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|