Metadata-Version: 2.4
Name: ThreadCam
Version: 0.1.0
Summary: A zero-dependency, ultra-low-latency threaded camera multiplexer for Python.
Project-URL: Homepage, https://github.com/GABAyou/ThreadCam
Project-URL: Bug Tracker, https://github.com/GABAyou/ThreadCam/issues
Author: GABAyou
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Video
Requires-Python: >=3.7
Requires-Dist: numpy>=1.19.0
Requires-Dist: opencv-python>=4.0.0
Description-Content-Type: text/markdown

# ThreadCam

A zero-lag, ultra-low-latency threaded camera multiplexer for Python.

Are you building a Flask app that streams video? Are you running a Machine Learning inference loop that drops frames or causes your UI to stutter? 

**ThreadCam** completely eliminates OpenCV's `VideoCapture` IO bottleneck.

## The Problem
When you call `cap.read()` in OpenCV, your Python script completely blocks while waiting for the USB hardware to compress and deliver the frame buffer. If you try to run multiple generators (like streaming to a Web UI *and* running an ML model), they fight for the camera lock, causing massive lag and crashes.

## The Solution
`ThreadCam` opens your webcam exactly once in a dedicated, ultra-light background C-thread. It constantly maintains the absolute latest frame in RAM behind a thread-safe lock. 

You can have infinite Python consumers reading `.read()` simultaneously. Because they are pulling from RAM instead of the hardware buffer, it executes in exactly `0.0000ms`, completely unblocking your application loop.

## Installation
```bash
pip install ThreadCam
```

## Usage

```python
from ThreadCam import ThreadCam
import cv2

# Initialize the hub (Starts the background thread)
hub = ThreadCam(src=0, target_fps=30)

while True:
    # Read the absolute newest frame instantly from RAM
    ret, frame = hub.read()
    
    if not ret:
        continue
        
    cv2.imshow("ThreadCam", frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

hub.stop()
```

## Ideal Use Cases
- Flask / FastAPI MJPEG Streaming
- MediaPipe / YOLO Inference Engines
- PyGame / Tkinter UI Overlays
- Multi-threaded processing pipelines
