OrbbecSDK 2.10.6
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 <vector>
26#include <cstring>
27
28namespace ob {
29
33typedef std::function<void(std::shared_ptr<Frame>)> FilterCallback;
34
38template <typename T> struct RangeTraits {
39 using valueType = void;
40};
41
42template <> struct RangeTraits<OBUint8PropertyRange> {
43 using valueType = uint8_t;
44};
45
47 using valueType = uint16_t;
48};
49
50template <> struct RangeTraits<OBIntPropertyRange> {
51 using valueType = uint32_t;
52};
53
54template <> struct RangeTraits<OBFloatPropertyRange> {
55 using valueType = float;
56};
57
61template <typename T> T getPropertyRange(const OBFilterConfigSchemaItem &item, const double cur) {
62 // If T type is illegal, T will be void
63 using valueType = typename RangeTraits<T>::valueType;
64 T range{};
65 // Compilate error will be reported here if T is void
66 range.cur = static_cast<valueType>(cur);
67 range.def = static_cast<valueType>(item.def);
68 range.max = static_cast<valueType>(item.max);
69 range.min = static_cast<valueType>(item.min);
70 range.step = static_cast<valueType>(item.step);
71 return range;
72}
73
77class Filter : public std::enable_shared_from_this<Filter> {
78protected:
79 ob_filter *impl_ = nullptr;
80 std::string name_;
82 std::vector<OBFilterConfigSchemaItem> configSchemaVec_;
83
84protected:
88 Filter() = default;
89
90 virtual void init(ob_filter *impl) {
91 impl_ = impl;
92 ob_error *error = nullptr;
94 Error::handle(&error);
95
96 auto configSchemaList = ob_filter_get_config_schema_list(impl_, &error);
97 Error::handle(&error);
98
99 auto count = ob_filter_config_schema_list_get_count(configSchemaList, &error);
100 Error::handle(&error);
101
102 for(uint32_t i = 0; i < count; i++) {
103 auto item = ob_filter_config_schema_list_get_item(configSchemaList, i, &error);
104 Error::handle(&error);
105 configSchemaVec_.emplace_back(item);
106 }
107
108 ob_delete_filter_config_schema_list(configSchemaList, &error);
109 Error::handle(&error);
110 }
111
112public:
113 explicit Filter(ob_filter *impl) {
114 init(impl);
115 }
116
117 virtual ~Filter() noexcept {
118 if(impl_ != nullptr) {
119 ob_error *error = nullptr;
120 ob_delete_filter(impl_, &error);
121 Error::handle(&error, false);
122 }
123 }
124
131 return impl_;
132 }
133
139 virtual const std::string &getName() const {
140 return name_;
141 }
142
147 virtual void reset() const {
148 ob_error *error = nullptr;
149 ob_filter_reset(impl_, &error);
150 Error::handle(&error);
151 }
152
156 virtual void enable(bool enable) const {
157 ob_error *error = nullptr;
158 ob_filter_enable(impl_, enable, &error);
159 Error::handle(&error);
160 }
161
165 virtual bool isEnabled() const {
166 ob_error *error = nullptr;
167 bool enable = ob_filter_is_enabled(impl_, &error);
168 Error::handle(&error);
169 return enable;
170 }
171
179 virtual std::shared_ptr<Frame> process(std::shared_ptr<const Frame> frame) const {
180 const ob_frame *frameImpl = nullptr;
181 if(frame) {
182 frameImpl = frame->getImpl();
183 }
184 ob_error *error = nullptr;
185 auto result = ob_filter_process(impl_, frameImpl, &error);
186 Error::handle(&error);
187 if(!result) {
188 return nullptr;
189 }
190 return std::make_shared<Frame>(result);
191 }
192
198 virtual void pushFrame(std::shared_ptr<Frame> frame) const {
199 const ob_frame *frameImpl = nullptr;
200 if(frame) {
201 frameImpl = frame->getImpl();
202 }
203 ob_error *error = nullptr;
204 ob_filter_push_frame(impl_, frameImpl, &error);
205 Error::handle(&error);
206 }
207
213 virtual void setCallBack(FilterCallback callback) {
214 callback_ = callback;
215 ob_error *error = nullptr;
216 ob_filter_set_callback(impl_, &Filter::filterCallback, this, &error);
217 Error::handle(&error);
218 }
219
228 virtual std::string getConfigSchema() const {
229 ob_error *error = nullptr;
230 auto schema = ob_filter_get_config_schema(impl_, &error);
231 Error::handle(&error);
232 return schema;
233 }
234
241 virtual std::vector<OBFilterConfigSchemaItem> getConfigSchemaVec() const {
242 return configSchemaVec_;
243 }
244
254 virtual void setConfigValue(const std::string &configName, double value) const {
255 ob_error *error = nullptr;
256 ob_filter_set_config_value(impl_, configName.c_str(), value, &error);
257 Error::handle(&error);
258 }
259
270 virtual double getConfigValue(const std::string &configName) const {
271 ob_error *error = nullptr;
272 double value = ob_filter_get_config_value(impl_, configName.c_str(), &error);
273 Error::handle(&error);
274 return value;
275 }
276
277private:
278 static void filterCallback(ob_frame *frame, void *userData) {
279 auto filter = static_cast<Filter *>(userData);
280 filter->callback_(std::make_shared<Frame>(frame));
281 }
282
283public:
284 // The following interfaces are deprecated and are retained here for compatibility purposes.
285 virtual const char *type() {
286 return getName().c_str();
287 }
288
296 template <typename T> bool is();
297
298 template <typename T> std::shared_ptr<T> as() {
299 if(!is<T>()) {
300 throw std::runtime_error("unsupported operation, object's type is not require type");
301 }
302
303 return std::static_pointer_cast<T>(shared_from_this());
304 }
305};
306
311public:
315 static std::shared_ptr<Filter> createFilter(const std::string &name) {
316 ob_error *error = nullptr;
317 auto impl = ob_create_filter(name.c_str(), &error);
318 Error::handle(&error);
319 return std::make_shared<Filter>(impl);
320 }
321
329 static std::shared_ptr<Filter> createPrivateFilter(const std::string &name, const std::string &activationKey) {
330 ob_error *error = nullptr;
331 auto impl = ob_create_private_filter(name.c_str(), activationKey.c_str(), &error);
332 Error::handle(&error);
333 return std::make_shared<Filter>(impl);
334 }
335
344 static std::string getFilterVendorSpecificCode(const std::string &name) {
345 ob_error *error = nullptr;
346 auto code = ob_filter_get_vendor_specific_code(name.c_str(), &error);
347 Error::handle(&error);
348 return code;
349 }
350};
351
355class PointCloudFilter : public Filter {
356public:
358 ob_error *error = nullptr;
359 auto impl = ob_create_filter("PointCloudFilter", &error);
360 Error::handle(&error);
361 init(impl);
362 }
363
364 virtual ~PointCloudFilter() noexcept override = default;
365
372 setConfigValue("pointFormat", static_cast<double>(format));
373 }
374
383 void setCoordinateDataScaled(float factor) {
384 setConfigValue("coordinateDataScale", factor);
385 }
386
395 void setColorDataNormalization(bool state) {
396 setConfigValue("colorDataNormalization", state);
397 }
398
405 setConfigValue("coordinateSystemType", static_cast<double>(type));
406 }
407
414 void setDecimationFactor(int value) {
415 setConfigValue("decimate", value);
416 }
417
422 OBIntPropertyRange scaleRange{};
423 if(configSchemaVec_.size() != 0) {
424 const auto &item = configSchemaVec_[5];
425 scaleRange = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("decimate"));
426 }
427 return scaleRange;
428 }
429
430public:
431 // The following interfaces are deprecated and are retained here for compatibility purposes.
432 void setPositionDataScaled(float scale) {
434 }
435
436 // The following interfaces are deprecated and are retained here for compatibility purposes.
437 void setFrameAlignState(bool state) {
438 (void)state; // to complie
439 }
440 // The following interfaces are deprecated and are retained here for compatibility purposes.
442 (void)param;
443 }
444};
445
449class Align : public Filter {
450public:
451 Align(OBStreamType alignToStreamType) {
452 ob_error *error = nullptr;
453 auto impl = ob_create_filter("Align", &error);
454 Error::handle(&error);
455 init(impl);
456
457 setConfigValue("AlignType", static_cast<double>(alignToStreamType));
458 }
459
460 virtual ~Align() noexcept override = default;
461
463 return static_cast<OBStreamType>(static_cast<int>(getConfigValue("AlignType")));
464 }
465
476 void setMatchTargetResolution(bool state) {
477 setConfigValue("MatchTargetRes", state);
478 }
479
486 void setAlignToStreamProfile(std::shared_ptr<const StreamProfile> profile) {
487 ob_error *error = nullptr;
488 ob_align_filter_set_align_to_stream_profile(impl_, profile->getImpl(), &error);
489 Error::handle(&error);
490 }
491};
492
498public:
500 ob_error *error = nullptr;
501 auto impl = ob_create_filter("UnDistortionFilter", &error);
502 Error::handle(&error);
503 init(impl);
504 setConfigValue("StreamType", static_cast<double>(streamType));
505 }
506
507 virtual ~UnDistortionFilter() noexcept override = default;
508
512 void setStreamType(OBStreamType streamType) {
513 setConfigValue("StreamType", static_cast<double>(streamType));
514 }
515
517 return static_cast<OBStreamType>(static_cast<int>(getConfigValue("StreamType")));
518 }
519
535 setConfigValue("NewCameraFx", static_cast<double>(depthIntrinsic.fx));
536 setConfigValue("NewCameraFy", static_cast<double>(depthIntrinsic.fy));
537 setConfigValue("NewCameraCx", static_cast<double>(depthIntrinsic.cx));
538 setConfigValue("NewCameraCy", static_cast<double>(depthIntrinsic.cy));
539 setConfigValue("NewCameraWidth", static_cast<double>(depthIntrinsic.width));
540 setConfigValue("NewCameraHeight", static_cast<double>(depthIntrinsic.height));
541 }
542
547 setConfigValue("NewCameraWidth", 0.0);
548 }
549};
550
555public:
557 ob_error *error = nullptr;
558 auto impl = ob_create_filter("FormatConverter", &error);
559 Error::handle(&error);
560 init(impl);
561 }
562
563 virtual ~FormatConvertFilter() noexcept override = default;
564
571 setConfigValue("convertType", static_cast<double>(type));
572 }
573};
574
580class HdrMerge : public Filter {
581public:
583 ob_error *error = nullptr;
584 auto impl = ob_create_filter("HDRMerge", &error);
585 Error::handle(&error);
586 init(impl);
587 }
588
589 virtual ~HdrMerge() noexcept override = default;
590};
591
595class SequenceIdFilter : public Filter {
596private:
597 std::map<float, std::string> sequenceIdList_{ { 0.f, "all" }, { 1.f, "1" } };
598 OBSequenceIdItem *outputSequenceIdList_ = nullptr;
599
600 void initSequenceIdList() {
601 outputSequenceIdList_ = new OBSequenceIdItem[sequenceIdList_.size()];
602
603 int i = 0;
604 for(const auto &pair: sequenceIdList_) {
605 outputSequenceIdList_[i].sequenceSelectId = static_cast<int>(pair.first);
606 strncpy(outputSequenceIdList_[i].name, pair.second.c_str(), sizeof(outputSequenceIdList_[i].name) - 1);
607 outputSequenceIdList_[i].name[sizeof(outputSequenceIdList_[i].name) - 1] = '\0';
608 ++i;
609 }
610 }
611
612public:
614 ob_error *error = nullptr;
615 auto impl = ob_create_filter("SequenceIdFilter", &error);
616 Error::handle(&error);
617 init(impl);
618 initSequenceIdList();
619 }
620
621 virtual ~SequenceIdFilter() noexcept override {
622 if(outputSequenceIdList_) {
623 delete[] outputSequenceIdList_;
624 outputSequenceIdList_ = nullptr;
625 }
626 }
627
633 void selectSequenceId(int sequence_id) {
634 setConfigValue("sequenceid", static_cast<double>(sequence_id));
635 }
636
643 return static_cast<int>(getConfigValue("sequenceid"));
644 }
645
647 return outputSequenceIdList_;
648 }
649
656 return static_cast<int>(sequenceIdList_.size());
657 }
658};
659
663class DecimationFilter : public Filter {
664public:
666 ob_error *error = nullptr;
667 auto impl = ob_create_filter("DecimationFilter", &error);
668 Error::handle(&error);
669 init(impl);
670 }
671
672 virtual ~DecimationFilter() noexcept override = default;
673
679 void setScaleValue(uint8_t value) {
680 setConfigValue("decimate", static_cast<double>(value));
681 }
682
686 uint8_t getScaleValue() {
687 return static_cast<uint8_t>(getConfigValue("decimate"));
688 }
689
694 OBUint8PropertyRange scaleRange{};
695 if(configSchemaVec_.size() != 0) {
696 const auto &item = configSchemaVec_[0];
697 scaleRange = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("decimate"));
698 }
699 return scaleRange;
700 }
701};
702
707class ThresholdFilter : public Filter {
708public:
710 ob_error *error = nullptr;
711 auto impl = ob_create_filter("ThresholdFilter", &error);
712 Error::handle(&error);
713 init(impl);
714 }
715
716 virtual ~ThresholdFilter() noexcept override = default;
717
724 OBIntPropertyRange range{};
725 const auto &schemaVec = getConfigSchemaVec();
726 for(const auto &item: schemaVec) {
727 if(strcmp(item.name, "min") == 0) {
729 break;
730 }
731 }
732 return range;
733 }
734
741 OBIntPropertyRange range{};
742 const auto &schemaVec = getConfigSchemaVec();
743 for(const auto &item: schemaVec) {
744 if(strcmp(item.name, "max") == 0) {
746 break;
747 }
748 }
749 return range;
750 }
751
755 bool setValueRange(uint16_t min, uint16_t max) {
756 if(min >= max) {
757 return false;
758 }
759 setConfigValue("min", min);
760 setConfigValue("max", max);
761 return true;
762 }
763};
764
771public:
772 SpatialAdvancedFilter(const std::string &activationKey = "") {
773 ob_error *error = nullptr;
774 auto impl = ob_create_private_filter("SpatialAdvancedFilter", activationKey.c_str(), &error);
775 Error::handle(&error);
776 init(impl);
777 }
778
779 virtual ~SpatialAdvancedFilter() noexcept override = default;
780
787 OBFloatPropertyRange range{};
788 const auto &schemaVec = getConfigSchemaVec();
789 for(const auto &item: schemaVec) {
790 if(strcmp(item.name, "alpha") == 0) {
792 break;
793 }
794 }
795 return range;
796 }
797
804 OBUint16PropertyRange range{};
805 const auto &schemaVec = getConfigSchemaVec();
806 for(const auto &item: schemaVec) {
807 if(strcmp(item.name, "disp_diff") == 0) {
809 break;
810 }
811 }
812 return range;
813 }
814
821 OBUint16PropertyRange range{};
822 const auto &schemaVec = getConfigSchemaVec();
823 for(const auto &item: schemaVec) {
824 if(strcmp(item.name, "radius") == 0) {
826 break;
827 }
828 }
829 return range;
830 }
831
838 OBIntPropertyRange range{};
839 const auto &schemaVec = getConfigSchemaVec();
840 for(const auto &item: schemaVec) {
841 if(strcmp(item.name, "magnitude") == 0) {
842 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("magnitude"));
843 break;
844 }
845 }
846 return range;
847 }
848
856 params.alpha = static_cast<float>(getConfigValue("alpha"));
857 params.disp_diff = static_cast<uint16_t>(getConfigValue("disp_diff"));
858 params.magnitude = static_cast<uint8_t>(getConfigValue("magnitude"));
859 params.radius = static_cast<uint16_t>(getConfigValue("radius"));
860 return params;
861 }
862
869 setConfigValue("alpha", params.alpha);
870 setConfigValue("disp_diff", params.disp_diff);
871 setConfigValue("magnitude", params.magnitude);
872 setConfigValue("radius", params.radius);
873 }
874};
875
880class SpatialFastFilter : public Filter {
881public:
882 SpatialFastFilter(const std::string &activationKey = "") {
883 ob_error *error = nullptr;
884 auto impl = ob_create_private_filter("SpatialFastFilter", activationKey.c_str(), &error);
885 Error::handle(&error);
886 init(impl);
887 }
888
889 virtual ~SpatialFastFilter() noexcept override = default;
890
897 OBIntPropertyRange range{};
898 const auto &schemaVec = getConfigSchemaVec();
899 for(const auto &item: schemaVec) {
900 if(strcmp(item.name, "radius") == 0) {
902 break;
903 }
904 }
905 return range;
906 }
907
915 params.radius = static_cast<uint8_t>(getConfigValue("radius"));
916 return params;
917 }
918
925 setConfigValue("radius", params.radius);
926 }
927};
928
934public:
935 SpatialModerateFilter(const std::string &activationKey = "") {
936 ob_error *error = nullptr;
937 auto impl = ob_create_private_filter("SpatialModerateFilter", activationKey.c_str(), &error);
938 Error::handle(&error);
939 init(impl);
940 }
941
942 virtual ~SpatialModerateFilter() noexcept override = default;
943
950 OBIntPropertyRange range{};
951 const auto &schemaVec = getConfigSchemaVec();
952 for(const auto &item: schemaVec) {
953 if(strcmp(item.name, "magnitude") == 0) {
954 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("magnitude"));
955 break;
956 }
957 }
958 return range;
959 }
960
967 OBIntPropertyRange range{};
968 const auto &schemaVec = getConfigSchemaVec();
969 for(const auto &item: schemaVec) {
970 if(strcmp(item.name, "radius") == 0) {
972 break;
973 }
974 }
975 return range;
976 }
977
984 OBIntPropertyRange range{};
985 const auto &schemaVec = getConfigSchemaVec();
986 for(const auto &item: schemaVec) {
987 if(strcmp(item.name, "disp_diff") == 0) {
988 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("disp_diff"));
989 break;
990 }
991 }
992 return range;
993 }
994
1002 params.magnitude = static_cast<uint8_t>(getConfigValue("magnitude"));
1003 params.radius = static_cast<uint8_t>(getConfigValue("radius"));
1004 params.disp_diff = static_cast<uint16_t>(getConfigValue("disp_diff"));
1005 return params;
1006 }
1007
1014 setConfigValue("magnitude", params.magnitude);
1015 setConfigValue("radius", params.radius);
1016 setConfigValue("disp_diff", params.disp_diff);
1017 }
1018};
1019
1024public:
1025 HoleFillingFilter(const std::string &activationKey = "") {
1026 ob_error *error = nullptr;
1027 auto impl = ob_create_private_filter("HoleFillingFilter", activationKey.c_str(), &error);
1028 Error::handle(&error);
1029 init(impl);
1030 }
1031
1032 ~HoleFillingFilter() noexcept override = default;
1033
1040 setConfigValue("hole_filling_mode", static_cast<double>(mode));
1041 }
1042
1049 return static_cast<OBHoleFillingMode>(static_cast<int>(getConfigValue("hole_filling_mode")));
1050 }
1051};
1052
1057public:
1058 NoiseRemovalFilter(const std::string &activationKey = "") {
1059 ob_error *error = nullptr;
1060 auto impl = ob_create_private_filter("NoiseRemovalFilter", activationKey.c_str(), &error);
1061 Error::handle(&error);
1062 init(impl);
1063 }
1064
1065 ~NoiseRemovalFilter() noexcept override = default;
1066
1073 setConfigValue("max_size", static_cast<double>(filterParams.max_size));
1074 setConfigValue("min_diff", static_cast<double>(filterParams.disp_diff));
1075 // todo:set noise remove type
1076 }
1077
1085 param.max_size = static_cast<uint16_t>(getConfigValue("max_size"));
1086 param.disp_diff = static_cast<uint16_t>(getConfigValue("min_diff"));
1087 // todo: type is not set
1088 return param;
1089 }
1090
1096 OBUint16PropertyRange range{};
1097 const auto &schemaVec = getConfigSchemaVec();
1098 for(const auto &item: schemaVec) {
1099 if(strcmp(item.name, "min_diff") == 0) {
1101 break;
1102 }
1103 }
1104 return range;
1105 }
1106
1112 OBUint16PropertyRange range{};
1113 const auto &schemaVec = getConfigSchemaVec();
1114 for(const auto &item: schemaVec) {
1115 if(strcmp(item.name, "max_size") == 0) {
1117 break;
1118 }
1119 }
1120 return range;
1121 }
1122};
1123
1127class TemporalFilter : public Filter {
1128public:
1129 TemporalFilter(const std::string &activationKey = "") {
1130 ob_error *error = nullptr;
1131 auto impl = ob_create_private_filter("TemporalFilter", activationKey.c_str(), &error);
1132 Error::handle(&error);
1133 init(impl);
1134 }
1135
1136 ~TemporalFilter() noexcept override = default;
1137
1144 OBFloatPropertyRange range{};
1145 const auto &schemaVec = getConfigSchemaVec();
1146 for(const auto &item: schemaVec) {
1147 if(strcmp(item.name, "diff_scale") == 0) {
1148 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("diff_scale"));
1149 break;
1150 }
1151 }
1152 return range;
1153 }
1154
1160 void setDiffScale(float value) {
1161 setConfigValue("diff_scale", static_cast<double>(value));
1162 }
1163
1170 OBFloatPropertyRange range{};
1171 const auto &schemaVec = getConfigSchemaVec();
1172 for(const auto &item: schemaVec) {
1173 if(strcmp(item.name, "weight") == 0) {
1175 break;
1176 }
1177 }
1178 return range;
1179 }
1180
1186 void setWeight(float value) {
1187 setConfigValue("weight", static_cast<double>(value));
1188 }
1189};
1190
1195public:
1196 EdgeNoiseRemovalFilter(const std::string &activationKey = "") {
1197 ob_error *error = nullptr;
1198 auto impl = ob_create_private_filter("EdgeNoiseRemovalFilter", activationKey.c_str(), &error);
1199 Error::handle(&error);
1200 init(impl);
1201 }
1202
1203 ~EdgeNoiseRemovalFilter() noexcept override = default;
1204
1210 OBUint16PropertyRange range{};
1211 const auto &schemaVec = getConfigSchemaVec();
1212 for(const auto &item: schemaVec) {
1213 if(strcmp(item.name, "margin_x_th") == 0) {
1214 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_x_th"));
1215 break;
1216 }
1217 }
1218 return range;
1219 }
1220
1226 OBUint16PropertyRange range{};
1227 const auto &schemaVec = getConfigSchemaVec();
1228 for(const auto &item: schemaVec) {
1229 if(strcmp(item.name, "margin_y_th") == 0) {
1230 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_y_th"));
1231 break;
1232 }
1233 }
1234 return range;
1235 }
1236
1242 OBUint16PropertyRange range{};
1243 const auto &schemaVec = getConfigSchemaVec();
1244 for(const auto &item: schemaVec) {
1245 if(strcmp(item.name, "limit_x_th") == 0) {
1246 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_x_th"));
1247 break;
1248 }
1249 }
1250 return range;
1251 }
1252
1258 OBUint16PropertyRange range{};
1259 const auto &schemaVec = getConfigSchemaVec();
1260 for(const auto &item: schemaVec) {
1261 if(strcmp(item.name, "limit_y_th") == 0) {
1262 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_y_th"));
1263 break;
1264 }
1265 }
1266 return range;
1267 }
1268
1274 OBUint16PropertyRange range{};
1275 const auto &schemaVec = getConfigSchemaVec();
1276 for(const auto &item: schemaVec) {
1277 if(strcmp(item.name, "enable_vertical_direction") == 0) {
1278 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("enable_vertical_direction"));
1279 break;
1280 }
1281 }
1282 return range;
1283 }
1284
1290 OBUint16PropertyRange range{};
1291 const auto &schemaVec = getConfigSchemaVec();
1292 for(const auto &item: schemaVec) {
1293 if(strcmp(item.name, "width") == 0) {
1295 break;
1296 }
1297 }
1298 return range;
1299 }
1300
1306 OBUint16PropertyRange range{};
1307 const auto &schemaVec = getConfigSchemaVec();
1308 for(const auto &item: schemaVec) {
1309 if(strcmp(item.name, "height") == 0) {
1311 break;
1312 }
1313 }
1314 return range;
1315 }
1316
1323 setConfigValue("margin_x_th", static_cast<double>(filterParams.margin_x_th));
1324 setConfigValue("margin_y_th", static_cast<double>(filterParams.margin_y_th));
1325 setConfigValue("limit_x_th", static_cast<double>(filterParams.limit_x_th));
1326 setConfigValue("limit_y_th", static_cast<double>(filterParams.limit_y_th));
1327 setConfigValue("enable_vertical_direction", static_cast<double>(filterParams.enable_direction));
1328 setConfigValue("width", static_cast<double>(filterParams.width));
1329 setConfigValue("height", static_cast<double>(filterParams.height));
1330 }
1331
1339 param.margin_x_th = static_cast<uint16_t>(getConfigValue("margin_x_th"));
1340 param.margin_y_th = static_cast<uint16_t>(getConfigValue("margin_y_th"));
1341 param.limit_x_th = static_cast<uint16_t>(getConfigValue("limit_x_th"));
1342 param.limit_y_th = static_cast<uint16_t>(getConfigValue("limit_y_th"));
1343 param.enable_direction = static_cast<uint16_t>(getConfigValue("enable_vertical_direction"));
1344 param.width = static_cast<uint16_t>(getConfigValue("width"));
1345 param.height = static_cast<uint16_t>(getConfigValue("height"));
1346 return param;
1347 }
1348};
1349
1354public:
1355 FalsePositiveFilter(const std::string &activationKey = "") {
1356 ob_error *error = nullptr;
1357 auto impl = ob_create_private_filter("FalsePositiveFilter", activationKey.c_str(), &error);
1358 Error::handle(&error);
1359 init(impl);
1360 }
1361
1362 virtual ~FalsePositiveFilter() noexcept override = default;
1363
1370 OBUint8PropertyRange range{};
1371 const auto &schemaVec = getConfigSchemaVec();
1372 for(const auto &item: schemaVec) {
1373 if(strcmp(item.name, "fpEdgeBleedFilterEnable") == 0) {
1374 range = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("fpEdgeBleedFilterEnable"));
1375 break;
1376 }
1377 }
1378 return range;
1379 }
1380
1387 OBFloatPropertyRange range{};
1388 const auto &schemaVec = getConfigSchemaVec();
1389 for(const auto &item: schemaVec) {
1390 if(strcmp(item.name, "fpebfROIMinXRatio") == 0) {
1391 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMinXRatio"));
1392 break;
1393 }
1394 }
1395 return range;
1396 }
1397
1404 OBFloatPropertyRange range{};
1405 const auto &schemaVec = getConfigSchemaVec();
1406 for(const auto &item: schemaVec) {
1407 if(strcmp(item.name, "fpebfROIMaxXRatio") == 0) {
1408 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMaxXRatio"));
1409 break;
1410 }
1411 }
1412 return range;
1413 }
1414
1421 OBFloatPropertyRange range{};
1422 const auto &schemaVec = getConfigSchemaVec();
1423 for(const auto &item: schemaVec) {
1424 if(strcmp(item.name, "fpebfROIMinYRatio") == 0) {
1425 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMinYRatio"));
1426 break;
1427 }
1428 }
1429 return range;
1430 }
1431
1438 OBFloatPropertyRange range{};
1439 const auto &schemaVec = getConfigSchemaVec();
1440 for(const auto &item: schemaVec) {
1441 if(strcmp(item.name, "fpebfROIMaxYRatio") == 0) {
1442 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMaxYRatio"));
1443 break;
1444 }
1445 }
1446 return range;
1447 }
1448
1455 OBUint16PropertyRange range{};
1456 const auto &schemaVec = getConfigSchemaVec();
1457 for(const auto &item: schemaVec) {
1458 if(strcmp(item.name, "fpebfMinBleedLength") == 0) {
1459 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fpebfMinBleedLength"));
1460 break;
1461 }
1462 }
1463 return range;
1464 }
1465
1472 OBUint8PropertyRange range{};
1473 const auto &schemaVec = getConfigSchemaVec();
1474 for(const auto &item: schemaVec) {
1475 if(strcmp(item.name, "fpTextureSparsityFilterEnable") == 0) {
1476 range = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("fpTextureSparsityFilterEnable"));
1477 break;
1478 }
1479 }
1480 return range;
1481 }
1482
1489 OBFloatPropertyRange range{};
1490 const auto &schemaVec = getConfigSchemaVec();
1491 for(const auto &item: schemaVec) {
1492 if(strcmp(item.name, "fptsfROIMinXRatio") == 0) {
1493 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMinXRatio"));
1494 break;
1495 }
1496 }
1497 return range;
1498 }
1499
1506 OBFloatPropertyRange range{};
1507 const auto &schemaVec = getConfigSchemaVec();
1508 for(const auto &item: schemaVec) {
1509 if(strcmp(item.name, "fptsfROIMaxXRatio") == 0) {
1510 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMaxXRatio"));
1511 break;
1512 }
1513 }
1514 return range;
1515 }
1516
1523 OBFloatPropertyRange range{};
1524 const auto &schemaVec = getConfigSchemaVec();
1525 for(const auto &item: schemaVec) {
1526 if(strcmp(item.name, "fptsfROIMinYRatio") == 0) {
1527 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMinYRatio"));
1528 break;
1529 }
1530 }
1531 return range;
1532 }
1533
1540 OBFloatPropertyRange range{};
1541 const auto &schemaVec = getConfigSchemaVec();
1542 for(const auto &item: schemaVec) {
1543 if(strcmp(item.name, "fptsfROIMaxYRatio") == 0) {
1544 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMaxYRatio"));
1545 break;
1546 }
1547 }
1548 return range;
1549 }
1550
1557 OBUint16PropertyRange range{};
1558 const auto &schemaVec = getConfigSchemaVec();
1559 for(const auto &item: schemaVec) {
1560 if(strcmp(item.name, "fptsfMaxNoiseLevel") == 0) {
1561 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fptsfMaxNoiseLevel"));
1562 break;
1563 }
1564 }
1565 return range;
1566 }
1567
1574 OBUint16PropertyRange range{};
1575 const auto &schemaVec = getConfigSchemaVec();
1576 for(const auto &item: schemaVec) {
1577 if(strcmp(item.name, "fptsfMaxSpeckleSize") == 0) {
1578 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fptsfMaxSpeckleSize"));
1579 break;
1580 }
1581 }
1582 return range;
1583 }
1584
1591 OBUint8PropertyRange range{};
1592 const auto &schemaVec = getConfigSchemaVec();
1593 for(const auto &item: schemaVec) {
1594 if(strcmp(item.name, "fpPatternAmbiguityFilterEnable") == 0) {
1595 range = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("fpPatternAmbiguityFilterEnable"));
1596 break;
1597 }
1598 }
1599 return range;
1600 }
1601
1608 OBFloatPropertyRange range{};
1609 const auto &schemaVec = getConfigSchemaVec();
1610 for(const auto &item: schemaVec) {
1611 if(strcmp(item.name, "fppafROIMinXRatio") == 0) {
1612 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMinXRatio"));
1613 break;
1614 }
1615 }
1616 return range;
1617 }
1618
1625 OBFloatPropertyRange range{};
1626 const auto &schemaVec = getConfigSchemaVec();
1627 for(const auto &item: schemaVec) {
1628 if(strcmp(item.name, "fppafROIMaxXRatio") == 0) {
1629 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMaxXRatio"));
1630 break;
1631 }
1632 }
1633 return range;
1634 }
1635
1642 OBFloatPropertyRange range{};
1643 const auto &schemaVec = getConfigSchemaVec();
1644 for(const auto &item: schemaVec) {
1645 if(strcmp(item.name, "fppafROIMinYRatio") == 0) {
1646 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMinYRatio"));
1647 break;
1648 }
1649 }
1650 return range;
1651 }
1652
1659 OBFloatPropertyRange range{};
1660 const auto &schemaVec = getConfigSchemaVec();
1661 for(const auto &item: schemaVec) {
1662 if(strcmp(item.name, "fppafROIMaxYRatio") == 0) {
1663 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMaxYRatio"));
1664 break;
1665 }
1666 }
1667 return range;
1668 }
1669
1676 OBUint16PropertyRange range{};
1677 const auto &schemaVec = getConfigSchemaVec();
1678 for(const auto &item: schemaVec) {
1679 if(strcmp(item.name, "fppafMaxNoiseLevel") == 0) {
1680 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fppafMaxNoiseLevel"));
1681 break;
1682 }
1683 }
1684 return range;
1685 }
1686
1693 OBUint16PropertyRange range{};
1694 const auto &schemaVec = getConfigSchemaVec();
1695 for(const auto &item: schemaVec) {
1696 if(strcmp(item.name, "fppafMaxSpeckleSize") == 0) {
1697 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fppafMaxSpeckleSize"));
1698 break;
1699 }
1700 }
1701 return range;
1702 }
1703
1710 OBFloatPropertyRange range{};
1711 const auto &schemaVec = getConfigSchemaVec();
1712 for(const auto &item: schemaVec) {
1713 if(strcmp(item.name, "fppafMaxWidthRatio") == 0) {
1714 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafMaxWidthRatio"));
1715 break;
1716 }
1717 }
1718 return range;
1719 }
1720
1727 OBFloatPropertyRange range{};
1728 const auto &schemaVec = getConfigSchemaVec();
1729 for(const auto &item: schemaVec) {
1730 if(strcmp(item.name, "fppafMaxHeightRatio") == 0) {
1731 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafMaxHeightRatio"));
1732 break;
1733 }
1734 }
1735 return range;
1736 }
1737
1744 OBFloatPropertyRange range{};
1745 const auto &schemaVec = getConfigSchemaVec();
1746 for(const auto &item: schemaVec) {
1747 if(strcmp(item.name, "fppafTolerance") == 0) {
1748 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafTolerance"));
1749 break;
1750 }
1751 }
1752 return range;
1753 }
1754
1761 OBUint16PropertyRange range{};
1762 const auto &schemaVec = getConfigSchemaVec();
1763 for(const auto &item: schemaVec) {
1764 if(strcmp(item.name, "fppafScore") == 0) {
1765 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fppafScore"));
1766 break;
1767 }
1768 }
1769 return range;
1770 }
1771};
1772
1777public:
1778 MgcNoiseRemovalFilter(const std::string &activationKey = "") {
1779 ob_error *error = nullptr;
1780 auto impl = ob_create_private_filter("MgcNoiseRemovalFilter", activationKey.c_str(), &error);
1781 Error::handle(&error);
1782 init(impl);
1783 }
1784
1785 ~MgcNoiseRemovalFilter() noexcept override = default;
1786
1792 setConfigValue("max_width_left", static_cast<double>(filterParams.max_width_left));
1793 setConfigValue("max_width_right", static_cast<double>(filterParams.max_width_right));
1794 setConfigValue("max_radius", static_cast<double>(filterParams.max_radius));
1795 setConfigValue("margin_x_th", static_cast<double>(filterParams.margin_x_th));
1796 setConfigValue("margin_y_th", static_cast<double>(filterParams.margin_y_th));
1797 setConfigValue("limit_x_th", static_cast<double>(filterParams.limit_x_th));
1798 setConfigValue("limit_y_th", static_cast<double>(filterParams.limit_y_th));
1799 setConfigValue("width", static_cast<double>(filterParams.width));
1800 setConfigValue("height", static_cast<double>(filterParams.height));
1801 }
1802
1809 params.max_width_left = static_cast<int>(getConfigValue("max_width_left"));
1810 params.max_width_right = static_cast<int>(getConfigValue("max_width_right"));
1811 params.max_radius = static_cast<int>(getConfigValue("max_radius"));
1812 params.margin_x_th = static_cast<int>(getConfigValue("margin_x_th"));
1813 params.margin_y_th = static_cast<int>(getConfigValue("margin_y_th"));
1814 params.limit_x_th = static_cast<int>(getConfigValue("limit_x_th"));
1815 params.limit_y_th = static_cast<int>(getConfigValue("limit_y_th"));
1816 params.width = static_cast<uint32_t>(getConfigValue("width"));
1817 params.height = static_cast<uint32_t>(getConfigValue("height"));
1818 return params;
1819 }
1820
1826 OBUint16PropertyRange range{};
1827 const auto &schemaVec = getConfigSchemaVec();
1828 for(const auto &item: schemaVec) {
1829 if(strcmp(item.name, "max_width_left") == 0) {
1830 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("max_width_left"));
1831 break;
1832 }
1833 }
1834 return range;
1835 }
1836
1842 OBUint16PropertyRange range{};
1843 const auto &schemaVec = getConfigSchemaVec();
1844 for(const auto &item: schemaVec) {
1845 if(strcmp(item.name, "max_width_right") == 0) {
1846 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("max_width_right"));
1847 break;
1848 }
1849 }
1850 return range;
1851 }
1852
1858 OBUint16PropertyRange range{};
1859 const auto &schemaVec = getConfigSchemaVec();
1860 for(const auto &item: schemaVec) {
1861 if(strcmp(item.name, "max_radius") == 0) {
1862 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("max_radius"));
1863 break;
1864 }
1865 }
1866 return range;
1867 }
1868
1874 OBUint16PropertyRange range{};
1875 const auto &schemaVec = getConfigSchemaVec();
1876 for(const auto &item: schemaVec) {
1877 if(strcmp(item.name, "margin_x_th") == 0) {
1878 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_x_th"));
1879 break;
1880 }
1881 }
1882 return range;
1883 }
1884
1890 OBUint16PropertyRange range{};
1891 const auto &schemaVec = getConfigSchemaVec();
1892 for(const auto &item: schemaVec) {
1893 if(strcmp(item.name, "margin_y_th") == 0) {
1894 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_y_th"));
1895 break;
1896 }
1897 }
1898 return range;
1899 }
1900
1906 OBUint16PropertyRange range{};
1907 const auto &schemaVec = getConfigSchemaVec();
1908 for(const auto &item: schemaVec) {
1909 if(strcmp(item.name, "limit_x_th") == 0) {
1910 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_x_th"));
1911 break;
1912 }
1913 }
1914 return range;
1915 }
1916
1922 OBUint16PropertyRange range{};
1923 const auto &schemaVec = getConfigSchemaVec();
1924 for(const auto &item: schemaVec) {
1925 if(strcmp(item.name, "limit_y_th") == 0) {
1926 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_y_th"));
1927 break;
1928 }
1929 }
1930 return range;
1931 }
1932
1938 OBUint16PropertyRange range{};
1939 const auto &schemaVec = getConfigSchemaVec();
1940 for(const auto &item: schemaVec) {
1941 if(strcmp(item.name, "width") == 0) {
1943 break;
1944 }
1945 }
1946 return range;
1947 }
1948
1954 OBUint16PropertyRange range{};
1955 const auto &schemaVec = getConfigSchemaVec();
1956 for(const auto &item: schemaVec) {
1957 if(strcmp(item.name, "height") == 0) {
1959 break;
1960 }
1961 }
1962 return range;
1963 }
1964};
1965
1970public:
1971 LutNoiseRemovalFilter(const std::string &activationKey = "") {
1972 ob_error *error = nullptr;
1973 auto impl = ob_create_private_filter("LutNoiseRemovalFilter", activationKey.c_str(), &error);
1974 Error::handle(&error);
1975 init(impl);
1976 }
1977
1978 ~LutNoiseRemovalFilter() noexcept override = default;
1979
1985 for(int i = 0; i < 16; ++i) {
1986 setConfigValue("max_lut_" + std::to_string(i), static_cast<double>(filterParams.max_lut[i]));
1987 }
1988 setConfigValue("min_diff", static_cast<double>(filterParams.min_diff));
1989 setConfigValue("width", static_cast<double>(filterParams.width));
1990 setConfigValue("height", static_cast<double>(filterParams.height));
1991 }
1992
1999 for(int i = 0; i < 16; ++i) {
2000 params.max_lut[i] = static_cast<uint16_t>(getConfigValue("max_lut_" + std::to_string(i)));
2001 }
2002 params.min_diff = static_cast<uint16_t>(getConfigValue("min_diff"));
2003 params.width = static_cast<uint32_t>(getConfigValue("width"));
2004 params.height = static_cast<uint32_t>(getConfigValue("height"));
2005 return params;
2006 }
2007
2014 OBUint16PropertyRange range{};
2015 if(index < 0 || index >= 16) {
2016 return range;
2017 }
2018 std::string name = "max_lut_" + std::to_string(index);
2019 const auto &schemaVec = getConfigSchemaVec();
2020 for(const auto &item: schemaVec) {
2021 if(strcmp(item.name, name.c_str()) == 0) {
2023 break;
2024 }
2025 }
2026 return range;
2027 }
2028
2034 OBUint16PropertyRange range{};
2035 const auto &schemaVec = getConfigSchemaVec();
2036 for(const auto &item: schemaVec) {
2037 if(strcmp(item.name, "min_diff") == 0) {
2039 break;
2040 }
2041 }
2042 return range;
2043 }
2044
2050 OBUint16PropertyRange range{};
2051 const auto &schemaVec = getConfigSchemaVec();
2052 for(const auto &item: schemaVec) {
2053 if(strcmp(item.name, "width") == 0) {
2055 break;
2056 }
2057 }
2058 return range;
2059 }
2060
2066 OBUint16PropertyRange range{};
2067 const auto &schemaVec = getConfigSchemaVec();
2068 for(const auto &item: schemaVec) {
2069 if(strcmp(item.name, "height") == 0) {
2071 break;
2072 }
2073 }
2074 return range;
2075 }
2076};
2077
2082public:
2083 DisparityTransform(const std::string &activationKey = "") {
2084 ob_error *error = nullptr;
2085 auto impl = ob_create_private_filter("DisparityTransform", activationKey.c_str(), &error);
2086 Error::handle(&error);
2087 init(impl);
2088 }
2089
2090 ~DisparityTransform() noexcept override = default;
2091};
2092
2100public:
2109 template <typename T> explicit EnhancedDepthFilter(std::shared_ptr<T> device, const std::string &modelPath = "") {
2110 if(!device) {
2111 throw std::invalid_argument("device is null");
2112 }
2113 ob_error *error = nullptr;
2114 auto impl = ob_create_private_filter("EnhancedDepthFilter", "", &error);
2115 Error::handle(&error);
2116
2117 // Only pass options when a model path is provided; otherwise hand down nullptr so the filter uses its default.
2119 ob_priv_filter_activate_options *optionsPtr = nullptr;
2120 if(!modelPath.empty()) {
2121 options.struct_size = sizeof(options);
2122 options.model_path = modelPath.c_str();
2123 optionsPtr = &options;
2124 }
2125 ob_filter_activate_private_ex(impl, device->getImpl(), optionsPtr, &error);
2126 Error::handle(&error);
2127 init(impl);
2128 }
2129
2130 ~EnhancedDepthFilter() noexcept override = default;
2131
2138 static const std::vector<std::pair<uint32_t, uint32_t>> &getSupportedResolutions() {
2139 static const std::vector<std::pair<uint32_t, uint32_t>> supportedResolutions = {
2140 { 640, 480 },
2141 { 1280, 720 },
2142 { 1280, 800 },
2143 };
2144 return supportedResolutions;
2145 }
2146
2156 static std::vector<OBFormat> getSupportedFormats(OBStreamType streamType) {
2157 if(streamType == OB_STREAM_COLOR) {
2158 return { OB_FORMAT_RGB };
2159 }
2160 if(streamType == OB_STREAM_DEPTH) {
2162 }
2163 return {};
2164 }
2165
2176 static bool isSupportedResolution(OBStreamType sourceStreamType, OBStreamType alignToStreamType, uint32_t width, uint32_t height) {
2177 if(sourceStreamType != alignToStreamType) {
2178 // If the source and target stream types are different, any resolution is supported.
2179 return true;
2180 }
2181
2182 for(const auto &res: getSupportedResolutions()) {
2183 if(res.first == width && res.second == height) {
2184 return true;
2185 }
2186 }
2187 return false;
2188 }
2189
2198 static bool isSupportedFormat(OBStreamType streamType, OBFormat format) {
2199 for(const auto &supported: getSupportedFormats(streamType)) {
2200 if(supported == format) {
2201 return true;
2202 }
2203 }
2204 return false;
2205 }
2206
2213 void setResolution(uint32_t width, uint32_t height) {
2214 setConfigValue("width", static_cast<double>(width));
2215 setConfigValue("height", static_cast<double>(height));
2216 }
2217
2223 uint32_t getCurrentWidth() const {
2224 return static_cast<uint32_t>(getConfigValue("width"));
2225 }
2226
2232 uint32_t getCurrentHeight() const {
2233 return static_cast<uint32_t>(getConfigValue("height"));
2234 }
2235
2241 void setConfidenceThreshold(uint32_t value) {
2242 setConfigValue("confidence_threshold", static_cast<double>(value));
2243 }
2244
2249 OBIntPropertyRange range{};
2250 const auto &schemaVec = getConfigSchemaVec();
2251 for(const auto &item: schemaVec) {
2252 const char *name = "confidence_threshold";
2253 if(std::strcmp(item.name, name) == 0) {
2255 break;
2256 }
2257 }
2258 return range;
2259 }
2260};
2261
2263private:
2264 ob_filter_list_t *impl_;
2265
2266public:
2267 explicit OBFilterList(ob_filter_list_t *impl) : impl_(impl) {}
2268
2269 ~OBFilterList() noexcept {
2270 ob_error *error = nullptr;
2271 ob_delete_filter_list(impl_, &error);
2272 Error::handle(&error, false);
2273 }
2274
2280 uint32_t getCount() const {
2281 ob_error *error = nullptr;
2282 auto count = ob_filter_list_get_count(impl_, &error);
2283 Error::handle(&error);
2284 return count;
2285 }
2286
2294 std::shared_ptr<Filter> getFilter(uint32_t index) {
2295 ob_error *error = nullptr;
2296 auto filter = ob_filter_list_get_filter(impl_, index, &error);
2297 Error::handle(&error);
2298 return std::make_shared<Filter>(filter);
2299 }
2300
2301public:
2302 // The following interfaces are deprecated and are retained here for compatibility purposes.
2303 uint32_t count() const {
2304 return getCount();
2305 }
2306};
2307
2311inline const std::unordered_map<std::string, std::type_index> &getFilterTypeMap() {
2312 static const std::unordered_map<std::string, std::type_index> filterTypeMap = {
2313 { "PointCloudFilter", typeid(PointCloudFilter) },
2314 { "Align", typeid(Align) },
2315 { "FormatConverter", typeid(FormatConvertFilter) },
2316 { "HDRMerge", typeid(HdrMerge) },
2317 { "SequenceIdFilter", typeid(SequenceIdFilter) },
2318 { "DecimationFilter", typeid(DecimationFilter) },
2319 { "ThresholdFilter", typeid(ThresholdFilter) },
2320 { "SpatialAdvancedFilter", typeid(SpatialAdvancedFilter) },
2321 { "HoleFillingFilter", typeid(HoleFillingFilter) },
2322 { "NoiseRemovalFilter", typeid(NoiseRemovalFilter) },
2323 { "TemporalFilter", typeid(TemporalFilter) },
2324 { "DisparityTransform", typeid(DisparityTransform) },
2325 { "SpatialFastFilter", typeid(SpatialFastFilter) },
2326 { "SpatialModerateFilter", typeid(SpatialModerateFilter) },
2327 { "EdgeNoiseRemovalFilter", typeid(EdgeNoiseRemovalFilter) },
2328 { "FalsePositiveFilter", typeid(FalsePositiveFilter) },
2329 { "MgcNoiseRemovalFilter", typeid(MgcNoiseRemovalFilter) },
2330 { "LutNoiseRemovalFilter", typeid(LutNoiseRemovalFilter) },
2331 { "UnDistortionFilter", typeid(UnDistortionFilter) },
2332 { "EnhancedDepthFilter", typeid(EnhancedDepthFilter) },
2333 };
2334 return filterTypeMap;
2335}
2336
2343template <typename T> bool Filter::is() {
2344 std::string name = type();
2345
2346 const auto &filterTypeMap = getFilterTypeMap();
2347 auto it = filterTypeMap.find(name);
2348 if(it != filterTypeMap.end()) {
2349 return std::type_index(typeid(T)) == it->second;
2350 }
2351 return false;
2352}
2353
2354} // 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_filter_activate_private_ex(ob_filter *filter, ob_device *device, const ob_priv_filter_activate_options *options, ob_error **error)
Activate a private filter object with a specific device.
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:262
@ OB_FORMAT_Y11
Definition ObTypes.h:275
@ OB_FORMAT_Y16
Definition ObTypes.h:272
@ OB_FORMAT_Z16
Definition ObTypes.h:291
@ OB_FORMAT_Y12
Definition ObTypes.h:276
@ OB_FORMAT_RGB
Definition ObTypes.h:285
@ OB_FORMAT_Y10
Definition ObTypes.h:274
@ OB_FORMAT_Y14
Definition ObTypes.h:287
OBStreamType
Enumeration value describing the type of data stream.
Definition ObTypes.h:203
@ OB_STREAM_DEPTH
Definition ObTypes.h:208
@ OB_STREAM_COLOR
Definition ObTypes.h:207
struct ob_filter_t ob_filter
Definition ObTypes.h:34
enum OB_COORDINATE_SYSTEM_TYPE OBCoordinateSystemType
OBHoleFillingMode
Hole fillig mode.
Definition ObTypes.h:1164
OBConvertFormat
Enumeration of format conversion types.
Definition ObTypes.h:614
Align for depth to other or other to depth.
Definition Filter.hpp:449
Align(OBStreamType alignToStreamType)
Definition Filter.hpp:451
virtual ~Align() noexcept override=default
OBStreamType getAlignToStreamType()
Definition Filter.hpp:462
void setMatchTargetResolution(bool state)
Sets whether the output frame resolution should match the target resolution. When enabled,...
Definition Filter.hpp:476
void setAlignToStreamProfile(std::shared_ptr< const StreamProfile > profile)
Set the Align To Stream Profile.
Definition Filter.hpp:486
Decimation filter, reducing complexity by subsampling depth maps and losing depth details.
Definition Filter.hpp:663
virtual ~DecimationFilter() noexcept override=default
OBUint8PropertyRange getScaleRange()
Get the property range of the decimation filter scale value.
Definition Filter.hpp:693
uint8_t getScaleValue()
Get the decimation filter scale value.
Definition Filter.hpp:686
void setScaleValue(uint8_t value)
Set the decimation filter scale value.
Definition Filter.hpp:679
Depth to disparity or disparity to depth.
Definition Filter.hpp:2081
DisparityTransform(const std::string &activationKey="")
Definition Filter.hpp:2083
~DisparityTransform() noexcept override=default
EdgeNoiseRemoval filter.
Definition Filter.hpp:1194
OBUint16PropertyRange getVerticalDirectionEnableRange()
Get the edge noise removal filter vertical direction enable range.
Definition Filter.hpp:1273
OBUint16PropertyRange getLimitXthRange()
Get the edge noise removal filter limit x th range.
Definition Filter.hpp:1241
EdgeNoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:1196
OBUint16PropertyRange getHeightRange()
Get the edge noise removal filter height range.
Definition Filter.hpp:1305
OBUint16PropertyRange getWidthRange()
Get the edge noise removal filter width range.
Definition Filter.hpp:1289
OBEdgeNoiseRemovalFilterParams getFilterParams()
Get the edge noise removal filter params.
Definition Filter.hpp:1337
~EdgeNoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMarginYthRange()
Get the edge noise removal filter margin y th range.
Definition Filter.hpp:1225
OBUint16PropertyRange getLimitYthRange()
Get the edge noise removal filter limit y th range.
Definition Filter.hpp:1257
OBUint16PropertyRange getMarginXthRange()
Get the edge noise removal filter margin x th range.
Definition Filter.hpp:1209
void setFilterParams(OBEdgeNoiseRemovalFilterParams filterParams)
Set the edge noise removal filter params.
Definition Filter.hpp:1322
Enhanced depth filter that requires a device for activation.
Definition Filter.hpp:2099
static std::vector< OBFormat > getSupportedFormats(OBStreamType streamType)
Get the frame formats supported by the enhanced depth filter for a given stream type.
Definition Filter.hpp:2156
static const std::vector< std::pair< uint32_t, uint32_t > > & getSupportedResolutions()
Get the resolutions supported by the enhanced depth filter for the constrained (aligned-to) stream.
Definition Filter.hpp:2138
EnhancedDepthFilter(std::shared_ptr< T > device, const std::string &modelPath="")
Construct an EnhancedDepthFilter and activate it for the given device.
Definition Filter.hpp:2109
~EnhancedDepthFilter() noexcept override=default
OBIntPropertyRange getConfidenceThresholdRange()
Get the property range of the confidence threshold range.
Definition Filter.hpp:2248
static bool isSupportedResolution(OBStreamType sourceStreamType, OBStreamType alignToStreamType, uint32_t width, uint32_t height)
Check whether a resolution is supported by the enhanced depth filter for a given stream alignment pai...
Definition Filter.hpp:2176
uint32_t getCurrentWidth() const
Get the current configured frame width.
Definition Filter.hpp:2223
void setConfidenceThreshold(uint32_t value)
Set the confidence threshold for depth values.
Definition Filter.hpp:2241
void setResolution(uint32_t width, uint32_t height)
Set the working resolution of the enhanced depth filter.
Definition Filter.hpp:2213
uint32_t getCurrentHeight() const
Get the current configured frame height.
Definition Filter.hpp:2232
static bool isSupportedFormat(OBStreamType streamType, OBFormat format)
Check whether a frame format is supported by the enhanced depth filter for a given stream type.
Definition Filter.hpp:2198
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
FalsePositive filter.
Definition Filter.hpp:1353
OBFloatPropertyRange getfppafMaxHeightRatioRange()
Get the FalsePositive filter fppafMaxHeightRatio range.
Definition Filter.hpp:1726
OBFloatPropertyRange getfppafROIMaxYRatioRange()
Get the FalsePositive filter fppafROIMaxYRatio range.
Definition Filter.hpp:1658
OBFloatPropertyRange getfptsfROIMinXRatioRange()
Get the FalsePositive filter fptsfROIMinXRatio range.
Definition Filter.hpp:1488
OBFloatPropertyRange getfptsfROIMaxYRatioRange()
Get the FalsePositive filter fptsfROIMaxYRatio range.
Definition Filter.hpp:1539
OBFloatPropertyRange getfpebfROIMinXRatioRange()
Get the FalsePositive filter fpebfROIMinXRatio range.
Definition Filter.hpp:1386
OBFloatPropertyRange getfptsfROIMinYRatioRange()
Get the FalsePositive filter fptsfROIMinYRatio range.
Definition Filter.hpp:1522
OBUint16PropertyRange getfpebfMinBleedLengthRange()
Get the FalsePositive filter fpebfMinBleedLength range.
Definition Filter.hpp:1454
OBUint16PropertyRange getfppafMaxNoiseLevelRange()
Get the FalsePositive filter fppafMaxNoiseLevel range.
Definition Filter.hpp:1675
OBUint16PropertyRange getfptsfMaxSpeckleSizeRange()
Get the FalsePositive filter fptsfMaxSpeckleSize range.
Definition Filter.hpp:1573
virtual ~FalsePositiveFilter() noexcept override=default
OBUint8PropertyRange getfpPatternAmbiguityFilterEnableRange()
Get the FalsePositive filter fpPatternAmbiguityFilterEnable range.
Definition Filter.hpp:1590
OBUint8PropertyRange getfpTextureSparsityFilterEnableRange()
Get the FalsePositive filter fpTextureSparsityFilterEnable range.
Definition Filter.hpp:1471
OBFloatPropertyRange getfppafROIMinYRatioRange()
Get the FalsePositive filter fppafROIMinYRatio range.
Definition Filter.hpp:1641
OBFloatPropertyRange getfppafToleranceRange()
Get the FalsePositive filter fppafTolerance range.
Definition Filter.hpp:1743
OBUint8PropertyRange getfpEdgeBleedFilterEnableRange()
Get the FalsePositive filter fpEdgeBleedFilterEnable range.
Definition Filter.hpp:1369
FalsePositiveFilter(const std::string &activationKey="")
Definition Filter.hpp:1355
OBUint16PropertyRange getfptsfMaxNoiseLevelRange()
Get the FalsePositive filter fptsfMaxNoiseLevel range.
Definition Filter.hpp:1556
OBUint16PropertyRange getfppafScoreRange()
Get the FalsePositive filter fppafScore range.
Definition Filter.hpp:1760
OBFloatPropertyRange getfptsfROIMaxXRatioRange()
Get the FalsePositive filter fptsfROIMaxXRatio range.
Definition Filter.hpp:1505
OBFloatPropertyRange getfppafROIMinXRatioRange()
Get the FalsePositive filter fppafROIMinXRatio range.
Definition Filter.hpp:1607
OBUint16PropertyRange getfppafMaxSpeckleSizeRange()
Get the FalsePositive filter fppafMaxSpeckleSize range.
Definition Filter.hpp:1692
OBFloatPropertyRange getfpebfROIMaxYRatioRange()
Get the FalsePositive filter fpebfROIMaxYRatio range.
Definition Filter.hpp:1437
OBFloatPropertyRange getfppafMaxWidthRatioRange()
Get the FalsePositive filter fppafMaxWidthRatio range.
Definition Filter.hpp:1709
OBFloatPropertyRange getfppafROIMaxXRatioRange()
Get the FalsePositive filter fppafROIMaxXRatio range.
Definition Filter.hpp:1624
OBFloatPropertyRange getfpebfROIMinYRatioRange()
Get the FalsePositive filter fpebfROIMinYRatio range.
Definition Filter.hpp:1420
OBFloatPropertyRange getfpebfROIMaxXRatioRange()
Get the FalsePositive filter fpebfROIMaxXRatio range.
Definition Filter.hpp:1403
A factory class for creating filters.
Definition Filter.hpp:310
static std::string getFilterVendorSpecificCode(const std::string &name)
Get the vendor specific code of a filter by filter name.
Definition Filter.hpp:344
static std::shared_ptr< Filter > createFilter(const std::string &name)
Create a filter by name.
Definition Filter.hpp:315
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:329
The Filter class is the base class for all filters in the SDK.
Definition Filter.hpp:77
FilterCallback callback_
Definition Filter.hpp:81
bool is()
Check if the runtime type of the filter object is compatible with a given type.
Definition Filter.hpp:2343
virtual void init(ob_filter *impl)
Definition Filter.hpp:90
std::shared_ptr< T > as()
Definition Filter.hpp:298
virtual const std::string & getName() const
Get the type of filter.
Definition Filter.hpp:139
virtual std::vector< OBFilterConfigSchemaItem > getConfigSchemaVec() const
Get the Config Schema Vec object.
Definition Filter.hpp:241
virtual void enable(bool enable) const
enable the filter
Definition Filter.hpp:156
std::string name_
Definition Filter.hpp:80
virtual void setConfigValue(const std::string &configName, double value) const
Set the filter config value by name.
Definition Filter.hpp:254
virtual std::string getConfigSchema() const
Get config schema of the filter.
Definition Filter.hpp:228
std::vector< OBFilterConfigSchemaItem > configSchemaVec_
Definition Filter.hpp:82
virtual bool isEnabled() const
Return Enable State.
Definition Filter.hpp:165
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:198
virtual std::shared_ptr< Frame > process(std::shared_ptr< const Frame > frame) const
Processes a frame synchronously.
Definition Filter.hpp:179
ob_filter * getImpl() const
Get the Impl object of the filter.
Definition Filter.hpp:130
virtual void reset() const
Reset the filter, freeing the internal cache, stopping the processing thread, and clearing the pendin...
Definition Filter.hpp:147
ob_filter * impl_
Definition Filter.hpp:79
virtual const char * type()
Definition Filter.hpp:285
virtual double getConfigValue(const std::string &configName) const
Get the Config Value object by name.
Definition Filter.hpp:270
virtual void setCallBack(FilterCallback callback)
Set the callback function for asynchronous processing.
Definition Filter.hpp:213
Filter(ob_filter *impl)
Definition Filter.hpp:113
virtual ~Filter() noexcept
Definition Filter.hpp:117
The FormatConvertFilter class is a subclass of Filter that performs format conversion.
Definition Filter.hpp:554
virtual ~FormatConvertFilter() noexcept override=default
void setFormatConvertType(OBConvertFormat type)
Set the format conversion type.
Definition Filter.hpp:570
HdrMerge processing block, the processing merges between depth frames with different sub-preset seque...
Definition Filter.hpp:580
virtual ~HdrMerge() noexcept override=default
Hole filling filter,the processing performed depends on the selected hole filling mode.
Definition Filter.hpp:1023
void setFilterMode(OBHoleFillingMode mode)
Set the HoleFillingFilter mode.
Definition Filter.hpp:1039
HoleFillingFilter(const std::string &activationKey="")
Definition Filter.hpp:1025
OBHoleFillingMode getFilterMode()
Get the HoleFillingFilter mode.
Definition Filter.hpp:1048
~HoleFillingFilter() noexcept override=default
LutNoiseRemoval filter.
Definition Filter.hpp:1969
OBUint16PropertyRange getHeightRange()
Get the lut noise removal filter height range.
Definition Filter.hpp:2065
OBUint16PropertyRange getMinDiffRange()
Get the lut noise removal filter min_diff range.
Definition Filter.hpp:2033
OBLutNoiseRemovalFilterParams getFilterParams()
Get the lut noise removal filter params.
Definition Filter.hpp:1997
OBUint16PropertyRange getWidthRange()
Get the lut noise removal filter width range.
Definition Filter.hpp:2049
OBUint16PropertyRange getMaxLutRange(int index)
Get the lut noise removal filter max_lut range for a given index (0-15).
Definition Filter.hpp:2013
~LutNoiseRemovalFilter() noexcept override=default
LutNoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:1971
void setFilterParams(OBLutNoiseRemovalFilterParams filterParams)
Set the lut noise removal filter params.
Definition Filter.hpp:1984
MgcNoiseRemoval filter.
Definition Filter.hpp:1776
OBUint16PropertyRange getWidthRange()
Get the mgc noise removal filter width range.
Definition Filter.hpp:1937
OBUint16PropertyRange getHeightRange()
Get the mgc noise removal filter height range.
Definition Filter.hpp:1953
OBUint16PropertyRange getMaxWidthRightRange()
Get the mgc noise removal filter max_width_right range.
Definition Filter.hpp:1841
OBUint16PropertyRange getMaxWidthLeftRange()
Get the mgc noise removal filter max_width_left range.
Definition Filter.hpp:1825
OBUint16PropertyRange getLimitYthRange()
Get the mgc noise removal filter limit_y_th range.
Definition Filter.hpp:1921
void setFilterParams(OBMgcNoiseRemovalFilterParams filterParams)
Set the mgc noise removal filter params.
Definition Filter.hpp:1791
MgcNoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:1778
OBUint16PropertyRange getMarginXthRange()
Get the mgc noise removal filter margin_x_th range.
Definition Filter.hpp:1873
OBUint16PropertyRange getLimitXthRange()
Get the mgc noise removal filter limit_x_th range.
Definition Filter.hpp:1905
OBMgcNoiseRemovalFilterParams getFilterParams()
Get the mgc noise removal filter params.
Definition Filter.hpp:1807
OBUint16PropertyRange getMarginYthRange()
Get the mgc noise removal filter margin_y_th range.
Definition Filter.hpp:1889
~MgcNoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMaxRadiusRange()
Get the mgc noise removal filter max_radius range.
Definition Filter.hpp:1857
The noise removal filter,removing scattering depth pixels.
Definition Filter.hpp:1056
OBUint16PropertyRange getDispDiffRange()
Get the noise removal filter disp diff range.
Definition Filter.hpp:1095
void setFilterParams(OBNoiseRemovalFilterParams filterParams)
Set the noise removal filter params.
Definition Filter.hpp:1072
NoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:1058
~NoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMaxSizeRange()
Get the noise removal filter max size range.
Definition Filter.hpp:1111
OBNoiseRemovalFilterParams getFilterParams()
Get the noise removal filter params.
Definition Filter.hpp:1083
~OBFilterList() noexcept
Definition Filter.hpp:2269
uint32_t getCount() const
Get the number of filters.
Definition Filter.hpp:2280
uint32_t count() const
Definition Filter.hpp:2303
std::shared_ptr< Filter > getFilter(uint32_t index)
Get the Filter object at the specified index.
Definition Filter.hpp:2294
OBFilterList(ob_filter_list_t *impl)
Definition Filter.hpp:2267
The PointCloudFilter class is a subclass of Filter that generates point clouds.
Definition Filter.hpp:355
void setCoordinateSystem(OBCoordinateSystemType type)
Set the point cloud coordinate system.
Definition Filter.hpp:404
void setCoordinateDataScaled(float factor)
Set the point cloud coordinate data zoom factor.
Definition Filter.hpp:383
void setCameraParam(OBCameraParam param)
Definition Filter.hpp:441
void setPositionDataScaled(float scale)
Definition Filter.hpp:432
void setCreatePointFormat(OBFormat format)
Set the output pointcloud frame format.
Definition Filter.hpp:371
virtual ~PointCloudFilter() noexcept override=default
void setFrameAlignState(bool state)
Definition Filter.hpp:437
OBIntPropertyRange getDecimationFactorRange()
Get the property range of the decimation factor range.
Definition Filter.hpp:421
void setDecimationFactor(int value)
Set the point cloud decimation factor. Calling this function to decimation factor will output thedown...
Definition Filter.hpp:414
void setColorDataNormalization(bool state)
Set point cloud color data normalization.
Definition Filter.hpp:395
Create SequenceIdFilter processing block.
Definition Filter.hpp:595
int getSelectSequenceId()
Get the current sequence id.
Definition Filter.hpp:642
void selectSequenceId(int sequence_id)
Set the sequenceId filter params.
Definition Filter.hpp:633
virtual ~SequenceIdFilter() noexcept override
Definition Filter.hpp:621
OBSequenceIdItem * getSequenceIdList()
Definition Filter.hpp:646
int getSequenceIdListSize()
Get the sequenceId list size.
Definition Filter.hpp:655
Spatial advanced filte smooths the image by calculating frame with alpha and delta settings alpha def...
Definition Filter.hpp:770
void setFilterParams(OBSpatialAdvancedFilterParams params)
Set the spatial advanced filter params.
Definition Filter.hpp:868
OBSpatialAdvancedFilterParams getFilterParams()
Get the spatial advanced filter params.
Definition Filter.hpp:854
OBUint16PropertyRange getRadiusRange()
Get the spatial advanced filter radius range.
Definition Filter.hpp:820
SpatialAdvancedFilter(const std::string &activationKey="")
Definition Filter.hpp:772
OBFloatPropertyRange getAlphaRange()
Get the spatial advanced filter alpha range.
Definition Filter.hpp:786
OBUint16PropertyRange getDispDiffRange()
Get the spatial advanced filter dispdiff range.
Definition Filter.hpp:803
virtual ~SpatialAdvancedFilter() noexcept override=default
OBIntPropertyRange getMagnitudeRange()
Get the spatial advanced filter magnitude range.
Definition Filter.hpp:837
The Spatial Fast Filter utilizes an enhanced median smoothing algorithm, designed to significantly re...
Definition Filter.hpp:880
virtual ~SpatialFastFilter() noexcept override=default
SpatialFastFilter(const std::string &activationKey="")
Definition Filter.hpp:882
void setFilterParams(OBSpatialFastFilterParams params)
Set the spatial fast filter params.
Definition Filter.hpp:924
OBSpatialFastFilterParams getFilterParams()
Get the spatial fast filter params.
Definition Filter.hpp:913
OBIntPropertyRange getRadiusRange()
Get the spatial fast filter radius range.
Definition Filter.hpp:896
The Spatial Moderate Filter utilizes an optimized average smoothing algorithm, to achieve a balance b...
Definition Filter.hpp:933
SpatialModerateFilter(const std::string &activationKey="")
Definition Filter.hpp:935
OBIntPropertyRange getRadiusRange()
Get the spatial moderate filter radius range.
Definition Filter.hpp:966
virtual ~SpatialModerateFilter() noexcept override=default
void setFilterParams(OBSpatialModerateFilterParams params)
Set the spatial moderate filter params.
Definition Filter.hpp:1013
OBSpatialModerateFilterParams getFilterParams()
Get the spatial moderate filter params.
Definition Filter.hpp:1000
OBIntPropertyRange getMagnitudeRange()
Get the spatial moderate filter magnitude range.
Definition Filter.hpp:949
OBIntPropertyRange getDispDiffRange()
Get the spatial moderate filter disp diff range.
Definition Filter.hpp:983
Temporal filter.
Definition Filter.hpp:1127
OBFloatPropertyRange getWeightRange()
Get the TemporalFilter weight range.
Definition Filter.hpp:1169
void setDiffScale(float value)
Set the TemporalFilter diffscale value.
Definition Filter.hpp:1160
~TemporalFilter() noexcept override=default
OBFloatPropertyRange getDiffScaleRange()
Get the TemporalFilter diffscale range.
Definition Filter.hpp:1143
void setWeight(float value)
Set the TemporalFilter weight value.
Definition Filter.hpp:1186
TemporalFilter(const std::string &activationKey="")
Definition Filter.hpp:1129
Creates depth Thresholding filter By controlling min and max options on the block.
Definition Filter.hpp:707
bool setValueRange(uint16_t min, uint16_t max)
Set the threshold filter max and min range.
Definition Filter.hpp:755
OBIntPropertyRange getMinRange()
Get the threshold filter min range.
Definition Filter.hpp:723
virtual ~ThresholdFilter() noexcept override=default
OBIntPropertyRange getMaxRange()
Get the threshold filter max range.
Definition Filter.hpp:740
UnDistortionFilter removes lens distortion from a chosen stream (Color, IR, or Depth).
Definition Filter.hpp:497
void setNewCameraMatrix(OBCameraIntrinsic depthIntrinsic)
Set the new camera matrix used to project the undistorted image (equivalent to OpenCV's newCameraMatr...
Definition Filter.hpp:534
void setStreamType(OBStreamType streamType)
Set which stream to undistort (default: OB_STREAM_COLOR).
Definition Filter.hpp:512
virtual ~UnDistortionFilter() noexcept override=default
void clearNewCameraMatrix()
Clear the new camera matrix and return to pure undistortion.
Definition Filter.hpp:546
UnDistortionFilter(OBStreamType streamType=OB_STREAM_COLOR)
Definition Filter.hpp:499
OBStreamType getStreamType() const
Definition Filter.hpp:516
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:2311
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:33
T getPropertyRange(const OBFilterConfigSchemaItem &item, const double cur)
Get T Property Range.
Definition Filter.hpp:61
Structure for camera intrinsic parameters.
Definition ObTypes.h:466
float fx
Focal length in x direction.
Definition ObTypes.h:467
float cx
Optical center abscissa.
Definition ObTypes.h:469
int16_t height
Image height.
Definition ObTypes.h:472
float cy
Optical center ordinate.
Definition ObTypes.h:470
int16_t width
Image width.
Definition ObTypes.h:471
float fy
Focal length in y direction.
Definition ObTypes.h:468
Structure for camera parameters.
Definition ObTypes.h:526
int limit_y_th
Maximum vertical threshold.
Definition ObTypes.h:1215
int margin_x_th
Horizontal threshold settings.
Definition ObTypes.h:1212
uint32_t height
Image height.
Definition ObTypes.h:1217
uint32_t width
Image width.
Definition ObTypes.h:1216
bool enable_direction
Set to true for horizontal and vertical, false for horizontal only.
Definition ObTypes.h:1218
int limit_x_th
Maximum horizontal threshold.
Definition ObTypes.h:1214
int margin_y_th
Vertical threshold settings.
Definition ObTypes.h:1213
Configuration Item for the filter.
Definition ObTypes.h:1735
double min
Minimum value casted to double.
Definition ObTypes.h:1738
double max
Maximum value casted to double.
Definition ObTypes.h:1739
double def
Default value casted to double.
Definition ObTypes.h:1741
double step
Step value casted to double.
Definition ObTypes.h:1740
Structure for float range.
Definition ObTypes.h:410
Structure for integer range.
Definition ObTypes.h:399
Configuration parameters for the LUT noise removal filter.
Definition ObTypes.h:1239
uint32_t width
Depth map width the above parameters correspond to.
Definition ObTypes.h:1242
uint32_t height
Depth map height the above parameters correspond to.
Definition ObTypes.h:1243
uint16_t max_lut[16]
LUT max size of noise pixels (4x4 LUT, 16 entries total).
Definition ObTypes.h:1240
uint16_t min_diff
Difference threshold between neighbor pixels.
Definition ObTypes.h:1241
Configuration parameters for the MGC noise removal filter.
Definition ObTypes.h:1224
int limit_y_th
Maximum vertical threshold.
Definition ObTypes.h:1231
int limit_x_th
Maximum horizontal threshold.
Definition ObTypes.h:1230
int max_radius
Chamfer radius threshold settings.
Definition ObTypes.h:1227
int max_width_right
Right chamfer threshold settings.
Definition ObTypes.h:1226
int margin_y_th
Vertical threshold settings.
Definition ObTypes.h:1229
uint32_t height
Depth map height the above parameters correspond to.
Definition ObTypes.h:1233
uint32_t width
Depth map width the above parameters correspond to.
Definition ObTypes.h:1232
int max_width_left
Left chamfer threshold settings.
Definition ObTypes.h:1225
int margin_x_th
Horizontal threshold settings.
Definition ObTypes.h:1228
SequenceId fliter list item.
Definition ObTypes.h:1156
Structure for float range.
Definition ObTypes.h:421
Structure for float range.
Definition ObTypes.h:432
Get the type of a PropertyRange member.
Definition Filter.hpp:38
The error class exposed by the SDK, users can get detailed error information according to the error.
Definition ObTypes.h:162
Extensible options for activating a private filter instance.
Definition ObTypes.h:1752
uint32_t struct_size
Size of this struct in bytes, set by the caller to sizeof(ob_priv_filter_activate_options).
Definition ObTypes.h:1753
const char * model_path
Path to the inference model file. NULL or empty selects the filter's default model.
Definition ObTypes.h:1754