Metadata-Version: 2.1
Name: pylightcam
Version: 0.1.2
Summary: A minimal Windows x64 camera capture library.Based on MediaFoundation.
Author-email: PyLightCam <3550413036@qq.com>
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Video :: Capture
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: full
Requires-Dist: numpy; extra == "full"
Requires-Dist: pillow; extra == "full"

# pylightcam

Ultra-lightweight Windows camera capture library — **no OpenCV required**, works out of the box.

## Installation

```bash
pip install pylightcam
```

## Quick Start

```python
import pylightcam as plc

cap = plc.VideoCapture(0)
ret, img = cap.read()

if ret:
    # img is a numpy.ndarray (H×W×3, RGB)
    # Save with Pillow
    from PIL import Image
    Image.fromarray(img).save("photo.jpg")

cap.release()
```

Or use Pillow directly:

```python
from PIL import Image

cap = plc.VideoCapture(0)
ret, pil_img = cap.read()  # pil_img is PIL.Image
if ret:
    pil_img.save("photo.jpg")
```

Pure JPEG bytes (zero dependencies):

```python
cap = plc.VideoCapture(0)
ret, jpg_bytes = cap.read_jpg()
if ret:
    with open("photo.jpg", "wb") as f:
        f.write(jpg_bytes)
```

## API

### `plc.get_device_count()`
Returns the number of cameras on the system.

### `plc.VideoCapture(device_index=0, width=0, height=0)`
Opens a camera. Supports `with` statement.

| Return type | Method | Dependencies |
|-------------|--------|-------------|
| `numpy.ndarray` (RGB) | `.read()` | numpy + pillow |
| `PIL.Image` | `.read()` | pillow |
| `bytes` (JPEG) | `.read_jpg()` | none |

### `.release()`
Close the camera.

## Comparison with cv2.VideoCapture

| Feature | cv2 | pylightcam |
|---------|-----|------------|
| Package size | ~500 MB | ~50 KB |
| Dependencies | OpenCV + ffmpeg + ... | none |
| Color format | BGR | RGB |
| Capture speed | fast | moderate |
