Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLMarkers/src/ICLMarkers/Fiducial.h ** 00010 ** Module : ICLMarkers ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLUtils/CompatMacros.h> 00034 #include <ICLUtils/Point32f.h> 00035 #include <ICLGeom/GeomDefs.h> 00036 #include <ICLCV/ImageRegion.h> 00037 00038 #include <bitset> 00039 00040 namespace icl{ 00041 namespace markers{ 00042 00044 struct FiducialImpl; 00045 struct FiducialDetectorPlugin; 00049 00050 00056 class ICLMarkers_API Fiducial{ 00058 FiducialImpl *impl; 00059 00060 public: 00061 00062 00064 00065 enum Feature{ 00066 Center2D, 00067 Rotation2D, 00068 Corners2D, 00069 KeyPoints2D, 00070 ImageRegion, 00071 Center3D, 00072 Rotation3D, 00073 Pose3D, 00074 FeatureCount 00075 }; 00076 00078 00080 typedef std::bitset<(int)FeatureCount> FeatureSet; 00081 00083 static const FeatureSet AllFeatures; 00084 00086 00092 struct KeyPoint{ 00094 inline KeyPoint(){} 00095 00097 inline KeyPoint(const utils::Point32f &imagePos, const utils::Point32f &markerPos, int ID): 00098 imagePos(imagePos),markerPos(markerPos),ID(ID){} 00099 00100 utils::Point32f imagePos; 00101 utils::Point32f markerPos; 00102 int ID; 00103 }; 00104 00106 inline Fiducial(FiducialImpl *impl=0):impl(impl){} 00107 00109 int getID() const; 00110 00112 std::string getName() const; 00113 00115 bool supports(Feature f) const; 00116 00118 const utils::Point32f &getCenter2D() const; 00119 00121 const float &getRotation2D() const; 00122 00124 const std::vector<utils::Point32f> &getCorners2D() const; 00125 00127 const std::vector<KeyPoint> &getKeyPoints2D() const; 00128 00130 const cv::ImageRegion getImageRegion() const; 00131 00133 const geom::Vec &getCenter3D() const; 00134 00136 const geom::Vec &getRotation3D() const; 00137 00139 const geom::Mat &getPose3D() const; 00140 00142 inline operator bool() const { return impl; } 00143 00145 inline bool operator!() const { return isNull(); } 00146 00148 inline bool isNull() const { return !impl; } 00149 00151 inline bool operator==(const Fiducial &a) const { return impl == a.impl; } 00152 00154 inline bool operator!=(const Fiducial &a) const{ return impl != a.impl; } 00155 00157 inline FiducialImpl *getImpl() { return impl; } 00158 00160 inline const FiducialImpl *getImpl() const { return impl; } 00161 00163 FiducialDetectorPlugin *getDetector(); 00164 00166 const FiducialDetectorPlugin *getDetector() const; 00167 }; 00168 00169 00171 inline Fiducial::FeatureSet operator|(Fiducial::FeatureSet s, Fiducial::Feature f){ 00172 s.set(f); return s; 00173 } 00174 00176 inline Fiducial::FeatureSet operator|(Fiducial::Feature f, Fiducial::FeatureSet s){ 00177 return s|f; 00178 } 00179 00181 inline Fiducial::FeatureSet operator|(Fiducial::Feature f1, Fiducial::Feature f2){ 00182 Fiducial::FeatureSet s; s.reset(); s.set(f1); s.set(f2); return s; 00183 } 00184 } // namespace markers 00185 } 00186