OCR¶
Any number of textual fields can be scanned from the image. By default this happens for vehicle_direction as in this Hikvision example.

Each field can have optional permitted values (Unknown returned if none of them found) and a set of corrections to handle occasional OCR errors, where corrections are simple strings or regular expressions.
Use the OCR Tool for quick tests of configuration with a local image
OCR Stages¶
- Crop the image to a box starting at
xandyposition, measured from the bottom left of the image and a given height and width - Optionally invert the image colours for better capture accuracy
- Run OCR over the cropped image
- Apply optional corrections
- Optionally restrict to a list of values, forcing case if needed
Example Configuration¶
The configuration for this can be in the anpr2mqtt.yaml file, or in environment variables or command line arguments.
In this example hik_direction is the ocr_field_id value that can be referenced in an event, and label is the name of the attribute that will appear in the Home Asssitant entity attributes.
ocr:
hik_direction:
label: vehicle_direction
values: Reverse, Forward
invert: true
crop:
x: 0
y: 850
h: 30
w: 650
correction:
Forward:
- F.*wd
Reverse:
- R.*v.*se
- Back.*