NVIDIA DeepStream SDK API Reference

7.1 Release
nvdspostprocesslib_base.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_BASE_HPP__
25 #define __NVDSPOSTPROCESSLIB_BASE_HPP__
26 
27 #include <gst/base/gstbasetransform.h>
28 #include <gst/video/video.h>
29 
30 #include "gstnvdsbufferpool.h"
32 
34 {
35 public:
37 
39 
40  virtual ~DSPostProcessLibraryBase();
41 
42  virtual bool HandleEvent (GstEvent *event) = 0;
43 
44  virtual bool SetConfigFile (const gchar *config_file) = 0;
45 
46  /* Process Incoming Buffer */
47  virtual BufferResult ProcessBuffer(GstBuffer *inbuf) = 0;
48 
49 public:
50  /* Gstreamer dsexaple2 plugin's base class reference */
51  GstBaseTransform *m_element;
52 
54  guint m_gpuId;
55 
58 
59 };
60 
61 
63  m_element = NULL;
64  m_gpuId = 0;
65  m_cudaStream = 0;
66  m_preprocessor_support = FALSE;
67 }
68 
70  if (params){
71  m_element = params->m_element;
72  m_gpuId = params->m_gpuId;
73  m_cudaStream = params->m_cudaStream;
75  }
76  else {
77  m_element = NULL;
78  m_gpuId = 0;
79  m_cudaStream = 0;
81  }
82 }
83 
85 }
86 
87 /* Helped function to get the NvBufSurface from the GstBuffer */
89 {
90  GstMapInfo in_map_info = GST_MAP_INFO_INIT;
91  NvBufSurface *nvbuf_surface = NULL;
92 
93  /* Map the buffer contents and get the pointer to NvBufSurface. */
94  if (!gst_buffer_map (inbuf, &in_map_info, GST_MAP_READ)) {
95  printf ("%s:gst buffer map to get pointer to NvBufSurface failed", __func__);
96  return NULL;
97  }
98 
99  // Assuming that the plugin uses DS NvBufSurface data structure
100  nvbuf_surface = (NvBufSurface *) in_map_info.data;
101 
102  gst_buffer_unmap(inbuf, &in_map_info);
103  return nvbuf_surface;
104 }
105 
106 #endif
IDSPostProcessLibrary
Definition: nvdspostprocesslib_interface.hpp:54
NvBufSurface
Holds information about batched buffers.
Definition: nvbufsurface.h:520
BufferResult
BufferResult
Definition: gst-nvdsA2Vtemplate/includes/nvdscustomlib_interface.hpp:22
DSPostProcessLibraryBase::m_cudaStream
cudaStream_t m_cudaStream
Definition: nvdspostprocesslib_base.hpp:57
DSPostProcess_CreateParams::m_gpuId
guint m_gpuId
Definition: nvdspostprocesslib_interface.hpp:39
DSPostProcessLibraryBase
Definition: nvdspostprocesslib_base.hpp:33
DSPostProcess_CreateParams::m_cudaStream
cudaStream_t m_cudaStream
Definition: nvdspostprocesslib_interface.hpp:40
DSPostProcess_CreateParams::m_preprocessor_support
bool m_preprocessor_support
Definition: nvdspostprocesslib_interface.hpp:41
DSPostProcess_CreateParams::m_element
GstBaseTransform * m_element
Definition: nvdspostprocesslib_interface.hpp:38
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: nvbufsurftransform.h:34
DSPostProcessLibraryBase::~DSPostProcessLibraryBase
virtual ~DSPostProcessLibraryBase()
Definition: nvdspostprocesslib_base.hpp:84
DSPostProcessLibraryBase::DSPostProcessLibraryBase
DSPostProcessLibraryBase()
Definition: nvdspostprocesslib_base.hpp:62
DSPostProcess_CreateParams
Definition: nvdspostprocesslib_interface.hpp:37
DSPostProcessLibraryBase::m_gpuId
guint m_gpuId
GPU ID on which we expect to execute the algorithm.
Definition: nvdspostprocesslib_base.hpp:54
DSPostProcessLibraryBase::m_element
GstBaseTransform * m_element
Definition: nvdspostprocesslib_base.hpp:51
nvdspostprocesslib_interface.hpp
DSPostProcessLibraryBase::SetConfigFile
virtual bool SetConfigFile(const gchar *config_file)=0
DSPostProcessLibraryBase::HandleEvent
virtual bool HandleEvent(GstEvent *event)=0
GstBuffer
struct _GstBuffer GstBuffer
Definition: idatatype.h:19
DSPostProcessLibraryBase::ProcessBuffer
virtual BufferResult ProcessBuffer(GstBuffer *inbuf)=0
DSPostProcessLibraryBase::m_preprocessor_support
gboolean m_preprocessor_support
Definition: nvdspostprocesslib_base.hpp:56
gstnvdsbufferpool.h
getNvBufSurface
static NvBufSurface * getNvBufSurface(GstBuffer *inbuf)
Definition: nvdspostprocesslib_base.hpp:88