VOXL OpenVINS Server 1.0
Visual Inertial Odometry Server for VOXL Platform
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
voxl::CameraManager Class Reference

Manages all camera instances in the system. More...

#include <CameraManager.h>

Public Member Functions

bool initialize (const std::vector< cam_info > &camera_configs)
 Initialize the camera manager with camera configurations.
 
void shutdown ()
 Shut down all cameras and clean up resources.
 
std::shared_ptr< CameraBasegetCamera (size_t camera_id)
 Get a camera by its ID.
 
std::vector< std::shared_ptr< CameraBase > > getAllCameras ()
 Get all cameras.
 
size_t getCameraCount () const
 Get the number of cameras.
 
bool isInitialized () const
 Check if the camera manager is initialized.
 

Static Public Member Functions

static CameraManagergetInstance ()
 Get the singleton instance of the CameraManager.
 

Detailed Description

Manages all camera instances in the system.

This class is responsible for creating, initializing, and managing all camera instances. It provides a centralized point for camera configuration and access using the singleton pattern.

The CameraManager provides:

Key features:

Definition at line 60 of file CameraManager.h.

Member Function Documentation

◆ getAllCameras()

std::vector< std::shared_ptr< CameraBase > > voxl::CameraManager::getAllCameras ( )

Get all cameras.

Returns a vector containing all managed camera instances.

Returns
Vector of camera shared pointers

Returns a vector containing all managed camera instances. The method is thread-safe and returns a copy of the camera collection to prevent external modification.

Returns
Vector of camera shared pointers

Definition at line 248 of file CameraManager.cpp.

◆ getCamera()

std::shared_ptr< CameraBase > voxl::CameraManager::getCamera ( size_t  camera_id)

Get a camera by its ID.

Retrieves a specific camera instance by its unique identifier.

Parameters
camera_idThe ID of the camera to retrieve
Returns
Shared pointer to the camera, or nullptr if not found

◆ getCameraCount()

size_t voxl::CameraManager::getCameraCount ( ) const

Get the number of cameras.

Returns the total number of cameras currently managed by the system.

Returns
Number of cameras managed

Returns the total number of cameras currently managed by the system. The method is thread-safe and provides a consistent count.

Returns
Number of cameras managed

Definition at line 267 of file CameraManager.cpp.

◆ getInstance()

CameraManager & voxl::CameraManager::getInstance ( )
static

Get the singleton instance of the CameraManager.

Returns the single instance of the CameraManager, creating it if it doesn't exist (lazy initialization).

Returns
Reference to the CameraManager instance

Returns the single instance of the CameraManager, creating it if it doesn't exist (lazy initialization). This ensures that only one camera manager exists throughout the application lifecycle.

Returns
Reference to the CameraManager instance

Definition at line 35 of file CameraManager.cpp.

◆ initialize()

bool voxl::CameraManager::initialize ( const std::vector< cam_info > &  camera_configs)

Initialize the camera manager with camera configurations.

Sets up the camera manager with the provided camera configurations. This method creates and initializes all cameras based on their configuration information.

Parameters
camera_configsVector of camera configurations
Returns
True if successful, false otherwise

Sets up the camera manager with the provided camera configurations. This method creates and initializes all cameras based on their configuration information.

The initialization process includes:

  • Validating that the manager is not already initialized
  • Checking that camera configurations are provided
  • Filtering cameras by supported modes (currently only MONO)
  • Creating and connecting each camera
  • Starting the camera fusion system
  • Setting the initialized flag

If any camera fails to initialize, the method performs a clean shutdown and returns false.

Parameters
camera_configsVector of camera configurations
Returns
true if successful, false otherwise

Definition at line 112 of file CameraManager.cpp.

References CameraQueueFusion::getInstance(), cam_info::mode, MONO, cam_info::name, shutdown(), CameraQueueFusion::start(), STEREO, and vio_error_codes.

Here is the call graph for this function:

◆ isInitialized()

bool voxl::CameraManager::isInitialized ( ) const

Check if the camera manager is initialized.

Determines whether the camera manager has been successfully initialized with camera configurations.

Returns
True if initialized, false otherwise

Determines whether the camera manager has been successfully initialized with camera configurations. The method is thread-safe and provides a consistent state check.

Returns
true if initialized, false otherwise

Definition at line 282 of file CameraManager.cpp.

◆ shutdown()

void voxl::CameraManager::shutdown ( )

Shut down all cameras and clean up resources.

Performs a clean shutdown of all camera instances, disconnecting them from their data sources and freeing allocated resources.

Performs a clean shutdown of all camera instances, disconnecting them from their data sources and freeing allocated resources.

The shutdown process includes:

  • Checking if the manager is already shut down
  • Disconnecting each camera in a separate thread to avoid blocking
  • Waiting for disconnect operations to complete with timeout
  • Clearing the camera collection
  • Resetting the initialized flag

The method uses detached threads for camera disconnection to prevent blocking the main thread during shutdown.

Definition at line 191 of file CameraManager.cpp.

Referenced by initialize().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: