forked from shouxieai/tensorRT_Pro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpreprocess_kernel.cuh
More file actions
64 lines (50 loc) · 1.92 KB
/
Copy pathpreprocess_kernel.cuh
File metadata and controls
64 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef PREPROCESS_KERNEL_CUH
#define PREPROCESS_KERNEL_CUH
#include "cuda_tools.hpp"
namespace CUDAKernel{
enum class NormType : int{
None = 0,
MeanStd = 1,
AlphaBeta = 2
};
enum class ChannelType : int{
None = 0,
Invert = 1
};
struct Norm{
float mean[3];
float std[3];
float alpha, beta;
NormType type = NormType::None;
ChannelType channel_type = ChannelType::None;
// out = (x * alpha - mean) / std
static Norm mean_std(const float mean[3], const float std[3], float alpha = 1/255.0f, ChannelType channel_type=ChannelType::None);
// out = x * alpha + beta
static Norm alpha_beta(float alpha, float beta = 0, ChannelType channel_type=ChannelType::None);
// None
static Norm None();
};
void warp_affine_bilinear_and_normalize_plane(
uint8_t* src, int src_line_size, int src_width, int src_height,
float* dst , int dst_width, int dst_height,
float* matrix_2_3, uint8_t const_value, const Norm& norm,
cudaStream_t stream);
void warp_affine_bilinear_and_normalize_focus(
uint8_t* src, int src_line_size, int src_width, int src_height,
float* dst , int dst_width, int dst_height,
float* matrix_2_3, uint8_t const_value, const Norm& norm,
cudaStream_t stream);
void resize_bilinear_and_normalize(
uint8_t* src, int src_line_size, int src_width, int src_height, float* dst, int dst_width, int dst_height,
uint8_t const_value, const Norm& norm,
cudaStream_t stream);
void norm_feature(
float* feature_array, int num_feature, int feature_length,
cudaStream_t stream
);
void convert_nv12_to_bgr_invoke(
const uint8_t* y, const uint8_t* uv, int width, int height,
int linesize, uint8_t* dst,
cudaStream_t stream);
};
#endif // PREPROCESS_KERNEL_CUH