My Project
MultiMarkerInitializer.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 MULTIMARKERINITIALIZER_H
25 #define MULTIMARKERINITIALIZER_H
26 
34 #include "MultiMarker.h"
35 
36 namespace alvar {
37 
49 class ALVAR_EXPORT MultiMarkerInitializer : public MultiMarker
50 {
51 public:
55  class MarkerMeasurement : public Marker
56  {
57  long _id;
58 
59  public:
60  MarkerMeasurement() : globalPose(false)
61  {
62  }
63  bool globalPose;
64  unsigned long
65  GetId() const
66  {
67  return _id;
68  }
69  void
70  SetId(unsigned long _id)
71  {
72  this->_id = _id;
73  }
74  };
75 
76 protected:
77  std::vector<bool> marker_detected;
78  std::vector<std::vector<MarkerMeasurement>> measurements;
79  typedef std::vector<std::vector<MarkerMeasurement>>::iterator MeasurementIterator;
80  FilterMedian * pointcloud_filtered;
81  int filter_buffer_min;
82 
83  bool updateMarkerPoses(std::vector<MarkerMeasurement> &markers, const Pose &pose);
84  void MeasurementsAdd(MarkerIterator &begin, MarkerIterator &end);
85 
86 public:
87  MultiMarkerInitializer(std::vector<int> &indices,
88  int filter_buffer_min = 4,
89  int filter_buffer_max = 15);
90  ~MultiMarkerInitializer();
91 
107  template <class M>
108  void
109  MeasurementsAdd(const std::vector<M> *markers)
110  {
111  MarkerIteratorImpl<M> begin(markers->begin());
112  MarkerIteratorImpl<M> end(markers->end());
113  MeasurementsAdd(begin, end);
114  }
115 
119  void MeasurementsReset();
120 
126  int Initialize(Camera *cam);
127 
128  int
129  getMeasurementCount()
130  {
131  return measurements.size();
132  }
133 
134  const std::vector<MarkerMeasurement> &
135  getMeasurementMarkers(int measurement)
136  {
137  return measurements[measurement];
138  }
139 
140  double
141  getMeasurementPose(int measurement, Camera *cam, Pose &pose)
142  {
143  MarkerIteratorImpl<MarkerMeasurement> m_begin(measurements[measurement].begin());
144  MarkerIteratorImpl<MarkerMeasurement> m_end(measurements[measurement].end());
145  return _GetPose(m_begin, m_end, cam, pose);
146  }
147 };
148 
149 } // namespace alvar
150 
151 #endif
This file implements a multi-marker.
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
Definition: Camera.h:82
Basic 2D Marker functionality.
Definition: Marker.h:53
Iterator implementation for traversing templated Marker vector without the template.
Definition: Marker.h:383
Base class for using MultiMarker.
Definition: MultiMarker.h:48
MarkerMeasurement that holds the maker id.
unsigned long GetId() const
Get id for this marker This is used e.g. in MarkerDetector to associate a marker id with an appropria...
Initializes multi marker by estimating their relative positions from one or more images.
void MeasurementsAdd(const std::vector< M > *markers)
Main ALVAR namespace.
Definition: Alvar.h:174