# -*- coding: utf-8 -*-
"""
图像识别
"""
im
port re
im
port sys
im
port math
im
port time
from .ba
se im
port Aipba
se
from .ba
se im
port ba
se64
from .ba
se im
port json
from .ba
se im
port urlencode
from .ba
se im
port quote
class AipOcr(Aipba
se):
"""
图像识别
"""
__generalBasicUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic'
__accurateBasicUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic'
__generalUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general'
__accurateUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/accurate'
__generalEnhancedUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general_enhanced'
__webImageUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/webimage'
__idcardUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/idcard'
__bankcardUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard'
__drivingLicenseUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/driving_license'
__vehicleLicenseUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license'
__licensePlateUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate'
__businessLicenseUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/business_license'
__receiptUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/receipt'
__trainTicketUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/train_ticket'
__taxiReceiptUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/taxi_receipt'
__formUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/form'
__tableRecognizeUrl = 'https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/request'
__tableResultGetUrl = 'https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/get_request_result'
__vatInvoiceUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice'
__qrcodeUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/qrcode'
__numbersUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/numbers'
__lotteryUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/lottery'
__passportUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/passport'
__businessCardUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/business_card'
__handwritingUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/handwriting'
__customUrl = 'https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise'
def basicGeneral(self, image, options=None):
"""
通用文字识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__generalBasicUrl, data)
def basicGeneralUrl(self, url, options=None):
"""
通用文字识别
"""
options = options or {}
data = {}
data['url'] = url
data.update(options)
return self._request(self.__generalBasicUrl, data)
def basicAccurate(self, image, options=None):
"""
通用文字识别(高精度版)
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__accurateBasicUrl, data)
def general(self, image, options=None):
"""
通用文字识别(含位置信息版)
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__generalUrl, data)
def generalUrl(self, url, options=None):
"""
通用文字识别(含位置信息版)
"""
options = options or {}
data = {}
data['url'] = url
data.update(options)
return self._request(self.__generalUrl, data)
def accurate(self, image, options=None):
"""
通用文字识别(含位置高精度版)
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__accurateUrl, data)
def enhancedGeneral(self, image, options=None):
"""
通用文字识别(含生僻字版)
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__generalEnhancedUrl, data)
def enhancedGeneralUrl(self, url, options=None):
"""
通用文字识别(含生僻字版)
"""
options = options or {}
data = {}
data['url'] = url
data.update(options)
return self._request(self.__generalEnhancedUrl, data)
def webImage(self, image, options=None):
"""
网络图片文字识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__webImageUrl, data)
def webImageUrl(self, url, options=None):
"""
网络图片文字识别
"""
options = options or {}
data = {}
data['url'] = url
data.update(options)
return self._request(self.__webImageUrl, data)
def idcard(self, image, id_card_side, options=None):
"""
身份证识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data['id_card_side'] = id_card_side
data.update(options)
return self._request(self.__idcardUrl, data)
def bankcard(self, image, options=None):
"""
银行卡识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__bankcardUrl, data)
def drivingLicense(self, image, options=None):
"""
驾驶证识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__drivingLicenseUrl, data)
def vehicleLicense(self, image, options=None):
"""
行驶证识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__vehicleLicenseUrl, data)
def licensePlate(self, image, options=None):
"""
车牌识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__licensePlateUrl, data)
def businessLicense(self, image, options=None):
"""
营业执照识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__businessLicenseUrl, data)
def receipt(self, image, options=None):
"""
通用票据识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__receiptUrl, data)
def trainTicket(self, image, options=None):
"""
火车票识别
"""
options = options or {}
data = {}
data['image'] = ba
se64.b64encode(image).decode()
data.update(options)
return self._request(self.__trainTicketUrl, data)
def taxiReceipt(self, image, options=None):
"""
出租车票识别
"""