pub struct VisionSignature {
pub u_threshold: (i32, i32, i32),
pub v_threshold: (i32, i32, i32),
pub range: f32,
pub flags: u8,
}
Expand description
A vision detection color signature.
Vision signatures contain information used by the vision sensor to detect objects of a certain
color. These signatures are typically generated through VEX’s vision utility tool rather than
written by hand. For creating signatures using the utility, see from_utility
.
§Format & Detection Overview
Vision signatures operate in a version of the Y’UV color space, specifically using the “U” and “V”
chroma components for edge detection purposes. This can be seen in the u_threshold
and
v_threshold
fields of this struct. These fields place three “threshold” (min, max, mean)
values on the u and v chroma values detected by the sensor. The values are then transformed to a
3D lookup table to detect actual colors.
There is additionally a range
field, which works as a scale factor or threshold for how lenient
edge detection should be.
Signatures can additionally be grouped together into VisionCode
s, which narrow the filter for
object detection by requiring two colors.
Fields§
§u_threshold: (i32, i32, i32)
The (min, max, mean) values on the “U” axis.
This defines a threshold of values for the sensor to match against a certain chroma in the Y’UV color space - specifically on the U component.
v_threshold: (i32, i32, i32)
The (min, max, mean) values on the V axis.
This defines a threshold of values for the sensor to match against a certain chroma in the Y’UV color space - specifically on the “V” component.
range: f32
The signature range scale factor.
This value effectively serves as a threshold for how lenient the sensor should be when detecting the edges of colors. This value ranges from 0-11 in Vision Utility.
Higher values of range
will increase the range of brightness that the sensor will
consider to be part of the signature. Lighter/Darker shades of the signature’s color
will be detected more often.
flags: u8
The signature’s flags.
Implementations§
Source§impl VisionSignature
impl VisionSignature
Sourcepub const fn new(
u_threshold: (i32, i32, i32),
v_threshold: (i32, i32, i32),
range: f32,
) -> Self
pub const fn new( u_threshold: (i32, i32, i32), v_threshold: (i32, i32, i32), range: f32, ) -> Self
Create a VisionSignature
.
§Examples
use vexide::devices::smart::vision::VisionSignature;
let my_signature = VisionSignature::new(
(10049, 11513, 10781),
(-425, 1, -212),
4.1,
);
Sourcepub const fn from_utility(
_id: u8,
u_min: i32,
u_max: i32,
u_mean: i32,
v_min: i32,
v_max: i32,
v_mean: i32,
range: f32,
_signature_type: u32,
) -> Self
pub const fn from_utility( _id: u8, u_min: i32, u_max: i32, u_mean: i32, v_min: i32, v_max: i32, v_mean: i32, range: f32, _signature_type: u32, ) -> Self
Create a VisionSignature
using the same format as VEX’s Vision Utility tool.
§Examples
use vexide::devices::smart::vision::VisionSignature;
// Register a signature for detecting red objects.
// This numbers in this signature was generated using VEX's vision utility app.
let my_signature =
VisionSignature::from_utility(1, 10049, 11513, 10781, -425, 1, -212, 4.1, 0);
Trait Implementations§
Source§impl Clone for VisionSignature
impl Clone for VisionSignature
Source§fn clone(&self) -> VisionSignature
fn clone(&self) -> VisionSignature
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more