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
@@ -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 device,the 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);