MarkerDetector.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2019, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef CORELIB_INCLUDE_RTABMAP_CORE_MARKERDETECTOR_H_
29 #define CORELIB_INCLUDE_RTABMAP_CORE_MARKERDETECTOR_H_
30 
33 #include <opencv2/opencv_modules.hpp>
34 
35 #ifdef HAVE_OPENCV_ARUCO
36 #include <opencv2/aruco.hpp>
37 #endif
38 
39 namespace rtabmap {
40 
41 typedef std::map<int, Transform> MapIdPose;
42 
43 class MarkerInfo {
44 public:
45  MarkerInfo(int id, float length, Transform pose) :
46  id_(id),
47  length_(length),
48  pose_(pose)
49  {}
50  int id() const {return id_;}
51  float length() const {return length_;}
52  const Transform & pose() const {return pose_;}
53 private:
54  int id_;
55  float length_;
57 };
58 
59 class RTABMAP_CORE_EXPORT MarkerDetector {
60 
61 public:
62  MarkerDetector(const ParametersMap & parameters = ParametersMap());
63  virtual ~MarkerDetector();
64  void parseParameters(const ParametersMap & parameters);
65 
66  // Use the other detect(), in which the returned map contains the length of each marker detected.
68  MapIdPose detect(const cv::Mat & image,
69  const CameraModel & model,
70  const cv::Mat & depth = cv::Mat(),
71  float * estimatedMarkerLength = 0,
72  cv::Mat * imageWithDetections = 0);
73 
74  std::map<int, MarkerInfo> detect(const cv::Mat & image,
75  const std::vector<CameraModel> & models,
76  const cv::Mat & depth = cv::Mat(),
77  const std::map<int, float> & markerLengths = std::map<int, float>(),
78  cv::Mat * imageWithDetections = 0);
79 
80  std::map<int, MarkerInfo> detect(const cv::Mat & image,
81  const CameraModel & model,
82  const cv::Mat & depth = cv::Mat(),
83  const std::map<int, float> & markerLengths = std::map<int, float>(),
84  cv::Mat * imageWithDetections = 0);
85 
86 private:
87 #ifdef HAVE_OPENCV_ARUCO
88  cv::Ptr<cv::aruco::DetectorParameters> detectorParams_;
89  float markerLength_;
90  float maxDepthError_;
91  float maxRange_;
92  float minRange_;
93  int dictionaryId_;
94  cv::Ptr<cv::aruco::Dictionary> dictionary_;
95 #endif
96 };
97 
98 } /* namespace rtabmap */
99 
100 #endif /* CORELIB_INCLUDE_RTABMAP_CORE_MARKERDETECTOR_H_ */
rtabmap::CameraModel
Definition: CameraModel.h:38
rtabmap::MarkerInfo
Definition: MarkerDetector.h:43
rtabmap::RTABMAP_DEPRECATED
RTABMAP_DEPRECATED(typedef SensorData Image, "rtabmap::Image class is renamed to rtabmap::SensorData, use the last one instead.")
rtabmap::ParametersMap
std::map< std::string, std::string > ParametersMap
Definition: Parameters.h:43
rtabmap::MarkerInfo::MarkerInfo
MarkerInfo(int id, float length, Transform pose)
Definition: MarkerDetector.h:45
rtabmap::MapIdPose
std::map< int, Transform > MapIdPose
Definition: MarkerDetector.h:41
Parameters.h
rtabmap::MarkerInfo::id
int id() const
Definition: MarkerDetector.h:50
rtabmap_superpoint.detect
def detect(imageBuffer)
Definition: rtabmap_superpoint.py:38
rtabmap::MarkerInfo::pose
const Transform & pose() const
Definition: MarkerDetector.h:52
rtabmap::MarkerDetector
Definition: MarkerDetector.h:59
rtabmap::MarkerInfo::id_
int id_
Definition: MarkerDetector.h:54
rtabmap::Transform
Definition: Transform.h:41
rtabmap::MarkerInfo::pose_
Transform pose_
Definition: MarkerDetector.h:56
rtabmap::MarkerInfo::length
float length() const
Definition: MarkerDetector.h:51
rtabmap::MarkerInfo::length_
float length_
Definition: MarkerDetector.h:55
CameraModel.h
rtabmap
Definition: CameraARCore.cpp:35
trace.model
model
Definition: trace.py:4


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:12