Closed wangminhang closed 4 years ago
Do you have a specific error you are getting from building? You might need to specify in open_vins/ov_core/CMakeLists.txt
a minor version number if you are getting an aruco tag error on ov_core building. Change the following:
find_package(OpenCV 3 REQUIRED)
to one of the following
find_package(OpenCV 3.3 REQUIRED)
find_package(OpenCV 3.4 REQUIRED)
ok, generally speaking,how to build ov_maplab after maplab and open_vins have built in different catkin workspace? Put ov_maplab to which catkin_ws? And how to build so that it can find vi_map lib and so on. Could maplab and ov_maplab use different version of opencv?
Clone both open_vins
and ov_maplab
into the same workspace which has maplab
and maplab_dependencies
cloned into it also. Then build using catkin build ov_maplab
and that should build the vi_map etc before hand.
If you run into opencv errors, please post after first changing as per my comment above to get the ros default (3.3.1 should be included with kinetic) or your local install.
yeah, In maplab_dependencies/3rdparty/opencv3_catkin/CMakeList , it download opencv 3.2.0, so the whole package in maplab use this version. when run catkin build ov_maplab,
In file included from ~/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.cpp:21:0:
~/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h:25:29: fatal error: opencv2/aruco.hpp: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/ov_core_lib.dir/src/track/TrackAruco.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from ~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.h:38:0,
from ~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.cpp:21:
~/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h: In static member function ‘static void ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)’:
~/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h:125:14: error: invalid initialization of reference of type ‘const cv::ParallelLoopBody&’ from expression of type ‘ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)::<lambda(const cv::Range&)>’
});
^
In file included from ~/maplab_ros/devel/include/opencv2/core.hpp:3216:0,
from ~/maplab_ros/devel/include/opencv2/core/types_c.h:101,
from ~/maplab_ros/devel/include/opencv2/core/core_c.h:48,
from ~/maplab_ros/devel/include/opencv/cv.h:63,
from ~/maplab_ros/devel/include/opencv/cv.hpp:50,
from ~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.h:34,
from ~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.cpp:21:
~/maplab_ros/devel/include/opencv2/core/utility.hpp:478:17: note: in passing argument 2 of ‘void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)’
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
^
make[2]: *** [CMakeFiles/ov_core_lib.dir/src/track/TrackBase.cpp.o] Error 1
make[1]: *** [CMakeFiles/ov_core_lib.dir/all] Error 2
make: *** [all] Error 2
opencv version in /user/local/lib is 3.4.6
Can you try editing the function in ov_core/src/track/Grider_FAST.h
to the following:
static void perform_griding(const cv::Mat &img, std::vector<cv::KeyPoint> &pts, int num_features,
int grid_x, int grid_y, int threshold, bool nonmaxSuppression) {
// Calculate the size our extraction boxes should be
int size_x = img.cols / grid_x;
int size_y = img.rows / grid_y;
// Make sure our sizes are not zero
assert(size_x > 0);
assert(size_y > 0);
// We want to have equally distributed features
auto num_features_grid = (int) (num_features / (grid_x * grid_y)) + 1;
// 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) {
// Skip if we are out of bounds
if (x + size_x > img.cols || y + size_y > img.rows)
continue;
// Calculate where we should be extracting from
cv::Rect img_roi = cv::Rect(x, y, size_x, size_y);
// Extract FAST features for this part of the image
std::vector<cv::KeyPoint> pts_new;
cv::FAST(img(img_roi), pts_new, threshold, nonmaxSuppression);
// Now lets get the top number from this
std::sort(pts_new.begin(), pts_new.end(), Grider_FAST::compare_response);
// Append the "best" ones to our vector
// Note that we need to "correct" the point u,v since we extracted it in a ROI
// So we should append the location of that ROI in the image
for (size_t i = 0; i < (size_t) num_features_grid && i < pts_new.size(); i++) {
cv::KeyPoint pt_cor = pts_new.at(i);
pt_cor.pt.x += x;
pt_cor.pt.y += y;
pts.push_back(pt_cor);
}
}
}
}
Originally it was not multi-threaded but I am not sure why opencv 3.4.6 is giving issues. I remember I had this at some point, and not sure how I fixed it.
huge errors. Can open_vins and ov_maplab build with opencv 3.2.0?
No it won't, can you build with 3.3? The aruco module isn't included with the 3.2 that maplab uses so there are some issues there with trying to link to it. Can you post what errors you are getting?
edit: I would also ensure you do a catkin clean
between changes so you don't have cmake things cached.
In file included from~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.h:38:0,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.cpp:21:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h: In static member function ‘static void ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)’:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h:125:14: error: invalid initialization of reference of type ‘const cv::ParallelLoopBody&’ from expression of type ‘ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)::<lambda(const cv::Range&)>’
});
^
In file included from~/maplab_ros/devel/include/opencv2/core.hpp:3216:0,
from~/maplab_ros/devel/include/opencv2/core/types_c.h:101,
from~/maplab_ros/devel/include/opencv2/core/core_c.h:48,
from~/maplab_ros/devel/include/opencv/cv.h:63,
from~/maplab_ros/devel/include/opencv/cv.hpp:50,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.h:34,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.cpp:21:
/home/robot/vslam/maplab_ros/devel/include/opencv2/core/utility.hpp:478:17: note: in passing argument 2 of ‘void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)’
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
^
In file included from~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.h:38:0,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h:27,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.cpp:21:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h: In static member function ‘static void ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)’:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h:125:14: error: invalid initialization of reference of type ‘const cv::ParallelLoopBody&’ from expression of type ‘ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)::<lambda(const cv::Range&)>’
});
^
In file included from~/maplab_ros/devel/include/opencv2/core.hpp:3216:0,
from~/maplab_ros/devel/include/opencv2/aruco.hpp:42,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h:25,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.cpp:21:
/home/robot/vslam/maplab_ros/devel/include/opencv2/core/utility.hpp:478:17: note: in passing argument 2 of ‘void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)’
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
^
In file included from~/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.cpp:21:0:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h: In constructor ‘ov_core::TrackAruco::TrackAruco()’:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h:48:27: error: ‘struct cv::aruco::DetectorParameters’ has no member named ‘cornerRefinementMethod’
aruco_params->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_SUBPIX; // people with newer opencv might fail here
^
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h:48:63: error: ‘cv::aruco::CornerRefineMethod’ has not been declared
aruco_params->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_SUBPIX; // people with newer opencv might fail here
^
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h: In constructor ‘ov_core::TrackAruco::TrackAruco(int, bool)’:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h:59:27: error: ‘struct cv::aruco::DetectorParameters’ has no member named ‘cornerRefinementMethod’
aruco_params->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_SUBPIX; // people with newer opencv might fail here
^
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/TrackAruco.h:59:63: error: ‘cv::aruco::CornerRefineMethod’ has not been declared
aruco_params->cornerRefinementMethod = cv::aruco::CornerRefineMethod::CORNER_REFINE_SUBPIX; // people with newer opencv might fail here
^
In file included from~/maplab_ros/src/open_vins/ov_core/src/track/TrackBase.h:38:0,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackDescriptor.h:27,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackDescriptor.cpp:21:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h: In static member function ‘static void ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)’:
/home/robot/vslam/maplab_ros/src/open_vins/ov_core/src/track/Grider_FAST.h:125:14: error: invalid initialization of reference of type ‘const cv::ParallelLoopBody&’ from expression of type ‘ov_core::Grider_FAST::perform_griding(const cv::Mat&, std::vector<cv::KeyPoint>&, int, int, int, int, bool)::<lambda(const cv::Range&)>’
});
^
In file included from~/maplab_ros/devel/include/opencv2/core.hpp:3216:0,
from~/maplab_ros/devel/include/opencv2/features2d.hpp:46,
from~/maplab_ros/devel/include/opencv2/xfeatures2d.hpp:42,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackDescriptor.h:25,
from~/maplab_ros/src/open_vins/ov_core/src/track/TrackDescriptor.cpp:21:
/home/robot/vslam/maplab_ros/devel/include/opencv2/core/utility.hpp:478:17: note: in passing argument 2 of ‘void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)’
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
^
make[2]: *** [CMakeFiles/ov_core_lib.dir/src/track/TrackBase.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/ov_core_lib.dir/src/track/TrackAruco.cpp.o] Error 1
make[2]: *** [CMakeFiles/ov_core_lib.dir/src/track/TrackDescriptor.cpp.o] Error 1
make[1]: *** [CMakeFiles/ov_core_lib.dir/all] Error 2
make: *** [all] Error 2
Finally, I use opencv3_catkin master branch build maplab and ov_maplab successfully, who use opencv 3.4.2. thanks for your help @goldbattle
Just now getting back to this. I have added detailed install guide on the specific branch needed and the commands I use to build it: https://github.com/rpng/ov_maplab#installation-commands
# need to fix the opencv to build with a 3.4.x version
cd maplab_dependencies/3rdparty/opencv3_catkin/
git checkout feature/3.4.2
Great work! As you said, openvins use 3.4.6, but maplab use 3.2.0, so how to compile successfully? Thank you!