API
This chapter documents the core C++ API provided by the common/ library
(libcamcom_com). This is the foundation that all adapters and the test bench
build upon.
AdapterBase
camcom::common::AdapterBase (camcom/common/adapterBase.hpp) is the central
abstract interface. Every camera adapter implements this class.
Connection Management
Method |
Description |
|---|---|
|
Connect to the camera and return the initial parameter set read from the device (camera-native names). Throws on failure. |
|
Disconnect from the camera. |
|
Check connection health. Returns |
|
Returns |
|
Set the camera address/URI before connecting. |
|
Set the connection timeout in seconds. |
|
Optional initialization with custom configuration (address, timeout, properties). |
|
Returns a protocol identifier string (e.g., |
Parameter Access
All parameter names across the AdapterBase boundary are camera-native.
The adapter does no name mapping.
Method |
Description |
|---|---|
|
Read a single parameter by its camera-native name. Returns a
|
|
Batch read multiple parameters. Returns a vector of |
|
Write a single parameter to the camera. |
|
Batch write multiple parameters. |
|
Discover all available parameters from the camera. Returns a vector of
|
|
Returns a |
|
Returns the camera’s native parameter document (e.g., GenICam XML). |
Acquisition Control
Method |
Description |
|---|---|
|
Start frame acquisition. Pass |
|
Stop frame acquisition. |
|
Receive a single frame. Sets |
|
Returns the current acquisition state (mode, remaining frames, measured FPS). |
Acquisition State
enum class AcqMode {
Inactive, // No acquisition
Continuous, // Stream until stopped
Finite // Acquire N frames then stop
};
struct AcquisitionState {
AcqMode mode{AcqMode::Inactive};
std::optional<int64_t> remaining_frames; // Only if Finite
double current_fps{0.0}; // Measured frame rate
};
Factory Functions
Each adapter shared library must export these C functions for dlopen
loading:
extern "C" {
camcom::common::AdapterBase* CreateAdapter();
void destroyAdapter(camcom::common::AdapterBase* adapter);
}
Parameter
camcom::common::Parameter (camcom/common/parameter.hpp) is a type-safe
container for camera parameters.
Construction
// Explicit construction
Parameter(const std::string& name, const Value& value, const DataType& type);
// Template construction (type deduced)
Parameter("ExposureTime", 10000.0); // DOUBLE
Parameter("Width", int32_t(1024)); // INT32
Parameter("Enabled", true); // BOOL
Parameter("PixelFormat", "Mono16"s); // STRING
Methods
Method |
Description |
|---|---|
|
Returns the parameter name. |
|
Returns the value cast to type |
|
Returns the value formatted as a string. |
|
Returns the |
|
Returns the type as a human-readable string. |
|
Replace the stored name, value, and type. |
|
Returns |
|
Returns a const reference to the |
|
Attach metadata to this parameter. |
DataType
CamCom does not define its own data-type enum. camcom::common::DataType
(camcom/common/datatype.hpp) is an alias for the ELT IFW data type
ifw::fnd::datatype::DataType (based on the CPL definition), so there is a
single source of truth across IFW. The supported values used for parameters and
pixel data are:
Enum Value |
Bit Value |
Description |
|---|---|---|
|
64 |
Unsigned 8-bit byte |
|
128 |
Boolean |
|
256 |
Signed 16-bit integer |
|
512 |
Unsigned 16-bit integer |
|
1024 |
Signed 32-bit integer |
|
2048 |
Unsigned 32-bit integer |
|
4096 |
Signed 64-bit integer |
|
8192 |
Unsigned 64-bit integer |
|
65536 |
32-bit floating point |
|
131072 |
64-bit floating point |
|
33 |
Character array (CHAR | ARRAY) |
|
32 |
Single character |
|
1048576 |
Unknown / not set |
|
16 |
Invalid type |
ParameterMetadata
camcom::common::ParameterMetadata (camcom/common/parameterMetadata.hpp)
carries optional constraints and descriptive information for a parameter.
Field |
Type |
Description |
|---|---|---|
|
|
Native parameter name (before any mapping). |
|
|
Minimum allowed value (numeric types). |
|
|
Maximum allowed value (numeric types). |
|
|
Step size (used for UI slider/spinbox). |
|
|
List of valid values (for enumerations). |
|
|
Physical unit (e.g., |
|
|
Human-readable description. |
|
|
Whether the parameter can be read (default: |
|
|
Whether the parameter can be written (default: |
|
|
Default value, if known. |
The server’s /parameters/scan endpoint returns parameters with their
metadata, enabling the GUI to render appropriate controls (spinboxes with
limits, comboboxes for enums, read-only labels, etc.).
FrameInfo
camcom::common::FrameInfo (camcom/common/frameInfo.hpp) carries metadata for a
single image frame.
Field |
Type |
Description |
|---|---|---|
|
|
ROI X offset in pixels. |
|
|
ROI Y offset in pixels. |
|
|
Image width in pixels. |
|
|
Image height in pixels. |
|
|
Frame sequence number. |
|
|
Camera timestamp in nanoseconds. |
|
|
Exposure time in microseconds. |
|
|
Pixel data type (e.g., |
|
|
Frame buffer size in bytes. |
|
|
Extensible key-value metadata. |
BasicParams
camcom::common::BasicParams (camcom/common/basicParams.hpp) provides a
standardized view of camera parameters in common units, independent of the
adapter’s native units.
Field |
Type |
Description |
|---|---|---|
|
|
Exposure time in seconds. |
|
|
Frame rate in Hz. |
|
|
Current image width in pixels. |
|
|
Current image height in pixels. |
|
|
ROI X offset. |
|
|
ROI Y offset. |
|
|
Horizontal binning factor. |
|
|
Vertical binning factor. |
|
|
Full sensor width in pixels. |
|
|
Full sensor height in pixels. |
|
|
Bytes per pixel (1, 2, 4, etc.). |
|
|
Maximum frame buffer size in bytes. |
FindFile
camcom::common::FindFile (camcom/common/find_file.hpp) provides centralized
file resolution used by both C++ and Python components.
Functions
Function |
Description |
|---|---|
|
Expand environment variables ( |
|
Resolve a file path using the CamCom search algorithm. Returns the resolved absolute path, or empty string if not found. |
Resolution Algorithm
Expand
$VAR,${VAR}, and~in the path.If the result is an absolute path and exists, use it directly.
If relative, search each directory in
CFGPATH(colon-separated environment variable).Fall back to
$INTROOT/resourceand$PREFIX/resource.If a referrer is provided, try the referrer’s directory.
Try the current working directory.
Return empty string if not found.
All resolutions are logged at INFO level.
Note
The Python implementation in testbench/gui/src/camcom/gui/find_file.py
follows the same algorithm, ensuring consistent file resolution between the
C++ server and the Python GUI.
Logger
CamCom uses the ifw-fnd logging abstraction (ifw/fnd/defs/base.hpp).
An application installs a concrete ifw::fnd::Logger (stdout, null, or
backend-specific such as log4cplus) once at startup via
ifw::fnd::InstallLogger(...); call sites then use the FND* macros
below. There is no camcom-specific logger to bootstrap.
Log Levels
Level |
Description |
|---|---|
ERROR |
Errors that may require attention. |
WARNING |
Unexpected conditions that are handled. |
INFO |
Informational messages about normal operation. |
DEBUG |
Diagnostic information for troubleshooting. |
TRACE |
Detailed tracing of function entry/exit with timing. |
Log Macros
The preferred way to log is via the macros, which automatically include source location:
FNDDEBUG("Exposure time set to {:.3f} ms", expo_ms);
FNDINFO("Connected to camera at {}", address);
FNDWARNING("Frame dropped, queue full (size={})", queue_size);
FNDERROR("Failed to open library: {}", dlerror());
FNDTHROW("Invalid data type: {}", type_str); // Logs and throws
FNDTRACE(); // Trace function entry/exit with timing
FNDTRACE("acquisition"); // Scope name appears on both ENTERING/LEAVING lines
Note
When adding diagnostic logs, use DEBUG level, not INFO. Leave DEBUG logs in the code for future troubleshooting.
Queue
camcom::common::Queue<T> (camcom/common/queue.hpp) is a thread-safe bounded
queue used in the frame pipeline.
Method |
Description |
|---|---|
|
Construct with maximum size and identifier for logging. |
|
Add an element. If full, drops the oldest element and logs a warning (throttled to once per 10 seconds). |
|
Remove and return the front element. Returns |
|
Current number of elements in the queue. |
|
Remove all elements. |
ReceiveCfg
camcom::common::ReceiveCfg (camcom/common/receiveCfg.hpp) encapsulates
adapter initialization parameters.
Method |
Description |
|---|---|
|
Construct with camera address and optional timeout (default: 10s). |
|
Construct with additional key-value properties. |
|
Returns the camera address string. |
|
Returns the connection timeout duration. |
|
Set a custom property. |
|
Check if a property exists. |
|
Get the value of a property. |