forked from HKUST-Aerial-Robotics/VINS-Mono
-
Notifications
You must be signed in to change notification settings - Fork 0
34 use observer design for feature tracker #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TanPinDa
wants to merge
37
commits into
master
Choose a base branch
from
34-use-observer-design-for-feature-tracker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
432d88c
[34] First working version of observer design
TanPinDa 3bd7995
[34] Minor cleanup
TanPinDa 9b3990b
[34] Remove cur_img variable
TanPinDa 5b79588
[34] Remove cur_time private varaible
TanPinDa 806a438
[34] Remove curr_pts private variable
TanPinDa 7d6231b
[34] Remove n-pts private variable
TanPinDa 700c13d
[34] Remove pts-Velocity private variable
TanPinDa afa854c
[34] Remove all the tic toc
TanPinDa 59fd7bc
[34] Remove cur_un_pts private variable
TanPinDa b829ff6
[34] Remove repeated lift projection
TanPinDa f23b221
[34] Remove the need for maps between id and points. Remove UpdateID …
TanPinDa 7982a9d
[34] Add arrows for point velocity
TanPinDa 1a5f129
[34] WIP create feature tracker node
TanPinDa 0edd083
[34] WIP Adding param reading
TanPinDa a22caf0
[34] WIP ros node basic function
TanPinDa bf0245c
[34] Update to use first frame
TanPinDa 7a1d353
[34] Rename pravite variables
TanPinDa bf47ab3
[34] Minor cleanup
TanPinDa d69add7
[34] Minor Clean up
TanPinDa 3bb873a
[34] Remove unused function
TanPinDa 921d16d
[34] Simplify mask generation
TanPinDa 8e94603
[34]Simplify mask generation
TanPinDa 3bf3fb9
[34] Add guard for ransac. Segfaults when n_points<8
TanPinDa c366f03
[34] Minor cleanup
TanPinDa 379af29
[34] Remove using namespace std
TanPinDa 829af89
[34] Remove unused files
TanPinDa f6771b0
[34] Remove unused imports and using namespace
TanPinDa 743099f
[34] Create seperated config files
TanPinDa 8331900
[34] Update rerun observer to actually use rerun
TanPinDa 3c2e38d
[34] Seperate rerun observer and main to seperate package
TanPinDa dbc6d28
[34] Rename feature tracker header and remove spdlog
TanPinDa 2c5eb28
[34] Add additional logging to rerun
TanPinDa 6035c2b
[34] Cleanup main
TanPinDa 8dc5693
[34] Update feature tracker demo to use config file
TanPinDa 48b1e3b
[34] Fix feature_tracker_ros to run with entire vins estimator
TanPinDa 4ca00f7
[34] Delete unused ros_parameter_reader
TanPinDa 97a92fa
[34] Add dependencies for rerun
TanPinDa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| %YAML:1.0 | ||
|
|
||
| #camera calibration | ||
| model_type: PINHOLE | ||
| camera_name: camera | ||
| image_width: 752 | ||
| image_height: 480 | ||
| distortion_parameters: | ||
| k1: -2.917e-01 | ||
| k2: 8.228e-02 | ||
| p1: 5.333e-05 | ||
| p2: -1.578e-04 | ||
| projection_parameters: | ||
| fx: 4.616e+02 | ||
| fy: 4.603e+02 | ||
| cx: 3.630e+02 | ||
| cy: 2.481e+02 | ||
|
|
||
| # Extrinsic parameter between IMU and Camera. | ||
| estimate_extrinsic: 0 # 0 Have an accurate extrinsic parameters. We will trust the following imu^R_cam, imu^T_cam, don't change it. | ||
| # 1 Have an initial guess about extrinsic parameters. We will optimize around your initial guess. | ||
| # 2 Don't know anything about extrinsic parameters. You don't need to give R,T. We will try to calibrate it. Do some rotation movement at beginning. | ||
| #If you choose 0 or 1, you should write down the following matrix. | ||
| #Rotation from camera frame to imu frame, imu^R_cam | ||
| extrinsicRotation: !!opencv-matrix | ||
| rows: 3 | ||
| cols: 3 | ||
| dt: d | ||
| data: [0.0148655429818, -0.999880929698, 0.00414029679422, | ||
| 0.999557249008, 0.0149672133247, 0.025715529948, | ||
| -0.0257744366974, 0.00375618835797, 0.999660727178] | ||
| #Translation from camera frame to imu frame, imu^T_cam | ||
| extrinsicTranslation: !!opencv-matrix | ||
| rows: 3 | ||
| cols: 1 | ||
| dt: d | ||
| data: [-0.0216401454975,-0.064676986768, 0.00981073058949] | ||
|
|
||
| #feature traker paprameters | ||
| max_cnt: 150 # max feature number in feature tracking | ||
| min_dist: 30 # min distance between two features | ||
| freq: 10 # frequence (Hz) of publish tracking result. At least 10Hz for good estimation. If set 0, the frequence will be same as raw image | ||
| F_threshold: 1.0 # ransac threshold (pixel) | ||
| show_track: 1 # publish tracking image as topic | ||
| equalize: 1 # if image is too dark or light, trun on equalize to find enough features | ||
| fisheye: 0 # if using fisheye, trun on it. A circle mask will be loaded to remove edge noisy points | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #feature traker paprameters | ||
| max_cnt: 150 # max feature number in feature tracking | ||
| min_dist: 30 # min distance between two features | ||
| freq: 10 # frequence (Hz) of publish tracking result. At least 10Hz for good estimation. If set 0, the frequence will be same as raw image | ||
| F_threshold: 1.0 # ransac threshold (pixel) | ||
| equalize: true # if image is too dark or light, trun on equalize to find enough features | ||
| fisheye: false # if using fisheye, trun on it. A circle mask will be loaded to remove edge noisy points |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
feature_tracker/include/feature_tracker/feature_tracker.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #ifndef FEATURE_TRACKER_HPP | ||
| #define FEATURE_TRACKER_HPP | ||
|
|
||
| #include <opencv2/opencv.hpp> | ||
| #include "camodocal/camera_models/CameraFactory.h" | ||
| #include "feature_tracker/feature_tracker_observer.hpp" | ||
|
|
||
| class FeatureTracker { | ||
| public: | ||
| FeatureTracker(std::string camera_config_file, bool fisheye, | ||
| bool run_histogram_equilisation, | ||
| uint max_feature_count_per_image, | ||
| uint min_distance_between_features, | ||
| double fundemental_matrix_ransac_threshold, double fx, | ||
| double fy, double feature_pruning_frequency, | ||
| double max_time_difference); | ||
|
|
||
| void RegisterEventObserver( | ||
| std::shared_ptr<FeatureTrackerObserver> event_observer); | ||
|
|
||
| void ProcessNewFrame(const cv::Mat &img, const double time_s); | ||
|
|
||
| private: | ||
| void RestartTracker(const cv::Mat &pre_processed_img, double current_time); | ||
|
|
||
| void AddPoints(const cv::Mat image, const cv::Mat mask, | ||
| const int max_number_new_of_points, | ||
| const int min_distance_between_points, | ||
| const camodocal::CameraPtr m_camera, | ||
| std::vector<cv::Point2f> &points, | ||
| std::vector<cv::Point2f> &undistorted_points, | ||
| std::vector<int> &track_length, std::vector<int> &feature_ids); | ||
|
|
||
| void PrunePoints(std::vector<cv::Point2f> &curr_points, | ||
| std::vector<cv::Point2f> &curr_un_points, | ||
| std::vector<cv::Point2f> &prev_points, | ||
| std::vector<cv::Point2f> &prev_un_points, | ||
| std::vector<int> &ids, std::vector<int> &track_counts, | ||
| const std::vector<uchar> &status); | ||
|
|
||
| cv::Mat CreateMask(std::vector<cv::Point2f> &curr_pts, | ||
| std::vector<int> &track_length, | ||
| std::vector<uchar> &status_out); | ||
|
|
||
| void RejectUsingRansac(const std::vector<cv::Point2f> &cur_un_pts, | ||
| const std::vector<cv::Point2f> &prev_un_pts, | ||
| std::vector<uchar> &status_out) const; | ||
|
|
||
| void GetPointVelocty(double dt, const std::vector<cv::Point2f> &cur_un_pts, | ||
| const std::vector<cv::Point2f> &prev_un_pts, | ||
| std::vector<cv::Point2f> &pts_velocity_out) const; | ||
|
|
||
| cv::Point2f UndistortPoint(const cv::Point2f point, | ||
| const camodocal::CameraPtr camera) const; | ||
|
|
||
| std::string GenerateStateString() const; | ||
|
|
||
| cv::Mat base_mask_; | ||
| cv::Mat previous_pre_processed_image_; | ||
| double previous_frame_time_; | ||
|
|
||
| std::vector<cv::Point2f> previous_undistorted_pts_; | ||
| std::vector<cv::Point2f> previous_points_; | ||
| std::vector<int> feature_ids_; | ||
| std::vector<int> feature_track_lengh_; | ||
| double prev_prune_time_; | ||
|
|
||
| double fx_; | ||
| double fy_; | ||
| camodocal::CameraPtr camera_model_; | ||
|
|
||
| static int feature_counter_; // Static to ensure unique id between different | ||
| // instances | ||
|
|
||
| cv::Ptr<cv::CLAHE> clahe_; | ||
|
|
||
| bool fisheye_; | ||
| bool run_histogram_equilisation_; | ||
| uint max_feature_count_per_image_; | ||
| uint min_distance_between_features_; | ||
| double fundemental_matrix_ransac_threshold_; | ||
|
|
||
| double max_time_difference_; | ||
| double feature_pruning_frequency_; | ||
| double feature_pruning_period_; | ||
| std::shared_ptr<FeatureTrackerObserver> event_observer_; | ||
| }; | ||
|
|
||
|
|
||
| #endif /* FEATURE_TRACKER_HPP */ |
45 changes: 45 additions & 0 deletions
45
feature_tracker/include/feature_tracker/feature_tracker_observer.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #ifndef FEATURE_TRACKER_OBSERVER_HPP | ||
| #define FEATURE_TRACKER_OBSERVER_HPP | ||
|
|
||
| #include <opencv2/opencv.hpp> | ||
| #include <vector> | ||
|
|
||
| class FeatureTrackerObserver | ||
| : public std::enable_shared_from_this<FeatureTrackerObserver> { | ||
| public: | ||
| FeatureTrackerObserver() = default; | ||
| virtual ~FeatureTrackerObserver() = default; | ||
|
|
||
| virtual void OnRegistered() = 0; | ||
| virtual void OnRestart() = 0; | ||
| virtual void OnDurationBetweenFrameTooLarge(double current_image_time_s, | ||
| double previous_image_time_s) = 0; | ||
| virtual void OnImageTimeMovingBackwards(double current_image_time_s, | ||
| double previous_image_time_s) = 0; | ||
|
|
||
| virtual void OnImageRecieved(const cv::Mat &new_frame, | ||
| double current_image_time_s) = 0; | ||
| virtual void OnHistogramEqualisation(const cv::Mat &new_frame, | ||
| double current_image_time_s) = 0; | ||
|
|
||
| virtual void OnProcessedImage(const cv::Mat &new_frame, | ||
| double current_image_time_s, | ||
| std::vector<cv::Point2f> features, | ||
| std::vector<cv::Point2f> undistorted_features, | ||
|
|
||
| std::vector<int> ids, | ||
| std::vector<int> track_count, | ||
| std::vector<cv::Point2f> points_velocity) = 0; | ||
|
|
||
| cv::Mat CreateTrackedFeatureImage(cv::Mat image, | ||
| std::vector<cv::Point2f> features, | ||
| std::vector<int> track_cnt, | ||
| uint max_track_count); | ||
|
|
||
| cv::Mat CreateOpticalFlowImage(cv::Mat image, | ||
| std::vector<cv::Point2f> features, | ||
| std::vector<int> track_cnt, | ||
| uint max_track_count, | ||
| std::vector<cv::Point2f> points_velocity); | ||
| }; | ||
| #endif /* FEATURE_TRACKER_OBSERVER_HPP */ | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 2 methods seem like feature tracker utility helper functions, and they do not need anything from this observer class. Maybe they shouldnt be part of the observer class.
We could have a include/feature_tracker/utils.hpp and park these 2 helpers as free functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to add a doc/update README for details on usage with rerun