Module: BaiduOcr

Defined in:
lib/baidu_ocr.rb,
lib/baidu_ocr/request.rb,
lib/baidu_ocr/version.rb,
lib/baidu_ocr/settings.rb,
lib/baidu_ocr/file_read.rb,
lib/baidu_ocr/exceptions.rb,
lib/baidu_ocr/encode_image.rb

Defined Under Namespace

Modules: EncodeImage, FileRead, Request, Settings Classes: BlankArgsError, Exception, NotFound

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.init_baidu_ocr(opt = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/baidu_ocr.rb', line 13

def init_baidu_ocr(opt = {})
  BaiduOcr::Settings.set_baidu_ocr opt
  image = case opt[:imagetype]
  when 1
    BaiduOcr::EncodeImage.encode opt[:image]
  when 2
    BaiduOcr::FileRead.read opt[:image]
  else
    raise BlankArgsError, "imagetype"
  end

  BaiduOcr::Settings.update_image(image)
end

.recognizeObject



27
28
29
# File 'lib/baidu_ocr.rb', line 27

def recognize
  BaiduOcr::Request.send_request(BaiduOcr::Settings.settings)
end