Skip to main content

极轻量 Windows 摄像头拍照库 — 无需 OpenCV,即装即用

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.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylightcam-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15b5d2356daa240914d2678ae7dbc104e81a44f2ccfdb7d94dd917a65b2e5b26
MD5 119edb2b14def6c351b780ba5a8c90a3
BLAKE2b-256 6fe5b6e483ec822704648549989a9b9d609be7c1b2cce27265181ab5b1a6e781

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