V5 Optical Sensor Readings (Python)

In using the Optical sensor the website says it can do RGB, hue and saturation, and grayscale. How do I pull the grayscale and rgb values? Hue and saturation is easy due to the .hue() function in Python. But the other two there doesn’t seem to be much documentation.

.color() seems to mostly work only when comparing against given colors like Color.RED.

1 Like

Did you try the .brightness() function for a grayscale value? I’m not sure how you got the saturation.

The c++ API has a function .getRgb(bool bRawColor=true) that doesn’t seem to exist in the Python version.

>>> help(optical_1)
object Optical(0) is of type optical
  installed -- <function>
  index -- <function>
  timestamp -- <function>
  hue -- <function>
  brightness -- <function>
  color -- <function>
  is_near_object -- <function>
  set_light -- <function>
  set_light_power -- <function>
  object_detect_threshold -- <function>
  gesture_enable -- <function>
  gesture_disable -- <function>
  get_gesture -- <function>
  object_detected -- <function>
  object_lost -- <function>
  gesture_up -- <function>
  gesture_down -- <function>
  gesture_left -- <function>
  gesture_right -- <function>