NVIDIA DeepStream SDK API Reference

6.4 Release
nvdspostprocesslib_factory.hpp
Go to the documentation of this file.
1 
23 #ifndef __NVDSPOSTPROCESSLIB_FACTORY_HPP__
24 #define __NVDSPOSTPROCESSLIB_FACTORY_HPP__
25 
26 #include <dlfcn.h>
27 #include <errno.h>
28 
29 #include <iostream>
30 #include <functional>
31 
33 
34 template<class T>
35 T* dlsym_ptr(void* handle, char const* name) {
36  return reinterpret_cast<T*>(dlsym(handle, name));
37 }
38 
40 {
41 public:
43  {
44  }
45 
47  {
48  if (m_libHandle)
49  {
50  dlclose(m_libHandle);
51  m_libHandle = NULL;
52  m_libName.clear();
53  }
54  }
55 
57  {
58  m_libName.assign(libName);
59 
60  m_libHandle = dlopen(m_libName.c_str(), RTLD_NOW);
61  if (m_libHandle)
62  {
63  //std::cout << "Library Opened Successfully" << std::endl;
64  m_CreateAlgoCtx = dlsym_ptr<IDSPostProcessLibrary*(DSPostProcess_CreateParams*)>(m_libHandle, "CreateCustomAlgoCtx");
65  if (!m_CreateAlgoCtx)
66  {
67 
68  //throw std::runtime_error("CreateCustomAlgoCtx function not found in library");
69  std::cout << "CreateCustomAlgoCtx function not found in library" << std::endl;
70  return nullptr;
71  }
72  }
73  else
74  {
75  // throw std::runtime_error(dlerror());
76  std::cout << dlerror() << std::endl;
77  return nullptr;
78  }
79 
81  }
82 
83 public:
84  void *m_libHandle;
85  std::string m_libName;
87 };
88 
89 #endif
DSPostProcessLibrary_Factory::CreateCustomAlgoCtx
IDSPostProcessLibrary * CreateCustomAlgoCtx(std::string libName, DSPostProcess_CreateParams *params)
Definition: nvdspostprocesslib_factory.hpp:56
IDSPostProcessLibrary
Definition: nvdspostprocesslib_interface.hpp:52
DSPostProcessLibrary_Factory::m_CreateAlgoCtx
std::function< IDSPostProcessLibrary *(DSPostProcess_CreateParams *)> m_CreateAlgoCtx
Definition: nvdspostprocesslib_factory.hpp:86
DSPostProcessLibrary_Factory::~DSPostProcessLibrary_Factory
~DSPostProcessLibrary_Factory()
Definition: nvdspostprocesslib_factory.hpp:46
DSPostProcessLibrary_Factory::m_libHandle
void * m_libHandle
Definition: nvdspostprocesslib_factory.hpp:84
DSPostProcessLibrary_Factory::m_libName
std::string m_libName
Definition: nvdspostprocesslib_factory.hpp:85
DSPostProcessLibrary_Factory
Definition: nvdspostprocesslib_factory.hpp:39
DSPostProcess_CreateParams
Definition: nvdspostprocesslib_interface.hpp:36
nvdspostprocesslib_interface.hpp
dlsym_ptr
T * dlsym_ptr(void *handle, char const *name)
Copyright (c) 2022, NVIDIA CORPORATION.
Definition: nvdspostprocesslib_factory.hpp:35
DSPostProcessLibrary_Factory::DSPostProcessLibrary_Factory
DSPostProcessLibrary_Factory()
Definition: nvdspostprocesslib_factory.hpp:42