board.h
Go to the documentation of this file.
1 /*****************************
2 Copyright 2011 Rafael Muñoz Salinas. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without modification, are
5 permitted provided that the following conditions are met:
6 
7  1. Redistributions of source code must retain the above copyright notice, this list of
8  conditions and the following disclaimer.
9 
10  2. Redistributions in binary form must reproduce the above copyright notice, this list
11  of conditions and the following disclaimer in the documentation and/or other materials
12  provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED
15 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 
24 The views and conclusions contained in the software and documentation are those of the
25 authors and should not be interpreted as representing official policies, either expressed
26 or implied, of Rafael Muñoz Salinas.
27 ********************************/
28 #ifndef _Aruco_board_h
29 #define _Aruco_board_h
30 #include <opencv2/core/core.hpp>
31 #include <string>
32 #include <vector>
33 #include "exports.h"
34 #include "marker.h"
35 using namespace std;
36 namespace aruco {
40 struct ARUCO_EXPORTS MarkerInfo : public vector< cv::Point3f > {
42  MarkerInfo(int _id) { id = _id; }
43  MarkerInfo(const MarkerInfo &MI) : vector< cv::Point3f >(MI) { id = MI.id; }
45  vector< cv::Point3f >::operator=(MI);
46  id = MI.id;
47  return *this;
48  }
49  int id; // maker id
50 };
51 
69 class ARUCO_EXPORTS BoardConfiguration : public vector< MarkerInfo > {
70  friend class Board;
71 
72  public:
74  NONE = -1,
75  PIX = 0,
76  METERS = 1
77  }; // indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally
78  // variable indicates if the data in MakersInfo is expressed in meters or in pixels so as to do conversion internally
79  int mInfoType;
86  BoardConfiguration(string filePath) throw(cv::Exception);
87 
91 
94  BoardConfiguration &operator=(const BoardConfiguration &T);
97  void saveToFile(string sfile) throw(cv::Exception);
100  void readFromFile(string sfile) throw(cv::Exception);
103  bool isExpressedInMeters() const { return mInfoType == METERS; }
106  bool isExpressedInPixels() const { return mInfoType == PIX; }
109  int getIndexOfMarkerId(int id) const;
112  const MarkerInfo &getMarkerInfo(int id) const throw(cv::Exception);
115  void getIdList(vector< int > &ids, bool append = true) const;
116 
117  private:
120  void saveToFile(cv::FileStorage &fs) throw(cv::Exception);
123  void readFromFile(cv::FileStorage &fs) throw(cv::Exception);
124 };
125 
128 class ARUCO_EXPORTS Board : public vector< Marker > {
129 
130  public:
132  // matrices of rotation and translation respect to the camera
133  cv::Mat Rvec, Tvec;
136  Board() {
137  Rvec.create(3, 1, CV_32FC1);
138  Tvec.create(3, 1, CV_32FC1);
139  for (int i = 0; i < 3; i++)
140  Tvec.at< float >(i, 0) = Rvec.at< float >(i, 0) = -999999;
141  }
142 
146  void glGetModelViewMatrix(double modelview_matrix[16]) throw(cv::Exception);
147 
158  void OgreGetPoseParameters(double position[3], double orientation[4]) throw(cv::Exception);
159 
160 
163  void saveToFile(string filePath) throw(cv::Exception);
166  void readFromFile(string filePath) throw(cv::Exception);
167 
170  void draw(cv::Mat &im, cv::Scalar color, int lineWidth = 1, bool writeId = true);
171 };
172 }
173 
174 #endif
#define ARUCO_EXPORTS
Definition: exports.h:42
cv::Mat Tvec
Definition: board.h:133
MarkerInfo & operator=(const MarkerInfo &MI)
Definition: board.h:44
MarkerInfo(int _id)
Definition: board.h:42
BoardConfiguration conf
Definition: board.h:131
This class defines a board with several markers. A Board contains several markers so that they are mo...
Definition: board.h:69
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
bool isExpressedInPixels() const
Definition: board.h:106
bool isExpressedInMeters() const
Definition: board.h:103
MarkerInfo(const MarkerInfo &MI)
Definition: board.h:43


asr_aruco_marker_recognition
Author(s): Allgeyer Tobias, Meißner Pascal, Qattan Mohamad
autogenerated on Mon Jun 10 2019 12:40:21