Urban sensing class team project - counting moving objects with Raspberry Pi
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
capture.py
capture_with_button.py
juan_capture_function.py
juan_detector.py
motion_detector_modified.py
rat_detector.py
track_movement.py

README.md

urban_sensing

Urban sensing class team project. We build a "rat detector" prototype with a Raspberry Pi. The detector uses background subtraction to identify moving objects in a video stream and counts them.

Team

  • Emil Christensen
  • Eduardo Franco
  • Juan Medina
  • Peter Varshavsky

Viewing images with SSH

The only way I am able to view images when connecting to RPi with ssh is in ASCII art mode. To do this, install FIM (which stands for 'Fbi IMproved' where FBI stands for FrameBuffer Image viewing) with sudo apt-get install fim.

To view images in ASCII art mode, run fim -at <image.png>.

TODO: figure out how to do X-forwarding and view images for real through SSH.

Camera

Currently capturing series of images. Camera can save to files or to byte stream. Camera docs are here and some advanced recipes are here.

TODO:

Get constant manually set exposure. Camera docs (link above) have that info.

Button IO

  • Using this Raspberry Pi Cookbook tutorial. See this image for Raspberry Pi 2 pin layout.

  • Tried to implement this multithread callback interrupts tutorial to have more control of camera, but having issues connecting to the web at the moment. It needs a newer version of RPi.GPIO library than what I have at the moment. More info on wait_for_edge() and event_detected() GPIO functions here

Notes on RPi setup

SSH Agent forwarding

Add this to your ~/.ssh/config to forward your SSH Agent to your RPi. This allows you to ssh into GitHub and other servers using your laptop's private keys without storing them on RPi.

# Raspberry Pi ssh Agent forwarding
Host <raspberry_pi_IP_address>
   ForwardAgent yes

More info in this GitHub guide

Ethernet and Wireless setup

To SSH into Raspberry Pi you need to know its IP address. By default your router probably assigns IP addresses of its choice to Ethernet and WiFi devices. This instructable step shows how to set up static IP to connect to your router with Ethernet.

These two docs helped me set up static IP WiFi. Very useful to SSH into Raspberry Pi from a machine on the same network:

Running a Python script on startup

This instructable goes over setting up a startup shell script to launch a python script and setting up a cron job to launch the shell script.

In my case the launcher script for capture.py is

#!/bin/sh
# rat_launch.sh
cd /home/pi/projects/rats/code
sudo python capture.py
cd /home/pi/logs

it drops me off in the ~/logs directory.

Color git output

git config --global color.ui auto

Vim

Install vim (so much better than vi)

From this text editors doc: sudo apt-get install vim

Vim configuration

This gist has my .vimrc file. Place it in your home folder to automatically set vim to highlight syntax, set tab to 4 spaces and convert tabs to spaces. It also highlights lines longer than 79 characters to keep you PEP8 compliant.

Make vim your default text editor

Run sudo update-alternatives --config editor and follow the prompts.