NVIDIA DeepStream SDK API Reference

8.0 Release
lidar_feeder.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
13 // #include <stdio.h>
14 // #include <cuda_runtime_api.h>
15 // #include <cuda.h>
16 
17 #include "data_feeder.hpp"
19 #include <ds3d/common/defines.h>
21 #include "buffer.hpp"
22 #include "iostream"
23 // #include "gst-nvevent.h"
24 
25 namespace deepstream
26 {
27 
28  class DS3DBuffer : public Buffer
29  {
30  public:
31  DS3DBuffer() : Buffer() {}
32  DS3DBuffer(OpaqueBuffer *buffer) : Buffer(buffer)
33  {
34  gst_buffer_unref(buffer_);
35  }
36  };
37 
39  {
40  public:
41  void initialize(DataFeeder &feeder)
42  {
43  using namespace ds3d;
44  _initialized = true;
45  ErrCode c;
46  std::string configPath;
47  Ptr<CustomLibFactory> customlib;
48  std::string configContent;
49  feeder.getProperty("config-path", configPath);
50  std::cout << "lidar_feeder plugin config-path: " << configPath << std::endl;
51  readFile(configPath, configContent);
52  config::parseComponentConfig(configContent, configPath, config);
53  c = gst::loadCustomProcessor(config, loader, customlib);
54  DS_ASSERT(c == ErrCode::kGood);
55  }
56 
57  Buffer read(DataFeeder &feeder, unsigned int size, bool &eos)
58  {
59  using namespace ds3d;
60  ErrCode c;
61  if (!_initialized)
62  {
63  initialize(feeder);
64  }
65 
66  if (loader.state() == State::kNone)
67  {
68  DataProcessUserData *uData = (DataProcessUserData *)loader.getUserData();
69  c = loader.start(uData->configContent, uData->configPath);
70  DS_ASSERT(c == ErrCode::kGood);
71  }
72  c = loader.readData(datamap);
73  DS_ASSERT(c >= ErrCode::kGood);
74  eos = (c == ErrCode::KEndOfStream);
75  if (!eos)
76  {
77  DS_ASSERT(datamap);
78 
79  c = NvDs3D_CreateGstBuf(buffer_, datamap.abiRef(), false);
80  DS_ASSERT(c == ErrCode::kGood);
81  return DS3DBuffer(buffer_);
82  }
83  else
84  {
85  std::cout << "EOS reached" << std::endl;
86  return DS3DBuffer();
87  }
88  }
89 
90 
91  private:
92  OpaqueBuffer *buffer_ = nullptr;
93  bool _initialized = false;
95  ds3d::GuardDataMap datamap;
96  ds3d::GuardDataLoader loader;
97  };
98 }
deepstream::DataFeeder::IDataProvider
required interface for a data feeder
Definition: data_feeder.hpp:47
deepstream::DataFeeder
A specific signal handler for feeding data.
Definition: data_feeder.hpp:39
deepstream::LiDARDataSource::initialize
void initialize(DataFeeder &feeder)
Definition: lidar_feeder.hpp:41
nvds3d_gst_plugin.h
DS_ASSERT
#define DS_ASSERT(...)
Definition: defines.h:31
NvDs3D_CreateGstBuf
DS3D_EXTERN_C_BEGIN DS3D_EXPORT_API ds3d::ErrCode NvDs3D_CreateGstBuf(GstBuffer *&outBuf, ds3d::abiRefDataMap *datamap, bool takeOwner)
deepstream::LiDARDataSource
Definition: lidar_feeder.hpp:38
deepstream::LiDARDataSource::read
Buffer read(DataFeeder &feeder, unsigned int size, bool &eos)
Definition: lidar_feeder.hpp:57
ds3d::gst::loadCustomProcessor
ErrCode loadCustomProcessor(const config::ComponentConfig &compConfig, GuardProcess &customProcessor, Ptr< CustomLibFactory > &lib)
Definition: nvds3d_gst_plugin.h:78
ds3d::DataProcessUserData::configPath
std::string configPath
Definition: nvds3d_gst_plugin.h:39
ds3d::GuardDataLoader
GuardDataLoader is the safe access entry for abiDataLoader.
Definition: dataloader.hpp:46
ds3d::readFile
bool readFile(const std::string &path, std::string &context)
Definition: func_utils.h:200
ds3d::DataProcessUserData
Definition: nvds3d_gst_plugin.h:35
defines.h
ds3d::config::parseComponentConfig
ErrCode parseComponentConfig(const std::string &yamlComp, const std::string &path, ComponentConfig &config)
Definition: yaml_config.hpp:53
ds3d::ErrCode
ErrCode
Definition: common.h:43
datamap.hpp
data_feeder.hpp
deepstream
Definition: buffer.hpp:33
OpaqueBuffer
struct _GstBuffer OpaqueBuffer
Definition: buffer.hpp:31
deepstream::Buffer
Base class of a buffer.
Definition: buffer.hpp:46
deepstream::DS3DBuffer::DS3DBuffer
DS3DBuffer(OpaqueBuffer *buffer)
Definition: lidar_feeder.hpp:32
deepstream::Buffer::buffer_
OpaqueBuffer * buffer_
opaque buffer pointer
Definition: buffer.hpp:164
deepstream::DS3DBuffer::DS3DBuffer
DS3DBuffer()
Definition: lidar_feeder.hpp:31
ds3d::Ptr
ShrdPtr< T > Ptr
Definition: obj.hpp:33
ds3d::config::ComponentConfig
Definition: includes/ds3d/common/config.h:34
ds3d::GuardDataMap
Definition: datamap.hpp:21
buffer.hpp
deepstream::DS3DBuffer
Definition: lidar_feeder.hpp:28
ds3d::DataProcessUserData::configContent
std::string configContent
Definition: nvds3d_gst_plugin.h:38
ds3d
Definition: abi_dataprocess.h:21
deepstream::Object::getProperty
Object & getProperty(const std::string &name, T &value, Args &... args)
Template for getting multiple properties.
Definition: object.hpp:171