Skip to main content

3D spatial scene monitoring — detect missing, moved, and new objects from video or live camera feeds

Project description

scenesense

A Python library for 3D spatial scene monitoring. Point a camera at any space, build a baseline, and get notified when objects are added, removed, or moved — with timestamps.

Install

pip install .

Or for development:

pip install -e .

Quick Start

Compare two videos

from scenesense import Scene

scene = Scene()

# Build baseline from first video
scene.baseline("room_before.mp4", save_path="baseline.json")

# Compare against second video
changes = scene.compare("room_after.mp4")

for c in changes:
    print(c)
# {"status": "missing", "object": "cup", "last_position": [...]}
# {"status": "new",     "object": "bag", "position": [...]}
# {"status": "moved",   "object": "chair", "from": [...], "to": [...]}

Load a saved baseline

scene = Scene()
scene.load_baseline("baseline.json")
changes = scene.compare("room_after.mp4")

Live camera monitoring

from scenesense import Scene

def on_event(event):
    print(f"[{event['timestamp']}] {event['event'].upper()}{event['object']}")
    # event keys: event, object, timestamp, stream_offset_seconds
    # + last_position (missing), position (new), from/to (moved)

scene = Scene()

scene.watch(
    source=0,                  # webcam index or RTSP URL
    baseline_duration=15,      # seconds to build baseline
    interval=30,               # seconds between checks
    on_event=on_event
)

Configuration

scene = Scene(
    model_size="n",        # yolo model: 'n' (fast), 's', 'm' (accurate)
    confidence=0.4,        # detection confidence threshold
    sample_rate=1.0,       # frames per second to sample from video
    move_threshold=0.3,    # distance to consider an object moved
    match_threshold=0.5    # distance to consider two detections the same object
)

How it works

  1. Frame extraction — samples frames from video at a controlled rate
  2. Object detection — runs YOLOv8 on each frame to find objects and bounding boxes
  3. Depth estimation — runs MiDaS to estimate per-pixel depth
  4. 3D projection — combines detection center + depth to get XYZ coordinates
  5. Scene graph — collapses per-frame detections into a stable list of unique objects
  6. Registration — aligns new video coordinate frame to baseline using ORB feature matching
  7. Delta detection — compares scene graphs to find missing, moved, and new objects

Use cases

  • Warehouse shelf auditing
  • Museum artifact monitoring
  • Security and facility management
  • Construction site progress tracking
  • Retail planogram compliance
  • Manufacturing FOD detection

Requirements

  • Python 3.10+
  • opencv-python
  • numpy
  • ultralytics (YOLOv8)

Models are downloaded automatically on first use (~30MB total).

Testing

pytest tests/unit/ -v

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scenesense-0.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scenesense-0.1.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file scenesense-0.1.0.tar.gz.

File metadata

  • Download URL: scenesense-0.1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for scenesense-0.1.0.tar.gz
Algorithm Hash digest
SHA256 29dfa2a01c1ff43ab712da4c74388f7e5b95413530cafb19eb22c31ea9c23cf8
MD5 15e346cb3ec6810bd4ad242b488d0917
BLAKE2b-256 66346c13234ffd1e763ac3593e89917a5c3b645b0d7bc57abbbacc0f2f51eec3

See more details on using hashes here.

File details

Details for the file scenesense-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: scenesense-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for scenesense-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 709ad33157d8493d4f78079a78fb1a90accdeaa6532771b6ef250002bb14a703
MD5 d12b36bf1608c9bea42bddc057a243f7
BLAKE2b-256 562c81b5867ae8eed3429146861b33b1bb3c4b5ce578f45dfd326e6ab4ed72b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page