From 0c1c101d45ac427b597b1b022a8936c817869909 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 26 Oct 2013 18:45:45 +0300 Subject: [PATCH] added wrappers for raspicam --- raspicam/motion | 52 +++++++++++++++++++++++++++++++++++++++++++++ raspicam/readme.txt | 15 +++++++++++++ raspicam/v4l2-ctl | 22 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100755 raspicam/motion create mode 100644 raspicam/readme.txt create mode 100755 raspicam/v4l2-ctl diff --git a/raspicam/motion b/raspicam/motion new file mode 100755 index 0000000..de31555 --- /dev/null +++ b/raspicam/motion @@ -0,0 +1,52 @@ +#!/bin/bash + +# this script is a wrapper around motion binary +# that makes motion work with the uv4l raspi camera module + +MOTION_BIN=/usr/bin/motion +UV4L_BIN=/usr/bin/uv4l +JPEG_QUALITY=85 + +function list_config_files() { + prev_arg="" + config_file="" + for arg in $*; do + if [ "$prev_arg" == "-c" ]; then + config_file=$arg + break + fi + prev_arg=$arg + done + + if [ -r "$config_file" ];then + echo "$config_file" + cat motion.conf | grep thread | cut -d ' ' -f 2 + fi +} + +function find_resolution() { + width="640" # the defaults + height="480" + + for file in $(list_config_files); do + w=$(cat "$file" | grep width | cut -d ' ' -f 2) + h=$(cat "$file" | grep height | cut -d ' ' -f 2) + if [ -n "$w" ] && [ -n "$h" ]; then + break + fi + done + + echo $width $height +} + +# find the configured resolution +resolution=$(find_resolution) +resolution=($resolution) + +# kill any previous uv4l instance +pkill uv4l +${UV4L_BIN} --driver raspicam --auto-video_nr --extension-presence 1 --sched-rr --width ${resolution[0]} --height ${resolution[1]} --encoding jpeg --quality $JPEG_QUALITY + +# start motion binary with preloaded .so +export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so +exec ${MOTION_BIN} $* diff --git a/raspicam/readme.txt b/raspicam/readme.txt new file mode 100644 index 0000000..f6e2962 --- /dev/null +++ b/raspicam/readme.txt @@ -0,0 +1,15 @@ +This folder is only meaningful for Raspberry PI devices used with the CSI camera board. + +1) make sure you have installed uv4l and uv4l-raspicam packages: + http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14 + +2) copy `motion' and `v4l2-ctl' scripts to /usr/local/bin; +they serve as wrappers for their corresponding programs and will +make the CSI camera work out of the box with motionEye: + sudo cp motion /usr/local/bin + sudo cp v4l2-ctl /usr/local/bin + +3) make the scripts executable: + sudo chmod +x /usr/local/bin/motion + sudo chmod +x /usr/local/bin/v4l2-ctl + diff --git a/raspicam/v4l2-ctl b/raspicam/v4l2-ctl new file mode 100755 index 0000000..27035af --- /dev/null +++ b/raspicam/v4l2-ctl @@ -0,0 +1,22 @@ +#!/bin/bash + +# this is a wrapper for v4l2-ctl that lists some custom resolutions +# when called with --list-formats-ext for the raspi camera module + +V4L2_CTL_BIN=/usr/bin/v4l2-ctl + +if echo $* | grep -- '--list-formats-ext' > /dev/null; then + echo "ioctl: VIDIOC_ENUM_FMT" + echo -e "\tIndex : 0" + echo -e "\tType : Video Capture" + echo -e "\tPixel Format: 'YUYV'" + echo -e "\tName : YUV 4:2:2 (YUYV)" + echo -e "\t\tSize: Discrete 320x240" + echo -e "\t\tSize: Discrete 640x480" + echo -e "\t\tSize: Discrete 1024x768" + echo -e "\t\tSize: Discrete 1280x1024" + + exit +fi + +${V4L2_CTL_BIN} $* -- 2.39.5