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.

Implementations

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

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

Gets the current Camera’s index.

Sets the current Camera’s index. Note that this re-initializes the camera.

Errors

The Backend may fail to initialize.

Gets the current Camera’s backend

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.

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

Gets the current CameraFormat.

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.

A hashmap of Resolutions 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).

A Vector of compatible FrameFormats.

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

Gets the current camera resolution (See: Resolution, CameraFormat).

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.

Gets the current camera framerate (See: CameraFormat).

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.

Gets the current camera’s frame format (See: FrameFormat, CameraFormat).

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 format, this will return an error.

Will open the camera stream with set parameters. This will be called internally if you try and call 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.

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

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.

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.

The minimum buffer size needed to write the current frame (RGB24). If rgba is true, it will instead return the minimum size of the RGBA buffer needed.

Directly writes the current frame(RGB24) into said buffer. If convert_rgba is true, the buffer written will be written as an RGBA frame instead of a RGB frame. Returns the amount of bytes written on successful capture.

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.

Directly copies a frame to a Wgpu texture. This will automatically convert the frame into a RGBA frame.

Errors

If the frame cannot be captured or the resolution is 0 on any axis, this will error.

Will drop the stream.

Errors

Please check the Quirks section of each backend.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.