OrbbecSDK 2.8.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 <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
178 virtual std::shared_ptr<Frame> process(std::shared_ptr<const Frame> frame) const {
179 ob_error *error = nullptr;
180 auto result = ob_filter_process(impl_, frame->getImpl(), &error);
181 Error::handle(&error);
182 if(!result) {
183 return nullptr;
184 }
185 return std::make_shared<Frame>(result);
186 }
187
193 virtual void pushFrame(std::shared_ptr<Frame> frame) const {
194 ob_error *error = nullptr;
195 ob_filter_push_frame(impl_, frame->getImpl(), &error);
196 Error::handle(&error);
197 }
198
204 virtual void setCallBack(FilterCallback callback) {
205 callback_ = callback;
206 ob_error *error = nullptr;
207 ob_filter_set_callback(impl_, &Filter::filterCallback, this, &error);
208 Error::handle(&error);
209 }
210
219 virtual std::string getConfigSchema() const {
220 ob_error *error = nullptr;
221 auto schema = ob_filter_get_config_schema(impl_, &error);
222 Error::handle(&error);
223 return schema;
224 }
225
232 virtual std::vector<OBFilterConfigSchemaItem> getConfigSchemaVec() const {
233 return configSchemaVec_;
234 }
235
245 virtual void setConfigValue(const std::string &configName, double value) const {
246 ob_error *error = nullptr;
247 ob_filter_set_config_value(impl_, configName.c_str(), value, &error);
248 Error::handle(&error);
249 }
250
261 virtual double getConfigValue(const std::string &configName) const {
262 ob_error *error = nullptr;
263 double value = ob_filter_get_config_value(impl_, configName.c_str(), &error);
264 Error::handle(&error);
265 return value;
266 }
267
268private:
269 static void filterCallback(ob_frame *frame, void *userData) {
270 auto filter = static_cast<Filter *>(userData);
271 filter->callback_(std::make_shared<Frame>(frame));
272 }
273
274public:
275 // The following interfaces are deprecated and are retained here for compatibility purposes.
276 virtual const char *type() {
277 return getName().c_str();
278 }
279
287 template <typename T> bool is();
288
289 template <typename T> std::shared_ptr<T> as() {
290 if(!is<T>()) {
291 throw std::runtime_error("unsupported operation, object's type is not require type");
292 }
293
294 return std::static_pointer_cast<T>(shared_from_this());
295 }
296};
297
302public:
306 static std::shared_ptr<Filter> createFilter(const std::string &name) {
307 ob_error *error = nullptr;
308 auto impl = ob_create_filter(name.c_str(), &error);
309 Error::handle(&error);
310 return std::make_shared<Filter>(impl);
311 }
312
320 static std::shared_ptr<Filter> createPrivateFilter(const std::string &name, const std::string &activationKey) {
321 ob_error *error = nullptr;
322 auto impl = ob_create_private_filter(name.c_str(), activationKey.c_str(), &error);
323 Error::handle(&error);
324 return std::make_shared<Filter>(impl);
325 }
326
335 static std::string getFilterVendorSpecificCode(const std::string &name) {
336 ob_error *error = nullptr;
337 auto code = ob_filter_get_vendor_specific_code(name.c_str(), &error);
338 Error::handle(&error);
339 return code;
340 }
341};
342
346class PointCloudFilter : public Filter {
347public:
349 ob_error *error = nullptr;
350 auto impl = ob_create_filter("PointCloudFilter", &error);
351 Error::handle(&error);
352 init(impl);
353 }
354
355 virtual ~PointCloudFilter() noexcept override = default;
356
363 setConfigValue("pointFormat", static_cast<double>(format));
364 }
365
374 void setCoordinateDataScaled(float factor) {
375 setConfigValue("coordinateDataScale", factor);
376 }
377
386 void setColorDataNormalization(bool state) {
387 setConfigValue("colorDataNormalization", state);
388 }
389
396 setConfigValue("coordinateSystemType", static_cast<double>(type));
397 }
398
405 void setDecimationFactor(int value) {
406 setConfigValue("decimate", value);
407 }
408
413 OBIntPropertyRange scaleRange{};
414 if(configSchemaVec_.size() != 0) {
415 const auto &item = configSchemaVec_[5];
416 scaleRange = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("decimate"));
417 }
418 return scaleRange;
419 }
420
421public:
422 // The following interfaces are deprecated and are retained here for compatibility purposes.
423 void setPositionDataScaled(float scale) {
425 }
426
427 // The following interfaces are deprecated and are retained here for compatibility purposes.
428 void setFrameAlignState(bool state) {
429 (void)state; // to complie
430 }
431 // The following interfaces are deprecated and are retained here for compatibility purposes.
433 (void)param;
434 }
435};
436
440class Align : public Filter {
441public:
442 Align(OBStreamType alignToStreamType) {
443 ob_error *error = nullptr;
444 auto impl = ob_create_filter("Align", &error);
445 Error::handle(&error);
446 init(impl);
447
448 setConfigValue("AlignType", static_cast<double>(alignToStreamType));
449 }
450
451 virtual ~Align() noexcept override = default;
452
454 return static_cast<OBStreamType>(static_cast<int>(getConfigValue("AlignType")));
455 }
456
467 void setMatchTargetResolution(bool state) {
468 setConfigValue("MatchTargetRes", state);
469 }
470
477 void setAlignToStreamProfile(std::shared_ptr<const StreamProfile> profile) {
478 ob_error *error = nullptr;
479 ob_align_filter_set_align_to_stream_profile(impl_, profile->getImpl(), &error);
480 Error::handle(&error);
481 }
482};
483
488public:
490 ob_error *error = nullptr;
491 auto impl = ob_create_filter("FormatConverter", &error);
492 Error::handle(&error);
493 init(impl);
494 }
495
496 virtual ~FormatConvertFilter() noexcept override = default;
497
504 setConfigValue("convertType", static_cast<double>(type));
505 }
506};
507
513class HdrMerge : public Filter {
514public:
516 ob_error *error = nullptr;
517 auto impl = ob_create_filter("HDRMerge", &error);
518 Error::handle(&error);
519 init(impl);
520 }
521
522 virtual ~HdrMerge() noexcept override = default;
523};
524
528class SequenceIdFilter : public Filter {
529private:
530 std::map<float, std::string> sequenceIdList_{ { 0.f, "all" }, { 1.f, "1" } };
531 OBSequenceIdItem *outputSequenceIdList_ = nullptr;
532
533 void initSequenceIdList() {
534 outputSequenceIdList_ = new OBSequenceIdItem[sequenceIdList_.size()];
535
536 int i = 0;
537 for(const auto &pair: sequenceIdList_) {
538 outputSequenceIdList_[i].sequenceSelectId = static_cast<int>(pair.first);
539 strncpy(outputSequenceIdList_[i].name, pair.second.c_str(), sizeof(outputSequenceIdList_[i].name) - 1);
540 outputSequenceIdList_[i].name[sizeof(outputSequenceIdList_[i].name) - 1] = '\0';
541 ++i;
542 }
543 }
544
545public:
547 ob_error *error = nullptr;
548 auto impl = ob_create_filter("SequenceIdFilter", &error);
549 Error::handle(&error);
550 init(impl);
551 initSequenceIdList();
552 }
553
554 virtual ~SequenceIdFilter() noexcept override {
555 if(outputSequenceIdList_) {
556 delete[] outputSequenceIdList_;
557 outputSequenceIdList_ = nullptr;
558 }
559 }
560
566 void selectSequenceId(int sequence_id) {
567 setConfigValue("sequenceid", static_cast<double>(sequence_id));
568 }
569
576 return static_cast<int>(getConfigValue("sequenceid"));
577 }
578
580 return outputSequenceIdList_;
581 }
582
589 return static_cast<int>(sequenceIdList_.size());
590 }
591};
592
596class DecimationFilter : public Filter {
597public:
599 ob_error *error = nullptr;
600 auto impl = ob_create_filter("DecimationFilter", &error);
601 Error::handle(&error);
602 init(impl);
603 }
604
605 virtual ~DecimationFilter() noexcept override = default;
606
612 void setScaleValue(uint8_t value) {
613 setConfigValue("decimate", static_cast<double>(value));
614 }
615
619 uint8_t getScaleValue() {
620 return static_cast<uint8_t>(getConfigValue("decimate"));
621 }
622
627 OBUint8PropertyRange scaleRange{};
628 if(configSchemaVec_.size() != 0) {
629 const auto &item = configSchemaVec_[0];
630 scaleRange = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("decimate"));
631 }
632 return scaleRange;
633 }
634};
635
640class ThresholdFilter : public Filter {
641public:
643 ob_error *error = nullptr;
644 auto impl = ob_create_filter("ThresholdFilter", &error);
645 Error::handle(&error);
646 init(impl);
647 }
648
649 virtual ~ThresholdFilter() noexcept override = default;
650
657 OBIntPropertyRange range{};
658 const auto &schemaVec = getConfigSchemaVec();
659 for(const auto &item: schemaVec) {
660 if(strcmp(item.name, "min") == 0) {
662 break;
663 }
664 }
665 return range;
666 }
667
674 OBIntPropertyRange range{};
675 const auto &schemaVec = getConfigSchemaVec();
676 for(const auto &item: schemaVec) {
677 if(strcmp(item.name, "max") == 0) {
679 break;
680 }
681 }
682 return range;
683 }
684
688 bool setValueRange(uint16_t min, uint16_t max) {
689 if(min >= max) {
690 return false;
691 }
692 setConfigValue("min", min);
693 setConfigValue("max", max);
694 return true;
695 }
696};
697
704public:
705 SpatialAdvancedFilter(const std::string &activationKey = "") {
706 ob_error *error = nullptr;
707 auto impl = ob_create_private_filter("SpatialAdvancedFilter", activationKey.c_str(), &error);
708 Error::handle(&error);
709 init(impl);
710 }
711
712 virtual ~SpatialAdvancedFilter() noexcept override = default;
713
720 OBFloatPropertyRange range{};
721 const auto &schemaVec = getConfigSchemaVec();
722 for(const auto &item: schemaVec) {
723 if(strcmp(item.name, "alpha") == 0) {
725 break;
726 }
727 }
728 return range;
729 }
730
737 OBUint16PropertyRange range{};
738 const auto &schemaVec = getConfigSchemaVec();
739 for(const auto &item: schemaVec) {
740 if(strcmp(item.name, "disp_diff") == 0) {
742 break;
743 }
744 }
745 return range;
746 }
747
754 OBUint16PropertyRange range{};
755 const auto &schemaVec = getConfigSchemaVec();
756 for(const auto &item: schemaVec) {
757 if(strcmp(item.name, "radius") == 0) {
759 break;
760 }
761 }
762 return range;
763 }
764
771 OBIntPropertyRange range{};
772 const auto &schemaVec = getConfigSchemaVec();
773 for(const auto &item: schemaVec) {
774 if(strcmp(item.name, "magnitude") == 0) {
775 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("magnitude"));
776 break;
777 }
778 }
779 return range;
780 }
781
789 params.alpha = static_cast<float>(getConfigValue("alpha"));
790 params.disp_diff = static_cast<uint16_t>(getConfigValue("disp_diff"));
791 params.magnitude = static_cast<uint8_t>(getConfigValue("magnitude"));
792 params.radius = static_cast<uint16_t>(getConfigValue("radius"));
793 return params;
794 }
795
802 setConfigValue("alpha", params.alpha);
803 setConfigValue("disp_diff", params.disp_diff);
804 setConfigValue("magnitude", params.magnitude);
805 setConfigValue("radius", params.radius);
806 }
807};
808
813class SpatialFastFilter : public Filter {
814public:
815 SpatialFastFilter(const std::string &activationKey = "") {
816 ob_error *error = nullptr;
817 auto impl = ob_create_private_filter("SpatialFastFilter", activationKey.c_str(), &error);
818 Error::handle(&error);
819 init(impl);
820 }
821
822 virtual ~SpatialFastFilter() noexcept override = default;
823
830 OBIntPropertyRange range{};
831 const auto &schemaVec = getConfigSchemaVec();
832 for(const auto &item: schemaVec) {
833 if(strcmp(item.name, "radius") == 0) {
835 break;
836 }
837 }
838 return range;
839 }
840
848 params.radius = static_cast<uint8_t>(getConfigValue("radius"));
849 return params;
850 }
851
858 setConfigValue("radius", params.radius);
859 }
860};
861
867public:
868 SpatialModerateFilter(const std::string &activationKey = "") {
869 ob_error *error = nullptr;
870 auto impl = ob_create_private_filter("SpatialModerateFilter", activationKey.c_str(), &error);
871 Error::handle(&error);
872 init(impl);
873 }
874
875 virtual ~SpatialModerateFilter() noexcept override = default;
876
883 OBIntPropertyRange range{};
884 const auto &schemaVec = getConfigSchemaVec();
885 for(const auto &item: schemaVec) {
886 if(strcmp(item.name, "magnitude") == 0) {
887 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("magnitude"));
888 break;
889 }
890 }
891 return range;
892 }
893
900 OBIntPropertyRange range{};
901 const auto &schemaVec = getConfigSchemaVec();
902 for(const auto &item: schemaVec) {
903 if(strcmp(item.name, "radius") == 0) {
905 break;
906 }
907 }
908 return range;
909 }
910
917 OBIntPropertyRange range{};
918 const auto &schemaVec = getConfigSchemaVec();
919 for(const auto &item: schemaVec) {
920 if(strcmp(item.name, "disp_diff") == 0) {
921 range = getPropertyRange<OBIntPropertyRange>(item, getConfigValue("disp_diff"));
922 break;
923 }
924 }
925 return range;
926 }
927
935 params.magnitude = static_cast<uint8_t>(getConfigValue("magnitude"));
936 params.radius = static_cast<uint8_t>(getConfigValue("radius"));
937 params.disp_diff = static_cast<uint16_t>(getConfigValue("disp_diff"));
938 return params;
939 }
940
947 setConfigValue("magnitude", params.magnitude);
948 setConfigValue("radius", params.radius);
949 setConfigValue("disp_diff", params.disp_diff);
950 }
951};
952
956class HoleFillingFilter : public Filter {
957public:
958 HoleFillingFilter(const std::string &activationKey = "") {
959 ob_error *error = nullptr;
960 auto impl = ob_create_private_filter("HoleFillingFilter", activationKey.c_str(), &error);
961 Error::handle(&error);
962 init(impl);
963 }
964
965 ~HoleFillingFilter() noexcept override = default;
966
973 setConfigValue("hole_filling_mode", static_cast<double>(mode));
974 }
975
982 return static_cast<OBHoleFillingMode>(static_cast<int>(getConfigValue("hole_filling_mode")));
983 }
984};
985
990public:
991 NoiseRemovalFilter(const std::string &activationKey = "") {
992 ob_error *error = nullptr;
993 auto impl = ob_create_private_filter("NoiseRemovalFilter", activationKey.c_str(), &error);
994 Error::handle(&error);
995 init(impl);
996 }
997
998 ~NoiseRemovalFilter() noexcept override = default;
999
1006 setConfigValue("max_size", static_cast<double>(filterParams.max_size));
1007 setConfigValue("min_diff", static_cast<double>(filterParams.disp_diff));
1008 // todo:set noise remove type
1009 }
1010
1018 param.max_size = static_cast<uint16_t>(getConfigValue("max_size"));
1019 param.disp_diff = static_cast<uint16_t>(getConfigValue("min_diff"));
1020 // todo: type is not set
1021 return param;
1022 }
1023
1029 OBUint16PropertyRange range{};
1030 const auto &schemaVec = getConfigSchemaVec();
1031 for(const auto &item: schemaVec) {
1032 if(strcmp(item.name, "min_diff") == 0) {
1034 break;
1035 }
1036 }
1037 return range;
1038 }
1039
1045 OBUint16PropertyRange range{};
1046 const auto &schemaVec = getConfigSchemaVec();
1047 for(const auto &item: schemaVec) {
1048 if(strcmp(item.name, "max_size") == 0) {
1050 break;
1051 }
1052 }
1053 return range;
1054 }
1055};
1056
1060class TemporalFilter : public Filter {
1061public:
1062 TemporalFilter(const std::string &activationKey = "") {
1063 ob_error *error = nullptr;
1064 auto impl = ob_create_private_filter("TemporalFilter", activationKey.c_str(), &error);
1065 Error::handle(&error);
1066 init(impl);
1067 }
1068
1069 ~TemporalFilter() noexcept override = default;
1070
1077 OBFloatPropertyRange range{};
1078 const auto &schemaVec = getConfigSchemaVec();
1079 for(const auto &item: schemaVec) {
1080 if(strcmp(item.name, "diff_scale") == 0) {
1081 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("diff_scale"));
1082 break;
1083 }
1084 }
1085 return range;
1086 }
1087
1093 void setDiffScale(float value) {
1094 setConfigValue("diff_scale", static_cast<double>(value));
1095 }
1096
1103 OBFloatPropertyRange range{};
1104 const auto &schemaVec = getConfigSchemaVec();
1105 for(const auto &item: schemaVec) {
1106 if(strcmp(item.name, "weight") == 0) {
1108 break;
1109 }
1110 }
1111 return range;
1112 }
1113
1119 void setWeight(float value) {
1120 setConfigValue("weight", static_cast<double>(value));
1121 }
1122};
1123
1128public:
1129 EdgeNoiseRemovalFilter(const std::string &activationKey = "") {
1130 ob_error *error = nullptr;
1131 auto impl = ob_create_private_filter("EdgeNoiseRemovalFilter", activationKey.c_str(), &error);
1132 Error::handle(&error);
1133 init(impl);
1134 }
1135
1136 ~EdgeNoiseRemovalFilter() noexcept override = default;
1137
1143 OBUint16PropertyRange range{};
1144 const auto & schemaVec = getConfigSchemaVec();
1145 for(const auto &item: schemaVec) {
1146 if(strcmp(item.name, "margin_x_th") == 0) {
1147 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_x_th"));
1148 break;
1149 }
1150 }
1151 return range;
1152 }
1153
1159 OBUint16PropertyRange range{};
1160 const auto & schemaVec = getConfigSchemaVec();
1161 for(const auto &item: schemaVec) {
1162 if(strcmp(item.name, "margin_y_th") == 0) {
1163 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_y_th"));
1164 break;
1165 }
1166 }
1167 return range;
1168 }
1169
1175 OBUint16PropertyRange range{};
1176 const auto & schemaVec = getConfigSchemaVec();
1177 for(const auto &item: schemaVec) {
1178 if(strcmp(item.name, "limit_x_th") == 0) {
1179 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_x_th"));
1180 break;
1181 }
1182 }
1183 return range;
1184 }
1185
1191 OBUint16PropertyRange range{};
1192 const auto & schemaVec = getConfigSchemaVec();
1193 for(const auto &item: schemaVec) {
1194 if(strcmp(item.name, "limit_y_th") == 0) {
1195 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_y_th"));
1196 break;
1197 }
1198 }
1199 return range;
1200 }
1201
1207 OBUint16PropertyRange range{};
1208 const auto & schemaVec = getConfigSchemaVec();
1209 for(const auto &item: schemaVec) {
1210 if(strcmp(item.name, "enable_vertical_direction") == 0) {
1211 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("enable_vertical_direction"));
1212 break;
1213 }
1214 }
1215 return range;
1216 }
1217
1223 OBUint16PropertyRange range{};
1224 const auto & schemaVec = getConfigSchemaVec();
1225 for(const auto &item: schemaVec) {
1226 if(strcmp(item.name, "width") == 0) {
1228 break;
1229 }
1230 }
1231 return range;
1232 }
1233
1239 OBUint16PropertyRange range{};
1240 const auto & schemaVec = getConfigSchemaVec();
1241 for(const auto &item: schemaVec) {
1242 if(strcmp(item.name, "height") == 0) {
1244 break;
1245 }
1246 }
1247 return range;
1248 }
1249
1256 setConfigValue("margin_x_th", static_cast<double>(filterParams.margin_x_th));
1257 setConfigValue("margin_y_th", static_cast<double>(filterParams.margin_y_th));
1258 setConfigValue("limit_x_th", static_cast<double>(filterParams.limit_x_th));
1259 setConfigValue("limit_y_th", static_cast<double>(filterParams.limit_y_th));
1260 setConfigValue("enable_vertical_direction", static_cast<double>(filterParams.enable_direction));
1261 setConfigValue("width", static_cast<double>(filterParams.width));
1262 setConfigValue("height", static_cast<double>(filterParams.height));
1263 }
1264
1272 param.margin_x_th = static_cast<uint16_t>(getConfigValue("margin_x_th"));
1273 param.margin_y_th = static_cast<uint16_t>(getConfigValue("margin_y_th"));
1274 param.limit_x_th = static_cast<uint16_t>(getConfigValue("limit_x_th"));
1275 param.limit_y_th = static_cast<uint16_t>(getConfigValue("limit_y_th"));
1276 param.enable_direction = static_cast<uint16_t>(getConfigValue("enable_vertical_direction"));
1277 param.width = static_cast<uint16_t>(getConfigValue("width"));
1278 param.height = static_cast<uint16_t>(getConfigValue("height"));
1279 return param;
1280 }
1281
1282};
1283
1288public:
1289 FalsePositiveFilter(const std::string &activationKey = "") {
1290 ob_error *error = nullptr;
1291 auto impl = ob_create_private_filter("FalsePositiveFilter", activationKey.c_str(), &error);
1292 Error::handle(&error);
1293 init(impl);
1294 }
1295
1296 virtual ~FalsePositiveFilter() noexcept override = default;
1297
1304 OBUint8PropertyRange range{};
1305 const auto &schemaVec = getConfigSchemaVec();
1306 for(const auto &item: schemaVec) {
1307 if(strcmp(item.name, "fpEdgeBleedFilterEnable") == 0) {
1308 range = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("fpEdgeBleedFilterEnable"));
1309 break;
1310 }
1311 }
1312 return range;
1313 }
1314
1321 OBFloatPropertyRange range{};
1322 const auto &schemaVec = getConfigSchemaVec();
1323 for(const auto &item: schemaVec) {
1324 if(strcmp(item.name, "fpebfROIMinXRatio") == 0) {
1325 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMinXRatio"));
1326 break;
1327 }
1328 }
1329 return range;
1330 }
1331
1338 OBFloatPropertyRange range{};
1339 const auto &schemaVec = getConfigSchemaVec();
1340 for(const auto &item: schemaVec) {
1341 if(strcmp(item.name, "fpebfROIMaxXRatio") == 0) {
1342 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMaxXRatio"));
1343 break;
1344 }
1345 }
1346 return range;
1347 }
1348
1355 OBFloatPropertyRange range{};
1356 const auto &schemaVec = getConfigSchemaVec();
1357 for(const auto &item: schemaVec) {
1358 if(strcmp(item.name, "fpebfROIMinYRatio") == 0) {
1359 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMinYRatio"));
1360 break;
1361 }
1362 }
1363 return range;
1364 }
1365
1372 OBFloatPropertyRange range{};
1373 const auto &schemaVec = getConfigSchemaVec();
1374 for(const auto &item: schemaVec) {
1375 if(strcmp(item.name, "fpebfROIMaxYRatio") == 0) {
1376 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fpebfROIMaxYRatio"));
1377 break;
1378 }
1379 }
1380 return range;
1381 }
1382
1389 OBUint8PropertyRange range{};
1390 const auto &schemaVec = getConfigSchemaVec();
1391 for(const auto &item: schemaVec) {
1392 if(strcmp(item.name, "fpTextureSparsityFilterEnable") == 0) {
1393 range = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("fpTextureSparsityFilterEnable"));
1394 break;
1395 }
1396 }
1397 return range;
1398 }
1399
1406 OBFloatPropertyRange range{};
1407 const auto &schemaVec = getConfigSchemaVec();
1408 for(const auto &item: schemaVec) {
1409 if(strcmp(item.name, "fptsfROIMinXRatio") == 0) {
1410 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMinXRatio"));
1411 break;
1412 }
1413 }
1414 return range;
1415 }
1416
1423 OBFloatPropertyRange range{};
1424 const auto &schemaVec = getConfigSchemaVec();
1425 for(const auto &item: schemaVec) {
1426 if(strcmp(item.name, "fptsfROIMaxXRatio") == 0) {
1427 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMaxXRatio"));
1428 break;
1429 }
1430 }
1431 return range;
1432 }
1433
1440 OBFloatPropertyRange range{};
1441 const auto &schemaVec = getConfigSchemaVec();
1442 for(const auto &item: schemaVec) {
1443 if(strcmp(item.name, "fptsfROIMinYRatio") == 0) {
1444 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMinYRatio"));
1445 break;
1446 }
1447 }
1448 return range;
1449 }
1450
1457 OBFloatPropertyRange range{};
1458 const auto &schemaVec = getConfigSchemaVec();
1459 for(const auto &item: schemaVec) {
1460 if(strcmp(item.name, "fptsfROIMaxYRatio") == 0) {
1461 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fptsfROIMaxYRatio"));
1462 break;
1463 }
1464 }
1465 return range;
1466 }
1467
1474 OBUint16PropertyRange range{};
1475 const auto &schemaVec = getConfigSchemaVec();
1476 for(const auto &item: schemaVec) {
1477 if(strcmp(item.name, "fptsfMaxNoiseLevel") == 0) {
1478 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fptsfMaxNoiseLevel"));
1479 break;
1480 }
1481 }
1482 return range;
1483 }
1484
1491 OBUint16PropertyRange range{};
1492 const auto &schemaVec = getConfigSchemaVec();
1493 for(const auto &item: schemaVec) {
1494 if(strcmp(item.name, "fptsfMaxSpeckleSize") == 0) {
1495 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fptsfMaxSpeckleSize"));
1496 break;
1497 }
1498 }
1499 return range;
1500 }
1501
1508 OBUint8PropertyRange range{};
1509 const auto &schemaVec = getConfigSchemaVec();
1510 for(const auto &item: schemaVec) {
1511 if(strcmp(item.name, "fpPatternAmbiguityFilterEnable") == 0) {
1512 range = getPropertyRange<OBUint8PropertyRange>(item, getConfigValue("fpPatternAmbiguityFilterEnable"));
1513 break;
1514 }
1515 }
1516 return range;
1517 }
1518
1525 OBFloatPropertyRange range{};
1526 const auto &schemaVec = getConfigSchemaVec();
1527 for(const auto &item: schemaVec) {
1528 if(strcmp(item.name, "fppafROIMinXRatio") == 0) {
1529 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMinXRatio"));
1530 break;
1531 }
1532 }
1533 return range;
1534 }
1535
1542 OBFloatPropertyRange range{};
1543 const auto &schemaVec = getConfigSchemaVec();
1544 for(const auto &item: schemaVec) {
1545 if(strcmp(item.name, "fppafROIMaxXRatio") == 0) {
1546 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMaxXRatio"));
1547 break;
1548 }
1549 }
1550 return range;
1551 }
1552
1559 OBFloatPropertyRange range{};
1560 const auto &schemaVec = getConfigSchemaVec();
1561 for(const auto &item: schemaVec) {
1562 if(strcmp(item.name, "fppafROIMinYRatio") == 0) {
1563 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMinYRatio"));
1564 break;
1565 }
1566 }
1567 return range;
1568 }
1569
1576 OBFloatPropertyRange range{};
1577 const auto &schemaVec = getConfigSchemaVec();
1578 for(const auto &item: schemaVec) {
1579 if(strcmp(item.name, "fppafROIMaxYRatio") == 0) {
1580 range = getPropertyRange<OBFloatPropertyRange>(item, getConfigValue("fppafROIMaxYRatio"));
1581 break;
1582 }
1583 }
1584 return range;
1585 }
1586
1593 OBUint16PropertyRange range{};
1594 const auto &schemaVec = getConfigSchemaVec();
1595 for(const auto &item: schemaVec) {
1596 if(strcmp(item.name, "fppafMaxNoiseLevel") == 0) {
1597 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fppafMaxNoiseLevel"));
1598 break;
1599 }
1600 }
1601 return range;
1602 }
1603
1610 OBUint16PropertyRange range{};
1611 const auto &schemaVec = getConfigSchemaVec();
1612 for(const auto &item: schemaVec) {
1613 if(strcmp(item.name, "fppafMaxSpeckleSize") == 0) {
1614 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("fppafMaxSpeckleSize"));
1615 break;
1616 }
1617 }
1618 return range;
1619 }
1620};
1621
1626public:
1627 MgcNoiseRemovalFilter(const std::string &activationKey = "") {
1628 ob_error *error = nullptr;
1629 auto impl = ob_create_private_filter("MgcNoiseRemovalFilter", activationKey.c_str(), &error);
1630 Error::handle(&error);
1631 init(impl);
1632 }
1633
1634 ~MgcNoiseRemovalFilter() noexcept override = default;
1635
1641 setConfigValue("max_width_left", static_cast<double>(filterParams.max_width_left));
1642 setConfigValue("max_width_right", static_cast<double>(filterParams.max_width_right));
1643 setConfigValue("max_radius", static_cast<double>(filterParams.max_radius));
1644 setConfigValue("margin_x_th", static_cast<double>(filterParams.margin_x_th));
1645 setConfigValue("margin_y_th", static_cast<double>(filterParams.margin_y_th));
1646 setConfigValue("limit_x_th", static_cast<double>(filterParams.limit_x_th));
1647 setConfigValue("limit_y_th", static_cast<double>(filterParams.limit_y_th));
1648 setConfigValue("width", static_cast<double>(filterParams.width));
1649 setConfigValue("height", static_cast<double>(filterParams.height));
1650 }
1651
1658 params.max_width_left = static_cast<int>(getConfigValue("max_width_left"));
1659 params.max_width_right = static_cast<int>(getConfigValue("max_width_right"));
1660 params.max_radius = static_cast<int>(getConfigValue("max_radius"));
1661 params.margin_x_th = static_cast<int>(getConfigValue("margin_x_th"));
1662 params.margin_y_th = static_cast<int>(getConfigValue("margin_y_th"));
1663 params.limit_x_th = static_cast<int>(getConfigValue("limit_x_th"));
1664 params.limit_y_th = static_cast<int>(getConfigValue("limit_y_th"));
1665 params.width = static_cast<uint32_t>(getConfigValue("width"));
1666 params.height = static_cast<uint32_t>(getConfigValue("height"));
1667 return params;
1668 }
1669
1675 OBUint16PropertyRange range{};
1676 const auto &schemaVec = getConfigSchemaVec();
1677 for(const auto &item: schemaVec) {
1678 if(strcmp(item.name, "max_width_left") == 0) {
1679 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("max_width_left"));
1680 break;
1681 }
1682 }
1683 return range;
1684 }
1685
1691 OBUint16PropertyRange range{};
1692 const auto &schemaVec = getConfigSchemaVec();
1693 for(const auto &item: schemaVec) {
1694 if(strcmp(item.name, "max_width_right") == 0) {
1695 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("max_width_right"));
1696 break;
1697 }
1698 }
1699 return range;
1700 }
1701
1707 OBUint16PropertyRange range{};
1708 const auto &schemaVec = getConfigSchemaVec();
1709 for(const auto &item: schemaVec) {
1710 if(strcmp(item.name, "max_radius") == 0) {
1711 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("max_radius"));
1712 break;
1713 }
1714 }
1715 return range;
1716 }
1717
1723 OBUint16PropertyRange range{};
1724 const auto &schemaVec = getConfigSchemaVec();
1725 for(const auto &item: schemaVec) {
1726 if(strcmp(item.name, "margin_x_th") == 0) {
1727 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_x_th"));
1728 break;
1729 }
1730 }
1731 return range;
1732 }
1733
1739 OBUint16PropertyRange range{};
1740 const auto &schemaVec = getConfigSchemaVec();
1741 for(const auto &item: schemaVec) {
1742 if(strcmp(item.name, "margin_y_th") == 0) {
1743 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("margin_y_th"));
1744 break;
1745 }
1746 }
1747 return range;
1748 }
1749
1755 OBUint16PropertyRange range{};
1756 const auto &schemaVec = getConfigSchemaVec();
1757 for(const auto &item: schemaVec) {
1758 if(strcmp(item.name, "limit_x_th") == 0) {
1759 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_x_th"));
1760 break;
1761 }
1762 }
1763 return range;
1764 }
1765
1771 OBUint16PropertyRange range{};
1772 const auto &schemaVec = getConfigSchemaVec();
1773 for(const auto &item: schemaVec) {
1774 if(strcmp(item.name, "limit_y_th") == 0) {
1775 range = getPropertyRange<OBUint16PropertyRange>(item, getConfigValue("limit_y_th"));
1776 break;
1777 }
1778 }
1779 return range;
1780 }
1781
1787 OBUint16PropertyRange range{};
1788 const auto &schemaVec = getConfigSchemaVec();
1789 for(const auto &item: schemaVec) {
1790 if(strcmp(item.name, "width") == 0) {
1792 break;
1793 }
1794 }
1795 return range;
1796 }
1797
1803 OBUint16PropertyRange range{};
1804 const auto &schemaVec = getConfigSchemaVec();
1805 for(const auto &item: schemaVec) {
1806 if(strcmp(item.name, "height") == 0) {
1808 break;
1809 }
1810 }
1811 return range;
1812 }
1813};
1814
1819public:
1820 LutNoiseRemovalFilter(const std::string &activationKey = "") {
1821 ob_error *error = nullptr;
1822 auto impl = ob_create_private_filter("LutNoiseRemovalFilter", activationKey.c_str(), &error);
1823 Error::handle(&error);
1824 init(impl);
1825 }
1826
1827 ~LutNoiseRemovalFilter() noexcept override = default;
1828
1834 for(int i = 0; i < 16; ++i) {
1835 setConfigValue("max_lut_" + std::to_string(i), static_cast<double>(filterParams.max_lut[i]));
1836 }
1837 setConfigValue("min_diff", static_cast<double>(filterParams.min_diff));
1838 setConfigValue("width", static_cast<double>(filterParams.width));
1839 setConfigValue("height", static_cast<double>(filterParams.height));
1840 }
1841
1848 for(int i = 0; i < 16; ++i) {
1849 params.max_lut[i] = static_cast<uint16_t>(getConfigValue("max_lut_" + std::to_string(i)));
1850 }
1851 params.min_diff = static_cast<uint16_t>(getConfigValue("min_diff"));
1852 params.width = static_cast<uint32_t>(getConfigValue("width"));
1853 params.height = static_cast<uint32_t>(getConfigValue("height"));
1854 return params;
1855 }
1856
1863 OBUint16PropertyRange range{};
1864 if(index < 0 || index >= 16) {
1865 return range;
1866 }
1867 std::string name = "max_lut_" + std::to_string(index);
1868 const auto &schemaVec = getConfigSchemaVec();
1869 for(const auto &item: schemaVec) {
1870 if(strcmp(item.name, name.c_str()) == 0) {
1872 break;
1873 }
1874 }
1875 return range;
1876 }
1877
1883 OBUint16PropertyRange range{};
1884 const auto &schemaVec = getConfigSchemaVec();
1885 for(const auto &item: schemaVec) {
1886 if(strcmp(item.name, "min_diff") == 0) {
1888 break;
1889 }
1890 }
1891 return range;
1892 }
1893
1899 OBUint16PropertyRange range{};
1900 const auto &schemaVec = getConfigSchemaVec();
1901 for(const auto &item: schemaVec) {
1902 if(strcmp(item.name, "width") == 0) {
1904 break;
1905 }
1906 }
1907 return range;
1908 }
1909
1915 OBUint16PropertyRange range{};
1916 const auto &schemaVec = getConfigSchemaVec();
1917 for(const auto &item: schemaVec) {
1918 if(strcmp(item.name, "height") == 0) {
1920 break;
1921 }
1922 }
1923 return range;
1924 }
1925};
1926
1931public:
1932 DisparityTransform(const std::string &activationKey = "") {
1933 ob_error *error = nullptr;
1934 auto impl = ob_create_private_filter("DisparityTransform", activationKey.c_str(), &error);
1935 Error::handle(&error);
1936 init(impl);
1937 }
1938
1939 ~DisparityTransform() noexcept override = default;
1940};
1941
1943private:
1944 ob_filter_list_t *impl_;
1945
1946public:
1947 explicit OBFilterList(ob_filter_list_t *impl) : impl_(impl) {}
1948
1949 ~OBFilterList() noexcept {
1950 ob_error *error = nullptr;
1951 ob_delete_filter_list(impl_, &error);
1952 Error::handle(&error, false);
1953 }
1954
1960 uint32_t getCount() const {
1961 ob_error *error = nullptr;
1962 auto count = ob_filter_list_get_count(impl_, &error);
1963 Error::handle(&error);
1964 return count;
1965 }
1966
1974 std::shared_ptr<Filter> getFilter(uint32_t index) {
1975 ob_error *error = nullptr;
1976 auto filter = ob_filter_list_get_filter(impl_, index, &error);
1977 Error::handle(&error);
1978 return std::make_shared<Filter>(filter);
1979 }
1980
1981public:
1982 // The following interfaces are deprecated and are retained here for compatibility purposes.
1983 uint32_t count() const {
1984 return getCount();
1985 }
1986};
1987
1991inline const std::unordered_map<std::string, std::type_index> &getFilterTypeMap() {
1992 static const std::unordered_map<std::string, std::type_index> filterTypeMap = {
1993 { "PointCloudFilter", typeid(PointCloudFilter) }, { "Align", typeid(Align) },
1994 { "FormatConverter", typeid(FormatConvertFilter) }, { "HDRMerge", typeid(HdrMerge) },
1995 { "SequenceIdFilter", typeid(SequenceIdFilter) }, { "DecimationFilter", typeid(DecimationFilter) },
1996 { "ThresholdFilter", typeid(ThresholdFilter) }, { "SpatialAdvancedFilter", typeid(SpatialAdvancedFilter) },
1997 { "HoleFillingFilter", typeid(HoleFillingFilter) }, { "NoiseRemovalFilter", typeid(NoiseRemovalFilter) },
1998 { "TemporalFilter", typeid(TemporalFilter) }, { "DisparityTransform", typeid(DisparityTransform) },
1999 { "SpatialFastFilter", typeid(SpatialFastFilter) }, { "SpatialModerateFilter", typeid(SpatialModerateFilter) },
2000 { "EdgeNoiseRemovalFilter", typeid(EdgeNoiseRemovalFilter) },
2001 { "FalsePositiveFilter", typeid(FalsePositiveFilter) },
2002 { "MgcNoiseRemovalFilter", typeid(MgcNoiseRemovalFilter) },
2003 { "LutNoiseRemovalFilter", typeid(LutNoiseRemovalFilter) },
2004 };
2005 return filterTypeMap;
2006}
2007
2014template <typename T> bool Filter::is() {
2015 std::string name = type();
2016
2017 const auto &filterTypeMap = getFilterTypeMap();
2018 auto it = filterTypeMap.find(name);
2019 if(it != filterTypeMap.end()) {
2020 return std::type_index(typeid(T)) == it->second;
2021 }
2022 return false;
2023}
2024
2025} // 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:259
OBStreamType
Enumeration value describing the type of data stream.
Definition ObTypes.h:200
struct ob_filter_t ob_filter
Definition ObTypes.h:34
enum OB_COORDINATE_SYSTEM_TYPE OBCoordinateSystemType
OBHoleFillingMode
Hole fillig mode.
Definition ObTypes.h:1152
OBConvertFormat
Enumeration of format conversion types.
Definition ObTypes.h:602
Align for depth to other or other to depth.
Definition Filter.hpp:440
Align(OBStreamType alignToStreamType)
Definition Filter.hpp:442
virtual ~Align() noexcept override=default
OBStreamType getAlignToStreamType()
Definition Filter.hpp:453
void setMatchTargetResolution(bool state)
Sets whether the output frame resolution should match the target resolution. When enabled,...
Definition Filter.hpp:467
void setAlignToStreamProfile(std::shared_ptr< const StreamProfile > profile)
Set the Align To Stream Profile.
Definition Filter.hpp:477
Decimation filter, reducing complexity by subsampling depth maps and losing depth details.
Definition Filter.hpp:596
virtual ~DecimationFilter() noexcept override=default
OBUint8PropertyRange getScaleRange()
Get the property range of the decimation filter scale value.
Definition Filter.hpp:626
uint8_t getScaleValue()
Get the decimation filter scale value.
Definition Filter.hpp:619
void setScaleValue(uint8_t value)
Set the decimation filter scale value.
Definition Filter.hpp:612
Depth to disparity or disparity to depth.
Definition Filter.hpp:1930
DisparityTransform(const std::string &activationKey="")
Definition Filter.hpp:1932
~DisparityTransform() noexcept override=default
EdgeNoiseRemoval filter.
Definition Filter.hpp:1127
OBUint16PropertyRange getVerticalDirectionEnableRange()
Get the edge noise removal filter vertical direction enable range.
Definition Filter.hpp:1206
OBUint16PropertyRange getLimitXthRange()
Get the edge noise removal filter limit x th range.
Definition Filter.hpp:1174
EdgeNoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:1129
OBUint16PropertyRange getHeightRange()
Get the edge noise removal filter height range.
Definition Filter.hpp:1238
OBUint16PropertyRange getWidthRange()
Get the edge noise removal filter width range.
Definition Filter.hpp:1222
OBEdgeNoiseRemovalFilterParams getFilterParams()
Get the edge noise removal filter params.
Definition Filter.hpp:1270
~EdgeNoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMarginYthRange()
Get the edge noise removal filter margin y th range.
Definition Filter.hpp:1158
OBUint16PropertyRange getLimitYthRange()
Get the edge noise removal filter limit y th range.
Definition Filter.hpp:1190
OBUint16PropertyRange getMarginXthRange()
Get the edge noise removal filter margin x th range.
Definition Filter.hpp:1142
void setFilterParams(OBEdgeNoiseRemovalFilterParams filterParams)
Set the edge noise removal filter params.
Definition Filter.hpp:1255
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:1287
OBFloatPropertyRange getfppafROIMaxYRatioRange()
Get the FalsePositive filter fppafROIMaxYRatio range.
Definition Filter.hpp:1575
OBFloatPropertyRange getfptsfROIMinXRatioRange()
Get the FalsePositive filter fptsfROIMinXRatio range.
Definition Filter.hpp:1405
OBFloatPropertyRange getfptsfROIMaxYRatioRange()
Get the FalsePositive filter fptsfROIMaxYRatio range.
Definition Filter.hpp:1456
OBFloatPropertyRange getfpebfROIMinXRatioRange()
Get the FalsePositive filter fpebfROIMinXRatio range.
Definition Filter.hpp:1320
OBFloatPropertyRange getfptsfROIMinYRatioRange()
Get the FalsePositive filter fptsfROIMinYRatio range.
Definition Filter.hpp:1439
OBUint16PropertyRange getfppafMaxNoiseLevelRange()
Get the FalsePositive filter fppafMaxNoiseLevel range.
Definition Filter.hpp:1592
OBUint16PropertyRange getfptsfMaxSpeckleSizeRange()
Get the FalsePositive filter fptsfMaxSpeckleSize range.
Definition Filter.hpp:1490
virtual ~FalsePositiveFilter() noexcept override=default
OBUint8PropertyRange getfpPatternAmbiguityFilterEnableRange()
Get the FalsePositive filter fpPatternAmbiguityFilterEnable range.
Definition Filter.hpp:1507
OBUint8PropertyRange getfpTextureSparsityFilterEnableRange()
Get the FalsePositive filter fpTextureSparsityFilterEnable range.
Definition Filter.hpp:1388
OBFloatPropertyRange getfppafROIMinYRatioRange()
Get the FalsePositive filter fppafROIMinYRatio range.
Definition Filter.hpp:1558
OBUint8PropertyRange getfpEdgeBleedFilterEnableRange()
Get the FalsePositive filter fpEdgeBleedFilterEnable range.
Definition Filter.hpp:1303
FalsePositiveFilter(const std::string &activationKey="")
Definition Filter.hpp:1289
OBUint16PropertyRange getfptsfMaxNoiseLevelRange()
Get the FalsePositive filter fptsfMaxNoiseLevel range.
Definition Filter.hpp:1473
OBFloatPropertyRange getfptsfROIMaxXRatioRange()
Get the FalsePositive filter fptsfROIMaxXRatio range.
Definition Filter.hpp:1422
OBFloatPropertyRange getfppafROIMinXRatioRange()
Get the FalsePositive filter fppafROIMinXRatio range.
Definition Filter.hpp:1524
OBUint16PropertyRange getfppafMaxSpeckleSizeRange()
Get the FalsePositive filter fppafMaxSpeckleSize range.
Definition Filter.hpp:1609
OBFloatPropertyRange getfpebfROIMaxYRatioRange()
Get the FalsePositive filter fpebfROIMaxYRatio range.
Definition Filter.hpp:1371
OBFloatPropertyRange getfppafROIMaxXRatioRange()
Get the FalsePositive filter fppafROIMaxXRatio range.
Definition Filter.hpp:1541
OBFloatPropertyRange getfpebfROIMinYRatioRange()
Get the FalsePositive filter fpebfROIMinYRatio range.
Definition Filter.hpp:1354
OBFloatPropertyRange getfpebfROIMaxXRatioRange()
Get the FalsePositive filter fpebfROIMaxXRatio range.
Definition Filter.hpp:1337
A factory class for creating filters.
Definition Filter.hpp:301
static std::string getFilterVendorSpecificCode(const std::string &name)
Get the vendor specific code of a filter by filter name.
Definition Filter.hpp:335
static std::shared_ptr< Filter > createFilter(const std::string &name)
Create a filter by name.
Definition Filter.hpp:306
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:320
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:2014
virtual void init(ob_filter *impl)
Definition Filter.hpp:89
std::shared_ptr< T > as()
Definition Filter.hpp:289
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:232
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:245
virtual std::string getConfigSchema() const
Get config schema of the filter.
Definition Filter.hpp:219
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:193
virtual std::shared_ptr< Frame > process(std::shared_ptr< const Frame > frame) const
Processes a frame synchronously.
Definition Filter.hpp:178
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:276
virtual double getConfigValue(const std::string &configName) const
Get the Config Value object by name.
Definition Filter.hpp:261
virtual void setCallBack(FilterCallback callback)
Set the callback function for asynchronous processing.
Definition Filter.hpp:204
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:487
virtual ~FormatConvertFilter() noexcept override=default
void setFormatConvertType(OBConvertFormat type)
Set the format conversion type.
Definition Filter.hpp:503
HdrMerge processing block, the processing merges between depth frames with different sub-preset seque...
Definition Filter.hpp:513
virtual ~HdrMerge() noexcept override=default
Hole filling filter,the processing performed depends on the selected hole filling mode.
Definition Filter.hpp:956
void setFilterMode(OBHoleFillingMode mode)
Set the HoleFillingFilter mode.
Definition Filter.hpp:972
HoleFillingFilter(const std::string &activationKey="")
Definition Filter.hpp:958
OBHoleFillingMode getFilterMode()
Get the HoleFillingFilter mode.
Definition Filter.hpp:981
~HoleFillingFilter() noexcept override=default
LutNoiseRemoval filter.
Definition Filter.hpp:1818
OBUint16PropertyRange getHeightRange()
Get the lut noise removal filter height range.
Definition Filter.hpp:1914
OBUint16PropertyRange getMinDiffRange()
Get the lut noise removal filter min_diff range.
Definition Filter.hpp:1882
OBLutNoiseRemovalFilterParams getFilterParams()
Get the lut noise removal filter params.
Definition Filter.hpp:1846
OBUint16PropertyRange getWidthRange()
Get the lut noise removal filter width range.
Definition Filter.hpp:1898
OBUint16PropertyRange getMaxLutRange(int index)
Get the lut noise removal filter max_lut range for a given index (0-15).
Definition Filter.hpp:1862
~LutNoiseRemovalFilter() noexcept override=default
LutNoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:1820
void setFilterParams(OBLutNoiseRemovalFilterParams filterParams)
Set the lut noise removal filter params.
Definition Filter.hpp:1833
MgcNoiseRemoval filter.
Definition Filter.hpp:1625
OBUint16PropertyRange getWidthRange()
Get the mgc noise removal filter width range.
Definition Filter.hpp:1786
OBUint16PropertyRange getHeightRange()
Get the mgc noise removal filter height range.
Definition Filter.hpp:1802
OBUint16PropertyRange getMaxWidthRightRange()
Get the mgc noise removal filter max_width_right range.
Definition Filter.hpp:1690
OBUint16PropertyRange getMaxWidthLeftRange()
Get the mgc noise removal filter max_width_left range.
Definition Filter.hpp:1674
OBUint16PropertyRange getLimitYthRange()
Get the mgc noise removal filter limit_y_th range.
Definition Filter.hpp:1770
void setFilterParams(OBMgcNoiseRemovalFilterParams filterParams)
Set the mgc noise removal filter params.
Definition Filter.hpp:1640
MgcNoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:1627
OBUint16PropertyRange getMarginXthRange()
Get the mgc noise removal filter margin_x_th range.
Definition Filter.hpp:1722
OBUint16PropertyRange getLimitXthRange()
Get the mgc noise removal filter limit_x_th range.
Definition Filter.hpp:1754
OBMgcNoiseRemovalFilterParams getFilterParams()
Get the mgc noise removal filter params.
Definition Filter.hpp:1656
OBUint16PropertyRange getMarginYthRange()
Get the mgc noise removal filter margin_y_th range.
Definition Filter.hpp:1738
~MgcNoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMaxRadiusRange()
Get the mgc noise removal filter max_radius range.
Definition Filter.hpp:1706
The noise removal filter,removing scattering depth pixels.
Definition Filter.hpp:989
OBUint16PropertyRange getDispDiffRange()
Get the noise removal filter disp diff range.
Definition Filter.hpp:1028
void setFilterParams(OBNoiseRemovalFilterParams filterParams)
Set the noise removal filter params.
Definition Filter.hpp:1005
NoiseRemovalFilter(const std::string &activationKey="")
Definition Filter.hpp:991
~NoiseRemovalFilter() noexcept override=default
OBUint16PropertyRange getMaxSizeRange()
Get the noise removal filter max size range.
Definition Filter.hpp:1044
OBNoiseRemovalFilterParams getFilterParams()
Get the noise removal filter params.
Definition Filter.hpp:1016
~OBFilterList() noexcept
Definition Filter.hpp:1949
uint32_t getCount() const
Get the number of filters.
Definition Filter.hpp:1960
uint32_t count() const
Definition Filter.hpp:1983
std::shared_ptr< Filter > getFilter(uint32_t index)
Get the Filter object at the specified index.
Definition Filter.hpp:1974
OBFilterList(ob_filter_list_t *impl)
Definition Filter.hpp:1947
The PointCloudFilter class is a subclass of Filter that generates point clouds.
Definition Filter.hpp:346
void setCoordinateSystem(OBCoordinateSystemType type)
Set the point cloud coordinate system.
Definition Filter.hpp:395
void setCoordinateDataScaled(float factor)
Set the point cloud coordinate data zoom factor.
Definition Filter.hpp:374
void setCameraParam(OBCameraParam param)
Definition Filter.hpp:432
void setPositionDataScaled(float scale)
Definition Filter.hpp:423
void setCreatePointFormat(OBFormat format)
Set the output pointcloud frame format.
Definition Filter.hpp:362
virtual ~PointCloudFilter() noexcept override=default
void setFrameAlignState(bool state)
Definition Filter.hpp:428
OBIntPropertyRange getDecimationFactorRange()
Get the property range of the decimation factor range.
Definition Filter.hpp:412
void setDecimationFactor(int value)
Set the point cloud decimation factor. Calling this function to decimation factor will output thedown...
Definition Filter.hpp:405
void setColorDataNormalization(bool state)
Set point cloud color data normalization.
Definition Filter.hpp:386
Create SequenceIdFilter processing block.
Definition Filter.hpp:528
int getSelectSequenceId()
Get the current sequence id.
Definition Filter.hpp:575
void selectSequenceId(int sequence_id)
Set the sequenceId filter params.
Definition Filter.hpp:566
virtual ~SequenceIdFilter() noexcept override
Definition Filter.hpp:554
OBSequenceIdItem * getSequenceIdList()
Definition Filter.hpp:579
int getSequenceIdListSize()
Get the sequenceId list size.
Definition Filter.hpp:588
Spatial advanced filte smooths the image by calculating frame with alpha and delta settings alpha def...
Definition Filter.hpp:703
void setFilterParams(OBSpatialAdvancedFilterParams params)
Set the spatial advanced filter params.
Definition Filter.hpp:801
OBSpatialAdvancedFilterParams getFilterParams()
Get the spatial advanced filter params.
Definition Filter.hpp:787
OBUint16PropertyRange getRadiusRange()
Get the spatial advanced filter radius range.
Definition Filter.hpp:753
SpatialAdvancedFilter(const std::string &activationKey="")
Definition Filter.hpp:705
OBFloatPropertyRange getAlphaRange()
Get the spatial advanced filter alpha range.
Definition Filter.hpp:719
OBUint16PropertyRange getDispDiffRange()
Get the spatial advanced filter dispdiff range.
Definition Filter.hpp:736
virtual ~SpatialAdvancedFilter() noexcept override=default
OBIntPropertyRange getMagnitudeRange()
Get the spatial advanced filter magnitude range.
Definition Filter.hpp:770
The Spatial Fast Filter utilizes an enhanced median smoothing algorithm, designed to significantly re...
Definition Filter.hpp:813
virtual ~SpatialFastFilter() noexcept override=default
SpatialFastFilter(const std::string &activationKey="")
Definition Filter.hpp:815
void setFilterParams(OBSpatialFastFilterParams params)
Set the spatial fast filter params.
Definition Filter.hpp:857
OBSpatialFastFilterParams getFilterParams()
Get the spatial fast filter params.
Definition Filter.hpp:846
OBIntPropertyRange getRadiusRange()
Get the spatial fast filter radius range.
Definition Filter.hpp:829
The Spatial Moderate Filter utilizes an optimized average smoothing algorithm, to achieve a balance b...
Definition Filter.hpp:866
SpatialModerateFilter(const std::string &activationKey="")
Definition Filter.hpp:868
OBIntPropertyRange getRadiusRange()
Get the spatial moderate filter radius range.
Definition Filter.hpp:899
virtual ~SpatialModerateFilter() noexcept override=default
void setFilterParams(OBSpatialModerateFilterParams params)
Set the spatial moderate filter params.
Definition Filter.hpp:946
OBSpatialModerateFilterParams getFilterParams()
Get the spatial moderate filter params.
Definition Filter.hpp:933
OBIntPropertyRange getMagnitudeRange()
Get the spatial moderate filter magnitude range.
Definition Filter.hpp:882
OBIntPropertyRange getDispDiffRange()
Get the spatial moderate filter disp diff range.
Definition Filter.hpp:916
Temporal filter.
Definition Filter.hpp:1060
OBFloatPropertyRange getWeightRange()
Get the TemporalFilter weight range.
Definition Filter.hpp:1102
void setDiffScale(float value)
Set the TemporalFilter diffscale value.
Definition Filter.hpp:1093
~TemporalFilter() noexcept override=default
OBFloatPropertyRange getDiffScaleRange()
Get the TemporalFilter diffscale range.
Definition Filter.hpp:1076
void setWeight(float value)
Set the TemporalFilter weight value.
Definition Filter.hpp:1119
TemporalFilter(const std::string &activationKey="")
Definition Filter.hpp:1062
Creates depth Thresholding filter By controlling min and max options on the block.
Definition Filter.hpp:640
bool setValueRange(uint16_t min, uint16_t max)
Set the threshold filter max and min range.
Definition Filter.hpp:688
OBIntPropertyRange getMinRange()
Get the threshold filter min range.
Definition Filter.hpp:656
virtual ~ThresholdFilter() noexcept override=default
OBIntPropertyRange getMaxRange()
Get the threshold filter max range.
Definition Filter.hpp:673
Definition Context.hpp:22
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:1991
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:515
int limit_y_th
Maximum vertical threshold.
Definition ObTypes.h:1203
int margin_x_th
Horizontal threshold settings.
Definition ObTypes.h:1200
uint32_t height
Image height.
Definition ObTypes.h:1205
uint32_t width
Image width.
Definition ObTypes.h:1204
bool enable_direction
Set to true for horizontal and vertical, false for horizontal only.
Definition ObTypes.h:1206
int limit_x_th
Maximum horizontal threshold.
Definition ObTypes.h:1202
int margin_y_th
Vertical threshold settings.
Definition ObTypes.h:1201
Configuration Item for the filter.
Definition ObTypes.h:1717
double min
Minimum value casted to double.
Definition ObTypes.h:1720
double max
Maximum value casted to double.
Definition ObTypes.h:1721
double def
Default value casted to double.
Definition ObTypes.h:1723
double step
Step value casted to double.
Definition ObTypes.h:1722
Structure for float range.
Definition ObTypes.h:399
Structure for integer range.
Definition ObTypes.h:388
Configuration parameters for the LUT noise removal filter.
Definition ObTypes.h:1227
uint32_t width
Depth map width the above parameters correspond to.
Definition ObTypes.h:1230
uint32_t height
Depth map height the above parameters correspond to.
Definition ObTypes.h:1231
uint16_t max_lut[16]
LUT max size of noise pixels (4x4 LUT, 16 entries total)
Definition ObTypes.h:1228
uint16_t min_diff
Difference threshold between neighbor pixels.
Definition ObTypes.h:1229
Configuration parameters for the MGC noise removal filter.
Definition ObTypes.h:1212
int limit_y_th
Maximum vertical threshold.
Definition ObTypes.h:1219
int limit_x_th
Maximum horizontal threshold.
Definition ObTypes.h:1218
int max_radius
Chamfer radius threshold settings.
Definition ObTypes.h:1215
int max_width_right
Right chamfer threshold settings.
Definition ObTypes.h:1214
int margin_y_th
Vertical threshold settings.
Definition ObTypes.h:1217
uint32_t height
Depth map height the above parameters correspond to.
Definition ObTypes.h:1221
uint32_t width
Depth map width the above parameters correspond to.
Definition ObTypes.h:1220
int max_width_left
Left chamfer threshold settings.
Definition ObTypes.h:1213
int margin_x_th
Horizontal threshold settings.
Definition ObTypes.h:1216
SequenceId fliter list item.
Definition ObTypes.h:1144
Structure for float range.
Definition ObTypes.h:410
Structure for float range.
Definition ObTypes.h:421
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:159