Sending image regions for recognition

Aspose.OCR Cloud allows you to extract names, dates, numbers, and other blocks from certain areas of uniform images, such as ID cards, visas, driver’s licenses, applications, and so on. Regions can be provided manually or automatically detected from an image.

To extract a text from one or more areas of an image, send a POST request to the https://api.aspose.cloud/v5.0/ocr/RecognizeRegions Aspose.OCR Cloud REST API endpoint. To authorize the request, pass the access token in Authorization header (Bearer authentication).

The image and recognition parameters are provided in JSON format in the request body.

{
  "image": "Base64 string",
  "settings": {
    "language": "English",
    "makeSkewCorrect": true,
    "rotate": 0,
    "makeBinarization": false,
    "makeContrastCorrection": true,
    "makeUpsampling": false,
    "makeSpellCheck": false,
    "dsrMode": "Regions",
    "dsrConfidence": "Default",
    "resultType": "Text",
    "regions": [
      {
        "rect": {
          "topLeftX": 0,
          "topLeftY": 0,
          "bottomRightX": 300,
          "bottomRightY": 100
        },
        "order": 0
      }
    ]
  }
}

Providing an image

The image is provided in a value of image property as a Base64 encoded string.

Specifying regions

Regions are provided as an array of objects in regions property. For each region, the following properties must be provided:

  • rect - image area, defined by the coordinates of its top-left and bottom-right corners (in pixels).
  • order - relative recognition priority of a region. The higher the number, the further the region’s text will be placed in the recognition result.

Recognition settings

Property Type Default value Description
language string English Specify a language for recognition.
makeSkewCorrect boolean true Automatically correct image tilt (deskew) before proceeding to recognition.
Automatic deskew works for images rotated 15 degrees or less. If the image is rotated by a larger degree or upside down, you must manually specify the rotation angle.
rotate integer 0 Rotate an image by the specified degree.
Should be used when the image is rotated by a significant angle or turned upside down.
makeBinarization boolean false Automatically convert an image to black and white before proceeding to recognition.
makeContrastCorrection boolean true Automatically increase the contrast of an image before proceeding to recognition.
makeUpsampling boolean false Intellectually upscale image to improve small font recognition and detection of dense lines.
makeSpellCheck boolean false Automatically replace commonly misspelled words in recognition results with the correct ones. The dictionary is based on the selected recognition language.
dsrMode string Regions Document structure analysis algorithm.
dsrConfidence string Default Threshold for filtering content blocks detected by the selected structure analysis algorithm.
resultType string Text Recognition results format. All region recognition results will be of the same type.

Return value

If successful, this method returns a string with a unique identifier (GUID) of the image recognition request in the queue.

Otherwise, it returns a HTTP status code corresponding to the error.

What’s next

Recognition will take a few seconds, depending on the size of the image and the current Aspose.Cloud load. See the article Fetching region recognition result for information on how to get an image recognition result from the server.

cURL example