MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
depthmap.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef MVE_DEPTHMAP_HEADER
11#define MVE_DEPTHMAP_HEADER
12
13#include "math/vector.h"
14#include "math/matrix.h"
15#include "mve/defines.h"
16#include "mve/camera.h"
17#include "mve/image.h"
18#include "mve/mesh.h"
19
22
28FloatImage::Ptr
29depthmap_cleanup (FloatImage::ConstPtr dm, int64_t thres);
30
35void
36depthmap_confidence_clean (FloatImage::Ptr dm, FloatImage::ConstPtr cm);
37
50FloatImage::Ptr
52 math::Matrix3f const& invproj, float gc_sigma, float pc_fator);
53
61template <typename T>
62void
64 math::Matrix3f const& invproj, bool to_mve);
65
68
69/* ---------------------------------------------------------------- */
70
73
74const float DD_FACTOR_DEFAULT = 5.0f;
75
81float
82pixel_footprint (int64_t x, int64_t y, float depth,
83 math::Matrix3f const& invproj);
84
90pixel_3dpos (int64_t x, int64_t y, float depth,
91 math::Matrix3f const& invproj);
92
108 float dd_factor = DD_FACTOR_DEFAULT,
109 mve::Image<unsigned int>* vids = nullptr);
110
119 math::Matrix3f const& invproj, float dd_factor = DD_FACTOR_DEFAULT,
120 mve::Image<unsigned int>* vertex_ids = nullptr);
121
130 CameraInfo const& cam, float dd_factor = DD_FACTOR_DEFAULT,
131 mve::Image<unsigned int>* vertex_ids = nullptr);
132
139void
141
147void
148depthmap_mesh_confidences (TriangleMesh::Ptr mesh, int iterations = 3);
149
156void
157depthmap_mesh_peeling (TriangleMesh::Ptr mesh, int iterations = 1);
158
161
162/* ------------------------- Implementation ----------------------- */
163
166
167template <typename T>
168inline void
170 math::Matrix3f const& invproj, bool to_mve)
171{
172 std::size_t w = dm->width();
173 std::size_t h = dm->height();
174 std::size_t pos = 0;
175 for (std::size_t y = 0; y < h; ++y)
176 for (std::size_t x = 0; x < w; ++x, ++pos)
177 {
178 // Construct viewing ray for that pixel
179 math::Vec3f px((float)x + 0.5f, (float)y + 0.5f, 1.0f);
180 px = invproj * px;
181 // Measure length of viewing ray
182 double len = px.norm();
183 // Either divide or multiply with the length
184 dm->at(pos) *= (to_mve ? len : 1.0 / len);
185 }
186}
187
190
191#endif /* MVE_DEPTHMAP_HEADER */
Matrix class for arbitrary dimensions and types.
Definition matrix.h:54
Vector class for arbitrary dimensions and types.
Definition vector.h:87
T norm(void) const
Computes the norm (length) of the vector.
Definition vector.h:434
int64_t height(void) const
Returns the height of the image.
Definition image_base.h:207
int64_t width(void) const
Returns the width of the image.
Definition image_base.h:201
Multi-channel image class of arbitrary but homogenous data type.
Definition image.h:40
std::shared_ptr< Image< T > > Ptr
Definition image.h:42
std::shared_ptr< Image< T > const > ConstPtr
Definition image.h:43
T const & at(int64_t index) const
Linear indexing of image data.
Definition image.h:307
std::shared_ptr< TriangleMesh > Ptr
Definition mesh.h:92
#define MVE_IMAGE_NAMESPACE_END
Definition defines.h:17
#define MVE_NAMESPACE_BEGIN
Definition defines.h:13
#define MVE_IMAGE_NAMESPACE_BEGIN
Definition defines.h:16
#define MVE_NAMESPACE_END
Definition defines.h:14
#define MVE_GEOM_NAMESPACE_END
Definition defines.h:20
#define MVE_GEOM_NAMESPACE_BEGIN
Definition defines.h:19
void rangegrid_triangulate(Image< unsigned int > const &grid, TriangleMesh::Ptr mesh)
Algorithm to triangulate range grids.
Definition depthmap.cc:420
const float DD_FACTOR_DEFAULT
Definition depthmap.h:74
math::Vec3f pixel_3dpos(int64_t x, int64_t y, float depth, math::Matrix3f const &invproj)
Function that calculates the pixel 3D position in camera coordinates for pixel (x,...
Definition depthmap.cc:150
TriangleMesh::Ptr depthmap_triangulate(FloatImage::ConstPtr dm, math::Matrix3f const &invproj, float dd_factor, mve::Image< unsigned int > *vids)
Algorithm to triangulate depth maps.
Definition depthmap.cc:210
void depthmap_mesh_confidences(TriangleMesh::Ptr mesh, int iterations)
Algorithm to assign per-vertex confidence values to vertices of a triangulated depth map.
Definition depthmap.cc:497
float pixel_footprint(int64_t x, int64_t y, float depth, math::Matrix3f const &invproj)
Function that calculates the pixel footprint (pixel width) in 3D coordinates for pixel (x,...
Definition depthmap.cc:139
void depthmap_mesh_peeling(TriangleMesh::Ptr mesh, int iterations)
Algorithm that peels away triangles at the mesh bounary of a triangulated depth map.
Definition depthmap.cc:550
void depthmap_confidence_clean(FloatImage::Ptr dm, FloatImage::ConstPtr cm)
Removes the backplane according to the confidence map IN-PLACE.
Definition depthmap.cc:116
FloatImage::Ptr depthmap_cleanup(FloatImage::ConstPtr dm, int64_t thres)
Algorithm to clean small confident islands in the depth maps.
Definition depthmap.cc:90
void depthmap_convert_conventions(typename Image< T >::Ptr dm, math::Matrix3f const &invproj, bool to_mve)
Converts between depth map conventions IN-PLACE.
Definition depthmap.h:169
FloatImage::Ptr depthmap_bilateral_filter(FloatImage::ConstPtr dm, math::Matrix3f const &invproj, float gc_sigma, float pc_fator)
Filters the given depthmap using a bilateral filter.
Per-view camera information with various helper functions.
Definition camera.h:24