internal.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <kfusion/tsdf_buffer.h>
5 #include "safe_call.hpp"
6 
7 //#define USE_DEPTH
8 
9 namespace kfusion
10 {
11  namespace device
12  {
13  typedef float4 Normal;
14  typedef float4 Point;
15 
16  typedef unsigned short ushort;
17  typedef unsigned char uchar;
18 
24 
25  typedef int3 Vec3i;
26  typedef float3 Vec3f;
27  struct Mat3f { float3 data[3]; };
28  struct Aff3f { Mat3f R; Vec3f t; };
29 
30  struct TsdfVolume
31  {
32  public:
33  typedef ushort2 elem_type;
34 
35  elem_type *const data;
36  const int3 dims;
37  const float3 voxel_size;
38  const float trunc_dist;
39  const int max_weight;
40 
41  TsdfVolume(elem_type* data, int3 dims, float3 voxel_size, float trunc_dist, int max_weight);
42  //TsdfVolume(const TsdfVolume&);
43 
44  __kf_device__ elem_type* operator()(int x, int y, int z);
45  __kf_device__ const elem_type* operator() (int x, int y, int z) const ;
46  __kf_device__ elem_type* beg(int x, int y) const;
47  __kf_device__ elem_type* zstep(elem_type *const ptr) const;
48  __kf_device__ elem_type* multzstep(int mult, elem_type *const ptr) const;
49 
50 
51  private:
52  TsdfVolume& operator=(const TsdfVolume&);
53  };
54 
55  struct Projector
56  {
57  float2 f, c;
59  Projector(float fx, float fy, float cx, float cy);
60  __kf_device__ float2 operator()(const float3& p) const;
61  };
62 
63  struct Reprojector
64  {
66  Reprojector(float fx, float fy, float cx, float cy);
67  float2 finv, c;
68  __kf_device__ float3 operator()(int x, int y, float z) const;
69  };
70 
72  {
73  struct Policy;
75  {
76  float* data;
78  ~PageLockHelper();
79  };
80 
81  float min_cosine;
82  float dist2_thres;
83 
85 
86  float rows, cols;
87  float2 f, c, finv;
88 
92 
93  ComputeIcpHelper(float dist_thres, float angle_thres);
94  void setLevelIntr(int level_index, float fx, float fy, float cx, float cy);
95 
96  void operator()(const Depth& dprev, const Normals& nprev, DeviceArray2D<float>& buffer, float* data, cudaStream_t stream);
97  void operator()(const Points& vprev, const Normals& nprev, DeviceArray2D<float>& buffer, float* data, cudaStream_t stream);
98 
99  static void allocate_buffer(DeviceArray2D<float>& buffer, int partials_count = -1);
100 
101  //private:
102  __kf_device__ int find_coresp(int x, int y, float3& n, float3& d, float3& s) const;
103  __kf_device__ void partial_reduce(const float row[7], PtrStep<float>& partial_buffer) const;
104  __kf_device__ float2 proj(const float3& p) const;
105  __kf_device__ float3 reproj(float x, float y, float z) const;
106  };
107 
108  //tsdf volume functions
109  void clear_volume(TsdfVolume volume);
110  void clearTSDFSlice (const TsdfVolume& volume, const kfusion::tsdf_buffer* buffer, const Vec3i offset);
111  void integrate(const Dists& depth, TsdfVolume& volume, tsdf_buffer& buffer, const Aff3f& aff, const Projector& proj);
112 
113  void raycast(const TsdfVolume& volume, tsdf_buffer& buffer, const Aff3f& aff, const Mat3f& Rinv,
114  const Reprojector& reproj, Depth& depth, Normals& normals, float step_factor, float delta_factor);
115 
116  void raycast(const TsdfVolume& volume, tsdf_buffer& buffer, const Aff3f& aff, const Mat3f& Rinv,
117  const Reprojector& reproj, Points& points, Normals& normals, float step_factor, float delta_factor);
118 
119  __kf_device__ ushort2 pack_tsdf(float tsdf, int weight);
120  __kf_device__ float unpack_tsdf(ushort2 value, int& weight);
121  __kf_device__ float unpack_tsdf(ushort2 value);
122 
123 
124  //image proc functions
125  void compute_dists(const Depth& depth, Dists dists, float2 f, float2 c);
126 
127  void truncateDepth(Depth& depth, float max_dist /*meters*/);
128  void bilateralFilter(const Depth& src, Depth& dst, int kernel_size, float sigma_spatial, float sigma_depth);
129  void depthPyr(const Depth& source, Depth& pyramid, float sigma_depth);
130 
131  void resizeDepthNormals(const Depth& depth, const Normals& normals, Depth& depth_out, Normals& normals_out);
132  void resizePointsNormals(const Points& points, const Normals& normals, Points& points_out, Normals& normals_out);
133 
134  void computeNormalsAndMaskDepth(const Reprojector& reproj, Depth& depth, Normals& normals);
135  void computePointNormals(const Reprojector& reproj, const Depth& depth, Points& points, Normals& normals);
136 
137  void renderImage(const Depth& depth, const Normals& normals, const Reprojector& reproj, const Vec3f& light_pose, Image& image);
138  void renderImage(const Points& points, const Normals& normals, const Reprojector& reproj, const Vec3f& light_pose, Image& image);
139  void renderTangentColors(const Normals& normals, Image& image);
140 
141 
142  //exctraction functionality
143  size_t extractSliceAsCloud (const TsdfVolume& volume, const kfusion::tsdf_buffer* buffer,
144  const Vec3i minBounds, const Vec3i maxBounds, const Vec3i globalShift
145  , const Aff3f& aff, PtrSz<Point> output);
146  size_t extractCloud(const TsdfVolume& volume, const tsdf_buffer& buffer, const Aff3f& aff, PtrSz<Point> output);
147  void extractNormals(const TsdfVolume& volume, const tsdf_buffer& buffer, const PtrSz<Point>& points, const Aff3f& aff, const Mat3f& Rinv, float gradient_delta_factor, float4* output);
148 
149 
150  //push
151  //void pushCloudAsSliceGPU (const TsdfVolume& volume, DeviceArray<float3> cloud_gpu, const tsdf_buffer* buffer);
152 
153  struct float8 { float x, y, z, w, c1, c2, c3, c4; };
154  struct float12 { float x, y, z, w, normal_x, normal_y, normal_z, n4, c1, c2, c3, c4; };
155  void mergePointNormal(const DeviceArray<Point>& cloud, const DeviceArray<float8>& normals, const DeviceArray<float12>& output);
156  }
157 }
void truncateDepth(Depth &depth, float max_dist)
void clearTSDFSlice(const TsdfVolume &volume, const kfusion::tsdf_buffer *buffer, const Vec3i offset)
void resizeDepthNormals(const Depth &depth, const Normals &normals, Depth &depth_out, Normals &normals_out)
PtrStepSz< ushort > Dists
Definition: internal.hpp:19
Structure to handle buffer addresses.
Definition: tsdf_buffer.h:48
void mergePointNormal(const DeviceArray< Point > &cloud, const DeviceArray< float8 > &normals, const DeviceArray< float12 > &output)
elem_type *const data
Definition: internal.hpp:35
void renderTangentColors(const Normals &normals, Image &image)
void depthPyr(const Depth &source, Depth &pyramid, float sigma_depth)
unsigned char uchar
Definition: internal.hpp:17
unsigned short ushort
Definition: internal.hpp:16
void computePointNormals(const Reprojector &reproj, const Depth &depth, Points &points, Normals &normals)
void raycast(const TsdfVolume &volume, tsdf_buffer &buffer, const Aff3f &aff, const Mat3f &Rinv, const Reprojector &reproj, Depth &depth, Normals &normals, float step_factor, float delta_factor)
#define __kf_device__
void integrate(const Dists &depth, TsdfVolume &volume, tsdf_buffer &buffer, const Aff3f &aff, const Projector &proj)
__kf_device__ ushort2 pack_tsdf(float tsdf, int weight)
packing/unpacking tsdf volume element
Definition: device.hpp:56
size_t extractCloud(const TsdfVolume &volume, const tsdf_buffer &buffer, const Aff3f &aff, PtrSz< Point > output)
size_t extractSliceAsCloud(const TsdfVolume &volume, const kfusion::tsdf_buffer *buffer, const Vec3i minBounds, const Vec3i maxBounds, const Vec3i globalShift, const Aff3f &aff, PtrSz< Point > output)
void bilateralFilter(const Depth &src, Depth &dst, int kernel_size, float sigma_spatial, float sigma_depth)
DeviceArray2D class
SharedPointer p
DeviceArray class
void renderImage(const Depth &depth, const Normals &normals, const Reprojector &reproj, const Vec3f &light_pose, Image &image)
void compute_dists(const Depth &depth, Dists dists, float2 f, float2 c)
void computeNormalsAndMaskDepth(const Reprojector &reproj, Depth &depth, Normals &normals)
DeviceArray2D< Normal > Normals
Definition: internal.hpp:21
DeviceArray2D< ushort > Depth
Definition: internal.hpp:20
void extractNormals(const TsdfVolume &volume, const tsdf_buffer &buffer, const PtrSz< Point > &points, const Aff3f &aff, const Mat3f &Rinv, float gradient_delta_factor, float4 *output)
DeviceArray2D< uchar4 > Image
Definition: internal.hpp:23
__kf_device__ float unpack_tsdf(ushort2 value, int &weight)
Definition: device.hpp:59
DeviceArray2D< Point > Points
Definition: internal.hpp:22
Utility.
Definition: capture.hpp:8
void clear_volume(TsdfVolume volume)
void resizePointsNormals(const Points &points, const Normals &normals, Points &points_out, Normals &normals_out)


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06