24#include <unordered_map>
65 range.cur =
static_cast<valueType
>(cur);
66 range.def =
static_cast<valueType
>(item.
def);
67 range.max =
static_cast<valueType
>(item.
max);
68 range.min =
static_cast<valueType
>(item.
min);
69 range.step =
static_cast<valueType
>(item.
step);
76class Filter :
public std::enable_shared_from_this<Filter> {
101 for(uint32_t i = 0; i < count; i++) {
117 if(
impl_ !=
nullptr) {
177 virtual std::shared_ptr<Frame>
process(std::shared_ptr<const Frame> frame)
const {
184 return std::make_shared<Frame>(result);
192 virtual void pushFrame(std::shared_ptr<Frame> frame)
const {
266 static void filterCallback(
ob_frame *frame,
void *userData) {
267 auto filter =
static_cast<Filter *
>(userData);
268 filter->
callback_(std::make_shared<Frame>(frame));
283 template <
typename T>
bool is();
285 template <
typename T> std::shared_ptr<T>
as() {
287 throw std::runtime_error(
"unsupported operation, object's type is not require type");
290 return std::static_pointer_cast<T>(shared_from_this());
306 return std::make_shared<Filter>(impl);
316 static std::shared_ptr<Filter>
createPrivateFilter(
const std::string &name,
const std::string &activationKey) {
320 return std::make_shared<Filter>(impl);
421 setConfigValue(
"AlignType",
static_cast<double>(alignToStreamType));
424 virtual ~Align() noexcept override = default;
503 std::map<float, std::string> sequenceIdList_{ { 0.f,
"all" }, { 1.f,
"1" } };
506 void initSequenceIdList() {
510 for(
const auto &pair: sequenceIdList_) {
511 outputSequenceIdList_[i].sequenceSelectId =
static_cast<int>(pair.first);
512 strncpy(outputSequenceIdList_[i].name, pair.second.c_str(),
sizeof(outputSequenceIdList_[i].name) - 1);
513 outputSequenceIdList_[i].name[
sizeof(outputSequenceIdList_[i].name) - 1] =
'\0';
524 initSequenceIdList();
528 if(outputSequenceIdList_) {
529 delete[] outputSequenceIdList_;
530 outputSequenceIdList_ =
nullptr;
553 return outputSequenceIdList_;
562 return static_cast<int>(sequenceIdList_.size());
632 for(
const auto &item: schemaVec) {
633 if(strcmp(item.name,
"min") == 0) {
649 for(
const auto &item: schemaVec) {
650 if(strcmp(item.name,
"max") == 0) {
695 for(
const auto &item: schemaVec) {
696 if(strcmp(item.name,
"alpha") == 0) {
712 for(
const auto &item: schemaVec) {
713 if(strcmp(item.name,
"disp_diff") == 0) {
729 for(
const auto &item: schemaVec) {
730 if(strcmp(item.name,
"radius") == 0) {
746 for(
const auto &item: schemaVec) {
747 if(strcmp(item.name,
"magnitude") == 0) {
805 for(
const auto &item: schemaVec) {
806 if(strcmp(item.name,
"radius") == 0) {
858 for(
const auto &item: schemaVec) {
859 if(strcmp(item.name,
"magnitude") == 0) {
875 for(
const auto &item: schemaVec) {
876 if(strcmp(item.name,
"radius") == 0) {
892 for(
const auto &item: schemaVec) {
893 if(strcmp(item.name,
"disp_diff") == 0) {
979 setConfigValue(
"max_size",
static_cast<double>(filterParams.max_size));
980 setConfigValue(
"min_diff",
static_cast<double>(filterParams.disp_diff));
1004 for(
const auto &item: schemaVec) {
1005 if(strcmp(item.name,
"min_diff") == 0) {
1020 for(
const auto &item: schemaVec) {
1021 if(strcmp(item.name,
"max_size") == 0) {
1052 for(
const auto &item: schemaVec) {
1053 if(strcmp(item.name,
"diff_scale") == 0) {
1078 for(
const auto &item: schemaVec) {
1079 if(strcmp(item.name,
"weight") == 0) {
1114 ob_filter_list_t *impl_;
1147 return std::make_shared<Filter>(filter);
1161 static const std::unordered_map<std::string, std::type_index> filterTypeMap = {
1170 return filterTypeMap;
1180 std::string name =
type();
1183 auto it = filterTypeMap.find(name);
1184 if(it != filterTypeMap.end()) {
1185 return std::type_index(
typeid(T)) == it->second;
This file defines the Error class, which describes abnormal errors within the SDK....
The processing unit of the SDK can perform point cloud generation, format conversion and other functi...
OB_EXPORT const char * ob_filter_get_vendor_specific_code(const char *name, ob_error **error)
Get the vendor specific code of a filter by filter name.
OB_EXPORT void ob_align_filter_set_align_to_stream_profile(ob_filter *filter, const ob_stream_profile *align_to_stream_profile, ob_error **error)
Set the align to stream profile for the align filter.
OB_EXPORT void ob_delete_filter_list(ob_filter_list *filter_list, ob_error **error)
Delete a list of ob_filter objects.
OB_EXPORT void ob_filter_push_frame(ob_filter *filter, const ob_frame *frame, ob_error **error)
Push the frame into the pending cache for the filter (asynchronous callback interface).
OB_EXPORT ob_frame * ob_filter_process(ob_filter *filter, const ob_frame *frame, ob_error **error)
Process the frame (synchronous interface).
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)
Get the config schema item by index.
OB_EXPORT void ob_filter_reset(ob_filter *filter, ob_error **error)
Reset the filter, clears the cache, and resets the state. If the asynchronous interface is used,...
OB_EXPORT const char * ob_filter_get_config_schema(const ob_filter *filter, ob_error **error)
Get config schema of the filter.
OB_EXPORT ob_filter * ob_create_private_filter(const char *name, const char *activation_key, ob_error **error)
Create a private Filter object with activation key.
OB_EXPORT void ob_filter_set_callback(ob_filter *filter, ob_filter_callback callback, void *user_data, ob_error **error)
Set the processing result callback function for the filter (asynchronous callback interface).
OB_EXPORT bool ob_filter_is_enabled(const ob_filter *filter, ob_error **error)
Get the enable status of the frame post processing.
OB_EXPORT uint32_t ob_filter_config_schema_list_get_count(const ob_filter_config_schema_list *config_schema_list, ob_error **error)
Get the number of config schema items in the config schema list.
OB_EXPORT const char * ob_filter_get_name(const ob_filter *filter, ob_error **error)
Get the name of ob_filter.
OB_EXPORT void ob_delete_filter(ob_filter *filter, ob_error **error)
Delete the filter.
OB_EXPORT double ob_filter_get_config_value(const ob_filter *filter, const char *config_name, ob_error **error)
Get the filter config value by name and cast to double.
OB_EXPORT ob_filter * ob_filter_list_get_filter(const ob_filter_list *filter_list, uint32_t index, ob_error **error)
Get the filter by index.
OB_EXPORT ob_filter * ob_create_filter(const char *name, ob_error **error)
Create a Filter object.
OB_EXPORT uint32_t ob_filter_list_get_count(const ob_filter_list *filter_list, ob_error **error)
Get the number of filter in the list.
OB_EXPORT void ob_filter_set_config_value(ob_filter *filter, const char *config_name, double value, ob_error **error)
Set the filter config value by name.
OB_EXPORT void ob_filter_enable(ob_filter *filter, bool enable, ob_error **error)
Enable the frame post processing.
OB_EXPORT ob_filter_config_schema_list * ob_filter_get_config_schema_list(const ob_filter *filter, ob_error **error)
Get the filter config schema list of the filter.
OB_EXPORT void ob_delete_filter_config_schema_list(ob_filter_config_schema_list *config_schema_list, ob_error **error)
Delete a list of filter config schema items.
Frame related function is mainly used to obtain frame data and frame information.
Frame related type, which is mainly used to obtain frame data and frame information.
struct ob_frame_t ob_frame
OBFormat
Enumeration value describing the pixel format.
OBStreamType
Enumeration value describing the type of data stream.
struct ob_filter_t ob_filter
enum OB_COORDINATE_SYSTEM_TYPE OBCoordinateSystemType
OBHoleFillingMode
Hole fillig mode.
OBConvertFormat
Enumeration of format conversion types.
Align for depth to other or other to depth.
Align(OBStreamType alignToStreamType)
virtual ~Align() noexcept override=default
OBStreamType getAlignToStreamType()
void setMatchTargetResolution(bool state)
Sets whether the output frame resolution should match the target resolution. When enabled,...
void setAlignToStreamProfile(std::shared_ptr< const StreamProfile > profile)
Set the Align To Stream Profile.
Decimation filter, reducing complexity by subsampling depth maps and losing depth details.
virtual ~DecimationFilter() noexcept override=default
OBUint8PropertyRange getScaleRange()
Get the property range of the decimation filter scale value.
uint8_t getScaleValue()
Get the decimation filter scale value.
void setScaleValue(uint8_t value)
Set the decimation filter scale value.
static void handle(ob_error **error, bool throw_exception=true)
A static function to handle the ob_error and throw an exception if needed.
A factory class for creating filters.
static std::string getFilterVendorSpecificCode(const std::string &name)
Get the vendor specific code of a filter by filter name.
static std::shared_ptr< Filter > createFilter(const std::string &name)
Create a filter by name.
static std::shared_ptr< Filter > createPrivateFilter(const std::string &name, const std::string &activationKey)
Create a private filter by name and activation key.
The Filter class is the base class for all filters in the SDK.
bool is()
Check if the runtime type of the filter object is compatible with a given type.
virtual void init(ob_filter *impl)
std::shared_ptr< T > as()
virtual const std::string & getName() const
Get the type of filter.
virtual std::vector< OBFilterConfigSchemaItem > getConfigSchemaVec() const
Get the Config Schema Vec object.
virtual void enable(bool enable) const
enable the filter
virtual void setConfigValue(const std::string &configName, double value) const
Set the filter config value by name.
virtual std::string getConfigSchema() const
Get config schema of the filter.
std::vector< OBFilterConfigSchemaItem > configSchemaVec_
virtual bool isEnabled() const
Return Enable State.
Filter()=default
Default constructor with nullptr impl, used for derived classes only.
virtual void pushFrame(std::shared_ptr< Frame > frame) const
Pushes the pending frame into the cache for asynchronous processing.
virtual std::shared_ptr< Frame > process(std::shared_ptr< const Frame > frame) const
Processes a frame synchronously.
ob_filter * getImpl() const
Get the Impl object of the filter.
virtual void reset() const
Reset the filter, freeing the internal cache, stopping the processing thread, and clearing the pendin...
virtual const char * type()
virtual double getConfigValue(const std::string &configName) const
Get the Config Value object by name.
virtual void setCallBack(FilterCallback callback)
Set the callback function for asynchronous processing.
virtual ~Filter() noexcept
HdrMerge processing block, the processing merges between depth frames with different sub-preset seque...
virtual ~HdrMerge() noexcept override=default
Hole filling filter,the processing performed depends on the selected hole filling mode.
void setFilterMode(OBHoleFillingMode mode)
Set the HoleFillingFilter mode.
HoleFillingFilter(const std::string &activationKey="")
OBHoleFillingMode getFilterMode()
Get the HoleFillingFilter mode.
~HoleFillingFilter() noexcept override=default
The noise removal filter,removing scattering depth pixels.
OBUint16PropertyRange getDispDiffRange()
Get the noise removal filter disp diff range.
void setFilterParams(OBNoiseRemovalFilterParams filterParams)
Set the noise removal filter params.
NoiseRemovalFilter(const std::string &activationKey="")
~NoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMaxSizeRange()
Get the noise removal filter max size range.
OBNoiseRemovalFilterParams getFilterParams()
Get the noise removal filter params.
uint32_t getCount() const
Get the number of filters.
std::shared_ptr< Filter > getFilter(uint32_t index)
Get the Filter object at the specified index.
OBFilterList(ob_filter_list_t *impl)
The PointCloudFilter class is a subclass of Filter that generates point clouds.
void setCoordinateSystem(OBCoordinateSystemType type)
Set the point cloud coordinate system.
void setCoordinateDataScaled(float factor)
Set the point cloud coordinate data zoom factor.
void setCameraParam(OBCameraParam param)
void setPositionDataScaled(float scale)
void setCreatePointFormat(OBFormat format)
Set the output pointcloud frame format.
virtual ~PointCloudFilter() noexcept override=default
void setFrameAlignState(bool state)
void setColorDataNormalization(bool state)
Set point cloud color data normalization.
Create SequenceIdFilter processing block.
int getSelectSequenceId()
Get the current sequence id.
void selectSequenceId(int sequence_id)
Set the sequenceId filter params.
virtual ~SequenceIdFilter() noexcept override
OBSequenceIdItem * getSequenceIdList()
int getSequenceIdListSize()
Get the sequenceId list size.
Spatial advanced filte smooths the image by calculating frame with alpha and delta settings alpha def...
void setFilterParams(OBSpatialAdvancedFilterParams params)
Set the spatial advanced filter params.
OBSpatialAdvancedFilterParams getFilterParams()
Get the spatial advanced filter params.
OBUint16PropertyRange getRadiusRange()
Get the spatial advanced filter radius range.
SpatialAdvancedFilter(const std::string &activationKey="")
OBFloatPropertyRange getAlphaRange()
Get the spatial advanced filter alpha range.
OBUint16PropertyRange getDispDiffRange()
Get the spatial advanced filter dispdiff range.
virtual ~SpatialAdvancedFilter() noexcept override=default
OBIntPropertyRange getMagnitudeRange()
Get the spatial advanced filter magnitude range.
The Spatial Fast Filter utilizes an enhanced median smoothing algorithm, designed to significantly re...
virtual ~SpatialFastFilter() noexcept override=default
SpatialFastFilter(const std::string &activationKey="")
void setFilterParams(OBSpatialFastFilterParams params)
Set the spatial fast filter params.
OBSpatialFastFilterParams getFilterParams()
Get the spatial fast filter params.
OBIntPropertyRange getRadiusRange()
Get the spatial fast filter radius range.
The Spatial Moderate Filter utilizes an optimized average smoothing algorithm, to achieve a balance b...
SpatialModerateFilter(const std::string &activationKey="")
OBIntPropertyRange getRadiusRange()
Get the spatial moderate filter radius range.
virtual ~SpatialModerateFilter() noexcept override=default
void setFilterParams(OBSpatialModerateFilterParams params)
Set the spatial moderate filter params.
OBSpatialModerateFilterParams getFilterParams()
Get the spatial moderate filter params.
OBIntPropertyRange getMagnitudeRange()
Get the spatial moderate filter magnitude range.
OBIntPropertyRange getDispDiffRange()
Get the spatial moderate filter disp diff range.
OBFloatPropertyRange getWeightRange()
Get the TemporalFilter weight range.
void setDiffScale(float value)
Set the TemporalFilter diffscale value.
~TemporalFilter() noexcept override=default
OBFloatPropertyRange getDiffScaleRange()
Get the TemporalFilter diffscale range.
void setWeight(float value)
Set the TemporalFilter weight value.
TemporalFilter(const std::string &activationKey="")
Creates depth Thresholding filter By controlling min and max options on the block.
bool setValueRange(uint16_t min, uint16_t max)
Set the threshold filter max and min range.
OBIntPropertyRange getMinRange()
Get the threshold filter min range.
virtual ~ThresholdFilter() noexcept override=default
OBIntPropertyRange getMaxRange()
Get the threshold filter max range.
const std::unordered_map< std::string, std::type_index > & getFilterTypeMap()
Returns the mapping of filter type names to their corresponding type_index.
std::function< void(std::shared_ptr< Frame >)> FilterCallback
A callback function that takes a shared pointer to a Frame object as its argument.
T getPropertyRange(const OBFilterConfigSchemaItem &item, const double cur)
Get T Property Range.
Structure for camera parameters.
Configuration Item for the filter.
double min
Minimum value casted to double.
double max
Maximum value casted to double.
double def
Default value casted to double.
double step
Step value casted to double.
Structure for float range.
Structure for integer range.
SequenceId fliter list item.
Structure for float range.
Structure for float range.
Get the type of a PropertyRange member.
The error class exposed by the SDK, users can get detailed error information according to the error.