pub struct CameraFrame {
pub width: u32,
pub height: u32,
pub format: FrameFormat,
pub rotation_degrees: u16,
pub sequence: u64,
pub bytes: Vec<u8>,
}Expand description
Re-export framework services (HTTP, URI, etc.) from the dedicated services crate. One frame from the viewfinder.
Fields§
§width: u32§height: u32§format: FrameFormat§rotation_degrees: u16How far the frame must be rotated clockwise to be the right way up, which is the sensor’s mounting plus the device’s rotation.
sequence: u64Which frame this is in the session, so a consumer can tell a repeat from a new one and count what it missed.
bytes: Vec<u8>The pixels, in format.
Implementations§
Source§impl CameraFrame
impl CameraFrame
Sourcepub fn new(
width: u32,
height: u32,
format: FrameFormat,
rotation_degrees: u16,
sequence: u64,
bytes: Vec<u8>,
) -> Option<CameraFrame>
pub fn new( width: u32, height: u32, format: FrameFormat, rotation_degrees: u16, sequence: u64, bytes: Vec<u8>, ) -> Option<CameraFrame>
A frame, or None when the bytes do not match the size and format —
which is a backend bug, and one that reads as corrupted video rather
than as an error if it is let through.
Sourcepub fn to_rgba8(&self) -> Vec<u8> ⓘ
pub fn to_rgba8(&self) -> Vec<u8> ⓘ
The frame as tightly packed RGBA8, converting only when it has to.
One pass over the bytes with no allocation beyond the result, because this runs per frame: a conversion that allocates per row shows up as dropped frames rather than as a slow function.
Sourcepub fn upright_rgba8(&self) -> UprightRgba
pub fn upright_rgba8(&self) -> UprightRgba
The frame as tightly packed RGBA8 with
rotation_degrees applied, so the pixels are
the right way up whatever the sensor’s mounting was.
The turn happens in the same pass as the format conversion, because this runs on every previewed frame: converting and then turning would walk the pixels twice. A rotation that is not a quarter turn is left alone — no camera produces one.
Trait Implementations§
Source§impl Clone for CameraFrame
impl Clone for CameraFrame
Source§fn clone(&self) -> CameraFrame
fn clone(&self) -> CameraFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CameraFrame
impl Debug for CameraFrame
impl Eq for CameraFrame
Source§impl PartialEq for CameraFrame
impl PartialEq for CameraFrame
impl StructuralPartialEq for CameraFrame
Auto Trait Implementations§
impl Freeze for CameraFrame
impl RefUnwindSafe for CameraFrame
impl Send for CameraFrame
impl Sync for CameraFrame
impl Unpin for CameraFrame
impl UnsafeUnpin for CameraFrame
impl UnwindSafe for CameraFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.