Introduction: Shape Color Recognizer - Intel Edison

*** we have to add the final video and some photos of final exposition ***

This project is part of Intel Make It Challenge

Our team in Fablab develop a prototype to manage and subdivide bottle cups by shape and color. In this first try we separate by shape with a balistic separator and by color with a Intel Edison board and a webcam. The system use Cloud platform for stream bottle cup type, to organize a future recycle system in the local area of a town.

Our Team

  • Stefano Varano Stefanosky
  • Armando Federici
  • Rosario Uriselli
  • Francesco Luzio

Step 1: Video

Step 2: Why We Build This One

we create a documentation in Italian about the project that aim to help local communities

Step 3: Balistic Separator

The balistic separator is the first part of mechanical separation of the bottle cups.

Two perforated plates do the job of separation. The bottle cups flow in different direction so we can manage the separation

All insert in a wood box, laser cutted

  • Wood 4mm - 120cmX60cm
  • plexiglass 3mm or 4mm - 40cmX40cm
  • plexiglass , a little piece of 5mm
  • glue for wood
  • brushed dc motor
  • electric wire
  • 1m wood rod of 6mm

Cut the piece with a laser cutter CO2 , files cad in AI8 for cutting is attached here in this STEP.

mount the structure and put some glue for wood

in plexiglass 5mm cut the wheel and little piece to move the plates

the kerf of our laser was ok for fit the motor shaft

Step 4: Slide

slide to bring bottle cup in the color separator

Step 5: Color Separator - Mechanical

instruction for the mechanical

I draw the parts and the gears. For the gears I experimented this http://geargenerator.com/

Then in Illustrator I tranform the round gear in a linear gear, and to obtain the right combination, we try!

It works! File Cad attached

the motors are 2 stepper motor 5V with uln2003 Driver, in the video a demo movement made with Arduino board.

Ex. http://www.arduiner.com/3002-home_default/5v-stepp...

In final costruction we add some little piece of lexi to reduce the noise movement as you can see in the video.

Step 6: Color Separator : Electronics & Software

instruction for electronics

  • Install Intel Edison
  • update firmware
  • update package
  • follow istruction for mraa, python, opencv, numpy
  • write code for color recognizer
  • move the mechanical parts
  • connect to iotkit platform by Intel (enableiot.com)

The Intel Edison it's a mini computer fanless with wifi onboard. Inside there is a linux based OS, Yocto. For starting with this prototyping board it's necessary install:

  • driver software
  • the Intel Edison Board Configuration Board
    • install driver
    • update firmware
    • wifi configuration
  • chose a IDE

The starting process is detailed here in Intel website
https://software.intel.com/en-us/get-started-ediso...

Step 7: Install Python Accessory

After Configuring driver, firmware and wifi we can start to update the repository where Yocto find some new libraries and software configurated for this distro Linux.

For our recognition system we need

  • Python
  • numpy
  • openCv

We follow the beginning of this guide https://communities.intel.com/docs/DOC-24179 (the CandyLocker project) so:

--------------------- NOTE ----------------------

from the software Intel Edison Board Configuration Board you get the ip of the board download Putty.exe to connect via SSH and look the image about putty

configure to connection type SSH, host root@IP_FINDED (ex. root@192.168.0.6 ) port 22

be sure to be in the same wifi with Edison board and your pc both

-------------------------------------------

SSH to your Intel® Edison and type the following command in the terminal:

# echo -e “src iot-devkit-i586 http://iotdk.intel.com/repos/1.1/iotdk/i586\nsrc mraa-upm http://iotdk.intel.com/repos/1.1/iotdk/i586\nsrc > /etc/opkg/intel-iotdk.conf

# opkg update

# opkg upgrade

Install Python Libraries

Next, it’s time to install Numpy and OpenCV
Numpy is a python library for working with data. To install it, type the following command in the terminal:

# opkg install python-numpy

The newest version of system actually has OpenCV installed, but only with C++. Here we need a Python binding to get it working. To do this, type the following command in the terminal:

# opkg install python-opencv

WARNING

while Edison is still downloading software seems that nothing happen, the cursor don't show some progress, so be sure of your wifi connection and be patient if you get some errors, check wifi connection with # ipconfig and # iwconfig to see the signal strenght (as we read here https://communities.intel.com/thread/59889 )

------------------------------------------

in windows to upload file on the board we use WinScp software it connect with SSH and seems a FTP software (look screenshot) we start to upload some python code to test the correct working (from example CandyLocker https://communities.intel.com/thread/59889 )

So connect a WebCam to the usb, and put the little switch on the Edison in the usb OTG mode

Reboot the entire system

----------------------------------------

WEBCAM PROBLEM if you encounter in a webcam problem look here

http://unix.stackexchange.com/questions/113893/how-do-i-find-out-which-process-is-using-my-v4l2-webcam

https://communities.intel.com/thread/59889

http://stackoverflow.com/questions/15177313/acces...

-----------------------------------------

Step 8: Software of Color Recognition - Logic

The system of color recognition is based on python image elaboration.

we do a photo with webcam to a bottle cup, then crop the photo to read only pixels on the center of the image, then pass the RGB value in several condition range, to detect color we want. Then move the mechanical part to put the bottle cup in the correct exit . The system also interact with Cloud IotKit by Intel to upload the statistics.

We start from CandyLocker software to test the python and the webcam

We use Sublime text 2 as text editor

with WinSCP upload the file in /home/root/CandyLock

via Putty SSH launch first python script

# python /home/root/CandyLock/TestCamera.py

the script produce a jpg image (attached in this step)

Step 9: Software of Color Recognition - Practice

algoritm, file attached in this step

  • wait some key pressed
  • take photo
  • crop a little photo in the center
  • calculate a square in the center of around 2000 pixels
  • get the RGB value
  • put in a range condition
  • detect color!

for determination of the color range i use a website http://www.rapidtables.com/web/color/red-color.htm

ang get the min and max of each R, G, B of this color nearby

Step 10: Software of Color Recognition - LCD

the Lcd isn't managed by mraa, so instead you have to use pyupm_i2clcd

import pyupm_i2clcd as lcd

# Initialize Jhd1313m1 at 0x3E (LCD_ADDRESS) and 0x62 (RGB_ADDRESS)
myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)

# Clear

myLcd.clear()

# Green

myLcd.setColor(255, 255, 0)

# Zero the cursor

myLcd.setCursor(0,0) # the first number is the line, 0 is the first line

# write

myLcd.write("Hola")

source!!! https://www.instructables.com/id/Show-the-Intel-Edi...

Step 11: Software of Color Recognition - STEPPER Motor

so the system move in the right position the bottle cups

we chose 5V stepper motor

http://www.arduiner.com/3002-home_default/5v-stepp...

to move the motor directly by Edison board we follow this tutorial

https://www.instructables.com/id/Intel-Edison-Setti...

but use python instead of js

https://raw.githubusercontent.com/intel-iot-devkit...

Step 12: Software of Color Recognition - IotKit Cloud

Intel team are developing a very nice Cloud system

if you follow the guidelines will be ok. we don't have any issue.

we follow istruction on the slides from Baldassarri on Intel Community Team

from page 178

http://www.developer-zone.it/extra/material/2016-0...

here the official tutorial

https://software.intel.com/en-us/intel-iot-platfor...

wiki of Api

https://github.com/enableiot/iotkit-api/wiki

https://github.com/enableiot/iotkit-agent/wiki

to send data from Edison to Cloud we use this in python

import subprocess

and then in the algoritm

output = subprocess.check_output (["/usr/bin/iotkit-admin", "observation", "webcam1", str(coloreNum)])

where:

output : is the string of response from the server Cloud

webcam1: is the name of the sensor, registered in Edison platform and in the iotkit platform

coloreNum: is a int variable, that has to bo be casted to string, to be send correctly

other important resource

https://github.com/enableiot/iotkit-samples
https://github.com/enableiot/iotkit-samples/blob/master/python/IoTkitSimpleExample.py https://github.com/enableiot/iotkit-samples/blob/master/api/python/iotkit_client.py https://medium.com/@shonsh/visualizing-sensor-data-using-intel-iot-analytics-d2d1de9ae118#.t8c1xxyt4 https://www.openshift.com/devpreview/register.html

Step 13: Common Issue

CLEAN AND OBTAIN EMPTY MEMORY SPACE

in someways Edison can finish memory and works very bad, so after your testing and programming phase do a first clean of the Yocto system memory. In this way: (screenshot)

# rm -rf /var/log/journal/*

# umount /etc/machine-id

# systemd-machine-id-setup

# rm -rf /var/log/journal/* # reboot

------------------------------------------

Step 14: Mounting for Maker Faire Rome 2016

the whole system mounted and running

*** we have to add the final video and some photos of final exposition ***