Skip to main content

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:

MethodReturnsDescription
get_plate_number()strDetected plate text (e.g., "ABC1234")
get_plate_group()strPlate list/group name (see IPC vs NVR below)

Plus all common properties from ViewtronEvent (timestamp, camera name, images, etc.):

MethodReturnsDescription
get_ip_cam()strCamera device name
get_alarm_type()strRaw alarm type code ("VEHICE" for IPC, "vehicle" for NVR)
get_alarm_description()str"License Plate Detection"
get_time_stamp_formatted()strTimestamp like "2026-04-09 15:30:45"
get_time_stamp()strUnix timestamp string (for filenames)
source_image_exists()boolTrue if an overview/scene image is available
target_image_exists()boolTrue if a cropped plate image is available
get_source_image_bytes()bytes or NoneOverview image as JPEG bytes
get_target_image_bytes()bytes or NoneCropped plate image as JPEG bytes

IPC vs NVR Comparison

FeatureIPC (LPR class)NVR (VehicleLPR class)
Plate numberYesYes
Plate groupFixed: "whiteList", "blackList", "temporaryList"User-defined group names from NVR database
Plate colorNoYes
Vehicle typeNoYes (sedan, SUV, truck, etc.)
Vehicle colorNoYes
Vehicle brandNoYes (Toyota, Ford, etc.)
Vehicle modelNoYes
Car ownerNoYes (from NVR database)
Channel IDNoYes

NVR Vehicle Attributes

These methods are only available on VehicleLPR (NVR v2.0) events:

MethodReturnsExample
get_plate_number()str"ABC1234"
get_plate_color()str"blue", "yellow", "white"
get_plate_group()strUser-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()strModel name
get_car_owner()strOwner 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.