diff options
author | Guy Sheffer <guysoft@gmail.com> | 2015-06-19 20:36:43 +0300 |
---|---|---|
committer | Guy Sheffer <guysoft@gmail.com> | 2015-06-19 20:36:43 +0300 |
commit | 102facc0b6b0ceb582dd9ba3d26db17348b7fb51 (patch) | |
tree | 4e78d65be9727ec0dca4aadab2f8425b9dc45d3d | |
parent | dfedaa3f255ac457f9ff1757e0ac7371a4823fa2 (diff) |
Fixes webcamDaemon for Logitech C170logitech
-rw-r--r-- | src/filesystem/boot/octopi.txt | 22 | ||||
-rwxr-xr-x | src/filesystem/home/pi/scripts/webcamDaemon | 53 |
2 files changed, 62 insertions, 13 deletions
diff --git a/src/filesystem/boot/octopi.txt b/src/filesystem/boot/octopi.txt index d2427b3..56b1c0f 100644 --- a/src/filesystem/boot/octopi.txt +++ b/src/filesystem/boot/octopi.txt @@ -18,6 +18,28 @@ # #camera_usb_options="-r 640x480 -f 10" +### Additional webcam devices known to cause problems with -f +# +# Apparently there a some devices out there that with the current +# mjpg_streamer release do not support the -f parameter (for specifying +# the capturing framerate) and will just refuse to output an image if it +# is supplied. +# +# The webcam daemon will detect those devices by their USB Vendor and Product +# ID and remove the -f parameter from the options provided to mjpg_streamer. +# +# By default, this is done for the following devices: +# Logitech C170 (046d:082b) +# +# Using the following option it is possible to add additional devices. If +# your webcam happens to show above symptoms, try determining your cam's +# vendor and product id via lsusb, activating the line below by removing # and +# adding it as shown examplatory. +# +# If this fixes your problem, please report it back so we can include the device +# out of the box. +#additional_brokenfps_usb_devices=("046d:082b" "aabb:ccdd") + ### additional options to supply to MJPG Streamer for the RasPi Cam # # See https://github.com/foosel/OctoPrint/wiki/MJPG-Streamer-configuration diff --git a/src/filesystem/home/pi/scripts/webcamDaemon b/src/filesystem/home/pi/scripts/webcamDaemon index 3f5b37b..2525376 100755 --- a/src/filesystem/home/pi/scripts/webcamDaemon +++ b/src/filesystem/home/pi/scripts/webcamDaemon @@ -8,11 +8,14 @@ MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" camera="auto" camera_usb_options="-r 640x480 -f 10" camera_raspi_options="-fps 10" +additional_brokenfps_usb_devices=() if [ -e "/boot/octopi.txt" ]; then source "/boot/octopi.txt" fi +brokenfps_usb_devices=("046d:082b" "${additional_brokenfps_usb_devices[@]}") + # runs MJPG Streamer, using the provided input plugin + configuration function runMjpgStreamer { input=$1 @@ -24,14 +27,45 @@ function runMjpgStreamer { # starts up the RasPiCam function startRaspi { - logger -s "Starting Raspberry Pi camera" + logger "Starting Raspberry Pi camera" runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options" } # starts up the USB webcam function startUsb { - logger -s "Starting USB webcam" - runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options" + options="$camera_usb_options" + device="video0" + + extracted_device=`echo $options | sed 's@.*-d /dev/\(video[0-9]+\).*@\1@'` + if [ "$extracted_device" != "$options" ] + then + # the camera options refer to another device, use that for determining product + device=$extracted_device + fi + + uevent_file="/sys/class/video4linux/$device/device/uevent" + if [ -e $uevent_file ]; then + # let's see what kind of webcam we have here, fetch vid and pid... + product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2` + vid=`echo $product | cut -d"/" -f1` + pid=`echo $product | cut -d"/" -f2` + vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` + + # ... then look if it is in our list of known broken-fps-devices and if so remove + # the -f parameter from the options (if it's in there, else that's just a no-op) + for identifier in ${brokenfps_usb_devices[@]}; + do + if [ "$vidpid" = "$identifier" ]; then + echo + echo "Camera model $vidpid is known to not work with -f parameter, stripping it out" + echo + options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"` + fi + done + fi + + logger "Starting USB webcam" + runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $options" } # we need this to prevent the later calls to vcgencmd from blocking @@ -39,14 +73,9 @@ function startUsb { vcgencmd version # echo configuration -echo "Starting up webcamDaemon..." -echo "" -echo "--- Configuration: -----------------------------" -echo "camera: $camera" -echo "usb options: $camera_usb_options" -echo "raspi options: $camera_raspi_options" -echo "-----------------------------------------------" -echo "" +echo camera: $camera +echo usb options: $camera_usb_options +echo raspi options: $camera_raspi_options # keep mjpg streamer running if some camera is attached while true; do @@ -61,5 +90,3 @@ while true; do sleep 120 done -echo "Goodbye..." -echo ""
\ No newline at end of file |