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

Base class for all camera implementations. More...

#include <CameraBase.h>

Inheritance diagram for voxl::CameraBase:
Inheritance graph
[legend]
Collaboration diagram for voxl::CameraBase:
Collaboration graph
[legend]

Public Member Functions

 CameraBase (const cam_info &camera_info)
 Constructor.
 
virtual ~CameraBase ()=default
 Virtual destructor.
 
virtual bool connect ()
 Initialize the camera pipe connection.
 
virtual void disconnect ()
 Disconnect and clean up resources.
 
const cam_infoget_camera_info () const
 Get the camera information.
 
bool popCameraData (ov_core::CameraData &out)
 Pop camera data from the queue.
 
int get_channel () const
 Get the camera pipe channel.
 
size_t get_id () const
 Get the camera identifier.
 

Protected Member Functions

virtual void process_image (const camera_image_metadata_t &meta, voxl::ImageType img_type, void *frame)=0
 Process incoming image data.
 

Static Protected Member Functions

static void camera_callback (int ch, camera_image_metadata_t meta, char *frame, void *context)
 Common callback function for pipe client.
 
static void camera_device_buffer_callback (int ch, mpa_ion_buf_t *data, void *context)
 

Protected Attributes

cam_info camera_info_
 Camera configuration information.
 
int channel_ {-1}
 Channel used for pipe communication.
 
bool is_connected_ {false}
 Indicates if camera is connected to pipe.
 
std::mutex mutex_
 Mutex for thread-safe operations.
 
cl_context ctx_ {nullptr}
 OpenCL context used if GPU is enabled.
 
cl_command_queue q_ {nullptr}
 OpenCL command queue used if GPU is enabled.
 
boost::lockfree::spsc_queue< ov_core::CameraData, boost::lockfree::capacity< 64 > > camera_queue
 Lock-free SPSC queue for camera data.
 
img_ringbuf_packet curr_message_
 Instance-local buffer for image processing.
 
cv::Mat use_mask_
 Per-instance reusable mask for feature tracking.
 
bool drop_frames {false}
 Indicates if frames should be dropped.
 
bool skip_jerk_detection {true}
 Indicates if jerk detection should be skipped.
 

Detailed Description

Base class for all camera implementations.

This abstract class defines the interface for camera handlers in the system. It provides the foundation for different camera types (mono, stereo, etc.) and handles pipe communication, image processing, and VIO integration.

The class manages:

Definition at line 56 of file CameraBase.h.

Constructor & Destructor Documentation

◆ CameraBase()

voxl::CameraBase::CameraBase ( const cam_info camera_info)
explicit

Constructor.

Constructor for CameraBase.

Parameters
camera_infoCamera configuration information

Initializes a camera instance with the provided configuration information. Sets up the camera with default values and prepares it for connection.

Parameters
camera_infoCamera configuration and calibration information

Definition at line 41 of file CameraBase.cpp.

◆ ~CameraBase()

virtual voxl::CameraBase::~CameraBase ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ camera_callback()

void voxl::CameraBase::camera_callback ( int  ch,
camera_image_metadata_t  meta,
char *  frame,
void *  context 
)
staticprotected

Common callback function for pipe client.

This function receives raw image data from the pipe and dispatches it to the appropriate processing method. It serves as the entry point for all camera data processing.

Parameters
chChannel number
metaImage metadata
framePointer to image data
contextContext pointer (the CameraBase instance)

This function receives raw image data from the pipe and dispatches it to the appropriate processing method. It serves as the entry point for all camera data processing.

The callback performs the following operations:

  • Enables thread cancellation for proper cleanup
  • Validates the camera context pointer
  • Checks for global shutdown conditions
  • Dispatches to the derived class process_image method
Parameters
chChannel number (unused)
metaImage metadata containing timestamp and format information
framePointer to image data buffer
contextContext pointer (the CameraBase instance)

Definition at line 186 of file CameraBase.cpp.

References main_running, process_image(), and vio_error_codes.

Referenced by connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ camera_device_buffer_callback()

void voxl::CameraBase::camera_device_buffer_callback ( int  ch,
mpa_ion_buf_t *  data,
void *  context 
)
staticprotected

Definition at line 213 of file CameraBase.cpp.

◆ connect()

bool voxl::CameraBase::connect ( )
virtual

Initialize the camera pipe connection.

Connect to the camera pipe service.

This method establishes the connection to the camera pipe service and sets up the necessary callbacks for image data reception.

Returns
True if successful, false otherwise

This method establishes the connection to the camera pipe service and sets up the necessary callbacks for image data reception.

The connection process includes:

  • Obtaining an available pipe channel
  • Configuring appropriate callbacks
  • Opening the pipe connection with proper flags and buffer size
  • Flushing the pipe to clear stale data
Returns
true if connection was successful, false otherwise

Definition at line 60 of file CameraBase.cpp.

References camera_callback(), camera_info_, channel_, en_debug, is_connected_, mutex_, cam_info::name, PROCESS_NAME, cam_info::tracking_name, and vio_error_codes.

Here is the call graph for this function:

◆ disconnect()

void voxl::CameraBase::disconnect ( )
virtual

Disconnect and clean up resources.

This method properly closes the pipe connection and cleans up any allocated resources.

This method properly closes the pipe connection and cleans up any allocated resources. It ensures a clean shutdown of the camera connection.

The disconnection process includes:

  • Flushing the pipe to clear pending data
  • Waiting for pending operations to complete
  • Closing the pipe connection
  • Updating connection state

The method is thread-safe and handles cases where the camera is already disconnected.

Definition at line 139 of file CameraBase.cpp.

References camera_info_, channel_, en_debug, is_connected_, mutex_, and cam_info::name.

◆ get_camera_info()

const cam_info & voxl::CameraBase::get_camera_info ( ) const
inline

Get the camera information.

Returns
Camera information structure

Definition at line 92 of file CameraBase.h.

References camera_info_.

◆ get_channel()

int voxl::CameraBase::get_channel ( ) const
inline

Get the camera pipe channel.

Returns
Pipe channel number

Definition at line 113 of file CameraBase.h.

References channel_.

◆ get_id()

size_t voxl::CameraBase::get_id ( ) const
inline

Get the camera identifier.

Returns
Camera identifier

Definition at line 119 of file CameraBase.h.

References cam_info::cam_id, and camera_info_.

◆ popCameraData()

bool voxl::CameraBase::popCameraData ( ov_core::CameraData &  out)
inline

Pop camera data from the queue.

Retrieves the next available camera data from the internal queue. This method is used to get processed image data for VIO processing.

The method uses a lock-free SPSC (Single Producer, Single Consumer) queue for efficient thread-safe data transfer between the camera callback thread and the VIO processing thread.

Parameters
outReference to store the popped data
Returns
true if data was popped, false if queue is empty

Definition at line 107 of file CameraBase.h.

References camera_queue.

◆ process_image()

virtual void voxl::CameraBase::process_image ( const camera_image_metadata_t &  meta,
voxl::ImageType  img_type,
void *  frame 
)
protectedpure virtual

Process incoming image data.

This method is called by the pipe callback when new image data arrives. Derived classes must implement this method to handle their specific image processing requirements.

Parameters
metaImage metadata containing timestamp and other information
framePointer to image data buffer

Implemented in voxl::MonoCamera, and voxl::StereoCamera.

Referenced by camera_callback().

Here is the caller graph for this function:

Member Data Documentation

◆ camera_info_

cam_info voxl::CameraBase::camera_info_
protected

Camera configuration information.

Definition at line 155 of file CameraBase.h.

Referenced by connect(), disconnect(), get_camera_info(), and get_id().

◆ camera_queue

boost::lockfree::spsc_queue<ov_core::CameraData, boost::lockfree::capacity<64> > voxl::CameraBase::camera_queue
protected

Lock-free SPSC queue for camera data.

Used for efficient communication between camera thread and VIO thread. Capacity of 64 provides approximately 2.4 seconds of buffering at 30fps.

Definition at line 178 of file CameraBase.h.

Referenced by popCameraData().

◆ channel_

int voxl::CameraBase::channel_ {-1}
protected

Channel used for pipe communication.

Definition at line 158 of file CameraBase.h.

Referenced by connect(), disconnect(), and get_channel().

◆ ctx_

cl_context voxl::CameraBase::ctx_ {nullptr}
protected

OpenCL context used if GPU is enabled.

Definition at line 167 of file CameraBase.h.

◆ curr_message_

img_ringbuf_packet voxl::CameraBase::curr_message_
protected

Instance-local buffer for image processing.

Definition at line 181 of file CameraBase.h.

◆ drop_frames

bool voxl::CameraBase::drop_frames {false}
protected

Indicates if frames should be dropped.

Definition at line 187 of file CameraBase.h.

Referenced by voxl::MonoCamera::process_image().

◆ is_connected_

bool voxl::CameraBase::is_connected_ {false}
protected

Indicates if camera is connected to pipe.

Definition at line 161 of file CameraBase.h.

Referenced by connect(), and disconnect().

◆ mutex_

std::mutex voxl::CameraBase::mutex_
protected

Mutex for thread-safe operations.

Definition at line 164 of file CameraBase.h.

Referenced by connect(), and disconnect().

◆ q_

cl_command_queue voxl::CameraBase::q_ {nullptr}
protected

OpenCL command queue used if GPU is enabled.

Definition at line 170 of file CameraBase.h.

◆ skip_jerk_detection

bool voxl::CameraBase::skip_jerk_detection {true}
protected

Indicates if jerk detection should be skipped.

Definition at line 190 of file CameraBase.h.

Referenced by voxl::MonoCamera::process_image().

◆ use_mask_

cv::Mat voxl::CameraBase::use_mask_
protected

Per-instance reusable mask for feature tracking.

Definition at line 184 of file CameraBase.h.


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