My Project
TrackerOrientation.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 TRACKERORIENTATION_H
25 #define TRACKERORIENTATION_H
26 
27 #include "Camera.h"
28 #include "Pose.h"
29 #include "Tracker.h"
30 #include "TrackerFeatures.h"
31 
38 namespace alvar {
39 
43 class ALVAR_EXPORT TrackerOrientation : public Tracker
44 {
45 public:
46  TrackerOrientation(int width, int height, int image_scale = 1, int outlier_limit = 20)
47  : _image_scale(image_scale), _outlier_limit(outlier_limit), _xres(width), _yres(height)
48  {
49  _camera = 0;
50  _grsc = 0;
51  _object_model = 0;
52  }
53 
54 private:
55  struct Feature
56  {
57  enum { NOT_TRACKED = 0, IS_TRACKED } status2D;
58  enum { NONE = 0, USE_FOR_POSE, IS_OUTLIER, IS_INITIAL } status3D;
59 
60  Feature()
61  {
62  status3D = NONE;
63  status2D = NOT_TRACKED;
64  }
65 
66  Feature(double vx, double vy)
67  {
68  point.x = float(vx);
69  point.y = float(vy);
70  status3D = NONE;
71  status2D = NOT_TRACKED;
72  }
73 
74  ~Feature()
75  {
76  }
77 
78  cv::Point2f point;
79  cv::Point3d point3d;
80  };
81 
82  TrackerFeatures _ft;
83  std::map<int, Feature> _F_v;
84 
85  int _xres;
86  int _yres;
87  int _image_scale;
88  int _outlier_limit;
89 
90  Pose _pose;
91  cv::Mat _grsc;
92  Camera *_camera;
93  cv::Mat _object_model;
94 
95 public:
96  void
97  SetCamera(Camera *camera)
98  {
99  _camera = camera;
100  }
101  void GetPose(Pose &pose);
102  void
103  GetPose(double gl_mat[16])
104  {
105  _pose.GetMatrixGL(gl_mat);
106  }
107  void Reset();
108  double Track(cv::Mat &image);
109 
110 private:
111  static void Project(cv::Mat &state, cv::Mat &projection, void *param);
112  bool UpdatePose(cv::Mat &image);
113  bool UpdateRotationOnly(cv::Mat &gray, cv::Mat &image);
114 };
115 
116 } // namespace alvar
117 
118 #endif
This file implements a camera used for projecting points and computing homographies.
This file implements a pose.
This file implements a tracking interface.
This file implements a feature tracker.
Simple Camera class for calculating distortions, orientation or projections with pre-calibrated camer...
Definition: Camera.h:82
Pose representation derived from the Rotation class
Definition: Pose.h:53
void GetMatrixGL(double gl[16], bool mirror=true)
Get the transformation matrix representation of the Pose using OpenGL's transposed format....
TrackerFeatures tracks features using OpenCV's cvGoodFeaturesToTrack and cvCalcOpticalFlowPyrLK
Pure virtual base class for tracking optical flow.
Definition: Tracker.h:45
Track orientation based only on features in the image plane.
double Track(cv::Mat &image)
Pure virtual function for making the next track step. This analyses the image and updates class membe...
Main ALVAR namespace.
Definition: Alvar.h:174