module BaiduOcr::Request
Constants
- API_URL
Public Class Methods
send_request(opt = {})
click to toggle source
# File lib/baidu_ocr/request.rb, line 11 def send_request(opt = {}) headers = { apiKey: opt.delete(:apikey) } params = opt respone = RestClient.post API_URL, params, headers if respone.code == 200 body = JSON.parse respone.body return words(body['retData']) if body['errNum'].to_i == 0 puts "识别不成功: #{body['errMsg']}" end end
words(text)
click to toggle source
# File lib/baidu_ocr/request.rb, line 22 def words(text) text.collect{|k| k['word']}.join("\n") end