AliyunOCR
set_public_auth
set_public_auth (access_key_id, access_key_secret)
Description
Sets the authorization information. You can find your AccessKey on the AccessKey Management page in the Alibaba Cloud console.
Parameters
access_key_id <str> The AccessKey ID.
access_key_secret <str> The AccessKey secret that corresponds to the AccessKey ID.
Sample call rpa.ai.aliyun_ocr.set_public_auth
The built-in software development kit (SDK) uses Alibaba Cloud OCR. Before you call this method, you must activate the relevant services for OCR. For more information, see OCR Capabilities under Asset Management in the Alibaba Cloud Robotic Process Automation (RPA) console. After you activate the services, we recommend that you use server-side authentication for improved security. Otherwise, you must configure the AccessKey ID and secret in your code. This is typically required when the Alibaba Cloud account that is used to activate the OCR service is different from the Alibaba Cloud account that is used for RPA.
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
ak = 'LT******XH'
ak_secret = 'YI******M3'
rpa.ai.aliyun_ocr.set_public_auth(ak ,ak_secret )recognize_advanced
recognize_advanced (image_path, output_char_info=False, need_rotate=False, output_table=False, need_sort_page=False, output_figure=False, no_stamp=False, paragraph=False, row=False)
Description
Recognizes full text with high precision.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
output_char_info <bool> Specifies whether to output the recognition result for each character.
need_rotate <bool> Specifies whether to enable the auto-rotation feature.
output_table <bool> Specifies whether to output table recognition results, including cell information.
need_sort_page <bool> Specifies whether to output text blocks in order.
output_figure <bool> Specifies whether to enable the figure detection feature.
no_stamp <bool> Specifies whether to enable the stamp removal feature.
paragraph <bool> Specifies whether to enable the paragraph segmentation feature.
row <bool> Specifies whether to enable the feature that returns results line by line.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442247.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_advanced
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/1845565761/p551695.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_advanced(image_url)
# Get the text content recognized by OCR
# content = json.loads(output_result_dict["Data"])['content']
# print(content)recognize_handwriting
recognize_handwriting (image_path, output_char_info=False, need_rotate=False, output_table=False, need_sort_page=False)
Description
Recognizes handwritten text.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
output_char_info <bool> Specifies whether to output the recognition result for each character.
need_rotate <bool> Specifies whether to enable the auto-rotation feature.
output_table <bool> Specifies whether to output table recognition results, including cell information.
need_sort_page <bool> Specifies whether to output text blocks in order.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442248.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_handwriting
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/3733380861/p623828.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_handwriting(image_url)
# Get the text content recognized by OCR
# content = json.loads(output_result_dict["Data"])['content']
# print(content)recognize_general
recognize_general (image_path)
Description
Recognizes general text.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442250.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_general
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/9845565761/p555969.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_general(image_url)
# Get the text content recognized by OCR
# content = json.loads(output_result_dict["Data"])['content']
# print(content)recognize_document_structure
recognize_document_structure (image_path, output_char_info=False, need_rotate=False, output_table=False, need_sort_page=False, page=False, no_stamp=False, paragraph=False, row=False, use_new_style_output=False)
Description
Recognizes the structure of a document.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
output_char_info <bool> Specifies whether to output the recognition result for each character.
need_rotate <bool> Specifies whether to enable the auto-rotation feature.
output_table <bool> Specifies whether to output table recognition results, including cell information.
need_sort_page <bool> Specifies whether to output text blocks in order.
page <bool> Specifies whether to enable the paging feature.
no_stamp <bool> Specifies whether to enable the stamp removal feature.
paragraph <bool> Specifies whether to enable the paragraph segmentation feature.
row <bool> Specifies whether to enable the feature that returns results line by line.
use_new_style_output <bool> Specifies whether to return the output in the new format.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/469431.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_document_structure
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/1443380861/p623845.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_document_structure(image_url)
# Get the text content recognized by OCR
# content = json.loads(output_result_dict["Data"])['content']
# print(content)recognize_table_ocr
recognize_table_ocr (image_path, need_rotate=False, lineless=False, skip_detection=False)
Description
Recognizes tables in an image.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
need_rotate <bool> Specifies whether to enable the auto-rotation feature.
lineless <bool> Specifies whether the table is lineless.
skip_detection <bool> Specifies whether to skip detection.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442251.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_table_ocr
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/9833380861/p623831.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_table_ocr(image_url)
# Get the table content recognized by OCR
# content = json.loads(output_result_dict["Data"])['content']
# print(content)recognize_id_card
recognize_id_card (image_path, output_figure=False, output_quality_info=False)
Description
Recognizes text on ID cards.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
output_figure <bool> Specifies whether to enable the figure detection feature.
output_quality_info <bool> Specifies whether to enable the ID card quality detection feature.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442255.html. <Dict>
<Dict>
Sample call rpa.ai.aliyun_ocr.recognize_id_card
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/8543380861/p623850.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_id_card(image_url)
# Get the ID card content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']['face']['data']
# print(data)recognize_bank_card
recognize_bank_card (image_path)
Description
Recognizes text on bank cards.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442259.html. <Dict>
<Dict>
Sample call rpa.ai.aliyun_ocr.recognize_bank_card
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/6743380861/p623853.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_bank_card(image_url)
# Get the bank card content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)recognize_mixed_invoices
recognize_mixed_invoices (image_path)
Description
Recognizes text on various types of invoices.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442266.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_mixed_invoices
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/4153380861/p623855.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_mixed_invoices(image_url)
# Get the mixed invoice content recognized by OCR
# Data = json.loads(output_result_dict["Data"])
# print(Data)recognize_invoices
recognize_invoices (image_path)
Description
Recognizes text on value-added tax (VAT) invoices.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442267.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_invoices
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/0653380861/p623862.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_invoices(image_url)
# Get the VAT invoice content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)recognize_air_itinerary
recognize_air_itinerary (image_path)
Description
Recognizes text on air travel itineraries.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442270.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_air_itinerary
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/8263380861/p623872.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_air_itinerary(image_url)
# Get the air travel itinerary content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)recognize_car_vin_code
recognize_car_vin_code (image_path)
Description
Recognizes vehicle identification numbers (VINs).
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442302.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_car_vin_code
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/8893380861/p623904.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_car_vin_code(image_url)
# Get the vehicle VIN content recognized by OCR
# content = json.loads(output_result_dict["Data"])['content']
# print(content)recognize_train_invoice
recognize_train_invoice (image_path)
Description
Recognizes text on train tickets.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442271.html. <Dict>
<Dict>
Sample call rpa.ai.aliyun_ocr.recognize_train_invoice
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/1563380861/p623876.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_train_invoice(image_url)
# Get the train ticket content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)recognize_taxi_invoice
recognize_taxi_invoice (image_path)
Description
Recognizes text on taxi invoices.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442272.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_taxi_invoice
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/9663380861/p623886.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_taxi_invoice(image_url)
# Get the taxi invoice content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)recognize_roll_ticket
recognize_roll_ticket (image_path)
Description
Recognizes text on VAT roll invoices.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442273.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_roll_ticket
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/3073380861/p623889.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_roll_ticket(image_url)
# Get the VAT roll invoice content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)recognize_ride_hailing_itinerary
recognize_ride_hailing_itinerary (image_path)
Description
Recognizes text on ride-hailing itineraries.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442281.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_ride_hailing_itinerary
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/2083380861/p623894.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_ride_hailing_itinerary(image_url)
# Get the ride-hailing itinerary content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)recognize_car_number
recognize_car_number (image_path)
Description
Recognizes license plates.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442301.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_car_number
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/1704380861/p623916.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_car_number(image_url)
# Get the license plate content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']['data']
# print(data)recognize_vehicle_license
recognize_vehicle_license (image_path)
Description
Recognizes text on vehicle licenses.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442298.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_vehicle_license
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/7619580861/p625352.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_vehicle_license(image_url)
# Get the vehicle license content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']['face']['data']
# print(data)recognize_driving_license
recognize_driving_license (image_path)
Description
Recognizes text on driver's licenses.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442299.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_driving_license
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/9714380861/p623946.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_driving_license(image_url)
# Get the driver's license content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']['face']['data']
# print(data)recognize_basic
recognize_basic (image_path)
Description
Recognizes text in E-commerce images.
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442249.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_basic
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/7043380861/p623838.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_basic(image_url)
# Get the text content from E-commerce images recognized by OCR
# content = json.loads(output_result_dict["Data"])['content']
# print(content)recognize_quota_invoice
recognize_quota_invoice (image_path)
Description
OCR of fixed-amount invoices
Parameters
image_path <str> The path of the image to recognize. This can be a local path or a URL.
Return value
A dictionary that contains the raw result returned by the OCR API. For information about how to parse the result, see https://help.aliyun.com/document_detail/442269.html. <Dict>
Sample call rpa.ai.aliyun_ocr.recognize_quota_invoice
# To get the service, see the official Alibaba Cloud OCR website: https://ai.aliyun.com/ocr
# The following code provides an example of how to call the method:
image_url = 'https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/3853380861/p623867.png'
output_result_dict = rpa.ai.aliyun_ocr.recognize_quota_invoice(image_url)
# Get the quota invoice content recognized by OCR
# data = json.loads(output_result_dict["Data"])['data']
# print(data)