Hello guys,
I want to use the RGB to HSV function (probably “CHSV rgb2hsv_approximate( const CRGB& rgb);” in the file hsv2rgb.h). in order to convert the raw data from a rgb sensor (16bit integer x3 for r, g and b).
But I dont understand how I can use the function. What should I write?
Not sure if I understand your question well…
I have used Adafruit’s TCS34725 color sensor and it also provides 16 bit data per color. For my use, I did not need to reproduce the color sensed however if you need to do it, I would suggest that you scale down the value from the sensor to an 8 bit value and use that data as RGB and not convert to HSV unless necessary. As explicitly stated in the function, conversions from RGB to HSV are just an approximation.
I am building a color sorting machine, so I want to gather red things in one box, green in another and so on… working with 3 raw integer as they come from the sensor is not easy for categorizing the colors, especially for the pastel (desaturated) tones. So I thought that working with hue and saturation should be easier to make categories.
Anyway, I have no choice but to embrace a solution that allows me to extract the hue and the saturation for every colors scanned in order to compare them, and decide in which box I will put the related object…
To use the function first you need to convert the 16 bit values into 8-bit values that you can use to fill in a CRGB object, which you can then pass into the function rgb2hsv_approximate to get a CHSV object back, from which you can get the hue and saturation out: