I dug out an old webcam for a ‘photobooth’ idea. The user is updated with what’s happening by the LCD display.
First, install fswebcam to drive the webcam:
sudo apt-get install fswebcam
Create a folder in /pi called ‘webcam’.
Depending on the quality of webcam, the resolution of the photo can be changed from 320×240 to whatever your Pi can cope with. I’m getting “Corrupt JPEG data: premature end of data segment” errors quite a lot; I think this is because I’m not using a powered USB hub. You can also remove the date/time stamp and do other things that are listed in fswebcam help:
Run this code to take a photo: