Struct nokhwa::Camera [−][src]
pub struct Camera { /* fields omitted */ }
Expand description
The main Camera
struct. This is the struct that abstracts over all the backends, providing a simplified interface for use.
For more details, please refer to CaptureBackendTrait
Implementations
impl Camera
[src]
impl Camera
[src]pub fn new(
index: usize,
format: Option<CameraFormat>,
backend: CaptureAPIBackend
) -> Result<Self, NokhwaError>
[src]
pub fn new(
index: usize,
format: Option<CameraFormat>,
backend: CaptureAPIBackend
) -> Result<Self, NokhwaError>
[src]Create a new camera from an index
, format
, and backend
. format
can be None
.
Errors
This will error if you either have a bad platform configuration (e.g. input_v4l
but not on linux) or the backend cannot create the camera (e.g. permission denied).
pub fn new_with(
index: usize,
width: u32,
height: u32,
fps: u32,
fourcc: FrameFormat,
backend: CaptureAPIBackend
) -> Result<Self, NokhwaError>
[src]
pub fn new_with(
index: usize,
width: u32,
height: u32,
fps: u32,
fourcc: FrameFormat,
backend: CaptureAPIBackend
) -> Result<Self, NokhwaError>
[src]Create a new Camera
from raw values.
Errors
This will error if you either have a bad platform configuration (e.g. input_v4l
but not on linux) or the backend cannot create the camera (e.g. permission denied).
pub fn set_index(self, new_idx: usize) -> Result<Self, NokhwaError>
[src]
pub fn set_index(self, new_idx: usize) -> Result<Self, NokhwaError>
[src]Sets the current Camera’s index. Note that this re-initializes the camera.
Errors
The Backend may fail to initialize.
pub fn backend(&self) -> CaptureAPIBackend
[src]
pub fn backend(&self) -> CaptureAPIBackend
[src]Gets the current Camera’s backend
pub fn set_backend(
self,
new_backend: CaptureAPIBackend
) -> Result<Self, NokhwaError>
[src]
pub fn set_backend(
self,
new_backend: CaptureAPIBackend
) -> Result<Self, NokhwaError>
[src]Sets the current Camera’s backend. Note that this re-initializes the camera.
Errors
The new backend may not exist or may fail to initialize the new camera.
pub fn get_info(&self) -> CameraInfo
[src]
pub fn get_info(&self) -> CameraInfo
[src]Gets the camera information such as Name and Index as a CameraInfo
.
pub fn get_camera_format(&self) -> CameraFormat
[src]
pub fn get_camera_format(&self) -> CameraFormat
[src]Gets the current CameraFormat
.
pub fn set_camera_format(
&mut self,
new_fmt: CameraFormat
) -> Result<(), NokhwaError>
[src]
pub fn set_camera_format(
&mut self,
new_fmt: CameraFormat
) -> Result<(), NokhwaError>
[src]Will set the current CameraFormat
This will reset the current stream if used while stream is opened.
Errors
If you started the stream and the camera rejects the new camera format, this will return an error.
pub fn get_compatible_list_by_resolution(
&self,
fourcc: FrameFormat
) -> Result<HashMap<Resolution, Vec<u32>>, NokhwaError>
[src]
pub fn get_compatible_list_by_resolution(
&self,
fourcc: FrameFormat
) -> Result<HashMap<Resolution, Vec<u32>>, NokhwaError>
[src]A hashmap of Resolution
s mapped to framerates
Errors
This will error if the camera is not queryable or a query operation has failed. Some backends will error this out as a Unsupported Operation (NokhwaError::UnsupportedOperation
).
pub fn get_compatible_fourcc(&mut self) -> Result<Vec<FrameFormat>, NokhwaError>
[src]
pub fn get_compatible_fourcc(&mut self) -> Result<Vec<FrameFormat>, NokhwaError>
[src]A Vector of compatible FrameFormat
s.
Errors
This will error if the camera is not queryable or a query operation has failed. Some backends will error this out as a Unsupported Operation (NokhwaError::UnsupportedOperation
).
pub fn get_resolution(&self) -> Resolution
[src]
pub fn get_resolution(&self) -> Resolution
[src]Gets the current camera resolution (See: Resolution
, CameraFormat
).
pub fn set_resolution(&mut self, new_res: Resolution) -> Result<(), NokhwaError>
[src]
pub fn set_resolution(&mut self, new_res: Resolution) -> Result<(), NokhwaError>
[src]Will set the current Resolution
This will reset the current stream if used while stream is opened.
Errors
If you started the stream and the camera rejects the new resolution, this will return an error.
pub fn get_framerate(&self) -> u32
[src]
pub fn get_framerate(&self) -> u32
[src]Gets the current camera framerate (See: CameraFormat
).
pub fn set_framerate(&mut self, new_fps: u32) -> Result<(), NokhwaError>
[src]
pub fn set_framerate(&mut self, new_fps: u32) -> Result<(), NokhwaError>
[src]Will set the current framerate This will reset the current stream if used while stream is opened.
Errors
If you started the stream and the camera rejects the new framerate, this will return an error.
pub fn get_frameformat(&self) -> FrameFormat
[src]
pub fn get_frameformat(&self) -> FrameFormat
[src]Gets the current camera’s frame format (See: FrameFormat
, CameraFormat
).
pub fn set_frameformat(
&mut self,
fourcc: FrameFormat
) -> Result<(), NokhwaError>
[src]
pub fn set_frameformat(
&mut self,
fourcc: FrameFormat
) -> Result<(), NokhwaError>
[src]Will set the current FrameFormat
This will reset the current stream if used while stream is opened.
Errors
If you started the stream and the camera rejects the new frame foramt, this will return an error.
pub fn open_stream(&mut self) -> Result<(), NokhwaError>
[src]
pub fn open_stream(&mut self) -> Result<(), NokhwaError>
[src]Will open the camera stream with set parameters. This will be called internally if you try and call get_frame()
before you call open_stream()
.
Errors
If the specific backend fails to open the camera (e.g. already taken, busy, doesn’t exist anymore) this will error.
pub fn is_stream_open(&self) -> bool
[src]
pub fn is_stream_open(&self) -> bool
[src]Checks if stream if open. If it is, it will return true.
pub fn get_frame(&self) -> Result<ImageBuffer<Rgb<u8>, Vec<u8>>, NokhwaError>
[src]
pub fn get_frame(&self) -> Result<ImageBuffer<Rgb<u8>, Vec<u8>>, NokhwaError>
[src]Will get a frame from the camera as a Raw RGB image buffer. Depending on the backend, if you have not called open_stream()
before you called this,
it will either return an error.
Errors
If the backend fails to get the frame (e.g. already taken, busy, doesn’t exist anymore), the decoding fails (e.g. MJPEG -> u8), or open_stream()
has not been called yet,
this will error.
pub fn get_frame_raw(&self) -> Result<Vec<u8>, NokhwaError>
[src]
pub fn get_frame_raw(&self) -> Result<Vec<u8>, NokhwaError>
[src]Will get a frame from the camera without any processing applied, meaning you will usually get a frame you need to decode yourself.
Errors
If the backend fails to get the frame (e.g. already taken, busy, doesn’t exist anymore), or open_stream()
has not been called yet, this will error.
pub fn stop_stream(&self) -> Result<(), NokhwaError>
[src]
pub fn stop_stream(&self) -> Result<(), NokhwaError>
[src]Auto Trait Implementations
impl !RefUnwindSafe for Camera
impl !Send for Camera
impl !Sync for Camera
impl Unpin for Camera
impl !UnwindSafe for Camera
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T