LPR Events
Overview
LPR events are generated when a Viewtron camera detects a license plate. The event includes the plate number and, depending on the source (IPC or NVR), additional vehicle attributes.
Two classes handle LPR events:
LPR— IPC v1.x format (direct from camera)VehicleLPR— NVR v2.0 format (via NVR, richer data)
Both have category == "lpr".
Common Properties
Available on both IPC and NVR LPR events:
| Method | Returns | Description |
|---|---|---|
get_plate_number() | str | Detected plate text (e.g., "ABC1234") |
get_plate_group() | str | Plate list/group name (see IPC vs NVR below) |
Plus all common properties from ViewtronEvent (timestamp, camera name, images, etc.):
| Method | Returns | Description |
|---|---|---|
get_ip_cam() | str | Camera device name |
get_alarm_type() | str | Raw alarm type code ("VEHICE" for IPC, "vehicle" for NVR) |
get_alarm_description() | str | "License Plate Detection" |
get_time_stamp_formatted() | str | Timestamp like "2026-04-09 15:30:45" |
get_time_stamp() | str | Unix timestamp string (for filenames) |
source_image_exists() | bool | True if an overview/scene image is available |
target_image_exists() | bool | True if a cropped plate image is available |
get_source_image_bytes() | bytes or None | Overview image as JPEG bytes |
get_target_image_bytes() | bytes or None | Cropped plate image as JPEG bytes |
IPC vs NVR Comparison
| Feature | IPC (LPR class) | NVR (VehicleLPR class) |
|---|---|---|
| Plate number | Yes | Yes |
| Plate group | Fixed: "whiteList", "blackList", "temporaryList" | User-defined group names from NVR database |
| Plate color | No | Yes |
| Vehicle type | No | Yes (sedan, SUV, truck, etc.) |
| Vehicle color | No | Yes |
| Vehicle brand | No | Yes (Toyota, Ford, etc.) |
| Vehicle model | No | Yes |
| Car owner | No | Yes (from NVR database) |
| Channel ID | No | Yes |
NVR Vehicle Attributes
These methods are only available on VehicleLPR (NVR v2.0) events:
| Method | Returns | Example |
|---|---|---|
get_plate_number() | str | "ABC1234" |
get_plate_color() | str | "blue", "yellow", "white" |
get_plate_group() | str | User-defined group name |
get_car_type() | str | "sedan", "SUV", "truck" |
get_car_color() | str | "white", "black", "red" |
get_car_brand() | str | "Toyota", "Ford", "Honda" |
get_car_model() | str | Model name |
get_car_owner() | str | Owner name from NVR plate database |
All vehicle attribute methods return an empty string if the value is not detected or not available.
Code Examples
Basic Plate Logging
def handle_event(event, client_ip):
if event.category == "lpr":
plate = event.get_plate_number()
group = event.get_plate_group()
print(f"Plate: {plate} | Group: {group} | Camera: {event.get_ip_cam()}")
Full Vehicle Details (NVR)
from viewtron.events import VehicleLPR
def handle_event(event, client_ip):
if event.category == "lpr":
print(f"Plate: {event.get_plate_number()}")
# NVR provides vehicle attributes
if isinstance(event, VehicleLPR):
print(f" Vehicle: {event.get_car_color()} {event.get_car_brand()} {event.get_car_type()}")
print(f" Owner: {event.get_car_owner()}")
print(f" Plate color: {event.get_plate_color()}")
Saving Plate Images
def handle_event(event, client_ip):
if event.category == "lpr":
plate = event.get_plate_number()
# Save the overview image
if event.source_image_exists():
with open(f"{plate}_overview.jpg", "wb") as f:
f.write(event.get_source_image_bytes())
# Save the cropped plate image
if event.target_image_exists():
with open(f"{plate}_plate.jpg", "wb") as f:
f.write(event.get_target_image_bytes())
IPC Plate Groups
IPC cameras use three fixed plate groups:
"whiteList"— Allow list"blackList"— Block list"temporaryList"— Temporary/visitor list
These are hardcoded in the camera firmware. The group is determined by which list the plate was added to via the camera's web interface or the ViewtronCamera API.
If the plate is not in the camera's database, get_plate_group() returns an empty string.
NVR Plate Groups
NVR plate groups are user-defined — you create custom group names in the NVR interface (e.g., "Residents", "Staff", "Visitors"). The get_plate_group() method returns whatever group name was assigned in the NVR database.
If the plate is not in the NVR database, get_plate_group() returns an empty string.
Related Pages
- ViewtronEvent — common properties and methods
- Images — working with plate and overview images
- ViewtronCamera — managing the plate database (add, delete, modify plates)
- API Reference: License Plate Recognition — raw XML endpoint documentation