标签:pos 识别 ken urlencode aml cli baidu yam size
require ‘restclient‘
require ‘open-uri‘
require ‘nokogiri‘
require ‘json‘
require ‘yaml‘
require ‘fileutils‘
require ‘base64‘
def extract_phone(image_src)
url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"
access_token = "24.0bbbc3338fcf9df41f26b42ff2a077.2593200.15323228.282335-11449805"
content_type = "application/x-www-form-urlencoded"
file = open(image_src).read
image = Base64.encode64(file)
RestClient.post(url, {access_token: access_token, image: image}, {content_type: content_type}) do |response|
body = JSON.parse(response.body)
return raise unless body[‘error_code‘].nil?
return body["words_result"][0]["words"]
end
end
标签:pos 识别 ken urlencode aml cli baidu yam size
原文地址:https://www.cnblogs.com/znsongshu/p/11371814.html