Webcam Video Surveillance via Motion through Optware-NG

Motion is a program that monitors the video signal from cameras.
It is able to detect if a significant part of the picture has changed; in other words, it can detect motion. :)

If you own a webcam from this list you can attach it to the AsusWRT routers usb port and capture images from it when motion is detected, like baby room, garage, courtyard...

It's only for arm devices like RT-AC56U, RT-AC68U, RT-AC87U, RT-AC88U, RT-AC3200, RT-AC5300...

- Install Optware-NG from here
- Create script for loading video modules

cat >> /opt/etc/init.d/S20videomod << 'EOF'
#!/bin/sh
PATH=/opt/sbin:/opt/bin:/opt/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
do_load_kmods_video()
{
## If uvcvideo module is already loaded exit with 1.
## Note: uvcvideo is being loaded last.
lsmod | grep -q uvcvideo && exit 1
DRV_PATH=lib/modules/`uname -r`/kernel/drivers
kmods_req="
usb/core/usbcore.ko
input/input-core.ko
media/video/v4l1-compat.ko
media/video/videodev.ko
media/video/v4l2-int-device.ko
media/video/v4l2-common.ko
media/video/v4l2loopback.ko
media/video/gspca/gspca_main.ko
media/video/uvc/uvcvideo.ko"
kmods_path=""
for i in $kmods_req ; do
if [ -f /$DRV_PATH/$i ] ; then
kmods_path="$kmods_path /$DRV_PATH/$i"
else
kmods_path="$kmods_path /opt/$DRV_PATH/$i"
fi
done
for i in $kmods_path ; do
insmod $i >/dev/null 2>&1
done
}
do_unload_kmods_video()
{
## If videodev module is not loaded exit with 1.
## Note: videodev.ko is being loaded first.
lsmod | grep -q videodev || exit 1
kmods_media="
uvcvideo
input-core
v4l2-int-device
v4l2-common
v4l1-compat
v4l2loopback
gspca_main
videodev"
for i in $kmods_media ; do
rmmod $i >/dev/null 2>&1
done
}
case "$1" in
start)
logger -s "Loading UVC modules..."
do_load_kmods_video
;;
stop)
logger -s "Unloading UVC modules..."
do_unload_kmods_video
;;
*)
echo "Usage: $0 { start | stop }"
exit 3
esac
exit 0
EOF
chmod a+rx /opt/etc/init.d/S20videomod

Press ENTER
3
 - Download and load UVC Modules (if you have a different firmware version, use this guide to compile modules or ask someone on forums)

wget -c -O /opt/tmp/uvc_modules-380.65_4-loop.tgz https://bit.ly/2xWdjfi
cd /
tar -zxvf /opt/tmp/uvc_modules-380.65_4-loop.tgz
rm /opt/tmp/uvc_modules-380.65_4-loop.tgz
/opt/etc/init.d/S20videomod start

4 - Install Motion

ipkg install motion

5 - Replace motion configuration file

mv /opt/etc/motion-dist.conf /opt/etc/motion.conf

6 - Change target dir path, where recorded videos and pictures are stored

mv /opt/etc/motion-dist.conf /opt/etc/motion.conf
sed -i 's|target_dir /.*|target_dir /opt/motion|g' "/opt/etc/motion.conf"

7 - Start motion

/opt/etc/init.d/S99motion start

8 - Perform a movement in the front of your webcam.

9 - Go to the folder you setup at point 6 and you'll find pictures captured by webcam and some .avi files which can be opened with any media player.
10 - If you want to enable live stream:

sed -i 's|stream_localhost on|stream_localhost off|g' "/opt/etc/motion.conf"
/opt/etc/init.d/S99motion restart

11 - Go to default router ip address and port :8081 or www.asusrouter.com:8081
To play with other settings like change framerate, enable password authentication, edit /opt/etc/motion.conf and don't forget to restart motion to take effect.

Tested successfully with Logitech C270 webcam
c270

 

REVIEW (CLICK ON THE STARS TO RATE!)
5
Sending
User Review
5 (9 votes)