MarkerDetector.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 MARKER_DETECTOR_H
25 #define MARKER_DETECTOR_H
26 
33 #include "Alvar.h"
34 #include "Util.h"
35 #include "ConnectedComponents.h"
36 #include "Draw.h"
37 #include "Camera.h"
38 #include "Marker.h"
39 #include "Rotation.h"
40 #include "Line.h"
41 #include <algorithm>
42 using std::rotate;
43 #include <list>
44 #include <vector>
45 #include <map>
46 #include <cassert>
47 #include <Eigen/StdVector>
48 
49 namespace alvar {
50 
55 protected:
56  virtual Marker* new_M(double _edge_length = 0, int _res = 0, double _margin = 0) = 0;
57  virtual void _markers_clear() = 0;
58  virtual void _markers_push_back(Marker *mn) = 0;
59  virtual size_t _markers_size() = 0;
60  virtual void _track_markers_clear() = 0;
61  virtual void _track_markers_push_back(Marker *mn) = 0;
62  virtual size_t _track_markers_size() = 0;
63  virtual Marker* _track_markers_at(size_t i) = 0;
64  virtual void _swap_marker_tables() = 0;
65 
67 
68  std::map<unsigned long, double> map_edge_length;
69  double edge_length;
70  int res;
71  double margin;
73 
75  virtual ~MarkerDetectorImpl();
76 
77 public:
79  void TrackMarkersReset();
80 
87  void TrackMarkerAdd(int id, PointDouble corners[4]);
88 
96  void SetMarkerSize(double _edge_length = 1, int _res = 5, double _margin = 2);
97 
102  void SetMarkerSizeForId(unsigned long id, double _edge_length = 1);
103 
107  void SetOptions(bool _detect_pose_grayscale=false);
108 
122  int Detect(IplImage *image,
123  Camera *cam,
124  bool track=false,
125  bool visualize=false,
126  double max_new_marker_error=0.08,
127  double max_track_error=0.2,
128  LabelingMethod labeling_method=CVSEQ,
129  bool update_pose=true);
130 
131  int DetectAdditional(IplImage *image, Camera *cam, bool visualize=false, double max_track_error=0.2);
132 };
133 
138 template<class M>
140 {
141 protected:
142  Marker* new_M(double _edge_length = 0, int _res = 0, double _margin = 0) {
143  return new M(_edge_length, _res, _margin);
144  }
145 
146  void _markers_clear() { markers->clear(); }
147  void _markers_push_back(Marker *mn) { markers->push_back(*((M*)mn)); }
148  size_t _markers_size() { return markers->size(); }
149  void _track_markers_clear() { track_markers->clear(); }
150  void _track_markers_push_back(Marker *mn) { track_markers->push_back(*((M*)mn)); }
151  size_t _track_markers_size() { return track_markers->size(); }
152  Marker* _track_markers_at(size_t i) { return &track_markers->at(i); }
153 
155  std::vector<M, Eigen::aligned_allocator<M> > *tmp_markers = markers;
156  markers = track_markers;
157  track_markers = tmp_markers;
158  }
159 
160 public:
161 
162  std::vector<M, Eigen::aligned_allocator<M> > *markers;
163  std::vector<M, Eigen::aligned_allocator<M> > *track_markers;
164 
167  markers = new std::vector<M, Eigen::aligned_allocator<M> >;
168  track_markers = new std::vector<M, Eigen::aligned_allocator<M> >;
169  }
170 
173  delete markers;
174  delete track_markers;
175  }
176 };
177 
178 } // namespace alvar
179 
180 #endif
double max_new_marker_error
Main ALVAR namespace.
Definition: Alvar.h:174
std::map< unsigned long, double > map_edge_length
This file implements a parametrized line.
This file implements connected component labeling.
This file implements a camera used for projecting points and computing homographies.
Marker * _track_markers_at(size_t i)
This file implements a collection of functions that are used to visualize lines, contours and corners...
int visualize
unsigned char * image
Definition: GlutViewer.cpp:155
void _markers_push_back(Marker *mn)
Templateless version of MarkerDetector. Please use MarkerDetector instead.
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
Definition: Camera.h:82
std::vector< M, Eigen::aligned_allocator< M > > * markers
Base class for labeling connected components from binary image.
This file implements a parametrized rotation.
MarkerDetector for detecting markers of type M
Basic 2D Marker functionality.
Definition: Marker.h:52
This file implements generic utility functions and a serialization interface.
#define ALVAR_EXPORT
Definition: Alvar.h:168
double max_track_error
void _track_markers_push_back(Marker *mn)
std::vector< M, Eigen::aligned_allocator< M > > * track_markers
ALVAR_EXPORT Point< CvPoint2D64f > PointDouble
The default double point type.
Definition: Util.h:108
Marker * new_M(double _edge_length=0, int _res=0, double _margin=0)
Camera * cam
This file implements a marker interface as well as ALVAR markers and ARToolKit markers.
This file defines library export definitions, version numbers and build information.


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Thu Jun 6 2019 19:27:24