TrackAruco.h
Go to the documentation of this file.
1 /*
2  * OpenVINS: An Open Platform for Visual-Inertial Research
3  * Copyright (C) 2018-2023 Patrick Geneva
4  * Copyright (C) 2018-2023 Guoquan Huang
5  * Copyright (C) 2018-2023 OpenVINS Contributors
6  * Copyright (C) 2018-2019 Kevin Eckenhoff
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef OV_CORE_TRACK_ARUCO_H
23 #define OV_CORE_TRACK_ARUCO_H
24 
25 #if ENABLE_ARUCO_TAGS
26 #include <opencv2/aruco.hpp>
27 #endif
28 
29 #include "TrackBase.h"
30 
31 namespace ov_core {
32 
43 class TrackAruco : public TrackBase {
44 
45 public:
54  explicit TrackAruco(std::unordered_map<size_t, std::shared_ptr<CamBase>> cameras, int numaruco, bool stereo, HistogramMethod histmethod,
55  bool downsize)
56  : TrackBase(cameras, 0, numaruco, stereo, histmethod), max_tag_id(numaruco), do_downsizing(downsize) {
57 #if ENABLE_ARUCO_TAGS
58 #if CV_MAJOR_VERSION > 4 || ( CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION >= 7)
59  aruco_dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_1000);
60  aruco_params.cornerRefinementMethod = cv::aruco::CORNER_REFINE_SUBPIX;
61  aruco_detector = cv::aruco::ArucoDetector(aruco_dict, aruco_params);
62 #else
63  aruco_dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_1000);
64  aruco_params = cv::aruco::DetectorParameters::create();
65  // NOTE: people with newer opencv might fail here
66  // aruco_params->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_SUBPIX;
67 #endif
68 #else
69  PRINT_ERROR(RED "[ERROR]: you have not compiled with aruco tag support!!!\n" RESET);
70  std::exit(EXIT_FAILURE);
71 #endif
72  }
73 
78  void feed_new_camera(const CameraData &message) override;
79 
80 #if ENABLE_ARUCO_TAGS
81 
88  void display_active(cv::Mat &img_out, int r1, int g1, int b1, int r2, int g2, int b2, std::string overlay = "") override;
89 #endif
90 
91 protected:
92 #if ENABLE_ARUCO_TAGS
93 
100  void perform_tracking(double timestamp, const cv::Mat &imgin, size_t cam_id, const cv::Mat &maskin);
101 #endif
102 
103  // Max tag ID we should extract from (i.e., number of aruco tags starting from zero)
105 
106  // If we should downsize the image
108 
109 #if ENABLE_ARUCO_TAGS
110 #if CV_MAJOR_VERSION > 4 || ( CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION >= 7)
111  // Our dictionary that we will extract aruco tags with
112  cv::aruco::Dictionary aruco_dict;
113  // Parameters the opencv extractor uses
114  cv::aruco::DetectorParameters aruco_params;
115  // Actual detector class
116  cv::aruco::ArucoDetector aruco_detector;
117 #else
118  // Our dictionary that we will extract aruco tags with
119  cv::Ptr<cv::aruco::Dictionary> aruco_dict;
120  // Parameters the opencv extractor uses
121  cv::Ptr<cv::aruco::DetectorParameters> aruco_params;
122 #endif
123 
124 
125  // Our tag IDs and corner we will get from the extractor
126  std::unordered_map<size_t, std::vector<int>> ids_aruco;
127  std::unordered_map<size_t, std::vector<std::vector<cv::Point2f>>> corners, rejects;
128 #endif
129 };
130 
131 } // namespace ov_core
132 
133 #endif /* OV_CORE_TRACK_ARUCO_H */
ov_core::TrackAruco::do_downsizing
bool do_downsizing
Definition: TrackAruco.h:107
ov_core::TrackBase::HistogramMethod
HistogramMethod
Desired pre-processing image method.
Definition: TrackBase.h:78
ov_core::TrackAruco
Tracking of OpenCV Aruoc tags.
Definition: TrackAruco.h:43
ov_core::TrackAruco::feed_new_camera
void feed_new_camera(const CameraData &message) override
Process a new image.
Definition: TrackAruco.cpp:31
TrackBase.h
ov_core::CameraData
Struct for a collection of camera measurements.
Definition: sensor_data.h:55
ov_core::TrackAruco::TrackAruco
TrackAruco(std::unordered_map< size_t, std::shared_ptr< CamBase >> cameras, int numaruco, bool stereo, HistogramMethod histmethod, bool downsize)
Public constructor with configuration variables.
Definition: TrackAruco.h:54
PRINT_ERROR
#define PRINT_ERROR(x...)
Definition: print.h:100
ov_core::TrackAruco::max_tag_id
int max_tag_id
Definition: TrackAruco.h:104
ov_core::TrackBase::display_active
virtual void display_active(cv::Mat &img_out, int r1, int g1, int b1, int r2, int g2, int b2, std::string overlay="")
Shows features extracted in the last image.
Definition: TrackBase.cpp:43
RED
#define RED
Definition: colors.h:27
RESET
#define RESET
Definition: colors.h:25
ov_core
Core algorithms for OpenVINS.
Definition: CamBase.h:30
ov_core::TrackBase
Visual feature tracking base class.
Definition: TrackBase.h:72


ov_core
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Mon Dec 16 2024 03:06:46