Note, the OCR field requires an internet connection to return image text.
The OCR (Optical Character Recognition) Field type lets you convert written or printed information into text via your device's camera.
Setting up an OCR Field
After creating a new Form screen, you will be taken to the Form Designer screen. The Form Designer screen provides a visual view of your Form and a drag-and-drop approach for creating your Form design. Along the left section of the Designer, you will find a column of Basic and Advanced Field types.
Two Unique properties specific to the OCR field are Result Mode and On Capture Action.
Result Mode
- Raw Text
When this option is chosen, the raw test result will be displayed (extracted from the image).
- JSON
When this option is chosen, the complete OCR JSON response will be available in other fields via the JSONVAL()formula.
On Capture Action
- Define an action each time a successful OCR result is returned.
When extracting specific information out of a JSON result, https://jsonpathfinder.com/ , might be of assistance.
Isolating Specific Text
An Advanced Options property enables the selection of a specific area for text conversion of the captured or chosen image.
Result Examples
Raw Text
Images was uploaded from the device gallery.
Raw JSON
Image was uploaded from the device gallery.
The above image depicts a RAW JSON result (text field) with its dynamic value property driven from the OCT Field-JSON Mode's (OCR Field) dataname.
Form Designer Build:
The JSON result can be processed using JSON Path Syntax.
JSON Result (full)
{ "version": "3.2.0", "modelVersion": "2021-04-12", "readResults": [ { "page": 1, "angle": 12.5894, "width": 800, "height": 449, "unit": "pixel", "lines": [ { "boundingBox": [ 91, 0, 788, 137, 781, 174, 84, 35 ], "text": "Nutrition Facts Amount Per Serving", "appearance": { "style": { "name": "other", "confidence": 0.878 } }, "words": [ { "boundingBox": [ 90, 0, 281, 34, 274, 70, 84, 36 ], "text": "Nutrition", "confidence": 0.994 }, { "boundingBox": [ 300, 38, 429, 64, 422, 98, 293, 73 ], "text": "Facts", "confidence": 0.995 }, { "boundingBox": [ 460, 70, 585, 98, 577, 130, 453, 104 ], "text": "Amount", "confidence": 0.996 }, { "boundingBox": [ 592, 99, 650, 113, 643, 144, 584, 131 ], "text": "Per", "confidence": 0.997 }, { "boundingBox": [ 657, 115, 783, 145, 775, 173, 650, 145 ], "text": "Serving", "confidence": 0.996 } ] } ] } ] }
JSON Result (retrieve all words text)
Syntax:
$.readResults[0].lines[*].words[*].text
[ "Nutrition", "Facts", "Amount", "Per", "Serving" ]
However, in a Text field's dynamic value, the above syntax would need to be used in junction with our JSON() function.
Formula:
SUBSTITUTE(STRING(JSONLIST({{myOCRfieldJSON}}, 'readResults[0].lines[*].words[*].text')) , '|' , '\n')
If there is a specific value you want to extract then replace the '*' with a numeric value. For example, to capture the 2nd line in an OCR Result: STRING(JSONLIST({{myOCRfieldJSON}}, 'readResults[0].lines[1].text'))
For more information on JSON formula, please review Formula Cheat Sheet - Data Interchange.