| OrbbecSDK 1.10.18 OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras

Loading...
Searching...
No Matches
Filter.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include "Types.hpp"
9#include <functional>
10#include <memory>
11#include <map>
12#include <string>
13#include <iostream>
14
15 namespace ob {
16 class Frame;
17 class OBFilterList;
18
22 typedef std::function<void(std::shared_ptr<Frame>)> FilterCallback;
23
27 class OB_EXTENSION_API Filter : public std::enable_shared_from_this<Filter> {
28 public:
29 Filter();
30
31 Filter(std::shared_ptr<FilterImpl> impl);
32
33 virtual ~Filter() = default;
34
39 virtual void reset();
40
44 void enable(bool enable);
45
49 bool isEnabled();
50
57 virtual std::shared_ptr<Frame> process(std::shared_ptr<Frame> frame);
58
64 virtual void pushFrame(std::shared_ptr<Frame> frame);
65
71 virtual void setCallBack(FilterCallback callback);
72
78 virtual const char *type();
79
86 template <typename T> bool is();
87
94 template <typename T> std::shared_ptr<T> as() {
95 if(!is<T>()) {
96 throw std::runtime_error("unsupported operation, object's type is not require type");
97 }
98
99 return std::static_pointer_cast<T>(shared_from_this());
100 }
101
102 protected:
103 std::shared_ptr<FilterImpl> impl_;
104 std::string type_;
105
106 friend class OBFilterList;
107};
108
112 class OB_EXTENSION_API PointCloudFilter : public Filter {
113 public:
114 PointCloudFilter();
115
121 void setCreatePointFormat(OBFormat type);
122
128 void setCameraParam(OBCameraParam param);
129
135 void setFrameAlignState(bool state);
136
145 void setPositionDataScaled(float scale);
146
152 void setColorDataNormalization(bool state);
153
159 void setCoordinateSystem(OBCoordinateSystemType type);
160};
161
165 class OB_EXTENSION_API FormatConvertFilter : public Filter {
166 public:
167 FormatConvertFilter();
168
174 void setFormatConvertType(OBConvertFormat type);
175};
176
180 class OB_EXTENSION_API CompressionFilter : public Filter {
181 public:
182 CompressionFilter();
183
190 void setCompressionParams(OBCompressionMode mode, void *params);
191};
192
196 class OB_EXTENSION_API DecompressionFilter : public Filter {
197 public:
198 DecompressionFilter();
199};
200
204 class OB_EXTENSION_API HoleFillingFilter : public Filter {
205 public:
206 HoleFillingFilter();
207
214 void setFilterMode(OBHoleFillingMode mode);
215
221 OBHoleFillingMode getFilterMode();
222};
223
227 class OB_EXTENSION_API TemporalFilter : public Filter {
228 public:
229 TemporalFilter();
230
236 OBFloatPropertyRange getDiffScaleRange();
237
243 void setDiffScale(float value);
244
250 OBFloatPropertyRange getWeightRange();
251
257 void setWeight(float value);
258};
259
265 class OB_EXTENSION_API SpatialAdvancedFilter : public Filter {
266 public:
267 SpatialAdvancedFilter();
268
274 OBFloatPropertyRange getAlphaRange();
275
281 OBUint16PropertyRange getDispDiffRange();
282
288 OBUint16PropertyRange getRadiusRange();
289
295 OBIntPropertyRange getMagnitudeRange();
296
302 OBSpatialAdvancedFilterParams getFilterParams();
303
309 void setFilterParams(OBSpatialAdvancedFilterParams params);
310};
311
315 class OB_EXTENSION_API SpatialFastFilter : public Filter {
316 public:
317 SpatialFastFilter();
323 OBUint8PropertyRange getSizeRange();
324
330 OBSpatialFastFilterParams getFilterParams();
336 void setFilterParams(OBSpatialFastFilterParams params);
337};
338
342 class OB_EXTENSION_API SpatialModerateFilter : public Filter {
343 public:
344 SpatialModerateFilter();
350 OBUint8PropertyRange getSizeRange();
351
357 OBUint8PropertyRange getMagnitudeRange();
363 OBUint16PropertyRange getDispDiffRange();
364
370 OBSpatialModerateFilterParams getFilterParams();
376 void setFilterParams(OBSpatialModerateFilterParams params);
377};
378
382 class OB_EXTENSION_API DisparityTransform : public Filter {
383 public:
384
389 DisparityTransform(bool depth_to_disparity);
390};
391
397 class OB_EXTENSION_API HdrMerge : public Filter {
398 public:
399 HdrMerge();
400};
401
405 class OB_EXTENSION_API Align : public Filter {
406 public:
411 Align(OBStreamType align_to_stream);
412
418 OBStreamType getAlignToStreamType();
419};
420
425 class OB_EXTENSION_API ThresholdFilter : public Filter {
426 public:
427 ThresholdFilter();
428
434 OBIntPropertyRange getMinRange();
435
441 OBIntPropertyRange getMaxRange();
442
446 bool setValueRange(uint16_t min, uint16_t max);
447};
448
452 class OB_EXTENSION_API SequenceIdFilter : public Filter {
453 public:
454 SequenceIdFilter();
455
461 void selectSequenceId(int sequence_id);
462
468 int getSelectSequenceId();
469
475 OBSequenceIdItem *getSequenceIdList();
476
482 int getSequenceIdListSize();
483};
484
488 class OB_EXTENSION_API NoiseRemovalFilter : public Filter {
489 public:
490 NoiseRemovalFilter();
491
497 void setFilterParams(OBNoiseRemovalFilterParams filterParams);
498
504 OBNoiseRemovalFilterParams getFilterParams();
505
510 OBUint16PropertyRange getDispDiffRange();
511
516 OBUint16PropertyRange getMaxSizeRange();
517};
518
522 class OB_EXTENSION_API DecimationFilter : public Filter {
523 public:
524 DecimationFilter();
525
531 void setScaleValue(uint8_t value);
532
536 uint8_t getScaleValue();
537
541 OBUint8PropertyRange getScaleRange();
542};
543
547 class OB_EXTENSION_API EdgeNoiseRemovalFilter : public Filter {
548 public:
549 EdgeNoiseRemovalFilter();
550
556 void setFilterParams(OBEdgeNoiseRemovalFilterParams filterParams);
557
563 OBEdgeNoiseRemovalFilterParams getFilterParams();
564
569 OBUint16PropertyRange getMarginLeftThRange();
570
575 OBUint16PropertyRange getMarginRightThRange();
576
581 OBUint16PropertyRange getMarginTopThRange();
582
587 OBUint16PropertyRange getMarginBottomThRange();
588};
589
590
591// Define the is() template function for the Filter class
592 template <typename T> bool Filter::is() {
593 std::string name = type();
594 if(name == "HDRMerge") {
595 return typeid(T) == typeid(HdrMerge);
596 }
597 if(name == "SequenceIdFilter") {
598 return typeid(T) == typeid(SequenceIdFilter);
599 }
600 if(name == "ThresholdFilter") {
601 return typeid(T) == typeid(ThresholdFilter);
602 }
603 if(name == "DisparityTransform") {
604 return typeid(T) == typeid(DisparityTransform);
605 }
606 if(name == "NoiseRemovalFilter") {
607 return typeid(T) == typeid(NoiseRemovalFilter);
608 }
609 if(name == "SpatialAdvancedFilter") {
610 return typeid(T) == typeid(SpatialAdvancedFilter);
611 }
612
613 if(name == "SpatialFastFilter") {
614 return typeid(T) == typeid(SpatialFastFilter);
615 }
616
617 if(name == "SpatialModerateFilter") {
618 return typeid(T) == typeid(SpatialModerateFilter);
619 }
620
621 if(name == "TemporalFilter") {
622 return typeid(T) == typeid(TemporalFilter);
623 }
624 if(name == "HoleFillingFilter") {
625 return typeid(T) == typeid(HoleFillingFilter);
626 }
627 if(name == "DecimationFilter") {
628 return typeid(T) == typeid(DecimationFilter);
629 }
630 if(name == "PointCloudFilter") {
631 return typeid(T) == typeid(PointCloudFilter);
632 }
633 if(name == "CompressionFilter") {
634 return typeid(T) == typeid(CompressionFilter);
635 }
636 if(name == "DecompressionFilter") {
637 return typeid(T) == typeid(DecompressionFilter);
638 }
639 if(name == "FormatConverter") {
640 return typeid(T) == typeid(FormatConvertFilter);
641 }
642 if(name == "Align") {
643 return typeid(T) == typeid(Align);
644 }
645 if(name == "EdgeNoiseRemovalFilter") {
646 return typeid(T) == typeid(EdgeNoiseRemovalFilter);
647 }
648 return false;
649}
650
651} // namespace ob
OBFormat
OBFormat
Enumeration value describing the pixel format.
Definition ObTypes.h:216
OBStreamType
OBStreamType
Enumeration value describing the type of data stream.
Definition ObTypes.h:179
OBCoordinateSystemType
enum OB_COORDINATE_SYSTEM_TYPE OBCoordinateSystemType
OB_EXTENSION_API
#define OB_EXTENSION_API
Definition ObTypes.h:28
OBCompressionMode
OBCompressionMode
Compression mode.
Definition ObTypes.h:781
OBHoleFillingMode
OBHoleFillingMode
Hole fillig mode.
Definition ObTypes.h:977
OBConvertFormat
OBConvertFormat
Enumeration of format conversion types.
Definition ObTypes.h:544
Types.hpp
Provides SDK structure and enumeration constant definitions (depending on libobsensor/h/ObTypes....
ob::Align
Align for depth to other or other to depth.
Definition Filter.hpp:405
ob::Align::getAlignToStreamType
OBStreamType getAlignToStreamType()
Get the stream type to be aligned with.
ob::Align::Align
Align(OBStreamType align_to_stream)
Creaet Align filter.
ob::CompressionFilter
The CompressionFilter class is a subclass of Filter that performs compression.
Definition Filter.hpp:180
ob::CompressionFilter::CompressionFilter
CompressionFilter()
ob::CompressionFilter::setCompressionParams
void setCompressionParams(OBCompressionMode mode, void *params)
Set the compression parameters.
ob::DecimationFilter
Decimation filter,reducing complexity by subsampling depth maps and losing depth details.
Definition Filter.hpp:522
ob::DecimationFilter::getScaleRange
OBUint8PropertyRange getScaleRange()
Get the property range of the decimation filter scale value.
ob::DecimationFilter::getScaleValue
uint8_t getScaleValue()
Get the decimation filter scale value.
ob::DecimationFilter::setScaleValue
void setScaleValue(uint8_t value)
Set the decimation filter scale value.
ob::DecimationFilter::DecimationFilter
DecimationFilter()
ob::DecompressionFilter
The DecompressionFilter class is a subclass of Filter that performs decompression.
Definition Filter.hpp:196
ob::DecompressionFilter::DecompressionFilter
DecompressionFilter()
ob::DisparityTransform
Depth to disparity or disparity to depth.
Definition Filter.hpp:382
ob::DisparityTransform::DisparityTransform
DisparityTransform(bool depth_to_disparity)
Create a disparity transform.
ob::EdgeNoiseRemovalFilter
The edge noise removal filter,removing scattering depth pixels.
Definition Filter.hpp:547
ob::EdgeNoiseRemovalFilter::getMarginLeftThRange
OBUint16PropertyRange getMarginLeftThRange()
Get the edge noise removal filter margin left th range.
ob::EdgeNoiseRemovalFilter::getMarginBottomThRange
OBUint16PropertyRange getMarginBottomThRange()
Get the edge noise removal filter margin bottom th range.
ob::EdgeNoiseRemovalFilter::getMarginRightThRange
OBUint16PropertyRange getMarginRightThRange()
Get the edge noise removal filter margin right th range.
ob::EdgeNoiseRemovalFilter::EdgeNoiseRemovalFilter
EdgeNoiseRemovalFilter()
ob::EdgeNoiseRemovalFilter::getMarginTopThRange
OBUint16PropertyRange getMarginTopThRange()
Get the edge noise removal filter margin top th range.
ob::EdgeNoiseRemovalFilter::getFilterParams
OBEdgeNoiseRemovalFilterParams getFilterParams()
Get the edge noise removal filter params.
ob::EdgeNoiseRemovalFilter::setFilterParams
void setFilterParams(OBEdgeNoiseRemovalFilterParams filterParams)
Set the edge noise removal filter params.
ob::Filter
The Filter class is the base class for all filters in the SDK.
Definition Filter.hpp:27
ob::Filter::is
bool is()
Check if the runtime type of the filter object is compatible with a given type.
Definition Filter.hpp:592
ob::Filter::process
virtual std::shared_ptr< Frame > process(std::shared_ptr< Frame > frame)
Processes a frame synchronously.
ob::Filter::as
std::shared_ptr< T > as()
Convert the filter object to a target type.
Definition Filter.hpp:94
ob::Filter::Filter
Filter()
ob::Filter::Filter
Filter(std::shared_ptr< FilterImpl > impl)
ob::Filter::enable
void enable(bool enable)
enable the filter
ob::Filter::type_
std::string type_
Definition Filter.hpp:104
ob::Filter::~Filter
virtual ~Filter()=default
ob::Filter::impl_
std::shared_ptr< FilterImpl > impl_
Definition Filter.hpp:103
ob::Filter::type
virtual const char * type()
Get the type of filter.
ob::Filter::pushFrame
virtual void pushFrame(std::shared_ptr< Frame > frame)
Pushes the pending frame into the cache for asynchronous processing.
ob::Filter::setCallBack
virtual void setCallBack(FilterCallback callback)
Set the callback function for asynchronous processing.
ob::Filter::reset
virtual void reset()
ReSet the filter, freeing the internal cache, stopping the processing thread, and clearing the pendin...
ob::Filter::isEnabled
bool isEnabled()
Return Enable State.
ob::FormatConvertFilter
The FormatConvertFilter class is a subclass of Filter that performs format conversion.
Definition Filter.hpp:165
ob::FormatConvertFilter::FormatConvertFilter
FormatConvertFilter()
ob::FormatConvertFilter::setFormatConvertType
void setFormatConvertType(OBConvertFormat type)
Set the format conversion type.
ob::HdrMerge
HdrMerge processing block, the processing merges between depth frames with different sub-preset seque...
Definition Filter.hpp:397
ob::HdrMerge::HdrMerge
HdrMerge()
ob::HoleFillingFilter
Hole filling filter,the processing performed depends on the selected hole filling mode.
Definition Filter.hpp:204
ob::HoleFillingFilter::setFilterMode
void setFilterMode(OBHoleFillingMode mode)
Set the HoleFillingFilter mode.
ob::HoleFillingFilter::getFilterMode
OBHoleFillingMode getFilterMode()
Get the HoleFillingFilter mode.
ob::HoleFillingFilter::HoleFillingFilter
HoleFillingFilter()
ob::NoiseRemovalFilter
The noise removal filter,removing scattering depth pixels.
Definition Filter.hpp:488
ob::NoiseRemovalFilter::getDispDiffRange
OBUint16PropertyRange getDispDiffRange()
Get the noise removal filter disp diff range.
ob::NoiseRemovalFilter::setFilterParams
void setFilterParams(OBNoiseRemovalFilterParams filterParams)
Set the noise removal filter params.
ob::NoiseRemovalFilter::getMaxSizeRange
OBUint16PropertyRange getMaxSizeRange()
Get the noise removal filter max size range.
ob::NoiseRemovalFilter::getFilterParams
OBNoiseRemovalFilterParams getFilterParams()
Get the noise removal filter params.
ob::NoiseRemovalFilter::NoiseRemovalFilter
NoiseRemovalFilter()
ob::OBFilterList
Class representing a list of FrameProcessingBlock.
Definition Sensor.hpp:125
ob::PointCloudFilter
The PointCloudFilter class is a subclass of Filter that generates point clouds.
Definition Filter.hpp:112
ob::PointCloudFilter::setCoordinateSystem
void setCoordinateSystem(OBCoordinateSystemType type)
Set the point cloud coordinate system.
ob::PointCloudFilter::setCameraParam
void setCameraParam(OBCameraParam param)
Set the camera parameters.
ob::PointCloudFilter::setPositionDataScaled
void setPositionDataScaled(float scale)
Set the point cloud coordinate data zoom factor.
ob::PointCloudFilter::setCreatePointFormat
void setCreatePointFormat(OBFormat type)
Set the point cloud type parameters.
ob::PointCloudFilter::setFrameAlignState
void setFrameAlignState(bool state)
Set the frame alignment state that will be input to generate point cloud.
ob::PointCloudFilter::PointCloudFilter
PointCloudFilter()
ob::PointCloudFilter::setColorDataNormalization
void setColorDataNormalization(bool state)
Set point cloud color data normalization.
ob::SequenceIdFilter
Create SequenceIdFilter processing block.
Definition Filter.hpp:452
ob::SequenceIdFilter::getSelectSequenceId
int getSelectSequenceId()
Get the current sequence id.
ob::SequenceIdFilter::SequenceIdFilter
SequenceIdFilter()
ob::SequenceIdFilter::selectSequenceId
void selectSequenceId(int sequence_id)
Set the sequenceId filter params.
ob::SequenceIdFilter::getSequenceIdList
OBSequenceIdItem * getSequenceIdList()
Get the current sequence id list.
ob::SequenceIdFilter::getSequenceIdListSize
int getSequenceIdListSize()
Get the sequenceId list size.
ob::SpatialAdvancedFilter
Spatial advanced filter smooths the image by calculating frame with alpha and delta settings alpha de...
Definition Filter.hpp:265
ob::SpatialAdvancedFilter::setFilterParams
void setFilterParams(OBSpatialAdvancedFilterParams params)
Set the spatial advanced filter params.
ob::SpatialAdvancedFilter::getFilterParams
OBSpatialAdvancedFilterParams getFilterParams()
Get the spatial advanced filter params.
ob::SpatialAdvancedFilter::getRadiusRange
OBUint16PropertyRange getRadiusRange()
Get the spatial advanced filter radius range.
ob::SpatialAdvancedFilter::getAlphaRange
OBFloatPropertyRange getAlphaRange()
Get the spatial advanced filter alpha range.
ob::SpatialAdvancedFilter::getDispDiffRange
OBUint16PropertyRange getDispDiffRange()
Get the spatial advanced filter dispdiff range.
ob::SpatialAdvancedFilter::getMagnitudeRange
OBIntPropertyRange getMagnitudeRange()
Get the spatial advanced filter magnitude range.
ob::SpatialAdvancedFilter::SpatialAdvancedFilter
SpatialAdvancedFilter()
ob::SpatialFastFilter
Spatial fast filter smooths the image by calculating frame with filter window size settings.
Definition Filter.hpp:315
ob::SpatialFastFilter::setFilterParams
void setFilterParams(OBSpatialFastFilterParams params)
Set the spatial fast filter params.
ob::SpatialFastFilter::SpatialFastFilter
SpatialFastFilter()
ob::SpatialFastFilter::getSizeRange
OBUint8PropertyRange getSizeRange()
Get the spatial fast filter window size range.
ob::SpatialFastFilter::getFilterParams
OBSpatialFastFilterParams getFilterParams()
Get the spatial fast filter params.
ob::SpatialModerateFilter
Spatial moderate filter smooths the image by calculating frame with filter window size,...
Definition Filter.hpp:342
ob::SpatialModerateFilter::getSizeRange
OBUint8PropertyRange getSizeRange()
Get the spatial moderate filter window size range.
ob::SpatialModerateFilter::setFilterParams
void setFilterParams(OBSpatialModerateFilterParams params)
Set the spatial moderate filter params.
ob::SpatialModerateFilter::getFilterParams
OBSpatialModerateFilterParams getFilterParams()
Get the spatial moderate filter params.
ob::SpatialModerateFilter::getDispDiffRange
OBUint16PropertyRange getDispDiffRange()
Get the spatial moderate filter dispdiff range.
ob::SpatialModerateFilter::getMagnitudeRange
OBUint8PropertyRange getMagnitudeRange()
Get the spatial moderate filter magnitude range.
ob::SpatialModerateFilter::SpatialModerateFilter
SpatialModerateFilter()
ob::TemporalFilter
Temporal filter.
Definition Filter.hpp:227
ob::TemporalFilter::getWeightRange
OBFloatPropertyRange getWeightRange()
Get the TemporalFilter weight range.
ob::TemporalFilter::setDiffScale
void setDiffScale(float value)
Set the TemporalFilter diffscale value.
ob::TemporalFilter::TemporalFilter
TemporalFilter()
ob::TemporalFilter::getDiffScaleRange
OBFloatPropertyRange getDiffScaleRange()
Get the TemporalFilter diffscale range.
ob::TemporalFilter::setWeight
void setWeight(float value)
Set the TemporalFilter weight value.
ob::ThresholdFilter
Creates depth Thresholding filter By controlling min and max options on the block.
Definition Filter.hpp:425
ob::ThresholdFilter::ThresholdFilter
ThresholdFilter()
ob::ThresholdFilter::setValueRange
bool setValueRange(uint16_t min, uint16_t max)
Get the threshold filter max and min range.
ob::ThresholdFilter::getMinRange
OBIntPropertyRange getMinRange()
Get the threshold filter min range.
ob::ThresholdFilter::getMaxRange
OBIntPropertyRange getMaxRange()
Get the threshold filter max range.
ob
Definition Context.hpp:16
ob::FilterCallback
std::function< void(std::shared_ptr< Frame >)> FilterCallback
A callback function that takes a shared pointer to a Frame object as its argument.
Definition Filter.hpp:22
OBCameraParam
Structure for camera parameters.
Definition ObTypes.h:462
OBEdgeNoiseRemovalFilterParams
Definition ObTypes.h:1011
OBFloatPropertyRange
Structure for float range.
Definition ObTypes.h:336
OBIntPropertyRange
Structure for integer range.
Definition ObTypes.h:325
OBNoiseRemovalFilterParams
Definition ObTypes.h:1028
OBSequenceIdItem
SequenceId fliter list item.
Definition ObTypes.h:969
OBSpatialAdvancedFilterParams
Definition ObTypes.h:984
OBSpatialFastFilterParams
Definition ObTypes.h:992
OBSpatialModerateFilterParams
Definition ObTypes.h:997
OBUint16PropertyRange
Structure for float range.
Definition ObTypes.h:347
OBUint8PropertyRange
Structure for float range.
Definition ObTypes.h:358