Calling Text OCR API
    • PDF

    Calling Text OCR API

    • PDF

    Article Summary

    Available in Classic and VPC

    Once tests and service deployments have been performed after completing template registration in CLOVA OCR builder, you can use CLOVA OCR through REST API. This guide introduces how to enter images and convert recognition values with the Text OCR API, and their examples.

    Note
    • API calls are available in the same way for Template OCR.
    • For more information on calling APIs. refer to the CLOVA OCR API Guide.

    The overall sequence of entering and converting images with the Text OCR API and description of each sequence are as follows.

    1. Set API environment

    To control Text OCR with an API, you need to first create a domain from CLOVA OCR of the NAVER Cloud Platform console. Once you create a domain in the OCR builder, a unique invokeURL is assigned. InvokeURLs are not disclosed directly to external services for security, and it's designed to be linked to API Gateway of NAVER Cloud Platform to increase the level of security and service processing.

    Link API Gateway to use invokeURLs. There are two methods of linking API Gateway: automatic and manual. Selecting the automatic linkage allows you to easily complete API Gateway linkage in a few clicks. This example introduces the automatic linkage method. The following describes how you can set up an automatic linkage.

    1. In the OCR builder, click the [Create] button to create a secret key.
      image-20191217135217405_en.png
    2. Click the [Automatic linkage] button to link API Gateway automatically.
    3. If you're not using API Gateway, when the Automatic linkage pop-up window appears, click the [OK] button to request subscription.
      image-20191217135507352_en.png
    4. Once the linkage is completed, copy the secret key and OCR invoke URL values required for API calls.
      image-20191217135557688_en.png
      • Secret Key: {X-OCR-SECRET}
      • OCR Invoke URL: {OCR Invoke URL}

    3. Check created URL in API Gateway

    Go to API Gateway of the NAVER Cloud Platform console to check the created URL in API Gateway. If a product named OCR_CUSTOM_API_KR is created successfully, you're ready to make API calls. The following describes how to check the created URL in API Gateway.

    1. From the NAVER Cloud Platform console's Region menu, click and select the region you're using.
    2. From the Platform menu, click and select between VPC and Classic.
    3. Click Services > Application Services > API Gateway menus in that order.
    4. Click the My Products menu.
    5. Check if a product named OCR_CUSTOM_API_KR has been created.
      image-20191217144827615_en.png
      • If it's created successfully, then you're ready to make API calls.

    4. Call API from Postman

    Running Text OCR API allows you to extract text from uploaded images. Image recognition results are returned in JSON format, and you can use returned result values in your service. The following describes how to call the Text OCR API.

    your title goes here

    This guide briefly describes the extraction method. If you're like to learn more details, refer to the CLOVA OCR API Guide.

    1. In Postman, create a new API and set the call method as POST.
    2. For the invoke URL address, enter the API Gateway's invokeURL created in OCR.
      image-20191217171936809_en.png
    3. Enter the X-OCR-SECRET information in the Headers field.
      image-20191217172419810_en.png
      • Content-Type : application/json
      • X-OCR-SECRET : {X-OCR-SECRET }
    4. Add the Text OCR call body in the form of an image recognition request body.
      image-20191217172912524_en.png
      {
          "images": [
            {
              "format": "png",
              "name": "medium",
              "data": null,
              "url": "https://kr.object.ncloudstorage.com/ocr-img/OCR_ko(1)REAN_ko(1).png"
            }
          ],
          "lang": "ko",
          "requestId": "string",
          "resultType": "string",
          "timestamp": {{$timestamp}},
          "version": "V1"
      }
      
    5. Click the [Send] button to check the response result.
      image-20191217173003063_en.png
    6. Check the response result.
      {
      "version":"V1",
      "requestId":"string",
      "timestamp":1576569034247,
      "images":[
        {
          "uid":"9fd73a6aacad4025b3099a36ee55aacd",
          "name":"medium","inferResult":"SUCCESS","message":"SUCCESS",
          "fields":[
              {"inferText":"I","inferConfidence":0.9967288},
              {"inferText":"shall return","inferConfidence":0.9998919},
              {"inferText":"to heaven","inferConfidence":0.9999104},
              {"inferText":"the day","inferConfidence":0.99992156},
              {"inferText":"my picnic","inferConfidence":0.99958915},
              {"inferText":"in this","inferConfidence":0.9998707},
              {"inferText":"beautiful","inferConfidence":0.9988277},
              {"inferText":"world","inferConfidence":0.9999253},
              {"inferText":"ends","inferConfidence":0.99908936},
              {"inferText":"I shall go","inferConfidence":0.99974936},
              {"inferText":"and say","inferConfidence":0.9997728},
              {"inferText":"that it was beautiful","inferConfidence":0.9993808}
              ],
          "validationResult":{"result":"NO_REQUESTED"}}
          ]
      }
      
    7. Use the response result in your service.

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.