Skip to main content

3D object detection and spatial mapping using webcam

Project description

Spatial Detector

A Python package for 3D object detection and spatial mapping using a webcam.

Features

  • YOLO-based object detection
  • MiDaS depth estimation
  • 3D spatial mapping and localization
  • Top-down view visualization
  • Depth calibration for accurate measurements
  • Designed for Apple Silicon and CUDA GPUs

Installation

pip install spatial-detector

Or install from source:

git clone https://github.com/yourusername/spatial-detector.git
cd spatial-detector
pip install -e .

Usage

Command Line Interface

# Basic usage
spatial-detector

# With custom settings
spatial-detector --camera 0 --yolo-model yolov8n.pt --device mps

As a Python Library

from spatial_detector.detection import YOLODetector
from spatial_detector.depth import MiDaSDepthEstimator
from spatial_detector.mapping import SpatialMap, DepthCalibrator

# Initialize components
detector = YOLODetector(model_path="yolov8n.pt")
depth_estimator = MiDaSDepthEstimator()
spatial_map = SpatialMap()

# Process a frame
detections = detector.detect(frame)
depth_map, _ = depth_estimator.estimate_depth(frame)

Controls

  • q: Quit
  • d: Toggle depth visualization
  • l: Toggle labels
  • c: Enter calibration mode
  • +/-: Adjust calibration distance
  • space: Set calibration point in calibration mode
  • s: Save depth calibration

Calibration

For accurate measurements:

  1. Press c to enter calibration mode
  2. Place an object at a known distance (e.g., 1 meter from camera)
  3. Use +/- to set the correct distance
  4. Align the object with the center crosshair
  5. Press space to calibrate
  6. Press s to save the calibration

License

MIT

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

spatial_detector-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

spatial_detector-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spatial_detector-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for spatial_detector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e51ece3fd12cd8d779841c97326e459b1b59f7b2b9da69fbeb877ff1c365900
MD5 c2479d93ae509d06e49574b9c2d8d52a
BLAKE2b-256 556e8e95783d7deae10fcc2bcd6ea40c14edb33e789f9219646ee84d83e8f9b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spatial_detector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f7a4f484d15aeccf363d35d4a6e252573d43a8b1fde08e17a1e779fde032392
MD5 effc6ff9f82c40759dd5dd3ec3b9826b
BLAKE2b-256 9ffa5aaec586d69ebc3a08ed77028e3350bc6ba798ef3c797c421fcbed8175c5

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