Skip to main content

A Python package for camera utilities

Project description

omnicam

A small, unified API for reading frames from USB cameras, IP streams, video files, screen capture, and Raspberry Pi cameras.

Features

  • Unified BaseCamera interface across backends
  • OpenCV-based capture for USB webcams, video files, RTSP/HTTP streams, and GStreamer pipelines
  • Optional Raspberry Pi Camera support (Picamera2)
  • Optional screen capture via mss

Installation

pip install omnicam

Optional extras:

pip install omnicam[opencv]
pip install omnicam[screen]
pip install omnicam[pi]

Quickstart

from omnicam import SimpleCamera

with SimpleCamera(index=0) as cam:
    frame = cam.read()
    if frame is not None:
        print(frame.shape)

Camera types

from omnicam import FileCapture, InternetCapture, ScreenCapture

# Video file
cam = FileCapture("/path/to/video.mp4")

# IP camera or MJPEG stream
cam = InternetCapture("http://192.168.1.10:8080/video")

# Screen capture (requires omnicam[screen])
cam = ScreenCapture(index=1)

Raspberry Pi camera

from omnicam import PiCamera

cam = PiCamera(model="IMX219", resolution="720p")

GStreamer and Gazebo

from omnicam import GStreamerCapture, GazeboCamera

pipeline = (
    GStreamerCapture.GstPipeline()
    .add("v4l2src", device="/dev/video0")
    .add("videoconvert")
    .add("appsink")
)
cam = GStreamerCapture(pipeline)

# Gazebo (requires gz tools available on PATH)
cam = GazeboCamera(topic_name="my_camera")

CameraInfo (advanced)

CameraInfo describes physical camera parameters and enables focal-length math and focus validation. It is optional but useful when you need real-world camera intrinsics.

Fields:

  • name: Full model name.
  • short_name: Short identifier (sensor/model code).
  • focal_length_mm: (fx_mm, fy_mm) in millimeters.
  • pixel_size_um: Pixel size in micrometers.
  • max_resolution: (width, height) at sensor maximum.
  • aperture_f: F-number (e.g., 2.0).
  • hfov_deg: Horizontal field of view in degrees.
  • focus_type: "Fixed" | "Autofocus" | "Manual" | "Unknown".
  • has_ir_filter: True if the camera has an IR filter.

Usage example:

from omnicam import SimpleCamera
from omnicam.base_camera import CameraInfo

info = CameraInfo(
    name="My Camera Model",
    short_name="MYCAM",
    focal_length_mm=(4.0, 4.0),
    pixel_size_um=1.4,
    max_resolution=(1920, 1080),
    aperture_f=2.0,
    hfov_deg=70.0,
    focus_type="Manual",
    has_ir_filter=True,
)

with SimpleCamera(index=0, info=info) as cam:
    fx, fy = cam.focal_length()  # focal length in pixels at current size

If you only know focal length in pixel units, use:

from omnicam.base_camera import CameraInfo

info = CameraInfo.from_focal_length(
    name="Synthetic",
    short_name="SYN",
    focal_length=(800.0, 800.0),
    resolution=(1280, 720),
)

Default Raspberry Pi cameras (short name → full name):

  • OV5647Camera Module 1
  • OV5647 NoIRCamera Module 1 NoIR
  • IMX219Camera Module 2
  • IMX219 NoIRCamera Module 2 NoIR
  • IMX708 StandardCamera Module 3 - Standard
  • IMX708 NoIRCamera Module 3 - Standard NoIR
  • IMX708 WideCamera Module 3 - Wide
  • IMX708 Wide NoIRCamera Module 3 - Wide NoIR
  • IMX477 6mmHigh Quality Camera w/ 6mm Lens
  • IMX477 16mmHigh Quality Camera w/ 16mm Lens
  • IMX477 35mmHigh Quality Camera w/ 35mm Lens
  • IMX477 M12-8mmHigh Quality Camera w/ 8mm M12 Lens
  • IMX477 M12-25mmHigh Quality Camera w/ 25mm M12 Lens
  • IMX477 M12-FishHigh Quality Camera w/ 2.7mm M12 Fisheye
  • IMX296 6mmGlobal Shutter Camera w/ 6mm Lens
  • IMX296 16mmGlobal Shutter Camera w/ 16mm Lens
  • IMX500Raspberry Pi AI Camera

Notes

  • numpy is required. OpenCV-based backends need omnicam[opencv].
  • GStreamer and Gazebo features rely on system-level tooling.

License

MIT. See LICENSE.

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

omnicam-0.1.4.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

omnicam-0.1.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file omnicam-0.1.4.tar.gz.

File metadata

  • Download URL: omnicam-0.1.4.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for omnicam-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3af9e5820283164aab03b9da809e55a66297c20a906fb6080888928dbac007d5
MD5 477e6806e8ad1f0df8e3115fa5dd2e15
BLAKE2b-256 1ab1d1e7a0a52b5e2aa97d87e26c6de714d6898091c4a8364aef8cd96ea9db45

See more details on using hashes here.

File details

Details for the file omnicam-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: omnicam-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for omnicam-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5b520717fa49d7eeafdfc79aad907c589a958e9c56bb3dc86c54b4ef6d76a0fc
MD5 b27eb13a8956be8abdfb6c5526b8e2cf
BLAKE2b-256 c62d40f49b118b74a2b9cbcd8584518134552c78e1b93ccace2b7ddfb8d3db07

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