Office window time-lapse

As followers of this blog will know, I’ve been experimenting with a Raspberry Pi (RPi) and one of the uses that I found for it is as a webcam server. I have plans to put a permanent webcam in the TrustIV office window in Manchester and I’ll be using a RPi to do this.

My installation is pretty straightforward:

  • Raspberry Pi
  • Logitech C270 webcam
  • Shared windows folder for storage of images

I installed the standard Raspbian operating system and connected the Pi to the Office network. Once I identified it by IP address, I connected to it via SSH. I left the RPi in “headless mode” without a keyboard, monitor or mouse attached.

I installed fswebcam software. Fswebcam is a simple webcam app. It captures images from a V4L1/V4L2 compatible device or file, averages them to reduce noise and outputs the image to PNG or JPEG formats. The resulting image can then be saved to a file, like the image below.

Webcam time-lapse

Click on the image above to see the timelapse, alternatively read on for the geeky bit…

I mounted an external shared windows folder (called nas) using these commands:

cd /mnt
sudo mkdir nas
sudo mount -t cifs -o username=<username>,password=<password> //PC/nas /mnt/nas
(instructions from the Raspberry Pi adventures blog.

Then I wrote a short script called webcam.sh  that created a folder on the NAS and saved images to that share at five-second intervals

mkdir /mnt/nas/$(date +”%Y%m%d”)
sudo fswebcam -r 640×480 -S 15 –jpeg 95 –save /mnt/nas/$(date +”%Y%m%d”)/webcam.jpg

while true
     do
     sleep5
     sudo mv /mnt/nas/$(date +”%Y%m%d”)/webcam.jpg /mnt/nas/$(date
+”%Y%m%d”)/webcam_$(date +”%m%d%Y%H%M%S”).jpg
     sudo fswebcam -r 640×480 -S 15 –jpeg 95 –save /mnt/nas/20130121/webcam.jpg
done

run using
sudo ./webcam.sh

To “stitch” the video together, I used Windows Live Movie Maker to convert the folder of images to a time-lapse video. Images were replaced every 0.05 seconds, meaning that the “action” was sped up 160x faster than real life.

If you read this far, well done. The video is now on the TrustIV blog page, click the image below to see the timelapse footage, and keep checking back there for the webcam. (When I finally get round to installing it) 🙂

Webcam time-lapse

 

 

Author: Richard Bishop

http://about.me/richard_bishop

2 thoughts on “Office window time-lapse”

  1. I’m looking to use your script with my Pi cam but I’m needing to at a -vf and -hf, Also I may want to implement other options to adjust the cam. where in the script should I enter that?

  2. Hi Jeff,

    Sorry for the very long delay in replying. For some reason I missed the notification that you’d commented. I can’t see -hf or -vf in the manpages for fswebcam, mv or mount so I’m not sure what you’re trying to achieve with these switches.

    Let me now what extra functionality you need and I”ll help if I can.

    All the best
    Richard

Comments are closed.