This site will go offline starting with 01-JUL-2017 when web hosting contract expires, I don't have free time and interest anymore to maintain it. If someone wants to copy all tutorials and post them somewhere else like RMerlin Wiki, please do. Contact me for other packages or modules, like debian, minidlna, uvc...

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, write a comment or use contact form to request modules)

wget -c -O /opt/tmp/uvc_modules-380.65_4-loop.tgz goo.gl/Bt8uSO
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

 

  • Mikhail Taran

    Hey.
    I tried to adjust the camera (Logitech C270) on ARM Asus RT N18U firmware Tomato USB from Shibe. I thought that the same processor (ARM) OpenWRT compatible firmware.
    And almost all things are turned. But there is a problem. The chamber is defined as a device, but not as camera, probably the drivers are not suitable.
    Please help me with this problem, if possible. Very grateful to you for your attention.
    P.S. Sorry for my english, it is the translator Google.
    Additions screenshots:
    https://drive.google.com/folderview?id=0B760JkG01GAzV2MzemxTeVhFeG8&usp=sharing

    • TeHashX

      You need uvc drivers made for your firmware, can't use those, ask on Shibby forums

      • Mikhail Taran

        Hello again! i found firmware and another uvc drivers, and then my c270 start working.
        But i have again new problem. My rt n18u router write video to mounted in usb 3.0 port sata 2.5" hdd (from laptop) very slow.even when the size of 640 * 480 , recorded on a video disc stops every 2-3 seconds to 0.5 seconds . At the same time the same thing happens with the other ( large ) size of the video. I tested my hdd, hi work fine in other read-write operations. whether it is possible to overcome this problem , or is it limited by the hardware limitations of my router ?

      • TeHashX

        It's the CPU not the HDD, try to increase/decrease frame rate

      • TeHashX

        Also you can try to install Motion Entware-NG version, steps are almost the same...

SUBSCRIBE

To be notified by email when a new tutorial is posted :)

Thanks for Subscribing! I'll keeping you up-to-date with latest tutorials!

Something went wrong, try again...