LivingroomCam http://livingroomcam.us/

How LivingRoomCam Works

LivingRoomCam's setup is a hodge-podge that has grown up over the years.

One of the effects of having grown up over the years is that most of the cameras are different and all of the cameras are connected differently. I've been trying different methods of capturing images weighing the problems of wiring and price. So, I'll cover each of the cameras separately.

picture of the camera in the kitchen Kitchen. The kitchen is the "cleanest" camera implementation so it should come first. I'm using an Axis 2100 Network Camera from Axis Communications . I have two total (the other one is in the livingroom). You plug the camera into the network and it serves up JPEG images. No muss, no fuss.

The kitchen camera is installed on the ceiling and I crawled around in the attic to run the network and power cables down to the basement where the network hub is.


picture of the camera in the living room Living Room The living room is another Axis 2100 camera but, rather than running cables around the house for networking, I'm using a WET11 Wireless Eternet Bridge from Linksys. The bridge just extends the ethernet connection from the house. The access point is a WAP11 Wireless Network Access Point that's in a closet in the middle of the house.


picture of the server in the basement Finally, it's all pulled together with scripts running on my Linux box that serves up the site over my cable connection. Here is a picture of the server sitting under a table midst piles of stuff in the downstairs storage room. This is where I hid all of my routers, firewalls, phone hookups and servers. I can only hope that I never get slash-dotted.


The total picture looks something like this:

Diagram of cameras

On the technical side, the fetching of the images occurs from the Linux server. The Axis cameras are networked devices that have a web server in them. The current image is available as a JPEG that can just be fetched from the camera. On the Linux server, a script is run that periodically fetches the image and places it as a JPEG on this site's web page.

The fetching script is:

#! /bin/bash
# Script that fetches images from an internet camera.
# Invocation: ./cam.sh CamConf
# where 'CamConf' is the name of a file that specifies the operations
# and configuration of the image capture process.
# The CamConf file is sourced by this script before each snap and
# has the following contents:
#
# IMAGENAME=name    # description of camera
# IMAGEURL=url      # URL to fetch the JPG image
# SNAPTIME=n      # seconds between images captured
# SNAPFILE=filename    # name of file to put captured image
# ONEDAY=(ON!OFF)    # whether to capture hourly images
# ONEDAYDIR=dirname    # directory to place hourly images
# SAVEALL=(ON|OFF)    # whether to save all images
# SAVEALLDIR=dirname  # basedir for saving all, daily subdirs will be created

CAMCONF=$1
if [[ ! -r ${CAMCONF} ]] ; then
  echo "Camera configuration file '${CAMCONF}' does not exist."
  exit 1
fi
while true ; do
  source ${CAMCONF}
  TEMPFILE=/tmp/cam$$
  # Fetch the jpg
  wget -q -T 20 -O ${TEMPFILE} ${IMAGEURL}

  if [[ $? == 0 ]] ; then
    # If a file destination is specified, copy the image there
    if [[ ! -z ${SNAPFILE} ]] ; then
      cp -f ${TEMPFILE} ${SNAPFILE}
    fi

    # If creating a directory of one snap per hour for the whole day
    #   copy the image there
    if [[ "${ONEDAY}" == "ON" ]] ; then
      DATEFILE=`date +%k | sed "s/^[^0-9]*\([0-9]\)$/0\1/"`
      DATEFILETHUMB=${ONEDAYDIR}/${DATEFILE}-120.jpg
      DATEFILE=${ONEDAYDIR}/${DATEFILE}.jpg
      cp -f "${TEMPFILE}" "${DATEFILE}"
      # create the thumbnail image
      cat "${TEMPFILE}" | jpegtopnm --quiet | pnmscale -width 120 | ppmtojpeg --comment "Copyright 2005 Robert Adams" --optimize --quality=50 > "${DATEFILETHUMB}"
    fi

    # If saving all images, do that
    if [[ "${SAVEALL}" == "ON" ]] ; then
      ALLDIR=`date +%Y%m%d`
      ALLDIR=${SAVEALLDIR}/${ALLDIR}
      if [[ ! -d "${ALLDIR}" ]] ; then
        mkdir -p "${ALLDIR}"
      fi
      ALLFILE=`date +%Y%m%d%H%M%S`
      ALLFILE=${ALLDIR}/${ALLFILE}.jpg
      cp -f "${TEMPFILE}" "${ALLFILE}"
    fi
  fi

  # wait until it is time for another snap
  sleep ${SNAPTIME}
done
You can see that this is a simple BASH script that fetches the image and, depending on the contents of the configuration file, saves the image, creates the 24 hour one day page and optionally saves all the images. (I do have some directories of a whole day of Christmas that I need to convert into a movie someday.)

This script is run for the two Axis cameras and it makes available the images on the web site. The other camera -- the deskcam -- is a USB camera that sits on top of my monitor. This is a Windows XP system and it runs WebCam32 which captures the image and saves it through a Samba shared drive directly into the directory used by the web server.

Since the images are merely JPEGs that are placed in the LivingRoomCam web page, there doesn't need to be anything special about the web page itself -- no PHP or fancy scripting. The Apache web server just serves up the page and it's images straight from the directory.

Some more pictures of the setup:


The camera in the living room is now sitting on top of a panel of family pictures. It moved here for Christmas 2005 and hasn't moved since. On the floor is the wireless bridge so I don't have to figure out how to get cables from the living room to the garage.


The kitchen cam hasn't moved in a long time -- I installed it on the ceiling and it just watches.


The networking for the house is in the garage. Here there are the Linksys firewall, switches for the machines that are inside and outside the firewall and a hub for those few 10MB devices left. You can see the wireless access point on the far left. To the right is a picture of the server that you go this page from. If you look closely, you can see it under the table.

MisterBlue / MisterBlue-MB at MisterBlue dott com Copyright 2016, Misterblue.com / // vim: tabstop=2 shiftwidth=2 autoindent expandtab