My Project
MultiMarkerBundle.h
Go to the documentation of this file.
1 /*
2  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
3  *
4  * Copyright 2007-2012 VTT Technical Research Centre of Finland
5  *
6  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
7  * <http://www.vtt.fi/multimedia/alvar.html>
8  *
9  * ALVAR is free software; you can redistribute it and/or modify it under the
10  * terms of the GNU Lesser General Public License as published by the Free
11  * Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
17  * for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with ALVAR; if not, see
21  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
22  */
23 
24 #ifndef MULTIMARKERBUNDLE_H
25 #define MULTIMARKERBUNDLE_H
26 
34 #include "MultiMarker.h"
35 #include "Optimization.h"
36 
37 namespace alvar {
38 
44 class ALVAR_EXPORT MultiMarkerBundle : public MultiMarker
45 {
46 protected:
47  int optimization_keyframes;
48  int optimization_markers;
49  double optimization_error;
50  bool optimizing;
51  std::vector<Pose> camera_poses; // Estimated camera pose for every frame
52  std::map<int, PointDouble> measurements; //
53  int
54  measurements_index(int frame, int marker_id, int marker_corner)
55  {
56  // hop return (int) (frame*marker_indices.size()*4)+(marker_id*4)+marker_corner;
57  return (int)(frame * marker_indices.size() * 4) + (get_id_index(marker_id) * 4) + marker_corner;
58  }
59 
60  void _MeasurementsAdd(MarkerIterator &begin, MarkerIterator &end, const Pose &camera_pose);
61 
62 public:
66  MultiMarkerBundle(std::vector<int> &indices);
67 
69 
74 
75  double
76  GetOptimizationError()
77  {
78  return optimization_error;
79  }
80  int
81  GetOptimizationKeyframes()
82  {
83  return optimization_keyframes;
84  }
85  int
86  GetOptimizationMarkers()
87  {
88  return optimization_markers;
89  }
90  bool
91  GetOptimizing()
92  {
93  return optimizing;
94  }
95 
100  template <class M>
101  void
102  MeasurementsAdd(const std::vector<M> *markers, const Pose &camera_pose)
103  {
104  MarkerIteratorImpl<M> begin(markers->begin());
105  MarkerIteratorImpl<M> end(markers->end());
106  _MeasurementsAdd(begin, end, camera_pose);
107  }
108  //LEVENBERGMARQUARDT
115  bool Optimize(Camera * _cam,
116  double stop,
117  int max_iter,
118  Optimization::OptimizeMethod method = Optimization::TUKEY_LM); //TUKEY_LM
119 };
120 
121 } // namespace alvar
122 
123 #endif
This file implements a multi-marker.
This file implements several optimization algorithms.
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
Definition: Camera.h:82
Iterator type for traversing templated Marker vector without the template.
Definition: Marker.h:365
Iterator implementation for traversing templated Marker vector without the template.
Definition: Marker.h:383
Multi marker that uses bundle adjustment to refine the 3D positions of the markers (point cloud).
void MeasurementsAdd(const std::vector< M > *markers, const Pose &camera_pose)
Adds new measurements that are used in bundle adjustment.
MultiMarkerBundle(std::vector< int > &indices)
Constructor.
bool Optimize(Camera *_cam, double stop, int max_iter, Optimization::OptimizeMethod method=Optimization::TUKEY_LM)
Runs the bundle adjustment optimization.
void MeasurementsReset()
Resets the measurements and camera poses that are stored for bundle adjustment. If something goes fro...
Base class for using MultiMarker.
Definition: MultiMarker.h:48
OptimizeMethod
Selection between the algorithm used in optimization. Following should be noticed:
Definition: Optimization.h:71
Pose representation derived from the Rotation class
Definition: Pose.h:53
Main ALVAR namespace.
Definition: Alvar.h:174