SfM.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 SFM_H
00025 #define SFM_H
00026 
00033 #include "EC.h"
00034 
00035 namespace alvar {
00036 
00041 class ALVAR_EXPORT SimpleSfM {
00042 public:
00044         class Feature : public ExternalContainer {
00045         public:
00046                 bool has_stored_pose;
00047                 Pose pose1;
00048                 CvPoint2D32f p2d1;
00049                 CvPoint3D32f p3d_sh;
00050                 CvPoint2D32f projected_p2d_sh;
00051                 int tri_cntr;        // This is needed only by UpdateTriangulateOnly
00052                 int estimation_type;
00053 
00054                 Feature() : ExternalContainer() {
00055                         has_stored_pose = false;
00056                         p3d_sh.x = 0.f; p3d_sh.y = 0.f; p3d_sh.z = 0.f;
00057                         tri_cntr = 0;
00058                         estimation_type = 0;
00059                 }
00060                 Feature(const Feature &c) : ExternalContainer(c) {
00061                         has_stored_pose = c.has_stored_pose;
00062                         pose1 = c.pose1;
00063                         p2d1 = c.p2d1;
00064                         p3d_sh = c.p3d_sh;
00065                         projected_p2d_sh = c.projected_p2d_sh;
00066                         tri_cntr = c.tri_cntr;
00067                         estimation_type = c.estimation_type;
00068                 }
00069         };
00071         std::map<int, Feature> container;
00072         std::map<int, Feature> container_triangulated;
00073 
00074 protected:
00075         std::map<int, Feature> container_reset_point;
00076         std::map<int, Feature> container_triangulated_reset_point;
00077 
00078         CameraEC cam;
00079         MarkerDetectorEC<MarkerData> marker_detector; 
00080         TrackerFeaturesEC tf;
00081         Pose pose;
00082         bool pose_ok;
00083 
00084         bool update_tri;
00085         std::string multi_marker_file;
00086         bool markers_found;
00087         double scale;
00088         Pose pose_original;
00089         Pose pose_difference;
00090 
00091 public:
00093         SimpleSfM() : tf(200, 200, 0.01, 20, 4, 6), pose_ok(false), update_tri(false), markers_found(false) {}
00095         void Reset(bool reset_also_triangulated = true);
00097         void SetResetPoint();
00099         void Clear();
00101         void SetScale(double s) { scale = s; }
00103         CameraEC *GetCamera();
00105         Pose *GetPose();
00107         bool AddMultiMarker(const char *fname, FILE_FORMAT format = FILE_FORMAT_XML);
00109         bool AddMultiMarker(MultiMarkerEC *mm);
00111         void AddMarker(int marker_id, double edge_length, Pose &pose);
00113         bool Update(IplImage *image, bool assume_plane=true, bool triangulate=true, float reproj_err_limit=5.f, float triangulate_angle=15.f);
00115         bool UpdateTriangulateOnly(IplImage *image);
00117         bool UpdateRotationsOnly(IplImage *image);
00119         void Draw(IplImage *rgba);
00120 };
00121 
00122 }
00123 #endif


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Sun Oct 5 2014 22:16:26