Package com.revrobotics
Class ColorMatch
- java.lang.Object
-
- com.revrobotics.ColorMatch
-
public class ColorMatch extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ColorMatch()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColorMatch(edu.wpi.first.wpilibj.util.Color color)
Add color to match objectstatic edu.wpi.first.wpilibj.util.Color
makeColor(double r, double g, double b)
Create an frc.Color object from r g b.ColorMatchResult
matchClosestColor(edu.wpi.first.wpilibj.util.Color color)
MatchColor uses euclidean distance to compare a given normalized RGB vector against stored valuesColorMatchResult
matchColor(edu.wpi.first.wpilibj.util.Color colorToMatch)
MatchColor uses euclidean distance to compare a given normalized RGB vector against stored valuesvoid
setConfidenceThreshold(double confidence)
Set the confidence interval for determining color.
-
-
-
Method Detail
-
addColorMatch
public void addColorMatch(edu.wpi.first.wpilibj.util.Color color)
Add color to match object- Parameters:
color
- color to add to matching
-
setConfidenceThreshold
public void setConfidenceThreshold(double confidence)
Set the confidence interval for determining color. Defaults to 0.95- Parameters:
confidence
- A value between 0 and 1
-
matchColor
public ColorMatchResult matchColor(edu.wpi.first.wpilibj.util.Color colorToMatch)
MatchColor uses euclidean distance to compare a given normalized RGB vector against stored values- Parameters:
colorToMatch
- color to compare against stored colors- Returns:
- Matched color if detected, returns null if no color detected confidence level
-
makeColor
public static edu.wpi.first.wpilibj.util.Color makeColor(double r, double g, double b)
Create an frc.Color object from r g b. This is necessary for WPILib versions older than 2020.2.2 and will be deprecated in 2021.- Parameters:
r
- Red valueg
- Green valueb
- Blue value- Returns:
- frc.Color object
-
matchClosestColor
public ColorMatchResult matchClosestColor(edu.wpi.first.wpilibj.util.Color color)
MatchColor uses euclidean distance to compare a given normalized RGB vector against stored values- Parameters:
color
- color to compare against stored colors- Returns:
- Closest color to match
-
-