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/core/core.hpp>
33 #include "exports.h"
34 #include "cameraparameters.h"
35 using namespace std;
36 namespace aruco {
41 class ARUCO_EXPORTS Marker : public std::vector< cv::Point2f > {
42  public:
43  // id of the marker
44  int id;
45  // size of the markers sides in meters
46  float ssize;
47  // matrices of rotation and translation respect to the camera
48  cv::Mat Rvec, Tvec;
49 
52  Marker();
55  Marker(const Marker &M);
58  Marker(const std::vector< cv::Point2f > &corners, int _id = -1);
61  ~Marker() {}
64  bool isValid() const { return id != -1 && size() == 4; }
65 
68  void draw(cv::Mat &in, cv::Scalar color, int lineWidth = 1, bool writeId = true) const;
69 
75  void calculateExtrinsics(float markerSize, const CameraParameters &CP, bool setYPerpendicular = true) throw(cv::Exception);
82  void calculateExtrinsics(float markerSize, cv::Mat CameraMatrix, cv::Mat Distorsion = cv::Mat(), bool setYPerpendicular = true) throw(cv::Exception);
83 
87  void glGetModelViewMatrix(double modelview_matrix[16]) throw(cv::Exception);
88 
99  void OgreGetPoseParameters(double position[3], double orientation[4]) throw(cv::Exception);
100 
103  cv::Point2f getCenter() const;
106  float getPerimeter() const;
109  float getArea() const;
114  friend bool operator<(const Marker &M1, const Marker &M2) { return M1.id < M2.id; }
117  friend ostream &operator<<(ostream &str, const Marker &M) {
118  str << M.id << "=";
119  for (int i = 0; i < 4; i++)
120  str << "(" << M[i].x << "," << M[i].y << ") ";
121  str << "Txyz=";
122  for (int i = 0; i < 3; i++)
123  str << M.Tvec.ptr< float >(0)[i] << " ";
124  str << "Rxyz=";
125  for (int i = 0; i < 3; i++)
126  str << M.Rvec.ptr< float >(0)[i] << " ";
127 
128  return str;
129  }
130 
131 
132  private:
133  void rotateXAxis(cv::Mat &rotation);
134 };
135 }
136 #endif
#define ARUCO_EXPORTS
Definition: exports.h:42
friend ostream & operator<<(ostream &str, const Marker &M)
Definition: marker.h:117
bool isValid() const
Definition: marker.h:64
cv::Mat Rvec
Definition: marker.h:48
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:46
cv::Mat Tvec
Definition: marker.h:48
friend bool operator<(const Marker &M1, const Marker &M2)
Definition: marker.h:114


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