Webcam: Difference between revisions

From Leo's Notes
This page was last edited on 23 March 2015, at 08:03.
Created page with " == 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 s..."
 
No edit summary
Line 9: Line 9:
=== fswebcam ===
=== fswebcam ===
  fswebcam -r 640x480 --jpeg 85 -D 1 web-cam-shot.jpg
  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.
<syntaxhighlight lang="php">
<?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");
</syntaxhighlight>


=== uvccapture ===
=== uvccapture ===


[[Category:Linux]]
[[Category:Linux]]

Revision as of 08:03, 23 March 2015

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