Update OrbbecSDK version to 2.5.5

This commit is contained in:
slz
2025-11-07 10:16:09 +08:00
parent b46f5191ad
commit 6e77843e2f
43 changed files with 2033 additions and 819 deletions
@@ -15,6 +15,7 @@
#include <functional>
#include <memory>
#include <string>
namespace ob {
@@ -28,16 +29,16 @@ public:
/**
* @brief Type definition for the device changed callback function.
*
* @param removedList The list of removed devices.
* @param addedList The list of added devices.
* @param[in] removedList The list of removed devices.
* @param[in] addedList The list of added devices.
*/
typedef std::function<void(std::shared_ptr<DeviceList> removedList, std::shared_ptr<DeviceList> addedList)> DeviceChangedCallback;
/**
* @brief Type definition for the log output callback function.
*
* @param severity The current callback log level.
* @param logMsg The log message.
* @param[in] severity The current callback log level.
* @param[in] logMsg The log message.
*/
typedef std::function<void(OBLogSeverity severity, const char *logMsg)> LogCallback;
@@ -97,6 +98,24 @@ public:
Error::handle(&error);
}
/**
* @brief "Force" a static IP address configuration in a device identified by its MAC Address.
*
* @param[in] macAddress MAC address of the network device.
* You can obtain it from @ref ob_device_info_get_uid, or specify it manually
* in the format xx:xx:xx:xx:xx:xx, where each xx is a two-digit hexadecimal value.
* @param[in] config The new IP configuration.
* @return bool true if the configuration command was processed successfully, false otherwise.
*
* @note This applies to all Orbbec GigE Vision devices
*/
bool forceIp(const char *macAddress, const OBNetIpConfig &config) {
ob_error *error = nullptr;
auto res = ob_force_ip_config(macAddress, config, &error);
Error::handle(&error);
return res;
}
/**
* @brief Creates a network device with the specified IP address and port.
*
@@ -115,7 +134,7 @@ public:
* @brief Set the device plug-in callback function.
* @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list.
*
* @param callback The function triggered when the device is plugged and unplugged.
* @param[in] callback The function triggered when the device is plugged and unplugged.
*/
void setDeviceChangedCallback(DeviceChangedCallback callback) {
deviceChangedCallback_ = callback;
@@ -127,7 +146,7 @@ public:
/**
* @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
*
* @param repeatIntervalMsec The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
* @param[in] repeatIntervalMsec The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
*/
void enableDeviceClockSync(uint64_t repeatIntervalMsec) const {
ob_error *error = nullptr;
@@ -163,7 +182,7 @@ public:
* @brief Set the level of the global log, which affects both the log level output to the console, output to the file and output the user defined
* callback.
*
* @param severity The log output level.
* @param[in] severity The log output level.
*/
static void setLoggerSeverity(OBLogSeverity severity) {
ob_error *error = nullptr;
@@ -174,9 +193,9 @@ public:
/**
* @brief Set log output to a file.
*
* @param severity The log level output to the file.
* @param directory The log file output path. If the path is empty, the existing settings will continue to be used (if the existing configuration is also
* empty, the log will not be output to the file).
* @param[in] severity The log level output to the file.
* @param[in] directory The log file output path. If the path is empty, the existing settings will continue to be used (if the existing configuration is
* also empty, the log will not be output to the file).
*/
static void setLoggerToFile(OBLogSeverity severity, const char *directory) {
ob_error *error = nullptr;
@@ -184,10 +203,24 @@ public:
Error::handle(&error);
}
/**
* @brief Set the log file name for file output
*
* @param[in] fileName Log file name. Must not be empty.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @note Other settings, such as log level and output directory, remain unchanged.
*/
static void setLoggerFileName(const std::string &fileName) {
ob_error *error = nullptr;
ob_set_logger_file_name(fileName.c_str(), &error);
Error::handle(&error);
}
/**
* @brief Set log output to the console.
*
* @param severity The log level output to the console.
* @param[in] severity The log level output to the console.
*/
static void setLoggerToConsole(OBLogSeverity severity) {
ob_error *error = nullptr;
@@ -198,8 +231,8 @@ public:
/**
* @brief Set the logger to callback.
*
* @param severity The callback log level.
* @param callback The callback function.
* @param[in] severity The callback log level.
* @param[in] callback The callback function.
*/
static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback) {
ob_error *error = nullptr;
@@ -208,13 +241,30 @@ public:
Error::handle(&error);
}
/**
* @brief Logs a message with severity, file, function, and line info.
*
* @param severity Log level, see @ref OBLogSeverity for details
* @param module The module or component the log belongs to
* @param message Message string to log
* @param file Source file name, e.g., __FILE__
* @param func Function name, e.g., __func__
* @param line Line number, e.g., __LINE__
*/
static void logExternalMessage(OBLogSeverity severity, const std::string &module, const std::string &message, const std::string &file,
const std::string &func, int line) {
ob_error *error = nullptr;
ob_log_external_message(severity, module.c_str(), message.c_str(), file.c_str(), func.c_str(), line, &error);
Error::handle(&error);
}
/**
* @brief Set the extensions directory
* @brief The extensions directory is used to search for dynamic libraries that provide additional functionality to the SDK, such as the Frame filters.
*
* @attention Should be called before creating the context and pipeline, otherwise the default extensions directory (./extensions) will be used.
*
* @param directory Path to the extensions directory. If the path is empty, the existing settings will continue to be used (if the existing
* @param[in] directory Path to the extensions directory. If the path is empty, the existing settings will continue to be used (if the existing
*/
static void setExtensionsDirectory(const char *directory) {
ob_error *error = nullptr;
@@ -30,24 +30,24 @@ class DevicePresetList;
class OBDepthWorkModeList;
class CameraParamList;
class DeviceFrameInterleaveList;
class PresetResolutionConfigeList;
class PresetResolutionConfigList;
class Device {
public:
/**
* @brief Callback function for device firmware update progress
*
* @param state The device firmware update status.
* @param message Status information.
* @param percent The percentage of the update progress.
* @param[in] state The device firmware update status.
* @param[in] message Status information.
* @param[in] percent The percentage of the update progress.
*/
typedef std::function<void(OBFwUpdateState state, const char *message, uint8_t percent)> DeviceFwUpdateCallback;
/**
* @brief Callback function for device status updates.
*
* @param state The device status.
* @param message Status information.
* @param[in] state The device status.
* @param[in] message Status information.
*/
typedef std::function<void(OBDeviceState state, const char *message)> DeviceStateChangedCallback;
@@ -105,7 +105,8 @@ public:
/**
* @brief Check if the extension information is exist
*
* @param infoKey The key of the extension information
* @param[in] infoKey The key of the extension information
*
* @return bool Whether the extension information exists
*/
bool isExtensionInfoExist(const std::string &infoKey) const {
@@ -118,7 +119,8 @@ public:
/**
* @brief Get information about extensions obtained from SDK supported by the device
*
* @param infoKey The key of the extension information
* @param[in] infoKey The key of the extension information
*
* @return const char* Returns extended information about the device
*/
const char *getExtensionInfo(const std::string &infoKey) const {
@@ -156,8 +158,8 @@ public:
/**
* @brief Set int type of device property
*
* @param propertyId Property id
* @param value Property value to be set
* @param[in] propertyId Property id
* @param[in] value Property value to be set
*/
void setIntProperty(OBPropertyID propertyId, int32_t value) const {
ob_error *error = nullptr;
@@ -168,8 +170,8 @@ public:
/**
* @brief Set float type of device property
*
* @param propertyId Property id
* @param value Property value to be set
* @param[in] propertyId Property id
* @param[in] value Property value to be set
*/
void setFloatProperty(OBPropertyID propertyId, float value) const {
ob_error *error = nullptr;
@@ -180,8 +182,8 @@ public:
/**
* @brief Set bool type of device property
*
* @param propertyId Property id
* @param value Property value to be set
* @param[in] propertyId Property id
* @param[in] value Property value to be set
*/
void setBoolProperty(OBPropertyID propertyId, bool value) const {
ob_error *error = nullptr;
@@ -192,7 +194,8 @@ public:
/**
* @brief Get int type of device property
*
* @param propertyId Property id
* @param[in] propertyId Property id
*
* @return int32_t Property to get
*/
int32_t getIntProperty(OBPropertyID propertyId) const {
@@ -205,7 +208,8 @@ public:
/**
* @brief Get float type of device property
*
* @param propertyId Property id
* @param[in] propertyId Property id
*
* @return float Property to get
*/
float getFloatProperty(OBPropertyID propertyId) const {
@@ -218,7 +222,8 @@ public:
/**
* @brief Get bool type of device property
*
* @param propertyId Property id
* @param[in] propertyId Property id
*
* @return bool Property to get
*/
bool getBoolProperty(OBPropertyID propertyId) const {
@@ -231,7 +236,8 @@ public:
/**
* @brief Get int type device property range (including current value and default value)
*
* @param propertyId Property id
* @param[in] propertyId Property id
*
* @return OBIntPropertyRange Property range
*/
OBIntPropertyRange getIntPropertyRange(OBPropertyID propertyId) const {
@@ -244,7 +250,8 @@ public:
/**
* @brief Get float type device property range((including current value and default value)
*
* @param propertyId Property id
* @param[in] propertyId Property id
*
* @return OBFloatPropertyRange Property range
*/
OBFloatPropertyRange getFloatPropertyRange(OBPropertyID propertyId) const {
@@ -257,7 +264,8 @@ public:
/**
* @brief Get bool type device property range (including current value and default value)
*
* @param propertyId The ID of the property
* @param[in] propertyId The ID of the property
*
* @return OBBoolPropertyRange The range of the property
*/
OBBoolPropertyRange getBoolPropertyRange(OBPropertyID propertyId) const {
@@ -270,9 +278,9 @@ public:
/**
* @brief Set the structured data type of a device property
*
* @param propertyId The ID of the property
* @param data The data to set
* @param dataSize The size of the data to set
* @param[in] propertyId The ID of the property
* @param[in] data The data to set
* @param[in] dataSize The size of the data to set
*/
void setStructuredData(OBPropertyID propertyId, const uint8_t *data, uint32_t dataSize) const {
ob_error *error = nullptr;
@@ -283,9 +291,9 @@ public:
/**
* @brief Get the structured data type of a device property
*
* @param propertyId The ID of the property
* @param data The property data obtained
* @param dataSize The size of the data obtained
* @param[in] propertyId The ID of the property
* @param[out] data The property data obtained
* @param[out] dataSize The size of the data obtained
*/
void getStructuredData(OBPropertyID propertyId, uint8_t *data, uint32_t *dataSize) const {
ob_error *error = nullptr;
@@ -296,8 +304,8 @@ public:
/**
* @brief Set the customer data type of a device property
*
* @param data The data to set
* @param dataSize The size of the data to set,the maximum length cannot exceed 65532 bytes.
* @param[in] data The data to set
* @param[in] dataSize The size of the data to set,the maximum length cannot exceed 65532 bytes.
*/
void writeCustomerData(const void *data, uint32_t dataSize) {
ob_error *error = nullptr;
@@ -308,8 +316,8 @@ public:
/**
* @brief Get the customer data type of a device property
*
* @param data The property data obtained
* @param dataSize The size of the data obtained
* @param[in] data The property data obtained
* @param[in] dataSize The size of the data obtained
*/
void readCustomerData(void *data, uint32_t *dataSize) {
ob_error *error = nullptr;
@@ -332,7 +340,8 @@ public:
/**
* @brief Get the supported properties of the device
*
* @param index The index of the property
* @param[in] index The index of the property
*
* @return The type of supported property
*/
OBPropertyItem getSupportedProperty(uint32_t index) const {
@@ -345,8 +354,9 @@ public:
/**
* @brief Check if a property permission is supported
*
* @param propertyId The ID of the property
* @param permission The read and write permissions to check
* @param[in] propertyId The ID of the property
* @param[in] permission The read and write permissions to check
*
* @return Whether the property permission is supported
*/
bool isPropertySupported(OBPropertyID propertyId, OBPermissionType permission) const {
@@ -371,7 +381,7 @@ public:
/**
* @brief Enable or disable the global timestamp
*
* @param enable Whether to enable the global timestamp
* @param[in] enable Whether to enable the global timestamp
*/
void enableGlobalTimestamp(bool enable) {
ob_error *error = nullptr;
@@ -382,9 +392,9 @@ public:
/**
* @brief Update the device firmware
*
* @param filePath Firmware path
* @param callback Firmware Update progress and status callback
* @param async Whether to execute asynchronously
* @param[in] filePath Firmware path
* @param[in] callback Firmware Update progress and status callback
* @param[in] async Whether to execute asynchronously
*/
void updateFirmware(const char *filePath, DeviceFwUpdateCallback callback, bool async = true) {
ob_error *error = nullptr;
@@ -396,10 +406,10 @@ public:
/**
* @brief Update the device firmware from data
*
* @param firmwareData Firmware data
* @param firmwareDataSize Firmware data size
* @param callback Firmware Update progress and status callback
* @param async Whether to execute asynchronously
* @param[in] firmwareData Firmware data
* @param[in] firmwareDataSize Firmware data size
* @param[in] callback Firmware Update progress and status callback
* @param[in] async Whether to execute asynchronously
*/
void updateFirmwareFromData(const uint8_t *firmwareData, uint32_t firmwareDataSize, DeviceFwUpdateCallback callback, bool async = true) {
ob_error *error = nullptr;
@@ -411,9 +421,9 @@ public:
/**
* @brief Update the device optional depth presets
*
* @param filePathList A list(2D array) of preset file paths, each up to OB_PATH_MAX characters.
* @param pathCount The number of the preset file paths.
* @param callback Preset update progress and status callback
* @param[in] filePathList A list(2D array) of preset file paths, each up to OB_PATH_MAX characters.
* @param[in] pathCount The number of the preset file paths.
* @param[in] callback Preset update progress and status callback
*/
void updateOptionalDepthPresets(const char filePathList[][OB_PATH_MAX], uint8_t pathCount, DeviceFwUpdateCallback callback) {
ob_error *error = nullptr;
@@ -425,7 +435,7 @@ public:
/**
* @brief Set the device state changed callbacks
*
* @param callback The callback function that is triggered when the device status changes (for example, the frame rate is automatically reduced or the
* @param[in] callback The callback function that is triggered when the device status changes (for example, the frame rate is automatically reduced or the
* stream is closed due to high temperature, etc.)
*/
void setDeviceStateChangedCallback(DeviceStateChangedCallback callback) {
@@ -455,6 +465,7 @@ public:
/**
* @brief Get current depth mode name
* @brief According the current preset name to return current depth mode name
*
* @return const char* return the current depth mode name.
*/
const char *getCurrentDepthModeName() {
@@ -490,6 +501,7 @@ public:
/**
* @brief Request support depth work mode list
*
* @return OBDepthWorkModeList list of ob_depth_work_mode
*/
std::shared_ptr<OBDepthWorkModeList> getDepthWorkModeList() const {
@@ -588,7 +600,7 @@ public:
* OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING
*
* @attention The frequency of the user call this function multiplied by the number of frames per trigger should be less than the frame rate of the stream.
* The number of frames per trigger can be set by @ref framesPerTrigger.
* The number of frames per trigger can be set by @ref OBMultiDeviceSyncConfig::framesPerTrigger.
* @attention For some models, receive and execute the capture command will have a certain delay and performance consumption, so the frequency of calling
* this function should not be too high, please refer to the product manual for the specific supported frequency.
* @attention If the device is not in the @ref OB_MULTI_DEVICE_SYNC_MODE_HARDWARE_TRIGGERING mode, device will ignore the capture command.
@@ -638,9 +650,11 @@ public:
}
/**
* @brief Alias for @ref timestampReset since it is more accurate.
* @brief Alias for @ref timestampReset() since it is more accurate.
*/
#define timerReset timestampReset
inline void timerReset() const {
timestampReset();
}
/**
* @brief synchronize the timer of the device with the host.
@@ -662,6 +676,7 @@ public:
/**
* @brief Get current preset name
* @brief The preset mean a set of parameters or configurations that can be applied to the device to achieve a specific effect or function.
*
* @return const char* return the current preset name, it should be one of the preset names returned by @ref getAvailablePresetList.
*/
const char *getCurrentPresetName() const {
@@ -675,7 +690,7 @@ public:
* @brief load the preset according to the preset name.
* @attention After loading the preset, the settings in the preset will set to the device immediately. Therefore, it is recommended to re-read the device
* settings to update the user program temporarily.
* @param presetName The preset name to set. The name should be one of the preset names returned by @ref getAvailablePresetList.
* @param[in] presetName The preset name to set. The name should be one of the preset names returned by @ref getAvailablePresetList.
*/
void loadPreset(const char *presetName) const {
ob_error *error = nullptr;
@@ -705,7 +720,7 @@ public:
* @attention The user should ensure that the custom preset file is adapted to the device and the settings in the file are valid.
* @attention It is recommended to re-read the device settings to update the user program temporarily after successfully loading the custom preset.
*
* @param filePath The path of the custom preset file.
* @param[in] filePath The path of the custom preset file.
*/
void loadPresetFromJsonFile(const char *filePath) const {
ob_error *error = nullptr;
@@ -716,13 +731,14 @@ public:
/**
* @brief Load custom preset from data.
* @brief After loading the custom preset, the settings in the custom preset will set to the device immediately.
* @brief After loading the custom preset, the available preset list will be appended with the custom preset and named as the @ref presetName.
* @brief After loading the custom preset, the available preset list will be appended with the custom preset and named as the @p presetName.
*
* @attention The user should ensure that the custom preset data is adapted to the device and the settings in the data are valid.
* @attention It is recommended to re-read the device settings to update the user program temporarily after successfully loading the custom preset.
*
* @param data The custom preset data.
* @param size The size of the custom preset data.
* @param[in] presetName The name of the custome preset.
* @param[in] data The custom preset data.
* @param[in] size The size of the custom preset data.
*/
void loadPresetFromJsonData(const char *presetName, const uint8_t *data, uint32_t size) {
ob_error *error = nullptr;
@@ -731,12 +747,13 @@ public:
/**
* @brief Export current device settings as a preset json data.
* @brief After exporting the preset, a new preset named as the @ref presetName will be added to the available preset list.
* @brief After exporting the preset, a new preset named as the @p presetName will be added to the available preset list.
*
* @attention The memory of the data is allocated by the SDK, and will automatically be released by the SDK.
* @attention The memory of the data will be reused by the SDK on the next call, so the user should copy the data to a new buffer if it needs to be
* preserved.
*
* @param[in] presetName The name of the custome preset.
* @param[out] data return the preset json data.
* @param[out] dataSize return the size of the preset json data.
*/
@@ -748,9 +765,9 @@ public:
/**
* @brief Export current device settings as a preset json file.
* @brief The exported preset file can be loaded by calling @ref loadPresetFromJsonFile to restore the device setting.
* @brief After exporting the preset, a new preset named as the @ref filePath will be added to the available preset list.
* @brief After exporting the preset, a new preset named as the @p filePath will be added to the available preset list.
*
* @param filePath The path of the preset file to be exported.
* @param[in] filePath The path of the preset file to be exported.
*/
void exportSettingsAsPresetJsonFile(const char *filePath) const {
ob_error *error = nullptr;
@@ -802,7 +819,7 @@ public:
/**
* @brief load the frame interleave according to frame interleave name.
* @param frameInterleaveName The frame interleave name to set. The name should be one of the frame interleave names returned by @ref
* @param[in] frameInterleaveName The frame interleave name to set. The name should be one of the frame interleave names returned by @ref
* getAvailableFrameInterleaveList.
*/
void loadFrameInterleave(const char *frameInterleaveName) const {
@@ -824,15 +841,15 @@ public:
}
/**
* @brief Get available frame interleave list
* @brief Get the available preset resolution config list
*
* @return DeviceFrameInterleaveList return the available frame interleave list.
* @return PresetResolutionConfigList return the available preset resolution config list.
*/
std::shared_ptr<PresetResolutionConfigeList> getAvailablePresetResolutionConfigeList() const {
std::shared_ptr<PresetResolutionConfigList> getAvailablePresetResolutionConfigList() const {
ob_error *error = nullptr;
auto list = ob_device_get_available_preset_resolution_config_list(impl_, &error);
Error::handle(&error);
return std::make_shared<PresetResolutionConfigeList>(list);
return std::make_shared<PresetResolutionConfigList>(list);
}
private:
@@ -1028,6 +1045,30 @@ public:
return type;
}
/**
* @brief Get the subnet mask of the device
*
* @return const char* the subnet mask of the device, such as "255.255.255.0"
*/
const char *getDeviceSubnetMask() const {
ob_error *error = nullptr;
const char *subnetMask = ob_device_info_get_subnet_mask(impl_, &error);
Error::handle(&error);
return subnetMask;
}
/**
* @brief Get the gateway address of the device
*
* @return const char* the gateway address of the device, such as "192.168.1.1"
*/
const char *getDevicegateway() const {
ob_error *error = nullptr;
const char *subnetMask = ob_device_info_get_gateway(impl_, &error);
Error::handle(&error);
return subnetMask;
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
const char *name() const {
@@ -1109,7 +1150,8 @@ public:
/**
* @brief Get the PID of the device at the specified index
*
* @param index the index of the device
* @param[in] index the index of the device
*
* @return int the PID of the device
*/
int getPid(uint32_t index) const {
@@ -1122,7 +1164,8 @@ public:
/**
* @brief Get the VID of the device at the specified index
*
* @param index the index of the device
* @param[in] index the index of the device
*
* @return int the VID of the device
*/
int getVid(uint32_t index) const {
@@ -1135,7 +1178,8 @@ public:
/**
* @brief Get the UID of the device at the specified index
*
* @param index the index of the device
* @param[in] index the index of the device
*
* @return const char* the UID of the device
*/
const char *getUid(uint32_t index) const {
@@ -1148,7 +1192,8 @@ public:
/**
* @brief Get the serial number of the device at the specified index
*
* @param index the index of the device
* @param[in] index the index of the device
*
* @return const char* the serial number of the device
*/
const char *getSerialNumber(uint32_t index) const {
@@ -1164,7 +1209,8 @@ public:
* This function retrieves the name of the device at the given index in the device list.
* If an error occurs during the operation, it will be handled by the Error::handle function.
*
* @param index The index of the device in the device list.
* @param[in] index The index of the device in the device list.
*
* @return const char* The name of the device at the specified index.
*/
const char *getName(uint32_t index) const {
@@ -1177,7 +1223,8 @@ public:
/**
* @brief Get device connection type
*
* @param index device index
* @param[in] index device index
*
* @return const char* returns connection type, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2", "Ethernet"
*/
const char *getConnectionType(uint32_t index) const {
@@ -1192,7 +1239,8 @@ public:
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param index the index of the device
* @param[in] index the index of the device
*
* @return const char* the ip address of the device
*/
const char *getIpAddress(uint32_t index) const {
@@ -1203,26 +1251,108 @@ public:
}
/**
* @brief get the local mac address of the device at the specified index
* @brief get the subnet mask of the device at the specified index
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param[in] index the index of the device
*
* @return const char* the subnet mask of the device
*/
const char *getSubnetMask(uint32_t index) const {
ob_error *error = nullptr;
auto subnetMask = ob_device_list_get_device_subnet_mask(impl_, index, &error);
Error::handle(&error);
return subnetMask;
}
/**
* @brief get the gateway of the device at the specified index
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param[in] index the index of the device
*
* @return const char* the gateway of the device
*/
const char *getGateway(uint32_t index) const {
ob_error *error = nullptr;
auto gateway = ob_device_list_get_device_gateway(impl_, index, &error);
Error::handle(&error);
return gateway;
}
/**
* @brief Get the MAC address of the host network interface corresponding to the device at the specified index
*
* @attention Only valid for network devices, otherwise it will return "0:0:0:0:0:0".
*
* @param index the index of the device
* @return const char* the local mac address of the device
* @param[in] index the index of the device
*
* @return const char* The MAC address of the host network interface associated with the device.
*/
const char *getLocalMacAddress(uint32_t index) const {
ob_error *error = nullptr;
auto mac = ob_device_list_get_device_local_mac(impl_, index, &error);
auto mac = ob_device_list_get_device_local_mac(impl_, index, &error);
Error::handle(&error);
return mac;
}
/**
* @brief Get the IP address of the host network interface corresponding to the device at the specified index
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param[in] index The index of the device
*
* @return const char* The IP address of the host network interface associated with the device.
*/
const char *getLocalIP(uint32_t index) const {
ob_error *error = nullptr;
auto ip = ob_device_list_get_device_local_ip(impl_, index, &error);
Error::handle(&error);
return ip;
}
/**
* @brief Get the subnet length of the host network interface corresponding to the device at the specified index
*
* @attention Only valid for network devices, otherwise it will return 0.
*
* @param[in] index The index of the device
*
* @return uint8_t The subnet length (0~32) of the host network interface associated with the device.
*/
uint8_t getLocalSubnetLength(uint32_t index) const {
ob_error *error = nullptr;
auto subnetMask = ob_device_list_get_device_local_subnet_length(impl_, index, &error);
Error::handle(&error);
return subnetMask;
}
/**
* @brief Get the gateway of the host network interface corresponding to the device at the specified index
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param[in] index The index of the device
*
* @return const char* The gateway of the host network interface associated with the device.
*/
const char *getLocalGateway(uint32_t index) const {
ob_error *error = nullptr;
auto gateway = ob_device_list_get_device_local_gateway(impl_, index, &error);
Error::handle(&error);
return gateway;
}
/**
* @brief Get the device object at the specified index
*
* @attention If the device has already been acquired and created elsewhere, repeated acquisition will throw an exception
*
* @param index the index of the device to create
* @param[in] index the index of the device to create
*
* @return std::shared_ptr<Device> the device object
*/
std::shared_ptr<Device> getDevice(uint32_t index) const {
@@ -1237,7 +1367,8 @@ public:
*
* @attention If the device has already been acquired and created elsewhere, repeated acquisition will throw an exception
*
* @param serialNumber the serial number of the device to create
* @param[in] serialNumber the serial number of the device to create
*
* @return std::shared_ptr<Device> the device object
*/
std::shared_ptr<Device> getDeviceBySN(const char *serialNumber) const {
@@ -1256,7 +1387,8 @@ public:
*
* @attention If the device has been acquired and created elsewhere, repeated acquisition will throw an exception
*
* @param uid The uid of the device to be created
* @param[in] uid The uid of the device to be created
*
* @return std::shared_ptr<Device> returns the device object
*/
std::shared_ptr<Device> getDeviceByUid(const char *uid) const {
@@ -1328,7 +1460,8 @@ public:
/**
* @brief Get the OBDepthWorkMode object at the specified index
*
* @param index the index of the target OBDepthWorkMode object
* @param[in] index the index of the target OBDepthWorkMode object
*
* @return OBDepthWorkMode the OBDepthWorkMode object at the specified index
*/
OBDepthWorkMode getOBDepthWorkMode(uint32_t index) {
@@ -1341,7 +1474,8 @@ public:
/**
* @brief Get the OBDepthWorkMode object at the specified index
*
* @param index the index of the target OBDepthWorkMode object
* @param[in] index the index of the target OBDepthWorkMode object
*
* @return OBDepthWorkMode the OBDepthWorkMode object at the specified index
*/
OBDepthWorkMode operator[](uint32_t index) {
@@ -1386,7 +1520,8 @@ public:
/**
* @brief Get the name of the device preset at the specified index
*
* @param index the index of the device preset
* @param[in] index the index of the device preset
*
* @return const char* the name of the device preset
*/
const char *getName(uint32_t index) {
@@ -1398,7 +1533,8 @@ public:
/**
* @brief check if the preset list contains the special name preset.
* @param name The name of the preset
* @param[in] name The name of the preset
*
* @return bool Returns true if the special name is found in the preset list, otherwise returns false.
*/
bool hasPreset(const char *name) {
@@ -1445,7 +1581,8 @@ public:
/**
* @brief Get the camera parameters for the specified index
*
* @param index the index of the parameter group
* @param[in] index the index of the parameter group
*
* @return OBCameraParam the corresponding group parameters
*/
OBCameraParam getCameraParam(uint32_t index) {
@@ -1492,7 +1629,8 @@ public:
/**
* @brief Get the name of the device frame interleave at the specified index
*
* @param index the index of the device frame interleave
* @param[in] index the index of the device frame interleave
*
* @return const char* the name of the device frame interleave
*/
const char *getName(uint32_t index) {
@@ -1504,7 +1642,9 @@ public:
/**
* @brief check if the frame interleave list contains the special name frame interleave.
* @param name The name of the frame interleave
*
* @param[in] name The name of the frame interleave
*
* @return bool Returns true if the special name is found in the frame interleave list, otherwise returns false.
*/
bool hasFrameInterleave(const char *name) {
@@ -1516,15 +1656,15 @@ public:
};
/**
* @brief Class representing a list of device Frame Interleave
* @brief Class representing a list of preset resolution config list
*/
class PresetResolutionConfigeList {
class PresetResolutionConfigList {
private:
ob_preset_resolution_config_list_t *impl_ = nullptr;
public:
explicit PresetResolutionConfigeList(ob_preset_resolution_config_list_t *impl) : impl_(impl) {}
~PresetResolutionConfigeList() noexcept {
explicit PresetResolutionConfigList(ob_preset_resolution_config_list_t *impl) : impl_(impl) {}
~PresetResolutionConfigList() noexcept {
ob_error *error = nullptr;
ob_delete_preset_resolution_config_list(impl_, &error);
Error::handle(&error, false);
@@ -1542,7 +1682,9 @@ public:
/*
* @brief Get the device preset resolution ratio at the specified index
* @param index the index of the device preset resolution ratio
* @param[in] index the index of the device preset resolution ratio
*
* @return OBPresetResolutionConfig the corresponding device preset resolution ratio
*/
OBPresetResolutionConfig getPresetResolutionRatioConfig(uint32_t index) {
@@ -22,7 +22,7 @@ private:
*
* @attention This constructor should not be called directly, use the handle() function instead.
*
* @param error The ob_error object
* @param[in] error The ob_error object
*/
explicit Error(ob_error *error) : impl_(error) {};
@@ -32,8 +32,8 @@ public:
/**
* @brief A static function to handle the ob_error and throw an exception if needed.
*
* @param error The ob_error pointer to be handled.
* @param throw_exception A boolean value to indicate whether to throw an exception or not, the default value is true.
* @param[in,out] error The ob_error pointer to be handled.
* @param[in] throw_exception A boolean value to indicate whether to throw an exception or not, the default value is true.
*/
static void handle(ob_error **error, bool throw_exception = true) {
if(!error || !*error) { // no error
@@ -171,7 +171,8 @@ public:
/**
* @brief Processes a frame synchronously.
*
* @param frame The frame to be processed.
* @param[in] frame The frame to be processed.
*
* @return std::shared_ptr< Frame > The processed frame.
*/
virtual std::shared_ptr<Frame> process(std::shared_ptr<const Frame> frame) const {
@@ -187,7 +188,7 @@ public:
/**
* @brief Pushes the pending frame into the cache for asynchronous processing.
*
* @param frame The pending frame. The processing result is returned by the callback function.
* @param[in] frame The pending frame. The processing result is returned by the callback function.
*/
virtual void pushFrame(std::shared_ptr<Frame> frame) const {
ob_error *error = nullptr;
@@ -198,7 +199,7 @@ public:
/**
* @brief Set the callback function for asynchronous processing.
*
* @param callback The processing result callback.
* @param[in] callback The processing result callback.
*/
virtual void setCallBack(FilterCallback callback) {
callback_ = callback;
@@ -210,7 +211,8 @@ public:
/**
* @brief Get config schema of the filter
* @brief The returned string is a csv format string representing the configuration schema of the filter. The format of the string is:
* <parameter_name>, <parameter_type: "int", "float", "bool">, <minimum_value>, <maximum_value>, <value_step>, <default_value>, <parameter_description>
* `<parameter_name>`, `<parameter_type: "int", "float", "bool">`, `<minimum_value>`, `<maximum_value>`, `<value_step>`, `<default_value>`,
* `<parameter_description>`
*
* @return std::string The config schema of the filter.
*/
@@ -237,8 +239,8 @@ public:
* @attention The pass into value type is double, witch will be cast to the actual type inside the filter. The actual type can be queried by the filter
* config schema returned by @ref getConfigSchemaVec.
*
* @param configName The name of the config.
* @param value The value of the config.
* @param[in] configName The name of the config.
* @param[in] value The value of the config.
*/
virtual void setConfigValue(const std::string &configName, double value) const {
ob_error *error = nullptr;
@@ -252,7 +254,8 @@ public:
* @attention The returned value type has been casted to double inside the filter. The actual type can be queried by the filter config schema returned by
* @ref getConfigSchemaVec.
*
* @param configName The name of the config.
* @param[in] configName The name of the config.
*
* @return double The value of the config.
*/
virtual double getConfigValue(const std::string &configName) const {
@@ -278,6 +281,7 @@ public:
* @brief Check if the runtime type of the filter object is compatible with a given type.
*
* @tparam T The given type.
*
* @return bool The result.
*/
template <typename T> bool is();
@@ -310,8 +314,8 @@ public:
* @brief Create a private filter by name and activation key.
* @brief Some private filters require an activation key to be activated, its depends on the vendor of the filter.
*
* @param name The name of the filter.
* @param activationKey The activation key of the filter.
* @param[in] name The name of the filter.
* @param[in] activationKey The activation key of the filter.
*/
static std::shared_ptr<Filter> createPrivateFilter(const std::string &name, const std::string &activationKey) {
ob_error *error = nullptr;
@@ -324,7 +328,8 @@ public:
* @brief Get the vendor specific code of a filter by filter name.
* @brief A private filter can define its own vendor specific code for specific purposes.
*
* @param name The name of the filter.
* @param[in] name The name of the filter.
*
* @return std::string The vendor specific code of the filter.
*/
static std::string getFilterVendorSpecificCode(const std::string &name) {
@@ -352,7 +357,7 @@ public:
/**
* @brief Set the output pointcloud frame format.
*
* @param format The point cloud frame format: OB_FORMAT_POINT or OB_FORMAT_RGB_POINT
* @param[in] format The point cloud frame format: OB_FORMAT_POINT or OB_FORMAT_RGB_POINT
*/
void setCreatePointFormat(OBFormat format) {
setConfigValue("pointFormat", static_cast<double>(format));
@@ -364,7 +369,7 @@ public:
* @brief Calling this function to set the scale will change the point coordinate scaling factor of the output point cloud frame, The point coordinate
* scaling factor for the output point cloud frame can be obtained via @ref PointsFrame::getCoordinateValueScale function.
*
* @param factor The scale factor.
* @param[in] factor The scale factor.
*/
void setCoordinateDataScaled(float factor) {
setConfigValue("coordinateDataScale", factor);
@@ -376,7 +381,7 @@ public:
*
* @attention This function only works for when create point format is set to OB_FORMAT_RGB_POINT.
*
* @param state Whether normalization is required.
* @param[in] state Whether normalization is required.
*/
void setColorDataNormalization(bool state) {
setConfigValue("colorDataNormalization", state);
@@ -385,7 +390,7 @@ public:
/**
* @brief Set the point cloud coordinate system.
*
* @param type The coordinate system type.
* @param[in] type The coordinate system type.
*/
void setCoordinateSystem(OBCoordinateSystemType type) {
setConfigValue("coordinateSystemType", static_cast<double>(type));
@@ -434,7 +439,7 @@ public:
* the aspect ratio of the target resolution.
*
*
* @param state If true, output frame resolution will match the target resolution; otherwise, it will
* @param[in] state If true, output frame resolution will match the target resolution; otherwise, it will
* maintain the original resolution with the target's aspect ratio.
*/
void setMatchTargetResolution(bool state) {
@@ -445,7 +450,7 @@ public:
* @brief Set the Align To Stream Profile
* @brief It is useful when the align target stream dose not started (without any frame to get intrinsics and extrinsics).
*
* @param profile The Align To Stream Profile.
* @param[in] profile The Align To Stream Profile.
*/
void setAlignToStreamProfile(std::shared_ptr<const StreamProfile> profile) {
ob_error *error = nullptr;
@@ -471,7 +476,7 @@ public:
/**
* @brief Set the format conversion type.
*
* @param type The format conversion type.
* @param[in] type The format conversion type.
*/
void setFormatConvertType(OBConvertFormat type) {
setConfigValue("convertType", static_cast<double>(type));
@@ -534,7 +539,7 @@ public:
/**
* @brief Set the sequenceId filter params.
*
* @param sequence_id id to pass the filter.
* @param[in] sequence_id id to pass the filter.
*/
void selectSequenceId(int sequence_id) {
setConfigValue("sequenceid", static_cast<double>(sequence_id));
@@ -580,7 +585,7 @@ public:
/**
* @brief Set the decimation filter scale value.
*
* @param value The decimation filter scale value.
* @param[in] value The decimation filter scale value.
*/
void setScaleValue(uint8_t value) {
setConfigValue("decimate", static_cast<double>(value));
@@ -769,7 +774,7 @@ public:
/**
* @brief Set the spatial advanced filter params.
*
* @param params OBSpatialAdvancedFilterParams.
* @param[in] params OBSpatialAdvancedFilterParams.
*/
void setFilterParams(OBSpatialAdvancedFilterParams params) {
setConfigValue("alpha", params.alpha);
@@ -779,6 +784,150 @@ public:
}
};
/**
* @brief The Spatial Fast Filter utilizes an enhanced median smoothing algorithm,
* designed to significantly reduce CPU usage and optimize processing efficiency.
*/
class SpatialFastFilter : public Filter {
public:
SpatialFastFilter(const std::string &activationKey = "") {
ob_error *error = nullptr;
auto impl = ob_create_private_filter("SpatialFastFilter", activationKey.c_str(), &error);
Error::handle(&error);
init(impl);
}
virtual ~SpatialFastFilter() noexcept override = default;
/**
* @brief Get the spatial fast filter radius range.
*
* @return OBIntPropertyRange the radius value of property range.
*/
OBIntPropertyRange getRadiusRange() {
OBIntPropertyRange range{};
const auto &schemaVec = getConfigSchemaVec();
for(const auto &item: schemaVec) {
if(strcmp(item.name, "radius") == 0) {
range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("radius"));
break;
}
}
return range;
}
/**
* @brief Get the spatial fast filter params.
*
* @return OBSpatialFastFilterParams
*/
OBSpatialFastFilterParams getFilterParams() {
OBSpatialFastFilterParams params{};
params.radius = static_cast<uint8_t>(getConfigValue("radius"));
return params;
}
/**
* @brief Set the spatial fast filter params.
*
* @param[in] params OBSpatialFastFilterParams.
*/
void setFilterParams(OBSpatialFastFilterParams params) {
setConfigValue("radius", params.radius);
}
};
/**
* @brief The Spatial Moderate Filter utilizes an optimized average smoothing algorithm,
* to achieve a balance between processing speed and the quality of smoothing achieved.
*/
class SpatialModerateFilter : public Filter {
public:
SpatialModerateFilter(const std::string &activationKey = "") {
ob_error *error = nullptr;
auto impl = ob_create_private_filter("SpatialModerateFilter", activationKey.c_str(), &error);
Error::handle(&error);
init(impl);
}
virtual ~SpatialModerateFilter() noexcept override = default;
/**
* @brief Get the spatial moderate filter magnitude range.
*
* @return OBIntPropertyRange the magnitude value of property range.
*/
OBIntPropertyRange getMagnitudeRange() {
OBIntPropertyRange range{};
const auto &schemaVec = getConfigSchemaVec();
for(const auto &item: schemaVec) {
if(strcmp(item.name, "magnitude") == 0) {
range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("magnitude"));
break;
}
}
return range;
}
/**
* @brief Get the spatial moderate filter radius range.
*
* @return OBIntPropertyRange the radius value of property range.
*/
OBIntPropertyRange getRadiusRange() {
OBIntPropertyRange range{};
const auto &schemaVec = getConfigSchemaVec();
for(const auto &item: schemaVec) {
if(strcmp(item.name, "radius") == 0) {
range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("radius"));
break;
}
}
return range;
}
/**
* @brief Get the spatial moderate filter disp diff range.
*
* @return OBIntPropertyRange the disp diff value of property range.
*/
OBIntPropertyRange getDispDiffRange() {
OBIntPropertyRange range{};
const auto &schemaVec = getConfigSchemaVec();
for(const auto &item: schemaVec) {
if(strcmp(item.name, "disp_diff") == 0) {
range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("disp_diff"));
break;
}
}
return range;
}
/**
* @brief Get the spatial moderate filter params.
*
* @return OBSpatialModerateFilterParams
*/
OBSpatialModerateFilterParams getFilterParams() {
OBSpatialModerateFilterParams params{};
params.magnitude = static_cast<uint8_t>(getConfigValue("magnitude"));
params.radius = static_cast<uint8_t>(getConfigValue("radius"));
params.disp_diff = static_cast<uint16_t>(getConfigValue("disp_diff"));
return params;
}
/**
* @brief Set the spatial moderate filter params.
*
* @param[in] params OBSpatialModerateFilterParams.
*/
void setFilterParams(OBSpatialModerateFilterParams params) {
setConfigValue("magnitude", params.magnitude);
setConfigValue("radius", params.radius);
setConfigValue("disp_diff", params.disp_diff);
}
};
/**
* @brief Hole filling filter,the processing performed depends on the selected hole filling mode.
*/
@@ -796,7 +945,7 @@ public:
/**
* @brief Set the HoleFillingFilter mode.
*
* @param mode OBHoleFillingMode, OB_HOLE_FILL_TOP,OB_HOLE_FILL_NEAREST or OB_HOLE_FILL_FAREST.
* @param[in] mode OBHoleFillingMode, OB_HOLE_FILL_TOP,OB_HOLE_FILL_NEAREST or OB_HOLE_FILL_FAREST.
*/
void setFilterMode(OBHoleFillingMode mode) {
setConfigValue("hole_filling_mode", static_cast<double>(mode));
@@ -917,7 +1066,7 @@ public:
/**
* @brief Set the TemporalFilter diffscale value.
*
* @param value diffscale value.
* @param[in] value diffscale value.
*/
void setDiffScale(float value) {
setConfigValue("diff_scale", static_cast<double>(value));
@@ -943,7 +1092,7 @@ public:
/**
* @brief Set the TemporalFilter weight value.
*
* @param value weight value.
* @param[in] value weight value.
*/
void setWeight(float value) {
setConfigValue("weight", static_cast<double>(value));
@@ -993,7 +1142,8 @@ public:
/**
* @brief Get the Filter object at the specified index
*
* @param index The filter index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown.
* @param[in] index The filter index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown.
*
* @return std::shared_ptr<Filter> The filter object.
*/
std::shared_ptr<Filter> getFilter(uint32_t index) {
@@ -1011,24 +1161,33 @@ public:
};
/**
* @brief Define the Filter type map
* @brief Returns the mapping of filter type names to their corresponding type_index.
*/
static const std::unordered_map<std::string, std::type_index> obFilterTypeMap = {
{ "PointCloudFilter", typeid(PointCloudFilter) }, { "Align", typeid(Align) },
{ "FormatConverter", typeid(FormatConvertFilter) }, { "HDRMerge", typeid(HdrMerge) },
{ "SequenceIdFilter", typeid(SequenceIdFilter) }, { "DecimationFilter", typeid(DecimationFilter) },
{ "ThresholdFilter", typeid(ThresholdFilter) }, { "SpatialAdvancedFilter", typeid(SpatialAdvancedFilter) },
{ "HoleFillingFilter", typeid(HoleFillingFilter) }, { "NoiseRemovalFilter", typeid(NoiseRemovalFilter) },
{ "TemporalFilter", typeid(TemporalFilter) }, { "DisparityTransform", typeid(DisparityTransform) }
};
inline const std::unordered_map<std::string, std::type_index> &getFilterTypeMap() {
static const std::unordered_map<std::string, std::type_index> filterTypeMap = {
{ "PointCloudFilter", typeid(PointCloudFilter) }, { "Align", typeid(Align) },
{ "FormatConverter", typeid(FormatConvertFilter) }, { "HDRMerge", typeid(HdrMerge) },
{ "SequenceIdFilter", typeid(SequenceIdFilter) }, { "DecimationFilter", typeid(DecimationFilter) },
{ "ThresholdFilter", typeid(ThresholdFilter) }, { "SpatialAdvancedFilter", typeid(SpatialAdvancedFilter) },
{ "HoleFillingFilter", typeid(HoleFillingFilter) }, { "NoiseRemovalFilter", typeid(NoiseRemovalFilter) },
{ "TemporalFilter", typeid(TemporalFilter) }, { "DisparityTransform", typeid(DisparityTransform) },
{ "SpatialFastFilter", typeid(SpatialFastFilter) }, { "SpatialModerateFilter", typeid(SpatialModerateFilter) },
};
return filterTypeMap;
}
/**
* @brief Define the is() template function for the Filter class
*
* @note When adding a new filter class, ensure the filter type map
* (see getFilterTypeMap()) is updated accordingly to maintain correct type matching.
*/
template <typename T> bool Filter::is() {
std::string name = type();
auto it = obFilterTypeMap.find(name);
if(it != obFilterTypeMap.end()) {
const auto &filterTypeMap = getFilterTypeMap();
auto it = filterTypeMap.find(name);
if(it != filterTypeMap.end()) {
return std::type_index(typeid(T)) == it->second;
}
return false;
@@ -57,7 +57,7 @@ public:
* frame object is destroyed.
* @attention The internal frame object should not be deleted by the caller.
*
* @param impl The pointer to the internal frame object.
* @param[in] impl The pointer to the internal frame object.
*/
explicit Frame(const ob_frame *impl) : impl_(impl) {}
@@ -227,7 +227,8 @@ public:
/**
* @brief Check if the frame object has metadata of a given type.
*
* @param type The metadata type. refer to @ref OBFrameMetadataType
* @param[in] type The metadata type. refer to @ref OBFrameMetadataType
*
* @return bool The result.
*/
bool hasMetadata(OBFrameMetadataType type) const {
@@ -241,7 +242,8 @@ public:
/**
* @brief Get the metadata value
*
* @param type The metadata type. refer to @ref OBFrameMetadataType
* @param[in] type The metadata type. refer to @ref OBFrameMetadataType
*
* @return int64_t The metadata value.
*/
int64_t getMetadataValue(OBFrameMetadataType type) const {
@@ -294,6 +296,7 @@ public:
* @brief Check if the runtime type of the frame object is compatible with a given type.
*
* @tparam T The given type.
*
* @return bool The result.
*/
template <typename T> bool is() const;
@@ -302,6 +305,7 @@ public:
* @brief Convert the frame object to a target type.
*
* @tparam T The target type.
*
* @return std::shared_ptr<T> The result. If it cannot be converted, an exception will be thrown.
*/
template <typename T> std::shared_ptr<T> as() {
@@ -320,6 +324,7 @@ public:
* @brief Convert the frame object to a target type.
*
* @tparam T The target type.
*
* @return std::shared_ptr<T> The result. If it cannot be converted, an exception will be thrown.
*/
template <typename T> std::shared_ptr<const T> as() const {
@@ -334,6 +339,87 @@ public:
return std::make_shared<const T>(impl_);
}
/**
* @brief Copy the information of the source frame object to the destination frame object.
* @brief Including the index, timestamp, system timestamp, global timestamp and metadata will be copied.
*
* @param[in] srcFrame Source frame object to copy the information from.
*/
void copyFrameInfo(std::shared_ptr<const Frame> srcFrame) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_frame_copy_info(srcFrame->getImpl(), unConstImpl, &error);
Error::handle(&error);
}
/**
* @brief Set the system timestamp of the frame in microseconds.
*
* @param systemTimestampUs frame system timestamp to set in microseconds.
*/
void setSystemTimestampUs(uint64_t systemTimestampUs) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_frame_set_system_timestamp_us(unConstImpl, systemTimestampUs, &error);
Error::handle(&error);
}
/**
* @brief Update the data of a frame.
* @brief The data will be memcpy to the frame data buffer.
* @brief The frame data size will be also updated as the input data size.
*
* @attention It is not recommended to update the frame data if the frame was not created by the user. If you must update it, ensure that the frame is not
* being used in other threads.
* @attention The size of the new data should be equal to or less than the current data size of the frame. Exceeding the original size may cause memory
* exceptions.
*
* @param[in] data The new data to update the frame with.
* @param[in] dataSize The size of the new data.
*/
void updateData(const uint8_t *data, uint32_t dataSize) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_frame_update_data(unConstImpl, data, dataSize, &error);
Error::handle(&error);
}
/**
* @brief Update the metadata of the frame
* @brief The metadata will be memcpy to the frame metadata buffer.
* @brief The frame metadata size will be also updated as the input metadata size.
*
* @attention It is not recommended to update the frame metadata if the frame was not created by the user. If you must update it, ensure that the frame is
* not being used in other threads or future use.
* @attention The metadata size should be equal to or less than 256 bytes, otherwise it will cause memory exception.
*
* @param[in] metadata The new metadata to update.
* @param[in] metadataSize The size of the new metadata.
*/
void updateMetadata(const uint8_t *metadata, uint32_t metadataSize) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_frame_update_metadata(unConstImpl, metadata, metadataSize, &error);
Error::handle(&error);
}
/**
* @brief Set (override) the stream profile of the frame
*
* @param profile The stream profile to set for the frame.
*/
void setStreamProfile(std::shared_ptr<const StreamProfile> profile) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_frame_set_stream_profile(unConstImpl, profile->getImpl(), &error);
Error::handle(&error);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBFrameType type() const {
@@ -398,7 +484,7 @@ public:
* frame object is destroyed.
* @attention The internal frame object should not be deleted by the caller.
*
* @param impl The pointer to the internal frame object.
* @param[in] impl The pointer to the internal frame object.
*/
explicit VideoFrame(const ob_frame *impl) : Frame(impl) {};
@@ -460,6 +546,34 @@ public:
return bitSize;
}
/**
* @brief Set video frame pixel format
*
* @param pixelType the pixel format of the frame
*/
void setPixelType(OBPixelType pixelType) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_video_frame_set_pixel_type(unConstImpl, pixelType, &error);
Error::handle(&error);
}
/**
* @brief Set the effective number of pixels (such as Y16 format frame, but only the lower 10 bits are effective bits, and the upper 6 bits are filled with
* 0)
* @attention Only valid for Y8/Y10/Y11/Y12/Y14/Y16 format
*
* @param[in] bitSize the effective number of pixels in the pixel, or 0 if it is an unsupported format
*/
void setPixelAvailableBitSize(uint8_t bitSize) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_video_frame_set_pixel_available_bit_size(unConstImpl, bitSize, &error);
Error::handle(&error);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t width() const {
@@ -488,7 +602,7 @@ public:
* @attention The internal frame object should not be deleted by the caller.
* @attention Please use the FrameFactory to create a Frame object.
*
* @param impl The pointer to the internal frame object.
* @param[in] impl The pointer to the internal frame object.
*/
explicit ColorFrame(const ob_frame *impl) : VideoFrame(impl) {};
@@ -509,7 +623,7 @@ public:
* @attention The internal frame object should not be deleted by the caller.
* @attention Please use the FrameFactory to create a Frame object.
*
* @param impl The pointer to the internal frame object.
* @param[in] impl The pointer to the internal frame object.
*/
explicit DepthFrame(const ob_frame *impl) : VideoFrame(impl) {};
@@ -529,6 +643,20 @@ public:
return scale;
}
/**
* @brief Set the value scale of the depth frame. The pixel value of the depth frame is multiplied by the scale to give a depth value in millimeters.
* For example, if valueScale=0.1 and a certain coordinate pixel value is pixelValue=10000, then the depth value = pixelValue*valueScale = 10000*0.1=1000mm.
*
* @param[in] valueScale The value scale of the depth frame
*/
void setValueScale(float valueScale) {
ob_error *error = nullptr;
auto unConstImpl = const_cast<ob_frame *>(impl_);
ob_depth_frame_set_value_scale(unConstImpl, valueScale, &error);
Error::handle(&error);
}
};
/**
@@ -546,7 +674,7 @@ public:
* @attention The internal frame object should not be deleted by the caller.
* @attention Please use the FrameFactory to create a Frame object.
*
* @param impl The pointer to the internal frame object.
* @param[in] impl The pointer to the internal frame object.
*/
explicit IRFrame(const ob_frame *impl) : VideoFrame(impl) {};
@@ -568,9 +696,9 @@ public:
* @attention The internal frame object should not be deleted by the caller.
* @attention Please use the FrameFactory to create a Frame object.
*
* @param impl The pointer to the internal frame object.
* @param[in] impl The pointer to the internal frame object.
*/
explicit ConfidenceFrame(const ob_frame *impl) : VideoFrame(impl){};
explicit ConfidenceFrame(const ob_frame *impl) : VideoFrame(impl) {};
~ConfidenceFrame() noexcept override = default;
};
@@ -580,8 +708,8 @@ public:
* @brief The PointsFrame class is used to obtain pointcloud data and point cloud information.
*
* @note The pointcloud data format can be obtained from the @ref Frame::getFormat() function. Witch can be one of the following formats:
* - @ref OB_FORMAT_POINT: 32-bit float format with 3D point coordinates (x, y, z), @ref OBPoint
* - @ref OB_FORMAT_RGB_POINT: 32-bit float format with 3D point coordinates (x, y, z) and point colors (r, g, b) @ref, OBColorPoint
* - @ref OB_FORMAT_POINT : 32-bit float format with 3D point coordinates (x, y, z), @ref OBPoint
* - @ref OB_FORMAT_RGB_POINT : 32-bit float format with 3D point coordinates (x, y, z) and point colors (r, g, b) @ref OBColorPoint
*/
class PointsFrame : public Frame {
@@ -594,7 +722,7 @@ public:
* @attention The internal frame object should not be deleted by the caller.
* @attention Please use the FrameFactory to create a Frame object.
*
* @param impl The pointer to the internal frame object.
* @param[in] impl The pointer to the internal frame object.
*/
explicit PointsFrame(const ob_frame *impl) : Frame(impl) {};
@@ -796,7 +924,8 @@ public:
/**
* @brief Get a frame of a specific type from the FrameSet
*
* @param frameType The type of sensor
* @param[in] frameType The type of sensor
*
* @return std::shared_ptr<Frame> The corresponding type of frame
*/
std::shared_ptr<Frame> getFrame(OBFrameType frameType) const {
@@ -812,7 +941,8 @@ public:
/**
* @brief Get a frame at a specific index from the FrameSet
*
* @param index The index of the frame
* @param[in] index The index of the frame
*
* @return std::shared_ptr<Frame> The frame at the specified index
*/
std::shared_ptr<Frame> getFrameByIndex(uint32_t index) const {
@@ -830,7 +960,7 @@ public:
*
* @attention If the FrameSet contains the same type of frame, the new frame will replace the old one.
*
* @param frame The frame to be pushed
* @param[in] frame The frame to be pushed
*/
void pushFrame(std::shared_ptr<const Frame> frame) const {
ob_error *error = nullptr;
@@ -844,6 +974,66 @@ public:
Error::handle(&error);
}
/**
* @brief Get the depth frame from the frameset.
*
* @return std::shared_ptr<DepthFrame> Return the depth frame.
*/
std::shared_ptr<DepthFrame> getDepthFrame() const {
ob_error *error = nullptr;
auto frame = ob_frameset_get_depth_frame(impl_, &error);
if(!frame) {
return nullptr;
}
Error::handle(&error);
return std::make_shared<DepthFrame>(frame);
}
/**
* @brief Get the color frame from the frameset.
*
* @return std::shared_ptr<ColorFrame> Return the color frame.
*/
std::shared_ptr<ColorFrame> getColorFrame() const {
ob_error *error = nullptr;
auto frame = ob_frameset_get_color_frame(impl_, &error);
if(!frame) {
return nullptr;
}
Error::handle(&error);
return std::make_shared<ColorFrame>(frame);
}
/**
* @brief Get the infrared frame from the frameset.
*
* @return std::shared_ptr<IRFrame> Return the infrared frame.
*/
std::shared_ptr<IRFrame> getIrFrame() const {
ob_error *error = nullptr;
auto frame = ob_frameset_get_ir_frame(impl_, &error);
if(!frame) {
return nullptr;
}
Error::handle(&error);
return std::make_shared<IRFrame>(frame);
}
/**
* @brief Get the point cloud frame from the frameset.
*
* @return std::shared_ptr<PointsFrame> Return the point cloud frame.
*/
std::shared_ptr<PointsFrame> getPointsFrame() const {
ob_error *error = nullptr;
auto frame = ob_frameset_get_points_frame(impl_, &error);
if(!frame) {
return nullptr;
}
Error::handle(&error);
return std::make_shared<PointsFrame>(frame);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t frameCount() const {
@@ -901,9 +1091,10 @@ public:
/**
* @brief Create a Frame object of a specific type with a given format and data size.
*
* @param frameType The type of the frame.
* @param format The format of the frame.
* @param dataSize The size of the data in bytes.
* @param[in] frameType The type of the frame.
* @param[in] format The format of the frame.
* @param[in] dataSize The size of the data in bytes.
*
* @return std::shared_ptr<Frame> The created frame object.
*/
static std::shared_ptr<Frame> createFrame(OBFrameType frameType, OBFormat format, uint32_t dataSize) {
@@ -918,11 +1109,11 @@ public:
* @brief Create a VideoFrame object of a specific type with a given format, width, height, and stride.
* @note If stride is not specified, it will be calculated based on the width and format.
*
* @param frameType The type of the frame.
* @param format The format of the frame.
* @param width The width of the frame.
* @param height The height of the frame.
* @param stride The stride of the frame.
* @param[in] frameType The type of the frame.
* @param[in] format The format of the frame.
* @param[in] width The width of the frame.
* @param[in] height The height of the frame.
* @param[in] stride The stride of the frame.
*
* @return std::shared_ptr<VideoFrame> The created video frame object.
*/
@@ -939,7 +1130,8 @@ public:
* @brief Create (clone) a frame object based on the specified other frame object.
* @brief The new frame object will have the same properties as the other frame object, but the data buffer is newly allocated.
*
* @param shouldCopyData If true, the data of the source frame object will be copied to the new frame object. If false, the new frame object will
* @param[in] otherFrame The source frame to be copied.
* @param[in] shouldCopyData If true, the data of the source frame object will be copied to the new frame object. If false, the new frame object will
* have a data buffer with random data. The default value is true.
*
* @return std::shared_ptr<Frame> The new frame object.
@@ -956,7 +1148,7 @@ public:
/**
* @brief Create a Frame From (according to)Stream Profile object
*
* @param profile The stream profile object to create the frame from.
* @param[in] profile The stream profile object to create the frame from.
*
* @return std::shared_ptr<Frame> The created frame object.
*/
@@ -1027,6 +1219,22 @@ public:
return frame->as<VideoFrame>();
}
/**
* @brief Create a new FrameSet object.
*
* This function creates a new FrameSet instance by internally calling the native C API.
* The returned FrameSet is managed by a std::shared_ptr, and its lifetime will be
* automatically managed. When no references remain, the underlying native resources will be released.
*
* @return std::shared_ptr<FrameSet> The created FrameSet object.
*/
static std::shared_ptr<FrameSet> createFrameSet() {
ob_error *error = nullptr;
auto impl = ob_create_frameset(&error);
Error::handle(&error);
return std::make_shared<FrameSet>(impl);
}
private:
struct BufferDestroyContext {
BufferDestroyCallback callback;
@@ -1050,8 +1258,8 @@ public:
/**
* @brief Set the device timestamp of the frame.
*
* @param frame The frame object.
* @param deviceTimestampUs The device timestamp to set in microseconds.
* @param[in] frame The frame object.
* @param[in] deviceTimestampUs The device timestamp to set in microseconds.
*/
static void setFrameDeviceTimestampUs(std::shared_ptr<Frame> frame, uint64_t deviceTimestampUs) {
ob_error *error = nullptr;
@@ -57,7 +57,7 @@ public:
/**
* @brief enable a stream with a specific stream type
*
* @param streamType The stream type to be enabled
* @param[in] streamType The stream type to be enabled
*/
void enableStream(OBStreamType streamType) const {
ob_error *error = nullptr;
@@ -69,7 +69,7 @@ public:
* @brief Enable a stream with a specific sensor type
* @brief Will convert sensor type to stream type automatically.
*
* @param sensorType The sensor type to be enabled
* @param[in] sensorType The sensor type to be enabled
*/
void enableStream(OBSensorType sensorType) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
@@ -79,7 +79,7 @@ public:
/**
* @brief Enable a stream to be used in the pipeline
*
* @param streamProfile The stream configuration to be enabled
* @param[in] streamProfile The stream configuration to be enabled
*/
void enableStream(std::shared_ptr<const StreamProfile> streamProfile) const {
ob_error *error = nullptr;
@@ -95,11 +95,11 @@ public:
* If no parameters are specified, the stream will be enabled with default resolution settings.
* Users who wish to set custom resolutions should refer to the product manual, as available resolutions vary by camera model.
*
* @param streamType The video stream type.
* @param width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution).
* @param height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution).
* @param fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate).
* @param format The video stream format (default is OB_FORMAT_ANY, which selects the default format).
* @param[in] streamType The video stream type.
* @param[in] width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution).
* @param[in] height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution).
* @param[in] fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate).
* @param[in] format The video stream format (default is OB_FORMAT_ANY, which selects the default format).
*/
void enableVideoStream(OBStreamType streamType, uint32_t width = OB_WIDTH_ANY, uint32_t height = OB_HEIGHT_ANY, uint32_t fps = OB_FPS_ANY,
OBFormat format = OB_FORMAT_ANY) const {
@@ -112,11 +112,11 @@ public:
* @brief Enable a video stream to be used in the pipeline.
* @brief Will convert sensor type to stream type automatically.
*
* @param sensorType The sensor type to be enabled.
* @param width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution).
* @param height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution).
* @param fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate).
* @param format The video stream format (default is OB_FORMAT_ANY, which selects the default format).
* @param[in] sensorType The sensor type to be enabled.
* @param[in] width The video stream width (default is OB_WIDTH_ANY, which selects the default resolution).
* @param[in] height The video stream height (default is OB_HEIGHT_ANY, which selects the default resolution).
* @param[in] fps The video stream frame rate (default is OB_FPS_ANY, which selects the default frame rate).
* @param[in] format The video stream format (default is OB_FORMAT_ANY, which selects the default format).
*/
void enableVideoStream(OBSensorType sensorType, uint32_t width = OB_WIDTH_ANY, uint32_t height = OB_HEIGHT_ANY, uint32_t fps = OB_FPS_ANY,
OBFormat format = OB_FORMAT_ANY) const {
@@ -131,8 +131,8 @@ public:
* If no parameters are specified, the stream will be enabled with default settings.
* Users who wish to set custom full-scale ranges or sample rates should refer to the product manual, as available settings vary by device model.
*
* @param fullScaleRange The full-scale range of the accelerometer (default is OB_ACCEL_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param sampleRate The sample rate of the accelerometer (default is OB_ACCEL_SAMPLE_RATE_ANY, which selects the default rate).
* @param[in] fullScaleRange The full-scale range of the accelerometer (default is OB_ACCEL_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param[in] sampleRate The sample rate of the accelerometer (default is OB_ACCEL_SAMPLE_RATE_ANY, which selects the default rate).
*/
void enableAccelStream(OBAccelFullScaleRange fullScaleRange = OB_ACCEL_FULL_SCALE_RANGE_ANY,
OBAccelSampleRate sampleRate = OB_ACCEL_SAMPLE_RATE_ANY) const {
@@ -148,8 +148,8 @@ public:
* If no parameters are specified, the stream will be enabled with default settings.
* Users who wish to set custom full-scale ranges or sample rates should refer to the product manual, as available settings vary by device model.
*
* @param fullScaleRange The full-scale range of the gyroscope (default is OB_GYRO_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param sampleRate The sample rate of the gyroscope (default is OB_GYRO_SAMPLE_RATE_ANY, which selects the default rate).
* @param[in] fullScaleRange The full-scale range of the gyroscope (default is OB_GYRO_FULL_SCALE_RANGE_ANY, which selects the default range).
* @param[in] sampleRate The sample rate of the gyroscope (default is OB_GYRO_SAMPLE_RATE_ANY, which selects the default rate).
*/
void enableGyroStream(OBGyroFullScaleRange fullScaleRange = OB_GYRO_FULL_SCALE_RANGE_ANY, OBGyroSampleRate sampleRate = OB_GYRO_SAMPLE_RATE_ANY) const {
ob_error *error = nullptr;
@@ -186,7 +186,7 @@ public:
/**
* @brief Disable a stream to be used in the pipeline
*
* @param streamType The stream configuration to be disabled
* @param[in] streamType The stream configuration to be disabled
*/
void disableStream(OBStreamType streamType) const {
ob_error *error = nullptr;
@@ -198,7 +198,7 @@ public:
* @brief Disable a sensor stream to be used in the pipeline.
* @brief Will convert sensor type to stream type automatically.
*
* @param sensorType The sensor configuration to be disabled
* @param[in] sensorType The sensor configuration to be disabled
*/
void disableStream(OBSensorType sensorType) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
@@ -229,7 +229,7 @@ public:
/**
* @brief Set the alignment mode
*
* @param mode The alignment mode
* @param[in] mode The alignment mode
*/
void setAlignMode(OBAlignMode mode) const {
ob_error *error = nullptr;
@@ -240,7 +240,7 @@ public:
/**
* @brief Set whether the depth needs to be scaled after setting D2C
*
* @param enable Whether scaling is required
* @param[in] enable Whether scaling is required
*/
void setDepthScaleRequire(bool enable) const {
ob_error *error = nullptr;
@@ -253,7 +253,7 @@ public:
* @brief The processing strategy when the FrameSet generated by the frame aggregation function does not contain the frames of all opened streams (which
* can be caused by different frame rates of each stream, or by the loss of frames of one stream): drop directly or output to the user.
*
* @param mode The frame aggregation output mode to be set (default mode is @ref OB_FRAME_AGGREGATE_OUTPUT_ANY_SITUATION)
* @param[in] mode The frame aggregation output mode to be set (default mode is @ref OB_FRAME_AGGREGATE_OUTPUT_ANY_SITUATION)
*/
void setFrameAggregateOutputMode(OBFrameAggregateOutputMode mode) const {
ob_error *error = nullptr;
@@ -267,7 +267,7 @@ public:
/**
* @brief FrameSetCallback is a callback function type for frameset data arrival.
*
* @param frame The returned frameset data
* @param[in] frame The returned frameset data
*/
typedef std::function<void(std::shared_ptr<FrameSet> frame)> FrameSetCallback;
@@ -310,7 +310,7 @@ public:
/**
* @brief Start the pipeline with configuration parameters
*
* @param config The parameter configuration of the pipeline
* @param[in] config The parameter configuration of the pipeline
*/
void start(std::shared_ptr<Config> config = nullptr) const {
ob_error *error = nullptr;
@@ -322,8 +322,8 @@ public:
/**
* @brief Start the pipeline and set the frameset data callback
*
* @param config The configuration of the pipeline
* @param callback The callback to be triggered when all frame data in the frameset arrives
* @param[in] config The configuration of the pipeline
* @param[in] callback The callback to be triggered when all frame data in the frameset arrives
*/
void start(std::shared_ptr<Config> config, FrameSetCallback callback) {
callback_ = callback;
@@ -362,7 +362,8 @@ public:
/**
* @brief Wait for frameset
*
* @param timeoutMs The waiting timeout in milliseconds
* @param[in] timeoutMs The waiting timeout in milliseconds
*
* @return std::shared_ptr<FrameSet> The waiting frameset data
*/
std::shared_ptr<FrameSet> waitForFrameset(uint32_t timeoutMs = 1000) const {
@@ -390,7 +391,8 @@ public:
/**
* @brief Get the stream profile of the specified sensor
*
* @param sensorType The type of sensor
* @param[in] sensorType The type of sensor
*
* @return std::shared_ptr<StreamProfileList> The stream profile list
*/
std::shared_ptr<StreamProfileList> getStreamProfileList(OBSensorType sensorType) const {
@@ -403,8 +405,8 @@ public:
/**
* @brief Get the stream profile list of supported depth-to-color alignments
*
* @param colorProfile The color stream profile, which is the target stream profile for the depth-to-color alignment.
* @param alignMode The alignment mode.
* @param[in] colorProfile The color stream profile, which is the target stream profile for the depth-to-color alignment.
* @param[in] alignMode The alignment mode.
*
* @attention Currently, only ALIGN_D2C_HW_MODE supported. For other align modes, please using the AlignFilter interface.
*
@@ -26,7 +26,7 @@ public:
/**
* @brief Callback function for frame data.
*
* @param frame The frame data.
* @param[in] frame The frame data.
*/
typedef std::function<void(std::shared_ptr<Frame> frame)> FrameCallback;
@@ -110,8 +110,8 @@ public:
/**
* @brief Open a frame data stream and set up a callback.
*
* @param streamProfile The stream configuration.
* @param callback The callback to set when frame data arrives.
* @param[in] streamProfile The stream configuration.
* @param[in] callback The callback to set when frame data arrives.
*/
void start(std::shared_ptr<StreamProfile> streamProfile, FrameCallback callback) {
ob_error *error = nullptr;
@@ -132,7 +132,7 @@ public:
/**
* @brief Dynamically switch resolutions.
*
* @param streamProfile The resolution to switch to.
* @param[in] streamProfile The resolution to switch to.
*/
void switchProfile(std::shared_ptr<StreamProfile> streamProfile) {
ob_error *error = nullptr;
@@ -185,7 +185,8 @@ public:
/**
* @brief Get the type of the specified sensor.
*
* @param index The sensor index.
* @param[in] index The sensor index.
*
* @return OBSensorType The sensor type.
*/
OBSensorType getSensorType(uint32_t index) const {
@@ -198,7 +199,8 @@ public:
/**
* @brief Get a sensor by index number.
*
* @param index The sensor index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown.
* @param[in] index The sensor index. The range is [0, count-1]. If the index exceeds the range, an exception will be thrown.
*
* @return std::shared_ptr<Sensor> The sensor object.
*/
std::shared_ptr<Sensor> getSensor(uint32_t index) const {
@@ -211,7 +213,8 @@ public:
/**
* @brief Get a sensor by sensor type.
*
* @param sensorType The sensor type to obtain.
* @param[in] sensorType The sensor type to obtain.
*
* @return std::shared_ptr<Sensor> A sensor object. If the specified sensor type does not exist, it will return empty.
*/
std::shared_ptr<Sensor> getSensor(OBSensorType sensorType) const {
@@ -114,6 +114,7 @@ public:
* @brief Check if frame object is compatible with the given type.
*
* @tparam T Given type.
*
* @return bool return result.
*/
template <typename T> bool is() const;
@@ -122,6 +123,7 @@ public:
* @brief Converts object type to target type.
*
* @tparam T Target type.
*
* @return std::shared_ptr<T> Return the result. Throws an exception if conversion is not possible.
*/
template <typename T> std::shared_ptr<T> as() {
@@ -136,6 +138,7 @@ public:
* @brief Converts object type to target type (const version).
*
* @tparam T Target type.
*
* @return std::shared_ptr<T> Return the result. Throws an exception if conversion is not possible.
*/
template <typename T> std::shared_ptr<const T> as() const {
@@ -219,7 +222,7 @@ public:
/**
* @brief Set the intrinsic parameters of the stream.
*
* @param intrinsic The intrinsic parameters.
* @param[in] intrinsic The intrinsic parameters.
*/
void setIntrinsic(const OBCameraIntrinsic &intrinsic) {
ob_error *error = nullptr;
@@ -243,7 +246,7 @@ public:
/**
* @brief Set the distortion parameters of the stream.
*
* @param distortion The distortion parameters.
* @param[in] distortion The distortion parameters.
*/
void setDistortion(const OBCameraDistortion &distortion) {
ob_error *error = nullptr;
@@ -476,7 +479,9 @@ public:
/**
* @brief Return the StreamProfile object at the specified index.
*
* @param index The index of the StreamProfile object to be retrieved. Must be in the range [0, count-1]. Throws an exception if the index is out of range.
* @param[in] index The index of the StreamProfile object to be retrieved. Must be in the range [0, count-1]. Throws an exception if the index is out of
* range.
*
* @return std::shared_ptr<StreamProfile> Return the StreamProfile object.
*/
std::shared_ptr<StreamProfile> getProfile(uint32_t index) const {
@@ -490,10 +495,11 @@ public:
* @brief Match the corresponding video stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list is
* returned by default. Throws an exception if no matching profile is found.
*
* @param width The width of the stream. Pass OB_WIDTH_ANY if no matching condition is required.
* @param height The height of the stream. Pass OB_HEIGHT_ANY if no matching condition is required.
* @param format The type of the stream. Pass OB_FORMAT_ANY if no matching condition is required.
* @param fps The frame rate of the stream. Pass OB_FPS_ANY if no matching condition is required.
* @param[in] width The width of the stream. Pass OB_WIDTH_ANY if no matching condition is required.
* @param[in] height The height of the stream. Pass OB_HEIGHT_ANY if no matching condition is required.
* @param[in] format The type of the stream. Pass OB_FORMAT_ANY if no matching condition is required.
* @param[in] fps The frame rate of the stream. Pass OB_FPS_ANY if no matching condition is required.
*
* @return std::shared_ptr<VideoStreamProfile> Return the matching resolution.
*/
std::shared_ptr<VideoStreamProfile> getVideoStreamProfile(int width = OB_WIDTH_ANY, int height = OB_HEIGHT_ANY, OBFormat format = OB_FORMAT_ANY,
@@ -509,8 +515,8 @@ public:
* @brief Match the corresponding accelerometer stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list
* is returned by default. Throws an exception if no matching profile is found.
*
* @param fullScaleRange The full scale range. Pass 0 if no matching condition is required.
* @param sampleRate The sampling frequency. Pass 0 if no matching condition is required.
* @param[in] fullScaleRange The full scale range. Pass 0 if no matching condition is required.
* @param[in] sampleRate The sampling frequency. Pass 0 if no matching condition is required.
*/
std::shared_ptr<AccelStreamProfile> getAccelStreamProfile(OBAccelFullScaleRange fullScaleRange, OBAccelSampleRate sampleRate) const {
ob_error *error = nullptr;
@@ -524,8 +530,8 @@ public:
* @brief Match the corresponding gyroscope stream profile based on the passed-in parameters. If multiple Match are found, the first one in the list is
* returned by default. Throws an exception if no matching profile is found.
*
* @param fullScaleRange The full scale range. Pass 0 if no matching condition is required.
* @param sampleRate The sampling frequency. Pass 0 if no matching condition is required.
* @param[in] fullScaleRange The full scale range. Pass 0 if no matching condition is required.
* @param[in] sampleRate The sampling frequency. Pass 0 if no matching condition is required.
*/
std::shared_ptr<GyroStreamProfile> getGyroStreamProfile(OBGyroFullScaleRange fullScaleRange, OBGyroSampleRate sampleRate) const {
ob_error *error = nullptr;
@@ -17,6 +17,7 @@ public:
* @brief Convert OBFormat to " string " type and then return.
*
* @param[in] type OBFormat type.
*
* @return OBFormat of "string" type.
*/
static std::string convertOBFormatTypeToString(const OBFormat &type) {
@@ -27,6 +28,7 @@ public:
* @brief Convert OBFrameType to " string " type and then return.
*
* @param[in] type OBFrameType type.
*
* @return OBFrameType of "string" type.
*/
static std::string convertOBFrameTypeToString(const OBFrameType &type) {
@@ -37,6 +39,7 @@ public:
* @brief Convert OBStreamType to " string " type and then return.
*
* @param[in] type OBStreamType type.
*
* @return OBStreamType of "string" type.
*/
static std::string convertOBStreamTypeToString(const OBStreamType &type) {
@@ -47,6 +50,7 @@ public:
* @brief Convert OBSensorType to " string " type and then return.
*
* @param[in] type OBSensorType type.
*
* @return OBSensorType of "string" type.
*/
static std::string convertOBSensorTypeToString(const OBSensorType &type) {
@@ -57,6 +61,7 @@ public:
* @brief Convert OBIMUSampleRate to " string " type and then return.
*
* @param[in] type OBIMUSampleRate type.
*
* @return OBIMUSampleRate of "string" type.
*/
static std::string convertOBIMUSampleRateTypeToString(const OBIMUSampleRate &type) {
@@ -67,6 +72,7 @@ public:
* @brief Convert OBGyroFullScaleRange to " string " type and then return.
*
* @param[in] type OBGyroFullScaleRange type.
*
* @return OBGyroFullScaleRange of "string" type.
*/
static std::string convertOBGyroFullScaleRangeTypeToString(const OBGyroFullScaleRange &type) {
@@ -77,6 +83,7 @@ public:
* @brief Convert OBAccelFullScaleRange to " string " type and then return.
*
* @param[in] type OBAccelFullScaleRange type.
*
* @return OBAccelFullScaleRange of "string" type.
*/
static std::string convertOBAccelFullScaleRangeTypeToString(const OBAccelFullScaleRange &type) {
@@ -97,6 +104,7 @@ public:
* @brief Convert OBFrameMetadataType to " string " type and then return.
*
* @param[in] type OBFrameMetadataType type.
*
* @return OBFrameMetadataType of "string" type.
*/
static std::string convertOBFrameMetadataTypeToString(const OBFrameMetadataType &type) {
@@ -107,6 +115,7 @@ public:
* @brief Convert OBSensorType to OBStreamType type and then return.
*
* @param[in] type OBSensorType type.
*
* @return OBStreamType type.
*/
static OBStreamType convertSensorTypeToStreamType(OBSensorType type) {
@@ -124,9 +133,9 @@ public:
* OB_SENSOR_IR_RIGHT,
* OB_SENSOR_CONFIDENCE,
*
* @param type The sensor type
* @return true
* @return false
* @param[in] type The sensor type
*
* @return true/false
*/
static bool isVideoSensorType(OBSensorType type) {
return ob_is_video_sensor_type(type);
@@ -144,7 +153,8 @@ public:
* OB_STREAM_IR_RIGHT,
* OB_STREAM_CONFIDENCE,
*
* @param type The stream type to check.
* @param[in] type The stream type to check.
*
* @return true if the given stream type is a video stream, false otherwise.
*/
static bool isVideoStreamType(OBStreamType type) {
@@ -186,5 +186,22 @@ public:
Error::handle(&error, false);
return result;
}
/**
* @brief Save LiDAR point cloud to PLY file.
*
* @param fileName Point cloud save path
* @param frame LiDAR point cloud frame
* @param saveBinary Binary or textual,true: binary, false: textual
* @return true if successful
* @return false if failed
*/
static bool saveLiDARPointcloudToPly(const char *fileName, std::shared_ptr<ob::LiDARPointsFrame> frame, bool saveBinary) {
ob_error *error = NULL;
auto unConstImpl = const_cast<ob_frame *>(frame->getImpl());
bool result = ob_save_lidar_pointcloud_to_ply(fileName, unConstImpl, saveBinary, &error);
Error::handle(&error, false);
return result;
}
};
} // namespace ob