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 }
kfusion::device::depthPyr
void depthPyr(const Depth &source, Depth &pyramid, float sigma_depth)
kfusion::cuda::DeviceArray2D::create
void create(int rows, int cols)
Allocates internal buffer in GPU memory. If internal buffer was created before the function recreates...
Definition: device_array.hpp:274
kfusion::device::truncateDepth
void truncateDepth(Depth &depth, float max_dist)
kfusion::cuda::depthTruncation
KF_EXPORTS void depthTruncation(Depth &depth, float threshold)
Definition: imgproc.cpp:9
kfusion::Vec3f
cv::Vec3f Vec3f
Definition: types.hpp:16
kfusion::cuda::computeDists
KF_EXPORTS void computeDists(const Depth &depth, Dists &dists, const Intr &intr)
Definition: imgproc.cpp:44
kfusion::cuda::waitAllDefaultStream
KF_EXPORTS void waitAllDefaultStream()
Definition: imgproc.cpp:18
kfusion::cuda::resizePointsNormals
KF_EXPORTS void resizePointsNormals(const Cloud &points, const Normals &normals, Cloud &points_out, Normals &normals_out)
Definition: imgproc.cpp:61
kfusion::cuda::DeviceArray2D::cols
int cols() const
Returns number of elements in each row.
Definition: device_array.hpp:300
kfusion::cuda::depthBilateralFilter
KF_EXPORTS void depthBilateralFilter(const Depth &in, Depth &out, int ksz, float sigma_spatial, float sigma_depth)
Definition: imgproc.cpp:3
precomp.hpp
p
SharedPointer p
Definition: ConvertShared.hpp:42
kfusion::device::Reprojector
Definition: internal.hpp:63
kfusion::Intr::fy
float fy
Definition: types.hpp:22
kfusion::device::Vec3f
float3 Vec3f
Definition: internal.hpp:26
kfusion::cuda::depthBuildPyramid
KF_EXPORTS void depthBuildPyramid(const Depth &depth, Depth &pyramid, float sigma_depth)
Definition: imgproc.cpp:12
kfusion::device::bilateralFilter
void bilateralFilter(const Depth &src, Depth &dst, int kernel_size, float sigma_spatial, float sigma_depth)
kfusion::Intr::cy
float cy
Definition: types.hpp:22
kfusion::device::compute_dists
void compute_dists(const Depth &depth, Dists dists, float2 f, float2 c)
kfusion::cuda::computeNormalsAndMaskDepth
KF_EXPORTS void computeNormalsAndMaskDepth(const Intr &intr, Depth &depth, Normals &normals)
Definition: imgproc.cpp:21
kfusion::cuda::DeviceArray2D::rows
int rows() const
Returns number of rows.
Definition: device_array.hpp:301
kfusion::cuda::renderTangentColors
KF_EXPORTS void renderTangentColors(const Normals &normals, Image &image)
Definition: imgproc.cpp:104
kfusion::Intr::cx
float cx
Definition: types.hpp:22
cudaSafeCall
#define cudaSafeCall(expr)
Definition: safe_call.hpp:16
kfusion::cuda::computePointNormals
KF_EXPORTS void computePointNormals(const Intr &intr, const Depth &depth, Cloud &points, Normals &normals)
Definition: imgproc.cpp:31
kfusion::cuda::resizeDepthNormals
KF_EXPORTS void resizeDepthNormals(const Depth &depth, const Normals &normals, Depth &depth_out, Normals &normals_out)
Definition: imgproc.cpp:50
kfusion::cuda::DeviceArray2D< unsigned short >
kfusion::Intr::fx
float fx
Definition: types.hpp:22
kfusion::cuda::renderImage
KF_EXPORTS void renderImage(const Depth &depth, const Normals &normals, const Intr &intr, const Vec3f &light_pose, Image &image)
Definition: imgproc.cpp:76
kfusion::Intr
Definition: types.hpp:20


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 Wed Mar 2 2022 00:37:23