![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
This example serves as as a playground for understanding how to control the parameters of the Baumer camera via the irsol::camera::Interface class.
The irsol::camera::Interface class provides a convenient abstraction over NeoAPI's camera control system. It simplifies getting and setting camera parameters while ensuring thread safety and proper type conversion. This section explains the design and usage of its parameter management functions.
getParamgetParam is a templated method used to retrieve the value of a camera feature by name. It is type-safe and automatically deduces the correct underlying NeoAPI getter based on the requested C++ type.
Supported types:
int, int64_t – for integer-based parametersdouble, float – for floating-point parametersstd::string – for string-valued parametersbool – for boolean switchesExample usage:
If a parameter fetch fails, the function logs the error and returns a default-constructed value (e.g., 0 for integers, "Unknown" for strings).
setParamsetParam is a templated, thread-safe setter that assigns a value to a camera feature, then reads back and returns the applied value to confirm the update.
This method ensures:
NeoAPI setter.Example usage:
setParam behaviorWhen using the setParam methods to configure camera parameters, it's important to understand that the value ultimately applied by the camera may differ slightly from the one provided. This is because some camera features accept only specific discrete values, or impose constraints such as value ranges or fixed precision steps. For example, setting an exposure time of 1037µs may result in the camera applying 1040µs if that's the closest supported value. To ensure the caller is aware of the actual value in effect, all setParam overloads return the final value that was accepted by the camera after attempting the update.
getExposure and setExposureExposure is a time-based parameter, and this abstraction uses irsol::types::duration_t for safe and expressive exposure control.
getExposure() reads the "ExposureTime" feature (in microseconds) and returns it as a irsol::types::duration_t type.setExposure() sets the exposure time.One should alway prefer to call these methods rather than relying on the raw setParam and getParam methods.
Example usage:
This approach provides type safety and unit clarity when managing exposure values.
setMultiParamTo optimize configuration and avoid repetitive locking and logging, setMultiParam allows batch updates to multiple parameters:
camera_param_t is a variant supporting multiple value types (int, double, std::string, etc.).Example:
Using setMultiParam ensures consistency and performance in situations where several related parameters must be updated simultaneously.