huaweicloud-sdk-python-v3/huaweicloud-sdk-ocr/huaweicloudsdkocr/v1/ocr_async_client.py

1532 lines
54 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding: utf-8
from __future__ import absolute_import
import datetime
import re
import importlib
import six
from huaweicloudsdkcore.client import Client, ClientBuilder
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcore.utils import http_utils
from huaweicloudsdkcore.sdk_stream_request import SdkStreamRequest
class OcrAsyncClient(Client):
"""
:param configuration: .Configuration object for this client
:param pool_threads: The number of threads to use for async requests
to the API. More threads means more concurrent API requests.
"""
PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
NATIVE_TYPES_MAPPING = {
'int': int,
'long': int if six.PY3 else long,
'float': float,
'str': str,
'bool': bool,
'date': datetime.date,
'datetime': datetime.datetime,
'object': object,
}
def __init__(self):
super(OcrAsyncClient, self).__init__()
self.model_package = importlib.import_module("huaweicloudsdkocr.v1.model")
self.preset_headers = {'User-Agent': 'HuaweiCloud-SDK-Python'}
@staticmethod
def new_builder(clazz):
return ClientBuilder(clazz)
def recognize_auto_classification_async(self, request):
"""智能分类识别
检测定位图片上指定要识别的票证(票据、证件或其他文字载体),并对其进行结构化识别。接口以列表形式返回图片上要识别票证的位置坐标、结构化识别的内容以及对应的类别。 计费次数说明: 只对识别成功的票证进行计费,识别失败的票证不计费。例如图片中包含三张票证,有两张识别成功,一张识别失败,此时接口计费两次。
:param RecognizeAutoClassificationRequest request
:return: RecognizeAutoClassificationResponse
"""
return self.recognize_auto_classification_with_http_info(request)
def recognize_auto_classification_with_http_info(self, request):
"""智能分类识别
检测定位图片上指定要识别的票证(票据、证件或其他文字载体),并对其进行结构化识别。接口以列表形式返回图片上要识别票证的位置坐标、结构化识别的内容以及对应的类别。 计费次数说明: 只对识别成功的票证进行计费,识别失败的票证不计费。例如图片中包含三张票证,有两张识别成功,一张识别失败,此时接口计费两次。
:param RecognizeAutoClassificationRequest request
:return: RecognizeAutoClassificationResponse
"""
all_params = ['recognize_auto_classification_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/auto-classification',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeAutoClassificationResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_bankcard_async(self, request):
"""银行卡识别
识别银行卡上的关键文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeBankcardRequest request
:return: RecognizeBankcardResponse
"""
return self.recognize_bankcard_with_http_info(request)
def recognize_bankcard_with_http_info(self, request):
"""银行卡识别
识别银行卡上的关键文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeBankcardRequest request
:return: RecognizeBankcardResponse
"""
all_params = ['recognize_bankcard_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/bankcard',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeBankcardResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_business_card_async(self, request):
"""名片识别
识别名片图片上的文字信息,并返回识别的结构化结果。支持对多种不同版式名片进行结构化信息提取。
:param RecognizeBusinessCardRequest request
:return: RecognizeBusinessCardResponse
"""
return self.recognize_business_card_with_http_info(request)
def recognize_business_card_with_http_info(self, request):
"""名片识别
识别名片图片上的文字信息,并返回识别的结构化结果。支持对多种不同版式名片进行结构化信息提取。
:param RecognizeBusinessCardRequest request
:return: RecognizeBusinessCardResponse
"""
all_params = ['recognize_business_card_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/business-card',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeBusinessCardResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_business_license_async(self, request):
"""营业执照识别
识别用户上传的营业执照首页图片中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeBusinessLicenseRequest request
:return: RecognizeBusinessLicenseResponse
"""
return self.recognize_business_license_with_http_info(request)
def recognize_business_license_with_http_info(self, request):
"""营业执照识别
识别用户上传的营业执照首页图片中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeBusinessLicenseRequest request
:return: RecognizeBusinessLicenseResponse
"""
all_params = ['recognize_business_license_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/business-license',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeBusinessLicenseResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_driver_license_async(self, request):
"""驾驶证识别
识别用户上传的驾驶证图片或者用户提供的华为云上OBS的驾驶证图片文件的URL中主页与副页的文字内容并将识别的结果返回给用户。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeDriverLicenseRequest request
:return: RecognizeDriverLicenseResponse
"""
return self.recognize_driver_license_with_http_info(request)
def recognize_driver_license_with_http_info(self, request):
"""驾驶证识别
识别用户上传的驾驶证图片或者用户提供的华为云上OBS的驾驶证图片文件的URL中主页与副页的文字内容并将识别的结果返回给用户。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeDriverLicenseRequest request
:return: RecognizeDriverLicenseResponse
"""
all_params = ['recognize_driver_license_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/driver-license',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeDriverLicenseResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_financial_statement_async(self, request):
"""财务报表识别
识别用户上传的表格图片中的文字内容,并将识别的结果返回给用户。
:param RecognizeFinancialStatementRequest request
:return: RecognizeFinancialStatementResponse
"""
return self.recognize_financial_statement_with_http_info(request)
def recognize_financial_statement_with_http_info(self, request):
"""财务报表识别
识别用户上传的表格图片中的文字内容,并将识别的结果返回给用户。
:param RecognizeFinancialStatementRequest request
:return: RecognizeFinancialStatementResponse
"""
all_params = ['project_id', 'recognize_financial_statement']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
if 'project_id' in local_var_params:
path_params['project_id'] = local_var_params['project_id']
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v2/{project_id}/ocr/financial-statement',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeFinancialStatementResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_flight_itinerary_async(self, request):
"""飞机行程单识别
识别飞机行程单中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeFlightItineraryRequest request
:return: RecognizeFlightItineraryResponse
"""
return self.recognize_flight_itinerary_with_http_info(request)
def recognize_flight_itinerary_with_http_info(self, request):
"""飞机行程单识别
识别飞机行程单中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeFlightItineraryRequest request
:return: RecognizeFlightItineraryResponse
"""
all_params = ['recognize_flight_itinerary_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/flight-itinerary',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeFlightItineraryResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_general_table_async(self, request):
"""通用表格识别
识别用于识别用户上传的通用表格图片或者用户提供的华为云上OBS的通用表格图片文件的URL中的文字内容并将识别的结果返回给用户。
:param RecognizeGeneralTableRequest request
:return: RecognizeGeneralTableResponse
"""
return self.recognize_general_table_with_http_info(request)
def recognize_general_table_with_http_info(self, request):
"""通用表格识别
识别用于识别用户上传的通用表格图片或者用户提供的华为云上OBS的通用表格图片文件的URL中的文字内容并将识别的结果返回给用户。
:param RecognizeGeneralTableRequest request
:return: RecognizeGeneralTableResponse
"""
all_params = ['recognize_general_table_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/general-table',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeGeneralTableResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_general_text_async(self, request):
"""通用文字识别
识别图片上的文字信息,返回识别的文字和坐标。支持扫描文件、电子文档、书籍、票据和表单等多种场景的文字识别。
:param RecognizeGeneralTextRequest request
:return: RecognizeGeneralTextResponse
"""
return self.recognize_general_text_with_http_info(request)
def recognize_general_text_with_http_info(self, request):
"""通用文字识别
识别图片上的文字信息,返回识别的文字和坐标。支持扫描文件、电子文档、书籍、票据和表单等多种场景的文字识别。
:param RecognizeGeneralTextRequest request
:return: RecognizeGeneralTextResponse
"""
all_params = ['recognize_general_text_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/general-text',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeGeneralTextResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_handwriting_async(self, request):
"""手写字母数字识别
识别用户上传的手写字母数字图片或者用户提供的华为云上OBS的手写字母数字图片文件的URL中的字母数字内容并将识别的结果返回给用户。
:param RecognizeHandwritingRequest request
:return: RecognizeHandwritingResponse
"""
return self.recognize_handwriting_with_http_info(request)
def recognize_handwriting_with_http_info(self, request):
"""手写字母数字识别
识别用户上传的手写字母数字图片或者用户提供的华为云上OBS的手写字母数字图片文件的URL中的字母数字内容并将识别的结果返回给用户。
:param RecognizeHandwritingRequest request
:return: RecognizeHandwritingResponse
"""
all_params = ['recognize_handwriting_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/handwriting',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeHandwritingResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_id_card_async(self, request):
"""身份证识别
识别用户上传的身份证图片或者用户提供的华为云上OBS的身份证图片文件的URL中的文字内容并将识别的结果返回给用户。 说明: 身份证识别只支持中国大陆汉族身份证识别。 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeIdCardRequest request
:return: RecognizeIdCardResponse
"""
return self.recognize_id_card_with_http_info(request)
def recognize_id_card_with_http_info(self, request):
"""身份证识别
识别用户上传的身份证图片或者用户提供的华为云上OBS的身份证图片文件的URL中的文字内容并将识别的结果返回给用户。 说明: 身份证识别只支持中国大陆汉族身份证识别。 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeIdCardRequest request
:return: RecognizeIdCardResponse
"""
all_params = ['recognize_id_card_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/id-card',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeIdCardResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_license_plate_async(self, request):
"""车牌识别
识别用户上传的车牌图片或者用户提供的华为云上OBS的车牌图片文件的URL中的文字内容并将识别的结果返回给用户。 注意: 车牌识别服务由于内部原因暂不支持用户调用调用入口改为VCR服务车辆识别功能后续使用敬请关注上线通知。
:param RecognizeLicensePlateRequest request
:return: RecognizeLicensePlateResponse
"""
return self.recognize_license_plate_with_http_info(request)
def recognize_license_plate_with_http_info(self, request):
"""车牌识别
识别用户上传的车牌图片或者用户提供的华为云上OBS的车牌图片文件的URL中的文字内容并将识别的结果返回给用户。 注意: 车牌识别服务由于内部原因暂不支持用户调用调用入口改为VCR服务车辆识别功能后续使用敬请关注上线通知。
:param RecognizeLicensePlateRequest request
:return: RecognizeLicensePlateResponse
"""
all_params = ['recognize_license_plate_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/license-plate',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeLicensePlateResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_mvs_invoice_async(self, request):
"""机动车销售发票识别
识别用户上传的机动车销售发票图片或者用户提供的华为云上OBS的机动车销售发票图片文件的URL中的文字内容并将识别的结果返回给用户。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeMvsInvoiceRequest request
:return: RecognizeMvsInvoiceResponse
"""
return self.recognize_mvs_invoice_with_http_info(request)
def recognize_mvs_invoice_with_http_info(self, request):
"""机动车销售发票识别
识别用户上传的机动车销售发票图片或者用户提供的华为云上OBS的机动车销售发票图片文件的URL中的文字内容并将识别的结果返回给用户。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeMvsInvoiceRequest request
:return: RecognizeMvsInvoiceResponse
"""
all_params = ['recognize_mvs_invoice_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/mvs-invoice',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeMvsInvoiceResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_passport_async(self, request):
"""护照识别
识别用户上传的护照首页图片中的文字信息并返回识别的结构化结果。当前版本支持中国护照的全字段识别。外国护照支持护照下方两行国际标准化的机读码识别并可从中提取6-7个关键字段信息。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizePassportRequest request
:return: RecognizePassportResponse
"""
return self.recognize_passport_with_http_info(request)
def recognize_passport_with_http_info(self, request):
"""护照识别
识别用户上传的护照首页图片中的文字信息并返回识别的结构化结果。当前版本支持中国护照的全字段识别。外国护照支持护照下方两行国际标准化的机读码识别并可从中提取6-7个关键字段信息。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizePassportRequest request
:return: RecognizePassportResponse
"""
all_params = ['recognize_passport_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/passport',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizePassportResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_quota_invoice_async(self, request):
"""定额发票识别
识别定额发票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeQuotaInvoiceRequest request
:return: RecognizeQuotaInvoiceResponse
"""
return self.recognize_quota_invoice_with_http_info(request)
def recognize_quota_invoice_with_http_info(self, request):
"""定额发票识别
识别定额发票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeQuotaInvoiceRequest request
:return: RecognizeQuotaInvoiceResponse
"""
all_params = ['recognize_quota_invoice_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/quota-invoice',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeQuotaInvoiceResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_taxi_invoice_async(self, request):
"""出租车发票识别
识别出租车发票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTaxiInvoiceRequest request
:return: RecognizeTaxiInvoiceResponse
"""
return self.recognize_taxi_invoice_with_http_info(request)
def recognize_taxi_invoice_with_http_info(self, request):
"""出租车发票识别
识别出租车发票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTaxiInvoiceRequest request
:return: RecognizeTaxiInvoiceResponse
"""
all_params = ['recognize_taxi_invoice_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/taxi-invoice',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeTaxiInvoiceResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_toll_invoice_async(self, request):
"""车辆通行费发票识别
识别车辆通行费发票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTollInvoiceRequest request
:return: RecognizeTollInvoiceResponse
"""
return self.recognize_toll_invoice_with_http_info(request)
def recognize_toll_invoice_with_http_info(self, request):
"""车辆通行费发票识别
识别车辆通行费发票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTollInvoiceRequest request
:return: RecognizeTollInvoiceResponse
"""
all_params = ['recognize_toll_invoice_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/toll-invoice',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeTollInvoiceResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_train_ticket_async(self, request):
"""火车票识别
识别火车票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTrainTicketRequest request
:return: RecognizeTrainTicketResponse
"""
return self.recognize_train_ticket_with_http_info(request)
def recognize_train_ticket_with_http_info(self, request):
"""火车票识别
识别火车票中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTrainTicketRequest request
:return: RecognizeTrainTicketResponse
"""
all_params = ['recognize_train_ticket_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/train-ticket',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeTrainTicketResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_transportation_license_async(self, request):
"""道路运输证识别
识别道路运输证首页中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTransportationLicenseRequest request
:return: RecognizeTransportationLicenseResponse
"""
return self.recognize_transportation_license_with_http_info(request)
def recognize_transportation_license_with_http_info(self, request):
"""道路运输证识别
识别道路运输证首页中的文字信息,并返回识别的结构化结果。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeTransportationLicenseRequest request
:return: RecognizeTransportationLicenseResponse
"""
all_params = ['recognize_transportation_license_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/transportation-license',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeTransportationLicenseResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_vat_invoice_async(self, request):
"""增值税发票识别
识别用户上传的增值税发票图片或者用户提供的华为云上OBS的增值税发票图片文件的URL中的文字内容并将识别的结果返回给用户。 说明: 该增值税发票仅限于中华人民共和国境内使用的增值税发票。 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeVatInvoiceRequest request
:return: RecognizeVatInvoiceResponse
"""
return self.recognize_vat_invoice_with_http_info(request)
def recognize_vat_invoice_with_http_info(self, request):
"""增值税发票识别
识别用户上传的增值税发票图片或者用户提供的华为云上OBS的增值税发票图片文件的URL中的文字内容并将识别的结果返回给用户。 说明: 该增值税发票仅限于中华人民共和国境内使用的增值税发票。 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeVatInvoiceRequest request
:return: RecognizeVatInvoiceResponse
"""
all_params = ['recognize_vat_invoice_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/vat-invoice',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeVatInvoiceResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_vehicle_license_async(self, request):
"""行驶证识别
识别用户上传的行驶证图片或者用户提供的华为云上OBS的行驶证图片文件的URL中主页和副页的文字内容并将识别的结果返回给用户。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeVehicleLicenseRequest request
:return: RecognizeVehicleLicenseResponse
"""
return self.recognize_vehicle_license_with_http_info(request)
def recognize_vehicle_license_with_http_info(self, request):
"""行驶证识别
识别用户上传的行驶证图片或者用户提供的华为云上OBS的行驶证图片文件的URL中主页和副页的文字内容并将识别的结果返回给用户。 说明: 如果图片中包含多张卡证票据,请调用智能分类识别服务。
:param RecognizeVehicleLicenseRequest request
:return: RecognizeVehicleLicenseResponse
"""
all_params = ['recognize_vehicle_license_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/vehicle-license',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeVehicleLicenseResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_web_image_async(self, request):
"""网络图片识别
识别用户上传的网络图片中的文字内容,并返回识别的结构化结果。
:param RecognizeWebImageRequest request
:return: RecognizeWebImageResponse
"""
return self.recognize_web_image_with_http_info(request)
def recognize_web_image_with_http_info(self, request):
"""网络图片识别
识别用户上传的网络图片中的文字内容,并返回识别的结构化结果。
:param RecognizeWebImageRequest request
:return: RecognizeWebImageResponse
"""
all_params = ['recognize_web_image_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/web-image',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeWebImageResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def recognize_vin_async(self, request):
"""VIN码识别
识别图片中的车架号信息,并将识别结果返回给用户。
:param RecognizeVinRequest request
:return: RecognizeVinResponse
"""
return self.recognize_vin_with_http_info(request)
def recognize_vin_with_http_info(self, request):
"""VIN码识别
识别图片中的车架号信息,并将识别结果返回给用户。
:param RecognizeVinRequest request
:return: RecognizeVinResponse
"""
all_params = ['recognize_vin_request_body']
local_var_params = {}
for attr in request.attribute_map:
if hasattr(request, attr):
local_var_params[attr] = getattr(request, attr)
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
if isinstance(request, SdkStreamRequest):
body_params = request.get_file_stream()
response_headers = []
header_params['Content-Type'] = http_utils.select_header_content_type(
['application/json;charset=UTF-8'])
auth_settings = []
return self.call_api(
resource_path='/v1.0/ocr/vin',
method='POST',
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body_params,
post_params=form_params,
response_type='RecognizeVinResponse',
response_headers=response_headers,
auth_settings=auth_settings,
collection_formats=collection_formats,
request_type=request.__class__.__name__)
def call_api(self, resource_path, method, path_params=None, query_params=None, header_params=None, body=None,
post_params=None, response_type=None, response_headers=None, auth_settings=None,
collection_formats=None, request_type=None):
"""Makes the HTTP request and returns deserialized data.
:param resource_path: Path to method endpoint.
:param method: Method to call.
:param path_params: Path parameters in the url.
:param query_params: Query parameters in the url.
:param header_params: Header parameters to be
placed in the request header.
:param body: Request body.
:param post_params dict: Request post form parameters,
for `application/x-www-form-urlencoded`, `multipart/form-data`.
:param auth_settings list: Auth Settings names for the request.
:param response_type: Response data type.
:param response_headers: Header should be added to response data.
:param collection_formats: dict of collection formats for path, query,
header, and post parameters.
:param request_type: Request data type.
:return:
Return the response directly.
"""
return self.do_http_request(
method=method,
resource_path=resource_path,
path_params=path_params,
query_params=query_params,
header_params=header_params,
body=body,
post_params=post_params,
response_type=response_type,
response_headers=response_headers,
collection_formats=collection_formats,
request_type=request_type,
async_request=True)