NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef DEEPSTREAM_DS3D_SENSOR_FUSION_HPP
19 #define DEEPSTREAM_DS3D_SENSOR_FUSION_HPP
20 
21 #include <unistd.h>
22 
23 // inlcude all ds3d hpp header files
24 #include <ds3d/common/hpp/dataloader.hpp>
25 #include <ds3d/common/hpp/datamap.hpp>
26 #include <ds3d/common/hpp/frame.hpp>
27 #include <ds3d/common/hpp/yaml_config.hpp>
28 #include <ds3d/common/hpp/profiling.hpp>
29 
30 // inlucde nvds3d Gst header files
31 #include <ds3d/gst/nvds3d_gst_plugin.h>
32 #include <ds3d/gst/nvds3d_gst_ptr.h>
33 #include <ds3d/gst/nvds3d_meta.h>
34 #include <ds3d/gst/nvds3d_pipeline_context.h>
35 
36 #include "gstnvdsmeta.h"
37 
38 using namespace ds3d;
39 
40 #undef CHECK_ERROR
41 #define CHECK_ERROR(statement, fmt, ...) DS3D_FAILED_RETURN(statement, -1, fmt, ##__VA_ARGS__)
42 
43 #undef RETURN_ERROR
44 #define RETURN_ERROR(statement, fmt, ...) DS3D_ERROR_RETURN(statement, fmt, ##__VA_ARGS__)
45 
46 using ConfigList = std::vector<config::ComponentConfig>;
47 
48 struct Component {
49 public:
50  virtual ~Component() = default;
51  bool isGstPlugin() const;
52  config::ComponentType type() const { return config.type; }
53 
55  gst::ElePtr gstElement;
56 };
57 
58 struct AppProfiler {
59 public:
61  bool enableDebug = false;
62  bool eosAutoStop = true;
63  bool probeBuffer = false;
64 
65  AppProfiler() = default;
66  AppProfiler(const AppProfiler&) = delete;
67  void operator=(const AppProfiler&) = delete;
69 
71  {
73  this->config = compConf;
74  YAML::Node node = YAML::Load(compConf.rawContent);
75  auto debugNode = node["enable_debug"];
76  auto eosNode = node["eos_auto_stop"];
77  auto probeNode = node["probe_buffer"];
78  if (debugNode) {
79  enableDebug = debugNode.as<bool>();
80  }
81 
82  if (eosNode) {
83  eosAutoStop = eosNode.as<bool>();
84  }
85  if (probeNode) {
86  probeBuffer = probeNode.as<bool>();
87  }
88  return ErrCode::kGood;
89  }
90 };
91 
93 public:
94  SensorFusionApp() = default;
96  {
97  stop();
98  deinit();
99  }
100 
101  ErrCode setup(const std::string& configPath, std::function<void()> windowClosed);
102  ErrCode stop() override;
103  void deinit() override;
104 
105  AppProfiler& profiler() { return _appProfiler; }
106 
107 private:
108  ErrCode init(const std::string& name) override;
109  ErrCode buildComponents(const ConfigList& componentConfigs);
110  ErrCode LinkComponents();
111 
112  std::unique_ptr<Component> createLoader(const config::ComponentConfig& c);
113  std::unique_ptr<Component> createRender(const config::ComponentConfig& c);
114  std::unique_ptr<Component> createFilterBridge(const config::ComponentConfig& c);
115  std::unique_ptr<Component> createMixer(const config::ComponentConfig& c);
116  std::unique_ptr<Component> createGstParseBin(const config::ComponentConfig& c);
117  ErrCode setupProfiling();
118 
119 private:
120  std::string _configPath;
121  std::map<std::string, Ptr<Component>> _components;
122  std::function<void()> _windowClosedCb;
123  AppProfiler _appProfiler;
124 };
125 
126 #endif
ds3d::config::ComponentType
ComponentType
Definition: sources/includes/ds3d/common/config.h:27
AppProfiler::parse
ErrCode parse(const config::ComponentConfig &compConf)
Definition: 9.1/sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:70
ds3d::config::ComponentConfig::type
ComponentType type
Definition: sources/includes/ds3d/common/config.h:40
SensorFusionApp::profiler
AppProfiler & profiler()
Definition: 9.1/sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:105
AppProfiler
Definition: sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:58
ds3d::ErrCode::kGood
@ kGood
ds3d::gst::ElePtr
Definition: sources/libs/ds3d/gst/nvds3d_gst_ptr.h:154
DS_ASSERT
#define DS_ASSERT(...)
Definition: sources/includes/ds3d/common/defines.h:36
ds3d::ErrCode
ErrCode
Definition: sources/includes/ds3d/common/common.h:47
SensorFusionApp
Definition: sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:92
AppProfiler::~AppProfiler
~AppProfiler()
Definition: 9.1/sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:68
ds3d::gst::PipelineContext
Definition: sources/libs/ds3d/gst/nvds3d_pipeline_context.h:66
SensorFusionApp::~SensorFusionApp
~SensorFusionApp()
Definition: 9.1/sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:95
ConfigList
std::vector< config::ComponentConfig > ConfigList
Definition: sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:46
Component::type
config::ComponentType type() const
Definition: 9.1/sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:52
ds3d::config::ComponentConfig::rawContent
std::string rawContent
Definition: sources/includes/ds3d/common/config.h:51
ds3d::config::ComponentConfig
Definition: sources/includes/ds3d/common/config.h:38
ds3d
Definition: sources/includes/ds3d/common/abi_dataprocess.h:25
Component
Definition: sources/apps/sample_apps/deepstream-3d-lidar-sensor-fusion/deepstream_3d_sensor_fusion.hpp:48
ds3d::config::ComponentType::kUserApp
@ kUserApp