imgproc.cpp
Go to the documentation of this file.
1 #include <kfusion/precomp.hpp>
2 
3 void kfusion::cuda::depthBilateralFilter(const Depth& in, Depth& out, int kernel_size, float sigma_spatial, float sigma_depth)
4 {
5  out.create(in.rows(), in.cols());
6  device::bilateralFilter(in, out, kernel_size, sigma_spatial, sigma_depth);
7 }
8 
9 void kfusion::cuda::depthTruncation(Depth& depth, float threshold)
10 { device::truncateDepth(depth, threshold); }
11 
12 void kfusion::cuda::depthBuildPyramid(const Depth& depth, Depth& pyramid, float sigma_depth)
13 {
14  pyramid.create (depth.rows () / 2, depth.cols () / 2);
15  device::depthPyr(depth, pyramid, sigma_depth);
16 }
17 
19 { cudaSafeCall(cudaDeviceSynchronize() ); }
20 
21 void kfusion::cuda::computeNormalsAndMaskDepth(const Intr& intr, Depth& depth, Normals& normals)
22 {
23  normals.create(depth.rows(), depth.cols());
24 
25  device::Reprojector reproj(intr.fx, intr.fy, intr.cx, intr.cy);
26 
27  device::Normals& n = (device::Normals&)normals;
28  device::computeNormalsAndMaskDepth(reproj, depth, n);
29 }
30 
31 void kfusion::cuda::computePointNormals(const Intr& intr, const Depth& depth, Cloud& points, Normals& normals)
32 {
33  points.create(depth.rows(), depth.cols());
34  normals.create(depth.rows(), depth.cols());
35 
36  device::Reprojector reproj(intr.fx, intr.fy, intr.cx, intr.cy);
37 
38  device::Points& p = (device::Points&)points;
39  device::Normals& n = (device::Normals&)normals;
40  device::computePointNormals(reproj, depth, p, n);
41 }
42 
43 
44 void kfusion::cuda::computeDists(const Depth& depth, Dists& dists, const Intr& intr)
45 {
46  dists.create(depth.rows(), depth.cols());
47  device::compute_dists(depth, dists, make_float2(intr.fx, intr.fy), make_float2(intr.cx, intr.cy));
48 }
49 
50 void kfusion::cuda::resizeDepthNormals(const Depth& depth, const Normals& normals, Depth& depth_out, Normals& normals_out)
51 {
52  depth_out.create (depth.rows()/2, depth.cols()/2);
53  normals_out.create (normals.rows()/2, normals.cols()/2);
54 
55  device::Normals& nsrc = (device::Normals&)normals;
56  device::Normals& ndst = (device::Normals&)normals_out;
57 
58  device::resizeDepthNormals(depth, nsrc, depth_out, ndst);
59 }
60 
61 void kfusion::cuda::resizePointsNormals(const Cloud& points, const Normals& normals, Cloud& points_out, Normals& normals_out)
62 {
63  points_out.create (points.rows()/2, points.cols()/2);
64  normals_out.create (normals.rows()/2, normals.cols()/2);
65 
66  device::Points& pi = (device::Points&)points;
67  device::Normals& ni= (device::Normals&)normals;
68 
69  device::Points& po = (device::Points&)points_out;
70  device::Normals& no = (device::Normals&)normals_out;
71 
72  device::resizePointsNormals(pi, ni, po, no);
73 }
74 
75 
76 void kfusion::cuda::renderImage(const Depth& depth, const Normals& normals, const Intr& intr, const Vec3f& light_pose, Image& image)
77 {
78  image.create(depth.rows(), depth.cols());
79 
80  const device::Depth& d = (const device::Depth&)depth;
81  const device::Normals& n = (const device::Normals&)normals;
82  device::Reprojector reproj(intr.fx, intr.fy, intr.cx, intr.fy);
83  device::Vec3f light = device_cast<device::Vec3f>(light_pose);
84 
85  device::Image& i = (device::Image&)image;
86  device::renderImage(d, n, reproj, light, i);
88 }
89 
90 void kfusion::cuda::renderImage(const Cloud& points, const Normals& normals, const Intr& intr, const Vec3f& light_pose, Image& image)
91 {
92  image.create(points.rows(), points.cols());
93 
94  const device::Points& p = (const device::Points&)points;
95  const device::Normals& n = (const device::Normals&)normals;
96  device::Reprojector reproj(intr.fx, intr.fy, intr.cx, intr.fy);
97  device::Vec3f light = device_cast<device::Vec3f>(light_pose);
98 
99  device::Image& i = (device::Image&)image;
100  device::renderImage(p, n, reproj, light, i);
102 }
103 
105 {
106  image.create(normals.rows(), normals.cols());
107  const device::Normals& n = (const device::Normals&)normals;
108  device::Image& i = (device::Image&)image;
109 
112 }
KF_EXPORTS void depthBuildPyramid(const Depth &depth, Depth &pyramid, float sigma_depth)
Definition: imgproc.cpp:12
void truncateDepth(Depth &depth, float max_dist)
cv::Vec3f Vec3f
Definition: types.hpp:16
void depthPyr(const Depth &source, Depth &pyramid, float sigma_depth)
KF_EXPORTS void computeDists(const Depth &depth, Dists &dists, const Intr &intr)
Definition: imgproc.cpp:44
KF_EXPORTS void computePointNormals(const Intr &intr, const Depth &depth, Cloud &points, Normals &normals)
Definition: imgproc.cpp:31
float fx
Definition: types.hpp:22
KF_EXPORTS void depthTruncation(Depth &depth, float threshold)
Definition: imgproc.cpp:9
int rows() const
Returns number of rows.
#define cudaSafeCall(expr)
Definition: safe_call.hpp:16
void bilateralFilter(const Depth &src, Depth &dst, int kernel_size, float sigma_spatial, float sigma_depth)
KF_EXPORTS void resizePointsNormals(const Cloud &points, const Normals &normals, Cloud &points_out, Normals &normals_out)
Definition: imgproc.cpp:61
KF_EXPORTS void resizeDepthNormals(const Depth &depth, const Normals &normals, Depth &depth_out, Normals &normals_out)
Definition: imgproc.cpp:50
float cx
Definition: types.hpp:22
D device_cast(const S &source)
Definition: precomp.hpp:16
SharedPointer p
void compute_dists(const Depth &depth, Dists dists, float2 f, float2 c)
float fy
Definition: types.hpp:22
KF_EXPORTS void depthBilateralFilter(const Depth &in, Depth &out, int ksz, float sigma_spatial, float sigma_depth)
Definition: imgproc.cpp:3
KF_EXPORTS void waitAllDefaultStream()
Definition: imgproc.cpp:18
KF_EXPORTS void renderTangentColors(const Normals &normals, Image &image)
Definition: imgproc.cpp:104
float cy
Definition: types.hpp:22
KF_EXPORTS void computeNormalsAndMaskDepth(const Intr &intr, Depth &depth, Normals &normals)
Definition: imgproc.cpp:21
void create(int rows, int cols)
Allocates internal buffer in GPU memory. If internal buffer was created before the function recreates...
KF_EXPORTS void renderImage(const Depth &depth, const Normals &normals, const Intr &intr, const Vec3f &light_pose, Image &image)
Definition: imgproc.cpp:76
int cols() const
Returns number of elements in each row.


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