Easy Raspberry Image Object Identification

Easy and fun; take a pic, run image object detection and process the results on Raspberry Pi and Mathematica

Public Chat
Similar projects worth following
a 30 minutes level beginner project to implement visual object detection on a stock raspberry pi.

My project is a very easy implementation of computer vision on raspberry pi.

Most people who had buy a Raspberry Pi camera module or similar (from here and thereafter Raspicam) is somehow thinking about computer vision, but the complexity of the implementation of layers and layers of software and code in the examples is a strong entry barrier.

I hope this project will help with that; if you have a raspberry and a raspicam you should try it... it only take 30 minutes ;) 

  • 1 × Raspberry Pi (the newest the best)
  • 1 × Raspberry Pi Camera Module
  • 1 × Raspberry Kit SD, keyboard, mouse and power source

View all 3 project logs

  • 1
    Get the components ready


    we have a raspicam, a data ribbon and the raspberry with a keyboard/mouse dongle.

    You should connect and re check connections between the camera and the pi. almost all the problems to get the camera working is about three connections; the connector between the black camera and the pcb, the ribbon on the back of the camera and the ribbon on the camera port of the pi. check them all and put them in a case if you have one. if questions arise follow the documentation on hardware connection :

    Next Step: start the pi and take a pic

  • 2
    Start the Pi and take a pic

    We have to install Raspberry Pi Desktop in the SD card. Follow the instructions (use New Out Of The Box if you are not familiar) and install the Pi Desktop.

    Now, if we connect the pi to the power source we can start the OS and configure an internet connection. The pi starts in a graphical environment with a setup mode, everything is mouse and click =D

    After the configuration we should have a rebooted raspberry logged with user pi and your new password and connected to the internet, nothing out of the ordinary in the pi setup.

    Next we should setup the raspicam; in 

    Preferences>Raspberry Pi Configuration>Interfaces 

    we put it in enable state and click Ok, then reboot the pi to start using the camera module.

    Now the Picture!!!!

    Create a new folder in the desktop named picamtest, then right-click it and click "open in terminal". now type 

    raspistill -v -o test.jpg

    and you should have something like this on your terminal window

    and a picture named test.jpg in your picamtest folder

    if the camera is not detected re-re-check the connections as is described in the first step and test again, it should solve it.

    Check the lightning and take a few pictures to get a nice and clean framing for the objects.

  • 3
    Mathematica (not the science, the Wolfram software) and computer vision

    Now it's time to recognize things!!!

    First, a few words on Mathematica from the Wikipedia;

    Wolfram Mathematica (usually termed Mathematica) is a modern technical computing system spanning most areas of technical computing — including neural networks, machine learning, image processing, geometry, data science, visualizations, and others. The Wolfram Language is the programming language used in Mathematica.

    Now in my words:

    Mathematica is an insanely powerful engine and the Wolfram Language is the easiest in earth. and it came installed and free for use in the raspberry pi. 

    Now that we know everything we need to know about Mathematica, we can open it on 


    It opens a blank notebook, now we will take a picture from Mathematica; type

    img = Import["!raspistill -n -w 600 -h 400 -t 1 -o -","JPG"]

    and, with a right-click, select "evaluate cell" and we have taking a picture from Mathematica

    Now step by step:

    img = Import[... ,"JPG"] we create a variable to store a JPG of the result of the importation

    raspistill -n -w 600 -h 400 -t 1 -o  ask the script to take a 600x400 JPG image with 1 second delay

    and the out = is the picture 

    Not bad for 1 line of code ;)

    Now we want to know what object is in the picture so we type in the next line*

    imgIdenEN = TextString[ImageIdentify[img]]

    (*now we need a working internet connection to download the identify data, it'll say "running" in the tab for a minute for the first time... it's not frozen)

    And voila! We have a textual description of the object in our picture =D

    Now again, step by step:

    imgIdenEN = TextString[ImageIdentify[img]]

    ImageIdentify[img]  Evaluate the picture to recognize objects, returns a Wolfram Entity. Ref : ImageIdentify 

    TextString[...] Returns a human readable form for the Entity. Ref: TextString  

    imgIdenEN = ... create a variable to store the resultant text name of the object.

    So, in resume, to recognize objects you need to type:

    img = Import["!raspistill -n -w 600 -h 400 -t 1 -o -","JPG"]

    imgIdenEN = TextString[ImageIdentify[img]]

    and that's all.

    Next Step: Processing the results

View all 4 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

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