marker.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_Marker_H
29 #define _Aruco_Marker_H
30 #include <vector>
31 #include <iostream>
32 #include <opencv2/opencv.hpp>
33 #include <aruco/exports.h>
34 #include <aruco/cameraparameters.h>
35 using namespace std;
36 namespace aruco {
41 class ARUCO_EXPORTS Marker: public std::vector<cv::Point2f>
42 {
43 public:
44  //id of the marker
45  int id;
46  //size of the markers sides in meters
47  float ssize;
48  //matrices of rotation and translation respect to the camera
49  cv::Mat Rvec,Tvec;
50 
53  Marker();
56  Marker(const Marker &M);
59  Marker(const std::vector<cv::Point2f> &corners,int _id=-1);
62  ~Marker() {}
65  bool isValid()const{return id!=-1 && size()==4;}
66 
69  void draw(cv::Mat &in, cv::Scalar color, int lineWidth=1,bool writeId=true)const;
70 
76  void calculateExtrinsics(float markerSize, const CameraParameters &CP, bool setYPerpendicular=true)throw(cv::Exception);
83  void calculateExtrinsics(float markerSize, cv::Mat CameraMatrix, cv::Mat Distorsion=cv::Mat(), bool setYPerpendicular=true)throw(cv::Exception);
84 
88  void glGetModelViewMatrix( double modelview_matrix[16])throw(cv::Exception);
89 
100  void OgreGetPoseParameters( double position[3], double orientation[4] )throw(cv::Exception);
101 
104  cv::Point2f getCenter()const;
107  float getPerimeter()const;
110  float getArea()const;
115  friend bool operator<(const Marker &M1,const Marker&M2)
116  {
117  return M1.id<M2.id;
118  }
121  friend ostream & operator<<(ostream &str,const Marker &M)
122  {
123  str<<M.id<<"=";
124  for (int i=0;i<4;i++)
125  str<<"("<<M[i].x<< ","<<M[i].y<<") ";
126  str<<"Txyz=";
127  for (int i=0;i<3;i++)
128  str<<M.Tvec.ptr<float>(0)[i]<<" ";
129  str<<"Rxyz=";
130  for (int i=0;i<3;i++)
131  str<<M.Rvec.ptr<float>(0)[i]<<" ";
132 
133  return str;
134  }
135 
136 
137 private:
138  void rotateXAxis(cv::Mat &rotation);
139 
140 };
141 
142 }
143 #endif
#define ARUCO_EXPORTS
Definition: exports.h:42
friend ostream & operator<<(ostream &str, const Marker &M)
Definition: marker.h:121
bool isValid() const
Definition: marker.h:65
cv::Mat Rvec
Definition: marker.h:49
This class represents a marker. It is a vector of the fours corners ot the marker.
Definition: marker.h:41
Parameters of the camera.
float ssize
Definition: marker.h:47
cv::Mat Tvec
Definition: marker.h:49
friend bool operator<(const Marker &M1, const Marker &M2)
Definition: marker.h:115


aruco
Author(s): Rafael Muñoz Salinas , Bence Magyar
autogenerated on Wed Sep 2 2020 04:02:09