NVIDIA DeepStream SDK API Reference

9.1 Release
sources/libs/nvdsinferserver/infer_preprocess_kernel.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018-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 
23 #ifndef __NVDSINFER_PREPROCESS_KERNEL_H__
24 #define __NVDSINFER_PREPROCESS_KERNEL_H__
25 
26 #include <cuda.h>
27 #include <cuda_fp16.h>
28 
29 #define NVDSINFER_MAX_PREPROC_CHANNELS 4
30 #define NVDSINFER_INVALID_CONVERSION_KEY UINT32_MAX
31 
33  unsigned int widthAlign;
34  unsigned int heightAlign;
35  unsigned int channelAlign;
36  // NCHW:pitchPerRow >= widthAlign
37  // NHWC:pitchPerRow >= widthAlign*channelAlign
38  unsigned int pitchPerRow;
39  unsigned int dataSizePerBatch;
40 };
41 
42 bool NvDsInferConvert_CxToPx(void* outBuffer, int outDataType,
43  BatchSurfaceInfo outBufferInfo, void* inBuffer, int inDatatype,
44  BatchSurfaceInfo inBufferInfo, int validN, int cropC, int cropH,
45  int cropW, // crop area
46  float scaleFactor, float meanOffsets[NVDSINFER_MAX_PREPROC_CHANNELS],
47  int fromChannelIndices[NVDSINFER_MAX_PREPROC_CHANNELS], int toNCHW,
48  cudaStream_t stream);
49 
50 bool NvDsInferConvert_CxToPxWithMeanBuffer(void* outBuffer, int outDataType,
51  BatchSurfaceInfo outBufferInfo, void* inBuffer, int inDatatype,
52  BatchSurfaceInfo inBufferInfo, int validN, int cropC, int cropH,
53  int cropW, // crop area
54  float scaleFactor, float* meanDataBuffer,
55  int fromChannelIndices[NVDSINFER_MAX_PREPROC_CHANNELS], int toNCHW,
56  cudaStream_t stream);
57 
62 typedef void (*NvDsInferConvertFcn)(void* outBuffer, int outDataType,
63  BatchSurfaceInfo outBufferInfo, void* inBuffer, int inDatatype,
64  BatchSurfaceInfo inBufferInfo, int validN, int cropC, int cropH,
65  int cropW, // crop area
66  float scaleFactor, float* meanDataBuffer,
67  int fromChannelIndices[NVDSINFER_MAX_PREPROC_CHANNELS], int toNCHW,
68  cudaStream_t stream);
69 
70 #endif /* __NVDSINFER_CONVERSION_H__ */
cudaStream_t
struct CUstream_st * cudaStream_t
Forward declaration of cudaStream_t.
Definition: sources/includes/nvbufsurftransform.h:35
NvDsInferConvertFcn
void(* NvDsInferConvertFcn)(void *outBuffer, int outDataType, BatchSurfaceInfo outBufferInfo, void *inBuffer, int inDatatype, BatchSurfaceInfo inBufferInfo, int validN, int cropC, int cropH, int cropW, float scaleFactor, float *meanDataBuffer, int fromChannelIndices[NVDSINFER_MAX_PREPROC_CHANNELS], int toNCHW, cudaStream_t stream)
Function pointer type to which any of the NvDsInferConvert functions can be assigned.
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:62
BatchSurfaceInfo
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:32
NvDsInferConvert_CxToPx
bool NvDsInferConvert_CxToPx(void *outBuffer, int outDataType, BatchSurfaceInfo outBufferInfo, void *inBuffer, int inDatatype, BatchSurfaceInfo inBufferInfo, int validN, int cropC, int cropH, int cropW, float scaleFactor, float meanOffsets[NVDSINFER_MAX_PREPROC_CHANNELS], int fromChannelIndices[NVDSINFER_MAX_PREPROC_CHANNELS], int toNCHW, cudaStream_t stream)
BatchSurfaceInfo::widthAlign
unsigned int widthAlign
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:33
NvDsInferConvert_CxToPxWithMeanBuffer
bool NvDsInferConvert_CxToPxWithMeanBuffer(void *outBuffer, int outDataType, BatchSurfaceInfo outBufferInfo, void *inBuffer, int inDatatype, BatchSurfaceInfo inBufferInfo, int validN, int cropC, int cropH, int cropW, float scaleFactor, float *meanDataBuffer, int fromChannelIndices[NVDSINFER_MAX_PREPROC_CHANNELS], int toNCHW, cudaStream_t stream)
BatchSurfaceInfo::channelAlign
unsigned int channelAlign
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:35
BatchSurfaceInfo::dataSizePerBatch
unsigned int dataSizePerBatch
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:39
BatchSurfaceInfo::heightAlign
unsigned int heightAlign
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:34
BatchSurfaceInfo::pitchPerRow
unsigned int pitchPerRow
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:38
NVDSINFER_MAX_PREPROC_CHANNELS
#define NVDSINFER_MAX_PREPROC_CHANNELS
Header file for pre-processing CUDA kernels with normalization and mean subtraction required by nvdsi...
Definition: sources/libs/nvdsinferserver/infer_preprocess_kernel.h:29