Character Recognition using Einstein

Einstein Vision brings the power to use AI and deep learning models in Salesforce for detection as well as classification. It includes these APIs - Einstein Image Classification, Einstein Object Detection and Einstein OCR (Optical Character Recognition).

Einstein OCR provides OCR (optical character recognition) models that are able to detect characters as well as numbers in an image. It gives high accuracy in reading from formatted as well as unformatted text in the image. With the help of Einstein OCR, we are able to fully automate the processes in salesforce. After Generating a private key and access token, We can access the models from a single REST API endpoint. Each model is used for specific use cases, such as business card scanning, product lookup, and digitizing documents and tables etc.

For Example - The company wants to make their detailing form section fast and easy for their clients. For that, clients only need to upload their Id which contains their basic information. With help of Einstein OCR API the company is able to fetch their basic details in salesforce from the client’s Id and automate the process of filling the form. The user only needs to check their details.

Einstein OCR Models

  • 1. OCRModel -
    • This model is used for detecting text from Images that contain unformatted data like Business cards.
  • 2. Tabulatev2 -
    • This model is used for detecting text from images that contain a table.
  • On the basis of response type, it can be categorized in following types :-
    • Text
    • In order to extract text from image, set parameter model Id to “OCRModel” and task to “text” in api calling.In response you can get task type, probability(Confidence) that the detected bounding box contains text, label(String of alphanumeric characters), four boundingBox coordinate [minX, minY, maxX, maxY].
    • Contact
    • In contact, generally we use business cards or data which has labels. You need to set modelId to “OCRModel” and task to “contact”. Response is the same as text only an attribute is added which has a tag value.
  • Table
  • This type is used to detect alphanumeric strings inside the table,specify api parameter modelId to “tabulatev2” and task to “table”. All fields of response are as text type except one additional attribute “cellLocation” in which it specifies the label Location inside table.

  • enstein ocr image 1

In this walkthrough, you will see the use of Einstein OCR API to pass an image into the OCR model. The model detects any text in the image and returns the text and other details in the response.

1.   First you need to sign up in Einstein Platform services and download the private key.

Steps to Download Private Key:-

  • You have a salesforce account, then sign up in the Einstein Platform Services link:
  • (If you already signed up then you should click on ‘Lost your private key ? if your key doesn’t work.)

  • enstein ocr image 2

  • Download & save the private key safely.

2.   Now you need to generate an oauth token. There are two ways either directly from the link or from the apex code.

Steps to Generate a Token:-

  • Open given a link to open Generate an OAuth Token:

  • enstein ocr image 3

  • Fill the email or account id and upload ‘Private Key File’ .
  • Set Token expiry and click on ‘GET TOKEN’.

  • enstein ocr image 4

3.   Now, after successful authentication, Use generated token code in Einstein OCR API to access Einstein Platform Services.

Business Scenarios

There are several scenarios where Einstein OCR functionality have application.

  • After writing the prescription by the doctor at the admitted patient bed, all instructions on the prescription go to the medical staff and required medicine will go to the hospital pharmacy automatically.
  • Scanning of handwritten application forms like bank account opening forms.
  • Reading answers from handwritten answer sheets of the test.
  • Scanning the business cards and saving their contact details.

For any query on Einstein OCR, contact