|
|
NVIDIA DeepStream SDK API Reference
|
9.1 Release
|
Go to the documentation of this file.
18 #ifndef __NVDSPREPROCESS_IMPL_H__
19 #define __NVDSPREPROCESS_IMPL_H__
22 #include <condition_variable>
29 #include <cuda_runtime_api.h>
31 #include "nvdspreprocess_interface.h"
38 #define _MAX_CHANNELS 4
41 #define DISABLE_CLASS_COPY(NoCopyClass) \
42 NoCopyClass(const NoCopyClass &) = delete; \
43 void operator=(const NoCopyClass &) = delete
46 #define SIMPLE_MOVE_COPY(Cls) \
47 Cls &operator=(Cls &&o) \
49 move_copy(std::move(o)); \
52 Cls(Cls &&o) { move_copy(std::move(o)); }
55 inline const char *
safeStr(
const std::string &str)
64 return (access(path, F_OK) != -1);
81 std::string labelsFilePath;
85 std::string meanImageFilePath;
90 std::vector<float> offsets;
93 float pixel_normalization_factor = 1.0;
105 explicit CudaStream(uint flag = cudaStreamDefault,
int priority = 0);
117 m_Stream = o.m_Stream;
118 o.m_Stream =
nullptr;
135 template <
typename T>
158 void*
m_Buf =
nullptr;
187 bool setScaleOffsets(
float scale,
const std::vector<float>& offsets = {});
212 float m_Scale = 1.0f;
213 std::vector<float> m_ChannelMeans;
214 std::string m_MeanFile;
216 std::unique_ptr<CudaStream> m_PreProcessStream;
217 std::unique_ptr<CudaDeviceBuffer> m_MeanDataBuffer;
227 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.
#define SIMPLE_MOVE_COPY(Cls)
helper move function
const char * safeStr(const std::string &str)
helper check safe string in C
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)