Oops! Something went sideways.

Looks like the styling got goofed up. Sorry about that, unless it's what you wanted. If this isn't what you were looking for, try force refreshing your page. You can do that by pressing Shift + F5, or holding Shift and clicking on the "reload" icon. (It's the weird circle arrow thing "⟳" just above this page, usually next to where it says https://blog.unitedheroes.net...)

isn't quite ashamed enough to present

jr conlin's ink stained banana

:: Keeping an Eye On Things

So, in the midst of being a paranoid little geek, i’ve been mucking about with the idea of setting up some cameras around my house. Fortunately, that’s something that’s become a tad more affordable as of late. Mostly thanks to the fact that folks insist on getting the latest generation of electronic gizmo and orphan the old one.

This is interesting because many of those said gizmos have wifi and cameras built in. In addition, you can get real wireless cameras for a lot less than you could a few years ago, so there’s that.

Here’s how i set up my configuration (or at least the bits that are interesting):

What you’ll need:
N Wireless
a Linux server with a fair bit of space on it (Pics and videos take space)
IP cameras.

1) The pre-install.
Technically, N wireless does 300Mbps per channel, with bursting up to 450Mpbs. A lot of devices top at 100Mbps. i’d recommend getting a dual band router and keep the devices on the broader 2.4Ghz channel.

The linux box is also kinda key. It doesn’t have to be spectacular (i run a dual core franken-box i built about 7 years ago), and has Ubuntu server loaded on it. It runs headless, so there’s no need for anything fancy.

2) The real webcameras
i picked up some FOSCAMs that were on sale on Amazon. These are nice little cameras that have built-in wifi, as well as remote movement controls. They also have the ability to do motion detection and have a pretty powerful set of IR lights. They’re not without a few problems, though.

For one thing, getting the camera on the network. The easiest way to do that is to plug it into the router, find the IP in the attached device list and then http to that. Once you’re there you can set the network, IP address, port, and all the other settings you’ll need. Fortunately, once they’re configured, they’re pretty autonomous.

Another issue is that they reboot every so often. When they do, they turn on the IR lights. The problem with that is IR reflects amazingly well off of glass which blinds the camera. Sadly, there’s no way have the camera remember to not turn those on, but you can use a remote command to force the IR off.

/usr/bin/curl -n --silent http://$CAMERA_ADDR/decoder_control.cgi?command=94 > /dev/null

i have a crontab entry that sends that command every so often to make sure the damn lights stay off.

3) The more disposable webcams

Like i said, depending on where you are and how tech savvy your community happens to be, you can get things like first generation ipod touches for as low as $1. Old Android phones can also be had for darn cheap, so it can be fairly easy to load up just by visiting craigslist. Once you have your handfuls of junk cameras, you can then load them with ipCam for iOS or IPWebcam for Android. Both of these apps let you route the camera to the local LAN, and that’s a delightful thing, as we’ll discover in a second.

4) Setting things in Motion

Now comes the fun bit…

On the linux box, grab a copy of motion. Motion will pull the cameras for images and do some quick analytics to detect motion. It will also capture snapshots and compile a stream of activity for the day.

Be sure to point motion at a directory with “ample space”. In my case, i record about 2GB of data for 4 days. i have a script that goes through the directories and purges files older than that, but that’s me. Granted, in an era of sub $100 2 TB drives, this is probably being overly aggressive. Here’s the cleanup code:
/usr/bin/find /d2/media/ipcam -type f -ctime +2 -delete
for i in `ls -1` ; do
/usr/bin/find /d2/media/ipcam/$i/jpg -type d -empty -delete
/usr/bin/find /d2/media/ipcam/$i/swf -type d -empty -delete

And for those that are interested, my motion.conf file is below. i’ve trimmed out the comments and blank lines, but this shows the values.
process_id_file /var/run/motion/motion.pid
setup_mode off
videodevice /dev/video0
v4l2_palette 8
input 8
norm 0
frequency 0
rotate 0
width 320
height 240
framerate 2
minimum_frame_time .5
netcam_tolerant_check off
auto_brightness off
brightness 0
contrast 0
saturation 0
hue 0
roundrobin_frames 1
roundrobin_skip 1
switchfilter off
threshold 1500
threshold_tune off
noise_level 32
noise_tune on
despeckle EedDl
smart_mask_speed 0
lightswitch 0
minimum_motion_frames 1
pre_capture 0
post_capture 0
gap 60
max_mpeg_time 0
output_all off
output_normal on
output_motion off
quality 75
ppm off
ffmpeg_cap_new on
ffmpeg_cap_motion off
ffmpeg_timelapse 0
ffmpeg_timelapse_mode daily
ffmpeg_bps 600000
ffmpeg_variable_bitrate 0
ffmpeg_video_codec swf
ffmpeg_deinterlace off
snapshot_interval 0
text_right %Y-%m-%d\n%T-%q
text_changes off
text_event %Y%m%d%H%M%S
text_double off
target_dir /tmp/motion
webcam_quality 70
webcam_motion off
webcam_maxrate 1
webcam_localhost off
webcam_limit 0
control_port 8080
control_localhost off
control_html_output on
track_type 0
track_auto off
track_motorx 0
track_motory 0
track_maxx 0
track_maxy 0
track_iomojo_id 0
track_step_angle_x 10
track_step_angle_y 10
track_move_wait 10
track_speed 255
track_stepsize 40
quiet on
thread /etc/motion/lr.conf
thread ...

And the main camera config (remember, this replaces the values from motion.conf)
lightswitch 0
pre_capture 3
width 640
height 480
target_dir /d2/media/ipcam/lr
snapshot_filename jpg/%Y%m%d/s-%H%M%S-%q
jpeg_filename jpg/%Y%m%d/%H%M%S-%q
movie_filename swf/%Y%m%d/%H%M%S
timelapse_filename tl/%Y%M%d
ffmpeg_timelapse 5
text_left LivingRoom
webcam_port 8081
netcam_userpass ##:##
netcam_http 1.1
auto_brightness on
text_left LivingRoom
webcam_port 8081
on_picture_save /home/jrconlin/bin/newPic.sh %f

The “on_picture_save” bit stores a copy of the latest picture to my remote server. i have something else pull movies, but i could have also had motion push them just as easily. It’s also possible to have motion monitor just parts of an image and fire a script when it sees activity at that position. i’ve thought about rigging that up for Halloween one year to scare the pants off of kids coming up the driveway.

That’s it! Happy monitoring.

Blogs of note
personal Christopher Conlin USMC memoirs of hydrogen guy rhapsodic.org Henriette's Herbal Blog
geek ultramookie

Powered by WordPress
Hosted on Dreamhost.