For the people who are having the problem of fswebcam crapping out after a few shots I have found a work around.
https://gist.github.com/x2q/5124616is a C program that will reset usb devices by bus and device number
save the code as
in your home folder
then compile
then make executable
type
and find the device and bus number of your camera
sample output
Code: Select all
[jib@alarmpi ~]$ lsusb
Bus 001 Device 005: ID 0846:9041 NetGear, Inc. WNA1000M 802.11bgn [Realtek RTL8188CUS]
Bus 001 Device 099: ID 046d:0825 Logitech, Inc. Webcam C270 <------------------------------- This is what you are looking for
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
then test usbreset. With your webcam plugged in do
Code: Select all
$ sudo ~/usbreset /dev/bus/usb/0XX/0XX
(replace 0XX with the output from lsusb)
if you did it correctly the shell should output something like
or something like that
now we need to create a bash script to run fswebcam and reset the cam every few shots, here is what I came up with. Note that you need to change the line "Logitech" to whatever your manufacture output is from lsusb and you need to run the script as root (sudo)so you don't have to put in a password every time the webcam resets. The following script takes four shots five seconds apart and then reset the webcam and keeps doing that until I stop it [ctrl+c to stop]. The usbreset takes about 7 seconds from shot to shot. To get this to work for you you will have to tweak the file paths to fit your setup. Good luck and if you have any question just ask.
Code: Select all
#!/bin/bash
##configure here
#type your username for the variable USER if you run with sudo, otherwise bash will use root.
USER=
#put the path to this bash script here
pathtoscript=
bs=`lsusb | grep Logitech | cut -c5-7`
dve=`lsusb | grep Logitech | cut -c16-18`
cam() {
for n in {1..3}; do
fswebcam /home/$USER/media/%H%M%S.jpg -D 1
sleep 4
done
}
cam
sudo /home/$USER/usbreset /dev/bus/usb/$bs/$dve
sudo $pathtoscript