I am using Debian Linux and Python 2.7 with PIL. I want to capture an image from a webcam and store it in a file. What are the ways in which this can be done? Also,I want to covert the captured image for modification using Scipy. What is the procedure.for this. My code is intended to run on the raspberry Pi.
I've done this sort of stuff before. To answer your second question, here's a code sub-snippet:
import numpy as np
img = Image.open('E:\\JCH\\Snap.jpg')
newx = img.size
newy = img.size # Image is (newx,newy) pixels
imga = np.asarray(img) # This is the secret; convert img to array
imgc = copy.copy(imga) # Make a copy, lest you step on toes
# then the value of imgc[y,x] is the pixel [R,G,B] or [R,G,B,A]
# Note the order [y,x] for the pixel at (x,y). You're welcome :-)
This is very interesting BearofNH. Unfortunately it does not work with all hardware (eg my laptop :( ). I'm trying to port this code to python, using the python bindings for v4L2 and opencv2. If it works, I'll make a code snippet. See also the author's blog.