Human Detection & Intrusion Detection API
Viewtron AI security cameras include built-in human detection and intrusion detection that runs entirely on the camera hardware — no cloud service or external AI software required. When a person, vehicle, or motorcycle enters a defined intrusion zone, the camera sends an HTTP POST webhook to your server with the detection event data, including a full-frame overview image, a cropped image of the detected target, bounding box coordinates, and target classification (person, car, or motorcycle).
This is the most commonly used AI detection feature in the Viewtron API. You can configure up to 4 intrusion zones per camera, each with independent object filters and sensitivity settings. All Viewtron IP cameras and NVRs are NDAA compliant.
What You Can Build
- Automated intruder alerts — send email, SMS, or push notifications with snapshot images when a person enters a restricted area
- Presence-based automation — turn on lights, activate relays, or trigger recordings when humans are detected
- Custom alarm logic — filter by target type (person vs car vs motorcycle) to reduce false alarms
- Security dashboards — aggregate intrusion events across multiple cameras with images and timestamps
- Integration with access control — connect to VMS, alarm panels, or building management systems
- Dwell time tracking — combine with real-time traject data for continuous position monitoring
How It Works
- Configure an intrusion zone on the camera — define a polygon region and enable object filters (person, car, motor)
- Enable HTTP POST webhooks — point the camera or NVR at your server's IP and port
- Your server receives XML when a detection occurs — the POST includes alarm type, target coordinates, zone boundary, and base64 images
- Parse the event using the Viewtron Python SDK (
pip install viewtron) or Node.js SDK - Take action — save images, log to CSV, send alerts, trigger relays
Event Data Included
Each intrusion detection webhook POST contains:
| Field | Description |
|---|---|
smartType | PEA (IPC) or regionIntrusion (NVR) |
targetType | person, car, or motor |
rect | Bounding box of the detected target (x1, y1, x2, y2) |
boundary / pointGroup | Polygon coordinates of the intrusion zone |
eventId / targetId | Unique IDs for the event and tracked target |
status | SMART_START, SMART_PROCEDURE, or SMART_STOP |
sourceBase64Data | Full-frame JPEG image (base64 encoded, ~500 KB) |
targetBase64Data | Cropped target JPEG image (base64 encoded, ~50-80 KB) |
currentTime | Detection timestamp |
Object Filters
Each intrusion zone can independently filter by target type with per-object sensitivity (1-100):
| Object | Description | Default Sensitivity |
|---|---|---|
person | Human detection | 50 |
car | Vehicle (car/truck) detection | 50 |
motor | Motorcycle/bicycle detection | 50 |
Disable any object type to ignore it entirely, or adjust sensitivity to control the detection threshold.
Parsing Intrusion Events
- Python SDK
- Node.js SDK
- NVR XML (v2.0)
- IPC XML (v1.x)
The simplest way to receive intrusion events. The SDK's ViewtronServer handles HTTP connections, keepalives, XML parsing, and version detection — you just write the callback:
pip install viewtron
from viewtron import ViewtronServer
import os
IMG_DIR = "images"
os.makedirs(IMG_DIR, exist_ok=True)
def on_event(event, client_ip):
if event.category != "intrusion":
return
print(f"Intrusion detected from {client_ip}")
print(f" Target: {event.get_alarm_type()} ({event.get_alarm_description()})")
print(f" Event ID: {event.raw.get('eventId', 'N/A')}")
overview = event.get_source_image_bytes()
if overview:
with open(f"{IMG_DIR}/{event.get_time_stamp()}-overview.jpg", "wb") as f:
f.write(overview)
target = event.get_target_image_bytes()
if target:
with open(f"{IMG_DIR}/{event.get_time_stamp()}-target.jpg", "wb") as f:
f.write(target)
server = ViewtronServer(port=5002, on_event=on_event)
server.serve_forever()
See the Python SDK reference for the full list of methods and event classes.
npm install viewtron-sdk
const { ViewtronServer } = require('viewtron-sdk');
const fs = require('fs');
fs.mkdirSync('images', { recursive: true });
const server = new ViewtronServer({ port: 5002 });
server.on('event', (event, clientIP) => {
if (event.category !== 'intrusion') return;
console.log(`Intrusion detected from ${clientIP}`);
console.log(` Target: ${event.eventType} (${event.targetType})`);
console.log(` Event ID: ${event.eventId}`);
if (event.sourceImageBytes) {
fs.writeFileSync(
`images/${Date.now()}-overview.jpg`,
event.sourceImageBytes
);
}
if (event.targetImageBytes) {
fs.writeFileSync(
`images/${Date.now()}-target.jpg`,
event.targetImageBytes
);
}
});
server.start();
The NVR v2.0 format uses regionIntrusion with eventInfo for zone boundaries and targetListInfo for target classification and images:
<?xml version="1.0" encoding="UTF-8"?>
<config version="2.0.0" xmlns="http://www.ipc.com/ver10">
<messageType>alarmData</messageType>
<deviceInfo>
<deviceName><![CDATA[Front Door]]></deviceName>
<ip><![CDATA[192.168.0.55]]></ip>
<mac><![CDATA[58:5B:69:40:F4:0D]]></mac>
<channelId>1</channelId>
</deviceInfo>
<smartType>regionIntrusion</smartType>
<currentTime>1772056914604000</currentTime>
<eventInfo>
<item>
<eventId>916</eventId>
<targetId>716</targetId>
<boundary>area</boundary>
<pointGroup>
<item><x>1590</x><y>3080</y></item>
<item><x>4715</x><y>3181</y></item>
<item><x>4772</x><y>9217</y></item>
<item><x>416</x><y>9141</y></item>
</pointGroup>
<rect><x1>3096</x1><y1>3715</y1><x2>4005</x2><y2>9861</y2></rect>
</item>
</eventInfo>
<sourceDataInfo>
<sourceBase64Length>400924</sourceBase64Length>
<sourceBase64Data>... (base64 JPEG) ...</sourceBase64Data>
</sourceDataInfo>
<targetListInfo>
<item>
<targetId>716</targetId>
<targetType>person</targetType>
<targetImageData>
<targetBase64Length>78796</targetBase64Length>
<targetBase64Data>... (base64 JPEG) ...</targetBase64Data>
</targetImageData>
</item>
</targetListInfo>
</config>
See the NVR Event Format reference for the complete v2.0 XML structure.
The IPC v1.x format uses PEA smartType with a <perimeter> block containing zone boundaries and target bounding boxes:
<?xml version="1.0" encoding="UTF-8" ?>
<config version="1.7" xmlns="http://www.ipc.com/ver10">
<smartType type="openAlramObj">PEA</smartType>
<deviceName type="string"><![CDATA[FaceCam]]></deviceName>
<currentTime type="tint64">1774792701902505</currentTime>
<perimeter>
<perInfo type="list" count="1">
<item>
<eventId type="uint32">2357</eventId>
<targetId type="uint32">2157</targetId>
<status type="perStatus">SMART_START</status>
<boundary type="list" count="5">
<item><point><x type="uint32">450</x><y type="uint32">466</y></point></item>
<!-- additional polygon points -->
</boundary>
<rect>
<x1 type="uint32">4403</x1><y1 type="uint32">694</y1>
<x2 type="uint32">5909</x2><y2 type="uint32">8125</y2>
</rect>
</item>
</perInfo>
</perimeter>
<!-- sourceDataInfo and listInfo with base64 images -->
</config>
See the IPC Event Format reference for the complete v1.x XML structure.
Relevant API Endpoints
| Endpoint | Purpose | Reference |
|---|---|---|
| GetSmartPerimeterConfig | Read intrusion zone configuration | Intrusion Detection Config |
| SetHttpPostConfig | Configure webhook destination | Webhook Config |
| GetAlarmStatus | Poll current alarm state | Alarm Status |
Integrations
Viewtron human detection also integrates with automation platforms via published packages:
| Platform | Package | What It Does |
|---|---|---|
| Home Assistant | viewtron-home-assistant | Person and vehicle detection as native HA sensors — automate lights, alarms, notifications |
| Node-RED | node-red-contrib-viewtron | Intrusion events direct to Node-RED flows — no middleware needed |
Related Applications
- Perimeter Security & Line Crossing — tripwire detection and region entry/exit
- Real-Time Object Tracking — continuous target position data via traject
- Relay Control & IoT Automation — trigger relays based on human detection
- Webhook Event Notification — complete webhook setup and format reference
- Viewtron Python SDK — parse intrusion events in Python with typed accessors
Related Products
- Viewtron AI Security Cameras — IP cameras with built-in human detection
- Viewtron IP Camera NVRs — NVRs with HTTP POST event forwarding
For a walkthrough of human detection events in action, including zone configuration and live webhook output, see the AI Security Camera System video guide.
Questions & Development Inquiries
- Email: mike@viewtron.com
- Phone: 561-433-8488
- Forum: NVR Webhook Setup Guide
Mike Haldas is available for questions, consultation, and custom software development for Viewtron API related projects. Email details about your project to mike@viewtron.com.