NVIDIA DeepStream SDK API Reference
9.0 Release
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: MIT
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
* and/or sell copies of the Software, and to permit persons to whom the
10
* Software is furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
* DEALINGS IN THE SOFTWARE.
22
*/
23
24
#ifndef __NVDSPOSTPROCESSLIB_FACTORY_HPP__
25
#define __NVDSPOSTPROCESSLIB_FACTORY_HPP__
26
27
#include <dlfcn.h>
28
#include <errno.h>
29
30
#include <iostream>
31
#include <functional>
32
33
#include "
nvdspostprocesslib_interface.hpp
"
34
35
template
<
class
T>
36
T*
dlsym_ptr
(
void
* handle,
char
const
* name) {
37
return
reinterpret_cast<
T*
>
(dlsym(handle, name));
38
}
39
40
class
DSPostProcessLibrary_Factory
41
{
42
public
:
43
DSPostProcessLibrary_Factory
()
44
{
45
}
46
47
~DSPostProcessLibrary_Factory
()
48
{
49
if
(
m_libHandle
)
50
{
51
dlclose(
m_libHandle
);
52
m_libHandle
= NULL;
53
m_libName
.clear();
54
}
55
}
56
57
IDSPostProcessLibrary
*
CreateCustomAlgoCtx
(std::string libName,
DSPostProcess_CreateParams
*params)
58
{
59
m_libName
.assign(libName);
60
61
m_libHandle
= dlopen(
m_libName
.c_str(), RTLD_NOW);
62
if
(
m_libHandle
)
63
{
64
m_CreateAlgoCtx
= dlsym_ptr<IDSPostProcessLibrary*(DSPostProcess_CreateParams*)>(
m_libHandle
,
"CreateCustomAlgoCtx"
);
65
if
(!
m_CreateAlgoCtx
)
66
{
67
std::cout <<
"CreateCustomAlgoCtx function not found in library\n"
;
68
return
nullptr
;
69
}
70
}
71
else
72
{
73
// throw std::runtime_error(dlerror());
74
std::cout << dlerror() << std::endl;
75
return
nullptr
;
76
}
77
return
m_CreateAlgoCtx
((
DSPostProcess_CreateParams
*)params);
78
}
79
80
public
:
81
void
*
m_libHandle
;
82
std::string
m_libName
;
83
std::function<
IDSPostProcessLibrary
*(
DSPostProcess_CreateParams
*)>
m_CreateAlgoCtx
;
84
};
85
86
#endif
DSPostProcessLibrary_Factory::CreateCustomAlgoCtx
IDSPostProcessLibrary * CreateCustomAlgoCtx(std::string libName, DSPostProcess_CreateParams *params)
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:57
IDSPostProcessLibrary
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:54
DSPostProcessLibrary_Factory::~DSPostProcessLibrary_Factory
~DSPostProcessLibrary_Factory()
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:47
dlsym_ptr
T * dlsym_ptr(void *handle, char const *name)
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:36
DSPostProcessLibrary_Factory::m_libHandle
void * m_libHandle
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:81
DSPostProcessLibrary_Factory::m_CreateAlgoCtx
std::function< IDSPostProcessLibrary *(DSPostProcess_CreateParams *)> m_CreateAlgoCtx
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:83
DSPostProcessLibrary_Factory::m_libName
std::string m_libName
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:82
DSPostProcessLibrary_Factory
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:40
DSPostProcess_CreateParams
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:37
nvdspostprocesslib_interface.hpp
DSPostProcessLibrary_Factory::DSPostProcessLibrary_Factory
DSPostProcessLibrary_Factory()
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:43
Privacy Policy
|
Manage My Privacy
|
Do Not Sell or Share My Data
|
Terms of Service
|
Accessibility
|
Corporate Policies
|
Product Security
|
Contact
© 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
NVIDIA Confidential | Subject to Change | For test and development only.
Fri Mar 20 2026 14:37:00 | PR-09318-R32