This commit is contained in:
2026-01-09 13:59:10 +08:00
commit 336a19762a
378 changed files with 99177 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* \file ObSensor.h
* \brief This file serves as the C entrance for the OrbbecSDK library.
* It includes all necessary header files for OrbbecSDK usage.
*/
#pragma once
#include <libobsensor/h/Context.h>
#include <libobsensor/h/Device.h>
#include <libobsensor/h/Error.h>
#include <libobsensor/h/Filter.h>
#include <libobsensor/h/Frame.h>
#include <libobsensor/h/ObTypes.h>
#include <libobsensor/h/Pipeline.h>
#include <libobsensor/h/Property.h>
#include <libobsensor/h/Sensor.h>
#include <libobsensor/h/StreamProfile.h>
#include <libobsensor/h/Version.h>
#include <libobsensor/h/TypeHelper.h>
#include <libobsensor/h/RecordPlayback.h>

View File

@@ -0,0 +1,21 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* \file ObSensor.hpp
* \brief This is the main entry point for the OrbbecSDK C++ library.
* It includes all necessary header files for using the library.
*/
#pragma once
#include <libobsensor/hpp/Context.hpp>
#include <libobsensor/hpp/Device.hpp>
#include <libobsensor/hpp/Error.hpp>
#include <libobsensor/hpp/Filter.hpp>
#include <libobsensor/hpp/Frame.hpp>
#include <libobsensor/hpp/Pipeline.hpp>
#include <libobsensor/hpp/RecordPlayback.hpp>
#include <libobsensor/hpp/Sensor.hpp>
#include <libobsensor/hpp/StreamProfile.hpp>
#include <libobsensor/hpp/Version.hpp>
#include <libobsensor/hpp/TypeHelper.hpp>

View File

@@ -0,0 +1,314 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Get the current depth work mode.
*
* @param[in] device The device object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_depth_work_mode The current depth work mode.
*/
OB_EXPORT ob_depth_work_mode ob_device_get_current_depth_work_mode(const ob_device *device, ob_error **error);
/**
* @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.
*/
OB_EXPORT const char *ob_device_get_current_depth_work_mode_name(const ob_device *device, ob_error **error);
/**
* @brief Switch the depth work mode by ob_depth_work_mode.
* Prefer to use ob_device_switch_depth_work_mode_by_name to switch depth mode when the complete name of the depth work mode is known.
*
* @param[in] device The device object.
* @param[in] work_mode The depth work mode from ob_depth_work_mode_list which is returned by ob_device_get_depth_work_mode_list.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_status The switch result. OB_STATUS_OK: success, other failed.
*/
OB_EXPORT ob_status ob_device_switch_depth_work_mode(ob_device *device, const ob_depth_work_mode *work_mode, ob_error **error);
/**
* @brief Switch the depth work mode by work mode name.
*
* @param[in] device The device object.
* @param[in] mode_name The depth work mode name which is equal to ob_depth_work_mode.name.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_status The switch result. OB_STATUS_OK: success, other failed.
*/
OB_EXPORT ob_status ob_device_switch_depth_work_mode_by_name(ob_device *device, const char *mode_name, ob_error **error);
/**
* @brief Request the list of supported depth work modes.
*
* @param[in] device The device object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_depth_work_mode_list The list of ob_depth_work_mode.
*/
OB_EXPORT ob_depth_work_mode_list *ob_device_get_depth_work_mode_list(const ob_device *device, ob_error **error);
/**
* \if English
* @brief Get the depth work mode count that ob_depth_work_mode_list hold
* @param[in] work_mode_list data struct contain list of ob_depth_work_mode
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The total number contained in ob_depth_work_mode_list
*
*/
OB_EXPORT uint32_t ob_depth_work_mode_list_get_count(const ob_depth_work_mode_list *work_mode_list, ob_error **error);
/**
* @brief Get the index target of ob_depth_work_mode from work_mode_list
*
* @param[in] work_mode_list Data structure containing a list of ob_depth_work_mode
* @param[in] index Index of the target ob_depth_work_mode
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_depth_work_mode
*
*/
OB_EXPORT ob_depth_work_mode ob_depth_work_mode_list_get_item(const ob_depth_work_mode_list *work_mode_list, uint32_t index, ob_error **error);
/**
* @brief Free the resources of ob_depth_work_mode_list
*
* @param[in] work_mode_list Data structure containing a list of ob_depth_work_mode
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
*/
OB_EXPORT void ob_delete_depth_work_mode_list(ob_depth_work_mode_list *work_mode_list, ob_error **error);
/**
* @brief Get the 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.
*
* @param device The device object.
* @param error Pointer to an error object that will be set if an error occurs.
* @return The current preset name, it should be one of the preset names returned by @ref ob_device_get_available_preset_list.
*/
OB_EXPORT const char *ob_device_get_current_preset_name(const ob_device *device, ob_error **error);
/**
* @brief Get the available preset list.
* @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 device The device object.
* @param preset_name Pointer to an error object that will be set if an error occurs. The name should be one of the preset names returned by @ref
* ob_device_get_available_preset_list.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_load_preset(ob_device *device, const char *preset_name, ob_error **error);
/**
* @brief Load preset from json string.
* @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 file name.
*
* @param device The device object.
* @param json_file_path The json file path.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_load_preset_from_json_file(ob_device *device, const char *json_file_path, ob_error **error);
/**
* @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.
*
* @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.
*/
OB_EXPORT void ob_device_load_preset_from_json_data(ob_device *device, const char *presetName, const uint8_t *data, uint32_t size, ob_error **error);
/**
* @brief Export current settings as a preset json file.
* @brief After exporting the custom preset, the available preset list will be appended with the custom preset and named as the file name.
*
* @param device The device object.
* @param json_file_path The json file path.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_export_current_settings_as_preset_json_file(ob_device *device, const char *json_file_path, ob_error **error);
/**
* @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.
*
* @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[out] data return the preset json data.
* @param[out] dataSize return the size of the preset json data.
*/
OB_EXPORT void ob_device_export_current_settings_as_preset_json_data(ob_device *device, const char *presetName, const uint8_t **data, uint32_t *dataSize,
ob_error **error);
/**
* @brief Get the available preset list.
*
* @param device The device object.
* @param error Pointer to an error object that will be set if an error occurs.
* @return The available preset list.
*/
OB_EXPORT ob_device_preset_list *ob_device_get_available_preset_list(const ob_device *device, ob_error **error);
/**
* @brief Delete the available preset list.
*
* @param preset_list The available preset list.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_preset_list(ob_device_preset_list *preset_list, ob_error **error);
/**
* @brief Get the number of preset in the preset list.
*
* @param preset_list The available preset list.
* @param error Pointer to an error object that will be set if an error occurs.
* @return The number of preset in the preset list.
*/
OB_EXPORT uint32_t ob_device_preset_list_get_count(const ob_device_preset_list *preset_list, ob_error **error);
/**
* @brief Get the name of the preset in the preset list.
*
* @param preset_list The available preset list.
* @param index The index of the preset in the preset list.
* @param error Pointer to an error object that will be set if an error occurs.
* @return The name of the preset in the preset list.
*/
OB_EXPORT const char *ob_device_preset_list_get_name(const ob_device_preset_list *preset_list, uint32_t index, ob_error **error);
/**
* @brief Check if the preset list has the preset.
*
* @param preset_list The available preset list.
* @param preset_name The name of the preset.
* @param error Pointer to an error object that will be set if an error occurs.
* @return Whether the preset list has the preset. If true, the preset list has the preset. If false, the preset list does not have the preset.
*/
OB_EXPORT bool ob_device_preset_list_has_preset(const ob_device_preset_list *preset_list, const char *preset_name, ob_error **error);
/**
* @brief Check if the device supports the frame interleave feature.
*
* @param device The device object.
* @param error Pointer to an error object that will be set if an error occurs.
* @return bool Returns true if the device supports the frame interleave feature.
*/
OB_EXPORT bool ob_device_is_frame_interleave_supported(const ob_device *device, ob_error **error);
/**
*
* @brief load the frame interleave mode according to frame interleavee name.
*
* @param device The device object.
* @param frame_interleave_name The name should be one of the frame interleave names returned by @ref ob_device_get_available_frame_interleave_list.
* @param error Log error messages.
*/
OB_EXPORT void ob_device_load_frame_interleave(ob_device *device, const char *frame_interleave_name, ob_error **error);
/**
* @brief Get the available frame interleave list.
*
* @param device The device object.
* @param error Log error messages.
* @return The available frame interleave list.
*/
OB_EXPORT ob_device_frame_interleave_list *ob_device_get_available_frame_interleave_list(ob_device *device, ob_error **error);
/**
* @brief Delete the available frame interleave list.
*
* @param frame_interleave_list The available frame interleave list.
* @param error Log error messages.
*/
OB_EXPORT void ob_delete_frame_interleave_list(ob_device_frame_interleave_list *frame_interleave_list, ob_error **error);
/**
* @brief Get the number of frame interleave in the frame interleave list.
*
* @param frame_interleave_list The available frame interleave list.
* @param error Log error messages.
* @return The number of frame interleave in the frame interleave list.
*/
OB_EXPORT uint32_t ob_device_frame_interleave_list_get_count(ob_device_frame_interleave_list *frame_interleave_list, ob_error **error);
/**
* @brief Get the name of frame interleave in the frame interleave list.
*
* @param frame_interleave_list The available frame interleave list.
* @param index The index of frame interleave in the frame interleave list.
* @param error Log error messages.
* @return The name of frame interleave in the frame interleave list..
*/
OB_EXPORT const char *ob_device_frame_interleave_list_get_name(ob_device_frame_interleave_list *frame_interleave_list, uint32_t index, ob_error **error);
/**
* @brief Check if the interleave ae list has the interleave ae.
*
* @param frame_interleave_list The available interleave ae list.
* @param frame_interleave_name The name of the interleave ae.
* @param error Log error messages.
* @return Whether the interleave ae list has the interleave ae. If true, the interleave ae list has the interleave ae. If false, the interleave ae list does
* not have the interleave ae.
*/
OB_EXPORT bool ob_device_frame_interleave_list_has_frame_interleave(ob_device_frame_interleave_list *frame_interleave_list, const char *frame_interleave_name,
ob_error **error);
/* @brief Get the available preset resolution config list.
*
* @param device The device object.
* @param error Log error messages.
* @return The available frame resolution config list.
*
*/
OB_EXPORT ob_preset_resolution_config_list *ob_device_get_available_preset_resolution_config_list(ob_device *device, ob_error **error);
/* @brief Get the number of preset resolution in the preset resolution list.
*
* @param ob_preset_resolution_config_list The available preset resolution list.
* @param error Log error messages.
* @return The number of preset resolution in the preset resolution list.
*/
OB_EXPORT uint32_t ob_device_preset_resolution_config_get_count(ob_preset_resolution_config_list *ob_preset_resolution_config_list, ob_error **error);
/**
* @brief Get the preset resolution in the preset resolution list.
*
* @param ob_preset_resolution_config_list The available preset resolution list.
* @param index The index of preset resolution in the preset resolution list.
* @param error Log error messages.
* @return The preset resolution in the preset resolution list.
*/
OB_EXPORT OBPresetResolutionConfig ob_device_preset_resolution_config_list_get_item(const ob_preset_resolution_config_list *ob_preset_resolution_config_list,
uint32_t index, ob_error **error);
/**
* @brief Delete the available preset resolution list.
*
* @param frame_interleave_list The available preset resolution list.
* @param error Log error messages.
*/
OB_EXPORT void ob_delete_preset_resolution_config_list(ob_preset_resolution_config_list *ob_preset_resolution_config_list, ob_error **error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_depth_work_mode_list_count ob_depth_work_mode_list_get_count
#define ob_device_preset_list_count ob_device_preset_list_get_count
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,187 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Context.h
* @brief Context is a management class that describes the runtime of the SDK and is responsible for resource allocation and release of the SDK.
* Context has the ability to manage multiple devices. It is responsible for enumerating devices, monitoring device callbacks, and enabling multi-device
* synchronization.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Create a context object with the default configuration file
*
* @param[out] error Pointer to an error object that will be populated if an error occurs during context creation
* @return Pointer to the created context object
*/
OB_EXPORT ob_context *ob_create_context(ob_error **error);
/**
* @brief Create a context object with a specified configuration file
*
* @param[in] config_file_path Path to the configuration file. If NULL, the default configuration file will be used.
* @param[out] error Pointer to an error object that will be populated if an error occurs during context creation
* @return Pointer to the created context object
*/
OB_EXPORT ob_context *ob_create_context_with_config(const char *config_file_path, ob_error **error);
/**
* @brief Delete a context object
*
* @param[in] context Pointer to the context object to be deleted
* @param[out] error Pointer to an error object that will be populated if an error occurs during context deletion
*/
OB_EXPORT void ob_delete_context(ob_context *context, ob_error **error);
/**
* @brief Get a list of enumerated devices
*
* @param[in] context Pointer to the context object
* @param[out] error Pointer to an error object that will be populated if an error occurs during device enumeration
* @return Pointer to the device list object
*/
OB_EXPORT ob_device_list *ob_query_device_list(ob_context *context, ob_error **error);
/**
* @brief Enable or disable network device enumeration
* @brief After enabling, the network device will be automatically discovered and can be retrieved through @ref ob_query_device_list. The default state can be
* set in the configuration file.
*
* @attention Network device enumeration is performed through the GVCP protocol. If the device is not in the same subnet as the host, it will be discovered but
* cannot be connected.
*
* @param[in] context Pointer to the context object
* @param[in] enable true to enable, false to disable
* @param[out] error Pointer to an error object that will be populated if an error occurs.
*/
OB_EXPORT void ob_enable_net_device_enumeration(ob_context *context, bool enable, ob_error **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 DeviceList::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.
* @param[out] error Pointer to an error object that will be populated if an error occurs.
* @return bool true if the configuration command was processed successfully, false otherwise.
*
* @note This applies to all Orbbec GigE Vision devices
*/
OB_EXPORT bool ob_force_ip_config(const char *deviceUid, ob_net_ip_config config, ob_error **error);
/**
* @brief Create a network device object
*
* @param[in] context Pointer to the context object
* @param[in] address IP address of the device
* @param[in] port Port number of the device
* @param[out] error Pointer to an error object that will be populated if an error occurs during device creation
* @return Pointer to the created device object
*/
OB_EXPORT ob_device *ob_create_net_device(ob_context *context, const char *address, uint16_t port, ob_error **error);
/**
* @brief Set a device plug-in callback function
* @attention The added and removed device lists returned through the callback interface need to be released manually
* @attention This function supports multiple callbacks. Each call to this function adds a new callback to an internal list.
*
* @param[in] context Pointer to the context object
* @param[in] callback Pointer to the callback function triggered when a device is plugged or unplugged
* @param[in] user_data Pointer to user data that can be passed to and retrieved from the callback function
* @param[out] error Pointer to an error object that will be populated if an error occurs during callback function setting
*/
OB_EXPORT void ob_set_device_changed_callback(ob_context *context, ob_device_changed_callback callback, void *user_data, ob_error **error);
/**
* @brief Activates device clock synchronization to synchronize the clock of the host and all created devices (if supported).
*
* @param[in] context Pointer to the context object
* @param[in] repeat_interval_msec The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
* @param[out] error Pointer to an error object that will be populated if an error occurs during execution
*/
OB_EXPORT void ob_enable_device_clock_sync(ob_context *context, uint64_t repeat_interval_msec, ob_error **error);
/**
* @brief Free idle memory from the internal frame memory pool
*
* @param[in] context Pointer to the context object
* @param[out] error Pointer to an error object that will be populated if an error occurs during memory freeing
*/
OB_EXPORT void ob_free_idle_memory(ob_context *context, ob_error **error);
/**
* @brief For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type.
* @brief It is effective when the new device is created.
*
* @attention This interface is only available for Linux.
*
* @param[in] context Pointer to the context object
* @param[in] backend_type The backend type to be used.
* @param[out] error Pointer to an error object that will be populated if an error occurs during backend type setting
*/
OB_EXPORT void ob_set_uvc_backend_type(ob_context *context, ob_uvc_backend_type backend_type, ob_error **error);
/**
* @brief Set the global log level
*
* @attention This interface setting will affect the output level of all logs (terminal, file, callback)
*
* @param[in] severity Log level to set
* @param[out] error Pointer to an error object that will be populated if an error occurs during log level setting
*/
OB_EXPORT void ob_set_logger_severity(ob_log_severity severity, ob_error **error);
/**
* @brief Set the log output to a file
*
* @param[in] severity Log level to output to file
* @param[in] directory Path to the log file output directory. 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[out] error Pointer to an error object that will be populated if an error occurs during log output setting
*/
OB_EXPORT void ob_set_logger_to_file(ob_log_severity severity, const char *directory, ob_error **error);
/**
* @brief Set the log callback function
*
* @param[in] severity Log level to set for the callback function
* @param[in] callback Pointer to the callback function
* @param[in] user_data Pointer to user data that can be passed to and retrieved from the callback function
* @param[out] error Pointer to an error object that will be populated if an error occurs during log callback function setting
*/
OB_EXPORT void ob_set_logger_to_callback(ob_log_severity severity, ob_log_callback callback, void *user_data, ob_error **error);
/**
* @brief Set the log output to the console
*
* @param[in] severity Log level to output to the console
* @param[out] error Pointer to an error object that will be populated if an error occurs during log output setting
*/
OB_EXPORT void ob_set_logger_to_console(ob_log_severity severity, ob_error **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, extensions path will be set to the current working directory.
* @param error Pointer to an error object that will be populated if an error occurs during extensions directory setting
*/
OB_EXPORT void ob_set_extensions_directory(const char *directory, ob_error **error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_enable_multi_device_sync ob_enable_device_clock_sync
#define ob_set_logger_callback ob_set_logger_to_callback
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,768 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Device.h
* @brief Device-related functions, including operations such as obtaining and creating a device, setting and obtaining device property, and obtaining sensors
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
#include "Property.h"
#include "MultipleDevices.h"
#include "Advanced.h"
/**
* @brief Delete a device.
*
* @param[in] device The device to be deleted.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_device(ob_device *device, ob_error **error);
/**
* @brief List all sensors.
*
* @param[in] device The device object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_sensor_list* The list of all sensors.
*/
OB_EXPORT ob_sensor_list *ob_device_get_sensor_list(const ob_device *device, ob_error **error);
/**
* @brief Get a device's sensor.
*
* @param[in] device The device object.
* @param[in] type The type of sensor to get.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_sensor* The acquired sensor.
*/
OB_EXPORT ob_sensor *ob_device_get_sensor(ob_device *device, ob_sensor_type type, ob_error **error);
/**
* @brief Set an integer type of device property.
*
* @param[in] device The device object.
* @param[in] property_id The ID of the property to be set.
* @param[in] value The property value to be set.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_set_int_property(ob_device *device, ob_property_id property_id, int32_t value, ob_error **error);
/**
* @brief Get an integer type of device property.
*
* @param[in] device The device object.
* @param[in] property_id The property ID.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return int32_t The property value.
*/
OB_EXPORT int32_t ob_device_get_int_property(ob_device *device, ob_property_id property_id, ob_error **error);
/**
* @brief Get the integer type of device property range.
*
* @param[in] device The device object.
* @param[in] property_id The property id.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The property range.
*/
OB_EXPORT ob_int_property_range ob_device_get_int_property_range(ob_device *device, ob_property_id property_id, ob_error **error);
/**
* @brief Set a float type of device property.
*
* @param[in] device The device object.
* @param[in] property_id The ID of the property to be set.
* @param[in] value The property value to be set.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_set_float_property(ob_device *device, ob_property_id property_id, float value, ob_error **error);
/**
* @brief Get a float type of device property.
*
* @param[in] device The device object.
* @param[in] property_id The property ID.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return float The property value.
*/
OB_EXPORT float ob_device_get_float_property(ob_device *device, ob_property_id property_id, ob_error **error);
/**
* @brief Get the float type of device property range.
*
* @param[in] device The device object.
* @param[in] property_id The property id.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The property range.
*/
OB_EXPORT ob_float_property_range ob_device_get_float_property_range(ob_device *device, ob_property_id property_id, ob_error **error);
/**
* @brief Set a boolean type of device property.
*
* @param[in] device The device object.
* @param[in] property_id The ID of the property to be set.
* @param[in] value The property value to be set.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_set_bool_property(ob_device *device, ob_property_id property_id, bool value, ob_error **error);
/**
* @brief Get a boolean type of device property.
*
* @param[in] device The device object.
* @param[in] property_id The property ID.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return bool The property value.
*/
OB_EXPORT bool ob_device_get_bool_property(ob_device *device, ob_property_id property_id, ob_error **error);
/**
* @brief Get the boolean type of device property range.
*
* @param[in] device The device object.
* @param[in] property_id The property id.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The property range.
*/
OB_EXPORT ob_bool_property_range ob_device_get_bool_property_range(ob_device *device, ob_property_id property_id, ob_error **error);
/**
* @brief Set structured data.
*
* @param[in] device The device object.
* @param[in] property_id The ID of the property to be set.
* @param[in] data The property data to be set.
* @param[in] data_size The size of the property to be set.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_set_structured_data(ob_device *device, ob_property_id property_id, const uint8_t *data, uint32_t data_size, ob_error **error);
/**
* @brief Get structured data of a device property.
*
* @param[in] device The device object.
* @param[in] property_id The ID of the property.
* @param[out] data The obtained property data.
* @param[out] data_size The size of the obtained property data.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_get_structured_data(ob_device *device, ob_property_id property_id, uint8_t *data, uint32_t *data_size, ob_error **error);
/**
* @brief Get raw data of a device property.
*
* @param[in] device The device object.
* @param[in] property_id The ID of the property.
* @param[out] cb The get data callback.
* @param[out] user_data User-defined data that will be returned in the callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_get_raw_data(ob_device *device, ob_property_id property_id, ob_get_data_callback cb, void *user_data, ob_error **error);
/**
* @brief Set customer data.
*
* @param[in] device The device object.
* @param[in] data The property data to be set.
* @param[in] data_size The size of the property to be set,the maximum length cannot exceed 65532 bytes.
* @param[out] error Log error messages.
*/
OB_EXPORT void ob_device_write_customer_data(ob_device *device, const void *data, uint32_t data_size, ob_error **error);
/**
* @brief Get customer data of a device property.
*
* @param[in] device The device object.
* @param[out] data The obtained property data.
* @param[out] data_size The size of the obtained property data.
* @param[out] error Log error messages.
*/
OB_EXPORT void ob_device_read_customer_data(ob_device *device, void *data, uint32_t *data_size, ob_error **error);
/**
* @brief Get the number of properties supported by the device.
*
* @param[in] device The device object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The number of properties supported by the device.
*/
OB_EXPORT uint32_t ob_device_get_supported_property_count(const ob_device *device, ob_error **error);
/**
* @brief Get the type of property supported by the device.
*
* @param[in] device The device object.
* @param[in] index The property index.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The type of property supported by the device.
*/
OB_EXPORT ob_property_item ob_device_get_supported_property_item(const ob_device *device, uint32_t index, ob_error **error);
/**
* @brief Check if a device property permission is supported.
*
* @param[in] device The device object.
* @param[in] property_id The property id.
* @param[in] permission The type of permission that needs to be interpreted.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return Whether the property permission is supported.
*/
OB_EXPORT bool ob_device_is_property_supported(const ob_device *device, ob_property_id property_id, ob_permission_type permission, ob_error **error);
/**
* @brief Check if the device supports global timestamp.
*
* @param[in] device The device object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return bool Whether the device supports global timestamp.
*/
OB_EXPORT bool ob_device_is_global_timestamp_supported(const ob_device *device, ob_error **error);
/**
* @brief Enable or disable global timestamp.
*
* @param device The device object.
* @param enable Whether to enable global timestamp.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_enable_global_timestamp(ob_device *device, bool enable, ob_error **error);
/**
* @brief Update the device firmware.
*
* @param[in] device The device object.
* @param[in] path The firmware path.
* @param[in] callback The firmware upgrade progress callback.
* @param[in] async Whether to execute asynchronously.
* @param[in] user_data User-defined data that will be returned in the callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_update_firmware(ob_device *device, const char *path, ob_device_fw_update_callback callback, bool async, void *user_data,
ob_error **error);
/**
* @brief Update the device firmware from data.
*
* @param[in] device The device object.
* @param[in] data The firmware file data.
* @param[in] data_size The firmware file size.
* @param[in] callback The firmware upgrade progress callback.
* @param[in] async Whether to execute asynchronously.
* @param[in] user_data User-defined data that will be returned in the callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_update_firmware_from_data(ob_device *device, const uint8_t *data, uint32_t data_size, ob_device_fw_update_callback callback,
bool async, void *user_data, ob_error **error);
/**
* @brief Update the device optional depth presets.
*
* @param[in] device The device object.
* @param[in] file_path_list A list(2D array) of preset file paths, each up to OB_PATH_MAX characters.
* @param[in] path_count The number of the preset file paths.
* @param[in] callback The preset upgrade progress callback.
* @param[in] user_data User-defined data that will be returned in the callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_update_optional_depth_presets(ob_device *device, const char file_path_list[][OB_PATH_MAX], uint8_t path_count,
ob_device_fw_update_callback callback, void *user_data, ob_error **error);
/**
* @brief Device reboot
* @attention The device will be disconnected and reconnected. After the device is disconnected, the interface access to the device handle may be abnormal.
* Please use the ob_delete_device interface to delete the handle directly. After the device is reconnected, it can be obtained again.
*
* @param[in] device Device object
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_reboot(ob_device *device, ob_error **error);
/**
* @brief Get the current device status.
*
* @param[in] device The device object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_device_state The device state information.
*/
OB_EXPORT ob_device_state ob_device_get_device_state(const ob_device *device, ob_error **error);
/**
* @brief Set the device state changed callback.
*
* @param[in] device The device object.
* @param[in] callback The callback function to be called when the device status changes.
* @param[in] user_data User-defined data that will be returned in the callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_set_state_changed_callback(ob_device *device, ob_device_state_callback callback, void *user_data, ob_error **error);
/**
* @brief Enable or disable the device heartbeat.
* @brief After enable the device heartbeat, the sdk will start a thread to send heartbeat signal to the device error every 3 seconds.
* @attention If the device does not receive the heartbeat signal for a long time, it will be disconnected and rebooted.
*
* @param[in] device The device object.
* @param[in] enable Whether to enable the device heartbeat.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_enable_heartbeat(ob_device *device, bool enable, ob_error **error);
/**
* @brief Send data to the device and receive data from the device.
* @brief This is a factory and debug function, which can be used to send and receive data from the device. The data format is secret and belongs to the device
* vendor.
*
* @param[in] device The device object.
* @param[in] send_data The data to be sent to the device.
* @param[in] send_data_size The size of the data to be sent to the device.
* @param[out] receive_data The data received from the device.
* @param[in,out] receive_data_size Pass in the expected size of the receive data, and return the actual size of the received data.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_send_and_receive_data(ob_device *device, const uint8_t *send_data, uint32_t send_data_size, uint8_t *receive_data,
uint32_t *receive_data_size, ob_error **error);
/**
* @brief Get device information.
*
* @param[in] device The device to obtain information from.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device_info* The device information.
*/
OB_EXPORT ob_device_info *ob_device_get_device_info(const ob_device *device, ob_error **error);
/**
* @brief Delete device information.
*
* @param[in] info The device information to be deleted.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_device_info(ob_device_info *info, ob_error **error);
/**
* @brief Get device name
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* return the device name
*/
OB_EXPORT const char *ob_device_info_get_name(const ob_device_info *info, ob_error **error);
/**
* @brief Get device pid
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return int return the device pid
*/
OB_EXPORT int ob_device_info_get_pid(const ob_device_info *info, ob_error **error);
/**
* @brief Get device vid
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return int return device vid
*/
OB_EXPORT int ob_device_info_get_vid(const ob_device_info *info, ob_error **error);
/**
* @brief Get device uid
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* return device uid
*/
OB_EXPORT const char *ob_device_info_get_uid(const ob_device_info *info, ob_error **error);
/**
* @brief Get device serial number
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* return device serial number
*/
OB_EXPORT const char *ob_device_info_get_serial_number(const ob_device_info *info, ob_error **error);
/**
* @brief Get the firmware version number
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return int return the firmware version number
*/
OB_EXPORT const char *ob_device_info_get_firmware_version(const ob_device_info *info, ob_error **error);
/**
* @brief Get the device connection type
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The connection type, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2", "Ethernet"
*/
OB_EXPORT const char *ob_device_info_get_connection_type(const ob_device_info *info, ob_error **error);
/**
* @brief Get the device IP address
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0"
*
* @param info Device Information
* @param error Pointer to an error object that will be set if an error occurs.
* @return const char* The IP address, such as "192.168.1.10"
*/
OB_EXPORT const char *ob_device_info_get_ip_address(const ob_device_info *info, ob_error **error);
/**
* @brief Get the network device subnet mask
*
* @param[in] info Device information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The subnet mask, such as "255.255.255.0"
*/
OB_EXPORT const char *ob_device_info_get_subnet_mask(const ob_device_info *info, ob_error **error);
/**
* @brief Get the network device gateway address
*
* @param[in] info Device information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The gateway address, such as "192.168.1.1"
*/
OB_EXPORT const char *ob_device_info_get_gateway(const ob_device_info *info, ob_error **error);
/**
* @brief Get the hardware version number
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The hardware version number
*/
OB_EXPORT const char *ob_device_info_get_hardware_version(const ob_device_info *info, ob_error **error);
/**
* @brief Check if the device extension information exists.
*
* @param device The device object.
* @param info_key The key of the device extension information.
* @param error Pointer to an error object that will be set if an error occurs.
* @return bool Whether the device extension information exists.
*/
OB_EXPORT bool ob_device_is_extension_info_exist(const ob_device *device, const char *info_key, ob_error **error);
/**
* @brief Get the device extension information.
* @brief Extension information is a set of key-value pair of string, user cat get the information by the key.
*
* @param[in] device The device object.
* @param[in] info_key The key of the device extension information.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The device extension information
*/
OB_EXPORT const char *ob_device_get_extension_info(const ob_device *device, const char *info_key, ob_error **error);
/**
* @brief Get the minimum SDK version number supported by the device
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The minimum SDK version number supported by the device
*/
OB_EXPORT const char *ob_device_info_get_supported_min_sdk_version(const ob_device_info *info, ob_error **error);
/**
* @brief Get the chip name
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The ASIC name
*/
OB_EXPORT const char *ob_device_info_get_asicName(const ob_device_info *info, ob_error **error);
/**
* @brief Get the device type
*
* @param[in] info Device Information
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device_type The device type
*/
OB_EXPORT ob_device_type ob_device_info_get_device_type(const ob_device_info *info, ob_error **error);
/**
* @brief Delete a device list.
*
* @param[in] list The device list object to be deleted.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_device_list(ob_device_list *list, ob_error **error);
/**
* @brief Get the number of devices
*
* @param[in] list Device list object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the number of devices
*/
OB_EXPORT uint32_t ob_device_list_get_count(const ob_device_list *list, ob_error **error);
/**
* @brief Get device name
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* return device name
*/
OB_EXPORT const char *ob_device_list_get_device_name(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the pid of the specified device
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return int return the device pid
*/
OB_EXPORT int ob_device_list_get_device_pid(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the vid of the specified device
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return int return device vid
*/
OB_EXPORT int ob_device_list_get_device_vid(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the uid of the specified device
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* return the device uid
*/
OB_EXPORT const char *ob_device_list_get_device_uid(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the serial number of the specified device.
*
* @param[in] list Device list object.
* @param[in] index Device index.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The device UID.
*/
OB_EXPORT const char *ob_device_list_get_device_serial_number(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get device connection type
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* returns the device connection type, currently supports: "USB", "USB1.0", "USB1.1", "USB2.0", "USB2.1", "USB3.0", "USB3.1", "USB3.2",
* "Ethernet"
*/
OB_EXPORT const char *ob_device_list_get_device_connection_type(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get device ip address
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param list Device list object
* @param index Device index
* @param error Pointer to an error object that will be set if an error occurs.
* @return const char* returns the device ip address, such as "192.168.1.10"
*/
OB_EXPORT const char *ob_device_list_get_device_ip_address(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get device subnet mask
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* returns the device subnet mask, such as "255.255.255.0"
*/
OB_EXPORT const char *ob_device_list_get_device_subnet_mask(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get device gateway
*
* @attention Only valid for network devices, otherwise it will return "0.0.0.0".
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* returns the device gateway, such as "192.168.1.1"
*/
OB_EXPORT const char *ob_device_list_get_device_gateway(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the MAC address of the host network interface corresponding to the network device.
*
* @attention Only valid for network devices. Returns "0:0:0:0:0:0" for non-network devices.
*
* @param list Device list object
* @param index Device index
* @param error Pointer to an error object that will be set if an error occurs.
* @return const char* The MAC address of the host network interface associated with the device.
*/
OB_EXPORT const char *ob_device_list_get_device_local_mac(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the IP address of the host network interface corresponding to the network device.
*
* @attention Only valid for network devices. Returns "0.0.0.0" for non-network devices.
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The IP address of the host network interface associated with the device.
*/
OB_EXPORT const char *ob_device_list_get_device_local_ip(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the subnet length of the host network interface corresponding to the network device.
*
* @attention Only valid for network devices. Returns 0 for non-network devices.
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const uint8_t The subnet length (0~32) of the host network interface associated with the device.
*/
OB_EXPORT uint8_t ob_device_list_get_device_local_subnet_length(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Get the gateway of the host network interface corresponding to the network device.
*
* @attention Only valid for network devices. Returns "0.0.0.0" for non-network devices.
*
* @param[in] list Device list object
* @param[in] index Device index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const char* The gateway of the host network interface associated with the device.
*/
OB_EXPORT const char *ob_device_list_get_device_local_gateway(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Create a device.
*
* @attention If the device has already been acquired and created elsewhere, repeated acquisitions will return an error.
*
* @param[in] list Device list object.
* @param[in] index The index of the device to create.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device* The created device.
*
*/
OB_EXPORT ob_device *ob_device_list_get_device(const ob_device_list *list, uint32_t index, ob_error **error);
/**
* @brief Create a device.
*
* @attention If the device has already been acquired and created elsewhere, repeated acquisitions will return an error.
*
* @param[in] list Device list object.
* @param[in] serial_number The serial number of the device to create.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device* The created device.
*/
OB_EXPORT ob_device *ob_device_list_get_device_by_serial_number(const ob_device_list *list, const char *serial_number, ob_error **error);
/**
* @brief Create device by uid
* @brief On Linux platform, for usb device, the uid of the device is composed of bus-port-dev, for example 1-1.2-1. But the SDK will remove the dev number and
* only keep the bus-port as the uid to create the device, for example 1-1.2, so that we can create a device connected to the specified USB port. Similarly,
* users can also directly pass in bus-port as uid to create device.
* @brief For GMSL device, the uid is GMSL port with "gmsl2-" prefix, for example gmsl2-1.
*
* @attention If the device has already been acquired and created elsewhere, repeated acquisitions will return an error.
*
* @param[in] list Device list object.
* @param[in] uid The UID of the device to create.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device* The created device.
*/
OB_EXPORT ob_device *ob_device_list_get_device_by_uid(const ob_device_list *list, const char *uid, ob_error **error);
/**
* @brief Get the original parameter list of camera calibration saved on the device.
*
* @attention The parameters in the list do not correspond to the current open-stream configuration.You need to select the parameters according to the actual
* situation, and may need to do scaling, mirroring and other processing. Non-professional users are recommended to use the ob_pipeline_get_camera_param()
* interface.
*
* @param[in] device The device object.
* @param[out] error Log error messages.
*
* @return ob_camera_param_list The camera parameter list.
*/
OB_EXPORT ob_camera_param_list *ob_device_get_calibration_camera_param_list(ob_device *device, ob_error **error);
/**
* @brief Get the number of camera parameter lists
*
* @param[in] param_list Camera parameter list
* @param[out] error Log error messages
* @return uint32_t The number of lists
*/
OB_EXPORT uint32_t ob_camera_param_list_get_count(ob_camera_param_list *param_list, ob_error **error);
/**
* @brief Get camera parameters from the camera parameter list
*
* @param[in] param_list Camera parameter list
* @param[in] index Parameter index
* @param[out] error Log error messages
* @return ob_camera_param The camera parameters. Since it returns the structure object directly, there is no need to provide a delete interface.
*/
OB_EXPORT ob_camera_param ob_camera_param_list_get_param(ob_camera_param_list *param_list, uint32_t index, ob_error **error);
/**
* @brief Delete the camera parameter list
*
* @param[in] param_list Camera parameter list
* @param[out] error Log error messages
*/
OB_EXPORT void ob_delete_camera_param_list(ob_camera_param_list *param_list, ob_error **error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_device_list_device_count ob_device_list_get_count
#define ob_device_list_get_extension_info ob_device_info_get_extension_info
#define ob_device_upgrade ob_device_update_firmware
#define ob_device_upgrade_from_data ob_device_update_firmware_from_data
#define ob_device_get_supported_property ob_device_get_supported_property_item
#define ob_device_state_changed ob_device_set_state_changed_callback
#define ob_device_info_name ob_device_info_get_name
#define ob_device_info_pid ob_device_info_get_pid
#define ob_device_info_vid ob_device_info_get_vid
#define ob_device_info_uid ob_device_info_get_uid
#define ob_device_info_serial_number ob_device_info_get_serial_number
#define ob_device_info_firmware_version ob_device_info_get_firmware_version
#define ob_device_info_connection_type ob_device_info_get_connection_type
#define ob_device_info_ip_address ob_device_info_get_ip_address
#define ob_device_info_hardware_version ob_device_info_get_hardware_version
#define ob_device_info_supported_min_sdk_version ob_device_info_get_supported_min_sdk_version
#define ob_device_info_asicName ob_device_info_get_asicName
#define ob_device_info_device_type ob_device_info_get_device_type
#define ob_device_list_get_device_count ob_device_list_get_count
#define ob_camera_param_list_count ob_camera_param_list_get_count
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,84 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Error.h
* @brief Functions for handling errors, mainly used for obtaining error messages.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Create a new error object.
*
* @param status The error status.
* @param message The error message.
* @param function The name of the API function that caused the error.
* @param args The error parameters.
* @param exception_type The type of exception that caused the error.
* @return ob_error* The new error object.
*/
OB_EXPORT ob_error *ob_create_error(ob_status status, const char *message, const char *function, const char *args, ob_exception_type exception_type);
/**
* @brief Get the error status.
*
* @param[in] error The error object.
* @return The error status.
*/
OB_EXPORT ob_status ob_error_get_status(const ob_error *error);
/**
* @brief Get the error message.
*
* @param[in] error The error object.
* @return The error message.
*/
OB_EXPORT const char *ob_error_get_message(const ob_error *error);
/**
* @brief Get the name of the API function that caused the error.
*
* @param[in] error The error object.
* @return The name of the API function.
*/
OB_EXPORT const char *ob_error_get_function(const ob_error *error);
/**
* @brief Get the error parameters.
*
* @param[in] error The error object.
* @return The error parameters.
*/
OB_EXPORT const char *ob_error_get_args(const ob_error *error);
/**
* @brief Get the type of exception that caused the error.
*
* @param[in] error The error object.
* @return The type of exception.
*/
OB_EXPORT ob_exception_type ob_error_get_exception_type(const ob_error *error);
/**
* @brief Delete the error object.
*
* @param[in] error The error object to delete, you should set the pointer to NULL after calling this function.
*/
OB_EXPORT void ob_delete_error(ob_error *error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_error_status ob_error_get_status
#define ob_error_message ob_error_get_message
#define ob_error_function ob_error_get_function
#define ob_error_args ob_error_get_args
#define ob_error_exception_type ob_error_get_exception_type
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,43 @@
#ifndef OB_EXPORT_H
#define OB_EXPORT_H
#ifdef OB_STATIC_DEFINE
# define OB_EXPORT
# define OB_NO_EXPORT
#else
# ifndef OB_EXPORT
# ifdef OrbbecSDK_EXPORTS
/* We are building this library */
# define OB_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define OB_EXPORT __attribute__((visibility("default")))
# endif
# endif
# ifndef OB_NO_EXPORT
# define OB_NO_EXPORT __attribute__((visibility("hidden")))
# endif
#endif
#ifndef OB_DEPRECATED
# define OB_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef OB_DEPRECATED_EXPORT
# define OB_DEPRECATED_EXPORT OB_EXPORT OB_DEPRECATED
#endif
#ifndef OB_DEPRECATED_NO_EXPORT
# define OB_DEPRECATED_NO_EXPORT OB_NO_EXPORT OB_DEPRECATED
#endif
/* NOLINTNEXTLINE(readability-avoid-unconditional-preprocessor-if) */
#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef OB_NO_DEPRECATED
# define OB_NO_DEPRECATED
# endif
#endif
#endif /* OB_EXPORT_H */

View File

@@ -0,0 +1,265 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Filter.h
* @brief The processing unit of the SDK can perform point cloud generation, format conversion and other functions.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Create a Filter object.
*
* @attention If the filter of the specified name is a private filter, and the creator of the filter have not been activated, the function will return NULL.
*
* @param name The name of the filter.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT ob_filter *ob_create_filter(const char *name, ob_error **error);
/**
* @brief Get the name of ob_filter
*
* @param filter ob_filter object
* @param error Pointer to an error object that will be set if an error occurs.
* @return char The filter of name
*/
OB_EXPORT const char *ob_filter_get_name(const ob_filter *filter, ob_error **error);
/**
* @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 error Pointer to an error object that will be set if an error occurs.
* @return const char* Return the vendor specific code of the filter.
*/
OB_EXPORT const char *ob_filter_get_vendor_specific_code(const char *name, ob_error **error);
/**
* @brief Create a private Filter object with 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 activation_key The activation key of the filter.
* @param error Pointer to an error object that will be set if an error occurs.
*
* @return ob_filter* Return the private filter object.
*/
OB_EXPORT ob_filter *ob_create_private_filter(const char *name, const char *activation_key, ob_error **error);
/**
* @brief Delete the filter.
*
* @param[in] filter The filter object to be deleted.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_filter(ob_filter *filter, ob_error **error);
/**
* @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>
*
* @param[in] filter The filter object to get the configuration schema for
* @param[out] error Pointer to an error object that will be set if an error occurs
*
* @return A csv format string representing the configuration schema of the filter
*/
OB_EXPORT const char *ob_filter_get_config_schema(const ob_filter *filter, ob_error **error);
/**
* @brief Get the filter config schema list of the filter
* @brief The returned string is a list of ob_config_schema_item representing the configuration schema of the filter.
*
* @attention The returned list should be deleted by calling @ref ob_delete_filter_config_schema_list when it is no longer needed.
*
* @param filter The filter object to get the configuration schema for
* @param error Pointer to an error object that will be set if an error occurs
* @return ob_filter_config_schema_list* Return the filter config schema list of the filter
*/
OB_EXPORT ob_filter_config_schema_list *ob_filter_get_config_schema_list(const ob_filter *filter, ob_error **error);
/**
* @brief Delete a list of filter config schema items.
*
* @param config_schema_list The list of filter config schema items to delete.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_filter_config_schema_list(ob_filter_config_schema_list *config_schema_list, ob_error **error);
/**
* @brief Update config of the filter
*
* @attention The passed in argc and argv must match the configuration schema returned by the @ref ob_filter_get_config_schema function.
*
* @param[in] filter The filter object to update the configuration for
* @param[in] argc The number of arguments in the argv array
* @param[in] argv An array of strings representing the configuration values
* @param[out] error Pointer to an error object that will be set if an error occurs
*/
OB_EXPORT void ob_filter_update_config(ob_filter *filter, uint8_t argc, const char **argv, ob_error **error);
/**
* @brief Get the filter config value by name and cast to double.
*
* @attention The returned value is cast to double, the actual type of the value depends on the filter config schema returned by @ref
* ob_filter_get_config_schema.
*
* @param[in] filter A filter object.
* @param[in] config_name config name
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return double The value of the config.
*/
OB_EXPORT double ob_filter_get_config_value(const ob_filter *filter, const char *config_name, ob_error **error);
/**
* @brief Set the filter config value by name.
*
* @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 ob_filter_get_config_schema.
*
* @param[in] filter A filter object.
* @param[in] config_name config name
* @param[in] value The value to set.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_filter_set_config_value(ob_filter *filter, const char *config_name, double value, ob_error **error);
/**
* @brief Reset the filter, clears the cache, and resets the state. If the asynchronous interface is used, the processing thread will also be stopped and the
* pending cache frames will be cleared.
*
* @param[in] filter A filter object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_filter_reset(ob_filter *filter, ob_error **error);
/**
* @brief Enable the frame post processing
* @brief The filter default is enable.
*
* @attention If the filter has been disabled by calling this function, processing will directly output a clone of the input frame.
*
* @param[in] filter A filter object.
* @param[in] enable enable status, true: enable; false: disable.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_filter_enable(ob_filter *filter, bool enable, ob_error **error);
/**
* @brief Get the enable status of the frame post processing
*
* @attention If the filter is disabled, the processing will directly output a clone of the input frame.
*
* @param[in] filter A filter object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return The post processing filter status. True: enable; False: disable.
*/
OB_EXPORT bool ob_filter_is_enabled(const ob_filter *filter, ob_error **error);
/**
* @brief Process the frame (synchronous interface).
*
* @param[in] filter A filter object.
* @param[in] frame Pointer to the frame object to be processed.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return The frame object processed by the filter.
*/
OB_EXPORT ob_frame *ob_filter_process(ob_filter *filter, const ob_frame *frame, ob_error **error);
/**
* @brief Set the processing result callback function for the filter (asynchronous callback interface).
*
* @param[in] filter A filter object.
* @param[in] callback Callback function.
* @param[in] user_data Arbitrary user data pointer can be passed in and returned from the callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_filter_set_callback(ob_filter *filter, ob_filter_callback callback, void *user_data, ob_error **error);
/**
* @brief Push the frame into the pending cache for the filter (asynchronous callback interface).
* @brief The frame will be processed by the filter when the processing thread is available and return a new processed frame to the callback function.
*
* @attention The frame object will be add reference count, so the user still need call @ref ob_delete_frame to release the frame after calling this function.
*
* @param[in] filter A filter object.
* @param[in] frame Pointer to the frame object to be processed.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_filter_push_frame(ob_filter *filter, const ob_frame *frame, ob_error **error);
/**
* @brief Get the number of filter in the list
*
* @param[in] filter_list filter list
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t The number of list
*/
OB_EXPORT uint32_t ob_filter_list_get_count(const ob_filter_list *filter_list, ob_error **error);
/**
* @brief Get the filter by index
*
* @param[in] filter_list Filter list
* @param[in] index Filter index
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_filter The index of ob_filter
*/
OB_EXPORT ob_filter *ob_filter_list_get_filter(const ob_filter_list *filter_list, uint32_t index, ob_error **error);
/**
* @brief Delete a list of ob_filter objects.
*
* @param[in] filter_list The list of ob_filter objects to delete.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_filter_list(ob_filter_list *filter_list, ob_error **error);
/**
* @brief Get the number of config schema items in the config schema list
*
* @param config_schema_list Filter config schema list
* @param error Pointer to an error object that will be set if an error occurs.
* @return uint32_t The number of config schema items in the filter list
*/
OB_EXPORT uint32_t ob_filter_config_schema_list_get_count(const ob_filter_config_schema_list *config_schema_list, ob_error **error);
/**
* @brief Get the config schema item by index
*
* @param config_schema_list Filter config schema list
* @param index Config schema item index
* @param error Pointer to an error object that will be set if an error occurs.
* @return ob_filter_config_schema_item* The config schema item by index
*/
OB_EXPORT ob_filter_config_schema_item ob_filter_config_schema_list_get_item(const ob_filter_config_schema_list *config_schema_list, uint32_t index,
ob_error **error);
/**
* @brief Set the align to stream profile for the align filter.
* @brief It is useful when the align target stream dose not started (without any frame to get intrinsics and extrinsics).
*
* @param filter A filter object.
* @param align_to_stream_profile The align target stream profile.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_align_filter_set_align_to_stream_profile(ob_filter *filter, const ob_stream_profile *align_to_stream_profile, ob_error **error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_get_filter ob_filter_list_get_filter
#define ob_get_filter_name ob_filter_get_name
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,657 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Frame.h
* @brief Frame related function is mainly used to obtain frame data and frame information
*
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Crate a frame object based on the specified parameters.
*
* @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is
* no longer needed.
*
* @param frame_type The frame object type.
* @param format The frame object format.
* @param data_size The size of the frame object data.
* @param error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the frame object.
*/
OB_EXPORT ob_frame *ob_create_frame(ob_frame_type frame_type, ob_format format, uint32_t data_size, ob_error **error);
/**
* @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.
*
* @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is
* no longer needed.
*
* @param[in] other_frame The frame object to create the new frame object according to.
* @param[in] should_copy_data 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.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the new frame object.
*/
OB_EXPORT ob_frame *ob_create_frame_from_other_frame(const ob_frame *other_frame, bool should_copy_data, ob_error **error);
/**
* @brief Create a frame object according to the specified stream profile.
*
* @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is
* no logger needed.
*
* @param stream_profile The stream profile to create the new frame object according to.
* @param error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the new frame object.
*/
OB_EXPORT ob_frame *ob_create_frame_from_stream_profile(const ob_stream_profile *stream_profile, ob_error **error);
/**
* @brief Create an video frame object based on the specified parameters.
*
* @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is
* no longer needed.
*
* @param[in] frame_type Frame object type.
* @param[in] format Frame object format.
* @param[in] width Frame object width.
* @param[in] height Frame object height.
* @param[in] stride_bytes Row span in bytes. If 0, the stride is calculated based on the width and format.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return an empty frame object.
*/
OB_EXPORT ob_frame *ob_create_video_frame(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes, ob_error **error);
/**
* @brief Create a frame object based on an externally created buffer.
*
* @attention The buffer is owned by the user and will not be destroyed by the frame object. The user should ensure that the buffer is valid and not modified.
* @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is
* no longer needed.
*
* @param[in] frame_type Frame object type.
* @param[in] format Frame object format.
* @param[in] buffer Frame object buffer.
* @param[in] buffer_size Frame object buffer size.
* @param[in] buffer_destroy_cb Destroy callback, will be called when the frame object is destroyed.
* @param[in] buffer_destroy_context Destroy context, user-defined context to be passed to the destroy callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the frame object.
*/
OB_EXPORT ob_frame *ob_create_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint8_t *buffer, uint32_t buffer_size,
ob_frame_destroy_callback *buffer_destroy_cb, void *buffer_destroy_context, ob_error **error);
/**
* @brief Create a video frame object based on an externally created buffer.
*
* @attention The buffer is owned by the user and will not be destroyed by the frame object. The user should ensure that the buffer is valid and not modified.
* @attention The frame object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it is
* no longer needed.
*
* @param[in] frame_type Frame object type.
* @param[in] format Frame object format.
* @param[in] width Frame object width.
* @param[in] height Frame object height.
* @param[in] stride_bytes Row span in bytes. If 0, the stride is calculated based on the width and format.
* @param[in] buffer Frame object buffer.
* @param[in] buffer_size Frame object buffer size.
* @param[in] buffer_destroy_cb Destroy callback, user-defined function to destroy the buffer.
* @param[in] buffer_destroy_context Destroy context, user-defined context to be passed to the destroy callback.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the frame object.
*/
OB_EXPORT ob_frame *ob_create_video_frame_from_buffer(ob_frame_type frame_type, ob_format format, uint32_t width, uint32_t height, uint32_t stride_bytes,
uint8_t *buffer, uint32_t buffer_size, ob_frame_destroy_callback *buffer_destroy_cb,
void *buffer_destroy_context, ob_error **error);
/**
* @brief Create an empty frameset object.
* @brief A frameset object is a special type of frame object that can be used to store multiple frames.
*
* @attention The frameset object is created with a reference count of 1, and the reference count should be decreased by calling @ref ob_delete_frame() when it
* is no longer needed.
*
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the frameset object.
*/
OB_EXPORT ob_frame *ob_create_frameset(ob_error **error);
/**
* @brief Increase the reference count of a frame object.
* @brief The reference count is used to manage the lifetime of the frame object.
*
* @attention When calling this function, the reference count of the frame object is
* increased and requires to be decreased by calling @ref ob_delete_frame().
*
* @param[in] frame Frame object to increase the reference count.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frame_add_ref(const ob_frame *frame, ob_error **error);
/**
* @brief Delete a frame object
* @brief This function will decrease the reference count of the frame object and release the memory if the reference count becomes 0.
*
* @param[in] frame The frame object to delete.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_frame(const ob_frame *frame, ob_error **error);
/**
* @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] src_frame Source frame object to copy the information from.
* @param[in] dst_frame Destination frame object to copy the information to.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frame_copy_info(const ob_frame *src_frame, ob_frame *dst_frame, ob_error **error);
/**
* @brief Get the frame index
*
* @param[in] frame Frame object
* @param[out] error Log wrong message
* @return uint64_t return the frame index
*/
OB_EXPORT uint64_t ob_frame_get_index(const ob_frame *frame, ob_error **error);
/**
* @brief Get the frame format
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_format return the frame format
*/
OB_EXPORT ob_format ob_frame_get_format(const ob_frame *frame, ob_error **error);
/**
* @brief Get the frame type
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame_type return the frame type
*/
OB_EXPORT ob_frame_type ob_frame_get_type(const ob_frame *frame, ob_error **error);
/**
* @brief Get the frame timestamp (also known as device timestamp, hardware timestamp) of the frame in microseconds.
* @brief The hardware timestamp is the time point when the frame was captured by the device (Typically in the mid-exposure, unless otherwise stated), on device
* clock domain.
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint64_t return the frame hardware timestamp in microseconds
*/
OB_EXPORT uint64_t ob_frame_get_timestamp_us(const ob_frame *frame, ob_error **error);
/**
* @brief Set the frame timestamp (also known as the device timestamp, hardware timestamp) of a frame object.
*
* @param[in] frame Frame object to set the timestamp.
* @param[in] timestamp_us frame timestamp to set in microseconds.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frame_set_timestamp_us(ob_frame *frame, uint64_t timestamp_us, ob_error **error);
/**
* @brief Get the system timestamp of the frame in microseconds.
* @brief The system timestamp is the time point when the frame was received by the host, on host clock domain.
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint64_t return the frame system timestamp in microseconds
*/
OB_EXPORT uint64_t ob_frame_get_system_timestamp_us(const ob_frame *frame, ob_error **error);
/**
* @brief Set the system timestamp of the frame in microseconds.
*
* @param frame Frame object
* @param system_timestamp_us frame system timestamp to set in microseconds.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frame_set_system_timestamp_us(ob_frame *frame, uint64_t system_timestamp_us, ob_error **error);
/**
* @brief Get the global timestamp of the frame in microseconds.
* @brief The global timestamp is the time point when the frame was captured by the device, and has been converted to the host clock domain. The
* conversion process base on the frame timestamp and can eliminate the timer drift of the device
*
* @attention The global timestamp is disabled by default. If global timestamp is not enabled, the function will return 0. To enable it, call @ref
* ob_device_enable_global_timestamp() function.
* @attention Only some models of device support getting the global timestamp. Check the device support status by @ref
* ob_device_is_global_timestamp_supported() function.
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint64_t The global timestamp of the frame in microseconds.
*/
OB_EXPORT uint64_t ob_frame_get_global_timestamp_us(const ob_frame *frame, ob_error **error);
/**
* @brief Get the data buffer of a frame.
*
* @attention The returned data buffer is mutable, but it is not recommended to modify it directly. Modifying the data directly may cause issues if the frame is
* being used in other threads or future use. If you need to modify the data, it is recommended to create a new frame object.
*
* @param[in] frame The frame object from which to retrieve the data.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint8_t* Pointer to the frame data buffer.
*/
OB_EXPORT uint8_t *ob_frame_get_data(const ob_frame *frame, ob_error **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] frame The frame object to update.
* @param[in] data The new data to update the frame with.
* @param[in] data_size The size of the new data.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frame_update_data(ob_frame *frame, const uint8_t *data, uint32_t data_size, ob_error **error);
/**
* @brief Get the frame data size
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the frame data size
* If it is point cloud data, it return the number of bytes occupied by all point sets. If you need to find the number of points, you need to divide dataSize
* by the structure size of the corresponding point type.
*/
OB_EXPORT uint32_t ob_frame_get_data_size(const ob_frame *frame, ob_error **error);
/**
* @brief Get the metadata of the frame
*
* @attention The returned metadata is mutable, but it is not recommended to modify it directly. Modifying the metadata directly may cause issues if the frame
* is being used in other threads or future use. If you need to modify the metadata, it is recommended to create a new frame object.
*
* @param[in] frame frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return const uint8_t * return the metadata pointer of the frame
*/
OB_EXPORT uint8_t *ob_frame_get_metadata(const ob_frame *frame, ob_error **error);
#define ob_video_frame_metadata ob_frame_get_metadata // for compatibility
/**
* @brief Get the metadata size of the frame
*
* @param[in] frame frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the metadata size of the frame
*/
OB_EXPORT uint32_t ob_frame_get_metadata_size(const ob_frame *frame, ob_error **error);
#define ob_video_frame_metadata_size ob_frame_get_metadata_size // for compatibility
/**
* @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] frame frame object
* @param[in] metadata The new metadata to update.
* @param[in] metadata_size The size of the new metadata.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frame_update_metadata(ob_frame *frame, const uint8_t *metadata, uint32_t metadata_size, ob_error **error);
/**
* @brief check if the frame contains the specified metadata
*
* @param[in] frame frame object
* @param[in] type metadata type, refer to @ref ob_frame_metadata_type
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT bool ob_frame_has_metadata(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error);
/**
* @brief Get the metadata value of the frame
*
* @param[in] frame frame object
* @param[in] type metadata type, refer to @ref ob_frame_metadata_type
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return int64_t return the metadata value of the frame
*/
OB_EXPORT int64_t ob_frame_get_metadata_value(const ob_frame *frame, ob_frame_metadata_type type, ob_error **error);
/**
* @brief Get the stream profile of the frame
*
* @attention Require @ref ob_delete_stream_profile() to release the return stream profile.
*
* @param frame frame object
* @param error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile* Return the stream profile of the frame, if the frame is not captured by a sensor stream, it will return NULL
*/
OB_EXPORT ob_stream_profile *ob_frame_get_stream_profile(const ob_frame *frame, ob_error **error);
/**
* @brief Set (override) the stream profile of the frame
*
* @param frame frame object
* @param stream_profile The stream profile to set for the frame.
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frame_set_stream_profile(ob_frame *frame, const ob_stream_profile *stream_profile, ob_error **error);
/**
* @brief Get the sensor of the frame
*
* @attention Require @ref ob_delete_sensor() to release the return sensor.
*
* @param[in] frame frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_sensor* return the sensor of the frame, if the frame is not captured by a sensor or the sensor stream has been destroyed, it will return NULL
*/
OB_EXPORT ob_sensor *ob_frame_get_sensor(const ob_frame *frame, ob_error **error);
/**
* @brief Get the device of the frame
*
* @attention Require @ref ob_delete_device() to release the return device.
*
* @param frame frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device* return the device of the frame, if the frame is not captured by a sensor stream or the device has been destroyed, it will return NULL
*/
OB_EXPORT ob_device *ob_frame_get_device(const ob_frame *frame, ob_error **error);
/**
* @brief Get video frame width
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the frame width
*/
OB_EXPORT uint32_t ob_video_frame_get_width(const ob_frame *frame, ob_error **error);
/**
* @brief Get video frame height
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the frame height
*/
OB_EXPORT uint32_t ob_video_frame_get_height(const ob_frame *frame, ob_error **error);
/**
* @brief Get video frame pixel format
* @brief Usually used to determine the pixel type of depth frame (depth, disparity, raw phase, etc.)
*
* @attention Always return OB_PIXEL_UNKNOWN for non-depth frame currently if user has not set the pixel type by @ref ob_video_frame_set_pixel_type()
*
* @param frame Frame object
* @param error Pointer to an error object that will be set if an error occurs.
* @return ob_pixel_type return the pixel format of the frame.
*/
OB_EXPORT ob_pixel_type ob_video_frame_get_pixel_type(const ob_frame *frame, ob_error **error);
/**
* @brief Set video frame pixel format
*
* @param frame Frame object
* @param pixel_type the pixel format of the frame
* @param error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_video_frame_set_pixel_type(ob_frame *frame, ob_pixel_type pixel_type, ob_error **error);
/**
* @brief Get 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] frame video frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint8_t return the effective number of pixels in the pixel, or 0 if it is an unsupported format
*/
OB_EXPORT uint8_t ob_video_frame_get_pixel_available_bit_size(const ob_frame *frame, ob_error **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] frame video frame object
* @param[in] bit_size the effective number of pixels in the pixel, or 0 if it is an unsupported format
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_video_frame_set_pixel_available_bit_size(ob_frame *frame, uint8_t bit_size, ob_error **error);
/**
* @brief Get the source sensor type of the ir frame (left or right for dual camera)
*
* @param frame Frame object
* @param ob_error Pointer to an error object that will be set if an error occurs.
* @return ob_sensor_type return the source sensor type of the ir frame
*/
OB_EXPORT ob_sensor_type ob_ir_frame_get_source_sensor_type(const ob_frame *frame, ob_error **ob_error);
/**
* @brief Get 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] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return float The value scale of the depth frame
*/
OB_EXPORT float ob_depth_frame_get_value_scale(const ob_frame *frame, ob_error **error);
/**
* @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] frame Frame object
* @param[in] value_scale The value scale of the depth frame
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_depth_frame_set_value_scale(ob_frame *frame, float value_scale, ob_error **error);
/**
* @brief Get the point coordinate value scale of the points frame. The point position value of the points frame is multiplied by the scale to give a position
* value in millimeters. For example, if scale=0.1, the x-coordinate value of a point is x = 10000, which means that the actual x-coordinate value = x*scale =
* 10000*0.1 = 1000mm.
*
* @param[in] frame Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return float The coordinate value scale of the points frame
*/
OB_EXPORT float ob_points_frame_get_coordinate_value_scale(const ob_frame *frame, ob_error **error);
/**
* @brief Get accelerometer frame data.
*
* @param[in] frame Accelerometer frame.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_accel_value Return the accelerometer data.
*/
OB_EXPORT ob_accel_value ob_accel_frame_get_value(const ob_frame *frame, ob_error **error);
/**
* @brief Get the temperature when acquiring the accelerometer frame.
*
* @param[in] frame Accelerometer frame.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return float Return the temperature value.
*/
OB_EXPORT float ob_accel_frame_get_temperature(const ob_frame *frame, ob_error **error);
/**
* @brief Get gyroscope frame data.
*
* @param[in] frame Gyroscope frame.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_gyro_value Return the gyroscope data.
*/
OB_EXPORT ob_gyro_value ob_gyro_frame_get_value(const ob_frame *frame, ob_error **error);
/**
* @brief Get the temperature when acquiring the gyroscope frame.
*
* @param[in] frame Gyroscope frame.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return float Return the temperature value.
*/
OB_EXPORT float ob_gyro_frame_get_temperature(const ob_frame *frame, ob_error **error);
/**
* @brief Get the number of frames contained in the frameset
*
* @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed.
*
* @param[in] frameset frameset object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the number of frames
*/
OB_EXPORT uint32_t ob_frameset_get_count(const ob_frame *frameset, ob_error **error);
/**
* @brief Get the depth frame from the frameset.
*
* @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed.
*
* @param[in] frameset Frameset object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the depth frame.
*/
OB_EXPORT ob_frame *ob_frameset_get_depth_frame(const ob_frame *frameset, ob_error **error);
/**
* @brief Get the color frame from the frameset.
*
* @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed.
*
* @param[in] frameset Frameset object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the color frame.
*/
OB_EXPORT ob_frame *ob_frameset_get_color_frame(const ob_frame *frameset, ob_error **error);
/**
* @brief Get the infrared frame from the frameset.
*
* @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed.
*
* @param[in] frameset Frameset object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the infrared frame.
*/
OB_EXPORT ob_frame *ob_frameset_get_ir_frame(const ob_frame *frameset, ob_error **error);
/**
* @brief Get point cloud frame from the frameset.
*
* @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed.
*
* @param[in] frameset Frameset object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the point cloud frame.
*/
OB_EXPORT ob_frame *ob_frameset_get_points_frame(const ob_frame *frameset, ob_error **error);
/**
* @brief Get a frame of a specific type from the frameset.
*
* @attention The frame returned by this function should call @ref ob_delete_frame() to decrease the reference count when it is no longer needed.
*
* @param[in] frameset Frameset object.
* @param[in] frame_type Frame type.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the frame of the specified type, or nullptr if it does not exist.
*/
OB_EXPORT ob_frame *ob_frameset_get_frame(const ob_frame *frameset, ob_frame_type frame_type, ob_error **error);
/**
* @brief Get a frame at a specific index from the FrameSet
*
* @param[in] frameset Frameset object.
* @param[in] index The index of the frame.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* Return the frame at the specified index, or nullptr if it does not exist.
*/
OB_EXPORT ob_frame *ob_frameset_get_frame_by_index(const ob_frame *frameset, uint32_t index, ob_error **error);
/**
* @brief Push a frame to the frameset
*
* @attention If a frame with same type already exists in the frameset, it will be replaced by the new frame.
* @attention The frame push to the frameset will be add reference count, so you still need to call @ref ob_delete_frame() to decrease the reference count when
* it is no longer needed.
*
* @param[in] frameset Frameset object.
* @param[in] frame Frame object to push.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_frameset_push_frame(ob_frame *frameset, const ob_frame *frame, ob_error **error);
/**
* @brief Get point cloud frame width
*
* @param[in] frame point cloud Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the point cloud frame width
*/
OB_EXPORT uint32_t ob_point_cloud_frame_get_width(const ob_frame *frame, ob_error **error);
/**
* @brief Get point cloud frame height
*
* @param[in] frame point cloud Frame object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the point cloud frame height
*/
OB_EXPORT uint32_t ob_point_cloud_frame_get_height(const ob_frame *frame, ob_error **error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_frame_index ob_frame_get_index
#define ob_frame_format ob_frame_get_format
#define ob_frame_time_stamp_us ob_frame_get_timestamp_us
#define ob_frame_set_device_time_stamp_us ob_frame_set_timestamp_us
#define ob_frame_system_time_stamp_us ob_frame_get_system_timestamp_us
#define ob_frame_global_time_stamp_us ob_frame_get_global_timestamp_us
#define ob_frame_data ob_frame_get_data
#define ob_frame_data_size ob_frame_get_data_size
#define ob_frame_metadata ob_frame_get_metadata
#define ob_frame_metadata_size ob_frame_get_metadata_size
#define ob_video_frame_width ob_video_frame_get_width
#define ob_video_frame_height ob_video_frame_get_height
#define ob_video_frame_pixel_available_bit_size ob_video_frame_get_pixel_available_bit_size
#define ob_points_frame_get_position_value_scale ob_points_frame_get_coordinate_value_scale
#define ob_frameset_frame_count ob_frameset_get_count
#define ob_frameset_depth_frame ob_frameset_get_depth_frame
#define ob_frameset_color_frame ob_frameset_get_color_frame
#define ob_frameset_ir_frame ob_frameset_get_ir_frame
#define ob_frameset_points_frame ob_frameset_get_points_frame
#define ob_accel_frame_value ob_accel_frame_get_value
#define ob_accel_frame_temperature ob_accel_frame_get_temperature
#define ob_gyro_frame_value ob_gyro_frame_get_value
#define ob_gyro_frame_temperature ob_gyro_frame_get_temperature
#define ob_frameset_get_frame_count ob_frameset_get_count
#define ob_frame_time_stamp(frame, err) (ob_frame_get_timestamp_us(frame, err) / 1000)
#define ob_frame_system_time_stamp(frame, err) (ob_frame_get_system_timestamp_us(frame, err))
#define ob_frame_set_system_time_stamp(frame, system_timestamp, err) (ob_frame_set_system_timestamp_us(frame, system_timestamp * 1000, err))
#define ob_frame_set_device_time_stamp(frame, device_timestamp, err) (ob_frame_set_timestamp_us(frame, device_timestamp * 1000, err))
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,128 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file MultipleDevices.h
* @brief This file contains the multiple devices related API witch is used to control the synchronization between multiple devices and the synchronization
* between different sensor within single device.
* @brief The synchronization between multiple devices is complex, and different models have different synchronization modes and limitations. please refer to
* the product manual for details.
* @brief As the Depth and Infrared are the same sensor physically, the behavior of the Infrared is same as the Depth in the synchronization mode.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
#include "Device.h"
/**
* @brief Get the supported multi device sync mode bitmap of the device.
* @brief For example, if the return value is 0b00001100, it means the device supports @ref OB_MULTI_DEVICE_SYNC_MODE_PRIMARY and @ref
* OB_MULTI_DEVICE_SYNC_MODE_SECONDARY. User can check the supported mode by the code:
* ```c
* if(supported_mode_bitmap & OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN){
* //support OB_MULTI_DEVICE_SYNC_MODE_FREE_RUN
* }
* if(supported_mode_bitmap & OB_MULTI_DEVICE_SYNC_MODE_STANDALONE){
* //support OB_MULTI_DEVICE_SYNC_MODE_STANDALONE
* }
* // and so on
* ```
* @param[in] device The device handle.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint16_t return the supported multi device sync mode bitmap of the device.
*/
OB_EXPORT uint16_t ob_device_get_supported_multi_device_sync_mode_bitmap(const ob_device *device, ob_error **error);
/**
* @brief set the multi device sync configuration of the device.
*
* @param[in] device The device handle.
* @param[in] config The multi device sync configuration.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_set_multi_device_sync_config(ob_device *device, const ob_multi_device_sync_config *config, ob_error **error);
/**
* @brief get the current multi device sync configuration of the device.
*
* @param[in] device The device handle.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_multi_device_sync_config return the multi device sync configuration of the device.
*/
OB_EXPORT ob_multi_device_sync_config ob_device_get_multi_device_sync_config(const ob_device *device, ob_error **error);
/**
* @brief send the capture command to the device to trigger the capture.
* @brief The device will start one time capture after receiving the capture command when it is in the @ref 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.
* @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.
*
* @param[in] device The device handle.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_trigger_capture(ob_device *device, ob_error **error);
/**
* @brief set the timestamp reset configuration of the device.
*
* @param[in] device The device handle.
* @param[in] config The timestamp reset configuration.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_set_timestamp_reset_config(ob_device *device, const ob_device_timestamp_reset_config *config, ob_error **error);
/**
* @brief get the timestamp reset configuration of the device.
*
* @param[in] device The device handle.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device_timestamp_reset_config return the timestamp reset configuration of the device.
*/
OB_EXPORT ob_device_timestamp_reset_config ob_device_get_timestamp_reset_config(ob_device *device, ob_error **error);
/**
* @brief send the timestamp reset command to the device.
* @brief The device will reset the timer for calculating the timestamp for output frames to 0 after receiving the timestamp reset command when the timestamp
* reset function is enabled. The timestamp reset function can be enabled by call @ref ob_device_set_timestamp_reset_config.
*
* @attention If the stream of the device is started, the timestamp of the continuous frames output by the stream will jump once after the timestamp reset.
* @attention Due to the timer of device is not high-accuracy, the timestamp of the continuous frames output by the stream will drift after a long time. User
* can call this function periodically to reset the timer to avoid the timestamp drift, the recommended interval time is 60 minutes.
*
* @param[in] device The device handle.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_timestamp_reset(ob_device *device, ob_error **error);
/**
* @brief Alias for @ref ob_device_timestamp_reset since it is more accurate.
*/
#define ob_device_timer_reset ob_device_timestamp_reset
/**
* @brief synchronize the timer of the device with the host.
* @brief After calling this function, the timer of the device will be synchronized with the host. User can call this function to multiple devices to
* synchronize all timers of the devices.
*
* @attention If the stream of the device is started, the timestamp of the continuous frames output by the stream will may jump once after the timer sync.
* @attention Due to the timer of device is not high-accuracy, the timestamp of the continuous frames output by the stream will drift after a long time. User
* can call this function periodically to synchronize the timer to avoid the timestamp drift, the recommended interval time is 60 minutes.
*
* @param[in] device The device handle.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_device_timer_sync_with_host(ob_device *device, ob_error **error);
#ifdef __cplusplus
} // extern "C"
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,335 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Pipeline.h
* @brief The SDK's advanced API can quickly implement functions such as switching streaming, frame synchronization, software filtering, etc., suitable for
* applications, and the algorithm focuses on rgbd data stream scenarios. If you are on real-time or need to handle synchronization separately, align the scene.
* Please use the interface of Device's Lower API.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Create a pipeline object
*
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_pipeline* return the pipeline object
*/
OB_EXPORT ob_pipeline *ob_create_pipeline(ob_error **error);
/**
* @brief Using device objects to create pipeline objects
*
* @param[in] dev Device object used to create pipeline
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_pipeline* return the pipeline object
*/
OB_EXPORT ob_pipeline *ob_create_pipeline_with_device(const ob_device *dev, ob_error **error);
/**
* @brief Delete pipeline objects
*
* @param[in] pipeline The pipeline object to be deleted
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_pipeline(ob_pipeline *pipeline, ob_error **error);
/**
* @brief Start the pipeline with default parameters
*
* @param[in] pipeline pipeline object
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_pipeline_start(ob_pipeline *pipeline, ob_error **error);
/**
* @brief Start the pipeline with configuration parameters
*
* @param[in] pipeline pipeline object
* @param[in] config Parameters to be configured
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_pipeline_start_with_config(ob_pipeline *pipeline, const ob_config *config, ob_error **error);
/**
* @brief Start the pipeline and set the frame collection data callback
*
* @attention After start the pipeline with this interface, the frames will be output to the callback function and cannot be obtained frames by call
* @ob_pipeline_wait_for_frameset
*
* @param[in] pipeline pipeline object
* @param[in] config Parameters to be configured
* @param[in] callback Trigger a callback when all frame data in the frameset arrives
* @param[in] user_data Pass in any user data and get it from the callback
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_pipeline_start_with_callback(ob_pipeline *pipeline, const ob_config *config, ob_frameset_callback callback, void *user_data,
ob_error **error);
/**
* @brief Stop pipeline
*
* @param[in] pipeline pipeline object
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_pipeline_stop(ob_pipeline *pipeline, ob_error **error);
/**
* @brief Get the configuration object associated with the pipeline
* @brief Returns default configuration if the user has not configured
*
* @param[in] pipeline The pipeline object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_config* The configuration object
*/
OB_EXPORT ob_config *ob_pipeline_get_config(const ob_pipeline *pipeline, ob_error **error);
/**
* @brief Switch the corresponding configuration
*
* @param[in] pipeline The pipeline object
* @param[in] config The pipeline configuration
* @param[out] error Log error messages
*/
OB_EXPORT void ob_pipeline_switch_config(ob_pipeline *pipeline, ob_config *config, ob_error **error);
/**
* @brief Wait for a set of frames to be returned synchronously
*
* @param[in] pipeline The pipeline object
* @param[in] timeout_ms The timeout for waiting (in milliseconds)
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_frame* The frameset that was waited for. A frameset is a special frame that can be used to obtain independent frames from the set.
*/
OB_EXPORT ob_frame *ob_pipeline_wait_for_frameset(ob_pipeline *pipeline, uint32_t timeout_ms, ob_error **error);
/**
* @brief Get the device object associated with the pipeline
*
* @param[in] pipeline The pipeline object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_device* The device object
*/
OB_EXPORT ob_device *ob_pipeline_get_device(const ob_pipeline *pipeline, ob_error **error);
/**
* @brief Get the stream profile list associated with the pipeline
*
* @param[in] pipeline The pipeline object
* @param[in] sensorType The sensor type. The supported sensor types can be obtained through the ob_device_get_sensor_list() interface.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile_list* The stream profile list
*/
OB_EXPORT ob_stream_profile_list *ob_pipeline_get_stream_profile_list(const ob_pipeline *pipeline, ob_sensor_type sensorType, ob_error **error);
/**
* @brief Enable frame synchronization
* @brief Synchronize the frames of different streams by using the timestamp information of the frames.
* @brief Dynamically (when pipeline is started) enable/disable frame synchronization is allowed.
*
* @param[in] pipeline The pipeline object
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_pipeline_enable_frame_sync(ob_pipeline *pipeline, ob_error **error);
/**
* @brief Disable frame synchronization
*
* @param[in] pipeline The pipeline object
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_pipeline_disable_frame_sync(ob_pipeline *pipeline, ob_error **error);
/**
* @brief Return a list of D2C-enabled depth sensor resolutions corresponding to the input color sensor resolution
*
* @param[in] pipeline The pipeline object
* @param[in] color_profile The input profile of the color sensor
* @param[in] align_mode The input align mode
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile_list* The list of D2C-enabled depth sensor resolutions
*/
OB_EXPORT ob_stream_profile_list *ob_get_d2c_depth_profile_list(const ob_pipeline *pipeline, const ob_stream_profile *color_profile, ob_align_mode align_mode,
ob_error **error);
/**
* @brief Create the pipeline configuration
*
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_config* The configuration object
*/
OB_EXPORT ob_config *ob_create_config(ob_error **error);
/**
* @brief Delete the pipeline configuration
*
* @param[in] config The configuration to be deleted
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_config(ob_config *config, ob_error **error);
/**
* @brief Enable a stream with default profile
*
* @param[in] config The pipeline configuration object
* @param[in] stream_type The type of the stream to be enabled
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_enable_stream(ob_config *config, ob_stream_type stream_type, ob_error **error);
/**
* @brief Enable all streams in the pipeline configuration
*
* @param[in] config The pipeline configuration
* @param[out] error Log error messages
*/
OB_EXPORT void ob_config_enable_all_stream(ob_config *config, ob_error **error);
/**
* @brief Enable a stream according to the stream profile
*
* @param[in] config The pipeline configuration object
* @param[in] profile The stream profile to be enabled
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_enable_stream_with_stream_profile(ob_config *config, const ob_stream_profile *profile, ob_error **error);
/**
* @brief Enable video stream with specified parameters
*
* @attention The stream_type should be a video stream type, such as OB_STREAM_IR, OB_STREAM_COLOR, OB_STREAM_DEPTH, etc.
*
* @param[in] config The pipeline configuration object
* @param[in] stream_type The type of the stream to be enabled
* @param[in] width The width of the video stream
* @param[in] height The height of the video stream
* @param[in] fps The frame rate of the video stream
* @param[in] format The format of the video stream
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_enable_video_stream(ob_config *config, ob_stream_type stream_type, uint32_t width, uint32_t height, uint32_t fps, ob_format format,
ob_error **error);
/**
* @brief Enable accelerometer stream with specified parameters
*
* @param[in] config The pipeline configuration object
* @param[in] full_scale_range The full scale range of the accelerometer
* @param[in] sample_rate The sample rate of the accelerometer
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_enable_accel_stream(ob_config *config, ob_accel_full_scale_range full_scale_range, ob_accel_sample_rate sample_rate, ob_error **error);
/**
* @brief Enable gyroscope stream with specified parameters
*
* @param[in] config The pipeline configuration object
* @param[in] full_scale_range The full scale range of the gyroscope
* @param[in] sample_rate The sample rate of the gyroscope
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_enable_gyro_stream(ob_config *config, ob_gyro_full_scale_range full_scale_range, ob_gyro_sample_rate sample_rate, ob_error **error);
/**
* @brief Get the enabled stream profile list in the pipeline configuration
*
* @param config The pipeline configuration object
* @param error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile_list* The enabled stream profile list, should be released by @ref ob_delete_stream_profile_list after use
*/
OB_EXPORT ob_stream_profile_list *ob_config_get_enabled_stream_profile_list(const ob_config *config, ob_error **error);
/**
* @brief Disable a specific stream in the pipeline configuration
*
* @param[in] config The pipeline configuration object
* @param[in] type The type of stream to be disabled
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_disable_stream(ob_config *config, ob_stream_type type, ob_error **error);
/**
* @brief Disable all streams in the pipeline configuration
*
* @param[in] config The pipeline configuration object
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_disable_all_stream(ob_config *config, ob_error **error);
/**
* @brief Set the alignment mode for the pipeline configuration
*
* @param[in] config The pipeline configuration object
* @param[in] mode The alignment mode to be set
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_set_align_mode(ob_config *config, ob_align_mode mode, ob_error **error);
/**
* @brief Set whether depth scaling is required after enable depth to color alignment
* @brief After enabling depth to color alignment, the depth image may need to be scaled to match the color image size.
*
* @param[in] config The pipeline configuration object
* @param[in] enable Whether scaling is required
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_set_depth_scale_after_align_require(ob_config *config, bool enable, ob_error **error);
/**
* @brief Set the frame aggregation output mode for the pipeline configuration
* @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[in] config The pipeline configuration object
* @param[in] mode The frame aggregation output mode to be set (default mode is @ref OB_FRAME_AGGREGATE_OUTPUT_ANY_SITUATION)
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_config_set_frame_aggregate_output_mode(ob_config *config, ob_frame_aggregate_output_mode mode, ob_error **error);
/**
* @brief Get current camera parameters
* @attention If D2C is enabled, it will return the camera parameters after D2C, if not, it will return to the default parameters
*
* @param[in] pipeline pipeline object
* @param[out] error Log error messages
* @return ob_camera_param The camera internal parameters
*/
OB_EXPORT ob_camera_param ob_pipeline_get_camera_param(ob_pipeline *pipeline, ob_error **error);
/**
* @brief Get the current camera parameters
*
* @param[in] pipeline pipeline object
* @param[in] colorWidth color width
* @param[in] colorHeight color height
* @param[in] depthWidth depth width
* @param[in] depthHeight depth height
* @param[out] error Log error messages
* @return ob_camera_param returns camera internal parameters
*/
OB_EXPORT ob_camera_param ob_pipeline_get_camera_param_with_profile(ob_pipeline *pipeline, uint32_t colorWidth, uint32_t colorHeight, uint32_t depthWidth,
uint32_t depthHeight, ob_error **error);
/**
* @brief Get device calibration parameters with the specified configuration
*
* @param[in] pipeline pipeline object
* @param[in] config The pipeline configuration
* @param[out] error Log error messages
* @return ob_calibration_param The calibration parameters
*/
OB_EXPORT ob_calibration_param ob_pipeline_get_calibration_param(ob_pipeline *pipeline, ob_config *config, ob_error **error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_config_set_depth_scale_require ob_config_set_depth_scale_after_align_require
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,919 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Property.h
* @brief Control command property list maintenance
*/
#pragma once
#include "ObTypes.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enumeration value describing all attribute control commands of the device
*/
typedef enum {
/**
* @brief LDP switch
*/
OB_PROP_LDP_BOOL = 2,
/**
* @brief Laser switch
*/
OB_PROP_LASER_BOOL = 3,
/**
* @brief laser pulse width
*/
OB_PROP_LASER_PULSE_WIDTH_INT = 4,
/**
* @brief Laser current (uint: mA)
*/
OB_PROP_LASER_CURRENT_FLOAT = 5,
/**
* @brief IR flood switch
*/
OB_PROP_FLOOD_BOOL = 6,
/**
* @brief IR flood level
*/
OB_PROP_FLOOD_LEVEL_INT = 7,
/**
* @brief Enable/disable temperature compensation
*
*/
OB_PROP_TEMPERATURE_COMPENSATION_BOOL = 8,
/**
* @brief Depth mirror
*/
OB_PROP_DEPTH_MIRROR_BOOL = 14,
/**
* @brief Depth flip
*/
OB_PROP_DEPTH_FLIP_BOOL = 15,
/**
* @brief Depth Postfilter
*/
OB_PROP_DEPTH_POSTFILTER_BOOL = 16,
/**
* @brief Depth Holefilter
*/
OB_PROP_DEPTH_HOLEFILTER_BOOL = 17,
/**
* @brief IR mirror
*/
OB_PROP_IR_MIRROR_BOOL = 18,
/**
* @brief IR flip
*/
OB_PROP_IR_FLIP_BOOL = 19,
/**
* @brief Minimum depth threshold
*/
OB_PROP_MIN_DEPTH_INT = 22,
/**
* @brief Maximum depth threshold
*/
OB_PROP_MAX_DEPTH_INT = 23,
/**
* @brief Software filter switch
*/
OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_BOOL = 24,
/**
* @brief LDP status
*/
OB_PROP_LDP_STATUS_BOOL = 32,
/**
* @brief maxdiff for depth noise removal filter
*/
OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_DIFF_INT = 40,
/**
* @brief maxSpeckleSize for depth noise removal filter
*/
OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_SPECKLE_SIZE_INT = 41,
/**
* @brief Hardware d2c is on
*/
OB_PROP_DEPTH_ALIGN_HARDWARE_BOOL = 42,
/**
* @brief Timestamp adjustment
*/
OB_PROP_TIMESTAMP_OFFSET_INT = 43,
/**
* @brief Hardware distortion switch Rectify
*/
OB_PROP_HARDWARE_DISTORTION_SWITCH_BOOL = 61,
/**
* @brief Fan mode switch
*/
OB_PROP_FAN_WORK_MODE_INT = 62,
/**
* @brief Multi-resolution D2C mode
*/
OB_PROP_DEPTH_ALIGN_HARDWARE_MODE_INT = 63,
/**
* @brief Anti_collusion activation status
*/
OB_PROP_ANTI_COLLUSION_ACTIVATION_STATUS_BOOL = 64,
/**
* @brief the depth precision level, which may change the depth frame data unit, needs to be confirmed through the ValueScale interface of
* DepthFrame
*/
OB_PROP_DEPTH_PRECISION_LEVEL_INT = 75,
/**
* @brief tof filter range configuration
*/
OB_PROP_TOF_FILTER_RANGE_INT = 76,
/**
* @brief laser mode, the firmware terminal currently only return 1: IR Drive, 2: Torch
*/
OB_PROP_LASER_MODE_INT = 79,
/**
* @brief brt2r-rectify function switch (brt2r is a special module on mx6600), 0: Disable, 1: Rectify Enable
*/
OB_PROP_RECTIFY2_BOOL = 80,
/**
* @brief Color mirror
*/
OB_PROP_COLOR_MIRROR_BOOL = 81,
/**
* @brief Color flip
*/
OB_PROP_COLOR_FLIP_BOOL = 82,
/**
* @brief Indicator switch, 0: Disable, 1: Enable
*/
OB_PROP_INDICATOR_LIGHT_BOOL = 83,
/**
* @brief Disparity to depth switch, false: switch to software disparity convert to depth, true: switch to hardware disparity convert to depth
*/
OB_PROP_DISPARITY_TO_DEPTH_BOOL = 85,
/**
* @brief BRT function switch (anti-background interference), 0: Disable, 1: Enable
*/
OB_PROP_BRT_BOOL = 86,
/**
* @brief Watchdog function switch, 0: Disable, 1: Enable
*/
OB_PROP_WATCHDOG_BOOL = 87,
/**
* @brief External signal trigger restart function switch, 0: Disable, 1: Enable
*/
OB_PROP_EXTERNAL_SIGNAL_RESET_BOOL = 88,
/**
* @brief Heartbeat monitoring function switch, 0: Disable, 1: Enable
*/
OB_PROP_HEARTBEAT_BOOL = 89,
/**
* @brief Depth cropping mode device: OB_DEPTH_CROPPING_MODE
*/
OB_PROP_DEPTH_CROPPING_MODE_INT = 90,
/**
* @brief D2C preprocessing switch (such as RGB cropping), 0: off, 1: on
*/
OB_PROP_D2C_PREPROCESS_BOOL = 91,
/**
* @brief Enable/disable GPM function
*/
OB_PROP_GPM_BOOL = 93,
/**
* @brief Custom RGB cropping switch, 0 is off, 1 is on custom cropping, and the ROI cropping area is issued
*/
OB_PROP_RGB_CUSTOM_CROP_BOOL = 94,
/**
* @brief Device operating mode (power consumption)
*/
OB_PROP_DEVICE_WORK_MODE_INT = 95,
/**
* @brief Device communication type, 0: USB; 1: Ethernet(RTSP)
*/
OB_PROP_DEVICE_COMMUNICATION_TYPE_INT = 97,
/**
* @brief Switch infrared imaging mode, 0: active IR mode, 1: passive IR mode
*/
OB_PROP_SWITCH_IR_MODE_INT = 98,
/**
* @brief Laser power level
*/
OB_PROP_LASER_POWER_LEVEL_CONTROL_INT = 99,
/**
* @brief LDP's measure distance, unit: mm
*/
OB_PROP_LDP_MEASURE_DISTANCE_INT = 100,
/**
* @brief Reset device time to zero
*/
OB_PROP_TIMER_RESET_SIGNAL_BOOL = 104,
/**
* @brief Enable send reset device time signal to other device. true: enable, false: disable
*/
OB_PROP_TIMER_RESET_TRIGGER_OUT_ENABLE_BOOL = 105,
/**
* @brief Delay to reset device time, unit: us
*/
OB_PROP_TIMER_RESET_DELAY_US_INT = 106,
/**
* @brief Signal to capture image
*/
OB_PROP_CAPTURE_IMAGE_SIGNAL_BOOL = 107,
/**
* @brief Right IR sensor mirror state
*/
OB_PROP_IR_RIGHT_MIRROR_BOOL = 112,
/**
* @brief Number frame to capture once a 'OB_PROP_CAPTURE_IMAGE_SIGNAL_BOOL' effect. range: [1, 255]
*/
OB_PROP_CAPTURE_IMAGE_FRAME_NUMBER_INT = 113,
/**
* @brief Right IR sensor flip state. true: flip image, false: origin, default: false
*/
OB_PROP_IR_RIGHT_FLIP_BOOL = 114,
/**
* @brief Color sensor rotation, angle{0, 90, 180, 270}
*/
OB_PROP_COLOR_ROTATE_INT = 115,
/**
* @brief IR/Left-IR sensor rotation, angle{0, 90, 180, 270}
*/
OB_PROP_IR_ROTATE_INT = 116,
/**
* @brief Right IR sensor rotation, angle{0, 90, 180, 270}
*/
OB_PROP_IR_RIGHT_ROTATE_INT = 117,
/**
* @brief Depth sensor rotation, angle{0, 90, 180, 270}
*/
OB_PROP_DEPTH_ROTATE_INT = 118,
/**
* @brief Get hardware laser power actual level which real state of laser element. OB_PROP_LASER_POWER_LEVEL_CONTROL_INT99 will effect this command
* which it setting and changed the hardware laser energy level.
*/
OB_PROP_LASER_POWER_ACTUAL_LEVEL_INT = 119,
/**
* @brief USB's power state, enum type: OBUSBPowerState
*/
OB_PROP_USB_POWER_STATE_INT = 121,
/**
* @brief DC's power state, enum type: OBDCPowerState
*/
OB_PROP_DC_POWER_STATE_INT = 122,
/**
* @brief Device development mode switch, optional modes can refer to the definition in @ref OBDeviceDevelopmentMode,the default mode is
* @ref OB_USER_MODE
* @attention The device takes effect after rebooting when switching modes.
*/
OB_PROP_DEVICE_DEVELOPMENT_MODE_INT = 129,
/**
* @brief Multi-DeviceSync synchronized signal trigger out is enable state. true: enable, false: disable
*/
OB_PROP_SYNC_SIGNAL_TRIGGER_OUT_BOOL = 130,
/**
* @brief Restore factory settings and factory parameters
* @attention This command can only be written, and the parameter value must be true. The command takes effect after restarting the device.
*/
OB_PROP_RESTORE_FACTORY_SETTINGS_BOOL = 131,
/**
* @brief Enter recovery mode (flashing mode) when boot the device
* @attention The device will take effect after rebooting with the enable option. After entering recovery mode, you can upgrade the device system. Upgrading
* the system may cause system damage, please use it with caution.
*/
OB_PROP_BOOT_INTO_RECOVERY_MODE_BOOL = 132,
/**
* @brief Query whether the current device is running in recovery mode (read-only)
*/
OB_PROP_DEVICE_IN_RECOVERY_MODE_BOOL = 133,
/**
* @brief Capture interval mode, 0:time interval, 1:number interval
*/
OB_PROP_CAPTURE_INTERVAL_MODE_INT = 134,
/**
* @brief Capture time interval
*/
OB_PROP_CAPTURE_IMAGE_TIME_INTERVAL_INT = 135,
/**
* @brief Capture number interval
*/
OB_PROP_CAPTURE_IMAGE_NUMBER_INTERVAL_INT = 136,
/*
* @brief Timer reset function enable
*/
OB_PROP_TIMER_RESET_ENABLE_BOOL = 140,
/**
* @brief Enable or disable the device to retry USB2.0 re-identification when the device is connected to a USB2.0 port.
* @brief This feature ensures that the device is not mistakenly identified as a USB 2.0 device when connected to a USB 3.0 port.
*/
OB_PROP_DEVICE_USB2_REPEAT_IDENTIFY_BOOL = 141,
/**
* @brief Reboot device delay mode. Delay time unit: ms, range: [0, 8000).
*/
OB_PROP_DEVICE_REBOOT_DELAY_INT = 142,
/**
* @brief Query the status of laser overcurrent protection (read-only)
*/
OB_PROP_LASER_OVERCURRENT_PROTECTION_STATUS_BOOL = 148,
/**
* @brief Query the status of laser pulse width protection (read-only)
*/
OB_PROP_LASER_PULSE_WIDTH_PROTECTION_STATUS_BOOL = 149,
/**
* @brief Laser always on, true: always on, false: off, laser will be turned off when out of exposure time
*/
OB_PROP_LASER_ALWAYS_ON_BOOL = 174,
/**
* @brief Laser on/off alternate mode, 0: off, 1: on-off alternate, 2: off-on alternate
* @attention When turn on this mode, the laser will turn on and turn off alternately each frame.
*/
OB_PROP_LASER_ON_OFF_PATTERN_INT = 175,
/**
* @brief Depth unit flexible adjustment\
* @brief This property allows continuous adjustment of the depth unit, unlike @ref OB_PROP_DEPTH_PRECISION_LEVEL_INT must be set to some fixed value.
*/
OB_PROP_DEPTH_UNIT_FLEXIBLE_ADJUSTMENT_FLOAT = 176,
/**
* @brief Laser control, 0: off, 1: on, 2: auto
*
*/
OB_PROP_LASER_CONTROL_INT = 182,
/**
* @brief IR brightness
*/
OB_PROP_IR_BRIGHTNESS_INT = 184,
/**
* @brief Slave/secondary device synchronization status (read-only)
*/
OB_PROP_SLAVE_DEVICE_SYNC_STATUS_BOOL = 188,
/**
* @brief Color AE max exposure
*/
OB_PROP_COLOR_AE_MAX_EXPOSURE_INT = 189,
/**
* @brief Max exposure time of IR auto exposure
*/
OB_PROP_IR_AE_MAX_EXPOSURE_INT = 190,
/**
* @brief Disparity search range mode, 1: 128, 2: 256
*/
OB_PROP_DISP_SEARCH_RANGE_MODE_INT = 191,
/**
* @brief Laser high temperature protection
*/
OB_PROP_LASER_HIGH_TEMPERATURE_PROTECT_BOOL = 193,
/**
* @brief low exposure laser control
*
* @brief Currently using for DabaiA device,if the exposure value is lower than a certain threshold, the laser is turned off;
* if it exceeds another threshold, the laser is turned on again.
*/
OB_PROP_LOW_EXPOSURE_LASER_CONTROL_BOOL = 194,
/**
* @brief check pps sync in signal
*/
OB_PROP_CHECK_PPS_SYNC_IN_SIGNAL_BOOL = 195,
/**
* @brief Disparity search range offset, range: [0, 127]
*/
OB_PROP_DISP_SEARCH_OFFSET_INT = 196,
/**
* @brief Repower device (cut off power and power on again)
*
* @brief Currently using for GMSL device, cut off power and power on again by GMSL host driver.
*/
OB_PROP_DEVICE_REPOWER_BOOL = 202,
/**
* @brief frame interleave config index
*/
OB_PROP_FRAME_INTERLEAVE_CONFIG_INDEX_INT = 204,
/**
* @brief frame interleave enable (true:enable,false:disable)
*/
OB_PROP_FRAME_INTERLEAVE_ENABLE_BOOL = 205,
/**
* @brief laser pattern sync with delay(us)
*/
OB_PROP_FRAME_INTERLEAVE_LASER_PATTERN_SYNC_DELAY_INT = 206,
/**
* @brief Get the health check result from device,range is [0.0f,1.5f]
*/
OB_PROP_ON_CHIP_CALIBRATION_HEALTH_CHECK_FLOAT = 209,
/**
* @brief Enable or disable on-chip calibration
*/
OB_PROP_ON_CHIP_CALIBRATION_ENABLE_BOOL = 210,
/**
* @brief hardware noise remove filter switch
*/
OB_PROP_HW_NOISE_REMOVE_FILTER_ENABLE_BOOL = 211,
/**
* @brief hardware noise remove filter threshold ,range [0.0 - 1.0]
*/
OB_PROP_HW_NOISE_REMOVE_FILTER_THRESHOLD_FLOAT = 212,
/**
* @brief soft trigger auto capture enable, use in OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING mode
*/
OB_DEVICE_AUTO_CAPTURE_ENABLE_BOOL = 216,
/**
* @brief soft trigger auto capture interval time, use in OB_MULTI_DEVICE_SYNC_MODE_SOFTWARE_TRIGGERING mode
*/
OB_DEVICE_AUTO_CAPTURE_INTERVAL_TIME_INT = 217,
/**
* @brief PTP time synchronization enable
*/
OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL = 223,
/**
* @brief Depth with confidence stream enable
*/
OB_PROP_DEPTH_WITH_CONFIDENCE_STREAM_ENABLE_BOOL = 224,
/**
* @brief Enable or disable confidence stream filter
*/
OB_PROP_CONFIDENCE_STREAM_FILTER_BOOL = 226,
/**
* @brief Confidence stream filter threshold, range [0, 255]
*/
OB_PROP_CONFIDENCE_STREAM_FILTER_THRESHOLD_INT = 227,
/**
* @brief Confidence stream mirror enable
*/
OB_PROP_CONFIDENCE_MIRROR_BOOL = 229,
/**
* @brief Confidence stream flip enable
*/
OB_PROP_CONFIDENCE_FLIP_BOOL = 230,
/**
* @brief Confidence stream rotate angle{0, 90, 180, 270}
*/
OB_PROP_CONFIDENCE_ROTATE_INT = 231,
/**
* @brief Intra-camera Sync Reference based on the exposure start time, the exposure middle time, or the exposure end time. the definition in @ref
* OBIntraCameraSyncReference
*/
OB_PROP_INTRA_CAMERA_SYNC_REFERENCE_INT = 236,
/**
* @brief Baseline calibration parameters
*/
OB_STRUCT_BASELINE_CALIBRATION_PARAM = 1002,
/**
* @brief Device temperature information
*/
OB_STRUCT_DEVICE_TEMPERATURE = 1003,
/**
* @brief TOF exposure threshold range
*/
OB_STRUCT_TOF_EXPOSURE_THRESHOLD_CONTROL = 1024,
/**
* @brief get/set serial number
*/
OB_STRUCT_DEVICE_SERIAL_NUMBER = 1035,
/**
* @brief get/set device time
*/
OB_STRUCT_DEVICE_TIME = 1037,
/**
* @brief Multi-device synchronization mode and parameter configuration
*/
OB_STRUCT_MULTI_DEVICE_SYNC_CONFIG = 1038,
/**
* @brief RGB cropping ROI
*/
OB_STRUCT_RGB_CROP_ROI = 1040,
/**
* @brief Device IP address configuration
*/
OB_STRUCT_DEVICE_IP_ADDR_CONFIG = 1041,
/**
* @brief The current camera depth mode
*/
OB_STRUCT_CURRENT_DEPTH_ALG_MODE = 1043,
/**
* @brief A list of depth accuracy levels, returning an array of uin16_t, corresponding to the enumeration
*/
OB_STRUCT_DEPTH_PRECISION_SUPPORT_LIST = 1045,
/**
* @brief Device network static ip config record
* @brief Using for get last static ip config, witch is record in device flash when user set static ip config
*
* @attention read only
*/
OB_STRUCT_DEVICE_STATIC_IP_CONFIG_RECORD = 1053,
/**
* @brief Using to configure the depth sensor's HDR mode
* @brief The Value type is @ref OBHdrConfig
*
* @attention After enable HDR mode, the depth sensor auto exposure will be disabled.
*/
OB_STRUCT_DEPTH_HDR_CONFIG = 1059,
/**
* @brief Color Sensor AE ROI configuration
* @brief The Value type is @ref OBRegionOfInterest
*/
OB_STRUCT_COLOR_AE_ROI = 1060,
/**
* @brief Depth Sensor AE ROI configuration
* @brief The Value type is @ref OBRegionOfInterest
* @brief Since the ir sensor is the same physical sensor as the depth sensor, this property will also effect the ir sensor.
*/
OB_STRUCT_DEPTH_AE_ROI = 1061,
/**
* @brief ASIC serial number
*/
OB_STRUCT_ASIC_SERIAL_NUMBER = 1063,
/**
* @brief Disparity offset interleaving
*/
OB_STRUCT_DISP_OFFSET_CONFIG = 1064,
/**
* @brief Preset resolution ratio configuration
*/
OB_STRUCT_PRESET_RESOLUTION_CONFIG = 1069,
/**
* @brief Color camera auto exposure
*/
OB_PROP_COLOR_AUTO_EXPOSURE_BOOL = 2000,
/**
* @brief Color camera exposure adjustment
*/
OB_PROP_COLOR_EXPOSURE_INT = 2001,
/**
* @brief Color camera gain adjustment
*/
OB_PROP_COLOR_GAIN_INT = 2002,
/**
* @brief Color camera automatic white balance
*/
OB_PROP_COLOR_AUTO_WHITE_BALANCE_BOOL = 2003,
/**
* @brief Color camera white balance adjustment
*/
OB_PROP_COLOR_WHITE_BALANCE_INT = 2004,
/**
* @brief Color camera brightness adjustment
*/
OB_PROP_COLOR_BRIGHTNESS_INT = 2005,
/**
* @brief Color camera sharpness adjustment
*/
OB_PROP_COLOR_SHARPNESS_INT = 2006,
/**
* @brief Color camera shutter adjustment
*/
OB_PROP_COLOR_SHUTTER_INT = 2007,
/**
* @brief Color camera saturation adjustment
*/
OB_PROP_COLOR_SATURATION_INT = 2008,
/**
* @brief Color camera contrast adjustment
*/
OB_PROP_COLOR_CONTRAST_INT = 2009,
/**
* @brief Color camera gamma adjustment
*/
OB_PROP_COLOR_GAMMA_INT = 2010,
/**
* @brief Color camera image rotation
*/
OB_PROP_COLOR_ROLL_INT = 2011,
/**
* @brief Color camera auto exposure priority
*/
OB_PROP_COLOR_AUTO_EXPOSURE_PRIORITY_INT = 2012,
/**
* @brief Color camera brightness compensation
*/
OB_PROP_COLOR_BACKLIGHT_COMPENSATION_INT = 2013,
/**
* @brief Color camera color tint
*/
OB_PROP_COLOR_HUE_INT = 2014,
/**
* @brief Color Camera Power Line Frequency
*/
OB_PROP_COLOR_POWER_LINE_FREQUENCY_INT = 2015,
/**
* @brief Automatic exposure of depth camera (infrared camera will be set synchronously under some models of devices)
*/
OB_PROP_DEPTH_AUTO_EXPOSURE_BOOL = 2016,
/**
* @brief Depth camera exposure adjustment (infrared cameras will be set synchronously under some models of devices)
*/
OB_PROP_DEPTH_EXPOSURE_INT = 2017,
/**
* @brief Depth camera gain adjustment (infrared cameras will be set synchronously under some models of devices)
*/
OB_PROP_DEPTH_GAIN_INT = 2018,
/**
* @brief Infrared camera auto exposure (depth camera will be set synchronously under some models of devices)
*/
OB_PROP_IR_AUTO_EXPOSURE_BOOL = 2025,
/**
* @brief Infrared camera exposure adjustment (some models of devices will set the depth camera synchronously)
*/
OB_PROP_IR_EXPOSURE_INT = 2026,
/**
* @brief Infrared camera gain adjustment (the depth camera will be set synchronously under some models of devices)
*/
OB_PROP_IR_GAIN_INT = 2027,
/**
* @brief Select Infrared camera data source channel. If not support throw exception. 0 : IR stream from IR Left sensor; 1 : IR stream from IR Right sensor;
*/
OB_PROP_IR_CHANNEL_DATA_SOURCE_INT = 2028,
/**
* @brief Depth effect dedistortion, true: on, false: off. mutually exclusive with D2C function, RM_Filter disable When hardware or software D2C is enabled.
*/
OB_PROP_DEPTH_RM_FILTER_BOOL = 2029,
/**
* @brief Color camera maximal gain
*/
OB_PROP_COLOR_MAXIMAL_GAIN_INT = 2030,
/**
* @brief Color camera shutter gain
*/
OB_PROP_COLOR_MAXIMAL_SHUTTER_INT = 2031,
/**
* @brief The enable/disable switch for IR short exposure function, supported only by a few devices.
*/
OB_PROP_IR_SHORT_EXPOSURE_BOOL = 2032,
/**
* @brief Color camera HDR
*/
OB_PROP_COLOR_HDR_BOOL = 2034,
/**
* @brief IR long exposure mode switch read and write.
*/
OB_PROP_IR_LONG_EXPOSURE_BOOL = 2035,
/**
* @brief Setting and getting the USB device frame skipping mode status, true: frame skipping mode, false: non-frame skipping mode.
*/
OB_PROP_SKIP_FRAME_BOOL = 2036,
/**
* @brief Depth HDR merge, true: on, false: off.
*/
OB_PROP_HDR_MERGE_BOOL = 2037,
/**
* @brief Color camera FOCUS
*/
OB_PROP_COLOR_FOCUS_INT = 2038,
/**
* @brief ir rectify status,true: ir rectify, false: no rectify
*/
OB_PROP_IR_RECTIFY_BOOL = 2040,
/**
* @brief Depth camera priority
*
*/
OB_PROP_DEPTH_AUTO_EXPOSURE_PRIORITY_INT = 2052,
/**
* @brief Software disparity to depth
*/
OB_PROP_SDK_DISPARITY_TO_DEPTH_BOOL = 3004,
/**
* @brief Depth data unpacking function switch (each open stream will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format)
*/
OB_PROP_SDK_DEPTH_FRAME_UNPACK_BOOL = 3007,
/**
* @brief IR data unpacking function switch (each current will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format)
*/
OB_PROP_SDK_IR_FRAME_UNPACK_BOOL = 3008,
/**
* @brief Accel data conversion function switch (on by default)
*/
OB_PROP_SDK_ACCEL_FRAME_TRANSFORMED_BOOL = 3009,
/**
* @brief Gyro data conversion function switch (on by default)
*/
OB_PROP_SDK_GYRO_FRAME_TRANSFORMED_BOOL = 3010,
/**
* @brief Left IR frame data unpacking function switch (each current will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format)
*/
OB_PROP_SDK_IR_LEFT_FRAME_UNPACK_BOOL = 3011,
/**
* @brief Right IR frame data unpacking function switch (each current will be turned on by default, support RLE/Y10/Y11/Y12/Y14 format)
*/
OB_PROP_SDK_IR_RIGHT_FRAME_UNPACK_BOOL = 3012,
/**
* @brief Depth Stream Industry Working Mode Settings, currently only supported by DCW2.
*/
OB_PROP_DEPTH_INDUSTRY_MODE_INT = 3024,
/**
* @brief Read the current network bandwidth type of the network device, whether it is Gigabit Ethernet or Fast Ethernet, such as G335LE.
*/
OB_PROP_NETWORK_BANDWIDTH_TYPE_INT = 3027,
/**
* @brief Switch device performance mode, currently available in Adaptive Mode and High Performance Mode, such as G335LE.
*/
OB_PROP_DEVICE_PERFORMANCE_MODE_INT = 3028,
/**
* @brief Calibration JSON file read from device (Femto Mega, read only)
*/
OB_RAW_DATA_CAMERA_CALIB_JSON_FILE = 4029,
/**
* @brief Confidence degree
*/
OB_PROP_DEBUG_ESGM_CONFIDENCE_FLOAT = 5013,
/**
* @brief Color camera CCI denoising level. 0: Auto; 1-8: higher values indicate stronger denoising.
* @note This setting has no effect when AE (Auto Exposure) is disabled.
*/
OB_PROP_COLOR_DENOISING_LEVEL_INT = 5525,
} OBPropertyID,
ob_property_id;
// For backward compatibility
#define OB_PROP_TIMER_RESET_TRIGGLE_OUT_ENABLE_BOOL OB_PROP_TIMER_RESET_TRIGGER_OUT_ENABLE_BOOL
#define OB_PROP_LASER_ON_OFF_MODE_INT OB_PROP_LASER_ON_OFF_PATTERN_INT
#define OB_PROP_LASER_ENERGY_LEVEL_INT OB_PROP_LASER_POWER_LEVEL_CONTROL_INT
#define OB_PROP_LASER_HW_ENERGY_LEVEL_INT OB_PROP_LASER_POWER_ACTUAL_LEVEL_INT
#define OB_PROP_DEVICE_USB3_REPEAT_IDENTIFY_BOOL OB_PROP_DEVICE_USB2_REPEAT_IDENTIFY_BOOL
#define OB_PROP_DEPTH_SOFT_FILTER_BOOL OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_BOOL
#define OB_PROP_DEPTH_MAX_DIFF_INT OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_DIFF_INT
#define OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT OB_PROP_DEPTH_NOISE_REMOVAL_FILTER_MAX_SPECKLE_SIZE_INT
/**
* @brief The data type used to describe all property settings
*/
typedef enum OBPropertyType {
OB_BOOL_PROPERTY = 0, /**< Boolean property */
OB_INT_PROPERTY = 1, /**< Integer property */
OB_FLOAT_PROPERTY = 2, /**< Floating-point property */
OB_STRUCT_PROPERTY = 3, /**< Struct property */
} OBPropertyType,
ob_property_type;
/**
* @brief Used to describe the characteristics of each property
*/
typedef struct OBPropertyItem {
OBPropertyID id; /**< Property ID */
const char *name; /**< Property name */
OBPropertyType type; /**< Property type */
OBPermissionType permission; /**< Property read and write permission */
} OBPropertyItem, ob_property_item;
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,135 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file RecordPlayback.hpp
* @brief Record and playback device-related types, including interfaces to create recording and playback devices,
record and playback streaming data, etc.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "Device.h"
/**
* @brief Create a recording device for the specified device with a specified file path and compression enabled.
*
* @param[in] device The device to record.
* @param[in] file_path The file path to record to.
* @param[in] compression_enabled Whether to enable compression for the recording.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return A pointer to the newly created recording device, or NULL if an error occurred.
*/
OB_EXPORT ob_record_device *ob_create_record_device(ob_device *device, const char *file_path, bool compression_enabled, ob_error **error);
/**
* @brief Delete a recording device.
*
* @param[in] recorder The recording device to delete.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_record_device(ob_record_device *recorder, ob_error **error);
/**
* @brief Pause recording on the specified recording device.
*
* @param[in] recorder The recording device to pause.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_record_device_pause(ob_record_device *recorder, ob_error **error);
/**
* @brief Resume recording on the specified recording device.
*
* @param[in] recorder The recording device to resume.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_record_device_resume(ob_record_device *recorder, ob_error **error);
/**
* @brief Create a playback device for the specified file path.
*
* @param[in] file_path The file path to playback from.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return A pointer to the newly created playback device, or NULL if an error occurred.
*/
OB_EXPORT ob_device *ob_create_playback_device(const char *file_path, ob_error **error);
/**
* @brief Pause playback on the specified playback device.
*
* @param[in] player The playback device to pause.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_playback_device_pause(ob_device *player, ob_error **error);
/**
* @brief Resume playback on the specified playback device.
*
* @param[in] player The playback device to resume.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_playback_device_resume(ob_device *player, ob_error **error);
/**
* @brief Set the playback to a specified time point of the played data.
*
* @param[in] player The playback device to set the position for.
* @param[in] timestamp The position to set the playback to, in milliseconds.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_playback_device_seek(ob_device *player, const uint64_t timestamp, ob_error **error);
/**
* @brief Set the playback to a specified time point of the played data.
*
* @param[in] player The playback device to set the position for.
* @param[in] rate The playback rate to set.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_playback_device_set_playback_rate(ob_device *player, const float rate, ob_error **error);
/**
* @brief Get the current playback status of the played data.
*
* @param[in] player The playback device to get the status for.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The current playback status of the played data.
*/
OB_EXPORT ob_playback_status ob_playback_device_get_current_playback_status(ob_device *player, ob_error **error);
/**
* @brief Set a callback function to receive playback status updates.
*
* @param[in] player The playback device to set the callback for.
* @param[in] callback The callback function to receive playback status updates.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_playback_device_set_playback_status_changed_callback(ob_device *player, ob_playback_status_changed_callback callback, void *user_data,
ob_error **error);
/**
* @brief Get the current playback position of the played data.
*
* @param[in] player The playback device to get the position for.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The current playback position of the played data, in milliseconds.
*/
OB_EXPORT uint64_t ob_playback_device_get_position(ob_device *player, ob_error **error);
/**
* @brief Get the duration of the played data.
*
* @param[in] player The playback device to get the duration for.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The duration of the played data, in milliseconds.
*/
OB_EXPORT uint64_t ob_playback_device_get_duration(ob_device *player, ob_error **error);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -0,0 +1,132 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Sensor.h
* @brief Defines types related to sensors, used for obtaining stream configurations, opening and closing streams, and setting and getting sensor properties.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Get the type of the sensor.
*
* @param[in] sensor The sensor object.
* @param[out] error Logs error messages.
* @return The sensor type.
*/
OB_EXPORT ob_sensor_type ob_sensor_get_type(const ob_sensor *sensor, ob_error **error);
/**
* @brief Get a list of all supported stream profiles.
*
* @param[in] sensor The sensor object.
* @param[out] error Logs error messages.
* @return A list of stream profiles.
*/
OB_EXPORT ob_stream_profile_list *ob_sensor_get_stream_profile_list(const ob_sensor *sensor, ob_error **error);
/**
* @brief Open the current sensor and set the callback data frame.
*
* @param[in] sensor The sensor object.
* @param[in] profile The stream configuration information.
* @param[in] callback The callback function triggered when frame data arrives.
* @param[in] user_data Any user data to pass in and get from the callback.
* @param[out] error Logs error messages.
*/
OB_EXPORT void ob_sensor_start(ob_sensor *sensor, const ob_stream_profile *profile, ob_frame_callback callback, void *user_data, ob_error **error);
/**
* @brief Stop the sensor stream.
*
* @param[in] sensor The sensor object.
* @param[out] error Logs error messages.
*/
OB_EXPORT void ob_sensor_stop(ob_sensor *sensor, ob_error **error);
/**
* @brief Switch resolutions.
*
* @param[in] sensor The sensor object.
* @param[in] profile The stream configuration information.
* @param[out] error Logs error messages.
*/
OB_EXPORT void ob_sensor_switch_profile(ob_sensor *sensor, ob_stream_profile *profile, ob_error **error);
/**
* @brief Delete a sensor object.
*
* @param[in] sensor The sensor object to delete.
* @param[out] error Logs error messages.
*/
OB_EXPORT void ob_delete_sensor(ob_sensor *sensor, ob_error **error);
/**
* @brief Create a list of recommended filters for the specified sensor.
*
* @param[in] sensor The ob_sensor object.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_filter_list
*/
OB_EXPORT ob_filter_list *ob_sensor_create_recommended_filter_list(const ob_sensor *sensor, ob_error **error);
/**
* @brief Get the number of sensors in the sensor list.
*
* @param[in] sensor_list The list of sensor objects.
* @param[out] error Logs error messages.
* @return The number of sensors in the list.
*/
OB_EXPORT uint32_t ob_sensor_list_get_count(const ob_sensor_list *sensor_list, ob_error **error);
/**
* @brief Get the sensor type.
*
* @param[in] sensor_list The list of sensor objects.
* @param[in] index The index of the sensor on the list.
* @param[out] error Logs error messages.
* @return The sensor type.
*/
OB_EXPORT ob_sensor_type ob_sensor_list_get_sensor_type(const ob_sensor_list *sensor_list, uint32_t index, ob_error **error);
/**
* @brief Get a sensor by sensor type.
*
* @param[in] sensor_list The list of sensor objects.
* @param[in] sensorType The sensor type to be obtained.
* @param[out] error Logs error messages.
* @return The sensor pointer. If the specified type of sensor does not exist, it will return null.
*/
OB_EXPORT ob_sensor *ob_sensor_list_get_sensor_by_type(const ob_sensor_list *sensor_list, ob_sensor_type sensorType, ob_error **error);
/**
* @brief Get a sensor by index number.
*
* @param[in] sensor_list The list of sensor objects.
* @param[in] index The index of the sensor on the list.
* @param[out] error Logs error messages.
* @return The sensor object.
*/
OB_EXPORT ob_sensor *ob_sensor_list_get_sensor(const ob_sensor_list *sensor_list, uint32_t index, ob_error **error);
/**
* @brief Delete a list of sensor objects.
*
* @param[in] sensor_list The list of sensor objects to delete.
* @param[out] error Logs error messages.
*/
OB_EXPORT void ob_delete_sensor_list(ob_sensor_list *sensor_list, ob_error **error);
#define ob_sensor_list_get_sensor_count ob_sensor_list_get_count
#define ob_sensor_get_recommended_filter_list ob_sensor_create_recommended_filter_list
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,417 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file StreamProfile.h
* @brief The stream profile related type is used to get information such as the width, height, frame rate, and format of the stream.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Create a stream profile object
*
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile* return the stream profile object
*/
OB_EXPORT ob_stream_profile *ob_create_stream_profile(ob_stream_type type, ob_format format, ob_error **error);
/**
* @brief Create a video stream profile object
*
* @param[in] type Stream type
* @param[in] format Stream format
* @param[in] width Stream width
* @param[in] height Stream height
* @param[in] fps Stream frame rate
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile* return the video stream profile object
*/
OB_EXPORT ob_stream_profile *ob_create_video_stream_profile(ob_stream_type type, ob_format format, uint32_t width, uint32_t height, uint32_t fps,
ob_error **error);
/**
* @brief Create a accel stream profile object
*
* @param[in] full_scale_range Accel full scale range
* @param[in] sample_rate Accel sample rate
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile* return the accel stream profile object
*/
OB_EXPORT ob_stream_profile *ob_create_accel_stream_profile(ob_accel_full_scale_range full_scale_range, ob_accel_sample_rate sample_rate, ob_error **error);
/**
* @brief Create a gyro stream profile object
*
* @param[in] full_scale_range Gyro full scale range
* @param[in] sample_rate Gyro sample rate
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_profile* return the accel stream profile object
*/
OB_EXPORT ob_stream_profile *ob_create_gyro_stream_profile(ob_gyro_full_scale_range full_scale_range, ob_gyro_sample_rate sample_rate, ob_error **error);
/**
* @brief Copy the stream profile object from an other stream profile object
*
* @param[in] srcProfile Source stream profile object
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_stream_profile* return the new stream profile object
*/
OB_EXPORT ob_stream_profile *ob_create_stream_profile_from_other_stream_profile(const ob_stream_profile *srcProfile, ob_error **error);
/**
* @brief Copy the stream profile object with a new format object
*
* @param[in] profile Stream profile object
* @param[in] new_format New format
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return ob_stream_profile* return the new stream profile object with the new format
*/
OB_EXPORT ob_stream_profile *ob_create_stream_profile_with_new_format(const ob_stream_profile *profile, ob_format new_format, ob_error **error);
/**
* @brief Delete the stream configuration.
*
* @param[in] profile Stream profile object .
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_stream_profile(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Get stream profile format
*
* @param[in] profile Stream profile object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_format return the format of the stream
*/
OB_EXPORT ob_format ob_stream_profile_get_format(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set stream profile format
*
* @param[in] profile Stream profile object
* @param[in] format The format of the stream
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_stream_profile_set_format(ob_stream_profile *profile, ob_format format, ob_error **error);
/**
* @brief Get stream profile type
*
* @param[in] profile Stream profile object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_stream_type stream type
*/
OB_EXPORT ob_stream_type ob_stream_profile_get_type(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set stream profile type
*
* @param[in] profile Stream profile object
* @param[in] type The type of the stream
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_stream_profile_set_type(const ob_stream_profile *profile, ob_stream_type type, ob_error **error);
/**
* @brief Get the extrinsic for source stream to target stream
*
* @param[in] source Source stream profile
* @param[in] target Target stream profile
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_extrinsic The extrinsic
*/
OB_EXPORT ob_extrinsic ob_stream_profile_get_extrinsic_to(const ob_stream_profile *source, ob_stream_profile *target, ob_error **error);
/**
* @brief Set the extrinsic for source stream to target stream
*
* @param[in] source Stream profile object
* @param[in] target Target stream type
* @param[in] extrinsic The extrinsic
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_stream_profile_set_extrinsic_to(ob_stream_profile *source, const ob_stream_profile *target, ob_extrinsic extrinsic, ob_error **error);
/**
* @brief Set the extrinsic for source stream to target stream type
*
* @param[in] source Source stream profile
* @param[in] type Target stream type
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_extrinsic The extrinsic
*/
OB_EXPORT void ob_stream_profile_set_extrinsic_to_type(ob_stream_profile *source, const ob_stream_type type, ob_extrinsic extrinsic, ob_error **error);
/**
* @brief Get the frame rate of the video stream
*
* @param[in] profile Stream profile object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the frame rate of the stream
*/
OB_EXPORT uint32_t ob_video_stream_profile_get_fps(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Get the width of the video stream
*
* @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the width of the stream
*/
OB_EXPORT uint32_t ob_video_stream_profile_get_width(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set the width of the video stream
*
* @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned
* @param[in] width The width of the stream
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_video_stream_profile_set_width(ob_stream_profile *profile, uint32_t width, ob_error **error);
/**
* @brief Get the height of the video stream
*
* @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return uint32_t return the height of the stream
*/
OB_EXPORT uint32_t ob_video_stream_profile_get_height(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set the height of the video stream
*
* @param[in] profile Stream profile object , If the profile is not a video stream configuration, an error will be returned
* @param[in] height The height of the stream
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_video_stream_profile_set_height(ob_stream_profile *profile, uint32_t height, ob_error **error);
/**
* @brief Get the intrinsic of the video stream profile
*
* @param[in] profile Stream profile object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_camera_intrinsic Return the intrinsic of the stream
*/
OB_EXPORT ob_camera_intrinsic ob_video_stream_profile_get_intrinsic(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set the intrinsic of the video stream profile
*
* @param[in] profile Stream profile object
* @param[in] intrinsic The intrinsic of the stream
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_video_stream_profile_set_intrinsic(ob_stream_profile *profile, ob_camera_intrinsic intrinsic, ob_error **error);
/**
* @brief Get the distortion of the video stream profile
*
* @param[in] profile Stream profile object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_camera_distortion Return the distortion of the stream
*/
OB_EXPORT ob_camera_distortion ob_video_stream_profile_get_distortion(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set the distortion of the video stream profile
*
* @param[in] profile Stream profile object
* @param[in] distortion The distortion of the stream
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_video_stream_profile_set_distortion(ob_stream_profile *profile, ob_camera_distortion distortion, ob_error **error);
/**
* @brief Get the process param of the disparity stream
*
* @param[in] profile Stream profile object
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_disparity_param Return the disparity process param of the stream
*/
OB_EXPORT ob_disparity_param ob_disparity_based_stream_profile_get_disparity_param(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set the disparity process param of the disparity stream.
*
* @param[in] profile Stream profile object. If the profile is not for the disparity stream, an error will be returned.
* @param[in] param The disparity process param of the disparity stream.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_disparity_based_stream_profile_set_disparity_param(ob_stream_profile *profile, ob_disparity_param param, ob_error **error);
/**
* @brief Get the full-scale range of the accelerometer stream.
*
* @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The full-scale range of the accelerometer stream.
*/
OB_EXPORT ob_accel_full_scale_range ob_accel_stream_profile_get_full_scale_range(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Get the sampling frequency of the accelerometer frame.
*
* @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The sampling frequency of the accelerometer frame.
*/
OB_EXPORT ob_accel_sample_rate ob_accel_stream_profile_get_sample_rate(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Get the intrinsic of the accelerometer stream.
*
* @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_accel_intrinsic Return the intrinsic of the accelerometer stream.
*/
OB_EXPORT ob_accel_intrinsic ob_accel_stream_profile_get_intrinsic(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set the intrinsic of the accelerometer stream.
*
* @param[in] profile Stream profile object. If the profile is not for the accelerometer stream, an error will be returned.
* @param[in] intrinsic The intrinsic of the accelerometer stream.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_accel_stream_profile_set_intrinsic(ob_stream_profile *profile, ob_accel_intrinsic intrinsic, ob_error **error);
/**
* @brief Get the full-scale range of the gyroscope stream.
*
* @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The full-scale range of the gyroscope stream.
*/
OB_EXPORT ob_gyro_full_scale_range ob_gyro_stream_profile_get_full_scale_range(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Get the sampling frequency of the gyroscope stream.
*
* @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The sampling frequency of the gyroscope stream.
*/
OB_EXPORT ob_gyro_sample_rate ob_gyro_stream_profile_get_sample_rate(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Get the intrinsic of the gyroscope stream.
*
* @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return ob_gyro_intrinsic Return the intrinsic of the gyroscope stream.
*/
OB_EXPORT ob_gyro_intrinsic ob_gyro_stream_get_intrinsic(const ob_stream_profile *profile, ob_error **error);
/**
* @brief Set the intrinsic of the gyroscope stream.
*
* @param[in] profile Stream profile object. If the profile is not for the gyroscope stream, an error will be returned.
* @param[in] intrinsic The intrinsic of the gyroscope stream.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_gyro_stream_set_intrinsic(ob_stream_profile *profile, ob_gyro_intrinsic intrinsic, ob_error **error);
/**
* @brief Get the number of StreamProfile lists.
*
* @param[in] profile_list StreamProfile list.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The number of StreamProfile lists.
*/
OB_EXPORT uint32_t ob_stream_profile_list_get_count(const ob_stream_profile_list *profile_list, ob_error **error);
/**
* @brief Get the corresponding StreamProfile by subscripting.
*
* @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed.
*
* @param[in] profile_list StreamProfile lists.
* @param[in] index Index.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The matching profile.
*/
OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_profile(const ob_stream_profile_list *profile_list, int index, ob_error **error);
/**
* @brief Match the corresponding ob_stream_profile through the passed parameters. If there are multiple matches,
* the first one in the list will be returned by default. If no matched profile is found, an error will be returned.
*
* @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed.
*
* @param[in] profile_list Resolution list.
* @param[in] width Width. If you don't need to add matching conditions, you can pass OB_WIDTH_ANY.
* @param[in] height Height. If you don't need to add matching conditions, you can pass OB_HEIGHT_ANY.
* @param[in] format Format. If you don't need to add matching conditions, you can pass OB_FORMAT_ANY.
* @param[in] fps Frame rate. If you don't need to add matching conditions, you can pass OB_FPS_ANY.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The matching profile.
*/
OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_video_stream_profile(const ob_stream_profile_list *profile_list, int width, int height,
ob_format format, int fps, ob_error **error);
/**
* @brief Match the corresponding ob_stream_profile through the passed parameters. If there are multiple matches,
* the first one in the list will be returned by default. If no matched profile is found, an error will be returned.
*
* @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed.
*
* @param[in] profile_list Resolution list.
* @param[in] full_scale_range Full-scale range. If you don't need to add matching conditions, you can pass 0.
* @param[in] sample_rate Sample rate. If you don't need to add matching conditions, you can pass 0.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The matching profile.
*/
OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_accel_stream_profile(const ob_stream_profile_list *profile_list,
ob_accel_full_scale_range full_scale_range, ob_accel_sample_rate sample_rate,
ob_error **error);
/**
* @brief Match the corresponding ob_stream_profile through the passed parameters. If there are multiple matches,
* the first one in the list will be returned by default. If no matched profile is found, an error will be returned.
*
* @attention The stream profile returned by this function should be deleted by calling @ref ob_delete_stream_profile() when it is no longer needed.
*
* @param[in] profile_list Resolution list.
* @param[in] full_scale_range Full-scale range. If you don't need to add matching conditions, you can pass 0.
* @param[in] sample_rate Sample rate. If you don't need to add matching conditions, you can pass 0.
* @param[out] error Pointer to an error object that will be set if an error occurs.
* @return The matching profile.
*/
OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_gyro_stream_profile(const ob_stream_profile_list *profile_list,
ob_gyro_full_scale_range full_scale_range, ob_gyro_sample_rate sample_rate,
ob_error **error);
/**
* @brief Delete the stream profile list.
*
* @param[in] profile_list Stream configuration list.
* @param[out] error Pointer to an error object that will be set if an error occurs.
*/
OB_EXPORT void ob_delete_stream_profile_list(const ob_stream_profile_list *profile_list, ob_error **error);
// The following interfaces are deprecated and are retained here for compatibility purposes.
#define ob_stream_profile_format ob_stream_profile_get_format
#define ob_stream_profile_type ob_stream_profile_get_type
#define ob_video_stream_profile_fps ob_video_stream_profile_get_fps
#define ob_video_stream_profile_width ob_video_stream_profile_get_width
#define ob_video_stream_profile_height ob_video_stream_profile_get_height
#define ob_accel_stream_profile_full_scale_range ob_accel_stream_profile_get_full_scale_range
#define ob_accel_stream_profile_sample_rate ob_accel_stream_profile_get_sample_rate
#define ob_gyro_stream_profile_full_scale_range ob_gyro_stream_profile_get_full_scale_range
#define ob_gyro_stream_profile_sample_rate ob_gyro_stream_profile_get_sample_rate
#define ob_stream_profile_list_count ob_stream_profile_list_get_count
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,93 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Convert OBFormat to " char* " type and then return.
*
* @param[in] type OBFormat type.
* @return OBFormat of "char*" type.
*/
OB_EXPORT const char* ob_format_type_to_string(OBFormat type);
/**
* @brief Convert OBFrameType to " char* " type and then return.
*
* @param[in] type OBFrameType type.
* @return OBFrameType of "char*" type.
*/
OB_EXPORT const char* ob_frame_type_to_string(OBFrameType type);
/**
* @brief Convert OBStreamType to " char* " type and then return.
*
* @param[in] type OBStreamType type.
* @return OBStreamType of "char*" type.
*/
OB_EXPORT const char* ob_stream_type_to_string(OBStreamType type);
/**
* @brief Convert OBSensorType to " char* " type and then return.
*
* @param[in] type OBSensorType type.
* @return OBSensorType of "char*" type.
*/
OB_EXPORT const char* ob_sensor_type_to_string(OBSensorType type);
/**
* @brief Convert OBIMUSampleRate to " char* " type and then return.
*
* @param[in] type OBIMUSampleRate type.
* @return OBIMUSampleRate of "char*" type.
*/
OB_EXPORT const char* ob_imu_rate_type_to_string(OBIMUSampleRate type);
/**
* @brief Convert OBGyroFullScaleRange to " char* " type and then return.
*
* @param[in] type OBGyroFullScaleRange type.
* @return OBGyroFullScaleRange of "char*" type.
*/
OB_EXPORT const char* ob_gyro_range_type_to_string(OBGyroFullScaleRange type);
/**
* @brief Convert OBAccelFullScaleRange to " char* " type and then return.
*
* @param[in] type OBAccelFullScaleRange type.
* @return OBAccelFullScaleRange of "char*" type.
*/
OB_EXPORT const char* ob_accel_range_type_to_string(OBAccelFullScaleRange type);
/**
* @brief Convert OBFrameMetadataType to " char* " type and then return.
*
* @param[in] type OBFrameMetadataType type.
* @return OBFrameMetadataType of "char*" type.
*/
OB_EXPORT const char* ob_meta_data_type_to_string(OBFrameMetadataType type);
/**
* @brief Convert OBStreamType to OBSensorType.
*
* @param[in] type The sensor type to convert.
* @return OBStreamType The corresponding stream type.
*/
OB_EXPORT OBStreamType ob_sensor_type_to_stream_type(OBSensorType type);
/**
* @brief Convert OBFormat to " char* " type and then return.
*
* @param format The OBFormat to convert.
* @return The string.
*/
OB_EXPORT const char *ob_format_to_string(OBFormat format);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,124 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "ObTypes.h"
/**
* @brief Transform a 3d point of a source coordinate system into a 3d point of the target coordinate system.
*
* @param[in] source_point3f Source 3d point value
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point3f Target 3d point value
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return bool Transform result
*/
OB_EXPORT bool ob_transformation_3d_to_3d(const OBPoint3f source_point3f, OBExtrinsic extrinsic, OBPoint3f *target_point3f, ob_error **error);
/**
* @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system.
*
* @param[in] source_point2f Source 2d point value
* @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters
* @param[in] source_intrinsic Source intrinsic parameters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point3f Target 3d point value
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return bool Transform result
*/
OB_EXPORT bool ob_transformation_2d_to_3d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic,
OBExtrinsic extrinsic, OBPoint3f *target_point3f, ob_error **error);
/**
* @brief Transform a 3d point of a source coordinate system into a 2d pixel coordinate of the target camera.
*
* @param[in] source_point3f Source 3d point value
* @param[in] target_intrinsic Target intrinsic parameters
* @param[in] target_distortion Target distortion parameters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point2f Target 2d point value
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return bool Transform result
*/
OB_EXPORT bool ob_transformation_3d_to_2d(const OBPoint3f source_point3f, const OBCameraIntrinsic target_intrinsic, const OBCameraDistortion target_distortion,
OBExtrinsic extrinsic, OBPoint2f *target_point2f, ob_error **error);
/**
* @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 2d pixel coordinate of the target camera
*
* @param[in] source_intrinsic Source intrinsic parameters
* @param[in] source_distortion Source distortion parameters
* @param[in] source_point2f Source 2d point value
* @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters
* @param[in] target_intrinsic Target intrinsic parameters
* @param[in] target_distortion Target distortion parameters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point2f Target 2d point value
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return bool Transform result
*/
OB_EXPORT bool ob_transformation_2d_to_2d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic,
const OBCameraDistortion source_distortion, const OBCameraIntrinsic target_intrinsic,
const OBCameraDistortion target_distortion, OBExtrinsic extrinsic, OBPoint2f *target_point2f, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
OB_EXPORT ob_frame *transformation_depth_frame_to_color_camera(ob_device *device, ob_frame *depth_frame, uint32_t target_color_camera_width,
uint32_t target_color_camera_height, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
OB_EXPORT bool transformation_init_xy_tables(const ob_calibration_param calibration_param, const ob_sensor_type sensor_type, float *data, uint32_t *data_size,
ob_xy_tables *xy_tables, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
OB_EXPORT void transformation_depth_to_pointcloud(ob_xy_tables *xy_tables, const void *depth_image_data, void *pointcloud_data, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
OB_EXPORT void transformation_depth_to_rgbd_pointcloud(ob_xy_tables *xy_tables, const void *depth_image_data, const void *color_image_data,
void *pointcloud_data, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
// Use the ob_transformation_3d_to_3d instead.
OB_EXPORT bool ob_calibration_3d_to_3d(const ob_calibration_param calibration_param, const ob_point3f source_point3f, const ob_sensor_type source_sensor_type,
const ob_sensor_type target_sensor_type, ob_point3f *target_point3f, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
// Use the ob_transformation_2d_to_3d instead.
OB_EXPORT bool ob_calibration_2d_to_3d(const ob_calibration_param calibration_param, const ob_point2f source_point2f, const float source_depth_pixel_value,
const ob_sensor_type source_sensor_type, const ob_sensor_type target_sensor_type, ob_point3f *target_point3f,
ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
// Use the ob_transformation_3d_to_2d instead.
OB_EXPORT bool ob_calibration_3d_to_2d(const ob_calibration_param calibration_param, const ob_point3f source_point3f, const ob_sensor_type source_sensor_type,
const ob_sensor_type target_sensor_type, ob_point2f *target_point2f, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
// Use the ob_transformation_2d_to_2d instead.
OB_EXPORT bool ob_calibration_2d_to_2d(const ob_calibration_param calibration_param, const ob_point2f source_point2f, const float source_depth_pixel_value,
const ob_sensor_type source_sensor_type, const ob_sensor_type target_sensor_type, ob_point2f *target_point2f,
ob_error **error);
/**
* @brief save point cloud to ply file.
*
* @param[in] file_name Point cloud save path
* @param[in] frame Point cloud frame
* @param[in] save_binary Binary or textual,true: binary, false: textual
* @param[in] use_mesh Save mesh or not, true: save as mesh, false: not save as mesh
* @param[in] mesh_threshold Distance threshold for creating faces in point cloud,default value :50
* @param[out] error Pointer to an error object that will be set if an error occurs.
*
* @return bool save point cloud result
*/
OB_EXPORT bool ob_save_pointcloud_to_ply(const char *file_name, ob_frame *frame, bool save_binary, bool use_mesh, float mesh_threshold, ob_error **error);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,55 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Version.h
* @brief Functions for retrieving the SDK version number information.
*
*/
#pragma once
#include "Export.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get the SDK version number.
*
* @return int The SDK version number.
*/
OB_EXPORT int ob_get_version(void);
/**
* @brief Get the SDK major version number.
*
* @return int The SDK major version number.
*/
OB_EXPORT int ob_get_major_version(void);
/**
* @brief Get the SDK minor version number.
*
* @return int The SDK minor version number.
*/
OB_EXPORT int ob_get_minor_version(void);
/**
* @brief Get the SDK patch version number.
*
* @return int The SDK patch version number.
*/
OB_EXPORT int ob_get_patch_version(void);
/**
* @brief Get the SDK stage version.
* @attention The returned char* does not need to be freed.
*
* @return const char* The SDK stage version.
*/
OB_EXPORT const char *ob_get_stage_version(void);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,269 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Context.hpp
* @brief The SDK context class, which serves as the entry point to the underlying SDK. It is used to query device lists, handle device callbacks, and set the
* log level.
*
*/
#pragma once
#include "libobsensor/h/Context.h"
#include "Types.hpp"
#include "Error.hpp"
#include <functional>
#include <memory>
namespace ob {
// forward declarations
class Device;
class DeviceInfo;
class DeviceList;
class Context {
public:
/**
* @brief Type definition for the device changed callback function.
*
* @param removedList The list of removed devices.
* @param 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.
*/
typedef std::function<void(OBLogSeverity severity, const char *logMsg)> LogCallback;
private:
ob_context *impl_ = nullptr;
DeviceChangedCallback deviceChangedCallback_;
// static LogCallback logCallback_;
public:
/**
* @brief Context constructor.
* @brief The Context class is a management class that describes the runtime of the SDK. It is responsible for applying and releasing resources for the SDK.
* The context has the ability to manage multiple devices, enumerate devices, monitor device callbacks, and enable functions such as multi-device
* synchronization.
*
* @param[in] configPath The path to the configuration file. If the path is empty, the default configuration will be used.
*/
explicit Context(const char *configPath = "") {
ob_error *error = nullptr;
impl_ = ob_create_context_with_config(configPath, &error);
Error::handle(&error);
}
/**
* @brief Context destructor.
*/
~Context() noexcept {
ob_error *error = nullptr;
ob_delete_context(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Queries the enumerated device list.
*
* @return std::shared_ptr<DeviceList> A pointer to the device list class.
*/
std::shared_ptr<DeviceList> queryDeviceList() const {
ob_error *error = nullptr;
auto list = ob_query_device_list(impl_, &error);
Error::handle(&error);
return std::make_shared<DeviceList>(list);
}
/**
* @brief enable or disable net device enumeration.
* @brief after enable, the net device will be discovered automatically and can be retrieved by @ref queryDeviceList. The default state can be set in the
* configuration file.
*
* @attention Net device enumeration by gvcp protocol, if the device is not in the same subnet as the host, it will be discovered but cannot be connected.
*
* @param[in] enable true to enable, false to disable
*/
void enableNetDeviceEnumeration(bool enable) const {
ob_error *error = nullptr;
ob_enable_net_device_enumeration(impl_, enable, &error);
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 DeviceList::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.
*
* @param[in] address The IP address, ipv4 only. such as "192.168.1.10"
* @param[in] port The port number, currently only support 8090
* @return std::shared_ptr<Device> The created device object.
*/
std::shared_ptr<Device> createNetDevice(const char *address, uint16_t port) const {
ob_error *error = nullptr;
auto device = ob_create_net_device(impl_, address, port, &error);
Error::handle(&error);
return std::make_shared<Device>(device);
}
/**
* @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.
*/
void setDeviceChangedCallback(DeviceChangedCallback callback) {
deviceChangedCallback_ = callback;
ob_error *error = nullptr;
ob_set_device_changed_callback(impl_, &Context::deviceChangedCallback, this, &error);
Error::handle(&error);
}
/**
* @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.
*/
void enableDeviceClockSync(uint64_t repeatIntervalMsec) const {
ob_error *error = nullptr;
ob_enable_device_clock_sync(impl_, repeatIntervalMsec, &error);
Error::handle(&error);
}
/**
* @brief Frees idle memory from the internal frame memory pool.
* @brief The SDK includes an internal frame memory pool that caches memory allocated for frames received from devices.
*/
void freeIdleMemory() const {
ob_error *error = nullptr;
ob_free_idle_memory(impl_, &error);
Error::handle(&error);
}
/**
* @brief For linux, there are two ways to enable the UVC backend: libuvc and v4l2. This function is used to set the backend type.
* @brief It is effective when the new device is created.
*
* @attention This interface is only available for Linux.
*
* @param[in] type The backend type to be used.
*/
void setUvcBackendType(OBUvcBackendType type) const {
ob_error *error = nullptr;
ob_set_uvc_backend_type(impl_, type, &error);
Error::handle(&error);
}
/**
* @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.
*/
static void setLoggerSeverity(OBLogSeverity severity) {
ob_error *error = nullptr;
ob_set_logger_severity(severity, &error);
Error::handle(&error);
}
/**
* @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).
*/
static void setLoggerToFile(OBLogSeverity severity, const char *directory) {
ob_error *error = nullptr;
ob_set_logger_to_file(severity, directory, &error);
Error::handle(&error);
}
/**
* @brief Set log output to the console.
*
* @param severity The log level output to the console.
*/
static void setLoggerToConsole(OBLogSeverity severity) {
ob_error *error = nullptr;
ob_set_logger_to_console(severity, &error);
Error::handle(&error);
}
/**
* @brief Set the logger to callback.
*
* @param severity The callback log level.
* @param callback The callback function.
*/
static void setLoggerToCallback(OBLogSeverity severity, LogCallback callback) {
ob_error *error = nullptr;
Context::getLogCallback() = callback;
ob_set_logger_to_callback(severity, &Context::logCallback, &Context::getLogCallback(), &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
*/
static void setExtensionsDirectory(const char *directory) {
ob_error *error = nullptr;
ob_set_extensions_directory(directory, &error);
Error::handle(&error);
}
private:
static void deviceChangedCallback(ob_device_list *removedList, ob_device_list *addedList, void *userData) {
auto ctx = static_cast<Context *>(userData);
if(ctx && ctx->deviceChangedCallback_) {
auto removed = std::make_shared<DeviceList>(removedList);
auto added = std::make_shared<DeviceList>(addedList);
ctx->deviceChangedCallback_(removed, added);
}
}
static void logCallback(OBLogSeverity severity, const char *logMsg, void *userData) {
auto cb = static_cast<LogCallback *>(userData);
if(cb) {
(*cb)(severity, logMsg);
}
}
// Lazy initialization of the logcallback_. The purpose is to initialize logcallback_ in .hpp
static LogCallback &getLogCallback() {
static LogCallback logCallback_ = nullptr;
return logCallback_;
}
// for backward compatibility
#define enableMultiDeviceSync enableDeviceClockSync
};
} // namespace ob

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Error.hpp
* @brief This file defines the Error class, which describes abnormal errors within the SDK.
* Detailed information about the exception can be obtained through this class.
*/
#pragma once
#include "Types.hpp"
#include "libobsensor/h/Error.h"
#include <memory>
namespace ob {
class Error : public std::exception {
private:
ob_error *impl_;
/**
* @brief Construct a new Error object
*
* @attention This constructor should not be called directly, use the handle() function instead.
*
* @param error The ob_error object
*/
explicit Error(ob_error *error) : impl_(error) {};
Error& operator=(const Error&) = default;
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.
*/
static void handle(ob_error **error, bool throw_exception = true) {
if(!error || !*error) { // no error
return;
}
if(throw_exception) {
throw Error(*error);
}
else {
ob_delete_error(*error);
*error = nullptr;
}
}
/**
* @brief Destroy the Error object
*/
~Error() override {
if(impl_) {
ob_delete_error(impl_);
impl_ = nullptr;
}
}
/**
* @brief Returns the error message of the exception.
*
* @return const char* The error message.
*/
const char *what() const noexcept override {
return impl_->message;
}
/**
* @brief Returns the exception type of the exception.
* @brief Read the comments of the OBExceptionType enum in the libobsensor/h/ObTypes.h file for more information.
*
* @return OBExceptionType The exception type.
*/
OBExceptionType getExceptionType() const noexcept {
return impl_->exception_type;
}
/**
* @brief Returns the name of the function where the exception occurred.
*
* @return const char* The function name.
*/
const char *getFunction() const noexcept {
return impl_->function;
}
/**
* @brief Returns the arguments of the function where the exception occurred.
*
* @return const char* The arguments.
*/
const char *getArgs() const noexcept {
return impl_->args;
}
/**
* @brief Returns the error message of the exception.
* @brief It is recommended to use the what() function instead.
*
* @return const char* The error message.
*/
const char *getMessage() const noexcept {
return impl_->message;
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
const char *getName() const noexcept {
return impl_->function;
}
};
} // namespace ob

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,451 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Pipeline.hpp
* @brief The SDK's advanced API type can quickly implement switching streaming and frame synchronization
* operations.
*/
#pragma once
#include "Frame.hpp"
#include "Device.hpp"
#include "StreamProfile.hpp"
#include "libobsensor/h/Pipeline.h"
#include "libobsensor/hpp/Types.hpp"
#include "libobsensor/hpp/TypeHelper.hpp"
#include <memory>
#include <functional>
namespace ob {
/**
* @brief Config class for configuring pipeline parameters
*
* The Config class provides an interface for configuring pipeline parameters.
*/
class Config {
private:
ob_config_t *impl_;
public:
/**
* @brief Construct a new Config object
*/
Config() {
ob_error *error = nullptr;
impl_ = ob_create_config(&error);
Error::handle(&error);
}
explicit Config(ob_config_t *impl) : impl_(impl) {}
/**
* @brief Destroy the Config object
*/
~Config() noexcept {
ob_error *error = nullptr;
ob_delete_config(impl_, &error);
Error::handle(&error, false);
}
ob_config_t *getImpl() const {
return impl_;
}
/**
* @brief enable a stream with a specific stream type
*
* @param streamType The stream type to be enabled
*/
void enableStream(OBStreamType streamType) const {
ob_error *error = nullptr;
ob_config_enable_stream(impl_, streamType, &error);
Error::handle(&error);
}
/**
* @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
*/
void enableStream(OBSensorType sensorType) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
enableStream(streamType);
}
/**
* @brief Enable a stream to be used in the pipeline
*
* @param streamProfile The stream configuration to be enabled
*/
void enableStream(std::shared_ptr<const StreamProfile> streamProfile) const {
ob_error *error = nullptr;
auto c_stream_profile = streamProfile->getImpl();
ob_config_enable_stream_with_stream_profile(impl_, c_stream_profile, &error);
Error::handle(&error);
}
/**
* @brief Enable a video stream to be used in the pipeline.
*
* This function allows users to enable a video stream with customizable parameters.
* 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).
*/
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 {
ob_error *error = nullptr;
ob_config_enable_video_stream(impl_, streamType, width, height, fps, format, &error);
Error::handle(&error);
}
/**
* @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).
*/
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 {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
enableVideoStream(streamType, width, height, fps, format);
}
/**
* @brief Enable an accelerometer stream to be used in the pipeline.
*
* This function allows users to enable an accelerometer stream with customizable parameters.
* 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).
*/
void enableAccelStream(OBAccelFullScaleRange fullScaleRange = OB_ACCEL_FULL_SCALE_RANGE_ANY,
OBAccelSampleRate sampleRate = OB_ACCEL_SAMPLE_RATE_ANY) const {
ob_error *error = nullptr;
ob_config_enable_accel_stream(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
}
/**
* @brief Enable a gyroscope stream to be used in the pipeline.
*
* This function allows users to enable a gyroscope stream with customizable parameters.
* 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).
*/
void enableGyroStream(OBGyroFullScaleRange fullScaleRange = OB_GYRO_FULL_SCALE_RANGE_ANY, OBGyroSampleRate sampleRate = OB_GYRO_SAMPLE_RATE_ANY) const {
ob_error *error = nullptr;
ob_config_enable_gyro_stream(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
}
/**
* @deprecated Use enableStream(std::shared_ptr<StreamProfile> streamProfile) instead
* @brief Enable all streams to be used in the pipeline
*/
void enableAllStream() {
ob_error *error = nullptr;
ob_config_enable_all_stream(impl_, &error);
Error::handle(&error);
}
/**
* @brief Disable a stream to be used in the pipeline
*
* @param streamType The stream configuration to be disabled
*/
void disableStream(OBStreamType streamType) const {
ob_error *error = nullptr;
ob_config_disable_stream(impl_, streamType, &error);
Error::handle(&error);
}
/**
* @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
*/
void disableStream(OBSensorType sensorType) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
disableStream(streamType);
}
/**
* @brief Disable all streams to be used in the pipeline
*/
void disableAllStream() const {
ob_error *error = nullptr;
ob_config_disable_all_stream(impl_, &error);
Error::handle(&error);
}
/**
* @brief Get the Enabled Stream Profile List
*
* @return std::shared_ptr<StreamProfileList>
*/
std::shared_ptr<StreamProfileList> getEnabledStreamProfileList() const {
ob_error *error = nullptr;
auto list = ob_config_get_enabled_stream_profile_list(impl_, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
/**
* @brief Set the alignment mode
*
* @param mode The alignment mode
*/
void setAlignMode(OBAlignMode mode) const {
ob_error *error = nullptr;
ob_config_set_align_mode(impl_, mode, &error);
Error::handle(&error);
}
/**
* @brief Set whether the depth needs to be scaled after setting D2C
*
* @param enable Whether scaling is required
*/
void setDepthScaleRequire(bool enable) const {
ob_error *error = nullptr;
ob_config_set_depth_scale_after_align_require(impl_, enable, &error);
Error::handle(&error);
}
/**
* @brief Set the frame aggregation output mode for the pipeline configuration
* @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)
*/
void setFrameAggregateOutputMode(OBFrameAggregateOutputMode mode) const {
ob_error *error = nullptr;
ob_config_set_frame_aggregate_output_mode(impl_, mode, &error);
Error::handle(&error);
}
};
class Pipeline {
public:
/**
* @brief FrameSetCallback is a callback function type for frameset data arrival.
*
* @param frame The returned frameset data
*/
typedef std::function<void(std::shared_ptr<FrameSet> frame)> FrameSetCallback;
private:
ob_pipeline_t *impl_;
FrameSetCallback callback_;
public:
/**
* @brief Pipeline is a high-level interface for applications, algorithms related RGBD data streams. Pipeline can provide alignment inside and synchronized
* FrameSet. Pipeline() no parameter version, which opens the first device in the list of devices connected to the OS by default. If the application has
* obtained the device through the DeviceList, opening the Pipeline() at this time will throw an exception that the device has been created.
*/
Pipeline() {
ob_error *error = nullptr;
impl_ = ob_create_pipeline(&error);
Error::handle(&error);
}
/**
* @brief
* Pipeline(std::shared_ptr< Device > device ) Function for multi-device operations. Multiple devices need to be obtained through DeviceList, and the device
* and pipeline are bound through this interface.
*/
explicit Pipeline(std::shared_ptr<Device> device) {
ob_error *error = nullptr;
impl_ = ob_create_pipeline_with_device(device->getImpl(), &error);
Error::handle(&error);
}
/**
* @brief Destroy the pipeline object
*/
~Pipeline() noexcept {
ob_error *error = nullptr;
ob_delete_pipeline(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Start the pipeline with configuration parameters
*
* @param config The parameter configuration of the pipeline
*/
void start(std::shared_ptr<Config> config = nullptr) const {
ob_error *error = nullptr;
ob_config_t *config_impl = config == nullptr ? nullptr : config->getImpl();
ob_pipeline_start_with_config(impl_, config_impl, &error);
Error::handle(&error);
}
/**
* @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
*/
void start(std::shared_ptr<Config> config, FrameSetCallback callback) {
callback_ = callback;
ob_error *error = nullptr;
ob_pipeline_start_with_callback(impl_, config ? config->getImpl() : nullptr, &Pipeline::frameSetCallback, this, &error);
Error::handle(&error);
}
static void frameSetCallback(ob_frame_t *frameSet, void *userData) {
auto pipeline = static_cast<Pipeline *>(userData);
pipeline->callback_(std::make_shared<FrameSet>(frameSet));
}
/**
* @brief Stop the pipeline
*/
void stop() const {
ob_error *error = nullptr;
ob_pipeline_stop(impl_, &error);
Error::handle(&error);
}
/**
* @brief Get the pipeline configuration parameters
* @brief Returns the default configuration if the user has not configured it
*
* @return std::shared_ptr<Config> The configured parameters
*/
std::shared_ptr<Config> getConfig() const {
ob_error *error = nullptr;
auto config = ob_pipeline_get_config(impl_, &error);
Error::handle(&error);
return std::make_shared<Config>(config);
}
/**
* @brief Wait for frameset
*
* @param 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 {
ob_error *error = nullptr;
auto frameSet = ob_pipeline_wait_for_frameset(impl_, timeoutMs, &error);
if(frameSet == nullptr) {
return nullptr;
}
Error::handle(&error);
return std::make_shared<FrameSet>(frameSet);
}
/**
* @brief Get the device object
*
* @return std::shared_ptr<Device> The device object
*/
std::shared_ptr<Device> getDevice() const {
ob_error *error = nullptr;
auto device = ob_pipeline_get_device(impl_, &error);
Error::handle(&error);
return std::make_shared<Device>(device);
}
/**
* @brief Get the stream profile of the specified sensor
*
* @param sensorType The type of sensor
* @return std::shared_ptr<StreamProfileList> The stream profile list
*/
std::shared_ptr<StreamProfileList> getStreamProfileList(OBSensorType sensorType) const {
ob_error *error = nullptr;
auto list = ob_pipeline_get_stream_profile_list(impl_, sensorType, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
/**
* @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.
*
* @attention Currently, only ALIGN_D2C_HW_MODE supported. For other align modes, please using the AlignFilter interface.
*
* @return std::shared_ptr<StreamProfileList> The stream profile list of supported depth-to-color alignments.
*/
std::shared_ptr<StreamProfileList> getD2CDepthProfileList(std::shared_ptr<StreamProfile> colorProfile, OBAlignMode alignMode) {
ob_error *error = nullptr;
auto list = ob_get_d2c_depth_profile_list(impl_, colorProfile->getImpl(), alignMode, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
/**
* @brief Turn on frame synchronization
*/
void enableFrameSync() const {
ob_error *error = nullptr;
ob_pipeline_enable_frame_sync(impl_, &error);
Error::handle(&error);
}
/**
* @brief Turn off frame synchronization
*/
void disableFrameSync() const {
ob_error *error = nullptr;
ob_pipeline_disable_frame_sync(impl_, &error);
Error::handle(&error);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBCameraParam getCameraParam() {
ob_error *error = nullptr;
OBCameraParam cameraParam = ob_pipeline_get_camera_param(impl_, &error);
Error::handle(&error);
return cameraParam;
}
OBCameraParam getCameraParamWithProfile(uint32_t colorWidth, uint32_t colorHeight, uint32_t depthWidth, uint32_t depthHeight) {
ob_error *error = nullptr;
OBCameraParam cameraParam = ob_pipeline_get_camera_param_with_profile(impl_, colorWidth, colorHeight, depthWidth, depthHeight, &error);
Error::handle(&error);
return cameraParam;
}
OBCalibrationParam getCalibrationParam(std::shared_ptr<Config> config) {
ob_error *error = nullptr;
OBCalibrationParam calibrationParam = ob_pipeline_get_calibration_param(impl_, config->getImpl(), &error);
Error::handle(&error);
return calibrationParam;
}
std::shared_ptr<FrameSet> waitForFrames(uint32_t timeoutMs = 1000) const {
return waitForFrameset(timeoutMs);
}
};
} // namespace ob

View File

@@ -0,0 +1,188 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file RecordPlayback.hpp
* @brief Record and playback device-related types, including interfaces to create recording and playback devices,
record and playback streaming data, etc.
*/
#pragma once
#include "Types.hpp"
#include "Error.hpp"
#include "libobsensor/h/RecordPlayback.h"
#include "libobsensor/hpp/Device.hpp"
namespace ob {
typedef std::function<void(OBPlaybackStatus status)> PlaybackStatusChangeCallback;
class RecordDevice {
private:
ob_record_device_t *impl_ = nullptr;
public:
explicit RecordDevice(std::shared_ptr<Device> device, const std::string &file, bool compressionEnabled = true) {
ob_error *error = nullptr;
impl_ = ob_create_record_device(device->getImpl(), file.c_str(), compressionEnabled, &error);
Error::handle(&error);
}
virtual ~RecordDevice() noexcept {
ob_error *error = nullptr;
ob_delete_record_device(impl_, &error);
Error::handle(&error, false);
}
RecordDevice(RecordDevice &&other) noexcept {
if(this != &other) {
impl_ = other.impl_;
other.impl_ = nullptr;
}
}
RecordDevice &operator=(RecordDevice &&other) noexcept {
if(this != &other) {
impl_ = other.impl_;
other.impl_ = nullptr;
}
return *this;
}
RecordDevice(const RecordDevice &) = delete;
RecordDevice &operator=(const RecordDevice &) = delete;
public:
void pause() {
ob_error *error = nullptr;
ob_record_device_pause(impl_, &error);
Error::handle(&error);
}
void resume() {
ob_error *error = nullptr;
ob_record_device_resume(impl_, &error);
Error::handle(&error);
}
};
class PlaybackDevice : public Device {
public:
explicit PlaybackDevice(const std::string &file) : Device(nullptr) {
ob_error *error = nullptr;
impl_ = ob_create_playback_device(file.c_str(), &error);
Error::handle(&error);
}
virtual ~PlaybackDevice() noexcept override = default;
PlaybackDevice(PlaybackDevice &&other) noexcept : Device(std::move(other)) {}
PlaybackDevice &operator=(PlaybackDevice &&other) noexcept {
Device::operator=(std::move(other));
return *this;
}
PlaybackDevice(const PlaybackDevice &) = delete;
PlaybackDevice &operator=(const PlaybackDevice &) = delete;
public:
/**
* @brief Pause the streaming data from the playback device.
*/
void pause() {
ob_error *error = nullptr;
ob_playback_device_pause(impl_, &error);
Error::handle(&error);
}
/**
* @brief Resume the streaming data from the playback device.
*/
void resume() {
ob_error *error = nullptr;
ob_playback_device_resume(impl_, &error);
Error::handle(&error);
}
/**
* @brief Seek to a specific timestamp when playing back a recording.
* @param[in] timestamp The timestamp to seek to, in milliseconds.
*/
void seek(const int64_t timestamp) {
ob_error *error = nullptr;
ob_playback_device_seek(impl_, timestamp, &error);
Error::handle(&error);
}
/**
* @brief Set the playback rate of the playback device.
* @param[in] rate The playback rate to set.
*/
void setPlaybackRate(const float rate) {
ob_error *error = nullptr;
ob_playback_device_set_playback_rate(impl_, rate, &error);
Error::handle(&error);
}
/**
* @brief Set a callback function to be called when the playback status changes.
* @param[in] callback The callback function to set.
*/
void setPlaybackStatusChangeCallback(PlaybackStatusChangeCallback callback) {
callback_ = callback;
ob_error *error = nullptr;
ob_playback_device_set_playback_status_changed_callback(impl_, &PlaybackDevice::playbackStatusCallback, this, &error);
Error::handle(&error);
}
/**
* @brief Get the current playback status of the playback device.
* @return The current playback status.
*/
OBPlaybackStatus getPlaybackStatus() const {
ob_error *error = nullptr;
OBPlaybackStatus status = ob_playback_device_get_current_playback_status(impl_, &error);
Error::handle(&error);
return status;
}
/**
* @brief Get the current position of the playback device.
* @return The current position of the playback device, in milliseconds.
*/
uint64_t getPosition() const {
ob_error *error = nullptr;
uint64_t position = ob_playback_device_get_position(impl_, &error);
Error::handle(&error);
return position;
}
/**
* @brief Get the duration of the playback device.
* @return The duration of the playback device, in milliseconds.
*/
uint64_t getDuration() const {
ob_error *error = nullptr;
uint64_t duration = ob_playback_device_get_duration(impl_, &error);
Error::handle(&error);
return duration;
}
private:
static void playbackStatusCallback(OBPlaybackStatus status, void *userData) {
auto *playbackDevice = static_cast<PlaybackDevice *>(userData);
if(playbackDevice && playbackDevice->callback_) {
playbackDevice->callback_(status);
}
}
private:
PlaybackStatusChangeCallback callback_;
};
} // namespace ob

View File

@@ -0,0 +1,236 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Sensor.hpp
* @brief Defines types related to sensors, which are used to obtain stream configurations, open and close streams, and set and get sensor properties.
*/
#pragma once
#include "Types.hpp"
#include "libobsensor/hpp/Filter.hpp"
#include "libobsensor/h/Sensor.h"
#include "libobsensor/h/Filter.h"
#include "Error.hpp"
#include "StreamProfile.hpp"
#include "Device.hpp"
#include "Frame.hpp"
#include <functional>
#include <memory>
#include <vector>
namespace ob {
class Sensor {
public:
/**
* @brief Callback function for frame data.
*
* @param frame The frame data.
*/
typedef std::function<void(std::shared_ptr<Frame> frame)> FrameCallback;
protected:
ob_sensor_t *impl_;
FrameCallback callback_;
public:
explicit Sensor(ob_sensor_t *impl) : impl_(impl) {}
Sensor(Sensor &&sensor) noexcept : impl_(sensor.impl_) {
sensor.impl_ = nullptr;
}
Sensor &operator=(Sensor &&sensor) noexcept {
if(this != &sensor) {
ob_error *error = nullptr;
ob_delete_sensor(impl_, &error);
Error::handle(&error);
impl_ = sensor.impl_;
sensor.impl_ = nullptr;
}
return *this;
}
Sensor(const Sensor &sensor) = delete;
Sensor &operator=(const Sensor &sensor) = delete;
virtual ~Sensor() noexcept {
ob_error *error = nullptr;
ob_delete_sensor(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Get the sensor type.
*
* @return OBSensorType The sensor type.
*/
OBSensorType getType() const {
ob_error *error = nullptr;
auto type = ob_sensor_get_type(impl_, &error);
Error::handle(&error);
return type;
}
/**
* @brief Get the list of stream profiles.
*
* @return std::shared_ptr<StreamProfileList> The stream profile list.
*/
std::shared_ptr<StreamProfileList> getStreamProfileList() const {
ob_error *error = nullptr;
auto list = ob_sensor_get_stream_profile_list(impl_, &error);
Error::handle(&error);
return std::make_shared<StreamProfileList>(list);
}
/**
* @brief Create a list of recommended filters for the sensor.
*
* @return OBFilterList list of frame processing block
*/
std::vector<std::shared_ptr<Filter>> createRecommendedFilters() const {
ob_error *error = nullptr;
auto list = ob_sensor_create_recommended_filter_list(impl_, &error);
Error::handle(&error);
auto filter_count = ob_filter_list_get_count(list, &error);
std::vector<std::shared_ptr<Filter>> filters;
for(uint32_t i = 0; i < filter_count; i++) {
auto filterImpl = ob_filter_list_get_filter(list, i, &error);
Error::handle(&error);
filters.push_back(std::make_shared<Filter>(filterImpl));
}
ob_delete_filter_list(list, &error);
Error::handle(&error, false);
return filters;
}
/**
* @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.
*/
void start(std::shared_ptr<StreamProfile> streamProfile, FrameCallback callback) {
ob_error *error = nullptr;
callback_ = std::move(callback);
ob_sensor_start(impl_, const_cast<ob_stream_profile_t *>(streamProfile->getImpl()), &Sensor::frameCallback, this, &error);
Error::handle(&error);
}
/**
* @brief Stop the stream.
*/
void stop() const {
ob_error *error = nullptr;
ob_sensor_stop(impl_, &error);
Error::handle(&error);
}
/**
* @brief Dynamically switch resolutions.
*
* @param streamProfile The resolution to switch to.
*/
void switchProfile(std::shared_ptr<StreamProfile> streamProfile) {
ob_error *error = nullptr;
ob_sensor_switch_profile(impl_, const_cast<ob_stream_profile_t *>(streamProfile->getImpl()), &error);
Error::handle(&error);
}
private:
static void frameCallback(ob_frame *frame, void *userData) {
auto sensor = static_cast<Sensor *>(userData);
sensor->callback_(std::make_shared<Frame>(frame));
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBSensorType type() const {
return getType();
}
std::vector<std::shared_ptr<Filter>> getRecommendedFilters() const {
return createRecommendedFilters();
}
};
class SensorList {
private:
ob_sensor_list_t *impl_ = nullptr;
public:
explicit SensorList(ob_sensor_list_t *impl) : impl_(impl) {}
~SensorList() noexcept {
ob_error *error = nullptr;
ob_delete_sensor_list(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Get the number of sensors.
*
* @return uint32_t The number of sensors.
*/
uint32_t getCount() const {
ob_error *error = nullptr;
auto count = ob_sensor_list_get_count(impl_, &error);
Error::handle(&error);
return count;
}
/**
* @brief Get the type of the specified sensor.
*
* @param index The sensor index.
* @return OBSensorType The sensor type.
*/
OBSensorType getSensorType(uint32_t index) const {
ob_error *error = nullptr;
auto type = ob_sensor_list_get_sensor_type(impl_, index, &error);
Error::handle(&error);
return type;
}
/**
* @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.
* @return std::shared_ptr<Sensor> The sensor object.
*/
std::shared_ptr<Sensor> getSensor(uint32_t index) const {
ob_error *error = nullptr;
auto sensor = ob_sensor_list_get_sensor(impl_, index, &error);
Error::handle(&error);
return std::make_shared<Sensor>(sensor);
}
/**
* @brief Get a sensor by sensor type.
*
* @param 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 {
ob_error *error = nullptr;
auto sensor = ob_sensor_list_get_sensor_by_type(impl_, sensorType, &error);
Error::handle(&error);
return std::make_shared<Sensor>(sensor);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t count() const {
return getCount();
}
OBSensorType type(uint32_t index) const {
return getSensorType(index);
}
};
} // namespace ob

View File

@@ -0,0 +1,523 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file StreamProfile.hpp
* @brief The stream profile related type is used to get information such as the width, height, frame rate, and format of the stream.
*/
#pragma once
#include "Types.hpp"
#include "libobsensor/h/StreamProfile.h"
#include "libobsensor/h/Error.h"
#include <iostream>
#include <memory>
namespace ob {
class StreamProfile : public std::enable_shared_from_this<StreamProfile> {
protected:
const ob_stream_profile_t *impl_ = nullptr;
public:
StreamProfile(StreamProfile &streamProfile) = delete;
StreamProfile &operator=(StreamProfile &streamProfile) = delete;
StreamProfile(StreamProfile &&streamProfile) noexcept : impl_(streamProfile.impl_) {
streamProfile.impl_ = nullptr;
}
StreamProfile &operator=(StreamProfile &&streamProfile) noexcept {
if(this != &streamProfile) {
ob_error *error = nullptr;
ob_delete_stream_profile(impl_, &error);
Error::handle(&error);
impl_ = streamProfile.impl_;
streamProfile.impl_ = nullptr;
}
return *this;
}
virtual ~StreamProfile() noexcept {
if(impl_) {
ob_error *error = nullptr;
ob_delete_stream_profile(impl_, &error);
Error::handle(&error);
}
}
const ob_stream_profile *getImpl() const {
return impl_;
}
/**
* @brief Get the format of the stream.
*
* @return OBFormat return the format of the stream.
*/
OBFormat getFormat() const {
ob_error *error = nullptr;
auto format = ob_stream_profile_get_format(impl_, &error);
Error::handle(&error);
return format;
}
/**
* @brief Get the type of stream.
*
* @return OBStreamType return the type of the stream.
*/
OBStreamType getType() const {
ob_error *error = nullptr;
auto type = ob_stream_profile_get_type(impl_, &error);
Error::handle(&error);
return type;
}
/**
* @brief Get the extrinsic parameters from current stream profile to the given target stream profile.
*
* @return OBExtrinsic Return the extrinsic parameters.
*/
OBExtrinsic getExtrinsicTo(std::shared_ptr<StreamProfile> target) const {
ob_error *error = nullptr;
auto extrinsic = ob_stream_profile_get_extrinsic_to(impl_, const_cast<ob_stream_profile_t *>(target->getImpl()), &error);
Error::handle(&error);
return extrinsic;
}
/**
* @brief Set the extrinsic parameters from current stream profile to the given target stream profile.
*
* @tparam target Target stream profile.
* @tparam extrinsic The extrinsic.
*/
void bindExtrinsicTo(std::shared_ptr<StreamProfile> target, const OBExtrinsic &extrinsic) {
ob_error *error = nullptr;
ob_stream_profile_set_extrinsic_to(const_cast<ob_stream_profile_t *>(impl_), const_cast<const ob_stream_profile_t *>(target->getImpl()), extrinsic, &error);
Error::handle(&error);
}
/**
* @brief Set the extrinsic parameters from current stream profile to the given target stream type.
*
* @tparam targetStreamType Target stream type.
* @tparam extrinsic The extrinsic.
*/
void bindExtrinsicTo(const OBStreamType &targetStreamType, const OBExtrinsic &extrinsic) {
ob_error *error = nullptr;
ob_stream_profile_set_extrinsic_to_type(const_cast<ob_stream_profile_t *>(impl_),targetStreamType,extrinsic, &error);
Error::handle(&error);
}
/**
* @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;
/**
* @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() {
if(!is<T>()) {
throw std::runtime_error("Unsupported operation. Object's type is not the required type.");
}
return std::dynamic_pointer_cast<T>(shared_from_this());
}
/**
* @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 {
if(!is<T>()) {
throw std::runtime_error("Unsupported operation. Object's type is not the required type.");
}
return std::static_pointer_cast<const T>(shared_from_this());
}
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBFormat format() const {
return getFormat();
}
OBStreamType type() const {
return getType();
}
protected:
explicit StreamProfile(const ob_stream_profile_t *impl) : impl_(impl) {}
};
/**
* @brief Class representing a video stream profile.
*/
class VideoStreamProfile : public StreamProfile {
public:
explicit VideoStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {}
~VideoStreamProfile() noexcept override = default;
/**
* @brief Return the frame rate of the stream.
*
* @return uint32_t Return the frame rate of the stream.
*/
uint32_t getFps() const {
ob_error *error = nullptr;
auto fps = ob_video_stream_profile_get_fps(impl_, &error);
Error::handle(&error);
return fps;
}
/**
* @brief Return the width of the stream.
*
* @return uint32_t Return the width of the stream.
*/
uint32_t getWidth() const {
ob_error *error = nullptr;
auto width = ob_video_stream_profile_get_width(impl_, &error);
Error::handle(&error);
return width;
}
/**
* @brief Return the height of the stream.
*
* @return uint32_t Return the height of the stream.
*/
uint32_t getHeight() const {
ob_error *error = nullptr;
auto height = ob_video_stream_profile_get_height(impl_, &error);
Error::handle(&error);
return height;
}
/**
* @brief Get the intrinsic parameters of the stream.
*
* @return OBCameraIntrinsic Return the intrinsic parameters.
*/
OBCameraIntrinsic getIntrinsic() const {
ob_error *error = nullptr;
auto intrinsic = ob_video_stream_profile_get_intrinsic(impl_, &error);
Error::handle(&error);
return intrinsic;
}
/**
* @brief Set the intrinsic parameters of the stream.
*
* @param intrinsic The intrinsic parameters.
*/
void setIntrinsic(const OBCameraIntrinsic &intrinsic) {
ob_error *error = nullptr;
ob_video_stream_profile_set_intrinsic(const_cast<ob_stream_profile_t *>(impl_), intrinsic, &error);
Error::handle(&error);
}
/**
* @brief Get the distortion parameters of the stream.
* @brief Brown distortion model
*
* @return OBCameraDistortion Return the distortion parameters.
*/
OBCameraDistortion getDistortion() const {
ob_error *error = nullptr;
auto distortion = ob_video_stream_profile_get_distortion(impl_, &error);
Error::handle(&error);
return distortion;
}
/**
* @brief Set the distortion parameters of the stream.
*
* @param distortion The distortion parameters.
*/
void setDistortion(const OBCameraDistortion &distortion) {
ob_error *error = nullptr;
ob_video_stream_profile_set_distortion(const_cast<ob_stream_profile_t *>(impl_), distortion, &error);
Error::handle(&error);
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t fps() const {
return getFps();
}
uint32_t width() const {
return getWidth();
}
uint32_t height() const {
return getHeight();
}
};
/**
* @brief Class representing an accelerometer stream profile.
*/
class AccelStreamProfile : public StreamProfile {
public:
explicit AccelStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {}
~AccelStreamProfile() noexcept override = default;
/**
* @brief Return the full scale range.
*
* @return OBAccelFullScaleRange Return the scale range value.
*/
OBAccelFullScaleRange getFullScaleRange() const {
ob_error *error = nullptr;
auto fullScaleRange = ob_accel_stream_profile_get_full_scale_range(impl_, &error);
Error::handle(&error);
return fullScaleRange;
}
/**
* @brief Return the sampling frequency.
*
* @return OBAccelFullScaleRange Return the sampling frequency.
*/
OBAccelSampleRate getSampleRate() const {
ob_error *error = nullptr;
auto sampleRate = ob_accel_stream_profile_get_sample_rate(impl_, &error);
Error::handle(&error);
return sampleRate;
}
/**
* @brief get the intrinsic parameters of the stream.
*
* @return OBAccelIntrinsic Return the intrinsic parameters.
*/
OBAccelIntrinsic getIntrinsic() const {
ob_error *error = nullptr;
auto intrinsic = ob_accel_stream_profile_get_intrinsic(impl_, &error);
Error::handle(&error);
return intrinsic;
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBAccelFullScaleRange fullScaleRange() const {
return getFullScaleRange();
}
OBAccelSampleRate sampleRate() const {
return getSampleRate();
}
};
/**
* @brief Class representing a gyroscope stream profile.
*/
class GyroStreamProfile : public StreamProfile {
public:
explicit GyroStreamProfile(const ob_stream_profile_t *impl) : StreamProfile(impl) {}
~GyroStreamProfile() noexcept override = default;
/**
* @brief Return the full scale range.
*
* @return OBAccelFullScaleRange Return the scale range value.
*/
OBGyroFullScaleRange getFullScaleRange() const {
ob_error *error = nullptr;
auto fullScaleRange = ob_gyro_stream_profile_get_full_scale_range(impl_, &error);
Error::handle(&error);
return fullScaleRange;
}
/**
* @brief Return the sampling frequency.
*
* @return OBAccelFullScaleRange Return the sampling frequency.
*/
OBGyroSampleRate getSampleRate() const {
ob_error *error = nullptr;
auto sampleRate = ob_gyro_stream_profile_get_sample_rate(impl_, &error);
Error::handle(&error);
return sampleRate;
}
/**
* @brief get the intrinsic parameters of the stream.
*
* @return OBGyroIntrinsic Return the intrinsic parameters.
*/
OBGyroIntrinsic getIntrinsic() const {
ob_error *error = nullptr;
auto intrinsic = ob_gyro_stream_get_intrinsic(impl_, &error);
Error::handle(&error);
return intrinsic;
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBGyroFullScaleRange fullScaleRange() const {
return getFullScaleRange();
}
OBGyroSampleRate sampleRate() const {
return getSampleRate();
}
};
template <typename T> bool StreamProfile::is() const {
switch(this->getType()) {
case OB_STREAM_VIDEO:
case OB_STREAM_IR:
case OB_STREAM_IR_LEFT:
case OB_STREAM_IR_RIGHT:
case OB_STREAM_COLOR:
case OB_STREAM_DEPTH:
case OB_STREAM_RAW_PHASE:
case OB_STREAM_CONFIDENCE:
return typeid(T) == typeid(VideoStreamProfile);
case OB_STREAM_ACCEL:
return typeid(T) == typeid(AccelStreamProfile);
case OB_STREAM_GYRO:
return typeid(T) == typeid(GyroStreamProfile);
default:
break;
}
return false;
}
class StreamProfileFactory {
public:
static std::shared_ptr<StreamProfile> create(const ob_stream_profile_t *impl) {
ob_error *error = nullptr;
const auto type = ob_stream_profile_get_type(impl, &error);
Error::handle(&error);
switch(type) {
case OB_STREAM_IR:
case OB_STREAM_IR_LEFT:
case OB_STREAM_IR_RIGHT:
case OB_STREAM_DEPTH:
case OB_STREAM_COLOR:
case OB_STREAM_VIDEO:
case OB_STREAM_CONFIDENCE:
return std::make_shared<VideoStreamProfile>(impl);
case OB_STREAM_ACCEL:
return std::make_shared<AccelStreamProfile>(impl);
case OB_STREAM_GYRO:
return std::make_shared<GyroStreamProfile>(impl);
default: {
ob_error *err = ob_create_error(OB_STATUS_ERROR, "Unsupported stream type.", "StreamProfileFactory::create", "", OB_EXCEPTION_TYPE_INVALID_VALUE);
Error::handle(&err);
return nullptr;
}
}
}
};
class StreamProfileList {
protected:
const ob_stream_profile_list_t *impl_;
public:
explicit StreamProfileList(ob_stream_profile_list_t *impl) : impl_(impl) {}
~StreamProfileList() noexcept {
ob_error *error = nullptr;
ob_delete_stream_profile_list(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Return the number of StreamProfile objects.
*
* @return uint32_t Return the number of StreamProfile objects.
*/
uint32_t getCount() const {
ob_error *error = nullptr;
auto count = ob_stream_profile_list_get_count(impl_, &error);
Error::handle(&error);
return count;
}
/**
* @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.
* @return std::shared_ptr<StreamProfile> Return the StreamProfile object.
*/
std::shared_ptr<StreamProfile> getProfile(uint32_t index) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_profile(impl_, index, &error);
Error::handle(&error);
return StreamProfileFactory::create(profile);
}
/**
* @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.
* @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,
int fps = OB_FPS_ANY) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_video_stream_profile(impl_, width, height, format, fps, &error);
Error::handle(&error);
auto vsp = StreamProfileFactory::create(profile);
return vsp->as<VideoStreamProfile>();
}
/**
* @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.
*/
std::shared_ptr<AccelStreamProfile> getAccelStreamProfile(OBAccelFullScaleRange fullScaleRange, OBAccelSampleRate sampleRate) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_accel_stream_profile(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
auto asp = StreamProfileFactory::create(profile);
return asp->as<AccelStreamProfile>();
}
/**
* @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.
*/
std::shared_ptr<GyroStreamProfile> getGyroStreamProfile(OBGyroFullScaleRange fullScaleRange, OBGyroSampleRate sampleRate) const {
ob_error *error = nullptr;
auto profile = ob_stream_profile_list_get_gyro_stream_profile(impl_, fullScaleRange, sampleRate, &error);
Error::handle(&error);
auto gsp = StreamProfileFactory::create(profile);
return gsp->as<GyroStreamProfile>();
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t count() const {
return getCount();
}
};
} // namespace ob

View File

@@ -0,0 +1,145 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
#pragma once
#include <string>
#include <iostream>
#include "libobsensor/h/ObTypes.h"
#include "libobsensor/h/TypeHelper.h"
#include <functional>
namespace ob {
class TypeHelper {
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) {
return ob_format_type_to_string(type);
}
/**
* @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) {
return ob_frame_type_to_string(type);
}
/**
* @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) {
return ob_stream_type_to_string(type);
}
/**
* @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) {
return ob_sensor_type_to_string(type);
}
/**
* @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) {
return ob_imu_rate_type_to_string(type);
}
/**
* @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) {
return ob_gyro_range_type_to_string(type);
}
/**
* @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) {
return ob_accel_range_type_to_string(type);
}
/**
* @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) {
return ob_meta_data_type_to_string(type);
}
/**
* @brief Convert OBSensorType to OBStreamType type and then return.
*
* @param[in] type OBSensorType type.
* @return OBStreamType type.
*/
static OBStreamType convertSensorTypeToStreamType(OBSensorType type) {
return ob_sensor_type_to_stream_type(type);
}
/**
* @brief Check if the given sensor type is a video sensor.
* @brief Video sensors are sensors that produce video frames.
* @brief The following sensor types are considered video sensors:
* OB_SENSOR_COLOR,
* OB_SENSOR_DEPTH,
* OB_SENSOR_IR,
* OB_SENSOR_IR_LEFT,
* OB_SENSOR_IR_RIGHT,
* OB_SENSOR_CONFIDENCE,
*
* @param type The sensor type
* @return true
* @return false
*/
static bool isVideoSensorType(OBSensorType type) {
return ob_is_video_sensor_type(type);
}
/**
* @brief Check if the given stream type is a video stream.
* @brief Video streams are streams that contain video frames.
* @brief The following stream types are considered video streams:
* OB_STREAM_VIDEO,
* OB_STREAM_DEPTH,
* OB_STREAM_COLOR,
* OB_STREAM_IR,
* OB_STREAM_IR_LEFT,
* OB_STREAM_IR_RIGHT,
* OB_STREAM_CONFIDENCE,
*
* @param type The stream type to check.
* @return true if the given stream type is a video stream, false otherwise.
*/
static bool isVideoStreamType(OBStreamType type) {
return ob_is_video_stream_type(type);
}
};
} // namespace ob

View File

@@ -0,0 +1,5 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
#pragma once
#include <libobsensor/h/ObTypes.h>

View File

@@ -0,0 +1,190 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Utils.hpp
* @brief The SDK utils class
*
*/
#pragma once
#include "libobsensor/h/Utils.h"
#include "Device.hpp"
#include "Types.hpp"
#include "Frame.hpp"
#include <memory>
namespace ob {
class Device;
class CoordinateTransformHelper {
public:
/**
* @brief Transform a 3d point of a source coordinate system into a 3d point of the target coordinate system.
*
* @param[in] source_point3f Source 3d point value
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point3f Target 3d point value
*
* @return bool Transform result
*/
static bool transformation3dto3d(const OBPoint3f source_point3f, OBExtrinsic extrinsic, OBPoint3f *target_point3f) {
ob_error *error = NULL;
bool result = ob_transformation_3d_to_3d(source_point3f, extrinsic, target_point3f, &error);
Error::handle(&error);
return result;
}
/**
* @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 3d point of the target coordinate system.
*
* @param[in] source_intrinsic Source intrinsic parameters
* @param[in] source_point2f Source 2d point value
* @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point3f Target 3d point value
*
* @return bool Transform result
*/
static bool transformation2dto3d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic,
OBExtrinsic extrinsic, OBPoint3f *target_point3f) {
ob_error *error = NULL;
bool result = ob_transformation_2d_to_3d(source_point2f, source_depth_pixel_value, source_intrinsic, extrinsic, target_point3f, &error);
Error::handle(&error);
return result;
}
/**
* @brief Transform a 3d point of a source coordinate system into a 2d pixel coordinate of the target camera.
*
* @param[in] source_point3f Source 3d point value
* @param[in] target_intrinsic Target intrinsic parameters
* @param[in] target_distortion Target distortion parameters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point2f Target 2d point value
*
* @return bool Transform result
*/
static bool transformation3dto2d(const OBPoint3f source_point3f, const OBCameraIntrinsic target_intrinsic, const OBCameraDistortion target_distortion,
OBExtrinsic extrinsic, OBPoint2f *target_point2f) {
ob_error *error = NULL;
bool result = ob_transformation_3d_to_2d(source_point3f, target_intrinsic, target_distortion, extrinsic, target_point2f, &error);
Error::handle(&error);
return result;
}
/**
* @brief Transform a 2d pixel coordinate with an associated depth value of the source camera into a 2d pixel coordinate of the target camera
*
* @param[in] source_intrinsic Source intrinsic parameters
* @param[in] source_distortion Source distortion parameters
* @param[in] source_point2f Source 2d point value
* @param[in] source_depth_pixel_value The depth of sourcePoint2f in millimeters
* @param[in] target_intrinsic Target intrinsic parameters
* @param[in] target_distortion Target distortion parameters
* @param[in] extrinsic Transformation matrix from source to target
* @param[out] target_point2f Target 2d point value
*
* @return bool Transform result
*/
static bool transformation2dto2d(const OBPoint2f source_point2f, const float source_depth_pixel_value, const OBCameraIntrinsic source_intrinsic,
const OBCameraDistortion source_distortion, const OBCameraIntrinsic target_intrinsic,
const OBCameraDistortion target_distortion, OBExtrinsic extrinsic, OBPoint2f *target_point2f) {
ob_error *error = NULL;
bool result = ob_transformation_2d_to_2d(source_point2f, source_depth_pixel_value, source_intrinsic, source_distortion, target_intrinsic,
target_distortion, extrinsic, target_point2f, &error);
Error::handle(&error);
return result;
}
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
const OBSensorType targetSensorType, OBPoint3f *targetPoint3f) {
ob_error *error = NULL;
bool result = ob_calibration_3d_to_3d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint3f, &error);
Error::handle(&error);
return result;
}
static bool calibration2dTo3d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint3f *targetPoint3f) {
ob_error *error = NULL;
bool result =
ob_calibration_2d_to_3d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint3f, &error);
Error::handle(&error);
return result;
}
static bool calibration3dTo2d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
const OBSensorType targetSensorType, OBPoint2f *targetPoint2f) {
ob_error *error = NULL;
bool result = ob_calibration_3d_to_2d(calibrationParam, sourcePoint3f, sourceSensorType, targetSensorType, targetPoint2f, &error);
Error::handle(&error);
return result;
}
static bool calibration2dTo2d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
const OBSensorType sourceSensorType, const OBSensorType targetSensorType, OBPoint2f *targetPoint2f) {
ob_error *error = NULL;
bool result =
ob_calibration_2d_to_2d(calibrationParam, sourcePoint2f, sourceDepthPixelValue, sourceSensorType, targetSensorType, targetPoint2f, &error);
Error::handle(&error);
return result;
}
static std::shared_ptr<ob::Frame> transformationDepthFrameToColorCamera(std::shared_ptr<ob::Device> device, std::shared_ptr<ob::Frame> depthFrame,
uint32_t targetColorCameraWidth, uint32_t targetColorCameraHeight) {
ob_error *error = NULL;
// unsafe operation, need to cast const to non-const
auto unConstImpl = const_cast<ob_frame *>(depthFrame->getImpl());
auto result = transformation_depth_frame_to_color_camera(device->getImpl(), unConstImpl, targetColorCameraWidth, targetColorCameraHeight, &error);
Error::handle(&error);
return std::make_shared<ob::Frame>(result);
}
static bool transformationInitXYTables(const OBCalibrationParam calibrationParam, const OBSensorType sensorType, float *data, uint32_t *dataSize,
OBXYTables *xyTables) {
ob_error *error = NULL;
bool result = transformation_init_xy_tables(calibrationParam, sensorType, data, dataSize, xyTables, &error);
Error::handle(&error);
return result;
}
static void transformationDepthToPointCloud(OBXYTables *xyTables, const void *depthImageData, void *pointCloudData) {
ob_error *error = NULL;
transformation_depth_to_pointcloud(xyTables, depthImageData, pointCloudData, &error);
Error::handle(&error, false);
}
static void transformationDepthToRGBDPointCloud(OBXYTables *xyTables, const void *depthImageData, const void *colorImageData, void *pointCloudData) {
ob_error *error = NULL;
transformation_depth_to_rgbd_pointcloud(xyTables, depthImageData, colorImageData, pointCloudData, &error);
Error::handle(&error, false);
}
};
class PointCloudHelper {
public:
/**
* @brief save point cloud to ply file.
*
* @param[in] fileName Point cloud save path
* @param[in] frame Point cloud frame
* @param[in] saveBinary Binary or textual,true: binary, false: textual
* @param[in] useMesh Save mesh or not, true: save as mesh, false: not save as mesh
* @param[in] meshThreshold Distance threshold for creating faces in point cloud,default value :50
*
* @return bool save point cloud result
*/
static bool savePointcloudToPly(const char *fileName, std::shared_ptr<ob::Frame> frame, bool saveBinary, bool useMesh, float meshThreshold) {
ob_error *error = NULL;
auto unConstImpl = const_cast<ob_frame *>(frame->getImpl());
bool result = ob_save_pointcloud_to_ply(fileName, unConstImpl, saveBinary, useMesh, meshThreshold, &error);
Error::handle(&error, false);
return result;
}
};
} // namespace ob

View File

@@ -0,0 +1,62 @@
// Copyright (c) Orbbec Inc. All Rights Reserved.
// Licensed under the MIT License.
/**
* @file Version.hpp
* @brief Provides functions to retrieve version information of the SDK.
*/
#pragma once
#include "libobsensor/h/Version.h"
namespace ob {
class Version {
public:
/**
* @brief Get the full version number of the SDK.
* @brief The full version number equals to: major * 10000 + minor * 100 + patch
*
* @return int The full version number of the SDK.
*/
static int getVersion() {
return ob_get_version();
}
/**
* @brief Get the major version number of the SDK.
*
* @return int The major version number of the SDK.
*/
static int getMajor() {
return ob_get_major_version();
}
/**
* @brief Get the minor version number of the SDK.
*
* @return int The minor version number of the SDK.
*/
static int getMinor() {
return ob_get_minor_version();
}
/**
* @brief Get the patch version number of the SDK.
*
* @return int The patch version number of the SDK.
*/
static int getPatch() {
return ob_get_patch_version();
}
/**
* @brief Get the stage version of the SDK.
* @brief The stage version string is a vendor defined string for some special releases.
*
* @return char* The stage version string of the SDK.
*/
static const char *getStageVersion() {
return ob_get_stage_version();
}
};
} // namespace ob