It's been a little while since my last update. My attention was drawn by a project at work but now that it's launched I can focus on the High Speed Candy Sorting Machine.
First things first, the High Speed Candy Sorting Machine was selected for the Hackaday Prize 2016 final round!!! This is amazing! Thanks for the support, this will give me the extra motivation to finish this project on time.
To implement color detection, I compare all the pixels from the camera snapshot with a set of reference colors. Each of the reference colors matches the color of a candy. For each pixel I need to compute a distance between the reference color and the color of that pixel. The classic RGB format is very bad for computing distance between two colors, so I translate the RGB values to the LAB color space. It is then trivial to get the distance between two LAB values. Using this distance value, I can tell to which reference color the current pixel is the closest.
To speed up the process, I pre-calculate every RGB565 to LAB inside conversion table during initialization. With this table, converting from RGB to LAB is blazing fast.
For the moment I use the QQVGA2 resolution (128, 160). It's not a lot of pixels,but it's maybe already too much. I don't need a fine resolution to detect colors of candies that will be very close to the lens and having less pixels means faster image processing.
Laser cut frameLast week-end, I ordered laser cut acrylic parts from a German website, formulor.de.
I didn't know this website, but it looks like it's the only online laser cutting service in Europe.
You can find the designs (3D and SVG) in the project repository: here