ruby_marks 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -89,7 +89,7 @@ Then, we write a basic code to scan it and print result on console:
89
89
  recognizer = RubyMarks::Recognizer.new
90
90
  recognizer.configure do |config|
91
91
 
92
- config.clock_marks_scan_x = 42
92
+ config.clock_marks_scan_x = 20
93
93
  config.clock_width = 29
94
94
  config.clock_height = 12
95
95
 
@@ -167,6 +167,22 @@ This should puts each scan in a hash, like this:
167
167
  }
168
168
  ```
169
169
 
170
+ There's a method you can call to will help you to configure the positions. This method return the image
171
+ with the markups of encountered clock marks, where the marks is being recognized and where the clock_marks_scan_x
172
+ config is making the column search.
173
+
174
+ Example:
175
+
176
+ ```ruby
177
+ flagged_document = recognizer.flag_all_marks
178
+ flagged_document.write(temp_filename)
179
+ ```
180
+
181
+ Will return the image below with recognized clock marks in green, the clock_marks_scan_x line in blue and
182
+ each mark position in a red cross:
183
+
184
+ [![Flagged Document Example](https://raw.github.com/andrerpbts/ruby_marks/master/assets/sheet_demo2_flagged.png)](https://github.com/andrerpbts/ruby_marks/blob/master/assets/sheet_demo2_flagged.png)
185
+
170
186
 
171
187
  General Configuration Options
172
188
  -----------------------------
@@ -254,7 +254,9 @@ module RubyMarks
254
254
 
255
255
  @clock_marks = []
256
256
  x = @config.clock_marks_scan_x
257
+ total_width = @file && @file.page.width || 0
257
258
  total_height = @file && @file.page.height || 0
259
+
258
260
  @clock_marks.tap do |clock_marks|
259
261
  current_y = 0
260
262
  loop do
@@ -277,6 +279,11 @@ module RubyMarks
277
279
  x_elements.sort!.uniq!
278
280
  y_elements.sort!.uniq!
279
281
  last_y = y_elements.last
282
+
283
+ if x_elements.size > 50
284
+ current_y = last_y + 1
285
+ next
286
+ end
280
287
 
281
288
  loop do
282
289
  stack_modified = false
@@ -349,8 +356,7 @@ module RubyMarks
349
356
  loop do
350
357
  color = self.file.pixel_color(current_x, y)
351
358
  color = RubyMarks::ImageUtils.to_hex(color.red, color.green, color.blue)
352
-
353
- break if !self.config.recognition_colors.include?(color) || current_x - 1 <= 0
359
+ break if !self.config.recognition_colors.include?(color) || current_x - 1 <= 0
354
360
  process_queue[y] << current_x unless process_queue[y].include?(current_x) || result_mask[y].include?(current_x)
355
361
  result_mask[y] << current_x unless result_mask[y].include?(current_x)
356
362
  current_x = current_x - 1
@@ -1,3 +1,3 @@
1
1
  module RubyMarks
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_marks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -34,8 +34,7 @@ email:
34
34
  - ronaldoaraujo1980@gmail.com
35
35
  executables: []
36
36
  extensions: []
37
- extra_rdoc_files:
38
- - README.md
37
+ extra_rdoc_files: []
39
38
  files:
40
39
  - README.md
41
40
  - lib/ruby_marks/clock_mark.rb