-
Notifications
You must be signed in to change notification settings - Fork 41
/
feature_tracker.h
executable file
·100 lines (88 loc) · 3.45 KB
/
feature_tracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*******************************************************
* Copyright (C) 2019, Aerial Robotics Group, Hong Kong University of Science and Technology
*
* This file is part of VINS.
*
* Licensed under the GNU General Public License v3.0;
* you may not use this file except in compliance with the License.
*
* Author: Qin Tong (qintonguav@gmail.com)
*******************************************************/
#pragma once
#define GPU_MODE 1
#include <cstdio>
#include <iostream>
#include <queue>
#include <execinfo.h>
#include <csignal>
#include <opencv2/opencv.hpp>
#include <eigen3/Eigen/Dense>
#ifdef GPU_MODE
#include <opencv2/cudaoptflow.hpp>
#include <opencv2/cudaimgproc.hpp>
#include <opencv2/cudaarithm.hpp>
#endif
#include "camodocal/camera_models/CameraFactory.h"
#include "camodocal/camera_models/CataCamera.h"
#include "camodocal/camera_models/PinholeCamera.h"
#include "../estimator/parameters.h"
#include "../utility/tic_toc.h"
using namespace std;
using namespace camodocal;
using namespace Eigen;
#define ROS_INFO RCUTILS_LOG_INFO
#define ROS_WARN RCUTILS_LOG_WARN
#define ROS_DEBUG RCUTILS_LOG_DEBUG
#define ROS_ERROR RCUTILS_LOG_ERROR
bool inBorder(const cv::Point2f &pt);
void reduceVector(vector<cv::Point2f> &v, vector<uchar> status);
void reduceVector(vector<int> &v, vector<uchar> status);
class FeatureTracker
{
public:
FeatureTracker();
map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>>>> trackImage(double _cur_time, const cv::Mat &_img, const cv::Mat &_img1 = cv::Mat());
void setMask();
void addPoints();
void readIntrinsicParameter(const vector<string> &calib_file);
void showUndistortion(const string &name);
void rejectWithF();
void undistortedPoints();
vector<cv::Point2f> undistortedPts(vector<cv::Point2f> &pts, camodocal::CameraPtr cam);
vector<cv::Point2f> ptsVelocity(vector<int> &ids, vector<cv::Point2f> &pts,
map<int, cv::Point2f> &cur_id_pts, map<int, cv::Point2f> &prev_id_pts);
void showTwoImage(const cv::Mat &img1, const cv::Mat &img2,
vector<cv::Point2f> pts1, vector<cv::Point2f> pts2);
void drawTrack(const cv::Mat &imLeft, const cv::Mat &imRight,
vector<int> &curLeftIds,
vector<cv::Point2f> &curLeftPts,
vector<cv::Point2f> &curRightPts,
map<int, cv::Point2f> &prevLeftPtsMap);
void setPrediction(map<int, Eigen::Vector3d> &predictPts);
double distance(cv::Point2f &pt1, cv::Point2f &pt2);
void removeOutliers(set<int> &removePtsIds);
cv::Mat getTrackImage();
bool inBorder(const cv::Point2f &pt);
int row, col;
cv::Mat imTrack;
cv::Mat mask;
cv::Mat fisheye_mask;
cv::Mat prev_img, cur_img;
vector<cv::Point2f> n_pts;
vector<cv::Point2f> predict_pts;
vector<cv::Point2f> predict_pts_debug;
vector<cv::Point2f> prev_pts, cur_pts, cur_right_pts;
vector<cv::Point2f> prev_un_pts, cur_un_pts, cur_un_right_pts;
vector<cv::Point2f> pts_velocity, right_pts_velocity;
vector<int> ids, ids_right;
vector<int> track_cnt;
map<int, cv::Point2f> cur_un_pts_map, prev_un_pts_map;
map<int, cv::Point2f> cur_un_right_pts_map, prev_un_right_pts_map;
map<int, cv::Point2f> prevLeftPtsMap;
vector<camodocal::CameraPtr> m_camera;
double cur_time;
double prev_time;
bool stereo_cam;
int n_id;
bool hasPrediction;
};