Add extension path

This commit is contained in:
Joe Dong
2024-09-12 19:29:53 +08:00
parent 648739e76d
commit 0de45c0caa
30 changed files with 1413 additions and 1402 deletions
@@ -19,7 +19,7 @@ OB_EXPORT ob_depth_work_mode ob_device_get_current_depth_work_mode(const ob_devi
* @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);
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.
@@ -151,7 +151,8 @@ OB_EXPORT void ob_device_export_current_settings_as_preset_json_file(ob_device *
* @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);
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.
@@ -199,10 +200,7 @@ OB_EXPORT const char *ob_device_preset_list_get_name(const ob_device_preset_list
*/
OB_EXPORT bool ob_device_preset_list_has_preset(const ob_device_preset_list *preset_list, const char *preset_name, ob_error **error);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
// 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
@@ -86,10 +86,10 @@ OB_EXPORT void ob_set_device_changed_callback(ob_context *context, ob_device_cha
* @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] repeatInterval The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
* @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 repeatInterval, ob_error **error);
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
@@ -138,9 +138,17 @@ OB_EXPORT void ob_set_logger_to_callback(ob_log_severity severity, ob_log_callba
OB_EXPORT void ob_set_logger_to_console(ob_log_severity severity, ob_error **error);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
* @brief Set the extensions directory
* @brief The extensions directory is used to search for dynamic libraries that provide additional functionality to the SDK such as the Frame filters.
*
* @attention Should be called before creating the context and pipeline, otherwise the default extensions directory (./extensions) will be used.
*
* @param directory Path to the extensions directory. If the path is empty, the existing settings will continue to be used (if the existing
* @param 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
@@ -152,6 +152,17 @@ OB_EXPORT void ob_device_set_structured_data(ob_device *device, ob_property_id p
*/
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 Get the number of properties supported by the device.
*
@@ -540,9 +551,10 @@ OB_EXPORT ob_device *ob_device_list_get_device_by_serial_number(const ob_device_
/**
* @brief Create device by uid
* @brief On Linux platform, 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 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 devicethe 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.
*
@@ -594,11 +606,7 @@ OB_EXPORT ob_camera_param ob_camera_param_list_get_param(ob_camera_param_list *p
*/
OB_EXPORT void ob_delete_camera_param_list(ob_camera_param_list *param_list, ob_error **error);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
// 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
@@ -69,10 +69,7 @@ OB_EXPORT ob_exception_type ob_error_get_exception_type(const ob_error *error);
*/
OB_EXPORT void ob_delete_error(ob_error *error);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
// 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
@@ -7,7 +7,7 @@
# define OB_NO_EXPORT
#else
# ifndef OB_EXPORT
# ifdef openobsdk_EXPORTS
# ifdef OrbbecSDK_EXPORTS
/* We are building this library */
# define OB_EXPORT __attribute__((visibility("default")))
# else
@@ -75,12 +75,22 @@ OB_EXPORT const char *ob_filter_get_config_schema(const ob_filter *filter, ob_er
* @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
*
@@ -231,10 +241,8 @@ OB_EXPORT uint32_t ob_filter_config_schema_list_get_count(const ob_filter_config
*/
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);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
// 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
@@ -600,10 +600,7 @@ OB_EXPORT ob_frame *ob_frameset_get_frame_by_index(const ob_frame *frameset, uin
*/
OB_EXPORT void ob_frameset_push_frame(ob_frame *frameset, const ob_frame *frame, ob_error **error);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
// 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
@@ -1241,7 +1241,7 @@ typedef struct {
/**
* @brief The sync mode of the device.
*/
ob_multi_device_sync_mode syncMode;
OBMultiDeviceSyncMode syncMode;
/**
* @brief The delay time of the depth image capture after receiving the capture command or trigger signal in microseconds.
@@ -1,9 +1,8 @@
/**
* @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.
* @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
@@ -53,14 +52,12 @@ OB_EXPORT void ob_pipeline_start(ob_pipeline *pipeline, ob_error **error);
* @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);
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
* @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
@@ -69,8 +66,7 @@ OB_EXPORT void ob_pipeline_start_with_config(ob_pipeline *pipeline, const ob_con
* @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_EXPORT void ob_pipeline_start_with_callback(ob_pipeline *pipeline, const ob_config *config, ob_frameset_callback callback, void *user_data,
ob_error **error);
/**
@@ -98,8 +94,7 @@ OB_EXPORT ob_config *ob_pipeline_get_config(const ob_pipeline *pipeline, ob_erro
* @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);
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
@@ -107,11 +102,9 @@ OB_EXPORT void ob_pipeline_switch_config(ob_pipeline *pipeline, ob_config *confi
* @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.
* @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);
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
@@ -126,19 +119,15 @@ OB_EXPORT ob_device *ob_pipeline_get_device(const ob_pipeline *pipeline, ob_erro
* @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[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);
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 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
@@ -155,8 +144,7 @@ OB_EXPORT void ob_pipeline_enable_frame_sync(ob_pipeline *pipeline, ob_error **e
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
* @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
@@ -164,9 +152,8 @@ OB_EXPORT void ob_pipeline_disable_frame_sync(ob_pipeline *pipeline, ob_error **
* @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);
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
@@ -191,8 +178,7 @@ OB_EXPORT void ob_delete_config(ob_config *config, ob_error **error);
* @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);
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
@@ -209,15 +195,12 @@ OB_EXPORT void ob_config_enable_all_stream(ob_config *config, ob_error **error);
* @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);
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.
* @attention The stream_type should be a video stream type, such as OB_STREAM_IR, OB_STREAM_COLOR, OB_STREAM_DEPTH, etc.
*
* @param config[in] The pipeline configuration object
* @param stream_type[in] The type of the stream to be enabled
@@ -227,9 +210,8 @@ OB_EXPORT void ob_config_enable_stream_with_stream_profile(ob_config *config,
* @param format[in] The format of the video stream
* @param error[out] 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);
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
@@ -239,9 +221,7 @@ OB_EXPORT void ob_config_enable_video_stream(ob_config *config, ob_stream_type s
* @param sample_rate[in] The sample rate of the accelerometer
* @param error[out] 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);
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
@@ -251,20 +231,16 @@ OB_EXPORT void ob_config_enable_accel_stream(ob_config *config,
* @param sample_rate[in] The sample rate of the gyroscope
* @param error[out] 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);
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
* @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);
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
@@ -294,35 +270,28 @@ OB_EXPORT void ob_config_set_align_mode(ob_config *config, ob_align_mode mode, o
/**
* @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.
* @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);
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.
* @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[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);
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
* @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
@@ -341,9 +310,8 @@ OB_EXPORT ob_camera_param ob_pipeline_get_camera_param(ob_pipeline *pipeline, ob
* @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);
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
@@ -353,14 +321,9 @@ OB_EXPORT ob_camera_param ob_pipeline_get_camera_param_with_profile(
* @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);
OB_EXPORT ob_calibration_param ob_pipeline_get_calibration_param(ob_pipeline *pipeline, ob_config *config, ob_error **error);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
// 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
@@ -440,6 +440,13 @@ typedef enum {
*/
OB_PROP_DISP_SEARCH_RANGE_MODE_INT = 191,
/**
* @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 Baseline calibration parameters
*/
@@ -65,14 +65,14 @@ OB_EXPORT void ob_sensor_switch_profile(ob_sensor *sensor, ob_stream_profile *pr
OB_EXPORT void ob_delete_sensor(ob_sensor *sensor, ob_error **error);
/**
* @brief Request the list of recommended filter list.
* @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_get_recommended_filter_list(const ob_sensor *sensor, ob_error **error);
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.
@@ -122,6 +122,7 @@ OB_EXPORT ob_sensor *ob_sensor_list_get_sensor(const ob_sensor_list *sensor_list
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
}
@@ -387,10 +387,7 @@ OB_EXPORT ob_stream_profile *ob_stream_profile_list_get_gyro_stream_profile(cons
*/
OB_EXPORT void ob_delete_stream_profile_list(const ob_stream_profile_list *profile_list, ob_error **error);
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
// 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
@@ -75,14 +75,14 @@ OB_EXPORT ob_frame *transformation_depth_frame_to_color_camera(ob_device *device
uint32_t target_color_camera_height, ob_error **error);
// \deprecated This function is deprecated and will be removed in a future version.
bool transformation_init_xy_tables(const ob_calibration_param calibration_param, const ob_sensor_type sensor_type, float *data, uint32_t *data_size,
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.
void transformation_depth_to_pointcloud(ob_xy_tables *xy_tables, const void *depth_image_data, void *pointcloud_data, ob_error **error);
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.
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_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.
@@ -125,9 +125,9 @@ public:
*
* @param repeatInterval The interval for auto-repeated synchronization, in milliseconds. If the value is 0, synchronization is performed only once.
*/
void enableDeviceClockSync(uint64_t repeatInterval) const {
void enableDeviceClockSync(uint64_t repeatIntervalMsec) const {
ob_error *error = nullptr;
ob_enable_device_clock_sync(impl_, repeatInterval, &error);
ob_enable_device_clock_sync(impl_, repeatIntervalMsec, &error);
Error::handle(&error);
}
@@ -189,6 +189,20 @@ public:
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);
@@ -1112,9 +1112,10 @@ public:
/**
* @brief Get the specified device object from the device list by uid
* @brief On Linux platform, 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 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 devicethe uid is GMSL port with “gmsl2-” prefix, for example gmsl2-1.
*
* @attention If the device has been acquired and created elsewhere, repeated acquisition will throw an exception
*
@@ -1324,4 +1325,4 @@ public:
}
};
} // namespace ob
} // namespace ob
@@ -101,13 +101,9 @@ public:
return impl_->message;
}
/**
* @brief (Deprecated) Returns the name of the function where the exception occurred.
* @brief Use the getFunction() function instead.
*
* @return const char* The function name.
*/
OB_DEPRECATED const char *getName() const noexcept {
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
const char *getName() const noexcept {
return impl_->function;
}
};
File diff suppressed because it is too large Load Diff
@@ -345,8 +345,9 @@ public:
return getIndex();
}
virtual uint8_t *data() const {
return getData();
virtual void *data() const {
auto data = getData();
return reinterpret_cast<void *>(data);
}
virtual uint32_t dataSize() const {
@@ -1,7 +1,7 @@
/**
* @file Pipeline.hpp
* @brief The SDK's advanced API type can quickly implement switching streaming and frame
* synchronization operations.
* @brief The SDK's advanced API type can quickly implement switching streaming and frame synchronization
* operations.
*/
#pragma once
@@ -23,446 +23,426 @@ namespace ob {
* The Config class provides an interface for configuring pipeline parameters.
*/
class Config {
private:
ob_config_t *impl_;
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);
}
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) {}
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);
}
/**
* @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_; }
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 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 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 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 type 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.
*
* 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 type 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 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 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);
}
/**
* @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);
}
/**
* @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 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
*/
void disableStream(OBSensorType sensorType) const {
auto streamType = ob::TypeHelper::convertSensorTypeToStreamType(sensorType);
disableStream(streamType);
}
/**
* @brief Disable a sensor stream to be used in the pipeline.
* @brief Will convert sensor type to stream type automatically.
*
* @param sensorType
*/
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 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 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 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 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);
}
/**
* @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;
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_;
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 timeout_ms 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;
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);
}
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
* 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 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 Destroy the pipeline object
*/
~Pipeline() noexcept {
ob_error *error = nullptr;
ob_delete_pipeline(impl_, &error);
Error::handle(&error, false);
}
/**
* @brief Turn on frame synchronization
*/
void enableFrameSync() const {
ob_error *error = nullptr;
ob_pipeline_enable_frame_sync(impl_, &error);
Error::handle(&error);
}
/**
* @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 Turn off frame synchronization
*/
void disableFrameSync() const {
ob_error *error = nullptr;
ob_pipeline_disable_frame_sync(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);
}
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);
}
static void frameSetCallback(ob_frame_t *frameSet, void *userData) {
auto pipeline = static_cast<Pipeline *>(userData);
pipeline->callback_(std::make_shared<FrameSet>(frameSet));
}
OBCameraParam getCameraParam() {
ob_error *error = nullptr;
OBCameraParam cameraParam = ob_pipeline_get_camera_param(impl_, &error);
Error::handle(&error);
return cameraParam;
}
/**
* @brief Stop the pipeline
*/
void stop() const {
ob_error *error = nullptr;
ob_pipeline_stop(impl_, &error);
Error::handle(&error);
}
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;
}
/**
* @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);
}
OBCalibrationParam getCalibrationParam(std::shared_ptr<Config> config) {
std::cout << "getCalibrationParam" << std::endl;
/**
* @brief Wait for frameset
*
* @param timeout_ms 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);
}
ob_error *error = nullptr;
OBCalibrationParam calibrationParam =
ob_pipeline_get_calibration_param(impl_, config->getImpl(), &error);
/**
* @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);
}
Error::handle(&error);
return calibrationParam;
}
/**
* @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);
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED std::shared_ptr<FrameSet> waitForFrames(uint32_t timeoutMs = 1000) const {
return waitForFrameset(timeoutMs);
}
/**
* @brief Get the stream profile list of supported depth-to-color alignments
*
* @param colorProfile The color stream profile, witch 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
@@ -28,7 +28,7 @@ public:
typedef std::function<void(std::shared_ptr<Frame> frame)> FrameCallback;
protected:
ob_sensor_t * impl_;
ob_sensor_t *impl_;
FrameCallback callback_;
public:
@@ -49,7 +49,7 @@ public:
return *this;
}
Sensor(const Sensor &sensor) = delete;
Sensor(const Sensor &sensor) = delete;
Sensor &operator=(const Sensor &sensor) = delete;
virtual ~Sensor() noexcept {
@@ -83,12 +83,13 @@ public:
}
/**
* @brief Request recommended filters
* @brief Create a list of recommended filters for the sensor.
*
* @return OBFilterList list of frame processing block
*/
std::vector<std::shared_ptr<Filter>> getRecommendedFilters() const {
std::vector<std::shared_ptr<Filter>> createRecommendedFilters() const {
ob_error *error = nullptr;
auto list = ob_sensor_get_recommended_filter_list(impl_, &error);
auto list = ob_sensor_create_recommended_filter_list(impl_, &error);
Error::handle(&error);
auto filter_count = ob_filter_list_get_count(list, &error);
@@ -98,6 +99,8 @@ public:
Error::handle(&error);
filters.push_back(std::make_shared<Filter>(filterImpl));
}
ob_delete_filter_list(list, &error);
Error::handle(&error, false);
return filters;
}
@@ -140,13 +143,15 @@ private:
sensor->callback_(std::make_shared<Frame>(frame));
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED OBSensorType type() const {
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 {
@@ -213,15 +218,13 @@ public:
return std::make_shared<Sensor>(sensor);
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED uint32_t count() const {
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t count() const {
return getCount();
}
OB_DEPRECATED OBSensorType type(uint32_t index) const {
OBSensorType type(uint32_t index) const {
return getSensorType(index);
}
};
@@ -120,15 +120,13 @@ public:
return std::static_pointer_cast<const T>(shared_from_this());
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED OBFormat format() const {
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBFormat format() const {
return getFormat();
}
OB_DEPRECATED OBStreamType type() const {
OBStreamType type() const {
return getType();
}
};
@@ -203,19 +201,17 @@ public:
return distortion;
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED uint32_t fps() const {
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t fps() const {
return getFps();
}
OB_DEPRECATED uint32_t width() const {
uint32_t width() const {
return getWidth();
}
OB_DEPRECATED uint32_t height() const {
uint32_t height() const {
return getHeight();
}
};
@@ -265,11 +261,13 @@ public:
return intrinsic;
}
OB_DEPRECATED OBAccelFullScaleRange fullScaleRange() const{
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBAccelFullScaleRange fullScaleRange() const {
return getFullScaleRange();
}
OB_DEPRECATED OBAccelSampleRate sampleRate() const{
OBAccelSampleRate sampleRate() const {
return getSampleRate();
}
};
@@ -319,11 +317,13 @@ public:
return intrinsic;
}
OB_DEPRECATED OBGyroFullScaleRange fullScaleRange() const{
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
OBGyroFullScaleRange fullScaleRange() const {
return getFullScaleRange();
}
OB_DEPRECATED OBGyroSampleRate sampleRate() const{
OBGyroSampleRate sampleRate() const {
return getSampleRate();
}
};
@@ -431,11 +431,9 @@ public:
return std::make_shared<GyroStreamProfile>(profile);
}
/**
* In order to be compatible with the closed source version of orbbecsdk's interface.
* We recommend using the latest interface names for a better experience.
*/
OB_DEPRECATED uint32_t count() const {
public:
// The following interfaces are deprecated and are retained here for compatibility purposes.
uint32_t count() const {
return getCount();
}
};
@@ -31,7 +31,7 @@ public:
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.
*
@@ -43,13 +43,13 @@ public:
*
* @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) {
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.
@@ -84,12 +84,12 @@ public:
*
* @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) {
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);
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;
}
@@ -112,7 +112,7 @@ public:
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);
Error::handle(&error);
return std::make_shared<ob::Frame>(result);
}
@@ -161,23 +161,21 @@ public:
*/
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);
transformation_depth_to_rgbd_pointcloud(xyTables, depthImageData, colorImageData, pointCloudData, &error);
Error::handle(&error, false);
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation3dto3d instead.
OB_DEPRECATED static bool calibration3dTo3d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
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;
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation2dto3d instead.
OB_DEPRECATED static bool calibration2dTo3d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
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);
@@ -185,18 +183,15 @@ public:
return result;
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation3dto2d instead.
OB_DEPRECATED static bool calibration3dTo2d(const OBCalibrationParam calibrationParam, const OBPoint3f sourcePoint3f, const OBSensorType sourceSensorType,
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;
}
// \deprecated This function is deprecated and will be removed in a future version.
// Use the transformation2dto2d instead.
OB_DEPRECATED static bool calibration2dTo2d(const OBCalibrationParam calibrationParam, const OBPoint2f sourcePoint2f, const float sourceDepthPixelValue,
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);
@@ -12,8 +12,8 @@ set_target_properties(ob::OrbbecSDK PROPERTIES
IMPORTED_SONAME_RELEASE "libOrbbecSDK.so"
)
list(APPEND _IMPORT_CHECK_TARGETS ob::OrbbecSDK )
list(APPEND _IMPORT_CHECK_FILES_FOR_ob::OrbbecSDK "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so" )
list(APPEND _cmake_import_check_targets ob::OrbbecSDK )
list(APPEND _cmake_import_check_files_for_ob::OrbbecSDK "${_IMPORT_PREFIX}/lib/libOrbbecSDK.so" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
+48 -36
View File
@@ -1,10 +1,13 @@
# Generated by CMake
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
message(FATAL_ERROR "CMake >= 2.6.0 required")
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
message(FATAL_ERROR "CMake >= 2.8.0 required")
endif()
if(CMAKE_VERSION VERSION_LESS "2.8.3")
message(FATAL_ERROR "CMake >= 2.8.3 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6)
cmake_policy(VERSION 2.8.3...3.28)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
@@ -13,32 +16,34 @@ cmake_policy(VERSION 2.6)
set(CMAKE_IMPORT_FILE_VERSION 1)
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget ob::OrbbecSDK)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
endif()
if(TARGET ${_expectedTarget})
list(APPEND _targetsDefined ${_expectedTarget})
set(_cmake_targets_defined "")
set(_cmake_targets_not_defined "")
set(_cmake_expected_targets "")
foreach(_cmake_expected_target IN ITEMS ob::OrbbecSDK)
list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
if(TARGET "${_cmake_expected_target}")
list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
else()
list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
set(CMAKE_IMPORT_FILE_VERSION)
unset(_cmake_expected_target)
if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
unset(_cmake_targets_defined)
unset(_cmake_targets_not_defined)
unset(_cmake_expected_targets)
unset(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
if(NOT _cmake_targets_defined STREQUAL "")
string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
unset(_cmake_targets_defined)
unset(_cmake_targets_not_defined)
unset(_cmake_expected_targets)
# Compute the installation prefix relative to this file.
@@ -56,21 +61,25 @@ set_target_properties(ob::OrbbecSDK PROPERTIES
)
# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/OrbbecSDKConfig-*.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/OrbbecSDKConfig-*.cmake")
foreach(_cmake_config_file IN LISTS _cmake_config_files)
include("${_cmake_config_file}")
endforeach()
unset(_cmake_config_file)
unset(_cmake_config_files)
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
if(NOT EXISTS "${file}" )
message(FATAL_ERROR "The imported target \"${target}\" references the file
\"${file}\"
foreach(_cmake_target IN LISTS _cmake_import_check_targets)
if(CMAKE_VERSION VERSION_LESS "3.28"
OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target}
OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}")
foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
if(NOT EXISTS "${_cmake_file}")
message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
\"${_cmake_file}\"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
@@ -78,11 +87,14 @@ but this file does not exist. Possible reasons include:
\"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
endif()
endforeach()
unset(_IMPORT_CHECK_FILES_FOR_${target})
endif()
endforeach()
endif()
unset(_cmake_file)
unset("_cmake_import_check_files_for_${_cmake_target}")
endforeach()
unset(_IMPORT_CHECK_TARGETS)
unset(_cmake_target)
unset(_cmake_import_check_targets)
# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.
Binary file not shown.
@@ -104,5 +104,6 @@ class OBCameraNodeDriver : public rclcpp::Node {
bool enable_sync_host_time_ = true;
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr reboot_device_srv_ = nullptr;
std::chrono::time_point<std::chrono::system_clock> start_time_;
std::string extension_path_;
};
} // namespace orbbec_camera
+38 -31
View File
@@ -19,6 +19,7 @@
#include <semaphore.h>
#include <sys/shm.h>
#include <ament_index_cpp/get_package_share_directory.hpp>
#include <ament_index_cpp/get_package_prefix.hpp>
#include <rclcpp_components/register_node_macro.hpp>
#include <csignal>
#include <sys/mman.h>
@@ -37,7 +38,7 @@ void signalHandler(int sig) {
// get current time
std::time_t now = std::time(nullptr);
std::tm *local_time = std::localtime(&now);
std::tm* local_time = std::localtime(&now);
// format date and time to string, format as "2024_05_20_12_34_56"
std::ostringstream time_stream;
@@ -68,20 +69,24 @@ void signalHandler(int sig) {
}
namespace orbbec_camera {
OBCameraNodeDriver::OBCameraNodeDriver(const rclcpp::NodeOptions &node_options)
OBCameraNodeDriver::OBCameraNodeDriver(const rclcpp::NodeOptions& node_options)
: Node("orbbec_camera_node", "/", node_options),
config_path_(ament_index_cpp::get_package_share_directory("orbbec_camera") +
"/config/OrbbecSDKConfig_v1.0.xml"),
ctx_(std::make_unique<ob::Context>(config_path_.c_str())),
logger_(this->get_logger()) {
logger_(this->get_logger()),
extension_path_(ament_index_cpp::get_package_prefix("orbbec_camera") +
"/lib/extensions") {
init();
}
OBCameraNodeDriver::OBCameraNodeDriver(const std::string &node_name, const std::string &ns,
const rclcpp::NodeOptions &node_options)
OBCameraNodeDriver::OBCameraNodeDriver(const std::string& node_name, const std::string& ns,
const rclcpp::NodeOptions& node_options)
: Node(node_name, ns, node_options),
ctx_(std::make_unique<ob::Context>()),
logger_(this->get_logger()) {
config_path_(ament_index_cpp::get_package_share_directory("orbbec_camera") +
"/config/OrbbecSDKConfig_v1.0.xml"),
logger_(this->get_logger()),
extension_path_(ament_index_cpp::get_package_prefix("orbbec_camera") +
"/lib/extensions") {
init();
}
@@ -104,6 +109,8 @@ void OBCameraNodeDriver::init() {
signal(SIGABRT, signalHandler); // abort
signal(SIGFPE, signalHandler); // float point exception
signal(SIGILL, signalHandler); // illegal instruction
ob::Context::setExtensionsDirectory(extension_path_.c_str());
ctx_ = std::make_unique<ob::Context>(config_path_.c_str());
auto log_level_str = declare_parameter<std::string>("log_level", "none");
auto log_level = obLogSeverityFromString(log_level_str);
connection_delay_ = static_cast<int>(declare_parameter<int>("connection_delay", 100));
@@ -121,8 +128,8 @@ void OBCameraNodeDriver::init() {
return;
}
orb_device_lock_shm_addr_ =
static_cast<uint8_t *>(mmap(NULL, sizeof(pthread_mutex_t), PROT_READ | PROT_WRITE, MAP_SHARED,
orb_device_lock_shm_fd_, 0));
static_cast<uint8_t*>(mmap(NULL, sizeof(pthread_mutex_t), PROT_READ | PROT_WRITE, MAP_SHARED,
orb_device_lock_shm_fd_, 0));
if (orb_device_lock_shm_addr_ == MAP_FAILED) {
RCLCPP_ERROR_STREAM(logger_, "Failed to map shared memory " << ORB_DEFAULT_LOCK_NAME);
return;
@@ -132,7 +139,7 @@ void OBCameraNodeDriver::init() {
std::placeholders::_1, std::placeholders::_2));
pthread_mutexattr_init(&orb_device_lock_attr_);
pthread_mutexattr_setpshared(&orb_device_lock_attr_, PTHREAD_PROCESS_SHARED);
orb_device_lock_ = (pthread_mutex_t *)orb_device_lock_shm_addr_;
orb_device_lock_ = (pthread_mutex_t*)orb_device_lock_shm_addr_;
pthread_mutex_init(orb_device_lock_, &orb_device_lock_attr_);
is_alive_.store(true);
parameters_ = std::make_shared<Parameters>(this);
@@ -143,8 +150,8 @@ void OBCameraNodeDriver::init() {
net_device_port_ = static_cast<int>(declare_parameter<int>("net_device_port", 0));
enumerate_net_device_ = declare_parameter<bool>("enumerate_net_device", false);
ctx_->enableNetDeviceEnumeration(enumerate_net_device_);
ctx_->setDeviceChangedCallback([this](const std::shared_ptr<ob::DeviceList> &removed_list,
const std::shared_ptr<ob::DeviceList> &added_list) {
ctx_->setDeviceChangedCallback([this](const std::shared_ptr<ob::DeviceList>& removed_list,
const std::shared_ptr<ob::DeviceList>& added_list) {
onDeviceConnected(added_list);
onDeviceDisconnected(removed_list);
});
@@ -155,7 +162,7 @@ void OBCameraNodeDriver::init() {
reset_device_thread_ = std::make_shared<std::thread>([this]() { resetDevice(); });
}
void OBCameraNodeDriver::onDeviceConnected(const std::shared_ptr<ob::DeviceList> &device_list) {
void OBCameraNodeDriver::onDeviceConnected(const std::shared_ptr<ob::DeviceList>& device_list) {
CHECK_NOTNULL(device_list);
if (device_list->getCount() == 0) {
return;
@@ -165,7 +172,7 @@ void OBCameraNodeDriver::onDeviceConnected(const std::shared_ptr<ob::DeviceList>
}
}
void OBCameraNodeDriver::onDeviceDisconnected(const std::shared_ptr<ob::DeviceList> &device_list) {
void OBCameraNodeDriver::onDeviceDisconnected(const std::shared_ptr<ob::DeviceList>& device_list) {
CHECK_NOTNULL(device_list);
if (device_list->getCount() == 0) {
return;
@@ -187,7 +194,7 @@ void OBCameraNodeDriver::onDeviceDisconnected(const std::shared_ptr<ob::DeviceLi
}
}
OBLogSeverity OBCameraNodeDriver::obLogSeverityFromString(const std::string_view &log_level) {
OBLogSeverity OBCameraNodeDriver::obLogSeverityFromString(const std::string_view& log_level) {
if (log_level == "debug") {
return OBLogSeverity::OB_LOG_SEVERITY_DEBUG;
} else if (log_level == "info") {
@@ -269,7 +276,7 @@ void OBCameraNodeDriver::rebootDeviceCallback(
}
std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDevice(
const std::shared_ptr<ob::DeviceList> &list) {
const std::shared_ptr<ob::DeviceList>& list) {
if (device_num_ == 1) {
RCLCPP_INFO_STREAM(logger_, "Connecting to the default device");
return list->getDevice(0);
@@ -293,7 +300,7 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDevice(
}
std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceBySerialNumber(
const std::shared_ptr<ob::DeviceList> &list, const std::string &serial_number) {
const std::shared_ptr<ob::DeviceList>& list, const std::string& serial_number) {
std::string lower_sn;
std::transform(serial_number.begin(), serial_number.end(), std::back_inserter(lower_sn),
[](auto ch) { return isalpha(ch) ? tolower(ch) : static_cast<int>(ch); });
@@ -320,10 +327,10 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceBySerialNumber(
return list->getDevice(i);
}
}
} catch (ob::Error &e) {
} catch (ob::Error& e) {
RCLCPP_ERROR_STREAM_THROTTLE(logger_, *get_clock(), 1000,
"Failed to get device info " << e.getMessage());
} catch (std::exception &e) {
} catch (std::exception& e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to get device info " << e.what());
} catch (...) {
RCLCPP_ERROR_STREAM(logger_, "Failed to get device info");
@@ -333,7 +340,7 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceBySerialNumber(
}
std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByUSBPort(
const std::shared_ptr<ob::DeviceList> &list, const std::string &usb_port) {
const std::shared_ptr<ob::DeviceList>& list, const std::string& usb_port) {
try {
RCLCPP_INFO_STREAM(logger_, "Before lock: Select device usb port: " << usb_port);
std::lock_guard<decltype(device_lock_)> lock(device_lock_);
@@ -341,9 +348,9 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByUSBPort(
auto device = list->getDeviceByUid(usb_port.c_str());
RCLCPP_INFO_STREAM(logger_, "Device usb port " << usb_port << " done");
return device;
} catch (ob::Error &e) {
} catch (ob::Error& e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to get device info " << e.getMessage());
} catch (std::exception &e) {
} catch (std::exception& e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to get device info " << e.what());
} catch (...) {
RCLCPP_ERROR_STREAM(logger_, "Failed to get device info");
@@ -352,7 +359,7 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByUSBPort(
return nullptr;
}
void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &device) {
void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device>& device) {
device_ = device;
CHECK_NOTNULL(device_);
CHECK_NOTNULL(device_.get());
@@ -367,7 +374,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
serial_number_ = device_info_->getSerialNumber();
CHECK_NOTNULL(device_info_.get());
device_unique_id_ = device_info_->getUid();
#if 0
#if 0
if (enable_sync_host_time_ && !isOpenNIDevice(device_info_->pid())) {
TRY_EXECUTE_BLOCK(device_->timerSyncWithHost());
sync_host_time_timer_ = this->create_wall_timer(std::chrono::milliseconds(30000), [this]() {
@@ -376,7 +383,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
}
});
}
#endif
#endif
RCLCPP_INFO_STREAM(logger_, "Device " << device_info_->getName() << " connected");
RCLCPP_INFO_STREAM(logger_, "Serial number: " << device_info_->getSerialNumber());
@@ -390,7 +397,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
RCLCPP_INFO_STREAM(logger_, "Start device cost " << time_cost.count() << " ms");
} // namespace orbbec_camera
void OBCameraNodeDriver::connectNetDevice(const std::string &net_device_ip, int net_device_port) {
void OBCameraNodeDriver::connectNetDevice(const std::string& net_device_ip, int net_device_port) {
if (net_device_ip.empty() || net_device_port == 0) {
RCLCPP_ERROR_STREAM(logger_, "Invalid net device ip or port");
return;
@@ -404,7 +411,7 @@ void OBCameraNodeDriver::connectNetDevice(const std::string &net_device_ip, int
initializeDevice(device);
}
void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list) {
void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList>& list) {
if (device_connected_) {
return;
}
@@ -419,7 +426,7 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list
std::this_thread::sleep_for(std::chrono::milliseconds(connection_delay_));
pthread_mutex_lock(orb_device_lock_);
std::shared_ptr<int> lock_holder(nullptr,
[this](int *) { pthread_mutex_unlock(orb_device_lock_); });
[this](int*) { pthread_mutex_unlock(orb_device_lock_); });
bool start_device_failed = false;
try {
auto start_time = std::chrono::high_resolution_clock::now();
@@ -438,10 +445,10 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list
end_time = std::chrono::high_resolution_clock::now();
time_cost = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
RCLCPP_INFO_STREAM(logger_, "Initialize device cost " << time_cost.count() << " ms");
} catch (ob::Error &e) {
} catch (ob::Error& e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device " << e.getMessage());
start_device_failed = true;
} catch (std::exception &e) {
} catch (std::exception& e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device " << e.what());
start_device_failed = true;
} catch (...) {