When I built and coded this device, I was originally inspired by the Microsoft IoT Lesson "What Color Is It", (Lesson 205). I saw a lot of great potential for what that project had and decided to take the opportunity to expand it.
Originally the project just found the closest color in the Windows UI library that matched closest to the color the TCS34725 RGB Sensor matched. I wanted to take this a step further and came up with the idea of using the sensor chip to get the RGB values and then some how turn that information into various color space information. Through research I found a free API (TheColorAPI.com) that returned information about colors if you pass it RGB values and decided to leverage its information with the power of the chip behind it.
How Does It Work:
The TCS34725 chip is able to detect the RGB values of various items held up to it. Holding up and object and pressing the button will trigger the chip to collect this data and pass it back to the Raspberry Pi. From there the code will make a call to The Color API and retrieve color space details about that color including CMYK (Cyan, Magenta, Yellow, Key), HSL (Hue, Saturation, Lightness), HSV (Hue, Saturation, Value) and XYZ (CIE 1931) as well the hexadecimal value for the color (or closest color) for web. This color data is read by a C# Json Serializer (ColorfulJsonParser) and then transformed into a color object (ColorfulRestProperty). Finally, the device will audibly tell the name of the color and present the data on its UI. The UI includes a drop down for the history (colors you've viewed that session), a large color preview panel, user inputs for RGB values to call the API manually (without using the TCS34725 chip), and a break down of the color space information.
The code is available to be reviewed and downloaded courtesy of GitHub. Here you will find the code to read the data from the chip as the code that calls The Color API and parses the output into a color object.
For those folks interested in just interfacing with The Color API, you can find a library I've created by extracting the code from the ColorDetector into a standalone DLL. The code for which can be found here:
This project is far from over as there is still so much potential to be harnessed. Shortly after finishing the basics of this project, I decided to extract methods and classes that interface with The Color API and create a Windows Universal App Library (.dll) with it. This library, ColorApiLib is also available on GitHub (as featured above under "The Code"). In a future update, I plan to remove the Colorful classes from the ColorDetector's code and replace it with this library for better code management.
The Color API also features the ability to create schemes of complementing and contrasting colors when getting data on a color. I plan to incorporate this into the app, giving the user the ability to view these various schemes.
Also, a not too distant future update will give the user the ability to email the color data to themselves they can hold onto the color for use later without having to open the app each time.
Stay tuned for more to come!