Skip to main content

LPR Events

Overview

LPR events have category === 'lpr'. They are generated when a Viewtron camera detects a license plate.

Unlike the Python SDK, the Node.js SDK uses a single ViewtronEvent object for both IPC and NVR events. The source property tells you which format the event came from, and NVR-only fields (plateColor, vehicle, carOwner) are empty or null on IPC events.

Properties

Common (IPC and NVR)

PropertyTypeDescription
plateNumberstringDetected plate text (e.g., "ABC1234"). Empty string if not detected.
plateGroupstringPlate list or group name. See IPC Plate Groups and NVR Plate Groups below.
sourcestring"IPC" or "NVR"
categorystringAlways "lpr" for these events
eventTypestringRaw alarm type: "VEHICE" or "VEHICLE" (IPC), "vehicle" (NVR)
eventDescriptionstring"License Plate Detection"
timestampstringEvent timestamp from the device
cameraNamestringCamera or NVR device name

NVR Only

These properties are populated only when source === 'NVR'. On IPC events they are empty strings or null.

PropertyTypeDescriptionExample
plateColorstringColor of the license plate"blue", "yellow", "white"
vehicleobject or nullVehicle attributes, or null if not detected\{ type, color, brand, model \}
vehicle.typestringVehicle type"sedan", "SUV", "truck"
vehicle.colorstringVehicle body color"white", "black", "red"
vehicle.brandstringVehicle manufacturer"Toyota", "Ford", "Honda"
vehicle.modelstringVehicle modelModel name string
carOwnerstringOwner name from NVR plate database"John Smith"
cameraIpstringCamera IP address"192.168.1.108"
cameraMacstringCamera MAC address"00:12:34:56:78:9A"
channelIdstringNVR channel number"1"

All NVR string properties return an empty string (not undefined) when the value is not detected or not available. The vehicle property is null when the NVR does not detect any vehicle attributes.

Images

PropertyTypeDescription
sourceImagestringOverview/scene image as a base64 string. Empty string if not available.
targetImagestringCropped plate image as a base64 string. Empty string if not available.
sourceImageBytesBuffer or nullOverview image decoded to a Buffer. Lazy -- decoded on first access.
targetImageBytesBuffer or nullCropped plate image decoded to a Buffer. Lazy -- decoded on first access.
hasImagesbooleantrue if either sourceImage or targetImage contains data.

IPC vs NVR Comparison

FeatureIPCNVR
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)
Camera IP / MACNoYes
Channel IDNoYes

Code Examples

Basic Plate Logging

const { ViewtronServer } = require('viewtron-sdk');

const server = new ViewtronServer({
port: 5050,
onEvent: (event, clientIP) => {
if (event.category === 'lpr') {
console.log(`Plate: ${event.plateNumber} | Group: ${event.plateGroup} | Camera: ${event.cameraName}`);
}
}
});

server.start();

Full Vehicle Details (NVR)

server.on('event', (event, clientIP) => {
if (event.category === 'lpr') {
console.log(`Plate: ${event.plateNumber}`);
console.log(` Source: ${event.source}`);
console.log(` Group: ${event.plateGroup}`);

// NVR provides vehicle attributes
if (event.source === 'NVR') {
console.log(` Plate color: ${event.plateColor}`);
console.log(` Owner: ${event.carOwner}`);

if (event.vehicle) {
console.log(` Vehicle: ${event.vehicle.color} ${event.vehicle.brand} ${event.vehicle.type}`);
console.log(` Model: ${event.vehicle.model}`);
}

console.log(` Channel: ${event.channelId}`);
}
}
});

Saving Plate Images

const fs = require('fs');
const path = require('path');

server.on('event', (event, clientIP) => {
if (event.category === 'lpr' && event.hasImages) {
const plate = event.plateNumber || 'unknown';
const ts = Date.now();

// Save the overview image
if (event.sourceImageBytes) {
fs.writeFileSync(
path.join('plates', `${plate}_${ts}_overview.jpg`),
event.sourceImageBytes
);
}

// Save the cropped plate image
if (event.targetImageBytes) {
fs.writeFileSync(
path.join('plates', `${plate}_${ts}_plate.jpg`),
event.targetImageBytes
);
}
}
});

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 plate management API.

If the detected plate is not in the camera's database, plateGroup is 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 plateGroup property returns whatever group name was assigned to the matched plate in the NVR database.

If the detected plate is not in the NVR database, plateGroup is an empty string.