NVIDIA DeepStream SDK API Reference

7.0 Release
nvdspostprocesslib_base.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2022 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 
57 
58 };
59 
60 
62  m_element = NULL;
63  m_gpuId = 0;
64  m_cudaStream = 0;
65 }
66 
68  if (params){
69  m_element = params->m_element;
70  m_gpuId = params->m_gpuId;
71  m_cudaStream = params->m_cudaStream;
72  }
73  else {
74  m_element = NULL;
75  m_gpuId = 0;
76  m_cudaStream = 0;
77  }
78 }
79 
81 }
82 
83 /* Helped function to get the NvBufSurface from the GstBuffer */
85 {
86  GstMapInfo in_map_info;
87  NvBufSurface *nvbuf_surface = NULL;
88 
89  /* Map the buffer contents and get the pointer to NvBufSurface. */
90  if (!gst_buffer_map (inbuf, &in_map_info, GST_MAP_READ)) {
91  printf ("%s:gst buffer map to get pointer to NvBufSurface failed", __func__);
92  return NULL;
93  }
94 
95  // Assuming that the plugin uses DS NvBufSurface data structure
96  nvbuf_surface = (NvBufSurface *) in_map_info.data;
97 
98  gst_buffer_unmap(inbuf, &in_map_info);
99  return nvbuf_surface;
100 }
101 
102 #endif
IDSPostProcessLibrary
Definition: nvdspostprocesslib_interface.hpp:53
NvBufSurface
Holds information about batched buffers.
Definition: nvbufsurface.h:509
BufferResult
BufferResult
Definition: gst-nvdsA2Vtemplate/includes/nvdscustomlib_interface.hpp:22
DSPostProcessLibraryBase::m_cudaStream
cudaStream_t m_cudaStream
Definition: nvdspostprocesslib_base.hpp:56
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_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:80
DSPostProcessLibraryBase::DSPostProcessLibraryBase
DSPostProcessLibraryBase()
Definition: nvdspostprocesslib_base.hpp:61
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
gstnvdsbufferpool.h
getNvBufSurface
static NvBufSurface * getNvBufSurface(GstBuffer *inbuf)
Definition: nvdspostprocesslib_base.hpp:84