Close
0%
0%

Classifying everything using your RPi Camera

How to classify images quickly and accurately using your RPi with a camera and an internet connection

Similar projects worth following
There are all kinds of autonomous tasks you can do with the RPi camera. Perhaps you want to know if your dog is in your living room, so the Pi can take his/her picture or tell him/her they are a good dog. Perhaps you want your RPi to recognize whether there is fruit in your fruit drawer so it can order you more when it is empty. The possibilities are endless.

This is a way to make all of that possible using the Caffe deep learning framework.
You can read more about this on my blog here:
http://stevenhickson.blogspot.com/2015/03/classifying-everything-using-your-rpi.html

Deep Learning on the Pi

Well I went ahead and compiled Caffe on the RPi. Unfortunately since it doesn't have code to optimize the network with it's GPU, the classification takes ~20-25s per image, which is far too much.

Note: I did find a different optimized CNN network for the RPi by Pete Warden here. It looks great but it still takes about 3 seconds per image, which still doesn't seem fast enough.

You will also need the Raspberry Pi camera module.

A better option: Using the web demo with python

So we can take advantage of the Caffe web demo and use that to reduce the processing time even further. With this method, the image classification takes ~1.5s, which is usable for a system.

  • 1
    Step 1

    Install requirements for python and query CNN code

    sudo apt-get install python python-pycurl python-lxml python-pip
    sudo pip install grab
    sudo apt-get install apache2
    mkdir -p /dev/shm/images
    sudo ln -s /dev/shm/images /var/www/images
    Then you must forward your router from port 5005 to port 80 on the Pi
    run test.sh

    How does this work

    First we use raspistill to take an image and save it to memory as /dev/shm/images/test.jpg. Since this is symlinked in /var/www, we should be able to see it at http://YOUR-EXTERNAL-IP:5005/images/test.jpg.
    Then we use grab to qull up the Caffe demo framework with our image and get the classification results. This is done in queryCNN.py which gets the results.

    The output of ./test.sh should look something like this:

    pi@raspberrypi ~/CaffeCNNQuery $ ./test.sh projector device equipment optical instrument electronic equipment 

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates