lib/sqed/parser/ocr_parser.rb in sqed-0.1.7 vs lib/sqed/parser/ocr_parser.rb in sqed-0.1.8
- old
+ new
@@ -59,11 +59,19 @@
labels: {
psm: 3, # may need to be 6
},
deterimination_labels: {
psm: 3
+ },
+ other_labels: {
+ psm: 3
+ },
+ collecting_event_labels: {
+ psm: 3
}
+
+
}
# the text extracted from the image
attr_accessor :text
@@ -83,19 +91,21 @@
# border_color = img.pixel_color(img.columns - 1, img.rows - 1)
# img = img.color_floodfill(img.columns - 1, img.rows - 1, new_color)
# img.write('tmp/foo4.jpg')
# img = img.quantize(2, Magick::GRAYColorspace)
# #img = img.threshold(0.5)
- # img.write('foo4.jpg') # for debugging purposes, this is the image that is sent to OCR
+ # img.write('foo4.jpg')
# img = img.equalize #(32, Magick::GRAYColorspace)
- # img.write('foo5.jpg') # for debugging purposes, this is the image that is sent to OCR
- # #img.write('foo3.jpg') # for debugging purposes, this is the image that is sent to OCR
+ # img.write('foo5.jpg')
+ # #img.write('foo3.jpg')
#
- # img.write('foo.jpg') # for debugging purposes, this is the image that is sent to OCR
+ # img.write('foo.jpg')
# img = img.white_threshold(245)
# img
# end
-
+
+ # @return [String]
+ # the ocr text
def text(section_type: :default)
img = @image
params = SECTION_PARAMS[:default].merge(SECTION_PARAMS[section_type])
r = RTesseract.new(img, params)
@text = r.to_s.strip