Skip to main content

Realtime 3D (depth) + detection pipeline for laptop cameras (OpenCV optional)

Project description

scanlt3d

Realtime camera pipeline for detection + monocular depth ("3D") with pluggable backends.

  • Project/package name (PyPI): scanlt3d
  • Import name (Python): scanlt

This library does not require OpenCV.

Install

Minimal (always works)

CPU-only, no special hardware acceleration:

pip install scanlt3d

Optional extras

You can install extra backends depending on your machine.

pip install "scanlt3d[onnx]"       # ONNX Runtime (recommended cross-platform)
pip install "scanlt3d[torch]"      # PyTorch (CUDA/MPS support)
pip install "scanlt3d[mediapipe]"  # (planned) camera source via MediaPipe

Note: Hardware acceleration depends on which runtime is installed and available on your system (CUDA/DirectML/MPS).

Quickstart

1) Demo webcam with segmentation mask (recommended)

This is the easiest way to understand what scanlt3d does.

Install OpenCV for preview:

pip install "scanlt3d[opencv]"

Then run:

import scanlt

# Downloads a default segmentation model on first run (profile="fast") and caches it.
# Press `q` to quit.
scanlt.demo_webcam()

Choose a different model profile (auto-downloads if needed):

import scanlt

scanlt.demo_webcam(profile="balanced")
scanlt.demo_webcam(profile="quality")

Notes:

  • The first run may take time to download the model.
  • If OpenCV is not installed, demo_webcam() will run headless and you should use on_result to consume masks.

2) Low-level loop (always works)

import scanlt

# Runs a realtime loop with a built-in dummy camera source.
# This ensures `import + run()` never fails even if no webcam/backend is available.
scanlt.run()

Use by hardware (CPU / NVIDIA / Windows iGPU / Mac M)

scanlt can auto-detect the best available backend:

import scanlt   

print(scanlt.choose_backend())

1) CPU (Intel/AMD)

Install:

pip install scanlt3d
# recommended runtime
pip install "scanlt3d[onnx]"

What to expect:

  • Best compatibility.
  • Realtime depends heavily on your detector/depth model sizes.
  • Use lower resolution / run depth less frequently for higher FPS.

2) NVIDIA GPU (CUDA)

Two typical options:

  • ONNX Runtime CUDA (best for ONNX models)
  • PyTorch CUDA (best for torch models)

Install (choose one):

# Option A: PyTorch CUDA
pip install "scanlt3d[torch]"

# Option B: ONNX Runtime (you must install a CUDA-enabled onnxruntime build)
pip install "scanlt3d[onnx]"

Notes:

  • If choose_backend() returns cuda, scanlt detected a CUDA-capable runtime.
  • CUDA packaging varies by OS/driver; if CUDA runtime is not available, scanLt falls back to CPU.

3) Windows Intel/AMD iGPU (DirectML)

scanlt can pick dml if your ONNX Runtime installation exposes a DirectML provider.

Install:

pip install "scanlt3d[onnx]"

Notes:

  • DirectML is Windows-specific.
  • If DirectML is not available, scanLt falls back to CPU.

4) macOS Apple Silicon (M1/M2/M3)

Install:

pip install scanlt3d
pip install "scanlt3d[torch]"

Notes:

  • scanLt will try to use mps if PyTorch MPS is available.
  • If MPS is not available or unsupported by the model, it falls back to CPU.

Force backend (override auto-detect)

You can override backend selection via environment variable:

  • SCANLT_BACKEND=cpu
  • SCANLT_BACKEND=cuda
  • SCANLT_BACKEND=dml
  • SCANLT_BACKEND=mps

Example:

# Windows PowerShell
setx SCANLT_BACKEND cuda

(Then restart your terminal.)

Provide your own detector/depth

scanLt is designed to let you plug in your own models.

Minimal interfaces

  • Detector.predict(frame) -> list[Detection]
  • DepthEstimator.predict(frame, detections=None) -> depth_map

Example

import scanlt

class MyDetector:
    def predict(self, frame):
        # return list of scanlt.api.Detection
        return []

class MyDepth:
    def predict(self, frame, detections=None):
        import numpy as np
        h, w = frame.shape[:2]
        return np.zeros((h, w), dtype=np.float32)


def on_result(res):
    # res.frame: np.ndarray (H,W,3)
    # res.detections: list
    # res.depth: np.ndarray (H,W) or None
    # res.fps: float
    print(res.fps)


scanlt.run(detector=MyDetector(), depth=MyDepth(), on_result=on_result, max_frames=100)

Troubleshooting

pip install succeeds but choose_backend() is still CPU

This usually means:

  • CUDA / DirectML / MPS runtime is not installed or not detected
  • your model runtime doesn't support the needed execution provider

scanLt will always fall back to CPU to stay usable.

I want real webcam input

Current default run() uses a dummy source. For real camera sources, you will plug in a FrameSource (or enable the MediaPipe source once implemented).

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

scanlt3d-0.1.7.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

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

scanlt3d-0.1.7-cp312-cp312-win_amd64.whl (228.6 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

Details for the file scanlt3d-0.1.7.tar.gz.

File metadata

  • Download URL: scanlt3d-0.1.7.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for scanlt3d-0.1.7.tar.gz
Algorithm Hash digest
SHA256 d0c98fbd0fa7a6f333d771845aabdc3078798a6a4a02d3e35a1b0cf1f6590c8d
MD5 26587c9712cfc223e43d19bdd75ce9a4
BLAKE2b-256 3e6da40baa9d724514a31c71cd577f1f4919eae0223ef32fd49c9ac57106c891

See more details on using hashes here.

File details

Details for the file scanlt3d-0.1.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: scanlt3d-0.1.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 228.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for scanlt3d-0.1.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 62056efb022a67c7743f30503ae19f4fccdebf56d808e16cb9c9be13d09260ae
MD5 bc77cea04f442a18073a0edee7915b8a
BLAKE2b-256 3b15789dcb98e3e3875ba457946a8b91955e885b08416a6ab0d2f41202d9a1ea

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