RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
MarkerDetector.h
1/*
2Copyright (c) 2010-2019, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, 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
31#include <rtabmap/core/Parameters.h>
32#include <rtabmap/core/CameraModel.h>
33#include <opencv2/opencv_modules.hpp>
34
35#if (CV_MAJOR_VERSION > 4 || (CV_MAJOR_VERSION==4 && CV_MINOR_VERSION >=7)) && defined(HAVE_OPENCV_OBJDETECT)
36#include <opencv2/objdetect.hpp>
37#elif defined(HAVE_OPENCV_ARUCO)
38#include <opencv2/aruco.hpp>
39#endif
40
41namespace rtabmap {
42
44public:
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_;}
53private:
54 int id_;
55 float length_;
56 Transform pose_;
57};
58
59class RTABMAP_CORE_EXPORT MarkerDetector {
60
61public:
62 enum Strategy {
63 kStrategyOpencv,
64 kStrategyApriltag
65 };
66
67public:
68 MarkerDetector(const ParametersMap & parameters = ParametersMap());
69 virtual ~MarkerDetector();
70 void parseParameters(const ParametersMap & parameters);
71
72 std::map<int, MarkerInfo> detect(const cv::Mat & image,
73 const std::vector<CameraModel> & models,
74 const cv::Mat & depth = cv::Mat(),
75 const std::map<int, float> & markerLengths = std::map<int, float>(),
76 cv::Mat * imageWithDetections = 0);
77
78 std::map<int, MarkerInfo> detect(const cv::Mat & image,
79 const CameraModel & model,
80 const cv::Mat & depth = cv::Mat(),
81 const std::map<int, float> & markerLengths = std::map<int, float>(),
82 cv::Mat * imageWithDetections = 0);
83
84private:
85 Strategy strategy_;
86 float markerLength_;
87 std::map<int, float> markerLengths_;
88 float maxDepthError_;
89 float maxRange_;
90 float minRange_;
91 int dictionaryId_;
92#if ((CV_MAJOR_VERSION > 4 || (CV_MAJOR_VERSION==4 && CV_MINOR_VERSION >=7)) && defined(HAVE_OPENCV_OBJDETECT)) || defined(HAVE_OPENCV_ARUCO)
93#if CV_MAJOR_VERSION > 4 || (CV_MAJOR_VERSION==4 && CV_MINOR_VERSION >=7)
94 cv::Ptr<cv::aruco::ArucoDetector> arucoDetector_;
95#endif
96 cv::Ptr<cv::aruco::DetectorParameters> detectorParams_;
97 cv::Ptr<cv::aruco::Dictionary> dictionary_;
98#endif
99 void * apriltagLibDetector_;
100 void * apriltagLibFamily_;
101};
102
103} /* namespace rtabmap */
104
105#endif /* CORELIB_INCLUDE_RTABMAP_CORE_MARKERDETECTOR_H_ */
Represents a pinhole camera model containing intrinsic and extrinsic parameters, used for projection,...
Definition CameraModel.h:53
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44