Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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;
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