Skip to content

Commit

Permalink
Merge pull request #1 from rpng/opencv_fixing
Browse files Browse the repository at this point in the history
Opencv fixing
  • Loading branch information
nmerrill67 authored Nov 22, 2020
2 parents 528c80d + 9e23c01 commit 93bd91d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 41 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/build_catkin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ master, develop_v2.3 ]
pull_request:
branches: [ master ]
branches: [ master, develop_v2.3 ]

jobs:
build:
Expand All @@ -24,14 +24,8 @@ 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/ &&
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
23 changes: 1 addition & 22 deletions docs/gs-installing.dox
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions ov_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 20 additions & 8 deletions ov_core/src/track/Grider_FAST.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

#include <vector>
#include <iostream>
#include <Eigen/Eigen>
#include <functional>

#include <Eigen/Eigen>

#include <opencv/cv.hpp>
#include <opencv2/core/core.hpp>
Expand All @@ -35,6 +36,19 @@

namespace ov_core {

class LambdaBody : public cv::ParallelLoopBody {
public:
LambdaBody(const std::function<void(const cv::Range &)> &body) {
_body = body;
}

void operator() (const cv::Range & range) const {
_body(range);
}
private:
std::function<void(const cv::Range &)> _body;
};

/**
* @brief Extracts FAST features in a grid pattern.
*
Expand Down Expand Up @@ -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<std::vector<cv::KeyPoint>> 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;
Expand Down Expand Up @@ -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<collection.size(); r++) {
pts.insert(pts.end(),collection.at(r).begin(),collection.at(r).end());
}

} else {

// Lets loop through each grid and extract features
for (int x = 0; x < img.cols; x += size_x) {
for (int y = 0; y < img.rows; y += size_y) {
Expand Down Expand Up @@ -198,4 +210,4 @@ namespace ov_core {
}


#endif /* OV_CORE_GRIDER_FAST_H */
#endif /* OV_CORE_GRIDER_FAST_H */
5 changes: 2 additions & 3 deletions ov_core/src/track/TrackDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#ifndef OV_CORE_TRACK_DESC_H
#define OV_CORE_TRACK_DESC_H


#include <opencv2/xfeatures2d.hpp>
#include <opencv2/features2d.hpp>

#include "TrackBase.h"

Expand Down Expand Up @@ -173,4 +172,4 @@ namespace ov_core {
}


#endif /* OV_CORE_TRACK_DESC_H */
#endif /* OV_CORE_TRACK_DESC_H */

0 comments on commit 93bd91d

Please sign in to comment.