NVIDIA DeepStream SDK API Reference

9.1 Release
service-maker/sources/modules/lidar_feeder/lidar_feeder.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2024-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 // #include <stdio.h>
19 // #include <cuda_runtime_api.h>
20 // #include <cuda.h>
21 
22 #include "data_feeder.hpp"
23 #include <ds3d/gst/nvds3d_gst_plugin.h>
24 #include <ds3d/common/defines.h>
25 #include <ds3d/common/hpp/datamap.hpp>
26 #include "buffer.hpp"
27 #include "iostream"
28 // #include "gst-nvevent.h"
29 
30 namespace deepstream
31 {
32 
33  class DS3DBuffer : public Buffer
34  {
35  public:
36  DS3DBuffer() : Buffer() {}
37  DS3DBuffer(OpaqueBuffer *buffer) : Buffer(buffer)
38  {
39  gst_buffer_unref(buffer_);
40  }
41  };
42 
44  {
45  public:
46  void initialize(DataFeeder &feeder)
47  {
48  using namespace ds3d;
49  _initialized = true;
50  ErrCode c;
51  std::string configPath;
52  Ptr<CustomLibFactory> customlib;
53  std::string configContent;
54  feeder.getProperty("config-path", configPath);
55  std::cout << "lidar_feeder plugin config-path: " << configPath << std::endl;
56  readFile(configPath, configContent);
57  config::parseComponentConfig(configContent, configPath, config);
58  c = gst::loadCustomProcessor(config, loader, customlib);
59  DS_ASSERT(c == ErrCode::kGood);
60  }
61 
62  Buffer read(DataFeeder &feeder, unsigned int size, bool &eos)
63  {
64  using namespace ds3d;
65  ErrCode c;
66  if (!_initialized)
67  {
68  initialize(feeder);
69  }
70 
71  if (loader.state() == State::kNone)
72  {
73  DataProcessUserData *uData = (DataProcessUserData *)loader.getUserData();
74  c = loader.start(uData->configContent, uData->configPath);
75  DS_ASSERT(c == ErrCode::kGood);
76  }
77  c = loader.readData(datamap);
78  DS_ASSERT(c >= ErrCode::kGood);
79  eos = (c == ErrCode::KEndOfStream);
80  if (!eos)
81  {
82  DS_ASSERT(datamap);
83 
84  c = NvDs3D_CreateGstBuf(buffer_, datamap.abiRef(), false);
85  DS_ASSERT(c == ErrCode::kGood);
86  return DS3DBuffer(buffer_);
87  }
88  else
89  {
90  std::cout << "EOS reached" << std::endl;
91  return DS3DBuffer();
92  }
93  }
94 
95 
96  private:
97  OpaqueBuffer *buffer_ = nullptr;
98  bool _initialized = false;
100  ds3d::GuardDataMap datamap;
101  ds3d::GuardDataLoader loader;
102  };
103 }
deepstream::DataFeeder::IDataProvider
required interface for a data feeder
Definition: service-maker/includes/data_feeder.hpp:52
deepstream::DataFeeder
A specific signal handler for feeding data.
Definition: service-maker/includes/data_feeder.hpp:44
deepstream::LiDARDataSource::initialize
void initialize(DataFeeder &feeder)
Definition: service-maker/sources/modules/lidar_feeder/lidar_feeder.hpp:46
OpaqueBuffer
struct _GstBuffer OpaqueBuffer
Definition: service-maker/includes/buffer.hpp:36
deepstream::Buffer::buffer_
OpaqueBuffer * buffer_
opaque buffer pointer
Definition: service-maker/includes/buffer.hpp:172
deepstream::LiDARDataSource
Definition: service-maker/sources/modules/lidar_feeder/lidar_feeder.hpp:43
deepstream::LiDARDataSource::read
Buffer read(DataFeeder &feeder, unsigned int size, bool &eos)
Definition: service-maker/sources/modules/lidar_feeder/lidar_feeder.hpp:62
ds3d::gst::loadCustomProcessor
ErrCode loadCustomProcessor(const config::ComponentConfig &compConfig, GuardProcess &customProcessor, Ptr< CustomLibFactory > &lib)
Definition: sources/libs/ds3d/gst/nvds3d_gst_plugin.h:82
ds3d::DataProcessUserData::configPath
std::string configPath
Definition: sources/libs/ds3d/gst/nvds3d_gst_plugin.h:43
ds3d::GuardDataLoader
GuardDataLoader is the safe access entry for abiDataLoader.
Definition: sources/includes/ds3d/common/hpp/dataloader.hpp:50
ds3d::readFile
bool readFile(const std::string &path, std::string &context)
Definition: sources/includes/ds3d/common/func_utils.h:204
ds3d::DataProcessUserData
Definition: sources/libs/ds3d/gst/nvds3d_gst_plugin.h:39
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
DS_ASSERT
#define DS_ASSERT(...)
Definition: sources/includes/ds3d/common/defines.h:36
ds3d::ErrCode
ErrCode
Definition: sources/includes/ds3d/common/common.h:47
NvDs3D_CreateGstBuf
DS3D_EXTERN_C_BEGIN DS3D_EXPORT_API ds3d::ErrCode NvDs3D_CreateGstBuf(GstBuffer *&outBuf, ds3d::abiRefDataMap *datamap, bool takeOwner)
deepstream
Definition: service-maker/includes/buffer.hpp:38
deepstream::Buffer
Base class of a buffer.
Definition: service-maker/includes/buffer.hpp:51
deepstream::DS3DBuffer::DS3DBuffer
DS3DBuffer(OpaqueBuffer *buffer)
Definition: service-maker/sources/modules/lidar_feeder/lidar_feeder.hpp:37
deepstream::DS3DBuffer::DS3DBuffer
DS3DBuffer()
Definition: service-maker/sources/modules/lidar_feeder/lidar_feeder.hpp:36
ds3d::Ptr
ShrdPtr< T > Ptr
Definition: sources/includes/ds3d/common/hpp/obj.hpp:37
ds3d::config::ComponentConfig
Definition: sources/includes/ds3d/common/config.h:38
ds3d::GuardDataMap
Definition: sources/includes/ds3d/common/hpp/datamap.hpp:27
deepstream::DS3DBuffer
Definition: service-maker/sources/modules/lidar_feeder/lidar_feeder.hpp:33
ds3d::DataProcessUserData::configContent
std::string configContent
Definition: sources/libs/ds3d/gst/nvds3d_gst_plugin.h:42
ds3d
Definition: sources/includes/ds3d/common/abi_dataprocess.h:25
deepstream::Object::getProperty
Object & getProperty(const std::string &name, T &value, Args &... args)
Template for getting multiple properties.
Definition: service-maker/includes/object.hpp:176