REVLib - C++
rev::ColorMatch Class Reference

#include <ColorMatch.h>

Public Member Functions

 ColorMatch ()
 
void AddColorMatch (const frc::Color &color)
 
void SetConfidenceThreshold (double confidence)
 
std::optional< frc::Color > MatchColor (const frc::Color &colorToMatch)
 
std::optional< frc::Color > MatchColor (const frc::Color &colorToMatch, double &confidence)
 
frc::Color MatchClosestColor (const frc::Color &colorToMatch, double &confidence)
 

Detailed Description

REV Robotics Color Sensor V3.

This class allows access to a REV Robotics color sensor V3 on an I2C bus.

Constructor & Destructor Documentation

◆ ColorMatch()

ColorMatch::ColorMatch ( )

Member Function Documentation

◆ AddColorMatch()

void ColorMatch::AddColorMatch ( const frc::Color &  color)

Add color to match object

Parameters
colorcolor to add to matching

◆ SetConfidenceThreshold()

void ColorMatch::SetConfidenceThreshold ( double  confidence)

Set the confidence interval for determining color. Defaults to 0.95

Parameters
confidenceA value between 0 and 1

◆ MatchColor() [1/2]

std::optional< frc::Color > ColorMatch::MatchColor ( const frc::Color &  colorToMatch)

MatchColor uses euclidean distance to compare a given normalized RGB vector against stored values

Parameters
colorToMatchcolor to compare against stored colors
Returns
Matched color if detected

◆ MatchColor() [2/2]

std::optional< frc::Color > ColorMatch::MatchColor ( const frc::Color &  colorToMatch,
double &  confidence 
)

MatchColor uses euclidean distance to compare a given normalized RGB vector against stored values

Parameters
colorToMatchcolor to compare against stored colors
confidenceThe confidence value for this match, this is simply 1 - euclidean distance of the two color vectors
Returns
Matched color if detected

◆ MatchClosestColor()

frc::Color ColorMatch::MatchClosestColor ( const frc::Color &  colorToMatch,
double &  confidence 
)

MatchColor uses euclidean distance to compare a given normalized RGB vector against stored values

Parameters
colorToMatchcolor to compare against stored colors
confidenceThe confidence value for this match, this is simply 1 - euclidean distance of the two color vectors
Returns
Closest matching color

The documentation for this class was generated from the following files: