Skip to content

Simple webcam library for Python 3 written in C++ with Cython

License

Notifications You must be signed in to change notification settings

zsxoff/pycppcam

Repository files navigation

pycppcam

Simple webcam library for Python 3 written in C++ with Cython.


Build Status


pycppcam is a simple library for get image with a webcam for Python. The program uses code written in C++ with Cython bindings.

Disclaimer: This project was created more as an experimental one and is unlikely to develop towards supporting new features. Use it if you really need it.

Example

from cppcam import Camera

# Init camera
cam = Camera()
cam.init('/dev/video0', (1280, 720))

# Read frame to in-memory buffer
cam.start_capture()
cam.read_frame()

# Get raw data
raw = cam.get_frame()

# Close camera
cam.stop_capture()
cam.release()

See more in examples dir.

Dependencies

  • python3
  • gcc
  • g++

On Ubuntu you can install it like:

sudo apt-get install python3 python3-pip gcc g++

Installation

Clone this repo and go to project folder:

git clone https://github.com/zsxoff/pycppcam.git
cd pycppcam
pip install --user -r requirements.txt
pip install --user .

If you use venv, Virtualenv, Anaconda and etc., you don't need --user option.

Known issues

Issue: gcc throws exceptions at compile process like only available with -std=c++11. Solution: execute command export CFLAGS="-std=c++11" before install command.

Issue: gcc throws exceptions at compile process fatal error: Python.h: No such file or directory. Solution: check if you installed python3-devel package.

Issue: Camera raise cppcam.BufDqbufError during read_frame(). Solution: Try to change #define MAX_IMG_SIZE in src/cpp_camera.h like 20 * 1024 * 1024 or bigger, where 20 is a maximum size of image in megabytes.

TODO

  • Fix camera raise cppcam.BufDqbufError during read_frame() due to #define MAX_IMG_SIZE in src/cpp_camera.h.
  • Improve setup.py file.

License

License: MIT

This project is licensed under the terms of the MIT license (see LICENSE file).

About

Simple webcam library for Python 3 written in C++ with Cython

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published