marker.h
Go to the documentation of this file.
00001 /*****************************
00002 Copyright 2011 Rafael Muñoz Salinas. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without modification, are
00005 permitted provided that the following conditions are met:
00006 
00007    1. Redistributions of source code must retain the above copyright notice, this list of
00008       conditions and the following disclaimer.
00009 
00010    2. Redistributions in binary form must reproduce the above copyright notice, this list
00011       of conditions and the following disclaimer in the documentation and/or other materials
00012       provided with the distribution.
00013 
00014 THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED
00015 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00016 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR
00017 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00018 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00019 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00020 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00021 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00022 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00023 
00024 The views and conclusions contained in the software and documentation are those of the
00025 authors and should not be interpreted as representing official policies, either expressed
00026 or implied, of Rafael Muñoz Salinas.
00027 ********************************/
00028 #ifndef _Aruco_Marker_H
00029 #define _Aruco_Marker_H
00030 #include <vector>
00031 #include <iostream>
00032 #include <opencv2/opencv.hpp>
00033 #include <aruco/exports.h>
00034 #include <aruco/cameraparameters.h>
00035 using namespace std;
00036 namespace aruco {
00041 class  ARUCO_EXPORTS Marker: public std::vector<cv::Point2f>
00042 {
00043 public:
00044     //id of  the marker
00045     int id;
00046     //size of the markers sides in meters
00047     float ssize;
00048     //matrices of rotation and translation respect to the camera
00049     cv::Mat Rvec,Tvec;
00050 
00053     Marker();
00056     Marker(const Marker &M);
00059     Marker(const  std::vector<cv::Point2f> &corners,int _id=-1);
00062     ~Marker() {}
00065     bool isValid()const{return id!=-1 && size()==4;}
00066 
00069     void draw(cv::Mat &in, cv::Scalar color, int lineWidth=1,bool writeId=true)const;
00070 
00076     void calculateExtrinsics(float markerSize, const CameraParameters &CP, bool setYPerpendicular=true)throw(cv::Exception);
00083     void calculateExtrinsics(float markerSize, cv::Mat  CameraMatrix, cv::Mat Distorsion=cv::Mat(), bool setYPerpendicular=true)throw(cv::Exception);
00084     
00088     void glGetModelViewMatrix(  double modelview_matrix[16])throw(cv::Exception);
00089     
00100     void OgreGetPoseParameters(  double position[3], double orientation[4] )throw(cv::Exception);    
00101     
00104     cv::Point2f getCenter()const;
00107     float getPerimeter()const;
00110     float getArea()const;
00115     friend bool operator<(const Marker &M1,const Marker&M2)
00116     {
00117         return M1.id<M2.id;
00118     }
00121     friend ostream & operator<<(ostream &str,const Marker &M)
00122     {
00123         str<<M.id<<"=";
00124         for (int i=0;i<4;i++)
00125             str<<"("<<M[i].x<< ","<<M[i].y<<") ";
00126         str<<"Txyz=";
00127         for (int i=0;i<3;i++)
00128             str<<M.Tvec.ptr<float>(0)[i]<<" ";
00129         str<<"Rxyz=";
00130         for (int i=0;i<3;i++)
00131             str<<M.Rvec.ptr<float>(0)[i]<<" ";
00132 
00133         return str;
00134     }
00135     
00136  
00137 private:
00138   void rotateXAxis(cv::Mat &rotation);
00139  
00140 };
00141 
00142 }
00143 #endif


aruco
Author(s): Rafael Muñoz Salinas , Bence Magyar
autogenerated on Thu Jun 6 2019 17:52:15