Skip to main content

A minimal Windows x64 camera capture library.Based on MediaFoundation.

Project description

pylightcam

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

Installation

pip install pylightcam

Quick Start

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:

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):

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pylightcam-0.1.2-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file pylightcam-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pylightcam-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pylightcam-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c95609fb89278df24625fca9fe9be3d1676df37434ff6e0f82c9dca34a1105ae
MD5 54425479d804d360cb50bb35c2f8fc3d
BLAKE2b-256 a979ccffa897a96ee553074acb438943ce3fc02bef6ed0953a01ddc310b638f8

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