Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
AlviumAsyncCamera Class Reference

#include <AsyncCamera.hpp>

Collaboration diagram for AlviumAsyncCamera:

Public Member Functions

 AlviumAsyncCamera ()
 
 ~AlviumAsyncCamera ()
 
bool start_grabbing_detached ()
 
void stop_grabbing_detached ()
 
std::shared_ptr< sensor_msgs::msg::Image > pop_image (bool blocking)
 

Private Attributes

CameraFrameObserver * m_frameObserver
 
std::atomic< bool > m_runGrabbing
 
VimbaSystem & m_vimbaSystem
 
AVT::VmbAPI::CameraPtr m_camera
 

Detailed Description

Definition at line 43 of file AsyncCamera.hpp.

Constructor & Destructor Documentation

◆ AlviumAsyncCamera()

AlviumAsyncCamera::AlviumAsyncCamera ( )

Definition at line 116 of file AsyncCamera.cpp.

116  : m_vimbaSystem(VimbaSystem::GetInstance()) {
117  m_runGrabbing = false;
118 
119  if(VmbErrorSuccess != m_vimbaSystem.Startup()) {
120  log_warning("[CAMERA] [ALVIUM] Vimba System failed to startup!");
121  }
122 }

References galaxis::utils::log_warning(), m_runGrabbing, and m_vimbaSystem.

Here is the call graph for this function:

◆ ~AlviumAsyncCamera()

AlviumAsyncCamera::~AlviumAsyncCamera ( )

Definition at line 124 of file AsyncCamera.cpp.

124  {
126  m_vimbaSystem.Shutdown();
127 }

References m_vimbaSystem, and stop_grabbing_detached().

Here is the call graph for this function:

Member Function Documentation

◆ pop_image()

std::shared_ptr< sensor_msgs::msg::Image > AlviumAsyncCamera::pop_image ( bool  blocking)

Definition at line 137 of file AsyncCamera.cpp.

137  {
138  if(m_frameObserver != nullptr) {
139  return m_frameObserver->PopLastImage(blocking);
140  }
141  else {
142  log_warning("[CAMERA] [ALVIUM] Frame Observer not initialized!");
143  return nullptr;
144  }
145 }

References galaxis::utils::log_warning(), m_frameObserver, and CameraFrameObserver::PopLastImage().

Referenced by VCINodeAsync::camera_publish_loop().

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

◆ start_grabbing_detached()

bool AlviumAsyncCamera::start_grabbing_detached ( )

Definition at line 147 of file AsyncCamera.cpp.

147  {
148 
149  AVT::VmbAPI::CameraPtrVector cameraPtrVec;
150  // Get all known cameras
151  if ( VmbErrorSuccess != m_vimbaSystem.GetCameras( cameraPtrVec )){
152  log_warning("[CAMERA] [ALVIUM] Failed to get cameras!");
153  return false;
154  }
155 
156  if(cameraPtrVec.size() < 1) {
157  log_warning("[CAMERA] [ALVIUM] No camera found!");
158  return false;
159  }
160 
161  std::string cameraIdString;
162  if(VmbErrorSuccess != cameraPtrVec[0]->GetID(cameraIdString)) {
163  log_warning("[CAMERA] [ALVIUM] Failed to get the camera ID string.");
164  return false;
165  }
166 
167  // open camera
168  if(VmbErrorSuccess != m_vimbaSystem.OpenCameraByID(cameraIdString.c_str(), VmbAccessModeFull, m_camera)) {
169  log_warning("[CAMERA] [ALVIUM] Failed to open the camera.");
170  return false;
171  }
172 
173  // load settings
174  if(VmbErrorSuccess != m_camera->LoadCameraSettings("AlviumCameraVimbaSettings.xml")) {
175  log_warning("[CAMERA] [ALVIUM] Failed to load camera settings.");
176  return false;
177  }
178 
179  // // set to rgb8
180  // AVT::VmbAPI::FeaturePtr formatFeature;
181  // if(VmbErrorSuccess != m_camera->GetFeatureByName( "PixelFormat", formatFeature )) {
182  // log_warning("[CAMERA] [ALVIUM] Failed to get the pixel format feature.");
183  // }
184 
185  // if(VmbErrorSuccess != formatFeature->SetValue(VmbPixelFormatRgb8)) {
186  // log_warning("[CAMERA] [ALVIUM] Failed to get the pixel format feature.");
187  // }
188 
189  // // prepare for image transformation
190  // if( VmbErrorSuccess != SetIntFeatureValueModulo2( m_camera, "Width" ) ){
191  // log_warning("[CAMERA] [ALVIUM] Failed to set int feature.");
192  // }
193  // if( VmbErrorSuccess != SetIntFeatureValueModulo2( m_camera, "Height" ) ){
194  // log_warning("[CAMERA] [ALVIUM] Failed to set int feature.");
195  // }
196 
197  // create frame observer (This will be wrapped in a shared_ptr so we don't delete it)
199 
200  // start streaming
201  if(VmbErrorSuccess != m_camera->StartContinuousImageAcquisition( 100/*number_of_frames*/, IFrameObserverPtr( m_frameObserver ))) {
202  log_warning("[CAMERA] [ALVIUM] Failed to set start continuous image acquision.");
203  return false;
204  }
205 
206  this->m_runGrabbing = true;
207  return true;
208 }

References galaxis::utils::log_warning(), m_camera, m_frameObserver, m_runGrabbing, and m_vimbaSystem.

Referenced by VCINodeAsync::VCINodeAsync().

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

◆ stop_grabbing_detached()

void AlviumAsyncCamera::stop_grabbing_detached ( )

Definition at line 129 of file AsyncCamera.cpp.

129  {
130  if(this->m_runGrabbing) {
131  m_camera->StopContinuousImageAcquisition();
132  delete m_frameObserver;
133  this->m_runGrabbing = false;
134  }
135 }

References m_camera, m_frameObserver, and m_runGrabbing.

Referenced by ~AlviumAsyncCamera().

Here is the caller graph for this function:

Member Data Documentation

◆ m_camera

AVT::VmbAPI::CameraPtr AlviumAsyncCamera::m_camera
private

Definition at line 50 of file AsyncCamera.hpp.

Referenced by start_grabbing_detached(), and stop_grabbing_detached().

◆ m_frameObserver

CameraFrameObserver* AlviumAsyncCamera::m_frameObserver
private

Definition at line 45 of file AsyncCamera.hpp.

Referenced by pop_image(), start_grabbing_detached(), and stop_grabbing_detached().

◆ m_runGrabbing

std::atomic<bool> AlviumAsyncCamera::m_runGrabbing
private

◆ m_vimbaSystem

VimbaSystem& AlviumAsyncCamera::m_vimbaSystem
private

Definition at line 49 of file AsyncCamera.hpp.

Referenced by AlviumAsyncCamera(), start_grabbing_detached(), and ~AlviumAsyncCamera().


The documentation for this class was generated from the following files:
AlviumAsyncCamera::stop_grabbing_detached
void stop_grabbing_detached()
Definition: AsyncCamera.cpp:129
CameraFrameObserver::PopLastImage
std::shared_ptr< sensor_msgs::msg::Image > PopLastImage(bool blocking)
Definition: AsyncCamera.cpp:99
galaxis::utils::log_warning
void log_warning(const Args &... args)
Definition: logger.hpp:41
CameraFrameObserver
Definition: AsyncCamera.hpp:24
AlviumAsyncCamera::m_runGrabbing
std::atomic< bool > m_runGrabbing
Definition: AsyncCamera.hpp:47
AlviumAsyncCamera::m_frameObserver
CameraFrameObserver * m_frameObserver
Definition: AsyncCamera.hpp:45
AlviumAsyncCamera::m_vimbaSystem
VimbaSystem & m_vimbaSystem
Definition: AsyncCamera.hpp:49
AlviumAsyncCamera::m_camera
AVT::VmbAPI::CameraPtr m_camera
Definition: AsyncCamera.hpp:50