TrackKLT.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_KLT_H
23 #define OV_CORE_TRACK_KLT_H
24 
25 #include "TrackBase.h"
26 
27 namespace ov_core {
28 
39 class TrackKLT : public TrackBase {
40 
41 public:
54  explicit TrackKLT(std::unordered_map<size_t, std::shared_ptr<CamBase>> cameras, int numfeats, int numaruco, bool stereo,
55  HistogramMethod histmethod, int fast_threshold, int gridx, int gridy, int minpxdist)
56  : TrackBase(cameras, numfeats, numaruco, stereo, histmethod), threshold(fast_threshold), grid_x(gridx), grid_y(gridy),
57  min_px_dist(minpxdist) {}
58 
63  void feed_new_camera(const CameraData &message) override;
64 
65 protected:
71  void feed_monocular(const CameraData &message, size_t msg_id);
72 
79  void feed_stereo(const CameraData &message, size_t msg_id_left, size_t msg_id_right);
80 
92  void perform_detection_monocular(const std::vector<cv::Mat> &img0pyr, const cv::Mat &mask0, std::vector<cv::KeyPoint> &pts0,
93  std::vector<size_t> &ids0);
94 
113  void perform_detection_stereo(const std::vector<cv::Mat> &img0pyr, const std::vector<cv::Mat> &img1pyr, const cv::Mat &mask0,
114  const cv::Mat &mask1, size_t cam_id_left, size_t cam_id_right, std::vector<cv::KeyPoint> &pts0,
115  std::vector<cv::KeyPoint> &pts1, std::vector<size_t> &ids0, std::vector<size_t> &ids1);
116 
131  void perform_matching(const std::vector<cv::Mat> &img0pyr, const std::vector<cv::Mat> &img1pyr, std::vector<cv::KeyPoint> &pts0,
132  std::vector<cv::KeyPoint> &pts1, size_t id0, size_t id1, std::vector<uchar> &mask_out);
133 
134  // Parameters for our FAST grid detector
136  int grid_x;
137  int grid_y;
138 
139  // Minimum pixel distance to be "far away enough" to be a different extracted feature
141 
142  // How many pyramid levels to track
143  int pyr_levels = 5;
144  cv::Size win_size = cv::Size(15, 15);
145 
146  // Last set of image pyramids
147  std::map<size_t, std::vector<cv::Mat>> img_pyramid_last;
148  std::map<size_t, cv::Mat> img_curr;
149  std::map<size_t, std::vector<cv::Mat>> img_pyramid_curr;
150 };
151 
152 } // namespace ov_core
153 
154 #endif /* OV_CORE_TRACK_KLT_H */
ov_core::TrackKLT::perform_matching
void perform_matching(const std::vector< cv::Mat > &img0pyr, const std::vector< cv::Mat > &img1pyr, std::vector< cv::KeyPoint > &pts0, std::vector< cv::KeyPoint > &pts1, size_t id0, size_t id1, std::vector< uchar > &mask_out)
KLT track between two images, and do RANSAC afterwards.
Definition: TrackKLT.cpp:829
ov_core::TrackKLT::grid_y
int grid_y
Definition: TrackKLT.h:137
ov_core::TrackBase::HistogramMethod
HistogramMethod
Desired pre-processing image method.
Definition: TrackBase.h:78
ov_core::TrackKLT::grid_x
int grid_x
Definition: TrackKLT.h:136
TrackBase.h
ov_core::TrackKLT::perform_detection_monocular
void perform_detection_monocular(const std::vector< cv::Mat > &img0pyr, const cv::Mat &mask0, std::vector< cv::KeyPoint > &pts0, std::vector< size_t > &ids0)
Detects new features in the current image.
Definition: TrackKLT.cpp:395
ov_core::CameraData
Struct for a collection of camera measurements.
Definition: sensor_data.h:55
ov_core::TrackKLT::feed_monocular
void feed_monocular(const CameraData &message, size_t msg_id)
Process a new monocular image.
Definition: TrackKLT.cpp:96
ov_core::TrackKLT::min_px_dist
int min_px_dist
Definition: TrackKLT.h:140
ov_core::TrackKLT::img_curr
std::map< size_t, cv::Mat > img_curr
Definition: TrackKLT.h:148
ov_core::TrackKLT::feed_stereo
void feed_stereo(const CameraData &message, size_t msg_id_left, size_t msg_id_right)
Process new stereo pair of images.
Definition: TrackKLT.cpp:202
ov_core::TrackKLT::threshold
int threshold
Definition: TrackKLT.h:135
ov_core::TrackKLT::TrackKLT
TrackKLT(std::unordered_map< size_t, std::shared_ptr< CamBase >> cameras, int numfeats, int numaruco, bool stereo, HistogramMethod histmethod, int fast_threshold, int gridx, int gridy, int minpxdist)
Public constructor with configuration variables.
Definition: TrackKLT.h:54
ov_core::TrackKLT::img_pyramid_curr
std::map< size_t, std::vector< cv::Mat > > img_pyramid_curr
Definition: TrackKLT.h:149
ov_core::TrackKLT::feed_new_camera
void feed_new_camera(const CameraData &message) override
Process a new image.
Definition: TrackKLT.cpp:34
ov_core::TrackKLT::perform_detection_stereo
void perform_detection_stereo(const std::vector< cv::Mat > &img0pyr, const std::vector< cv::Mat > &img1pyr, const cv::Mat &mask0, const cv::Mat &mask1, size_t cam_id_left, size_t cam_id_right, std::vector< cv::KeyPoint > &pts0, std::vector< cv::KeyPoint > &pts1, std::vector< size_t > &ids0, std::vector< size_t > &ids1)
Detects new features in the current stereo pair.
Definition: TrackKLT.cpp:530
ov_core::TrackKLT::pyr_levels
int pyr_levels
Definition: TrackKLT.h:143
ov_core::TrackKLT
KLT tracking of features.
Definition: TrackKLT.h:39
ov_core::TrackKLT::img_pyramid_last
std::map< size_t, std::vector< cv::Mat > > img_pyramid_last
Definition: TrackKLT.h:147
ov_core::TrackKLT::win_size
cv::Size win_size
Definition: TrackKLT.h:144
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 Jan 22 2024 03:08:17