NVIDIA DeepStream SDK API Reference

9.1 Release
sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h
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 DS3D_DATAFILTER_LIDAR_PREPROCESS_CONFIG_H
19 #define DS3D_DATAFILTER_LIDAR_PREPROCESS_CONFIG_H
20 
21 #include <ds3d/common/common.h>
22 #include <ds3d/common/func_utils.h>
23 
24 #include "ds3d/common/hpp/yaml_config.hpp"
25 
26 #include "infer_utils.h"
27 
28 using namespace nvdsinferserver;
29 
30 
31 namespace ds3d { namespace impl { namespace filter {
32 
34  std::string fromKey;
35  bool is2DFrame = false;
36 };
37 
38 struct Config {
40  std::string filterInputDatamapKey;
41  uint32_t memPoolSize = 8;
42  std::map<size_t, std::string> modelInputs;
43  uint gpuid;
44  InferMemType inputTensorMemType = InferMemType::kGpuCuda;
45  std::map<std::string, ModelInputDesc> inputLayersDes;
46  //app's cfg path
47  std::string configPath;
48  std::vector<std::string> lidarDataFrom;
49 
50  bool check()
51  {
52  if (!memPoolSize) {
53  LOG_ERROR("lidarpreprocess configed wrong mem_pool_size");
54  return false;
55  }
56  return true;
57  }
58 };
59 
60 inline ErrCode
61 parseConfig(const std::string& content, const std::string& path, Config& config)
62 {
64  config::parseComponentConfig(content, path, config.compConfig),
65  "parse dataloader component content failed");
66  YAML::Node node = YAML::Load(config.compConfig.configBody);
67  auto filterInputDatamapKey = node["filter_input_datamap_key"];
68  auto yMemPoolSize = node["mem_pool_size"];
69  auto modelInputs = node["model_inputs"];
70  auto gpuid = node["gpu_id"];
71  auto inputTensorMemType = node["input_tensor_mem_type"];
72  auto configPath = node["config_path"];
73  auto lidarDataFrom = node["lidar_data_from"];
74 
75  if (filterInputDatamapKey) {
76  config.filterInputDatamapKey = filterInputDatamapKey.as<std::string>();
77  }
78  if (yMemPoolSize) {
79  config.memPoolSize = yMemPoolSize.as<uint32_t>();
80  }
81  if (modelInputs) {
82  for (const auto& item :modelInputs) {
83  ModelInputDesc des;
84  if (item["name"])
85  des.name = item["name"].as<std::string>(); // name
86  std::string dataType;
87  if (item["datatype"]){
88  dataType = item["datatype"].as<std::string>();
89  des.dataType = grpcStr2DataType(dataType); //datatype
90  }
91  std::vector<std::string> strStreams = item["shape"].as<std::vector<std::string>>();
92  des.dims.numDims = strStreams.size();
93  for (size_t i = 0; i < des.dims.numDims; i++){
94  des.dims.d[i] = std::stoi(strStreams[i]);
95  }
96  des.dims.numElements = std::accumulate(des.dims.d, des.dims.d + des.dims.numDims, 1,
97  [](int s, int i) { return s * i; });
98  if (item["from"]) {
99  des.fromKey = item["from"].as<std::string>();
100  }
101  if (item["is_2d_frame"]) {
102  des.is2DFrame = item["is_2d_frame"].as<bool>();
103  }
104  LOG_INFO(
105  "modelInputs name:%s, dataType:%s, ndataType:%d, numDims:%d, numElements:%d, from: "
106  "%s",
107  des.name.c_str(), dataType.c_str(), (int)des.dataType, des.dims.numDims,
108  des.dims.numElements, des.fromKey.c_str());
109  config.inputLayersDes.emplace(des.name, des);
110  }
111  }
112  if (gpuid) {
113  config.gpuid = gpuid.as<uint>();
114  }
115  if (inputTensorMemType) {
116  std::string value = inputTensorMemType.as<std::string>();
117  if(!value.compare("GpuCuda")){
119  } else if (!value.compare("CpuCuda") || !value.compare("Cpu")) {
121  } else {
122  LOG_WARNING("%s not supported, use defualt value GpuCuda", value.c_str());
123  }
124  }
125  if (configPath) {
126  config.configPath = configPath.as<std::string>();
127  }
128  if (lidarDataFrom) {
129  config.lidarDataFrom = lidarDataFrom.as<std::vector<std::string>>();
130  }
131 
132  LOG_INFO("memPoolSize: %d", config.memPoolSize);
133  LOG_INFO("gpuid: %d", config.gpuid);
134  LOG_INFO("filterInputDatamapKey: %s", config.filterInputDatamapKey.c_str());
135  LOG_INFO("inputTensorMemType: %d", (int)config.inputTensorMemType);
136  LOG_INFO("configPath: %s", config.configPath.c_str());
137 
138  //config data checking
139  if (config.inputLayersDes.size() == 0) {
140  LOG_ERROR("model_inputs parse failed, abort");
141  abort();
142  }
143  if (config.lidarDataFrom.size() == 0) {
144  LOG_ERROR("no lidar data, abort");
145  abort();
146  }
147 
148  return ErrCode::kGood;
149 }
150 
151 }}} // namespace ds3d::impl::filter
152 
153 #endif // DS3D_DATAFILTER_LIDAR_PREPROCESS_CONFIG_H
ds3d::impl::filter::Config
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:38
nvdsinferserver
This is a header file for pre-processing cuda kernels with normalization and mean subtraction require...
Definition: sources/gst-plugins/gst-nvinferserver/gstnvinferserver_impl.h:69
INFER_EXPORT_API::grpcStr2DataType
InferDataType grpcStr2DataType(const std::string &type)
ds3d::impl::filter::Config::filterInputDatamapKey
std::string filterInputDatamapKey
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:40
ds3d::impl::filter::ModelInputDesc
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:33
ds3d::impl::filter::ModelInputDesc::is2DFrame
bool is2DFrame
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:35
nvdsinferserver::InferDims::numDims
unsigned int numDims
Number of dimensions of the layer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:154
ds3d::impl::filter::Config::inputTensorMemType
InferMemType inputTensorMemType
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:44
ds3d::impl::filter::ModelInputDesc::fromKey
std::string fromKey
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:34
ds3d::impl::filter::Config::memPoolSize
uint32_t memPoolSize
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:41
nvdsinferserver::InferDims::d
int d[NVDSINFER_MAX_DIMS]
Size of the layer in each dimension.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:156
ds3d::config::parseComponentConfig
ErrCode parseComponentConfig(const std::string &yamlComp, const std::string &path, ComponentConfig &config)
Definition: sources/includes/ds3d/common/hpp/yaml_config.hpp:57
ds3d::ErrCode
ErrCode
Definition: sources/includes/ds3d/common/common.h:47
nvdsinferserver::InferMemType::kGpuCuda
@ kGpuCuda
GPU CUDA memory.
LOG_ERROR
#define LOG_ERROR(fmt,...)
Definition: sources/apps/sample_apps/deepstream-3d-action-recognition/deepstream_action.h:60
ds3d::impl::filter::Config::compConfig
config::ComponentConfig compConfig
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:39
ds3d::impl::filter::Config::inputLayersDes
std::map< std::string, ModelInputDesc > inputLayersDes
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:45
LOG_INFO
#define LOG_INFO(fmt,...)
Definition: sources/apps/sample_apps/deepstream-3d-action-recognition/custom_sequence_preprocess/seq_process_common.h:68
ds3d::impl::filter::Config::lidarDataFrom
std::vector< std::string > lidarDataFrom
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:48
LOG_WARNING
#define LOG_WARNING
Definition: sources/gst-plugins/gst-nvtracker/logging.h:24
nvdsinferserver::InferBufferDescription::dataType
InferDataType dataType
Datatype associated with the buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:185
ds3d::config::ComponentConfig::configBody
std::string configBody
Definition: sources/includes/ds3d/common/config.h:48
ds3d::impl::filter::Config::configPath
std::string configPath
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:47
ds3d::impl::filter::Config::gpuid
uint gpuid
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:43
nvdsinferserver::InferMemType
InferMemType
The memory types of inference buffers.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:61
ds3d::config::ComponentConfig
Definition: sources/includes/ds3d/common/config.h:38
nvdsinferserver::InferDims::numElements
unsigned int numElements
Number of elements in the layer including all dimensions.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:158
nvdsinferserver::InferBufferDescription::dims
InferDims dims
Dimensions of the tensor.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:189
ds3d::impl::filter::Config::check
bool check()
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:50
DS3D_ERROR_RETURN
#define DS3D_ERROR_RETURN(code, fmt,...)
Definition: sources/includes/ds3d/common/defines.h:77
ds3d::impl::filter::Config::modelInputs
std::map< size_t, std::string > modelInputs
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:42
ds3d
Definition: sources/includes/ds3d/common/abi_dataprocess.h:25
nvdsinferserver::InferMemType::kCpuCuda
@ kCpuCuda
CUDA pinned memory.
ds3d::impl::filter::parseConfig
ErrCode parseConfig(const std::string &content, const std::string &path, Config &config)
Definition: sources/libs/ds3d/datafilter/lidar_preprocess/lidar_preprocess_config.h:61
nvdsinferserver::InferBufferDescription::name
std::string name
Name of the buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:197
nvdsinferserver::InferBufferDescription
Holds the information about a inference buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:173