8#ifndef META_OCEAN_IO_CAMERA_CALIBRATION_MANAGER_H
9#define META_OCEAN_IO_CAMERA_CALIBRATION_MANAGER_H
148 inline CalibrationGroup(
const int32_t priority,
const std::string& deviceProduct = std::string(),
const std::string& deviceVersion = std::string(),
const std::string& deviceSerial = std::string());
180 inline size_t size()
const;
185 int32_t priority_ = 0;
213 using CameraMap = std::unordered_map<std::string, CalibrationGroups>;
218 using AliasMap = std::unordered_map<std::string, std::string>;
398 deviceProduct_(std::move(deviceProduct)),
399 deviceVersion_(std::move(deviceVersion)),
400 deviceSerial_(std::move(deviceSerial))
407 return cameras_.size();
This class stores multiple camera calibrations with the same priority.
Definition CameraCalibrationManager.h:138
size_t size() const
Returns the number of camera calibrations in this group.
Definition CameraCalibrationManager.h:405
SharedAnyCamera camera(const unsigned int width, const unsigned int height, CalibrationQuality &calibrationQuality) const
Returns the best matching camera calibration for a given resolution.
CalibrationGroup(const int32_t priority, const std::string &deviceProduct=std::string(), const std::string &deviceVersion=std::string(), const std::string &deviceSerial=std::string())
Creates a new Calibrations object with a specific priority.
Definition CameraCalibrationManager.h:396
std::string deviceVersion_
Optional device version for this calibration group (e.g., "SM-G991U", "A2483"), empty if not set.
Definition CameraCalibrationManager.h:194
bool matchesDeviceContext(const DeviceContextLevel deviceContextLevel, const std::string &deviceContextValue) const
Checks whether this calibration group matches the given device context.
SharedAnyCameras cameras_
All camera models with individual resolutions.
Definition CameraCalibrationManager.h:188
std::string deviceSerial_
Optional device serial for this calibration group (e.g., "ABC123456"), empty if not set.
Definition CameraCalibrationManager.h:197
std::string deviceProduct_
Optional device product for this calibration group (e.g., "Samsung S21 5G", "iPhone 13 Pro"),...
Definition CameraCalibrationManager.h:191
bool addCamera(SharedAnyCamera &&camera)
Adds a camera model to this calibration group.
This class implements a manager for camera calibrations using a modern JSON-based format.
Definition CameraCalibrationManager.h:90
bool registerFactoryFunction(const std::string &modelName, FactoryFunction &&factoryFunction)
Registers a new camera factory for a specific camera type.
AliasMap aliasMap_
The map mapping camera aliases to their actual camera names.
Definition CameraCalibrationManager.h:384
std::unordered_map< std::string, FactoryFunction > FactoryFunctionMap
Definition of a map mapping camera model names to factory functions.
Definition CameraCalibrationManager.h:208
bool registerCalibrations(const std::string &url)
Registers calibrations from a JSON file.
FactoryFunctionMap factoryFunctionMap_
The map mapping camera model names to factory functions.
Definition CameraCalibrationManager.h:378
bool registerCameras(const JSONParser::JSONValue::Array &camerasArray, const std::string &deviceProduct=std::string(), const std::string &deviceVersion=std::string(), const std::string &deviceSerial=std::string())
Registers cameras from a JSON cameras array with optional device context.
SharedAnyCamera parseCamera(const std::string &jsonCameraCalibrationFile, std::string &&jsonCameraCalibration=std::string()) const
Parses one camera calibration from a file or a string/buffer containing the JSON calibration object f...
void clear()
Clears all registered calibrations and aliases.
CalibrationQuality
Definition of different calibration qualities indicating how the calibration was obtained.
Definition CameraCalibrationManager.h:115
@ CQ_INTERPOLATED
The calibration was interpolated from a calibration with a different resolution but the same aspect r...
Definition CameraCalibrationManager.h:119
std::vector< CalibrationGroup > CalibrationGroups
Definition of a vector holding calibration groups.
Definition CameraCalibrationManager.h:203
bool setDeviceProduct(const std::string &product)
Sets the device context to a specific product name.
std::function< SharedAnyCamera(const JSONParser::JSONValue &modelObject)> FactoryFunction
Definition of a factory function that creates a SharedAnyCamera from a JSON model object.
Definition CameraCalibrationManager.h:129
static bool parseResolution(const JSONParser::JSONValue &calibrationObject, unsigned int &width, unsigned int &height)
Parses the resolution of a camera from a JSON calibration object.
static SharedAnyCamera createOceanFisheye(const JSONParser::JSONValue &modelObject)
Factory function able to create the "Ocean Fisheye" camera model from a JSON configuration.
std::unordered_map< std::string, std::string > AliasMap
Definition of a map mapping camera aliases to their actual camera names.
Definition CameraCalibrationManager.h:218
Lock lock_
The lock for thread-safe access to all manager data.
Definition CameraCalibrationManager.h:393
CameraMap cameraMap_
The map mapping camera names to calibration groups.
Definition CameraCalibrationManager.h:381
void clearDeviceContext()
Clears the device context.
std::unordered_map< std::string, CalibrationGroups > CameraMap
Definition of a map mapping camera names to calibration groups.
Definition CameraCalibrationManager.h:213
bool setDeviceVersion(const std::string &version)
Sets the device context to a specific hardware version/variant.
bool setDeviceSerial(const std::string &serial)
Sets the device context to a specific device serial number.
bool registerCalibrations(const void *buffer, const size_t size)
Registers calibrations from a memory buffer containing JSON data.
CameraCalibrationManager()
Protected default constructor.
bool registerCamera(const std::string &cameraName, SharedAnyCamera &&camera, const int32_t priority)
Registers a single camera calibration with a specific priority.
SharedAnyCamera camera(const std::string &cameraName, unsigned int width, unsigned int height, CalibrationQuality *calibrationQuality=nullptr) const
Returns a camera for a given camera name and resolution.
static SharedAnyCamera createOceanPinhole(const JSONParser::JSONValue &modelObject)
Factory function able to create the "Ocean Pinhole" camera model from a JSON configuration.
std::string deviceContextValue_
The current device context value (product, version, or serial depending on deviceContextLevel_).
Definition CameraCalibrationManager.h:390
bool registerCalibrations(const JSONParser::JSONValue &jsonValue)
Registers calibrations from a parsed JSON value.
DeviceContextLevel
Definition of different device context levels.
Definition CameraCalibrationManager.h:100
@ DCL_VERSION
Device context is set to a hardware version/variant.
Definition CameraCalibrationManager.h:106
@ DCL_PRODUCT
Device context is set to a product name (least specific).
Definition CameraCalibrationManager.h:104
This class implements a JSON value that can hold different JSON types.
Definition JSONParser.h:35
std::vector< JSONValue > Array
Definition of a JSON array (vector of JSONValue).
Definition JSONParser.h:62
This class implements a recursive lock object.
Definition Lock.h:31
This template class is the base class for all singleton objects.
Definition Singleton.h:71
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition AnyCamera.h:91
The namespace covering the entire Ocean framework.
Definition Accessor.h:15