|
|
NVIDIA DeepStream SDK API Reference
|
9.0 Release
|
Go to the documentation of this file.
13 #ifndef __NVDSPREPROCESS_IMPL_H__
14 #define __NVDSPREPROCESS_IMPL_H__
17 #include <condition_variable>
24 #include <cuda_runtime_api.h>
26 #include "nvdspreprocess_interface.h"
33 #define _MAX_CHANNELS 4
36 #define DISABLE_CLASS_COPY(NoCopyClass) \
37 NoCopyClass(const NoCopyClass &) = delete; \
38 void operator=(const NoCopyClass &) = delete
41 #define SIMPLE_MOVE_COPY(Cls) \
42 Cls &operator=(Cls &&o) \
44 move_copy(std::move(o)); \
47 Cls(Cls &&o) { move_copy(std::move(o)); }
50 inline const char *
safeStr(
const std::string &str)
59 return (access(path, F_OK) != -1);
76 std::string labelsFilePath;
80 std::string meanImageFilePath;
85 std::vector<float> offsets;
88 float pixel_normalization_factor = 1.0;
100 explicit CudaStream(uint flag = cudaStreamDefault,
int priority = 0);
112 m_Stream = o.m_Stream;
113 o.m_Stream =
nullptr;
130 template <
typename T>
153 void*
m_Buf =
nullptr;
182 bool setScaleOffsets(
float scale,
const std::vector<float>& offsets = {});
207 float m_Scale = 1.0f;
208 std::vector<float> m_ChannelMeans;
209 std::string m_MeanFile;
211 std::unique_ptr<CudaStream> m_PreProcessStream;
212 std::unique_ptr<CudaDeviceBuffer> m_MeanDataBuffer;
222 std::unique_ptr<NvDsPreProcessTensorImpl> & m_Preprocessor,
int unique_id);
~CudaDeviceBuffer()
destructor
T * ptr()
template to return cuda buffer
CudaBuffer(size_t s)
helper move copy functionality
Custom parameters for normalization and mean subtractions.
@ NvDsPreProcessFormat_RGB
Specifies 24-bit interleaved R-G-B format.
Holds information about the model network.
bool setMeanFile(const std::string &file)
method to set mean file
Holds information about the batch of frames to be inferred.
const char * safeStr(const std::string &str)
helper check safe string in C
#define SIMPLE_MOVE_COPY(Cls)
helper move function
NvDsPreProcessStatus allocateResource()
allocate resources for tensor preparation
NvDsPreProcessStatus normalization_mean_subtraction_impl_initialize(CustomMeanSubandNormParams *custom_params, NvDsPreProcessTensorParams *tensor_params, std::unique_ptr< NvDsPreProcessTensorImpl > &m_Preprocessor, int unique_id)
Initialize for pixel normalization and mean subtraction.
bool setInputOrder(const NvDsPreProcessNetworkInputOrder order)
method to set network input order
NvDsPreProcessStatus
Enum for the status codes returned by NvDsPreProcessImpl.
Provides pre-processing functionality like mean subtraction and normalization.
Helper class for managing Cuda Streams.
NvDsPreProcessTensorImpl(const NvDsPreProcessNetworkSize &size, NvDsPreProcessFormat format, int id=0)
constructor for tensor preparation implementation
Helper base class for managing Cuda allocated buffers.
NvDsPreProcessStatus syncStream()
synchronize cuda stream
Tensor params passed to custom library for tensor preparation.
void move_copy(CudaBuffer &&o)
move_copy cuda buffer
virtual ~CudaBuffer()=default
virtual ~NvDsPreProcessTensorImpl()=default
Holds model parameters for tensor preparation.
void * m_Buf
pointer to cuda buffer
bool setScaleOffsets(float scale, const std::vector< float > &offsets={})
method to set offsets values
size_t bytes() const
size of cuda buffer in bytes
NvDsPreProcessNetworkInputOrder
Enum for the network input order according to which network shape will be provided to prepare raw ten...
CudaDeviceBuffer(size_t size)
constructor
@ NvDsPreProcessNetworkInputOrder_kNCHW
Specifies NCHW network input order.
DISABLE_CLASS_COPY(CudaBuffer)
disable class copy
void * ptr()
pointer to cuda buffer
NvDsPreProcessStatus prepare_tensor(NvDsPreProcessBatch *batch, CustomTensorParams &tensorParam, void *&devBuf)
method to prepare tensor using cuda kernels
bool file_accessible(const char *path)
helper check if file accessible in C
NvDsPreProcessFormat
Defines model color formats.
cudaStream_t & ptr()
pointer to cuda stream
static std::string format(const char *fmt,...)
CudaStream(uint flag=cudaStreamDefault, int priority=0)