Class ColorFrame

java.lang.Object
com.reduxrobotics.frames.Frame<ColorData>
com.reduxrobotics.sensors.canandcolor.ColorFrame

public class ColorFrame extends Frame<ColorData>
Implements an object-holding Frame with considerations for color data. This avoids creation of new objects by only converting to a ColorData when such an object is requested, while also offering interfaces to efficiently retrieve components and HSV calculations without allocation.
  • Constructor Details

    • ColorFrame

      public ColorFrame(double timestamp, ColorData defaultData)
      Instantiates a new ColorFrame
      Parameters:
      timestamp - initial timestamp
      defaultData - data to be returned when the frame value is not valid
  • Method Details

    • getValue

      public ColorData getValue()
      Description copied from class: Frame
      Returns the value of the data frame.
      Specified by:
      getValue in class Frame<ColorData>
      Returns:
      the value the data frame holds.
    • getRed

      public double getRed()
      Retreives the frame's stored red value [0..1] inclusive.
      Returns:
      red intensity
    • getGreen

      public double getGreen()
      Retreives the frame's stored green value [0..1] inclusive.
      Returns:
      green intensity
    • getBlue

      public double getBlue()
      Retreives the frame's stored blue value [0..1] inclusive.
      Returns:
      blue intensity
    • getHSVHue

      public double getHSVHue()
      Computes the frame's HSV hue value [0..1] inclusive from the stored RGB data. This function does not allocate objects!
      Returns:
      hue
    • getHSVSaturation

      public double getHSVSaturation()
      Computes the frame's HSV saturation value [0..1] inclusive from the stored RGB data. This function does not allocate objects!
      Returns:
      saturation
    • getHSVValue

      public double getHSVValue()
      Computes the frame's HSV value [0..1] inclusive from the stored RGB data. This function does not allocate objects!
      Returns:
      value
    • getColorPeriod

      public ColorPeriod getColorPeriod()
      Retrieves the frame's stored color period.
      Returns:
      color period
    • hasData

      public boolean hasData()
      Description copied from class: Frame
      Returns if this frame has data.
      Specified by:
      hasData in class Frame<ColorData>
      Returns:
      if this frame's data can be considered valid
    • clearData

      public void clearData()
      Flag that this frame's data is not valid.
    • updateData

      public void updateData(long data, double timestamp)
      Update the Frame with new data.
      Parameters:
      data - the new data to update with
      timestamp - the timestamp at which it occured