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  aruco_dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_1000);
59  aruco_params = cv::aruco::DetectorParameters::create();
60  // NOTE: people with newer opencv might fail here
61  // aruco_params->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_SUBPIX;
62 #else
63  PRINT_ERROR(RED "[ERROR]: you have not compiled with aruco tag support!!!\n" RESET);
64  std::exit(EXIT_FAILURE);
65 #endif
66  }
67 
72  void feed_new_camera(const CameraData &message) override;
73 
74 #if ENABLE_ARUCO_TAGS
75 
82  void display_active(cv::Mat &img_out, int r1, int g1, int b1, int r2, int g2, int b2, std::string overlay = "") override;
83 #endif
84 
85 protected:
86 #if ENABLE_ARUCO_TAGS
87 
94  void perform_tracking(double timestamp, const cv::Mat &imgin, size_t cam_id, const cv::Mat &maskin);
95 #endif
96 
97  // Max tag ID we should extract from (i.e., number of aruco tags starting from zero)
99 
100  // If we should downsize the image
102 
103 #if ENABLE_ARUCO_TAGS
104  // Our dictionary that we will extract aruco tags with
105  cv::Ptr<cv::aruco::Dictionary> aruco_dict;
106 
107  // Parameters the opencv extractor uses
108  cv::Ptr<cv::aruco::DetectorParameters> aruco_params;
109 
110  // Our tag IDs and corner we will get from the extractor
111  std::unordered_map<size_t, std::vector<int>> ids_aruco;
112  std::unordered_map<size_t, std::vector<std::vector<cv::Point2f>>> corners, rejects;
113 #endif
114 };
115 
116 } // namespace ov_core
117 
118 #endif /* OV_CORE_TRACK_ARUCO_H */
Tracking of OpenCV Aruoc tags.
Definition: TrackAruco.h:43
Visual feature tracking base class.
Definition: TrackBase.h:72
Struct for a collection of camera measurements.
Definition: sensor_data.h:55
#define RESET
Definition: colors.h:25
void feed_new_camera(const CameraData &message) override
Process a new image.
Definition: TrackAruco.cpp:31
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
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
#define RED
Definition: colors.h:27
HistogramMethod
Desired pre-processing image method.
Definition: TrackBase.h:78
Core algorithms for OpenVINS.
Definition: CamBase.h:30


ov_core
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Wed Jun 21 2023 03:05:36