ColorProfile

data class ColorProfile(val space: ColorSpace, val color: NextColor, val tolerance: NextColor)

Describes a target color and the per-channel tolerances used to decide whether a sensor reading is a match.

Use NextColorDistanceSensor.debug in telemetry to read live HSV values and calibrate color and tolerance. ColorSpace.HSV is recommended for most cases as it is more stable under changing lighting conditions.

Example:

val green = ColorProfile(
space = ColorSpace.HSV,
color = NextColor.HSV(130f, 0.7f, 0.6f),
tolerance = NextColor.HSV(20f, 0.3f, 1f),
)

override fun periodic() {
sensor.update()
if (sensor.isColor(green)) { ... }
}

Author

28shettr

Constructors

Link copied to clipboard
constructor(space: ColorSpace, color: NextColor, tolerance: NextColor)

Properties

Link copied to clipboard

The target color to match against.

Link copied to clipboard

The color space to compare in.

Link copied to clipboard

How far each channel can deviate from color and still count as a match.

Functions

Link copied to clipboard
fun matches(reading: NextColor): Boolean

Returns true if reading falls within tolerance of color in space.