Struct VisionSignature

Source
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 VisionCodes, 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

Source

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,
);
Source

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

Source§

fn clone(&self) -> VisionSignature

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VisionSignature

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<V5_DeviceVisionSignature> for VisionSignature

Source§

fn from(value: V5_DeviceVisionSignature) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for VisionSignature

Source§

fn eq(&self, other: &VisionSignature) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for VisionSignature

Source§

impl StructuralPartialEq for VisionSignature

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.