OCR document structure recognition

更新时间:
复制 MD 格式

1. Component introduction

Note

Prerequisites: None

Recommended next component: Conditional Branch. Use branch conditions to check whether the OCR call is successful and design the subsequent flow.

This component extracts structured information from documents using Optical Character Recognition (OCR) (example).

2. Inputs

Note

For details about each input, see the help information on the component panel in the application flow editor.

3. Outputs

Note

For details about each output, see the help information on the component panel in the application flow editor.

3.1. Key API return results

This output returns a dictionary that contains the key recognition results from the API call. The following table describes the key-value pairs in the dictionary.

Key

Key terms

Value data type

content

A collection of the text blocks recognized from the image.

String

3.2. Error message

This output returns a string that contains the error code and error message. For more information, see the OCR Error Center.

https://next.api.aliyun.com/document/ocr-api/2021-07-07/errorCode

4. Component usage example

4.1. Component configuration example

  1. Set AI engine to Alibaba Cloud OCR.

  2. For Image file path to recognize, enter the file path of the image that you want to recognize. This example uses the following image:

    image

  3. Keep the default values for the advanced options.

4.2. Example execution result

5. Flow example

5.1. Build the flow

  1. Use the OCR document structure recognition component to select the image file path.

  2. Use the Conditional Branch component to check if the OCR call is successful. Set the branch condition so that `v_documents_tructure_success_1` is equal to the Boolean value `True`.

  3. In the success branch, use the Get Value of a Specified Key component to retrieve the value of the `content` key from the `v_documents_tructure_data_1` dictionary.

  4. Use the Record Log component to print the recognition result.

  5. In the failure branch, use the Record Log component to print the error message. image

5.2. Execution result

As shown in the following figure, after the OCR call is successful, the recognition result is printed in the log panel.