Skip to main content

Quick Example

import videodb

conn = videodb.connect()

# Create a reusable event
event_id = conn.create_event(
    event_prompt="Detect when a person enters a restricted area",
    label="intrusion_detected"
)

# Attach to a scene index
scene_index.create_alert(
    event_id=event_id,
    callback_url="https://your-backend.com/alerts"
)

Events vs Alerts

ConceptWhat It IsScope
EventDetection rule (prompt + label)Account-level, reusable
AlertWiring between event and indexIndex-specific
Think of events as templates. Create them once, then wire them to multiple indexes via alerts.

Creating Events

Basic Event

event_id = conn.create_event(
    event_prompt="Detect when someone falls down",
    label="fall_detected"
)

Event Prompt Best Practices

The event_prompt is what the AI uses to evaluate each indexed scene. Be specific:
# Too vague - will trigger on many scenes
event_prompt = "Detect anything unusual"

# Better - specific condition
event_prompt = "Detect when a vehicle runs a red light"

# Best - specific with context
event_prompt = "Detect when a vehicle enters the intersection while the traffic light is red"

Detection Patterns by Use Case

Security & Safety

# Intrusion detection
conn.create_event(
    event_prompt="Detect when a person enters the warehouse after hours",
    label="after_hours_entry"
)

# Fall detection
conn.create_event(
    event_prompt="Detect when a person falls or collapses",
    label="fall_detected"
)

# Unauthorized access
conn.create_event(
    event_prompt="Detect when someone accesses the server room without a badge",
    label="unauthorized_access"
)

Retail & Operations

# Queue detection
conn.create_event(
    event_prompt="Detect when more than 5 people are waiting in line",
    label="queue_long"
)

# Spill detection
conn.create_event(
    event_prompt="Detect liquid spills on the floor",
    label="spill_detected"
)

# Shelf monitoring
conn.create_event(
    event_prompt="Detect when a shelf appears empty or low on products",
    label="shelf_empty"
)

Traffic & Transportation

# Traffic violation
conn.create_event(
    event_prompt="Detect when a vehicle runs a red light or stop sign",
    label="traffic_violation"
)

# Wrong-way driving
conn.create_event(
    event_prompt="Detect a vehicle driving in the wrong direction",
    label="wrong_way"
)

# Congestion
conn.create_event(
    event_prompt="Detect when traffic has stopped or is moving very slowly",
    label="congestion_detected"
)

Managing Events

List Events

events = conn.list_events()
for event in events:
    print(f"{event.id}: {event.label}")

Get Event Details

event = conn.get_event(event_id)
print(f"Label: {event.label}")
print(f"Prompt: {event.event_prompt}")

Delete Event

conn.delete_event(event_id)

Prompt Engineering Tips

Be Specific About Conditions

# Weak: ambiguous threshold
"Detect crowding"

# Strong: clear threshold
"Detect when more than 10 people are visible in the frame"

Include Context

# Weak: missing context
"Detect a person running"

# Strong: includes context
"Detect a person running in the parking lot (not jogging normally)"

Describe What “Detected” Means

# Weak: unclear criteria
"Detect suspicious activity"

# Strong: observable criteria
"Detect when someone looks into car windows repeatedly or tries door handles"

Event-Index Pairing

Match your event to the right index configuration:
Detection TypeRecommended Index Config
Static objects1 frame per scene
Motion/activity3-5 frames per scene
Quick eventsShort intervals (2-5s)
Sustained conditionsLonger intervals (10-30s)

What You Can Build

Intrusion Detection

Real-time alerts when unauthorized access is detected

Traffic Violations

Detect red light and stop sign violations automatically

Beep Profanity

Audio event detection to censor inappropriate language

Copyright Detection

Detect copyrighted content in video streams

Next Steps

Alerts and Callbacks

Wire events to delivery channels

Webhooks and Reliability

Handle alerts at scale