NVIDIA DeepStream SDK API Reference
9.1 Release
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2022-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 __NVDSPOSTPROCESSLIB_FACTORY_HPP__
19
#define __NVDSPOSTPROCESSLIB_FACTORY_HPP__
20
21
#include <dlfcn.h>
22
#include <errno.h>
23
24
#include <iostream>
25
#include <functional>
26
27
#include "
nvdspostprocesslib_interface.hpp
"
28
29
template
<
class
T>
30
T*
dlsym_ptr
(
void
* handle,
char
const
* name) {
31
return
reinterpret_cast<
T*
>
(dlsym(handle, name));
32
}
33
34
class
DSPostProcessLibrary_Factory
35
{
36
public
:
37
DSPostProcessLibrary_Factory
()
38
{
39
}
40
41
~DSPostProcessLibrary_Factory
()
42
{
43
if
(
m_libHandle
)
44
{
45
dlclose(
m_libHandle
);
46
m_libHandle
= NULL;
47
m_libName
.clear();
48
}
49
}
50
51
IDSPostProcessLibrary
*
CreateCustomAlgoCtx
(std::string libName,
DSPostProcess_CreateParams
*params)
52
{
53
m_libName
.assign(libName);
54
55
m_libHandle
= dlopen(
m_libName
.c_str(), RTLD_NOW);
56
if
(
m_libHandle
)
57
{
58
m_CreateAlgoCtx
= dlsym_ptr<IDSPostProcessLibrary*(DSPostProcess_CreateParams*)>(
m_libHandle
,
"CreateCustomAlgoCtx"
);
59
if
(!
m_CreateAlgoCtx
)
60
{
61
std::cout <<
"CreateCustomAlgoCtx function not found in library\n"
;
62
return
nullptr
;
63
}
64
}
65
else
66
{
67
// throw std::runtime_error(dlerror());
68
std::cout << dlerror() << std::endl;
69
return
nullptr
;
70
}
71
return
m_CreateAlgoCtx
((
DSPostProcess_CreateParams
*)params);
72
}
73
74
public
:
75
void
*
m_libHandle
;
76
std::string
m_libName
;
77
std::function<
IDSPostProcessLibrary
*(
DSPostProcess_CreateParams
*)>
m_CreateAlgoCtx
;
78
};
79
80
#endif
DSPostProcessLibrary_Factory::CreateCustomAlgoCtx
IDSPostProcessLibrary * CreateCustomAlgoCtx(std::string libName, DSPostProcess_CreateParams *params)
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:51
IDSPostProcessLibrary
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:48
DSPostProcessLibrary_Factory::~DSPostProcessLibrary_Factory
~DSPostProcessLibrary_Factory()
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:41
dlsym_ptr
T * dlsym_ptr(void *handle, char const *name)
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:30
DSPostProcessLibrary_Factory::m_libHandle
void * m_libHandle
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:75
DSPostProcessLibrary_Factory::m_CreateAlgoCtx
std::function< IDSPostProcessLibrary *(DSPostProcess_CreateParams *)> m_CreateAlgoCtx
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:77
DSPostProcessLibrary_Factory::m_libName
std::string m_libName
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:76
DSPostProcessLibrary_Factory
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:34
DSPostProcess_CreateParams
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_interface.hpp:31
nvdspostprocesslib_interface.hpp
DSPostProcessLibrary_Factory::DSPostProcessLibrary_Factory
DSPostProcessLibrary_Factory()
Definition:
sources/gst-plugins/gst-nvdspostprocess/includes/nvdspostprocesslib_factory.hpp:37
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.
Thu Jul 9 2026 11:48:20 | PR-09318-R32