Go to the documentation of this file.00001
00024 #ifndef CCNY_RGBD_KEYFRAME_GRAPH_DETECTOR_H
00025 #define CCNY_RGBD_KEYFRAME_GRAPH_DETECTOR_H
00026
00027 #include <boost/thread/mutex.hpp>
00028 #include <tf/transform_datatypes.h>
00029 #include <pcl/registration/transformation_estimation_svd.h>
00030 #include <opencv2/nonfree/features2d.hpp>
00031
00032 #include "ccny_rgbd/types.h"
00033 #include "ccny_rgbd/structures/rgbd_keyframe.h"
00034 #include "ccny_rgbd/structures/keyframe_association.h"
00035
00036 namespace ccny_rgbd {
00037
00041 class KeyframeGraphDetector
00042 {
00043 public:
00044
00049 KeyframeGraphDetector(const ros::NodeHandle& nh,
00050 const ros::NodeHandle& nh_private);
00051
00054 virtual ~KeyframeGraphDetector();
00055
00060 void generateKeyframeAssociations(
00061 KeyframeVector& keyframes,
00062 KeyframeAssociationVector& associations);
00063
00064 protected:
00065
00066 ros::NodeHandle nh_;
00067 ros::NodeHandle nh_private_;
00068
00069 private:
00070
00073 int max_ransac_iterations_;
00074
00078 bool save_ransac_results_;
00079
00082 std::string ransac_results_path_;
00083
00087 double n_ransac_candidates_;
00088
00091 int k_nearest_neighbors_;
00092
00098 int min_ransac_inliers_;
00099
00103 double max_corresp_dist_desc_;
00104
00108 double max_corresp_dist_eucl_;
00109
00112 double max_corresp_dist_eucl_sq_;
00113
00116 int n_keypoints_;
00117
00127 void prepareFeaturesForRANSAC(KeyframeVector& keyframes);
00128
00135 void visualOdometryAssociations(
00136 KeyframeVector& keyframes,
00137 KeyframeAssociationVector& associations);
00138
00150 void treeAssociations(
00151 KeyframeVector& keyframes,
00152 KeyframeAssociationVector& associations);
00153
00163 void manualBruteForceAssociations(
00164 KeyframeVector& keyframes,
00165 KeyframeAssociationVector& associations);
00166
00172 double distEuclideanSq(const PointFeature& a, const PointFeature& b)
00173 {
00174 float dx = a.x - b.x;
00175 float dy = a.y - b.y;
00176 float dz = a.z - b.z;
00177 return dx*dx + dy*dy + dz*dz;
00178 }
00179
00185 void getRandomIndices(int k, int n, IntVector& output);
00186
00192 void trainMatcher(const KeyframeVector& keyframes,
00193 cv::FlannBasedMatcher& matcher);
00194
00214 void pairwiseMatchingRANSAC(
00215 RGBDFrame& frame_a, RGBDFrame& frame_b,
00216 double max_eucl_dist_sq,
00217 double max_desc_dist,
00218 double sufficient_inlier_ratio,
00219 std::vector<cv::DMatch>& all_matches,
00220 std::vector<cv::DMatch>& best_inlier_matches,
00221 Eigen::Matrix4f& best_transformation);
00222 };
00223
00224 }
00225
00226 #endif // CCNY_RGBD_KEYFRAME_GRAPH_DETECTOR_H