I want to turn my old Lenovo R61 into a timelapse camera. I have a series of scripts that used to work on my HP NC6220, may it rest in pices. I use a Microsoft home cinema HD camera.
But I'm experiencing USB issues, it seams to loose USB connection and not reconnect. I have tried a lot of things but none were successful. Maybe I'm doing it wrong. So now I'm asking for help. And I'll be debugging at the same time myself.
For starters I'm using uvccapture, but I'm using a version that should be better with this camera (http://dp.nonoo.hu/modified-uvccapture/). It was better on the HP pc, but both versions seam to be equally bad on the Lenovo PC.
My script does a lot of odd things to handle the problems I have seen over time.
In front of the script below I have a script with a loop calling it. It does nothing else at the moment.
- Code: Select all
#!/bin/bash
# Crash script if not finished in 15 seconds
me=$$
(sleep 15; kill $me >/dev/null 2>&1) & nuker=$!
# Prime camera with a 4 sec delay
uvccapture -v -d/dev/video0 -x1280 -y720 -D4
# Take picture, with a 3 sec delay
uvccapture -v -d/dev/video0 -x1280 -y720 -D3 -o%Y%m%d%H%M%S.jpg
# Reset USB to make sure that the camera is ready for the next run
./ResetUSB.sh
# Script killer. KILL
kill $nuker >/dev/null 2>&1
This is the script I call to reset USB:
- Code: Select all
#!/bin/bash
#http://billauer.co.il/blog/2013/02/usb-reset-ehci-uhci-linux/
#SYSEHCI=/sys/bus/pci/drivers/ehci_hcd
SYSEHCI=/sys/bus/pci/drivers/ehci-pci
SYSUHCI=/sys/bus/pci/drivers/uhci_hcd
if [[ $EUID != 0 ]] ; then
echo This must be run as root!
exit 1
fi
if ! cd $SYSUHCI ; then
echo Weird error. Failed to change directory to $SYSUHCI
exit 1
fi
for i in ????:??:??.? ; do
echo -n "$i" > unbind
echo -n "$i" > bind
done
if ! cd $SYSEHCI ; then
echo Weird error. Failed to change directory to $SYSEHCI
exit 1
fi
for i in ????:??:??.? ; do
echo -n "$i" > unbind
echo -n "$i" > bind
done
I have not been able to find out where exactly this procedure craches. But I believe (from what I have seen in the terminal window) that the “path” to the webcam changes or becomes unavailable at some point (sometimes on the second picture) and this can only be helped by reconnecting the webcam.
- Code: Select all
ERROR opening V4L interface
: No such file or directory
Yesterday I shot almost 1000 pictures at a 24 second interval. I'll make it into a movie and post it later.
Next time my script crashes I'll have a look at lsusb to see if the interface changes. Currently it is:
- Code: Select all
Bus 002 Device 002: ID 045e:075d Microsoft Corp. LifeCam Cinema
I hope that some one has a bright idea. I would love to see this work.
Kind Regards J;-)
Edit: Wrong info about LSUSB corrected.