Optical Character Recognition (OCR)

Document Understanding can detect and recognize text in a document. OCR draws bounding boxes around the printed or hand-written text that it locates in a document, and digitizes the text.

If you have a PDF with text, Document Understanding locates the text in that document and extracts the text. It then provides bounding boxes for the identified text. Text Detection can be used with Document AI or Image Analysis models.

Document Understanding provides a confidence score for each text grouping. The confidence score is a decimal number. Scores closer to 1 indicate a higher confidence in the extracted text, while lower scores indicate lower confidence score. The range of the confidence score for each label is from 0 to 1.

Supported features are:
  • Word extraction
  • Text line extraction
  • Confidence score
  • Bounding polygons
  • Single request
  • Batch request
Limitations are:
  • OCR is limited to English.

OCR Example

An example of OCR use in Document Understanding.

Input document
Figure 1. OCR Input
Receipt from a fictitious cafe, including two line items, tax, subtotal and total amounts.
API Request:
{ "analyzeDocumentDetails":
                { "compartmentId": "",
                "document": { "namespaceName": "",
                "bucketName": "",
                "objectName": "",
                "source": "OBJECT_STORAGE" },
                "features":
                [ { "featureType": "TEXT_DETECTION" },
                { "featureType": "LANGUAGE_CLASSIFICATION",
                "maxResults": 5 } ]
                } 
                }
.
Output:
Figure 2. OCR Output
The receipt with all the fields identifed
API Response:
{ "documentMetadata":
              { "pageCount": 1,
              "mimeType": "image/jpeg" },
              "pages":
              [ { "pageNumber": 1,
              "dimensions":
              { "width": 361, 
              "height": 600,
              "unit": "PIXEL" },
              "detectedLanguages":
              [ { "languageCode": "ENG",
              "confidence": 0.9999994 },
              { "languageCode": "ARA", 
              "confidence": 4.7619238e-7 },
              { "languageCode": "NLD",
              "confidence": 7.2325456e-8 },
              { "languageCode": "CHI_SIM",
              "confidence": 3.0645523e-8 },
              { "languageCode": "ITA",
              "confidence": 8.6900076e-10 } ],
              "words":
              [ { "text": "Example",
              "confidence": 0.99908227,
              "boundingPolygon":
              { "normalizedVertices": 
              [ { "x": 0.0664819944598338, 
              "y": 0.011666666666666667 },
              { "x": 0.22160664819944598,
              "y": 0.011666666666666667 },
              { "x": 0.22160664819944598,
              "y": 0.035 },
              { "x": 0.0664819944598338,
              "y": 0.035 } ]
              } ... "detectedLanguages":
              [ { "languageCode": "ENG", 
              "confidence": 0.9999994 } ], ...