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)
| Property | Type | Description |
|---|---|---|
plateNumber | string | Detected plate text (e.g., "ABC1234"). Empty string if not detected. |
plateGroup | string | Plate list or group name. See IPC Plate Groups and NVR Plate Groups below. |
source | string | "IPC" or "NVR" |
category | string | Always "lpr" for these events |
eventType | string | Raw alarm type: "VEHICE" or "VEHICLE" (IPC), "vehicle" (NVR) |
eventDescription | string | "License Plate Detection" |
timestamp | string | Event timestamp from the device |
cameraName | string | Camera or NVR device name |
NVR Only
These properties are populated only when source === 'NVR'. On IPC events they are empty strings or null.
| Property | Type | Description | Example |
|---|---|---|---|
plateColor | string | Color of the license plate | "blue", "yellow", "white" |
vehicle | object or null | Vehicle attributes, or null if not detected | \{ type, color, brand, model \} |
vehicle.type | string | Vehicle type | "sedan", "SUV", "truck" |
vehicle.color | string | Vehicle body color | "white", "black", "red" |
vehicle.brand | string | Vehicle manufacturer | "Toyota", "Ford", "Honda" |
vehicle.model | string | Vehicle model | Model name string |
carOwner | string | Owner name from NVR plate database | "John Smith" |
cameraIp | string | Camera IP address | "192.168.1.108" |
cameraMac | string | Camera MAC address | "00:12:34:56:78:9A" |
channelId | string | NVR 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
| Property | Type | Description |
|---|---|---|
sourceImage | string | Overview/scene image as a base64 string. Empty string if not available. |
targetImage | string | Cropped plate image as a base64 string. Empty string if not available. |
sourceImageBytes | Buffer or null | Overview image decoded to a Buffer. Lazy -- decoded on first access. |
targetImageBytes | Buffer or null | Cropped plate image decoded to a Buffer. Lazy -- decoded on first access. |
hasImages | boolean | true if either sourceImage or targetImage contains data. |
IPC vs NVR Comparison
| Feature | IPC | NVR |
|---|---|---|
| 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) |
| Camera IP / MAC | No | Yes |
| Channel ID | No | Yes |
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.
Related Pages
- ViewtronEvent -- factory function and common properties
- Images -- working with plate and overview images
- API Reference: License Plate Recognition -- raw XML endpoint documentation