Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Raspberry Pi Surveillance Camera Website help
New Posts  All Forums:Forum Nav:

Raspberry Pi Surveillance Camera Website help

post #1 of 2
Thread Starter 
So one of my buddies is working on his senior(final) project for his Computer Science degree. This is what we are doing:
We bought a Raspberry Pi and a simple USB Logitech Webcam. Using 'Motion' we have configured the camera to take images every 30sec once motion is detected. In the end we want the pi to automatically upload any new images that are taken to a website and to dispatch an email if/when a new picture is taken/added to the website. The part we are confused on is getting the pi to upload the pictures to a website as soon as they're taken for quicker "surveillance" use.

Any help is appreciated
Thanks in advance
post #2 of 2
Quote:
Originally Posted by Jwright0291 View Post

So one of my buddies is working on his senior(final) project for his Computer Science degree. This is what we are doing:
We bought a Raspberry Pi and a simple USB Logitech Webcam. Using 'Motion' we have configured the camera to take images every 30sec once motion is detected. In the end we want the pi to automatically upload any new images that are taken to a website and to dispatch an email if/when a new picture is taken/added to the website. The part we are confused on is getting the pi to upload the pictures to a website as soon as they're taken for quicker "surveillance" use.

Any help is appreciated
Thanks in advance

There's dozens of ways you can do this, each with their own benefits and drawbacks. The easiest way would be the following:
Code:
#!/bin/sh

while true; do
    rsync -a -e "ssh -i /path/to/private.key" image.jpg username@domain.com:/destination/path/image.jpg 
    sleep 30
done
# You'll have to set up private, passwordless SSH keys on the webserver
# and change the code to point to your specific locations.
This will only upload the image if the time stamp and checksum on the destination differs.

It's not the most secure method of doing this, but it's the easiest way without worrying about race conditions (images changing while upload / hitting refresh on the website) nor mounted network shares dropping.

If you're using this for production use then you'd probably want to use HTTP uploads; or at the very least add some timeouts to this script to prevent rsync hanging. And also to daemonise this script and add it to sysv init / systemd so it starts on boot and doesn't require an interactive shell open. But this script would be enough to get you started.

Also, since you're exposing SSH on the web server (which I'm guessing isn't sat on the same LAN as your Pi, otherwise you'd just host the website on your Pi), make sure you set up fail2ban or denyhosts to blacklist the IPs of anyone who attempted to brute force their way onto your web server.
Edited by Plan9 - 3/27/14 at 12:01pm
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Raspberry Pi Surveillance Camera Website help