NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
lk_optical_flow.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef LK_OPTICAL_FLOW_LK_OPTICAL_FLOW_H_
20 #define LK_OPTICAL_FLOW_LK_OPTICAL_FLOW_H_
21 
22 #include <camera/camera_params.h>
23 #include <ff_msgs/Feature2d.h>
24 #include <ff_msgs/Feature2dArray.h>
25 
26 #include <cv_bridge/cv_bridge.h>
28 
29 #include <opencv2/core/core.hpp>
30 
31 #include <string>
32 #include <vector>
33 
34 namespace lk_optical_flow {
35 
37  public:
38  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
39  LKOpticalFlow(void);
40  ~LKOpticalFlow(void) {}
41 
43  void OpticalFlow(const sensor_msgs::ImageConstPtr& msg,
44  ff_msgs::Feature2dArray* features);
45  sensor_msgs::Image::Ptr ShowDebugWindow(const sensor_msgs::ImageConstPtr& msg);
46 
47  private:
48  void AddNewFeatures(const std::vector<cv::Point2f>& new_points);
49  void GetNewFeatures(std::vector<cv::Point2f>* new_corners);
50  void CreateFeatureArray(ff_msgs::Feature2dArray* features);
51  void RefineCorners();
52  void UpdateIdList(const size_t& num_itr);
53 
54  cv::Mat image_curr_, image_prev_;
55 
56  sensor_msgs::ImageConstPtr image_prev_ptr_;
57  std::vector<cv::Point2f> prev_corners_, curr_corners_, backwards_corners_;
58 
59  std::vector<uchar> status_, backwards_status_;
60  std::vector<float> err_, backwards_err_;
61  cv::Size win_size_;
62 
63  bool ignored_last_frame_;
64  size_t max_feature_;
65  int max_lk_pyr_level_;
66  int max_lk_itr_;
67  int max_gap_;
68  float scale_factor_;
69 
70  float max_flow_magnitude_, font_size_, max_feature_rad_;
71  int id_cnt_, id_max_;
72  std::vector<int> id_list_;
73 
74  camera::CameraParameters camera_param_;
75 };
76 } // end namespace lk_optical_flow
77 
78 #endif // LK_OPTICAL_FLOW_LK_OPTICAL_FLOW_H_
lk_optical_flow::LKOpticalFlow::LKOpticalFlow
EIGEN_MAKE_ALIGNED_OPERATOR_NEW LKOpticalFlow(void)
Definition: lk_optical_flow.cc:32
lk_optical_flow
Definition: lk_optical_flow.h:34
camera::CameraParameters
Definition: camera_params.h:58
lk_optical_flow::LKOpticalFlow::ShowDebugWindow
sensor_msgs::Image::Ptr ShowDebugWindow(const sensor_msgs::ImageConstPtr &msg)
Definition: lk_optical_flow.cc:213
lk_optical_flow::LKOpticalFlow::ReadParams
void ReadParams(config_reader::ConfigReader *config)
Definition: lk_optical_flow.cc:39
config_reader::ConfigReader
Definition: config_reader.h:48
lk_optical_flow::LKOpticalFlow::OpticalFlow
void OpticalFlow(const sensor_msgs::ImageConstPtr &msg, ff_msgs::Feature2dArray *features)
Definition: lk_optical_flow.cc:64
lk_optical_flow::LKOpticalFlow::~LKOpticalFlow
~LKOpticalFlow(void)
Definition: lk_optical_flow.h:40
config_reader.h
camera_params.h
lk_optical_flow::LKOpticalFlow
Definition: lk_optical_flow.h:36