From 0e36dabb6fb29ba947039c0ce96d3cf4f783b6ff Mon Sep 17 00:00:00 2001 From: akira_you Date: Sun, 26 Mar 2017 07:57:52 +0900 Subject: [PATCH] use EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION and use same CXX_FLAGS for rpg_svo rpg_vikit --- svo/CMakeLists.txt | 1 + svo/include/svo/depth_filter.h | 6 +++--- svo/include/svo/global.h | 10 ++++++---- svo/include/svo/initialization.h | 18 +++++++++--------- svo/src/depth_filter.cpp | 8 ++++---- svo/src/initialization.cpp | 18 +++++++++--------- svo_ros/CMakeLists.txt | 9 ++++++++- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/svo/CMakeLists.txt b/svo/CMakeLists.txt index 703e379..15257be 100644 --- a/svo/CMakeLists.txt +++ b/svo/CMakeLists.txt @@ -30,6 +30,7 @@ IF(DEBUG_OUTPUT) ENDIF() # Set build flags, set ARM_ARCHITECTURE environment variable on Odroid +# Set build flags. Set IS_ARM on odroid board as environment variable SET(CMAKE_CXX_FLAGS "-Wall -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas") IF(DEFINED ENV{ARM_ARCHITECTURE}) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -march=armv7-a") diff --git a/svo/include/svo/depth_filter.h b/svo/include/svo/depth_filter.h index 6333e54..70f6df3 100644 --- a/svo/include/svo/depth_filter.h +++ b/svo/include/svo/depth_filter.h @@ -116,10 +116,10 @@ public: /// Can be used to compute the Next-Best-View in parallel. /// IMPORTANT! Make sure you hold a valid reference counting pointer to frame /// so it is not being deleted while you use it. - void getSeedsCopy(const FramePtr& frame, std::list >& seeds); + void getSeedsCopy(const FramePtr& frame, std::list& seeds); /// Return a reference to the seeds. This is NOT THREAD SAFE! - std::list >& getSeeds() { return seeds_; } + std::list& getSeeds() { return seeds_; } /// Bayes update of the seed, x is the measurement, tau2 the measurement uncertainty static void updateSeed( @@ -137,7 +137,7 @@ public: protected: feature_detection::DetectorPtr feature_detector_; callback_t seed_converged_cb_; - std::list > seeds_; + std::list seeds_; boost::mutex seeds_mut_; bool seeds_updating_halt_; //!< Set this value to true when seeds updating should be interrupted. boost::thread* thread_; diff --git a/svo/include/svo/global.h b/svo/include/svo/global.h index 7a3989b..03aff4e 100644 --- a/svo/include/svo/global.h +++ b/svo/include/svo/global.h @@ -25,14 +25,16 @@ #include #include -template > > -using vectorA = std::vector< T, Allocator > ; -template > > -using listA = std::list< T, Allocator > ; #include #include #include #include +#include +#ifndef RPG_SVO_VIKIT_IS_VECTOR_SPECIALIZED //Guard for rpg_vikit +#define RPG_SVO_VIKIT_IS_VECTOR_SPECIALIZED +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3d) +EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2d) +#endif #ifdef SVO_USE_ROS #include diff --git a/svo/include/svo/initialization.h b/svo/include/svo/initialization.h index ec74ccd..cb562e5 100644 --- a/svo/include/svo/initialization.h +++ b/svo/include/svo/initialization.h @@ -44,11 +44,11 @@ public: protected: vector px_ref_; //!< keypoints to be tracked in reference frame. vector px_cur_; //!< tracked keypoints in current frame. - vectorA f_ref_; //!< bearing vectors corresponding to the keypoints in the reference image. - vectorA f_cur_; //!< bearing vectors corresponding to the keypoints in the current image. + vector f_ref_; //!< bearing vectors corresponding to the keypoints in the reference image. + vector f_cur_; //!< bearing vectors corresponding to the keypoints in the current image. vector disparities_; //!< disparity between first and second frame. vector inliers_; //!< inliers after the geometric check (e.g., Homography). - vectorA xyz_in_cur_; //!< 3D points computed during the geometric check. + vector xyz_in_cur_; //!< 3D points computed during the geometric check. SE3 T_cur_from_ref_; //!< computed transformation between the first two frames. }; @@ -56,7 +56,7 @@ protected: void detectFeatures( FramePtr frame, vector& px_vec, - vectorA& f_vec); + vector& f_vec); /// Compute optical flow (Lucas Kanade) for selected keypoints. void trackKlt( @@ -64,17 +64,17 @@ void trackKlt( FramePtr frame_cur, vector& px_ref, vector& px_cur, - vectorA& f_ref, - vectorA& f_cur, + vector& f_ref, + vector& f_cur, vector& disparities); void computeHomography( - const vectorA& f_ref, - const vectorA& f_cur, + const vector& f_ref, + const vector& f_cur, double focal_length, double reprojection_threshold, vector& inliers, - vectorA& xyz_in_cur, + vector& xyz_in_cur, SE3& T_cur_from_ref); } // namespace initialization diff --git a/svo/src/depth_filter.cpp b/svo/src/depth_filter.cpp index 4eb6249..db24408 100644 --- a/svo/src/depth_filter.cpp +++ b/svo/src/depth_filter.cpp @@ -135,7 +135,7 @@ void DepthFilter::removeKeyframe(FramePtr frame) { seeds_updating_halt_ = true; lock_t lock(seeds_mut_); - std::list >::iterator it=seeds_.begin(); + std::list::iterator it=seeds_.begin(); size_t n_removed = 0; while(it!=seeds_.end()) { @@ -200,7 +200,7 @@ void DepthFilter::updateSeeds(FramePtr frame) // for all the seeds in every frame! size_t n_updates=0, n_failed_matches=0, n_seeds = seeds_.size(); lock_t lock(seeds_mut_); - std::list >::iterator it=seeds_.begin(); + std::list::iterator it=seeds_.begin(); const double focal_length = frame->cam_->errorMultiplier2(); double px_noise = 1.0; @@ -296,10 +296,10 @@ void DepthFilter::clearFrameQueue() frame_queue_.pop(); } -void DepthFilter::getSeedsCopy(const FramePtr& frame, std::list >& seeds) +void DepthFilter::getSeedsCopy(const FramePtr& frame, std::list& seeds) { lock_t lock(seeds_mut_); - for(std::list >::iterator it=seeds_.begin(); it!=seeds_.end(); ++it) + for(std::list::iterator it=seeds_.begin(); it!=seeds_.end(); ++it) { if (it->ftr->frame == frame.get()) seeds.push_back(*it); diff --git a/svo/src/initialization.cpp b/svo/src/initialization.cpp index d8f947a..571a0bc 100644 --- a/svo/src/initialization.cpp +++ b/svo/src/initialization.cpp @@ -107,7 +107,7 @@ void KltHomographyInit::reset() void detectFeatures( FramePtr frame, vector& px_vec, - vectorA& f_vec) + vector& f_vec) { Features new_features; feature_detection::FastDetector detector( @@ -129,8 +129,8 @@ void trackKlt( FramePtr frame_cur, vector& px_ref, vector& px_cur, - vectorA& f_ref, - vectorA& f_cur, + vector& f_ref, + vector& f_cur, vector& disparities) { const double klt_win_size = 30.0; @@ -148,7 +148,7 @@ void trackKlt( vector::iterator px_ref_it = px_ref.begin(); vector::iterator px_cur_it = px_cur.begin(); - vectorA::iterator f_ref_it = f_ref.begin(); + vector::iterator f_ref_it = f_ref.begin(); f_cur.clear(); f_cur.reserve(px_cur.size()); disparities.clear(); disparities.reserve(px_cur.size()); for(size_t i=0; px_ref_it != px_ref.end(); ++i) @@ -169,16 +169,16 @@ void trackKlt( } void computeHomography( - const vectorA& f_ref, - const vectorA& f_cur, + const vector& f_ref, + const vector& f_cur, double focal_length, double reprojection_threshold, vector& inliers, - vectorA& xyz_in_cur, + vector& xyz_in_cur, SE3& T_cur_from_ref) { - vectorA uv_ref(f_ref.size()); - vectorA uv_cur(f_cur.size()); + vector uv_ref(f_ref.size()); + vector uv_cur(f_cur.size()); for(size_t i=0, i_max=f_ref.size(); i