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 MULTIMARKER_H
00025 #define MULTIMARKER_H
00026
00033 #include "Alvar.h"
00034 #include "Rotation.h"
00035 #include "MarkerDetector.h"
00036 #include "Camera.h"
00037 #include "Filter.h"
00038 #include "FileFormat.h"
00039 #include <tf/LinearMath/Vector3.h>
00040 #include <Eigen/StdVector>
00041
00042 namespace alvar {
00043
00047 class ALVAR_EXPORT MultiMarker {
00048
00049
00050 private:
00051
00052 bool SaveXML(const char* fname);
00053 bool SaveText(const char* fname);
00054 bool LoadText(const char* fname);
00055 bool LoadXML(const char* fname);
00056
00057 public:
00058
00059
00060
00061
00062
00063 std::map<int, CvPoint3D64f> pointcloud;
00064 std::vector<int> marker_indices;
00065 std::vector<int> marker_status;
00066 std::vector< std::vector<tf::Vector3> > rel_corners;
00067
00068 int pointcloud_index(int marker_id, int marker_corner, bool add_if_missing=false);
00069 int get_id_index(int id, bool add_if_missing=false);
00070
00071 double _GetPose(MarkerIterator &begin, MarkerIterator &end, Camera* cam, Pose& pose, IplImage* image);
00072
00073 int _SetTrackMarkers(MarkerDetectorImpl &marker_detector, Camera* cam, Pose& pose, IplImage *image);
00074 int master_id;
00075
00076
00078 virtual void Reset();
00079
00084 bool Save(const char* fname, FILE_FORMAT format = FILE_FORMAT_DEFAULT);
00085
00090 bool Load(const char* fname, FILE_FORMAT format = FILE_FORMAT_DEFAULT);
00091
00095 MultiMarker(std::vector<int>& indices);
00096
00098 MultiMarker() {}
00099
00108 template <class M>
00109 double GetPose(const std::vector<M, Eigen::aligned_allocator<M> >* markers, Camera* cam, Pose& pose, IplImage* image = 0)
00110 {
00111 MarkerIteratorImpl<M> begin(markers->begin());
00112 MarkerIteratorImpl<M> end(markers->end());
00113 return _GetPose(begin, end,
00114 cam, pose, image);
00115 }
00116
00119 template <class M>
00120 double Update(const std::vector<M, Eigen::aligned_allocator<M> >* markers, Camera* cam, Pose& pose, IplImage* image = 0)
00121 {
00122 if(markers->size() < 1) return -1.0;
00123
00124 return GetPose(markers, cam, pose, image);
00125 }
00126
00129 void PointCloudReset();
00130
00137 void PointCloudCorners3d(double edge_length, Pose &pose, CvPoint3D64f corners[4]);
00138
00144 void PointCloudAdd(int marker_id, double edge_length, Pose &pose);
00145
00148 void PointCloudCopy(const MultiMarker *m);
00149
00152 bool PointCloudIsEmpty() {
00153 return pointcloud.empty();
00154 }
00155
00157 size_t Size() {
00158 return marker_indices.size();
00159 }
00160
00168 void PointCloudGet(int marker_id, int point,
00169 double &x, double &y, double &z);
00170
00174 bool IsValidMarker(int marker_id);
00175
00176 std::vector<int> getIndices(){
00177 return marker_indices;
00178 }
00179
00180 int getMasterId(){
00181 return master_id;
00182 }
00183
00190 template <class M>
00191 int SetTrackMarkers(MarkerDetector<M> &marker_detector, Camera* cam, Pose& pose, IplImage *image=0) {
00192 return _SetTrackMarkers(marker_detector, cam, pose, image);
00193 }
00194 };
00195
00196 }
00197
00198 #endif