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
00040 namespace alvar {
00041
00045 class ALVAR_EXPORT MultiMarker {
00046
00047
00048 private:
00049
00050 bool SaveXML(const char* fname);
00051 bool SaveText(const char* fname);
00052 bool LoadText(const char* fname);
00053 bool LoadXML(const char* fname);
00054
00055 public:
00056
00057
00058
00059
00060
00061 std::map<int, CvPoint3D64f> pointcloud;
00062 std::vector<int> marker_indices;
00063 std::vector<int> marker_status;
00064 std::vector< std::vector<btVector3> > rel_corners;
00065
00066 int pointcloud_index(int marker_id, int marker_corner, bool add_if_missing=false);
00067 int get_id_index(int id, bool add_if_missing=false);
00068
00069 double _GetPose(MarkerIterator &begin, MarkerIterator &end, Camera* cam, Pose& pose, IplImage* image);
00070
00071 int _SetTrackMarkers(MarkerDetectorImpl &marker_detector, Camera* cam, Pose& pose, IplImage *image);
00072 int master_id;
00073
00074
00076 virtual void Reset();
00077
00082 bool Save(const char* fname, FILE_FORMAT format = FILE_FORMAT_DEFAULT);
00083
00088 bool Load(const char* fname, FILE_FORMAT format = FILE_FORMAT_DEFAULT);
00089
00093 MultiMarker(std::vector<int>& indices);
00094
00096 MultiMarker() {}
00097
00106 template <class M>
00107 double GetPose(const std::vector<M>* markers, Camera* cam, Pose& pose, IplImage* image = 0)
00108 {
00109 MarkerIteratorImpl<M> begin(markers->begin());
00110 MarkerIteratorImpl<M> end(markers->end());
00111 return _GetPose(begin, end,
00112 cam, pose, image);
00113 }
00114
00117 template <class M>
00118 double Update(const std::vector<M>* markers, Camera* cam, Pose& pose, IplImage* image = 0)
00119 {
00120 if(markers->size() < 1) return -1.0;
00121
00122 return GetPose(markers, cam, pose, image);
00123 }
00124
00127 void PointCloudReset();
00128
00135 void PointCloudCorners3d(double edge_length, Pose &pose, CvPoint3D64f corners[4]);
00136
00142 void PointCloudAdd(int marker_id, double edge_length, Pose &pose);
00143
00146 void PointCloudCopy(const MultiMarker *m);
00147
00150 bool PointCloudIsEmpty() {
00151 return pointcloud.empty();
00152 }
00153
00155 size_t Size() {
00156 return marker_indices.size();
00157 }
00158
00166 void PointCloudGet(int marker_id, int point,
00167 double &x, double &y, double &z);
00168
00172 bool IsValidMarker(int marker_id);
00173
00174 std::vector<int> getIndices(){
00175 return marker_indices;
00176 }
00177
00178 int getMasterId(){
00179 return master_id;
00180 }
00181
00188 template <class M>
00189 int SetTrackMarkers(MarkerDetector<M> &marker_detector, Camera* cam, Pose& pose, IplImage *image=0) {
00190 return _SetTrackMarkers(marker_detector, cam, pose, image);
00191 }
00192 };
00193
00194 }
00195
00196 #endif