TrackSIM.cpp
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 #include "TrackSIM.h"
23 
24 #include "cam/CamBase.h"
25 #include "feat/Feature.h"
26 #include "feat/FeatureDatabase.h"
27 
28 using namespace ov_core;
29 
30 void TrackSIM::feed_measurement_simulation(double timestamp, const std::vector<int> &camids,
31  const std::vector<std::vector<std::pair<size_t, Eigen::VectorXf>>> &feats) {
32 
33  // Assert our two vectors are equal
34  assert(camids.size() == feats.size());
35 
36  // Loop through each camera
37  for (size_t i = 0; i < camids.size(); i++) {
38 
39  // Current camera id
40  int cam_id = camids.at(i);
41 
42  // Our good ids and points
43  std::vector<cv::KeyPoint> good_left;
44  std::vector<size_t> good_ids_left;
45 
46  // Update our feature database, with theses new observations
47  // NOTE: we add the "currid" since we need to offset the simulator
48  // NOTE: ids by the number of aruoc tags we have specified as tracking
49  for (const auto &feat : feats.at(i)) {
50 
51  // Get our id value
52  size_t id = feat.first + currid;
53 
54  // Create the keypoint
55  cv::KeyPoint kpt;
56  kpt.pt.x = feat.second(0);
57  kpt.pt.y = feat.second(1);
58  good_left.push_back(kpt);
59  good_ids_left.push_back(id);
60 
61  // Append to the database
62  cv::Point2f npt_l = camera_calib.at(cam_id)->undistort_cv(kpt.pt);
63  database->update_feature(id, timestamp, cam_id, kpt.pt.x, kpt.pt.y, npt_l.x, npt_l.y);
64  }
65 
66  // Get our width and height
67  int width = camera_calib.at(cam_id)->w();
68  int height = camera_calib.at(cam_id)->h();
69 
70  // Move forward in time
71  {
72  std::lock_guard<std::mutex> lckv(mtx_last_vars);
73  img_last[cam_id] = cv::Mat::zeros(cv::Size(width, height), CV_8UC1);
74  img_mask_last[cam_id] = cv::Mat::zeros(cv::Size(width, height), CV_8UC1);
75  pts_last[cam_id] = good_left;
76  ids_last[cam_id] = good_ids_left;
77  }
78  }
79 }
FeatureDatabase.h
ov_core::TrackBase::currid
std::atomic< size_t > currid
Master ID for this tracker (atomic to allow for multi-threading)
Definition: TrackBase.h:192
ov_core::TrackBase::database
std::shared_ptr< FeatureDatabase > database
Database with all our current features.
Definition: TrackBase.h:159
ov_core::TrackBase::img_mask_last
std::map< size_t, cv::Mat > img_mask_last
Last set of images (use map so all trackers render in the same order)
Definition: TrackBase.h:183
ov_core::TrackBase::mtx_last_vars
std::mutex mtx_last_vars
Mutex for editing the *_last variables.
Definition: TrackBase.h:177
TrackSIM.h
Feature.h
ov_core::TrackBase::ids_last
std::unordered_map< size_t, std::vector< size_t > > ids_last
Set of IDs of each current feature in the database.
Definition: TrackBase.h:189
CamBase.h
ov_core::TrackBase::pts_last
std::unordered_map< size_t, std::vector< cv::KeyPoint > > pts_last
Last set of tracked points.
Definition: TrackBase.h:186
ov_core::TrackBase::img_last
std::map< size_t, cv::Mat > img_last
Last set of images (use map so all trackers render in the same order)
Definition: TrackBase.h:180
ov_core::TrackBase::camera_calib
std::unordered_map< size_t, std::shared_ptr< CamBase > > camera_calib
Camera object which has all calibration in it.
Definition: TrackBase.h:156
ov_core
Core algorithms for OpenVINS.
Definition: CamBase.h:30
ov_core::TrackSIM::feed_measurement_simulation
void feed_measurement_simulation(double timestamp, const std::vector< int > &camids, const std::vector< std::vector< std::pair< size_t, Eigen::VectorXf >>> &feats)
Feed function for a synchronized simulated cameras.
Definition: TrackSIM.cpp:30


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