Skip to main content
Open In Colab

The Story

Have you ever felt anxious leaving your home, shop, or property unattended? What if someone’s lurking around your property? What if someone’s trying the door or peeking through windows? Sure — you could install IP cameras, but who has the time to watch them 24/7? Good news — you don’t have to anymore. With VideoDB RTStream, you can build a smart, AI-powered property surveillance system that actively monitors live video streams, detects suspicious activity, and immediately sends alerts for escalating security breaches — all without human supervision.

What You’ll Build

With VideoDB RTStream, you can build a tiered security system that:
  • Monitors your property continuously
  • Classifies threats into three levels: loitering, door interaction, and entry
  • Sends escalating alerts based on threat severity
  • Provides video evidence for each detection

Setup

Install Dependencies

pip install videodb

Connect to VideoDB

import videodb

api_key = "your_api_key"
conn = videodb.connect(api_key=api_key)
coll = conn.get_collection()

Implementation

Step 1: Connect to Your Property Stream

rtsp_url = "rtsp://samples.rts.videodb.io:8554/intruder"
property_stream = coll.connect_rtstream(
    name="Property Security Stream",
    url=rtsp_url,
)

Step 2: Index Scenes with Multi-Level Threat Analysis

Create a scene index that monitors for all threat levels:
property_scene_index = property_stream.index_visuals(
    batch_config={
        "type": "time",
        "value": 5,
        "frame_count": 2,
    },
    prompt="""Monitor the area around the house closely. Detect and classify human presence
              around the house as either loitering, interacting with the door/lock, or entering
              the house; otherwise, consider the area safe.""",
    name="Property_Security_Index",
)

Step 3: Define Three-Tiered Events

Create events for each threat level:
# Level 1: Loitering (Low Threat)
loitering_event_id = conn.create_event(
    event_prompt="Detect if a person is loitering near the house perimeter.",
    label="loitering_near_property",
)

# Level 2: Door Interaction (Medium Threat)
intrusion_attempt_event_id = conn.create_event(
    event_prompt="Detect if a person is interacting with the door or visibly checking the lock.",
    label="intrusion_attempt",
)

# Level 3: Property Entry (Critical Threat)
entry_event_id = conn.create_event(
    event_prompt="Detect if a person enters the house or crosses the property boundary unlawfully.",
    label="property_entry",
)

Step 4: Attach Alerts with Progressive Response

webhook_url = "https://your-webhook-url.com"

# All three alerts routed to the same webhook with different priority labels
loitering_alert_id = property_scene_index.create_alert(loitering_event_id, callback_url=webhook_url)
intrusion_alert_id = property_scene_index.create_alert(intrusion_attempt_event_id, callback_url=webhook_url)
entry_alert_id = property_scene_index.create_alert(entry_event_id, callback_url=webhook_url)

Alert Examples

Level 1: Loitering Alert (Advisory)

{
  "event_id": "event-loitering-001",
  "label": "loitering_near_property",
  "confidence": 0.88,
  "explanation": "Person detected loitering near property perimeter. Not showing signs of intent to breach.",
  "timestamp": "2025-05-27T20:24:39.123456+00:00",
  "start_time": "2025-05-27T20:24:39.000000+05:30",
  "end_time": "2025-05-27T20:24:44.000000+05:30",
  "stream_url": "https://rt.stream.videodb.io/manifests/rts-019711a0-0fde-7911-b282-25bc0b4ecf65/1748444679000000-1748444684000000.m3u8"
}

Level 2: Intrusion Attempt Alert (Warning)

{
  "event_id": "event-intrusion-attempt-001",
  "label": "intrusion_attempt",
  "confidence": 0.92,
  "explanation": "Person is directly interacting with the door, checking the lock mechanism.",
  "timestamp": "2025-05-27T20:30:15.123456+00:00",
  "start_time": "2025-05-27T20:30:15.000000+05:30",
  "end_time": "2025-05-27T20:30:20.000000+05:30",
  "stream_url": "https://rt.stream.videodb.io/manifests/rts-019711a0-0fde-7911-b282-25bc0b4ecf65/1748445015000000-1748445020000000.m3u8"
}

Level 3: Property Entry Alert (Critical)

{
  "event_id": "event-entry-breach-001",
  "label": "property_entry",
  "confidence": 0.96,
  "explanation": "Unauthorized entry detected! Person has crossed the property boundary and is entering the house.",
  "timestamp": "2025-05-27T20:35:42.123456+00:00",
  "start_time": "2025-05-27T20:35:42.000000+05:30",
  "end_time": "2025-05-27T20:35:47.000000+05:30",
  "stream_url": "https://rt.stream.videodb.io/manifests/rts-019711a0-0fde-7911-b282-25bc0b4ecf65/1748445342000000-1748445347000000.m3u8"
}

The Result

With this in place, property owners can leave home without anxiety, knowing they’ll be immediately notified if anyone is:
  • Loitering nearby
  • Interacting with the door
  • Or breaking in
The tiered alert system lets you respond appropriately:
  • Level 1 alerts → Stay informed and monitor
  • Level 2 alerts → Increase vigilance, contact neighbors
  • Level 3 alerts → Contact emergency services immediately

Explore the Full Notebook

Open the complete implementation with advanced configuration and customization options.