点云BEV投影cuda代码实现
点云bev代码实现
在做点云项目中,会用到常见的BEV方式,在部署中需要用c++去实现,下面对于点云bev预处理的cuda实现,贴出了详细代码。对于点云体素化同样可以参照这个方式去实现。
耗时:约在0.01ms。
主要是分为五个文件:
- 预处理头文件
- 参数头文件
- cuda核函数头文件
- cuda核函数实现
- cpp函数实现
#ifndef PREPROCESS_H_
#define PREPROCESS_H_
#include "kernel.h"
class PreProcessCuda
{
private:
Params params_;
cudaStream_t stream_ = 0;
unsigned int *mask_;
public:
PreProcessCuda();
~PreProcessCuda();
void generateBevProjection(float *points, size_t points_size, float *bevimage);
};
#endif
#ifndef _PARAMS_H_
#define _PARAMS_H_
class Params
{
public:
static const int num_classes = 6;
const float min_x_range = 0.0;
const float max_x_range = 46.08;
const float min_y_range = -11.52;
const float max_y_range = 11.52;
const float min_z_range = -3.0;
const float max_z_range = 1.1;
// the size of a voxel
const float voxel_x_size = 0.04;
const float voxel_y_size = 0.02;
// the input size of the 2D backbone network
const int grid_x_size = (max_x_range - min_x_range) / voxel_x_size;
const int grid_y_size = (max_y_range - min_y_range) / voxel_y_size;
// the output size of thr backbone network
const int feature_x_size = grid_x_size / 8;
const int feature_y_size = grid_y_size / 8;
const float z_value_min = -2.0;
const float z_value_max = 1.5;
const int i_value_min = 0;
const int i_value_max = 128;
const int r_value_min = 0;
const int r_value_max= 32768;
Params(/* args */) {
};
};
#endif
#ifndef _KERNEL_H_