OrbbecSDK 2.5.5
OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras
Loading...
Searching...
No Matches
Filter.hpp
Go to the documentation of this file.
1// Copyright (c) Orbbec Inc. All Rights Reserved.
2// Licensed under the MIT License.
3
9#pragma once
10
11#include "Types.hpp"
12#include "Error.hpp"
13#include "Frame.hpp"
15#include "libobsensor/h/Frame.h"
16#include <functional>
17#include <memory>
18#include <map>
19#include <string>
20#include <iostream>
21#include <vector>
22#include <typeinfo>
23#include <typeindex>
24#include <unordered_map>
25#include <cstring>
26
27namespace ob {
28
32typedef std::function<void(std::shared_ptr<Frame>)> FilterCallback;
33
37template <typename T> struct RangeTraits {
38 using valueType = void;
39};
40
41template <> struct RangeTraits<OBUint8PropertyRange> {
42 using valueType = uint8_t;
43};
44
46 using valueType = uint16_t;
47};
48
49template <> struct RangeTraits<OBIntPropertyRange> {
50 using valueType = uint32_t;
51};
52
53template <> struct RangeTraits<OBFloatPropertyRange> {
54 using valueType = float;
55};
56
60template <typename T> T getPropertyRange(const OBFilterConfigSchemaItem &item, const double cur) {
61 // If T type is illegal, T will be void
62 using valueType = typename RangeTraits<T>::valueType;
63 T range{};
64 // Compilate error will be reported here if T is void
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);
70 return range;
71}
72
76class Filter : public std::enable_shared_from_this<Filter> {
77protected:
78 ob_filter *impl_ = nullptr;
79 std::string name_;
81 std::vector<OBFilterConfigSchemaItem> configSchemaVec_;
82
83protected:
87 Filter() = default;
88
89 virtual void init(ob_filter *impl) {
90 impl_ = impl;
91 ob_error *error = nullptr;
93 Error::handle(&error);
94
95 auto configSchemaList = ob_filter_get_config_schema_list(impl_, &error);
96 Error::handle(&error);
97
98 auto count = ob_filter_config_schema_list_get_count(configSchemaList, &error);
99 Error::handle(&error);
100
101 for(uint32_t i = 0; i < count; i++) {
102 auto item = ob_filter_config_schema_list_get_item(configSchemaList, i, &error);
103 Error::handle(&error);
104 configSchemaVec_.emplace_back(item);
105 }
106
107 ob_delete_filter_config_schema_list(configSchemaList, &error);
108 Error::handle(&error);
109 }
110
111public:
112 explicit Filter(ob_filter *impl) {
113 init(impl);
114 }
115
116 virtual ~Filter() noexcept {
117 if(impl_ != nullptr) {
118 ob_error *error = nullptr;
119 ob_delete_filter(impl_, &error);
120 Error::handle(&error, false);
121 }
122 }
123
130 return impl_;
131 }
132
138 virtual const std::string &getName() const {
139 return name_;
140 }
141
146 virtual void reset() const {
147 ob_error *error = nullptr;
148 ob_filter_reset(impl_, &error);
149 Error::handle(&error);
150 }
151
155 virtual void enable(bool enable) const {
156 ob_error *error = nullptr;
157 ob_filter_enable(impl_, enable, &error);
158 Error::handle(&error);
159 }
160
164 virtual bool isEnabled() const {
165 ob_error *error = nullptr;
166 bool enable = ob_filter_is_enabled(impl_, &error);
167 Error::handle(&error);
168 return enable;
169 }
170
177 virtual std::shared_ptr<Frame> process(std::shared_ptr<const Frame> frame) const {
178 ob_error *error = nullptr;
179 auto result = ob_filter_process(impl_, frame->getImpl(), &error);
180 Error::handle(&error);
181 if(!result) {
182 return nullptr;
183 }
184 return std::make_shared<Frame>(result);
185 }
186
192 virtual void pushFrame(std::shared_ptr<Frame> frame) const {
193 ob_error *error = nullptr;
194 ob_filter_push_frame(impl_, frame->getImpl(), &error);
195 Error::handle(&error);
196 }
197
203 virtual void setCallBack(FilterCallback callback) {
204 callback_ = callback;
205 ob_error *error = nullptr;
206 ob_filter_set_callback(impl_, &Filter::filterCallback, this, &error);
207 Error::handle(&error);
208 }
209
217 virtual std::string getConfigSchema() const {
218 ob_error *error = nullptr;
219 auto schema = ob_filter_get_config_schema(impl_, &error);
220 Error::handle(&error);
221 return schema;
222 }
223
230 virtual std::vector<OBFilterConfigSchemaItem> getConfigSchemaVec() const {
231 return configSchemaVec_;
232 }
233
243 virtual void setConfigValue(const std::string &configName, double value) const {
244 ob_error *error = nullptr;
245 ob_filter_set_config_value(impl_, configName.c_str(), value, &error);
246 Error::handle(&error);
247 }
248
258 virtual double getConfigValue(const std::string &configName) const {
259 ob_error *error = nullptr;
260 double value = ob_filter_get_config_value(impl_, configName.c_str(), &error);
261 Error::handle(&error);
262 return value;
263 }
264
265private:
266 static void filterCallback(ob_frame *frame, void *userData) {
267 auto filter = static_cast<Filter *>(userData);
268 filter->callback_(std::make_shared<Frame>(frame));
269 }
270
271public:
272 // The following interfaces are deprecated and are retained here for compatibility purposes.
273 virtual const char *type() {
274 return getName().c_str();
275 }
276
283 template <typename T> bool is();
284
285 template <typename T> std::shared_ptr<T> as() {
286 if(!is<T>()) {
287 throw std::runtime_error("unsupported operation, object's type is not require type");
288 }
289
290 return std::static_pointer_cast<T>(shared_from_this());
291 }
292};
293
298public:
302 static std::shared_ptr<Filter> createFilter(const std::string &name) {
303 ob_error *error = nullptr;
304 auto impl = ob_create_filter(name.c_str(), &error);
305 Error::handle(&error);
306 return std::make_shared<Filter>(impl);
307 }
308
316 static std::shared_ptr<Filter> createPrivateFilter(const std::string &name, const std::string &activationKey) {
317 ob_error *error = nullptr;
318 auto impl = ob_create_private_filter(name.c_str(), activationKey.c_str(), &error);
319 Error::handle(&error);
320 return std::make_shared<Filter>(impl);
321 }
322
330 static std::string getFilterVendorSpecificCode(const std::string &name) {
331 ob_error *error = nullptr;
332 auto code = ob_filter_get_vendor_specific_code(name.c_str(), &error);
333 Error::handle(&error);
334 return code;
335 }
336};
337
341class PointCloudFilter : public Filter {
342public:
344 ob_error *error = nullptr;
345 auto impl = ob_create_filter("PointCloudFilter", &error);
346 Error::handle(&error);
347 init(impl);
348 }
349
350 virtual ~PointCloudFilter() noexcept override = default;
351
358 setConfigValue("pointFormat", static_cast<double>(format));
359 }
360
369 void setCoordinateDataScaled(float factor) {
370 setConfigValue("coordinateDataScale", factor);
371 }
372
381 void setColorDataNormalization(bool state) {
382 setConfigValue("colorDataNormalization", state);
383 }
384
391 setConfigValue("coordinateSystemType", static_cast<double>(type));
392 }
393
394public:
395 // The following interfaces are deprecated and are retained here for compatibility purposes.
396 void setPositionDataScaled(float scale) {
398 }
399
400 // The following interfaces are deprecated and are retained here for compatibility purposes.
401 void setFrameAlignState(bool state) {
402 (void)state; // to complie
403 }
404 // The following interfaces are deprecated and are retained here for compatibility purposes.
406 (void)param;
407 }
408};
409
413class Align : public Filter {
414public:
415 Align(OBStreamType alignToStreamType) {
416 ob_error *error = nullptr;
417 auto impl = ob_create_filter("Align", &error);
418 Error::handle(&error);
419 init(impl);
420
421 setConfigValue("AlignType", static_cast<double>(alignToStreamType));
422 }
423
424 virtual ~Align() noexcept override = default;
425
427 return static_cast<OBStreamType>(static_cast<int>(getConfigValue("AlignType")));
428 }
429
440 void setMatchTargetResolution(bool state) {
441 setConfigValue("MatchTargetRes", state);
442 }
443
450 void setAlignToStreamProfile(std::shared_ptr<const StreamProfile> profile) {
451 ob_error *error = nullptr;
452 ob_align_filter_set_align_to_stream_profile(impl_, profile->getImpl(), &error);
453 Error::handle(&error);
454 }
455};
456
461public:
463 ob_error *error = nullptr;
464 auto impl = ob_create_filter("FormatConverter", &error);
465 Error::handle(&error);
466 init(impl);
467 }
468
469 virtual ~FormatConvertFilter() noexcept override = default;
470
477 setConfigValue("convertType", static_cast<double>(type));
478 }
479};
480
486class HdrMerge : public Filter {
487public:
489 ob_error *error = nullptr;
490 auto impl = ob_create_filter("HDRMerge", &error);
491 Error::handle(&error);
492 init(impl);
493 }
494
495 virtual ~HdrMerge() noexcept override = default;
496};
497
501class SequenceIdFilter : public Filter {
502private:
503 std::map<float, std::string> sequenceIdList_{ { 0.f, "all" }, { 1.f, "1" } };
504 OBSequenceIdItem *outputSequenceIdList_ = nullptr;
505
506 void initSequenceIdList() {
507 outputSequenceIdList_ = new OBSequenceIdItem[sequenceIdList_.size()];
508
509 int i = 0;
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';
514 ++i;
515 }
516 }
517
518public:
520 ob_error *error = nullptr;
521 auto impl = ob_create_filter("SequenceIdFilter", &error);
522 Error::handle(&error);
523 init(impl);
524 initSequenceIdList();
525 }
526
527 virtual ~SequenceIdFilter() noexcept override {
528 if(outputSequenceIdList_) {
529 delete[] outputSequenceIdList_;
530 outputSequenceIdList_ = nullptr;
531 }
532 }
533
539 void selectSequenceId(int sequence_id) {
540 setConfigValue("sequenceid", static_cast<double>(sequence_id));
541 }
542
549 return static_cast<int>(getConfigValue("sequenceid"));
550 }
551
553 return outputSequenceIdList_;
554 }
555
562 return static_cast<int>(sequenceIdList_.size());
563 }
564};
565
569class DecimationFilter : public Filter {
570public:
572 ob_error *error = nullptr;
573 auto impl = ob_create_filter("DecimationFilter", &error);
574 Error::handle(&error);
575 init(impl);
576 }
577
578 virtual ~DecimationFilter() noexcept override = default;
579
585 void setScaleValue(uint8_t value) {
586 setConfigValue("decimate", static_cast<double>(value));
587 }
588
592 uint8_t getScaleValue() {
593 return static_cast<uint8_t>(getConfigValue("decimate"));
594 }
595
600 OBUint8PropertyRange scaleRange{};
601 if(configSchemaVec_.size() != 0) {
602 const auto &item = configSchemaVec_[0];
603 scaleRange = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("decimate"));
604 }
605 return scaleRange;
606 }
607};
608
613class ThresholdFilter : public Filter {
614public:
616 ob_error *error = nullptr;
617 auto impl = ob_create_filter("ThresholdFilter", &error);
618 Error::handle(&error);
619 init(impl);
620 }
621
622 virtual ~ThresholdFilter() noexcept override = default;
623
630 OBIntPropertyRange range{};
631 const auto &schemaVec = getConfigSchemaVec();
632 for(const auto &item: schemaVec) {
633 if(strcmp(item.name, "min") == 0) {
635 break;
636 }
637 }
638 return range;
639 }
640
647 OBIntPropertyRange range{};
648 const auto &schemaVec = getConfigSchemaVec();
649 for(const auto &item: schemaVec) {
650 if(strcmp(item.name, "max") == 0) {
652 break;
653 }
654 }
655 return range;
656 }
657
661 bool setValueRange(uint16_t min, uint16_t max) {
662 if(min >= max) {
663 return false;
664 }
665 setConfigValue("min", min);
666 setConfigValue("max", max);
667 return true;
668 }
669};
670
677public:
678 SpatialAdvancedFilter(const std::string &activationKey = "") {
679 ob_error *error = nullptr;
680 auto impl = ob_create_private_filter("SpatialAdvancedFilter", activationKey.c_str(), &error);
681 Error::handle(&error);
682 init(impl);
683 }
684
685 virtual ~SpatialAdvancedFilter() noexcept override = default;
686
693 OBFloatPropertyRange range{};
694 const auto &schemaVec = getConfigSchemaVec();
695 for(const auto &item: schemaVec) {
696 if(strcmp(item.name, "alpha") == 0) {
698 break;
699 }
700 }
701 return range;
702 }
703
710 OBUint16PropertyRange range{};
711 const auto &schemaVec = getConfigSchemaVec();
712 for(const auto &item: schemaVec) {
713 if(strcmp(item.name, "disp_diff") == 0) {
715 break;
716 }
717 }
718 return range;
719 }
720
727 OBUint16PropertyRange range{};
728 const auto &schemaVec = getConfigSchemaVec();
729 for(const auto &item: schemaVec) {
730 if(strcmp(item.name, "radius") == 0) {
732 break;
733 }
734 }
735 return range;
736 }
737
744 OBIntPropertyRange range{};
745 const auto &schemaVec = getConfigSchemaVec();
746 for(const auto &item: schemaVec) {
747 if(strcmp(item.name, "magnitude") == 0) {
748 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("magnitude"));
749 break;
750 }
751 }
752 return range;
753 }
754
762 params.alpha = static_cast<float>(getConfigValue("alpha"));
763 params.disp_diff = static_cast<uint16_t>(getConfigValue("disp_diff"));
764 params.magnitude = static_cast<uint8_t>(getConfigValue("magnitude"));
765 params.radius = static_cast<uint16_t>(getConfigValue("radius"));
766 return params;
767 }
768
775 setConfigValue("alpha", params.alpha);
776 setConfigValue("disp_diff", params.disp_diff);
777 setConfigValue("magnitude", params.magnitude);
778 setConfigValue("radius", params.radius);
779 }
780};
781
786class SpatialFastFilter : public Filter {
787public:
788 SpatialFastFilter(const std::string &activationKey = "") {
789 ob_error *error = nullptr;
790 auto impl = ob_create_private_filter("SpatialFastFilter", activationKey.c_str(), &error);
791 Error::handle(&error);
792 init(impl);
793 }
794
795 virtual ~SpatialFastFilter() noexcept override = default;
796
803 OBIntPropertyRange range{};
804 const auto &schemaVec = getConfigSchemaVec();
805 for(const auto &item: schemaVec) {
806 if(strcmp(item.name, "radius") == 0) {
808 break;
809 }
810 }
811 return range;
812 }
813
821 params.radius = static_cast<uint8_t>(getConfigValue("radius"));
822 return params;
823 }
824
831 setConfigValue("radius", params.radius);
832 }
833};
834
840public:
841 SpatialModerateFilter(const std::string &activationKey = "") {
842 ob_error *error = nullptr;
843 auto impl = ob_create_private_filter("SpatialModerateFilter", activationKey.c_str(), &error);
844 Error::handle(&error);
845 init(impl);
846 }
847
848 virtual ~SpatialModerateFilter() noexcept override = default;
849
856 OBIntPropertyRange range{};
857 const auto &schemaVec = getConfigSchemaVec();
858 for(const auto &item: schemaVec) {
859 if(strcmp(item.name, "magnitude") == 0) {
860 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("magnitude"));
861 break;
862 }
863 }
864 return range;
865 }
866
873 OBIntPropertyRange range{};
874 const auto &schemaVec = getConfigSchemaVec();
875 for(const auto &item: schemaVec) {
876 if(strcmp(item.name, "radius") == 0) {
878 break;
879 }
880 }
881 return range;
882 }
883
890 OBIntPropertyRange range{};
891 const auto &schemaVec = getConfigSchemaVec();
892 for(const auto &item: schemaVec) {
893 if(strcmp(item.name, "disp_diff") == 0) {
894 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("disp_diff"));
895 break;
896 }
897 }
898 return range;
899 }
900
908 params.magnitude = static_cast<uint8_t>(getConfigValue("magnitude"));
909 params.radius = static_cast<uint8_t>(getConfigValue("radius"));
910 params.disp_diff = static_cast<uint16_t>(getConfigValue("disp_diff"));
911 return params;
912 }
913
920 setConfigValue("magnitude", params.magnitude);
921 setConfigValue("radius", params.radius);
922 setConfigValue("disp_diff", params.disp_diff);
923 }
924};
925
929class HoleFillingFilter : public Filter {
930public:
931 HoleFillingFilter(const std::string &activationKey = "") {
932 ob_error *error = nullptr;
933 auto impl = ob_create_private_filter("HoleFillingFilter", activationKey.c_str(), &error);
934 Error::handle(&error);
935 init(impl);
936 }
937
938 ~HoleFillingFilter() noexcept override = default;
939
946 setConfigValue("hole_filling_mode", static_cast<double>(mode));
947 }
948
955 return static_cast<OBHoleFillingMode>(static_cast<int>(getConfigValue("hole_filling_mode")));
956 }
957};
958
963public:
964 NoiseRemovalFilter(const std::string &activationKey = "") {
965 ob_error *error = nullptr;
966 auto impl = ob_create_private_filter("NoiseRemovalFilter", activationKey.c_str(), &error);
967 Error::handle(&error);
968 init(impl);
969 }
970
971 ~NoiseRemovalFilter() noexcept override = default;
972
979 setConfigValue("max_size", static_cast<double>(filterParams.max_size));
980 setConfigValue("min_diff", static_cast<double>(filterParams.disp_diff));
981 // todo:set noise remove type
982 }
983
991 param.max_size = static_cast<uint16_t>(getConfigValue("max_size"));
992 param.disp_diff = static_cast<uint16_t>(getConfigValue("min_diff"));
993 // todo: type is not set
994 return param;
995 }
996
1002 OBUint16PropertyRange range{};
1003 const auto &schemaVec = getConfigSchemaVec();
1004 for(const auto &item: schemaVec) {
1005 if(strcmp(item.name, "min_diff") == 0) {
1007 break;
1008 }
1009 }
1010 return range;
1011 }
1012
1018 OBUint16PropertyRange range{};
1019 const auto &schemaVec = getConfigSchemaVec();
1020 for(const auto &item: schemaVec) {
1021 if(strcmp(item.name, "max_size") == 0) {
1023 break;
1024 }
1025 }
1026 return range;
1027 }
1028};
1029
1033class TemporalFilter : public Filter {
1034public:
1035 TemporalFilter(const std::string &activationKey = "") {
1036 ob_error *error = nullptr;
1037 auto impl = ob_create_private_filter("TemporalFilter", activationKey.c_str(), &error);
1038 Error::handle(&error);
1039 init(impl);
1040 }
1041
1042 ~TemporalFilter() noexcept override = default;
1043
1050 OBFloatPropertyRange range{};
1051 const auto &schemaVec = getConfigSchemaVec();
1052 for(const auto &item: schemaVec) {
1053 if(strcmp(item.name, "diff_scale") == 0) {
1054 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("diff_scale"));
1055 break;
1056 }
1057 }
1058 return range;
1059 }
1060
1066 void setDiffScale(float value) {
1067 setConfigValue("diff_scale", static_cast<double>(value));
1068 }
1069
1076 OBFloatPropertyRange range{};
1077 const auto &schemaVec = getConfigSchemaVec();
1078 for(const auto &item: schemaVec) {
1079 if(strcmp(item.name, "weight") == 0) {
1081 break;
1082 }
1083 }
1084 return range;
1085 }
1086
1092 void setWeight(float value) {
1093 setConfigValue("weight", static_cast<double>(value));
1094 }
1095};
1096
1101public:
1102 DisparityTransform(const std::string &activationKey = "") {
1103 ob_error *error = nullptr;
1104 auto impl = ob_create_private_filter("DisparityTransform", activationKey.c_str(), &error);
1105 Error::handle(&error);
1106 init(impl);
1107 }
1108
1109 ~DisparityTransform() noexcept override = default;
1110};
1111
1113private:
1114 ob_filter_list_t *impl_;
1115
1116public:
1117 explicit OBFilterList(ob_filter_list_t *impl) : impl_(impl) {}
1118
1119 ~OBFilterList() noexcept {
1120 ob_error *error = nullptr;
1121 ob_delete_filter_list(impl_, &error);
1122 Error::handle(&error, false);
1123 }
1124
1130 uint32_t getCount() const {
1131 ob_error *error = nullptr;
1132 auto count = ob_filter_list_get_count(impl_, &error);
1133 Error::handle(&error);
1134 return count;
1135 }
1136
1143 std::shared_ptr<Filter> getFilter(uint32_t index) {
1144 ob_error *error = nullptr;
1145 auto filter = ob_filter_list_get_filter(impl_, index, &error);
1146 Error::handle(&error);
1147 return std::make_shared<Filter>(filter);
1148 }
1149
1150public:
1151 // The following interfaces are deprecated and are retained here for compatibility purposes.
1152 uint32_t count() const {
1153 return getCount();
1154 }
1155};
1156
1160inline const std::unordered_map<std::string, std::type_index> &getFilterTypeMap() {
1161 static const std::unordered_map<std::string, std::type_index> filterTypeMap = {
1162 { "PointCloudFilter", typeid(PointCloudFilter) }, { "Align", typeid(Align) },
1163 { "FormatConverter", typeid(FormatConvertFilter) }, { "HDRMerge", typeid(HdrMerge) },
1164 { "SequenceIdFilter", typeid(SequenceIdFilter) }, { "DecimationFilter", typeid(DecimationFilter) },
1165 { "ThresholdFilter", typeid(ThresholdFilter) }, { "SpatialAdvancedFilter", typeid(SpatialAdvancedFilter) },
1166 { "HoleFillingFilter", typeid(HoleFillingFilter) }, { "NoiseRemovalFilter", typeid(NoiseRemovalFilter) },
1167 { "TemporalFilter", typeid(TemporalFilter) }, { "DisparityTransform", typeid(DisparityTransform) },
1168 { "SpatialFastFilter", typeid(SpatialFastFilter) }, { "SpatialModerateFilter", typeid(SpatialModerateFilter) },
1169 };
1170 return filterTypeMap;
1171}
1172
1179template <typename T> bool Filter::is() {
1180 std::string name = type();
1181
1182 const auto &filterTypeMap = getFilterTypeMap();
1183 auto it = filterTypeMap.find(name);
1184 if(it != filterTypeMap.end()) {
1185 return std::type_index(typeid(T)) == it->second;
1186 }
1187 return false;
1188}
1189
1190} // namespace ob
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
Definition ObTypes.h:33
OBFormat
Enumeration value describing the pixel format.
Definition ObTypes.h:199
OBStreamType
Enumeration value describing the type of data stream.
Definition ObTypes.h:146
struct ob_filter_t ob_filter
Definition ObTypes.h:34
enum OB_COORDINATE_SYSTEM_TYPE OBCoordinateSystemType
OBHoleFillingMode
Hole fillig mode.
Definition ObTypes.h:1006
OBConvertFormat
Enumeration of format conversion types.
Definition ObTypes.h:535
Align for depth to other or other to depth.
Definition Filter.hpp:413
Align(OBStreamType alignToStreamType)
Definition Filter.hpp:415
virtual ~Align() noexcept override=default
OBStreamType getAlignToStreamType()
Definition Filter.hpp:426
void setMatchTargetResolution(bool state)
Sets whether the output frame resolution should match the target resolution. When enabled,...
Definition Filter.hpp:440
void setAlignToStreamProfile(std::shared_ptr< const StreamProfile > profile)
Set the Align To Stream Profile.
Definition Filter.hpp:450
Decimation filter, reducing complexity by subsampling depth maps and losing depth details.
Definition Filter.hpp:569
virtual ~DecimationFilter() noexcept override=default
OBUint8PropertyRange getScaleRange()
Get the property range of the decimation filter scale value.
Definition Filter.hpp:599
uint8_t getScaleValue()
Get the decimation filter scale value.
Definition Filter.hpp:592
void setScaleValue(uint8_t value)
Set the decimation filter scale value.
Definition Filter.hpp:585
Depth to disparity or disparity to depth.
Definition Filter.hpp:1100
DisparityTransform(const std::string &activationKey="")
Definition Filter.hpp:1102
~DisparityTransform() noexcept override=default
static void handle(ob_error **error, bool throw_exception=true)
A static function to handle the ob_error and throw an exception if needed.
Definition Error.hpp:38
A factory class for creating filters.
Definition Filter.hpp:297
static std::string getFilterVendorSpecificCode(const std::string &name)
Get the vendor specific code of a filter by filter name.
Definition Filter.hpp:330
static std::shared_ptr< Filter > createFilter(const std::string &name)
Create a filter by name.
Definition Filter.hpp:302
static std::shared_ptr< Filter > createPrivateFilter(const std::string &name, const std::string &activationKey)
Create a private filter by name and activation key.
Definition Filter.hpp:316
The Filter class is the base class for all filters in the SDK.
Definition Filter.hpp:76
FilterCallback callback_
Definition Filter.hpp:80
bool is()
Check if the runtime type of the filter object is compatible with a given type.
Definition Filter.hpp:1179
virtual void init(ob_filter *impl)
Definition Filter.hpp:89
std::shared_ptr< T > as()
Definition Filter.hpp:285
virtual const std::string & getName() const
Get the type of filter.
Definition Filter.hpp:138
virtual std::vector< OBFilterConfigSchemaItem > getConfigSchemaVec() const
Get the Config Schema Vec object.
Definition Filter.hpp:230
virtual void enable(bool enable) const
enable the filter
Definition Filter.hpp:155
std::string name_
Definition Filter.hpp:79
virtual void setConfigValue(const std::string &configName, double value) const
Set the filter config value by name.
Definition Filter.hpp:243
virtual std::string getConfigSchema() const
Get config schema of the filter.
Definition Filter.hpp:217
std::vector< OBFilterConfigSchemaItem > configSchemaVec_
Definition Filter.hpp:81
virtual bool isEnabled() const
Return Enable State.
Definition Filter.hpp:164
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.
Definition Filter.hpp:192
virtual std::shared_ptr< Frame > process(std::shared_ptr< const Frame > frame) const
Processes a frame synchronously.
Definition Filter.hpp:177
ob_filter * getImpl() const
Get the Impl object of the filter.
Definition Filter.hpp:129
virtual void reset() const
Reset the filter, freeing the internal cache, stopping the processing thread, and clearing the pendin...
Definition Filter.hpp:146
ob_filter * impl_
Definition Filter.hpp:78
virtual const char * type()
Definition Filter.hpp:273
virtual double getConfigValue(const std::string &configName) const
Get the Config Value object by name.
Definition Filter.hpp:258
virtual void setCallBack(FilterCallback callback)
Set the callback function for asynchronous processing.
Definition Filter.hpp:203
Filter(ob_filter *impl)
Definition Filter.hpp:112
virtual ~Filter() noexcept
Definition Filter.hpp:116
The FormatConvertFilter class is a subclass of Filter that performs format conversion.
Definition Filter.hpp:460
virtual ~FormatConvertFilter() noexcept override=default
void setFormatConvertType(OBConvertFormat type)
Set the format conversion type.
Definition Filter.hpp:476
HdrMerge processing block, the processing merges between depth frames with different sub-preset seque...
Definition Filter.hpp:486
virtual ~HdrMerge() noexcept override=default
Hole filling filter,the processing performed depends on the selected hole filling mode.
Definition Filter.hpp:929
void setFilterMode(OBHoleFillingMode mode)
Set the HoleFillingFilter mode.
Definition Filter.hpp:945
HoleFillingFilter(const std::string &activationKey="")
Definition Filter.hpp:931
OBHoleFillingMode getFilterMode()
Get the HoleFillingFilter mode.
Definition Filter.hpp:954
~HoleFillingFilter() noexcept override=default
The noise removal filter,removing scattering depth pixels.
Definition Filter.hpp:962
OBUint16PropertyRange getDispDiffRange()
Get the noise removal filter disp diff range.
Definition Filter.hpp:1001
void setFilterParams(OBNoiseRemovalFilterParams filterParams)
Set the noise removal filter params.
Definition Filter.hpp:978
NoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:964
~NoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMaxSizeRange()
Get the noise removal filter max size range.
Definition Filter.hpp:1017
OBNoiseRemovalFilterParams getFilterParams()
Get the noise removal filter params.
Definition Filter.hpp:989
~OBFilterList() noexcept
Definition Filter.hpp:1119
uint32_t getCount() const
Get the number of filters.
Definition Filter.hpp:1130
uint32_t count() const
Definition Filter.hpp:1152
std::shared_ptr< Filter > getFilter(uint32_t index)
Get the Filter object at the specified index.
Definition Filter.hpp:1143
OBFilterList(ob_filter_list_t *impl)
Definition Filter.hpp:1117
The PointCloudFilter class is a subclass of Filter that generates point clouds.
Definition Filter.hpp:341
void setCoordinateSystem(OBCoordinateSystemType type)
Set the point cloud coordinate system.
Definition Filter.hpp:390
void setCoordinateDataScaled(float factor)
Set the point cloud coordinate data zoom factor.
Definition Filter.hpp:369
void setCameraParam(OBCameraParam param)
Definition Filter.hpp:405
void setPositionDataScaled(float scale)
Definition Filter.hpp:396
void setCreatePointFormat(OBFormat format)
Set the output pointcloud frame format.
Definition Filter.hpp:357
virtual ~PointCloudFilter() noexcept override=default
void setFrameAlignState(bool state)
Definition Filter.hpp:401
void setColorDataNormalization(bool state)
Set point cloud color data normalization.
Definition Filter.hpp:381
Create SequenceIdFilter processing block.
Definition Filter.hpp:501
int getSelectSequenceId()
Get the current sequence id.
Definition Filter.hpp:548
void selectSequenceId(int sequence_id)
Set the sequenceId filter params.
Definition Filter.hpp:539
virtual ~SequenceIdFilter() noexcept override
Definition Filter.hpp:527
OBSequenceIdItem * getSequenceIdList()
Definition Filter.hpp:552
int getSequenceIdListSize()
Get the sequenceId list size.
Definition Filter.hpp:561
Spatial advanced filte smooths the image by calculating frame with alpha and delta settings alpha def...
Definition Filter.hpp:676
void setFilterParams(OBSpatialAdvancedFilterParams params)
Set the spatial advanced filter params.
Definition Filter.hpp:774
OBSpatialAdvancedFilterParams getFilterParams()
Get the spatial advanced filter params.
Definition Filter.hpp:760
OBUint16PropertyRange getRadiusRange()
Get the spatial advanced filter radius range.
Definition Filter.hpp:726
SpatialAdvancedFilter(const std::string &activationKey="")
Definition Filter.hpp:678
OBFloatPropertyRange getAlphaRange()
Get the spatial advanced filter alpha range.
Definition Filter.hpp:692
OBUint16PropertyRange getDispDiffRange()
Get the spatial advanced filter dispdiff range.
Definition Filter.hpp:709
virtual ~SpatialAdvancedFilter() noexcept override=default
OBIntPropertyRange getMagnitudeRange()
Get the spatial advanced filter magnitude range.
Definition Filter.hpp:743
The Spatial Fast Filter utilizes an enhanced median smoothing algorithm, designed to significantly re...
Definition Filter.hpp:786
virtual ~SpatialFastFilter() noexcept override=default
SpatialFastFilter(const std::string &activationKey="")
Definition Filter.hpp:788
void setFilterParams(OBSpatialFastFilterParams params)
Set the spatial fast filter params.
Definition Filter.hpp:830
OBSpatialFastFilterParams getFilterParams()
Get the spatial fast filter params.
Definition Filter.hpp:819
OBIntPropertyRange getRadiusRange()
Get the spatial fast filter radius range.
Definition Filter.hpp:802
The Spatial Moderate Filter utilizes an optimized average smoothing algorithm, to achieve a balance b...
Definition Filter.hpp:839
SpatialModerateFilter(const std::string &activationKey="")
Definition Filter.hpp:841
OBIntPropertyRange getRadiusRange()
Get the spatial moderate filter radius range.
Definition Filter.hpp:872
virtual ~SpatialModerateFilter() noexcept override=default
void setFilterParams(OBSpatialModerateFilterParams params)
Set the spatial moderate filter params.
Definition Filter.hpp:919
OBSpatialModerateFilterParams getFilterParams()
Get the spatial moderate filter params.
Definition Filter.hpp:906
OBIntPropertyRange getMagnitudeRange()
Get the spatial moderate filter magnitude range.
Definition Filter.hpp:855
OBIntPropertyRange getDispDiffRange()
Get the spatial moderate filter disp diff range.
Definition Filter.hpp:889
Temporal filter.
Definition Filter.hpp:1033
OBFloatPropertyRange getWeightRange()
Get the TemporalFilter weight range.
Definition Filter.hpp:1075
void setDiffScale(float value)
Set the TemporalFilter diffscale value.
Definition Filter.hpp:1066
~TemporalFilter() noexcept override=default
OBFloatPropertyRange getDiffScaleRange()
Get the TemporalFilter diffscale range.
Definition Filter.hpp:1049
void setWeight(float value)
Set the TemporalFilter weight value.
Definition Filter.hpp:1092
TemporalFilter(const std::string &activationKey="")
Definition Filter.hpp:1035
Creates depth Thresholding filter By controlling min and max options on the block.
Definition Filter.hpp:613
bool setValueRange(uint16_t min, uint16_t max)
Set the threshold filter max and min range.
Definition Filter.hpp:661
OBIntPropertyRange getMinRange()
Get the threshold filter min range.
Definition Filter.hpp:629
virtual ~ThresholdFilter() noexcept override=default
OBIntPropertyRange getMaxRange()
Get the threshold filter max range.
Definition Filter.hpp:646
Definition Context.hpp:19
const std::unordered_map< std::string, std::type_index > & getFilterTypeMap()
Returns the mapping of filter type names to their corresponding type_index.
Definition Filter.hpp:1160
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:32
T getPropertyRange(const OBFilterConfigSchemaItem &item, const double cur)
Get T Property Range.
Definition Filter.hpp:60
Structure for camera parameters.
Definition ObTypes.h:448
Configuration Item for the filter.
Definition ObTypes.h:1469
double min
Minimum value casted to double.
Definition ObTypes.h:1472
double max
Maximum value casted to double.
Definition ObTypes.h:1473
double def
Default value casted to double.
Definition ObTypes.h:1475
double step
Step value casted to double.
Definition ObTypes.h:1474
Structure for float range.
Definition ObTypes.h:332
Structure for integer range.
Definition ObTypes.h:321
SequenceId fliter list item.
Definition ObTypes.h:998
Structure for float range.
Definition ObTypes.h:343
Structure for float range.
Definition ObTypes.h:354
Get the type of a PropertyRange member.
Definition Filter.hpp:37
The error class exposed by the SDK, users can get detailed error information according to the error.
Definition ObTypes.h:117