![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
High-level wrapper around the NeoAPI camera for synchronized access. More...
#include <interface.hpp>
Public Types | |
using | image_t = NeoAPI::Image |
Alias for the image type returned by the NeoAPI. | |
using | camera_param_t = std::variant< bool, int, int64_t, double, std::string, const char * > |
Union of all supported types for camera parameters. | |
Public Member Functions | |
Interface (NeoAPI::Cam cam=irsol::utils::loadDefaultCamera()) | |
Constructs the Interface by loading the default camera. | |
Interface (Interface &&other) | |
Move constructor. | |
Interface & | operator= (Interface &&other) |
Move assignment operator. | |
std::string | cameraInfoAsString () const |
Get human-readable camera information. | |
std::string | cameraStatusAsString () const |
Get current camera status. | |
NeoAPI::Cam & | getNeoCam () |
Access the underlying NeoAPI camera instance. | |
bool | isConnected () const |
Check if the camera is currently connected. | |
void | resetSensorArea () |
Reset the sensor area to the full sensor dimensions. | |
irsol::types::duration_t | getExposure () const |
Get the current exposure time from the camera. | |
irsol::types::duration_t | setExposure (irsol::types::duration_t exposure) |
Set the exposure time of the camera. | |
template<typename T , std::enable_if_t< std::is_integral_v< T >||std::is_floating_point_v< T >||std::is_same_v< std::string, T >, int > = 0> | |
T | getParam (const std::string ¶m) const |
Retrieve a camera parameter of arbitrary type T. | |
std::string | getParam (const std::string ¶m) const |
Retrieve a camera parameter and convert it to string. | |
template<typename T , std::enable_if_t< std::is_integral_v< std::decay_t< T > >||std::is_floating_point_v< std::decay_t< T > >||std::is_same_v< std::decay_t< T >, std::string >, int > = 0> | |
T | setParam (const std::string ¶m, T value) |
Set a camera parameter of arbitrary type T. | |
template<typename T , std::enable_if_t< std::is_same_v< std::decay_t< T >, const char * >, int > = 0> | |
std::string | setParam (const std::string ¶m, T value) |
Specialization for setting const char* values as strings. | |
void | setMultiParam (const std::unordered_map< std::string, camera_param_t > ¶ms) |
Set multiple parameters in one call. | |
void | trigger (const std::string ¶m) |
Trigger a camera feature (e.g., software trigger). | |
image_t | captureImage (std::optional< irsol::types::duration_t > timeout=std::nullopt) |
Capture a single image from the camera. | |
Static Public Member Functions | |
static Interface | FullResolution () |
Factory method to create a camera interface using full sensor resolution. | |
static Interface | HalfResolution () |
Factory method to create a camera interface using half sensor resolution. | |
Static Public Attributes | |
static constexpr irsol::types::duration_t | DEFAULT_EXPOSURE_TIME = std::chrono::milliseconds(2) |
Default exposure time (2 milliseconds) used to initialize the camera. | |
Private Member Functions | |
template<typename T , std::enable_if_t< std::is_integral_v< std::decay_t< T > >||std::is_floating_point_v< std::decay_t< T > >||std::is_same_v< std::decay_t< T >, std::string >||std::is_same_v< std::decay_t< T >, const char * >, int > = 0> | |
void | setParamNonThreadSafe (const std::string ¶m, T value) |
Internal, non-thread-safe parameter setter used by setParam . | |
Private Attributes | |
std::mutex | m_camMutex |
Mutex to protect access to camera parameters and image acquisition. | |
NeoAPI::Cam | m_cam |
Internal camera instance from NeoAPI. | |
irsol::types::duration_t | m_CachedExposureTime |
High-level wrapper around the NeoAPI camera for synchronized access.
The Interface
class provides thread-safe control over camera acquisition and configuration via NeoAPI. It abstracts common camera operations such as setting exposure, retrieving and setting camera parameters, capturing images, and managing sensor state.
Definition at line 60 of file interface.hpp.
using irsol::camera::Interface::camera_param_t = std::variant<bool, int, int64_t, double, std::string, const char*> |
Union of all supported types for camera parameters.
Definition at line 67 of file interface.hpp.
using irsol::camera::Interface::image_t = NeoAPI::Image |
Alias for the image type returned by the NeoAPI.
Definition at line 64 of file interface.hpp.
irsol::camera::Interface::Interface | ( | NeoAPI::Cam | cam = irsol::utils::loadDefaultCamera() | ) |
Constructs the Interface by loading the default camera.
Initializes the camera by calling irsol::utils::loadDefaultCamera(), which automatically finds and opens the default device based on serial number.
cam | Optional camera handle. Defaults to the result of irsol::utils::loadDefaultCamera(). |
std::runtime_error | if camera initialization fails. |
Definition at line 13 of file interface.cpp.
irsol::camera::Interface::Interface | ( | Interface && | other | ) |
std::string irsol::camera::Interface::cameraInfoAsString | ( | ) | const |
Get human-readable camera information.
Collects fields from NeoAPI::CamInfo
and formats them into a readable tabular string.
Definition at line 79 of file interface.cpp.
std::string irsol::camera::Interface::cameraStatusAsString | ( | ) | const |
Get current camera status.
Reads camera state such as resolution, exposure, and other operational flags and returns a descriptive tabular string.
Definition at line 114 of file interface.cpp.
Interface::image_t irsol::camera::Interface::captureImage | ( | std::optional< irsol::types::duration_t > | timeout = std::nullopt | ) |
Capture a single image from the camera.
Waits up to a specified timeout (or the cached exposure time if not provided as argument). Thread-safe.
timeout | Optional duration to wait for a frame. |
std::runtime_error | on timeout or camera error. |
Definition at line 232 of file interface.cpp.
|
static |
Factory method to create a camera interface using full sensor resolution.
Definition at line 49 of file interface.cpp.
irsol::types::duration_t irsol::camera::Interface::getExposure | ( | ) | const |
Get the current exposure time from the camera.
Definition at line 170 of file interface.cpp.
NeoAPI::Cam & irsol::camera::Interface::getNeoCam | ( | ) |
Access the underlying NeoAPI camera instance.
NeoAPI::Cam
object. Definition at line 153 of file interface.cpp.
T irsol::camera::Interface::getParam | ( | const std::string & | param | ) | const |
Retrieve a camera parameter of arbitrary type T.
Uses the NeoAPI API to retrieve the value and cast to T. Supported types:
Thread-safe: locks internal mutex.
T | Desired return type. |
param | Name of the camera parameter. |
std::string irsol::camera::Interface::getParam | ( | const std::string & | param | ) | const |
Retrieve a camera parameter and convert it to string.
Thread-safe: locks internal mutex.
param | Name of the camera parameter. |
Definition at line 189 of file interface.cpp.
|
static |
Factory method to create a camera interface using half sensor resolution.
Uses hardware binning to reduce resolution by averaging pixels.
Definition at line 63 of file interface.cpp.
|
inline |
Check if the camera is currently connected.
Uses NeoAPI::Cam::IsConnected()
internally.
Definition at line 137 of file interface.hpp.
Move assignment operator.
Definition at line 42 of file interface.cpp.
void irsol::camera::Interface::resetSensorArea | ( | ) |
Reset the sensor area to the full sensor dimensions.
Useful if a previous program limited the sensor region and full dimensions need to be restored.
Definition at line 159 of file interface.cpp.
irsol::types::duration_t irsol::camera::Interface::setExposure | ( | irsol::types::duration_t | exposure | ) |
Set the exposure time of the camera.
exposure | New exposure duration. |
Definition at line 177 of file interface.cpp.
void irsol::camera::Interface::setMultiParam | ( | const std::unordered_map< std::string, camera_param_t > & | params | ) |
Set multiple parameters in one call.
Iterates through a map of key-value pairs and sets each camera parameter accordingly. Internally dispatches based on type.
params | Map of parameter names and values. |
Definition at line 203 of file interface.cpp.
T irsol::camera::Interface::setParam | ( | const std::string & | param, |
T | value | ||
) |
Set a camera parameter of arbitrary type T.
Thread-safe. Supported types:
T | Value type. |
param | Parameter name. |
value | Value to set. |
std::string irsol::camera::Interface::setParam | ( | const std::string & | param, |
T | value | ||
) |
Specialization for setting const char* values as strings.
param | Parameter name. |
value | C-string value. |
|
private |
Internal, non-thread-safe parameter setter used by setParam
.
T | Parameter value type. |
param | Name of the parameter. |
value | Value to assign. |
void irsol::camera::Interface::trigger | ( | const std::string & | param | ) |
Trigger a camera feature (e.g., software trigger).
param | Name of the triggerable feature. |
Definition at line 219 of file interface.cpp.
|
staticconstexpr |
Default exposure time (2 milliseconds) used to initialize the camera.
Definition at line 70 of file interface.hpp.
|
private |
Cached exposure value used for implicit timeout behavior in irsol::camera::Interface::captureImage().
Definition at line 270 of file interface.hpp.
|
private |
Internal camera instance from NeoAPI.
Definition at line 266 of file interface.hpp.
|
mutableprivate |
Mutex to protect access to camera parameters and image acquisition.
Definition at line 263 of file interface.hpp.