Webcam

From Leo's Notes
Revision as of 08:03, 23 March 2015 by 10.1.1.3 (talk)
This page was last edited on 23 March 2015, at 08:03.

Linux

To get a webcam working for Linux, ensure that it's supported. Newer webcams tend to have support though cheaper non-HD webcams from China might not. You should see a /dev/videoS0 device when the webcam is plugged into the computer. If not, check dmesg and see if the USB device is being detected. lsusb should also list it.

To capture images, use any one of the following utilities:

  • fswebcam
  • uvccapture

fswebcam

fswebcam -r 640x480 --jpeg 85 -D 1 web-cam-shot.jpg

Dumping fswebcam images via HTTP

You can make a quick an dirty wrapper around the command above so that it can be viewed via the web.

<?php

system("fswebcam -r 640x480 --jpeg 85 -D 1 /tmp/out.jpg > /dev/null");
header("Content-Type: image/jpeg");
echo file_get_contents("/tmp/out.jpg");


uvccapture