TrackerOrientation.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
00003  *
00004  * Copyright 2007-2012 VTT Technical Research Centre of Finland
00005  *
00006  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
00007  *          <http://www.vtt.fi/multimedia/alvar.html>
00008  *
00009  * ALVAR is free software; you can redistribute it and/or modify it under the
00010  * terms of the GNU Lesser General Public License as published by the Free
00011  * Software Foundation; either version 2.1 of the License, or (at your option)
00012  * any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but WITHOUT
00015  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00017  * for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with ALVAR; if not, see
00021  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
00022  */
00023 
00024 #ifndef TRACKERORIENTATION_H
00025 #define TRACKERORIENTATION_H
00026 
00027 #include "Tracker.h"
00028 #include "TrackerFeatures.h"
00029 #include "Pose.h"
00030 #include "Camera.h"
00031 
00038 namespace alvar {
00039 
00043 class ALVAR_EXPORT TrackerOrientation : public Tracker {
00044         
00045 public:
00046         TrackerOrientation(int width, int height, int image_scale=1, int outlier_limit=20)
00047                 : _image_scale(image_scale)
00048                 , _outlier_limit(outlier_limit)
00049                 , _xres(width)
00050                 , _yres(height)
00051         {
00052                 _camera           = 0;
00053                 _grsc             = 0;
00054                 _object_model = 0;
00055         }
00056 
00057 private:
00058 
00059         struct Feature
00060         {
00061                 enum {NOT_TRACKED=0, IS_TRACKED} status2D;
00062                 enum {NONE=0, USE_FOR_POSE, IS_OUTLIER, IS_INITIAL} status3D;
00063 
00064                 Feature()
00065                 {
00066                         status3D = NONE;
00067                         status2D = NOT_TRACKED;
00068                 }
00069 
00070                 Feature(double vx, double vy)
00071                 {
00072                         point.x   = float(vx);
00073                         point.y   = float(vy);
00074                         status3D  = NONE;
00075                         status2D  = NOT_TRACKED;
00076                 }
00077          
00078                 ~Feature() {}
00079 
00080                 CvPoint2D32f point;
00081                 CvPoint3D64f point3d;
00082         };
00083 
00084         TrackerFeatures           _ft;
00085         std::map<int,Feature> _F_v;
00086 
00087         int                                       _xres;
00088         int                                       _yres;
00089         int                                       _image_scale;
00090         int                                       _outlier_limit;
00091         
00092         Pose                              _pose;
00093         IplImage                         *_grsc;
00094         Camera                           *_camera;
00095         CvMat                            *_object_model;
00096 
00097 public:
00098         void SetCamera(Camera *camera) {
00099                 _camera = camera;
00100         }
00101         void GetPose(Pose &pose);
00102         void GetPose(double gl_mat[16]) {
00103                 _pose.GetMatrixGL(gl_mat);
00104         }
00105         void Reset();
00106         double Track(IplImage *image);
00107 
00108 private:
00109         static void Project(CvMat* state, CvMat* projection, void *param);
00110         bool UpdatePose(IplImage* image=0);
00111         bool UpdateRotationOnly(IplImage *gray, IplImage *image=0);
00112 
00113 };
00114 
00115 } // namespace alvar
00116 
00117 #endif
00118 
00119 


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Sat Dec 28 2013 16:46:16