From 6996d1b8f4936104dba3d7f6e18081c0b0685aca Mon Sep 17 00:00:00 2001 From: nmerrill67 Date: Sun, 22 Nov 2020 12:33:47 -0500 Subject: [PATCH 1/4] Attempt to compile with ROS OpenCV. Check the CI result. Should be a lot faster compile --- .github/workflows/build_catkin.yml | 8 +------- ov_core/CMakeLists.txt | 3 +++ ov_core/src/track/Grider_FAST.h | 28 ++++++++++++++++++++-------- ov_core/src/track/TrackDescriptor.h | 5 ++--- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build_catkin.yml b/.github/workflows/build_catkin.yml index 2de1b7631..d7651de31 100644 --- a/.github/workflows/build_catkin.yml +++ b/.github/workflows/build_catkin.yml @@ -2,7 +2,7 @@ name: C/C++ CI on: push: - branches: [ master, develop_v2.3 ] + branches: [ master, develop_v2.3, opencv_fixing ] pull_request: branches: [ master ] @@ -24,12 +24,6 @@ jobs: sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add - && sudo apt update && sudo apt -y install build-essential ros-melodic-desktop python-catkin-pkg python-catkin-tools libeigen3-dev git - - name: Install OpenCV - run: git clone --branch 3.4 https://github.com/opencv/opencv/ && - git clone --branch 3.4 https://github.com/opencv/opencv_contrib/ && - mkdir opencv/build/ && cd opencv/build/ && - cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D BUILD_opencv_java=OFF -D BUILD_opencv_python=OFF .. && - make -j2 && sudo make install - name: Create Catkin Workspace and compile run: export REPO=$(basename $GITHUB_REPOSITORY) && cd $GITHUB_WORKSPACE/.. && mkdir src/ && diff --git a/ov_core/CMakeLists.txt b/ov_core/CMakeLists.txt index a8332114f..b79ae1848 100644 --- a/ov_core/CMakeLists.txt +++ b/ov_core/CMakeLists.txt @@ -9,6 +9,9 @@ find_package(catkin QUIET COMPONENTS roscpp rosbag tf std_msgs geometry_msgs sen # Include libraries find_package(Eigen3 REQUIRED) find_package(OpenCV 3 REQUIRED) + +message(WARNING "OPENCV VERSION: " ${OpenCV_VERSION}) + find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time) # display message to user diff --git a/ov_core/src/track/Grider_FAST.h b/ov_core/src/track/Grider_FAST.h index ad591297e..412e48d96 100644 --- a/ov_core/src/track/Grider_FAST.h +++ b/ov_core/src/track/Grider_FAST.h @@ -24,8 +24,9 @@ #include #include -#include +#include +#include #include #include @@ -35,6 +36,19 @@ namespace ov_core { + class LambdaBody : public cv::ParallelLoopBody { + public: + LambdaBody(const std::function &body) { + _body = body; + } + + void operator() (const cv::Range & range) const { + _body(range); + } + private: + std::function _body; + }; + /** * @brief Extracts FAST features in a grid pattern. * @@ -91,15 +105,13 @@ namespace ov_core { // Either we will parellize with opencv parallel for loop // Or we will run through a standard double for loop - if(multithread) { - + if (multithread) { // Parallelize our 2d grid extraction!! int ct_cols = std::floor(img.cols/size_x); int ct_rows = std::floor(img.rows/size_y); std::vector> collection(ct_cols*ct_rows); - parallel_for_(cv::Range(0, ct_cols*ct_rows), [&](const cv::Range& range) { + parallel_for_(cv::Range(0, ct_cols*ct_rows), LambdaBody([&](const cv::Range& range) { for (int r = range.start; r < range.end; r++) { - // Calculate what cell xy value we are in int x = r%ct_cols*size_x; int y = r/ct_cols*size_y; @@ -128,14 +140,14 @@ namespace ov_core { collection.at(r).push_back(pt_cor); } } - }); + })); + // Combine all the collections into our single vector for(size_t r=0; r +#include #include "TrackBase.h" @@ -173,4 +172,4 @@ namespace ov_core { } -#endif /* OV_CORE_TRACK_DESC_H */ \ No newline at end of file +#endif /* OV_CORE_TRACK_DESC_H */ From 3fb6cc3cb22b3d3a20eb9dc8ebf8c52b805772c2 Mon Sep 17 00:00:00 2001 From: nmerrill67 Date: Sun, 22 Nov 2020 12:37:19 -0500 Subject: [PATCH 2/4] Fix comment [skip ci] --- .github/workflows/build_catkin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_catkin.yml b/.github/workflows/build_catkin.yml index d7651de31..532e762b5 100644 --- a/.github/workflows/build_catkin.yml +++ b/.github/workflows/build_catkin.yml @@ -28,4 +28,4 @@ jobs: run: export REPO=$(basename $GITHUB_REPOSITORY) && cd $GITHUB_WORKSPACE/.. && mkdir src/ && mv $REPO/ src/ && mkdir $REPO/ && mv src/ $REPO/ && cd $REPO/ && - source /opt/ros/melodic/setup.bash && catkin build -j2 --no-status # TODO REPO=open_vins + source /opt/ros/melodic/setup.bash && catkin build -j2 --no-status From 068f4bbc53942ae5996d3d81a2dd72eb4553b331 Mon Sep 17 00:00:00 2001 From: nmerrill67 Date: Sun, 22 Nov 2020 12:54:57 -0500 Subject: [PATCH 3/4] Update docs to reflect that we don't need opencv contrib anymore [skip ci] --- docs/gs-installing.dox | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/docs/gs-installing.dox b/docs/gs-installing.dox index e3e0b117b..16ba8cf06 100644 --- a/docs/gs-installing.dox +++ b/docs/gs-installing.dox @@ -28,31 +28,10 @@ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc source ~/.bashrc @endcode - - -@section gs-install-opencv OpenCV Dependency - -We leverage [OpenCV 3.4](https://opencv.org/) for this project and recommend you compile it from source. -You can try linking to the one included with ROS but we have always had success with building from source to ensure we have all contributed OpenCV libraries. -One should make sure you can see some of the "contrib" (e.g. xfeature2d) to ensure you have linked to the contrib modules. - -@code{.shell-session} -git clone --branch 3.4 https://github.com/opencv/opencv/ -git clone --branch 3.4 https://github.com/opencv/opencv_contrib/ -mkdir opencv/build/ -cd opencv/build/ -cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules .. -make -j8 -sudo make install -@endcode - - - - @section gs-install-openvins Cloning the OpenVINS Project -Now that we have ROS and OpenCV install we can setup a catkin workspace and build the project! +Now that we have ROS installed we can setup a catkin workspace and build the project! If you did not install the catkin_tools build system, you should be able to build using the standard `catkin_make` command that is included with ROS. If you run into any problems please google search the issue first and if you are unable to find a solution please open an issue on our github page. After the build is successful please following the @ref gs-tutorial guide on getting a dataset and running the system. From 9e23c01dcc8838c0dbfba071e643cdad984aca93 Mon Sep 17 00:00:00 2001 From: nmerrill67 Date: Sun, 22 Nov 2020 12:57:08 -0500 Subject: [PATCH 4/4] Add PR on dev branch to config --- .github/workflows/build_catkin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_catkin.yml b/.github/workflows/build_catkin.yml index 532e762b5..9bfde8c43 100644 --- a/.github/workflows/build_catkin.yml +++ b/.github/workflows/build_catkin.yml @@ -2,9 +2,9 @@ name: C/C++ CI on: push: - branches: [ master, develop_v2.3, opencv_fixing ] + branches: [ master, develop_v2.3 ] pull_request: - branches: [ master ] + branches: [ master, develop_v2.3 ] jobs: build: