MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
bundle.cc
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#include "mve/bundle.h"
11
13
14bool
15Bundle::Feature3D::contains_view_id (int id) const
16{
17 for (std::size_t i = 0; i < this->refs.size(); ++i)
18 if (this->refs[i].view_id == id)
19 return true;
20 return false;
21}
22
23/* -------------------------------------------------------------- */
24
25std::size_t
26Bundle::get_byte_size (void) const
27{
28 std::size_t ret = 0;
29 ret += this->cameras.capacity() * sizeof(CameraInfo);
30 ret += this->features.capacity() * sizeof(Feature3D);
31 for (std::size_t i = 0; i < this->features.size(); ++i)
32 ret += this->features[i].refs.capacity() * sizeof(Feature2D);
33 return ret;
34}
35
36/* -------------------------------------------------------------- */
37
38std::size_t
39Bundle::get_num_cameras (void) const
40{
41 return this->cameras.size();
42}
43
44/* -------------------------------------------------------------- */
45
46std::size_t
47Bundle::get_num_valid_cameras (void) const
48{
49 std::size_t ret = 0;
50 for (std::size_t i = 0; i < this->cameras.size(); ++i)
51 ret += (this->cameras[i].flen != 0.0f ? 1 : 0);
52 return ret;
53}
54
55/* -------------------------------------------------------------- */
56
58Bundle::get_features_as_mesh (void) const
59{
61 TriangleMesh::VertexList& verts = mesh->get_vertices();
62 TriangleMesh::ColorList& colors = mesh->get_vertex_colors();
63 for (std::size_t i = 0; i < this->features.size(); ++i)
64 {
65 Bundle::Feature3D const& f = this->features[i];
66 verts.push_back(math::Vec3f(f.pos));
67 colors.push_back(math::Vec4f(f.color[0], f.color[1], f.color[2], 1.0f));
68 }
69 return mesh;
70}
71
72/* -------------------------------------------------------------- */
73
74void
75Bundle::delete_camera (std::size_t index)
76{
77 if (index >= this->cameras.size())
78 throw std::invalid_argument("Invalid camera index");
79
80 /* Mark the deleted camera as invalid. */
81 this->cameras[index].flen = 0.0f;
82
83 /* Delete all SIFT features that are visible in this camera. */
84 for (std::size_t i = 0; i < this->features.size(); ++i)
85 {
86 Feature3D& feature = this->features[i];
87 typedef std::vector<Feature2D> FeatureRefs;
88 FeatureRefs& refs = feature.refs;
89
90 for (FeatureRefs::iterator iter = refs.begin(); iter != refs.end();)
91 if (iter->view_id == static_cast<int>(index))
92 iter = refs.erase(iter);
93 else
94 iter++;
95 }
96}
97
Vector class for arbitrary dimensions and types.
Definition vector.h:87
std::vector< math::Vec3f > VertexList
Definition mesh.h:33
std::vector< math::Vec4f > ColorList
Definition mesh.h:34
std::shared_ptr< TriangleMesh > Ptr
Definition mesh.h:92
static Ptr create(void)
Definition mesh.h:295
#define MVE_NAMESPACE_BEGIN
Definition defines.h:13
#define MVE_NAMESPACE_END
Definition defines.h:14
Representation of a 2D feature.
Definition bundle.h:34
Representation of a 3D feature with position and color.
Definition bundle.h:47
std::vector< Feature2D > refs
References to views that see the feature.
Definition bundle.h:53
float pos[3]
3D Position of the feature (track).
Definition bundle.h:49
float color[3]
RGB color of the feature in [0,1]^3.
Definition bundle.h:51
Per-view camera information with various helper functions.
Definition camera.h:24