What is Einstein OCR?
We all know that OCR is an Optical Character Recognition which can detect and extract text from images. But, what about Einstein OCR?
Einstein OCR provides models that can detect text in an image such as Business cards, Images that contain unformatted data and images that contain data in tables.
More info can be found here: https://metamind.readme.io/docs/what-is-einstein-ocr
In this blog post, we will focus on the Business Card Model. When choosing business card model, Einstein OCR can detect the entity type text such as Person, Organization, Email, Phone, Address, etc...
To get Started with Einstein Vision, you first need to register for an Account (If you don't already have one).
Go to: https://api.einstein.ai/signup and Click on Sign Up using Salesforce.
It is quite straight forward after that. If all goes well, you should see a screen with your Einstein Private Key like below. Download the key and keep it safe for later.
Deploy Salesforce code
Once you have an Einstein Account, we can start the setup. For the next step, you will require some basic developer skills.
Download this SFDX project from my public github repository: https://github.com/kevanmoothien/einsteinvisionocr
Connect the project to your Organization using SFDX: Authorize an Org option and then deploy all the elements inside the project structure.
(Here is a great trailhead which will explain same: https://trailhead.salesforce.com/en/content/learn/projects/quickstart-vscode-salesforce)
Configure Permission for Salesforce App
When everything has been deployed, you can assign the App Einstein OCR to the desired Profile.
Setup Einstein Vision
Configuring Einstein Vision is pretty straight forward, just switch to the Einstein OCR app on your Salesforce and open the Einstein Vision Setup tab
Enter the email address you used to Sign Up (make sure it is the email and not the Salesforce Username; you should find it in the welcome Einstein Mail).
Then use the Upload Files button to upload the private key (einstein_platform.pem file that you downloaded previously)
When saving the setting, you should have a green tick icon on the right hand side of the component to validate that the Account is valid.
|Setup Einstein Vision|
OCR in Action
To see the OCR in action, simply click on the Einstein OCR tab next to the Einstein Vision Setup tab.
Insert a Business Card Image Url and click on Scan.
The page comprises of 3 simple component:
- Component to input the Image Url
- Another one for Preview the Business Card
- lastly, result previewer
From the above example, you can see Mark Benioff business card. It has already categorised the different elements found on the Business Card.
If you want to dive into more details on how the API call is done and detection result is processed, you can just take a look at the class EinsteinVisionUtils and Prediction class in the source code.