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
15namespace ob {
16class Frame;
17class OBFilterList;
18
22typedef std::function<void(std::shared_ptr<Frame>)> FilterCallback;
23
27class OB_EXTENSION_API Filter : public std::enable_shared_from_this<Filter> {
28public:
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
102protected:
103 std::shared_ptr<FilterImpl> impl_;
104 std::string type_;
105
106 friend class OBFilterList;
107};
108
113public:
115
122
129
135 void setFrameAlignState(bool state);
136
145 void setPositionDataScaled(float scale);
146
153
160};
161
166public:
168
175};
176
181public:
183
190 void setCompressionParams(OBCompressionMode mode, void *params);
191};
192
197public:
199};
200
205public:
207
215
222};
223
228public:
230
237
243 void setDiffScale(float value);
244
251
257 void setWeight(float value);
258};
259
266public:
268
275
282
289
296
303
310};
311
316public:
324
337};
338
343public:
351
364
377};
378
383public:
384
389 DisparityTransform(bool depth_to_disparity);
390};
391
398public:
400};
401
406public:
411 Align(OBStreamType align_to_stream);
412
419};
420
426public:
428
435
442
446 bool setValueRange(uint16_t min, uint16_t max);
447};
448
453public:
455
461 void selectSequenceId(int sequence_id);
462
469
476
483};
484
489public:
491
498
505
511
517};
518
523public:
525
531 void setScaleValue(uint8_t value);
532
536 uint8_t getScaleValue();
537
542};
543
548public:
550
557
564
570
576
582
588};
589
590
591// Define the is() template function for the Filter class
592template <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
Enumeration value describing the pixel format.
Definition ObTypes.h:216
OBStreamType
Enumeration value describing the type of data stream.
Definition ObTypes.h:179
enum OB_COORDINATE_SYSTEM_TYPE OBCoordinateSystemType
#define OB_EXTENSION_API
Definition ObTypes.h:28
OBCompressionMode
Compression mode.
Definition ObTypes.h:781
OBHoleFillingMode
Hole fillig mode.
Definition ObTypes.h:977
OBConvertFormat
Enumeration of format conversion types.
Definition ObTypes.h:544
Provides SDK structure and enumeration constant definitions (depending on libobsensor/h/ObTypes....
Align for depth to other or other to depth.
Definition Filter.hpp:405
OBStreamType getAlignToStreamType()
Get the stream type to be aligned with.
Align(OBStreamType align_to_stream)
Creaet Align filter.
The CompressionFilter class is a subclass of Filter that performs compression.
Definition Filter.hpp:180
void setCompressionParams(OBCompressionMode mode, void *params)
Set the compression parameters.
Decimation filter,reducing complexity by subsampling depth maps and losing depth details.
Definition Filter.hpp:522
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.
The DecompressionFilter class is a subclass of Filter that performs decompression.
Definition Filter.hpp:196
Depth to disparity or disparity to depth.
Definition Filter.hpp:382
DisparityTransform(bool depth_to_disparity)
Create a disparity transform.
The edge noise removal filter,removing scattering depth pixels.
Definition Filter.hpp:547
OBUint16PropertyRange getMarginLeftThRange()
Get the edge noise removal filter margin left th range.
OBUint16PropertyRange getMarginBottomThRange()
Get the edge noise removal filter margin bottom th range.
OBUint16PropertyRange getMarginRightThRange()
Get the edge noise removal filter margin right th range.
OBUint16PropertyRange getMarginTopThRange()
Get the edge noise removal filter margin top th range.
OBEdgeNoiseRemovalFilterParams getFilterParams()
Get the edge noise removal filter params.
void setFilterParams(OBEdgeNoiseRemovalFilterParams filterParams)
Set the edge noise removal filter params.
The Filter class is the base class for all filters in the SDK.
Definition Filter.hpp:27
bool is()
Check if the runtime type of the filter object is compatible with a given type.
Definition Filter.hpp:592
virtual std::shared_ptr< Frame > process(std::shared_ptr< Frame > frame)
Processes a frame synchronously.
std::shared_ptr< T > as()
Convert the filter object to a target type.
Definition Filter.hpp:94
Filter(std::shared_ptr< FilterImpl > impl)
void enable(bool enable)
enable the filter
std::string type_
Definition Filter.hpp:104
virtual ~Filter()=default
std::shared_ptr< FilterImpl > impl_
Definition Filter.hpp:103
virtual const char * type()
Get the type of filter.
virtual void pushFrame(std::shared_ptr< Frame > frame)
Pushes the pending frame into the cache for asynchronous processing.
virtual void setCallBack(FilterCallback callback)
Set the callback function for asynchronous processing.
virtual void reset()
ReSet the filter, freeing the internal cache, stopping the processing thread, and clearing the pendin...
bool isEnabled()
Return Enable State.
The FormatConvertFilter class is a subclass of Filter that performs format conversion.
Definition Filter.hpp:165
void setFormatConvertType(OBConvertFormat type)
Set the format conversion type.
HdrMerge processing block, the processing merges between depth frames with different sub-preset seque...
Definition Filter.hpp:397
Hole filling filter,the processing performed depends on the selected hole filling mode.
Definition Filter.hpp:204
void setFilterMode(OBHoleFillingMode mode)
Set the HoleFillingFilter mode.
OBHoleFillingMode getFilterMode()
Get the HoleFillingFilter mode.
The noise removal filter,removing scattering depth pixels.
Definition Filter.hpp:488
OBUint16PropertyRange getDispDiffRange()
Get the noise removal filter disp diff range.
void setFilterParams(OBNoiseRemovalFilterParams filterParams)
Set the noise removal filter params.
OBUint16PropertyRange getMaxSizeRange()
Get the noise removal filter max size range.
OBNoiseRemovalFilterParams getFilterParams()
Get the noise removal filter params.
Class representing a list of FrameProcessingBlock.
Definition Sensor.hpp:125
The PointCloudFilter class is a subclass of Filter that generates point clouds.
Definition Filter.hpp:112
void setCoordinateSystem(OBCoordinateSystemType type)
Set the point cloud coordinate system.
void setCameraParam(OBCameraParam param)
Set the camera parameters.
void setPositionDataScaled(float scale)
Set the point cloud coordinate data zoom factor.
void setCreatePointFormat(OBFormat type)
Set the point cloud type parameters.
void setFrameAlignState(bool state)
Set the frame alignment state that will be input to generate point cloud.
void setColorDataNormalization(bool state)
Set point cloud color data normalization.
Create SequenceIdFilter processing block.
Definition Filter.hpp:452
int getSelectSequenceId()
Get the current sequence id.
void selectSequenceId(int sequence_id)
Set the sequenceId filter params.
OBSequenceIdItem * getSequenceIdList()
Get the current sequence id list.
int getSequenceIdListSize()
Get the sequenceId list size.
Spatial advanced filter smooths the image by calculating frame with alpha and delta settings alpha de...
Definition Filter.hpp:265
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.
OBFloatPropertyRange getAlphaRange()
Get the spatial advanced filter alpha range.
OBUint16PropertyRange getDispDiffRange()
Get the spatial advanced filter dispdiff range.
OBIntPropertyRange getMagnitudeRange()
Get the spatial advanced filter magnitude range.
Spatial fast filter smooths the image by calculating frame with filter window size settings.
Definition Filter.hpp:315
void setFilterParams(OBSpatialFastFilterParams params)
Set the spatial fast filter params.
OBUint8PropertyRange getSizeRange()
Get the spatial fast filter window size range.
OBSpatialFastFilterParams getFilterParams()
Get the spatial fast filter params.
Spatial moderate filter smooths the image by calculating frame with filter window size,...
Definition Filter.hpp:342
OBUint8PropertyRange getSizeRange()
Get the spatial moderate filter window size range.
void setFilterParams(OBSpatialModerateFilterParams params)
Set the spatial moderate filter params.
OBSpatialModerateFilterParams getFilterParams()
Get the spatial moderate filter params.
OBUint16PropertyRange getDispDiffRange()
Get the spatial moderate filter dispdiff range.
OBUint8PropertyRange getMagnitudeRange()
Get the spatial moderate filter magnitude range.
Temporal filter.
Definition Filter.hpp:227
OBFloatPropertyRange getWeightRange()
Get the TemporalFilter weight range.
void setDiffScale(float value)
Set the TemporalFilter diffscale value.
OBFloatPropertyRange getDiffScaleRange()
Get the TemporalFilter diffscale range.
void setWeight(float value)
Set the TemporalFilter weight value.
Creates depth Thresholding filter By controlling min and max options on the block.
Definition Filter.hpp:425
bool setValueRange(uint16_t min, uint16_t max)
Get the threshold filter max and min range.
OBIntPropertyRange getMinRange()
Get the threshold filter min range.
OBIntPropertyRange getMaxRange()
Get the threshold filter max range.
Definition Context.hpp:16
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
Structure for camera parameters.
Definition ObTypes.h:462
Structure for float range.
Definition ObTypes.h:336
Structure for integer range.
Definition ObTypes.h:325
SequenceId fliter list item.
Definition ObTypes.h:969
Structure for float range.
Definition ObTypes.h:347
Structure for float range.
Definition ObTypes.h:358