mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-04 12:07:46 +08:00
update SDK
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "Types.hpp"
|
||||
|
||||
#include "libobsensor/h/Property.h"
|
||||
|
||||
#include "libobsensor/hpp/Filter.hpp"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -24,6 +24,7 @@ class DeviceInfo;
|
||||
class Sensor;
|
||||
class CameraParamList;
|
||||
class OBDepthWorkModeList;
|
||||
class DevicePresetList;
|
||||
|
||||
class OB_EXTENSION_API Device {
|
||||
protected:
|
||||
@@ -550,6 +551,48 @@ public:
|
||||
*/
|
||||
void resetDefaultDepthFilterConfig();
|
||||
|
||||
/**
|
||||
* @brief Get current preset name
|
||||
* @brief The preset mean a set of parameters or configurations that can be applied to the device to achieve a specific effect or function.
|
||||
* @return const char* return the current preset name, it should be one of the preset names returned by @ref getAvailablePresetList.
|
||||
*/
|
||||
const char *getCurrentPresetName();
|
||||
|
||||
/**
|
||||
* @brief load the preset according to the preset name.
|
||||
* @attention After loading the preset, the settings in the preset will set to the device immediately. Therefore, it is recommended to re-read the device
|
||||
* settings to update the user program temporarily.
|
||||
* @param presetName The preset name to set. The name should be one of the preset names returned by @ref getAvailablePresetList.
|
||||
*/
|
||||
void loadPreset(const char *presetName);
|
||||
|
||||
/**
|
||||
* @brief Get available preset list
|
||||
* @brief The available preset list usually defined by the device manufacturer and restores on the device.
|
||||
* @brief User can load the custom preset by calling @ref loadPresetFromJsonFile to append the available preset list.
|
||||
*
|
||||
* @return DevicePresetList return the available preset list.
|
||||
*/
|
||||
std::shared_ptr<DevicePresetList> getAvailablePresetList();
|
||||
|
||||
/**
|
||||
* @brief Load custom preset from file.
|
||||
* @brief After loading the custom preset, the settings in the custom preset will set to the device immediately.
|
||||
* @brief After loading the custom preset, the available preset list will be appended with the custom preset and named as the file name.
|
||||
*
|
||||
* @attention The user should ensure that the custom preset file is adapted to the device and the settings in the file are valid.
|
||||
* @attention It is recommended to re-read the device settings to update the user program temporarily after successfully loading the custom preset.
|
||||
*
|
||||
* @param filePath The path of the custom preset file.
|
||||
*/
|
||||
void loadPresetFromJsonFile(const char *filePath);
|
||||
|
||||
/**
|
||||
* @brief Export current device settings as a preset json file.
|
||||
* @brief The exported preset file can be loaded by calling @ref loadPresetFromJsonFile to restore the device setting.
|
||||
*/
|
||||
void exportSettingsAsPresetJsonFile(const char *filePath);
|
||||
|
||||
friend class Pipeline;
|
||||
friend class Recorder;
|
||||
friend class CoordinateTransformHelper;
|
||||
@@ -852,4 +895,39 @@ public:
|
||||
OBDepthWorkMode operator[](uint32_t index);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class representing a list of device presets
|
||||
* @breif A device preset is a set of parameters or configurations that can be applied to the device to achieve a specific effect or function.
|
||||
*/
|
||||
class OB_EXTENSION_API DevicePresetList {
|
||||
private:
|
||||
std::unique_ptr<DevicePresetListImpl> impl_;
|
||||
|
||||
public:
|
||||
DevicePresetList(std::unique_ptr<DevicePresetListImpl> impl);
|
||||
~DevicePresetList() noexcept;
|
||||
|
||||
/**
|
||||
* @brief Get the number of device presets in the list
|
||||
*
|
||||
* @return uint32_t the number of device presets in the list
|
||||
*/
|
||||
uint32_t count();
|
||||
|
||||
/**
|
||||
* @brief Get the name of the device preset at the specified index
|
||||
*
|
||||
* @param index the index of the device preset
|
||||
* @return const char* the name of the device preset
|
||||
*/
|
||||
const char *getName(uint32_t index);
|
||||
|
||||
/**
|
||||
* @breif check if the preset list contains the special name preset.
|
||||
* @param name The name of the preset
|
||||
* @return bool Returns true if the special name is found in the preset list, otherwise returns false.
|
||||
*/
|
||||
bool hasPreset(const char *name);
|
||||
};
|
||||
|
||||
} // namespace ob
|
||||
|
||||
@@ -9,9 +9,12 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace ob {
|
||||
class Frame;
|
||||
class OBFilterList;
|
||||
|
||||
/**
|
||||
* @brief A callback function that takes a shared pointer to a Frame object as its argument.
|
||||
@@ -21,10 +24,12 @@ typedef std::function<void(std::shared_ptr<Frame>)> FilterCallback;
|
||||
/**
|
||||
* @brief The Filter class is the base class for all filters in the SDK.
|
||||
*/
|
||||
class OB_EXTENSION_API Filter {
|
||||
class OB_EXTENSION_API Filter : public std::enable_shared_from_this<Filter> {
|
||||
public:
|
||||
Filter();
|
||||
|
||||
Filter(std::shared_ptr<FilterImpl> impl);
|
||||
|
||||
virtual ~Filter() = default;
|
||||
|
||||
/**
|
||||
@@ -33,6 +38,16 @@ public:
|
||||
*/
|
||||
virtual void reset();
|
||||
|
||||
/**
|
||||
* @brief enable the filter
|
||||
*/
|
||||
void enable(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Return Enable State
|
||||
*/
|
||||
bool isEnabled();
|
||||
|
||||
/**
|
||||
* @brief Processes a frame synchronously.
|
||||
*
|
||||
@@ -55,8 +70,40 @@ public:
|
||||
*/
|
||||
virtual void setCallBack(FilterCallback callback);
|
||||
|
||||
/**
|
||||
* @brief Get the type of filter.
|
||||
*
|
||||
* @return string The type of filte.
|
||||
*/
|
||||
virtual const char *type();
|
||||
|
||||
/**
|
||||
* @brief Check if the runtime type of the filter object is compatible with a given type.
|
||||
*
|
||||
* @tparam T The given type.
|
||||
* @return bool The result.
|
||||
*/
|
||||
template <typename T> bool is();
|
||||
|
||||
/**
|
||||
* @brief Convert the filter object to a target type.
|
||||
*
|
||||
* @tparam T The target type.
|
||||
* @return std::shared_ptr<T> The result. If it cannot be converted, an exception will be thrown.
|
||||
*/
|
||||
template <typename T> std::shared_ptr<T> as() {
|
||||
if(!is<T>()) {
|
||||
throw std::runtime_error("unsupported operation, object's type is not require type");
|
||||
}
|
||||
|
||||
return std::static_pointer_cast<T>(shared_from_this());
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<FilterImpl> impl_;
|
||||
std::string type_;
|
||||
|
||||
friend class OBFilterList;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -152,17 +199,26 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hole filling filter
|
||||
* @brief Hole filling filter,the processing performed depends on the selected hole filling mode.
|
||||
*/
|
||||
class OB_EXTENSION_API HoleFillingFilter : public Filter {
|
||||
public:
|
||||
HoleFillingFilter();
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
|
||||
/**
|
||||
* @brief Set the HoleFillingFilter mode.
|
||||
*
|
||||
* @param[in] filter A holefilling_filter object.
|
||||
* @param mode OBHoleFillingMode, OB_HOLE_FILL_TOP,OB_HOLE_FILL_NEAREST or OB_HOLE_FILL_FAREST.
|
||||
*/
|
||||
void setFilterMode(OBHoleFillingMode mode);
|
||||
|
||||
/**
|
||||
* @brief Get the HoleFillingFilter mode.
|
||||
*
|
||||
* @return OBHoleFillingMode
|
||||
*/
|
||||
OBHoleFillingMode getFilterMode();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -172,41 +228,84 @@ class OB_EXTENSION_API TemporalFilter : public Filter {
|
||||
public:
|
||||
TemporalFilter();
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
|
||||
/**
|
||||
* @brief Get the TemporalFilter diffscale range.
|
||||
*
|
||||
* @return OBFloatPropertyRange the diffscale value of property range.
|
||||
*/
|
||||
OBFloatPropertyRange getDiffScaleRange();
|
||||
|
||||
/**
|
||||
* @brief Set the TemporalFilter diffscale value.
|
||||
*
|
||||
* @param value diffscale value.
|
||||
*/
|
||||
void setDiffScale(float value);
|
||||
|
||||
/**
|
||||
* @brief Get the TemporalFilter weight range.
|
||||
*
|
||||
* @return OBFloatPropertyRange the weight value of property range.
|
||||
*/
|
||||
OBFloatPropertyRange getWeightRange();
|
||||
|
||||
/**
|
||||
* @brief Set the TemporalFilter weight value.
|
||||
*
|
||||
* @param value weight value.
|
||||
*/
|
||||
void setWeight(float value);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Spatial advanced filter
|
||||
* @brief Spatial advanced filte smooths the image by calculating frame with alpha and delta settings
|
||||
* alpha defines the weight of the current pixel for smoothing,
|
||||
* delta defines the depth gradient below which the smoothing will occur as number of depth levels.
|
||||
*/
|
||||
class OB_EXTENSION_API SpatialAdvancedFilter : public Filter {
|
||||
public:
|
||||
SpatialAdvancedFilter();
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
|
||||
/**
|
||||
* @brief Get the spatial advanced filter alpha range.
|
||||
*
|
||||
* @return OBFloatPropertyRange the alpha value of property range.
|
||||
*/
|
||||
OBFloatPropertyRange getAlphaRange();
|
||||
|
||||
/**
|
||||
* @brief Get the spatial advanced filter dispdiff range.
|
||||
*
|
||||
* @return OBFloatPropertyRange the dispdiff value of property range.
|
||||
*/
|
||||
OBUint16PropertyRange getDispDiffRange();
|
||||
|
||||
/**
|
||||
* @brief Get the spatial advanced filter radius range.
|
||||
*
|
||||
* @return OBFloatPropertyRange the radius value of property range.
|
||||
*/
|
||||
OBUint16PropertyRange getRadiusRange();
|
||||
|
||||
/**
|
||||
* @brief Get the spatial advanced filter magnitude range.
|
||||
*
|
||||
* @return OBFloatPropertyRange the magnitude value of property range.
|
||||
*/
|
||||
OBIntPropertyRange getMagnitudeRange();
|
||||
|
||||
/**
|
||||
* @brief Get the spatial advanced filter params.
|
||||
*
|
||||
* @return OBSpatialAdvancedFilterParams
|
||||
*/
|
||||
OBSpatialAdvancedFilterParams getFilterParams();
|
||||
|
||||
/**
|
||||
* @brief Set the spatial advanced filter params.
|
||||
*
|
||||
* @param params OBSpatialAdvancedFilterParams.
|
||||
*/
|
||||
void setFilterParams(OBSpatialAdvancedFilterParams params);
|
||||
};
|
||||
|
||||
@@ -215,25 +314,22 @@ public:
|
||||
*/
|
||||
class OB_EXTENSION_API DisparityTransform : public Filter {
|
||||
public:
|
||||
DisparityTransform();
|
||||
|
||||
/**
|
||||
* @brief Create a disparity transform.
|
||||
* @param depth_to_disparity disparity to depth or depth to disparity Conversion.
|
||||
*/
|
||||
DisparityTransform(bool depth_to_disparity);
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Depth HDR merge
|
||||
* @brief HdrMerge processing block,
|
||||
* the processing merges between depth frames with
|
||||
* different sub-preset sequence ids.
|
||||
*/
|
||||
class OB_EXTENSION_API HdrMerge : public Filter {
|
||||
public:
|
||||
HdrMerge();
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -241,11 +337,18 @@ public:
|
||||
*/
|
||||
class OB_EXTENSION_API Align : public Filter {
|
||||
public:
|
||||
Align(OBStreamType align_to_stream, OBFrameType align_to_frame);
|
||||
/**
|
||||
* @brief Creaet Align filter.
|
||||
* @param OBStreamType alignment is performed between a depth image and another image.
|
||||
*/
|
||||
Align(OBStreamType align_to_stream);
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
/**
|
||||
* @brief Get the stream type to be aligned with.
|
||||
*
|
||||
* @return OBStreamType The stream type of align to.
|
||||
*/
|
||||
OBStreamType getAlignToStreamType();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,67 +359,167 @@ class OB_EXTENSION_API ThresholdFilter : public Filter {
|
||||
public:
|
||||
ThresholdFilter();
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
|
||||
/**
|
||||
* @brief Get the threshold filter min range.
|
||||
*
|
||||
* @return OBIntPropertyRange The range of the threshold filter min.
|
||||
*/
|
||||
OBIntPropertyRange getMinRange();
|
||||
|
||||
/**
|
||||
* @brief Get the threshold filter max range.
|
||||
*
|
||||
* @return OBIntPropertyRange The range of the threshold filter max.
|
||||
*/
|
||||
OBIntPropertyRange getMaxRange();
|
||||
|
||||
/**
|
||||
* @brief Get the threshold filter max and min range.
|
||||
*/
|
||||
void setValueRange(uint16_t min, uint16_t max);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Create SequenceIdFilter processing block.
|
||||
*/
|
||||
class OB_EXTENSION_API SequenceIdFilter : public Filter {
|
||||
public:
|
||||
SequenceIdFilter();
|
||||
|
||||
void enable(bool enable);
|
||||
/**
|
||||
* @brief Set the sequenceId filter params.
|
||||
*
|
||||
* @param sequence id to pass the filter.
|
||||
*/
|
||||
void selectSequenceId(int sequence_id);
|
||||
|
||||
bool isEnabled();
|
||||
/**
|
||||
* @brief Get the current sequence id.
|
||||
*
|
||||
* @return sequence id to pass the filter.
|
||||
*/
|
||||
int getSelectSequenceId();
|
||||
|
||||
void selectSequenceId(float sequence_id);
|
||||
/**
|
||||
* @brief Get the current sequence id list.
|
||||
*
|
||||
* @return OBSequenceIdItem.
|
||||
*/
|
||||
OBSequenceIdItem *getSequenceIdList();
|
||||
|
||||
float getSelectSequenceId();
|
||||
|
||||
std::map<float, std::string> getSequenceIdList();
|
||||
/**
|
||||
* @brief Get the sequenceId list size.
|
||||
*
|
||||
* @return the size of sequenceId list.
|
||||
*/
|
||||
int getSequenceIdListSize();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief The noise removal filter,removing scattering depth pixels.
|
||||
*/
|
||||
class OB_EXTENSION_API NoiseRemovalFilter : public Filter {
|
||||
public:
|
||||
NoiseRemovalFilter();
|
||||
|
||||
void enable(bool enable);
|
||||
/**
|
||||
* @brief Set the noise removal filter params.
|
||||
*
|
||||
* @param[in] params ob_noise_removal_filter_params.
|
||||
*/
|
||||
void setFilterParams(OBNoiseRemovalFilterParams filterParams);
|
||||
|
||||
bool isEnabled();
|
||||
|
||||
void setNoiseRemovalFilterParams(OBNoiseRemovalFilterParams *filterParams);
|
||||
/**
|
||||
* @brief Get the noise removal filter params.
|
||||
*
|
||||
* @return OBNoiseRemovalFilterParams.
|
||||
*/
|
||||
OBNoiseRemovalFilterParams getFilterParams();
|
||||
|
||||
/**
|
||||
* @brief Get the noise removal filter disp diff range.
|
||||
* @return OBUint16PropertyRange The disp diff of property range.
|
||||
*/
|
||||
OBUint16PropertyRange getDispDiffRange();
|
||||
|
||||
OBUint16PropertyRange getSizeRange();
|
||||
/**
|
||||
* @brief Get the noise removal filter max size range.
|
||||
* @return OBUint16PropertyRange The max size of property range.
|
||||
*/
|
||||
OBUint16PropertyRange getMaxSizeRange();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Decimation filter,reducing complexity by subsampling depth maps and losing depth details.
|
||||
*/
|
||||
class OB_EXTENSION_API DecimationFilter : public Filter {
|
||||
public:
|
||||
DecimationFilter();
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
bool isEnabled();
|
||||
|
||||
/**
|
||||
* @brief Set the decimation filter scale value.
|
||||
*
|
||||
* @param type The decimation filter scale value.
|
||||
*/
|
||||
void setScaleValue(uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Get the decimation filter scale value.
|
||||
*/
|
||||
uint8_t getScaleValue();
|
||||
|
||||
/**
|
||||
* @brief Get the property range of the decimation filter scale value.
|
||||
*/
|
||||
OBUint8PropertyRange getScaleRange();
|
||||
};
|
||||
|
||||
// Define the is() template function for the Filter class
|
||||
template <typename T> bool Filter::is() {
|
||||
std::string name = type();
|
||||
if(name == "HdrMerge") {
|
||||
return typeid(T) == typeid(HdrMerge);
|
||||
}
|
||||
if(name == "SequenceIdFilter") {
|
||||
return typeid(T) == typeid(SequenceIdFilter);
|
||||
}
|
||||
if(name == "ThresholdFilter") {
|
||||
return typeid(T) == typeid(ThresholdFilter);
|
||||
}
|
||||
if(name == "DisparityTransform") {
|
||||
return typeid(T) == typeid(DisparityTransform);
|
||||
}
|
||||
if(name == "NoiseRemovalFilter") {
|
||||
return typeid(T) == typeid(NoiseRemovalFilter);
|
||||
}
|
||||
if(name == "SpatialAdvancedFilter") {
|
||||
return typeid(T) == typeid(SpatialAdvancedFilter);
|
||||
}
|
||||
if(name == "TemporalFilter") {
|
||||
return typeid(T) == typeid(TemporalFilter);
|
||||
}
|
||||
if(name == "HoleFillingFilter") {
|
||||
return typeid(T) == typeid(HoleFillingFilter);
|
||||
}
|
||||
if(name == "DecimationFilter") {
|
||||
return typeid(T) == typeid(DecimationFilter);
|
||||
}
|
||||
if(name == "PointCloudFilter") {
|
||||
return typeid(T) == typeid(PointCloudFilter);
|
||||
}
|
||||
if(name == "CompressionFilter") {
|
||||
return typeid(T) == typeid(CompressionFilter);
|
||||
}
|
||||
if(name == "DecompressionFilter") {
|
||||
return typeid(T) == typeid(DecompressionFilter);
|
||||
}
|
||||
if(name == "FormatConverter") {
|
||||
return typeid(T) == typeid(FormatConvertFilter);
|
||||
}
|
||||
if(name == "Align") {
|
||||
return typeid(T) == typeid(Align);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace ob
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Types.hpp"
|
||||
#include "libobsensor/hpp/Filter.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -18,6 +19,7 @@ class StreamProfileList;
|
||||
class Device;
|
||||
class Frame;
|
||||
class ImuFrame;
|
||||
class OBFilterList;
|
||||
|
||||
/**
|
||||
* @brief Callback function for frame data.
|
||||
@@ -48,6 +50,12 @@ public:
|
||||
*/
|
||||
const std::shared_ptr<StreamProfileList> getStreamProfileList();
|
||||
|
||||
/**
|
||||
* @brief Request recommended filters
|
||||
* @return OBFilterList list of frame processing block
|
||||
*/
|
||||
const std::shared_ptr<OBFilterList> getRecommendedFilters();
|
||||
|
||||
/**
|
||||
* @brief Open a frame data stream and set up a callback.
|
||||
*
|
||||
@@ -109,4 +117,33 @@ public:
|
||||
*/
|
||||
std::shared_ptr<Sensor> getSensor(OBSensorType sensorType);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Class representing a list of FrameProcessingBlock
|
||||
*/
|
||||
class OB_EXTENSION_API OBFilterList {
|
||||
private:
|
||||
std::unique_ptr<OBFilterListImpl> impl_;
|
||||
|
||||
public:
|
||||
OBFilterList(std::unique_ptr<OBFilterListImpl> impl_);
|
||||
~OBFilterList() noexcept;
|
||||
|
||||
/**
|
||||
* @brief Get the number of OBDepthWorkMode FrameProcessingBlock in the list
|
||||
*
|
||||
* @return uint32_t the number of FrameProcessingBlock objects in the list
|
||||
*/
|
||||
uint32_t count();
|
||||
|
||||
/**
|
||||
* @brief Get the Filter object at the specified index
|
||||
*
|
||||
* @param index the index of the target Filter object
|
||||
* @return the Filter object at the specified index
|
||||
*/
|
||||
std::shared_ptr<Filter> getFilter(uint32_t index);
|
||||
};
|
||||
|
||||
} // namespace ob
|
||||
|
||||
Reference in New Issue
Block a user