Metadata-Version: 2.4
Name: omnicam
Version: 0.2.5
Summary: A Python package for camera utilities
Author-email: OguzhanUmutlu <contact@oguzhanumutlu.com>
License: MIT License
        
        Copyright (c) 2025 Oğuzhan
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/OguzhanUmutlu/omnicam
Project-URL: Issues, https://github.com/OguzhanUmutlu/omnicam/issues
Project-URL: Documentation, https://github.com/OguzhanUmutlu/omnicam#readme
Keywords: camera,opencv,vision,stream,capture
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21
Provides-Extra: opencv
Requires-Dist: opencv-python>=4.7; extra == "opencv"
Provides-Extra: screen
Requires-Dist: mss>=9.0; extra == "screen"
Provides-Extra: pi
Requires-Dist: picamera2>=0.3; extra == "pi"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# 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

```bash
pip install omnicam
```

Optional extras:

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

## Quickstart

```python
from omnicam import SimpleCamera

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

## Camera types

```python
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

```python
from omnicam import PiCamera

cam = PiCamera(info="IMX219", resolution="720p")
```

## GStreamer and Gazebo

```python
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:

```python
from omnicam import SimpleCamera
from omnicam.base_camera import CameraInfo

info = CameraInfo(
    name="My Camera Model",
    short_name="MYCAM",
    focal_length_px=(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:

```python
from omnicam.base_camera import CameraInfo

info = CameraInfo(
    name="Synthetic",
    short_name="SYN",
    aperture_f=1.0,
    focal_length_px=(800.0, 800.0),
    max_resolution=(1280, 720),
    update_rate=60.0
)
```

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

- `OV5647` → `Camera Module 1`
- `OV5647 NoIR` → `Camera Module 1 NoIR`
- `IMX219` → `Camera Module 2`
- `IMX219 NoIR` → `Camera Module 2 NoIR`
- `IMX708 Standard` → `Camera Module 3 - Standard`
- `IMX708 NoIR` → `Camera Module 3 - Standard NoIR`
- `IMX708 Wide` → `Camera Module 3 - Wide`
- `IMX708 Wide NoIR` → `Camera Module 3 - Wide NoIR`
- `IMX477 6mm` → `High Quality Camera w/ 6mm Lens`
- `IMX477 16mm` → `High Quality Camera w/ 16mm Lens`
- `IMX477 35mm` → `High Quality Camera w/ 35mm Lens`
- `IMX477 M12-8mm` → `High Quality Camera w/ 8mm M12 Lens`
- `IMX477 M12-25mm` → `High Quality Camera w/ 25mm M12 Lens`
- `IMX477 M12-Fish` → `High Quality Camera w/ 2.7mm M12 Fisheye`
- `IMX296 6mm` → `Global Shutter Camera w/ 6mm Lens`
- `IMX296 16mm` → `Global Shutter Camera w/ 16mm Lens`
- `IMX500` → `Raspberry 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`.
