sqed 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +9 -0
- data/lib/sqed.rb +111 -0
- data/lib/sqed/boundaries.rb +79 -0
- data/lib/sqed/boundary_finder.rb +150 -0
- data/lib/sqed/boundary_finder/color_line_finder.rb +83 -0
- data/lib/sqed/boundary_finder/cross_finder.rb +23 -0
- data/lib/sqed/boundary_finder/stage_finder.rb +139 -0
- data/lib/sqed/extractor.rb +45 -0
- data/lib/sqed/parser.rb +11 -0
- data/lib/sqed/parser/barcode_parser.rb +27 -0
- data/lib/sqed/parser/ocr_parser.rb +52 -0
- data/lib/sqed/result.rb +15 -0
- data/lib/sqed/version.rb +3 -0
- data/lib/sqed_config.rb +112 -0
- data/spec/lib/sqed/boundaries_spec.rb +35 -0
- data/spec/lib/sqed/boundary_finder/color_line_finder_spec.rb +167 -0
- data/spec/lib/sqed/boundary_finder/cross_finder_spec.rb +28 -0
- data/spec/lib/sqed/boundary_finder/stage_finder_spec.rb +9 -0
- data/spec/lib/sqed/boundary_finder_spec.rb +108 -0
- data/spec/lib/sqed/extractor_spec.rb +82 -0
- data/spec/lib/sqed/parser_spec.rb +6 -0
- data/spec/lib/sqed/result_spec.rb +17 -0
- data/spec/lib/sqed_spec.rb +200 -0
- data/spec/spec_helper.rb +34 -0
- data/spec/support/files/2Dbarcode.png +0 -0
- data/spec/support/files/CrossyBlackLinesSpecimen.jpg +0 -0
- data/spec/support/files/CrossyGreenLinesSpecimen.jpg +0 -0
- data/spec/support/files/Quadrant_2_3.jpg +0 -0
- data/spec/support/files/black_stage_green_line_specimen.jpg +0 -0
- data/spec/support/files/boundary_cross_green.jpg +0 -0
- data/spec/support/files/boundary_left_t_yellow.jpg +0 -0
- data/spec/support/files/boundary_offset_cross_red.jpg +0 -0
- data/spec/support/files/boundary_right_t_green.jpg +0 -0
- data/spec/support/files/greenlineimage.jpg +0 -0
- data/spec/support/files/label_images/black_stage_green_line_specimen_label.jpg +0 -0
- data/spec/support/files/test0.jpg +0 -0
- data/spec/support/files/test1.jpg +0 -0
- data/spec/support/files/test2.jpg +0 -0
- data/spec/support/files/test3.jpg +0 -0
- data/spec/support/files/test4.jpg +0 -0
- data/spec/support/files/test4OLD.jpg +0 -0
- data/spec/support/files/test_barcode.JPG +0 -0
- data/spec/support/files/test_ocr0.jpg +0 -0
- data/spec/support/files/types_21.jpg +0 -0
- data/spec/support/files/types_8.jpg +0 -0
- data/spec/support/image_helpers.rb +78 -0
- data/sqed.gemspec +31 -0
- metadata +244 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sqed::Boundaries do
|
4
|
+
|
5
|
+
let(:s) { Sqed::Boundaries.new}
|
6
|
+
let(:layout) {:horizontal_split}
|
7
|
+
|
8
|
+
specify "#coordinates defaults to a Hash when no layout provided" do
|
9
|
+
expect(s.coordinates).to eq({})
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'with a layout provided' do
|
13
|
+
before {
|
14
|
+
s.layout = layout
|
15
|
+
}
|
16
|
+
|
17
|
+
specify "coordinates can be initialized after the fact (bad idea likely)" do
|
18
|
+
expect(s.initialize_coordinates).to be_truthy
|
19
|
+
end
|
20
|
+
|
21
|
+
specify "#coordinates has one coordinate system for each section (key in layout)" do
|
22
|
+
s.initialize_coordinates
|
23
|
+
expect(s.coordinates.keys.sort).to eq([0,1])
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "#each" do
|
27
|
+
s.initialize_coordinates
|
28
|
+
s.each do |k,v|
|
29
|
+
expect([0,1].include?(k)).to be(true)
|
30
|
+
expect(v).to eq([nil, nil, nil, nil])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sqed::BoundaryFinder::ColorLineFinder do
|
4
|
+
|
5
|
+
let(:image) { ImageHelpers.crossy_green_line_specimen }
|
6
|
+
|
7
|
+
let(:b) { Sqed::BoundaryFinder::StageFinder.new(image: image) }
|
8
|
+
let(:c) {b.boundaries}
|
9
|
+
let(:d) { image.crop(*c.for(0), true) }
|
10
|
+
|
11
|
+
let(:e) { Sqed::BoundaryFinder::ColorLineFinder.new(image: d, layout: :right_t) }
|
12
|
+
let(:f) { e.boundaries }
|
13
|
+
let(:g) { Sqed::BoundaryFinder::ColorLineFinder.new(image: d, layout: :offset_cross)}
|
14
|
+
let(:h) { g.boundaries }
|
15
|
+
let(:gv) { Sqed::BoundaryFinder::ColorLineFinder.new(image: d, layout: :vertical_split) }
|
16
|
+
let(:hv) { gv.boundaries }
|
17
|
+
|
18
|
+
let(:ah) { ImageHelpers.offset_cross_red }
|
19
|
+
let(:bh) { Sqed::BoundaryFinder::StageFinder.new(image: ah) }
|
20
|
+
let(:ch) { bh.boundaries }
|
21
|
+
let(:dh) { ah.crop(*ch.for(0), true) }
|
22
|
+
let(:gh) { Sqed::BoundaryFinder::ColorLineFinder.new(image: dh, layout: :horizontal_split, boundary_color: :red) } # was :horizontal_split
|
23
|
+
let(:hh) { gh.boundaries }
|
24
|
+
|
25
|
+
let(:ibs) { ImageHelpers.black_stage_green_line_specimen }
|
26
|
+
let(:bbs) { Sqed::BoundaryFinder::StageFinder.new(image: ibs) }
|
27
|
+
let(:cbs) { bbs.boundaries }
|
28
|
+
let(:dbs) { ibs.crop(*cbs.for(0), true) }
|
29
|
+
let(:gbs) { Sqed::BoundaryFinder::ColorLineFinder.new(image: dbs, layout: :offset_cross) }
|
30
|
+
let(:hbs) { gbs.boundaries }
|
31
|
+
|
32
|
+
specify 'initial image columns are as expected for :image above' do
|
33
|
+
expect(image.columns).to eq(3264)
|
34
|
+
expect(image.rows).to eq(2452)
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'stage image is properly found (sanity check, should be tests in stage finder)' do
|
38
|
+
specify 'stage image boundaries are correct' do
|
39
|
+
pct = 0.02
|
40
|
+
expect(in_range(c.x_for(0), pct, 407)).to be(true)
|
41
|
+
expect(in_range(c.y_for(0), pct, 301)).to be(true)
|
42
|
+
expect(in_range(c.width_for(0), pct, 2587)).to be(true)
|
43
|
+
expect(in_range(c.height_for(0), pct, 1990)).to be(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
specify 'stage image size is correct' do
|
47
|
+
expect(d.columns).to be_within(50).of(2587)
|
48
|
+
expect(d.rows).to be_within(40).of(1990)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
specify "CrossGreenLinesSpecimen using right_t layout should yield 3 rectangular boundaries" do
|
53
|
+
# use the f object for right_t
|
54
|
+
f.each do |i, coord|
|
55
|
+
q = d.crop(*coord, true)
|
56
|
+
q.write("tmp/q0#{i}.jpg")
|
57
|
+
end
|
58
|
+
|
59
|
+
expect(f.count).to eq(3)
|
60
|
+
pct = 0.02
|
61
|
+
|
62
|
+
expect(f.x_for(0)).to be_within(1).of(1)
|
63
|
+
expect(f.y_for(0)).to be_within(1).of(1)
|
64
|
+
expect(f.width_for(0)).to be_within(pct*2051).of(2051)
|
65
|
+
expect(f.height_for(0)).to be_within(pct*1990).of(1990)
|
66
|
+
|
67
|
+
expect(f.x_for(1)).to be_within(pct*2099).of(2099)
|
68
|
+
expect(f.y_for(1)).to be_within(1).of(1)
|
69
|
+
expect(f.width_for(1)).to be_within(pct*438).of(488)
|
70
|
+
expect(f.height_for(1)).to be_within(pct*987).of(987)
|
71
|
+
|
72
|
+
expect(f.x_for(2)).to be_within(pct*2099).of(2099)
|
73
|
+
expect(f.y_for(2)).to be_within(pct*1026).of(1026)
|
74
|
+
expect(f.width_for(2)).to be_within(pct*488).of(488)
|
75
|
+
expect(f.height_for(2)).to be_within(pct*964).of(964)
|
76
|
+
end
|
77
|
+
|
78
|
+
specify "CrossGreenLinesSpecimen using offset_cross layout should yield 4 rectangular boundaries" do
|
79
|
+
h.each do |i, coord|
|
80
|
+
q = d.crop(*coord, true)
|
81
|
+
q.write("tmp/q1#{i}.jpg")
|
82
|
+
end
|
83
|
+
|
84
|
+
expect(h.count).to eq(4)
|
85
|
+
|
86
|
+
pct = 0.02
|
87
|
+
|
88
|
+
expect(h.x_for(0)).to be_within(pct*2099).of(0)
|
89
|
+
expect(h.y_for(0)).to be_within(pct*0).of(0)
|
90
|
+
expect(h.width_for(0)).to be_within(pct*2051).of(2051)
|
91
|
+
expect(h.height_for(0)).to be_within(pct*1054).of(1054)
|
92
|
+
|
93
|
+
expect(h.x_for(1)).to be_within(pct*2099).of(2099)
|
94
|
+
expect(h.y_for(1)).to be_within(pct*0).of(0)
|
95
|
+
expect(h.width_for(1)).to be_within(pct*488).of(488)
|
96
|
+
expect(h.height_for(1)).to be_within(pct*987).of(987)
|
97
|
+
|
98
|
+
expect(h.x_for(2)).to be_within(pct*2099).of(2099)
|
99
|
+
expect(h.y_for(2)).to be_within(pct*1026).of(1026)
|
100
|
+
expect(h.width_for(2)).to be_within(pct*488).of(488)
|
101
|
+
expect(h.height_for(2)).to be_within(pct*964).of(964)
|
102
|
+
|
103
|
+
expect(h.x_for(3)).to be_within(0).of(0)
|
104
|
+
expect(h.y_for(3)).to be_within(pct*1093).of(1093)
|
105
|
+
expect(h.width_for(3)).to be_within(pct*2051).of(2051)
|
106
|
+
expect(h.height_for(3)).to be_within(pct*897).of(897)
|
107
|
+
end
|
108
|
+
|
109
|
+
specify "CrossGreenLinesSpecimen using vertical_split layout should yield 2 rectangular boundaries" do
|
110
|
+
hv.each do |k, v|
|
111
|
+
q = d.crop(*v, true)
|
112
|
+
q.write("tmp/q2#{k}.jpg")
|
113
|
+
end
|
114
|
+
expect(hv.count).to eq(2)
|
115
|
+
|
116
|
+
expect(hv.x_for(0)).to be_within(0.02*0).of(0)
|
117
|
+
expect(hv.y_for(0)).to be_within(0.02*0).of(0)
|
118
|
+
expect(hv.width_for(0)).to be_within(0.02*2051).of(2051)
|
119
|
+
expect(hv.height_for(0)).to be_within(0.02*1990).of(1990)
|
120
|
+
|
121
|
+
expect(hv.x_for(1)).to be_within(0.02*2099).of(2099)
|
122
|
+
expect(hv.y_for(1)).to be_within(0.02*0).of(0)
|
123
|
+
expect(hv.width_for(1)).to be_within(0.02*488).of(488)
|
124
|
+
expect(hv.height_for(1)).to be_within(0.02*1990).of(1990)
|
125
|
+
end
|
126
|
+
|
127
|
+
specify "boundary_offset_cross_red using horizontal_split layout should yield 2 rectangular boundaries" do
|
128
|
+
hh.each do |k, v|
|
129
|
+
q = dh.crop(*v, true)
|
130
|
+
q.write("tmp/q3#{k}.jpg")
|
131
|
+
end
|
132
|
+
|
133
|
+
expect(hh.count).to eq(2)
|
134
|
+
expect([[0, 0, 798, 146] , [0, 0, 799, 145]]).to include(hh.coordinates[0]) # for quadrant 0
|
135
|
+
expect(hh.coordinates[0]).to eq([0, 0, 799, 145]).or eq([0, 0, 798, 146]) # for quadrant 0
|
136
|
+
expect(hh.coordinates[1]).to eq([0, 154, 799, 445]) # for quadrant 1
|
137
|
+
end
|
138
|
+
|
139
|
+
specify "offset cross method on black stage specimen should yield 4 rectangular boundaries for 0" do
|
140
|
+
(hbs.first[0]..hbs.count - 1).each do |j|
|
141
|
+
q = dbs.crop(*hbs.for(j), true)
|
142
|
+
q.write("tmp/qb#{j}.jpg")
|
143
|
+
end
|
144
|
+
expect(hbs.coordinates.keys.count).to eq(4)
|
145
|
+
|
146
|
+
pct = 0.02
|
147
|
+
|
148
|
+
expect(hbs.width_for(0)).to be_within(pct*2999).of(2999)
|
149
|
+
expect(hbs.height_for(0)).to be_within(pct*506).of(506)
|
150
|
+
end
|
151
|
+
|
152
|
+
specify "offset cross method on black stage specimen should yield 4 rectangular boundaries for 1" do
|
153
|
+
expect(hbs.width_for(1)).to be_within(0.02*447).of(447)
|
154
|
+
expect(hbs.height_for(1)).to be_within(0.02*487).of(487)
|
155
|
+
end
|
156
|
+
|
157
|
+
specify "offset cross method on black stage specimen should yield 4 rectangular boundaries for 2" do
|
158
|
+
expect(hbs.width_for(2)).to be_within(0.02*447).of(447)
|
159
|
+
expect(hbs.height_for(2)).to be_within(0.02*1680).of(1680)
|
160
|
+
end
|
161
|
+
|
162
|
+
specify "offset cross method on black stage specimen should yield 4 rectangular boundaries for 3" do
|
163
|
+
expect(hbs.width_for(3)).to be_within(0.02*2999).of(2999)
|
164
|
+
expect(hbs.height_for(3)).to be_within(0.02*1677).of(1677)
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sqed::BoundaryFinder::CrossFinder do
|
4
|
+
let(:image) { ImageHelpers.of_size(800, 600) }
|
5
|
+
let(:b) {Sqed::BoundaryFinder::CrossFinder.new(image: image)}
|
6
|
+
let(:c) {b.boundaries}
|
7
|
+
|
8
|
+
specify '#boundaries returns a Sqed::Boundaries instance' do
|
9
|
+
expect(b.boundaries.class).to eq(Sqed::Boundaries)
|
10
|
+
end
|
11
|
+
|
12
|
+
specify 'the 0th image starts at x = 0' do
|
13
|
+
expect(c.x_for(0)).to eq(0)
|
14
|
+
end
|
15
|
+
|
16
|
+
specify 'the 0th image starts at y = 0' do
|
17
|
+
expect(c.y_for(0)).to eq(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
specify 'the 0th image has width = 400' do
|
21
|
+
expect(c.width_for(0)).to eq(400)
|
22
|
+
end
|
23
|
+
|
24
|
+
specify 'the 0th image has height = 300' do
|
25
|
+
expect(c.height_for(0)).to eq(300)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sqed::BoundaryFinder do
|
4
|
+
|
5
|
+
specify 'when no image provided, #new raises' do
|
6
|
+
expect { Sqed::BoundaryFinder.new() }.to raise_error
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'when initiated with an image' do
|
10
|
+
let(:b) {Sqed::BoundaryFinder.new(image: ImageHelpers.standard_cross_green, layout: :offset_cross)}
|
11
|
+
|
12
|
+
context 'attributes' do
|
13
|
+
specify '#img' do
|
14
|
+
expect(b).to respond_to(:img)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
specify '#boundaries' do
|
19
|
+
expect(b.boundaries.class).to eq(Sqed::Boundaries)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context '.color_boundary_finder(image: image, sample_subdivision: 10)' do
|
24
|
+
specify 'finds the vertical dividing line in a standard cross, with border still present' do
|
25
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.standard_cross_green)[1]
|
26
|
+
expect(center).to be > 492
|
27
|
+
expect(center).to be < 504
|
28
|
+
end
|
29
|
+
|
30
|
+
specify 'finds the vertical dividing line in a standard cross, with border still present, when more precise' do
|
31
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.standard_cross_green, sample_cutoff_factor: 0.7)[1]
|
32
|
+
expect(center).to be > 492
|
33
|
+
expect(center).to be < 504
|
34
|
+
end
|
35
|
+
|
36
|
+
specify 'finds the vertical dividing line in a right t green cross, with border still present' do
|
37
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.right_t_green)[1]
|
38
|
+
expect(center).to be > 695
|
39
|
+
expect(center).to be < 705
|
40
|
+
end
|
41
|
+
|
42
|
+
specify 'finds the vertical dividing line a real image, with border still present' do
|
43
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.crossy_green_line_specimen)[1]
|
44
|
+
expect(center).to be > 2452
|
45
|
+
expect(center).to be < 2495
|
46
|
+
end
|
47
|
+
|
48
|
+
specify 'finds the vertical dividing line a real image, with border still present, with 10x fewer subsamples' do
|
49
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.crossy_green_line_specimen, sample_subdivision_size: 100 )[1]
|
50
|
+
expect(center).to be > 2452
|
51
|
+
expect(center).to be < 2495
|
52
|
+
end
|
53
|
+
|
54
|
+
specify 'finds the vertical dividing line a real image, with border still present, with 50x fewer subsamples' do
|
55
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.crossy_green_line_specimen, sample_subdivision_size: 500 )[1]
|
56
|
+
expect(center).to be > 2452
|
57
|
+
expect(center).to be < 2495
|
58
|
+
end
|
59
|
+
|
60
|
+
specify 'FAILS to find the vertical dividing line a real image, with border still present, with 200x fewer subsamples' do
|
61
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.crossy_green_line_specimen, sample_subdivision_size: 2000 )
|
62
|
+
expect(center).to be nil
|
63
|
+
end
|
64
|
+
|
65
|
+
specify 'finds the vertical dividing line another real image, with border still present' do
|
66
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.greenline_image)[1]
|
67
|
+
expect(center).to be > 2445
|
68
|
+
expect(center).to be < 2495
|
69
|
+
end
|
70
|
+
|
71
|
+
specify 'finds the vertical dividing line another real image, with border still present, and 20x fewer subsamples' do
|
72
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.greenline_image, sample_subdivision_size: 200)[1]
|
73
|
+
expect(center).to be > 2445
|
74
|
+
expect(center).to be < 2495
|
75
|
+
end
|
76
|
+
|
77
|
+
specify 'finds the vertical dividing line another real image, with border still present, and 50x fewer subsamples' do
|
78
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.greenline_image, sample_subdivision_size: 500)[1]
|
79
|
+
expect(center).to be > 2445
|
80
|
+
expect(center).to be < 2495
|
81
|
+
end
|
82
|
+
|
83
|
+
specify 'FAILS to find the vertical dividing line in a standard cross, with border still present, when even more precise' do
|
84
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.standard_cross_green, sample_cutoff_factor: 1)
|
85
|
+
expect(center).to be nil
|
86
|
+
end
|
87
|
+
|
88
|
+
specify 'finds the horizontal dividing line another real image, with border still present' do
|
89
|
+
center = Sqed::BoundaryFinder.color_boundary_finder(image: ImageHelpers.greenline_image, scan: :columns)[1]
|
90
|
+
expect(center).to be > 1282
|
91
|
+
expect(center).to be < 1332
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
context '.frequency_stats(frequency_hash, samples_taken)' do
|
97
|
+
# i is a Hash of position => count (it is unordered, but constructed ordered here in assignment)
|
98
|
+
let(:i) { {1 => 1, 2 => 3, 3 => 15, 4 => 14, 5 => 13 }}
|
99
|
+
specify 'returns the median position (rounds up)' do
|
100
|
+
expect( Sqed::BoundaryFinder.frequency_stats(i, 12)).to eq([3, 4, 5])
|
101
|
+
end
|
102
|
+
|
103
|
+
specify 'returns nil if no count is greater than samples taken' do
|
104
|
+
expect( Sqed::BoundaryFinder.frequency_stats(i, 15)).to eq(nil)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sqed::Extractor do
|
4
|
+
|
5
|
+
let(:s) {Sqed::Extractor.new}
|
6
|
+
|
7
|
+
# context 'attributes' do
|
8
|
+
# specify '#image' do
|
9
|
+
# # expect that s.image is a method
|
10
|
+
# expect(s).to respond_to(:image)
|
11
|
+
# end
|
12
|
+
|
13
|
+
# specify 'autocropper/edgeDetector works' do
|
14
|
+
# this_image = ImageHelpers.ocr_image
|
15
|
+
# expect(Sqed::AutoCropper.new(this_image)).to be_truthy
|
16
|
+
# end
|
17
|
+
|
18
|
+
# specify 'Sqed.new(image: file) assigns to image' do
|
19
|
+
# specify 'Sqed.new(image:file) "works"' do
|
20
|
+
# expect(Sqed.new(image: ImageHelpers.test0_image)).to be_truthy
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
|
24
|
+
# specify 'green line parser does something' do
|
25
|
+
# this_image = ImageHelpers.greenline_image
|
26
|
+
# cropped_image = Sqed::AutoCropper.new(this_image).img
|
27
|
+
# a = Sqed::GreenLineFinder.new(cropped_image)
|
28
|
+
# b = 0
|
29
|
+
# end
|
30
|
+
|
31
|
+
# specify 'Sqed.new(image: file) assigns to image' do
|
32
|
+
# a = Sqed.new(image: ImageHelpers.test0_image)
|
33
|
+
# expect(a.image == ImageHelpers.test0_image).to be(true)
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
|
37
|
+
# specify 'zbar barcode decodes' do
|
38
|
+
# eb = Sqed::BarcodeParser.new(image: ImageHelpers.barcode_image) # was barcode_image
|
39
|
+
# bc = eb.barcodes
|
40
|
+
# expect(bc).to be_truthy
|
41
|
+
# expect(bc[2]).to eq('CODE-128:013117001040986')
|
42
|
+
# expect(bc[3]).to eq('CODE-128:SDLXHD1QTDVGJ')
|
43
|
+
# expect(bc[4]).to eq('CODE-128:1PPD368LL/A')
|
44
|
+
# expect(bc[5]).to eq('EAN-13:0885909541171')
|
45
|
+
# expect(bc[6]).to eq('EAN-13:885909270334')
|
46
|
+
# expect(bc[7]).to be(nil)
|
47
|
+
# end
|
48
|
+
|
49
|
+
# specify 'INHS specimen labels' do
|
50
|
+
# eg = Sqed.new(image: ImageHelpers.labels_image)
|
51
|
+
# # eg = Sqed.new(image: ImageHelpers.foo3_image)
|
52
|
+
# eg.image.rotate!(270.0)
|
53
|
+
# eg.image.write('foo5.jpg')
|
54
|
+
# egt = eg.text_from_quadrant(3)
|
55
|
+
# expect(egt).to match(/529 234/)
|
56
|
+
# end
|
57
|
+
|
58
|
+
# context "foo.jpg" do
|
59
|
+
# let(:eg) { Sqed.new(image: ImageHelpers.ocr_image) }
|
60
|
+
|
61
|
+
# specify 'all together' do
|
62
|
+
# # eg = Sqed.new(image: ImageHelpers.ocr_image)
|
63
|
+
# egt = eg.text_from_quadrant(3)
|
64
|
+
|
65
|
+
# expect(egt).to match(/Designed by Apple in California/)
|
66
|
+
# expect(egt).to match(/8 85909 27035/)
|
67
|
+
# expect(egt).to match(/EASY/)
|
68
|
+
# expect(eg.text_from_quadrant(3)).to match(/013‘1700104U986/) #ACTUALLY 013117001040986
|
69
|
+
|
70
|
+
# eg = Sqed.new(image: ImageHelpers.ocr_image)
|
71
|
+
# egb = eg.text_from_quadrant(2)
|
72
|
+
# u = 1 #pre-test breakpoint
|
73
|
+
# expect(egb.barcodes[0]).to eq('QR-Code:http://youtu.be/h9fkPPp8Y1c')
|
74
|
+
# expect(egb.barcodes[1]).to eq('EAN-13:0885909270354')
|
75
|
+
# expect(egb.barcodes[2]).to eq('CODE-128:013117001040986')
|
76
|
+
# expect(egb.barcodes[3]).to eq('CODE-128:SDLXHD1QTDVGJ')
|
77
|
+
# expect(egb.barcodes[4]).to eq('CODE-128:1PPD368LL/A')
|
78
|
+
# expect(egb.barcodes[5]).to eq('EAN-13:0885909541171')
|
79
|
+
# expect(egb.barcodes[6]).to be(nil)
|
80
|
+
# end
|
81
|
+
# end
|
82
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sqed::Result do
|
4
|
+
let(:r) {Sqed::Result.new}
|
5
|
+
|
6
|
+
context "attributes are derived from SqedConfig::LAYOUT_SECTION_TYPES" do
|
7
|
+
SqedConfig::LAYOUT_SECTION_TYPES.each do |type|
|
8
|
+
specify "##{type}" do
|
9
|
+
expect(r.respond_to?(type.to_sym)).to be_truthy
|
10
|
+
end
|
11
|
+
|
12
|
+
specify "##{type}_image" do
|
13
|
+
expect(r.respond_to?("#{type}_image".to_sym)).to be_truthy
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|