Visual Servoing Platform  version 3.1.0
vpDetectorAprilTag.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Base class for April Tag detection.
33  *
34  *****************************************************************************/
35 #ifndef __vpDetectorAprilTag_h__
36 #define __vpDetectorAprilTag_h__
37 
38 #include <visp3/core/vpConfig.h>
39 
40 #ifdef VISP_HAVE_APRILTAG
41 #include <visp3/core/vpCameraParameters.h>
42 #include <visp3/core/vpHomogeneousMatrix.h>
43 #include <visp3/core/vpImage.h>
44 #include <visp3/detection/vpDetectorBase.h>
45 
155 class VISP_EXPORT vpDetectorAprilTag : public vpDetectorBase
156 {
157 
158 public:
160  TAG_36h11,
163  TAG_36h10,
166  TAG_36ARTOOLKIT,
168  TAG_25h9,
171  TAG_25h7,
174  TAG_16h5
177  };
178 
180  HOMOGRAPHY_VIRTUAL_VS,
182  DEMENTHON_VIRTUAL_VS,
184  LAGRANGE_VIRTUAL_VS,
186  BEST_RESIDUAL_VIRTUAL_VS
189  };
190 
191  vpDetectorAprilTag(const vpAprilTagFamily &tagFamily = TAG_36h11,
192  const vpPoseEstimationMethod &poseEstimationMethod = HOMOGRAPHY_VIRTUAL_VS);
193  virtual ~vpDetectorAprilTag();
194 
195  bool detect(const vpImage<unsigned char> &I);
196  bool detect(const vpImage<unsigned char> &I, const double tagSize, const vpCameraParameters &cam,
197  std::vector<vpHomogeneousMatrix> &cMo_vec);
198 
202  inline vpPoseEstimationMethod getPoseEstimationMethod() const { return m_poseEstimationMethod; }
203 
204  void setAprilTagNbThreads(const int nThreads);
205  void setAprilTagPoseEstimationMethod(const vpPoseEstimationMethod &poseEstimationMethod);
206  void setAprilTagQuadDecimate(const float quadDecimate);
207  void setAprilTagQuadSigma(const float quadSigma);
208  void setAprilTagRefineDecode(const bool refineDecode);
209  void setAprilTagRefineEdges(const bool refineEdges);
210  void setAprilTagRefinePose(const bool refinePose);
211 
214  inline void setDisplayTag(const bool display) { m_displayTag = display; }
215 
216 protected:
220 
221 private:
222  vpDetectorAprilTag(const vpDetectorAprilTag &); // noncopyable
223  vpDetectorAprilTag &operator=(const vpDetectorAprilTag &); //
224 
225  // PIMPL idiom
226  class Impl;
227  Impl *m_impl;
228 };
229 
230 inline std::ostream &operator<<(std::ostream &os, const vpDetectorAprilTag::vpPoseEstimationMethod &method)
231 {
232  switch (method) {
234  os << "HOMOGRAPHY_VIRTUAL_VS";
235  break;
236 
238  os << "DEMENTHON_VIRTUAL_VS";
239  break;
240 
242  os << "LAGRANGE_VIRTUAL_VS";
243  break;
244 
246  os << "BEST_RESIDUAL_VIRTUAL_VS";
247  break;
248 
249  default:
250  break;
251  }
252 
253  return os;
254 }
255 
256 inline std::ostream &operator<<(std::ostream &os, const vpDetectorAprilTag::vpAprilTagFamily &tagFamily)
257 {
258  switch (tagFamily) {
260  os << "36h11";
261  break;
262 
264  os << "36h10";
265  break;
266 
268  os << "36artoolkit";
269  break;
270 
272  os << "25h9";
273  break;
274 
276  os << "25h7";
277  break;
278 
280  os << "16h5";
281  break;
282 
283  default:
284  break;
285  }
286 
287  return os;
288 }
289 
290 #endif
291 #endif
vpPoseEstimationMethod getPoseEstimationMethod() const
virtual bool detect(const vpImage< unsigned char > &I)=0
Generic class defining intrinsic camera parameters.
vpPoseEstimationMethod m_poseEstimationMethod
void setDisplayTag(const bool display)
vpAprilTagFamily m_tagFamily