Trait nokhwa::FormatDecoder

source ·
pub trait FormatDecoder: Clone + Sized + Send + Sync {
    type Output: Pixel<Subpixel = u8>;

    const FORMATS: &'static [FrameFormat];

    // Required methods
    fn write_output(
        fcc: FrameFormat,
        resolution: Resolution,
        data: &[u8]
    ) -> Result<Vec<u8, Global>, NokhwaError>;
    fn write_output_buffer(
        fcc: FrameFormat,
        resolution: Resolution,
        data: &[u8],
        dest: &mut [u8]
    ) -> Result<(), NokhwaError>;
}
Expand description

Trait that has methods to convert raw data from the webcam to a proper raw image.

Required Associated Types§

source

type Output: Pixel<Subpixel = u8>

Required Associated Constants§

source

const FORMATS: &'static [FrameFormat]

Required Methods§

source

fn write_output( fcc: FrameFormat, resolution: Resolution, data: &[u8] ) -> Result<Vec<u8, Global>, NokhwaError>

Allocates and returns a Vec

Errors

If the data is malformed, or the source FrameFormat is incompatible, this will error.

source

fn write_output_buffer( fcc: FrameFormat, resolution: Resolution, data: &[u8], dest: &mut [u8] ) -> Result<(), NokhwaError>

Writes to a user provided buffer.

Errors

If the data is malformed, the source FrameFormat is incompatible, or the user-alloted buffer is not large enough, this will error.

Implementors§

source§

impl FormatDecoder for LumaAFormat

§

type Output = LumaA<u8>

source§

const FORMATS: &'static [FrameFormat] = frame_formats()

source§

impl FormatDecoder for LumaFormat

§

type Output = Luma<u8>

source§

const FORMATS: &'static [FrameFormat] = frame_formats()

source§

impl FormatDecoder for RgbAFormat

§

type Output = Rgba<u8>

source§

const FORMATS: &'static [FrameFormat] = color_frame_formats()

source§

impl FormatDecoder for RgbFormat

§

type Output = Rgb<u8>

source§

const FORMATS: &'static [FrameFormat] = color_frame_formats()