Home CCTV (Cheapo Edition)

Forum rules
Share your brain ;)
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Home CCTV (Cheapo Edition)

Unread post by machinebacon » Sun Sep 27, 2015 10:05 am

The following instructions turn your computer with webcam to a poor man's surveillance system. If you are planning to go on holidays, if you don't trust the neighbors or family members, or if you want to know who cums on your toothbrush while you are at work -- these are all use-cases for you!

CASE 1: Holidays! I am not at home but I want to know who steals my underwear :(

You will be able to log in to dropbox and see the images there.

1) You need a computer -- I use a RasPi -- and a webcam that is actually detected by the device. Usually, most of them will work well.
2) Install 'cron' 'fswebcam' and 'curl' from the repos:

Code: Select all

sudo apt-get install cron fswebcam curl
3) Get yourself a Dropbox account on which the images will be uploaded: http://www.dropbox.com
4) Fetch the dropbox_uploader.sh script, make it executable (chmod a+x dropbox_uploader.sh), and if wished, move it to /usr/local/bin/dropbox_uploader.sh

Code: Select all

curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o dropbox_uploader.sh
5) Run dropbox_uploader.sh and follow the instructions. It's easy.
6) Create a directory named ~/webcam

Code: Select all

mkdir ~/webcam
7) Create /usr/local/bin/snap with following content and make it executable (chmod a+x /usr/local/bin/snap)

Code: Select all

#!/bin/bash
IMGPATH=~/webcam/
IMGNAME="$(date +\%Y\%m\%d\%H\%M).jpg"
FULLPATH=$IMGPATH$IMGNAME
fswebcam $FULLPATH
/usr/local/bin/dropbox_uploader.sh upload $FULLPATH $IMGNAME
8) Add a new crontab entry:

Code: Select all

crontab -e
at the bottom, add

Code: Select all

* * * * * /usr/local/bin/snap
for a snapshot every minute. If you want a snapshot every 5 minutes, use

Code: Select all

*/5 * * * * /usr/local/bin/snap
You don't need to worry about filling up your hard disc with stills: dropbox_uploader.sh moves the files to the server so your drive stays clean. Of course you should clean up the images folder in dropbox every now and then (for me, one image a minute produced around 6Mb of data per hour, YMMV -- you can resize fswebcam's output and also reduce the size by compressing jpg to 70% or so -- have a try first!)

CASE 2: I just want to spy on my loved ones :P

1) You need a computer -- I use a RasPi -- and a webcam that is actually detected by the device. Usually, most of them will work well.
2) Install 'cron' and 'fswebcam' from the repos:

Code: Select all

sudo apt-get install cron fswebcam
3) Create a directory named ~/webcam

Code: Select all

mkdir ~/webcam
4) Create /usr/local/bin/snap with following content and make it executable (chmod a+x /usr/local/bin/snap)

Code: Select all

#!/bin/bash
IMGPATH=~/webcam/
IMGNAME="$(date +\%Y\%m\%d\%H\%M).jpg"
FULLPATH=$IMGPATH$IMGNAME
fswebcam $FULLPATH
5) Add a new crontab entry:

Code: Select all

crontab -e
at the bottom, add

Code: Select all

* * * * * /usr/local/bin/snap
for a snapshot every minute. If you want a snapshot every 5 minutes, use

Code: Select all

*/5 * * * * /usr/local/bin/snap
..gnutella..

User avatar
simgin
Meme Fodder
Posts: 1167
Joined: Sun Jan 06, 2013 12:07 am
Location: Bradford-on-Avon, UK

Re: Home CCTV (Cheapo Edition)

Unread post by simgin » Sun Sep 27, 2015 12:07 pm

Nice writeup Julius, someone is stealing your underwear? What fucking looser does that :S
Someone told me that I am delusional, I almost fell off my unicorn.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: Home CCTV (Cheapo Edition)

Unread post by dkeg » Sun Sep 27, 2015 12:58 pm

Interesting. No use case for it atm, but very cool nonetheless. Thanks for the write up.

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Home CCTV (Cheapo Edition)

Unread post by machinebacon » Sun Sep 27, 2015 2:38 pm

simgin wrote:Nice writeup Julius, someone is stealing your underwear? What fucking looser does that :S
I wonder, too -- I don't even *wear* underwear!
..gnutella..

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: Home CCTV (Cheapo Edition)

Unread post by pidsley » Sun Sep 27, 2015 3:58 pm

Cool! I used something similar to make a time-lapse video with my cheap webcam and rpi (taking a snap every 5 seconds, and then making a video with mencoder) -- fswebcam has a handy "loop" option.

fswebcam.sh:

Code: Select all

#!/bin/sh

fswebcam --loop 5 test.jpg -r 768x576 --exec ./update.sh
update.sh:

Code: Select all

#!/bin/sh

cp test.jpg "test-$(date +%s).jpg"
Running fswebcam.sh takes a snap every 5 seconds and uses update.sh to copy each snap to a time-coded file.

Then use mencoder to build a video:

Code: Select all

#!/bin/sh

mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=4/3:vbitrate=8000000 \
  -vf scale=768:576 -o timelapse.avi -mf type=jpeg:fps=24 mf://@list.txt
I started with the instructions here and made some minor modifications to the scripts.

I believe you can also make the video with ffmpeg, but I did not try that. Search the web for "time-lapse video linux".

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Home CCTV (Cheapo Edition)

Unread post by machinebacon » Sun Sep 27, 2015 4:18 pm

^ Ah, that's nice, too! Thanks :)
..gnutella..

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: Home CCTV (Cheapo Edition)

Unread post by ivanovnegro » Sun Sep 27, 2015 5:48 pm

That is really cool.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: Home CCTV (Cheapo Edition)

Unread post by GekkoP » Mon Sep 28, 2015 7:15 am

Nice, I just need a webcam, but this could be useful to monitor who the hell uses my media server when I'm not at home. Thanks.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Home CCTV (Cheapo Edition)

Unread post by machinebacon » Mon Sep 28, 2015 3:49 pm

Some older 'digital camera' models work fine as webcams, and if you replace fswebcam with arecord you can monitor the noise in your apartment :D
..gnutella..

User avatar
ChefIronBelly
Approved BBQer
Posts: 1044
Joined: Mon Jan 13, 2014 6:01 am
Location: Michigan

Re: Home CCTV (Cheapo Edition)

Unread post by ChefIronBelly » Thu Oct 01, 2015 2:02 pm

I need to dig out my old webcam and give this a go. thanks for sharing.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]

User avatar
nova
applies for custom title
Posts: 49
Joined: Tue Dec 09, 2014 6:55 pm
Location: Planet 892-IV

Re: Home CCTV (Cheapo Edition)

Unread post by nova » Sat Oct 10, 2015 1:23 am

This may resolve a soiled bed linen mystery. Thanks.
difficile est saturam non scribere. nam quis iniquae
tam patiens urbis, tam ferreus, ut teneat se...

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: Home CCTV (Cheapo Edition)

Unread post by rhowaldt » Sat Oct 10, 2015 9:24 am

hahaha wtf? i hope youre talking animals :D
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

skakos
Distrowatcher
Posts: 1
Joined: Fri Apr 21, 2017 11:34 am

Re: Home CCTV (Cheapo Edition)

Unread post by skakos » Fri Apr 21, 2017 11:40 am

Hi, I read twice but still unable to understand the bed linen or bedding mystery! btw new from Australia!
Shop online Bianca Bedspreads in Australia.

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: Home CCTV (Cheapo Edition)

Unread post by ivanovnegro » Fri Apr 21, 2017 6:29 pm

Then what about an introduction in the appropriate forum thread? ;) Then we can properly welcome you.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Home CCTV (Cheapo Edition)

Unread post by wuxmedia » Sun Apr 23, 2017 10:52 pm

^^ I presume Nova has had a soiled bed and would use the CCTV to find out how did it..?
"Seek, and Ye shall find"
"Github | Chooons | Site"

Post Reply