CameraManager

Struct CameraManager 

Source
pub struct CameraManager { /* private fields */ }
Expand description

Camera manager used to enumerate available cameras in the system.

Implementations§

Source§

impl CameraManager

Source

pub fn new() -> Result<Self>

Initializes libcamera, starts the manager and creates Self.

Source

pub fn new_unstarted() -> Result<Self>

Create a CameraManager without starting it.

Call Self::start before using it to enumerate cameras.

Source

pub fn start(&mut self) -> Result<()>

Start the camera manager if it is not already running.

Source

pub fn stop(&mut self) -> Result<()>

Stop the camera manager. Safe to call multiple times.

Source

pub fn try_stop(&mut self) -> Result<()>

Attempt to stop only if no tracked cameras are still alive.

Source

pub fn restart(&mut self) -> Result<()>

Restart the manager by stopping (if safe) and starting again.

Source

pub fn is_started(&self) -> bool

Returns true if the manager has been started.

Source

pub fn version(&self) -> &str

Returns version string of the linked libcamera.

Source

pub fn cameras<'a>(&self) -> CameraList<'a>

Enumerates cameras within the system.

Source

pub fn get<'a>(&self, id: &str) -> Option<Camera<'a>>

Returns a camera by id if present.

Source

pub fn log_set_level(&self, category: &str, level: LoggingLevel)

Set the log level.

§Parameters
  • category - Free-form category string, a list of those can be seen by running grep 'LOG_DEFINE_CATEGORY(' -R on the libcamera source code
  • level - Maximum log importance level to show, anything more less important than that will be hidden.
Source

pub fn on_camera_added( &mut self, cb: impl FnMut(Camera<'static>) + Send + 'static, )

Register a callback for camera-added events.

§Warning

The callback is invoked on libcamera’s internal thread. Do not block in the callback; send work to another thread/channel if needed.

Source

pub fn on_camera_removed( &mut self, cb: impl FnMut(Camera<'static>) + Send + 'static, )

Register a callback for camera-removed events.

§Warning

The callback is invoked on libcamera’s internal thread. Do not block in the callback; send work to another thread/channel if needed.

Source

pub fn subscribe_hotplug_events(&mut self) -> Receiver<HotplugEvent>

Subscribe to hotplug events via a channel.

The returned Receiver yields HotplugEvent values. Internally this hooks into the libcamera hotplug signals and forwards them; it uses the same callbacks as on_camera_added/removed, so do not mix different senders without care.

Trait Implementations§

Source§

impl Drop for CameraManager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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

Source§

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.