pub struct AVFoundationCaptureDevice {}
Available on crate feature input-avfoundation only.
Expand description

The backend struct that interfaces with V4L2. To see what this does, please see CaptureBackendTrait.

Quirks

  • While working with iOS is allowed, it is not officially supported and may not work.
  • You must call nokhwa_initialize before doing anything with AVFoundation.
  • This only works on 64 bit platforms.
  • FPS adjustment does not work.
  • If permission has not been granted and you call init() it will error.

Implementations§

source§

impl AVFoundationCaptureDevice

source

pub fn new( index: &CameraIndex, req_fmt: RequestedFormat<'_> ) -> Result<Self, NokhwaError>

Creates a new capture device using the AVFoundation backend. Indexes are gives to devices by the OS, and usually numbered by order of discovery.

If camera_format is None, it will be spawned with with 640x480@15 FPS, MJPEG CameraFormat default.

Errors

This function will error if the camera is currently busy or if AVFoundation can’t read device information, or permission was not given by the user.

source

pub fn new_with( index: usize, width: u32, height: u32, fps: u32, fourcc: FrameFormat ) -> Result<Self, NokhwaError>

👎Deprecated since 0.10.0: please use new instead.

Creates a new capture device using the AVFoundation backend with desired settings.

Errors

This function will error if the camera is currently busy or if AVFoundation can’t read device information, or permission was not given by the user.

Trait Implementations§

source§

impl CaptureBackendTrait for AVFoundationCaptureDevice

source§

fn backend(&self) -> ApiBackend

Returns the current backend used.
source§

fn camera_info(&self) -> &CameraInfo

Gets the camera information such as Name and Index as a CameraInfo.
source§

fn refresh_camera_format(&mut self) -> Result<(), NokhwaError>

Forcefully refreshes the stored camera format, bringing it into sync with “reality” (current camera state) Read more
source§

fn camera_format(&self) -> CameraFormat

Gets the current CameraFormat. This will force refresh to the current latest if it has changed.
source§

fn set_camera_format(&mut self, _: CameraFormat) -> Result<(), NokhwaError>

Will set the current CameraFormat This will reset the current stream if used while stream is opened. Read more
source§

fn compatible_list_by_resolution( &mut self, _: FrameFormat ) -> Result<HashMap<Resolution, Vec<u32>>, NokhwaError>

A hashmap of Resolutions mapped to framerates. Not sorted! Read more
source§

fn compatible_fourcc(&mut self) -> Result<Vec<FrameFormat>, NokhwaError>

A Vector of compatible FrameFormats. Will only return 2 elements at most. Read more
source§

fn resolution(&self) -> Resolution

Gets the current camera resolution (See: Resolution, CameraFormat). This will force refresh to the current latest if it has changed.
source§

fn set_resolution(&mut self, _: Resolution) -> Result<(), NokhwaError>

Will set the current Resolution This will reset the current stream if used while stream is opened. Read more
source§

fn frame_rate(&self) -> u32

Gets the current camera framerate (See: CameraFormat). This will force refresh to the current latest if it has changed.
source§

fn set_frame_rate(&mut self, _: u32) -> Result<(), NokhwaError>

Will set the current framerate This will reset the current stream if used while stream is opened. Read more
source§

fn frame_format(&self) -> FrameFormat

Gets the current camera’s frame format (See: FrameFormat, CameraFormat). This will force refresh to the current latest if it has changed.
source§

fn set_frame_format(&mut self, _: FrameFormat) -> Result<(), NokhwaError>

Will set the current FrameFormat This will reset the current stream if used while stream is opened. Read more
source§

fn camera_control( &self, _: KnownCameraControl ) -> Result<CameraControl, NokhwaError>

Gets the value of KnownCameraControl. Read more
source§

fn camera_controls(&self) -> Result<Vec<CameraControl>, NokhwaError>

Gets the current supported list of KnownCameraControl Read more
source§

fn set_camera_control( &mut self, _: KnownCameraControl, _: ControlValueSetter ) -> Result<(), NokhwaError>

Sets the control to control in the camera. Usually, the pipeline is calling camera_control(), getting a camera control that way then calling value() to get a ControlValueSetter and setting the value that way. Read more
source§

fn open_stream(&mut self) -> Result<(), NokhwaError>

Will open the camera stream with set parameters. This will be called internally if you try and call frame() before you call open_stream(). Read more
source§

fn is_stream_open(&self) -> bool

Checks if stream if open. If it is, it will return true.
source§

fn frame(&mut self) -> Result<Buffer, NokhwaError>

Will get a frame from the camera as a Buffer. Depending on the backend, if you have not called open_stream() before you called this, it will either return an error. Read more
source§

fn frame_raw(&mut self) -> Result<Cow<'_, [u8]>, NokhwaError>

Will get a frame from the camera without any processing applied, meaning you will usually get a frame you need to decode yourself. Read more
source§

fn stop_stream(&mut self) -> Result<(), NokhwaError>

Will drop the stream. Read more
source§

fn compatible_camera_formats( &mut self ) -> Result<Vec<CameraFormat, Global>, NokhwaError>

Gets the compatible CameraFormat of the camera Read more
source§

fn decoded_buffer_size(&self, alpha: bool) -> usize

The minimum buffer size needed to write the current frame. If alpha is true, it will instead return the minimum size of the buffer with an alpha channel as well. This assumes that you are decoding to RGB/RGBA for FrameFormat::MJPEG or FrameFormat::YUYV and Luma8/LumaA8 for FrameFormat::GRAY
source§

fn frame_texture<'a>( &mut self, device: &Device, queue: &Queue, label: Option<&'a str> ) -> Result<Texture, NokhwaError>

Available on crate feature wgpu-types only.
Directly copies a frame to a Wgpu texture. This will automatically convert the frame into a RGBA frame. Read more
source§

impl Drop for AVFoundationCaptureDevice

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>