Search code examples
pythonraspberry-piwebcam

How do you capture an image from a webcam in python WITHOUT OpenCV


I'm programming in python on a Raspberry Pi Zero and I want to capture an image from a USB webcam and I can't find a way of doing this without OpenCV. I don't want to use OpenCV because it's way overkill in features and size for what I'm doing (just taking a raw image from a camera, no processing) and it will take 10+ hours to compile on a Pi Zero. Please tell me there is another way. Pygame was mentioned in another similar question but that only works on Windows. Any ideas or must I sacrifice a half GB of flash to the OpenCV gods and spend 10+ hours compiling its code just to take an image?


Solution

  • It looks like there are ctypes bindings to the Video 4 Linux 2 userspace libraries.

    ctypes is icky (replace with cffi if you have time, then send that package's authors a patch), but they should work.