Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to OpenCV4 and fix some build errors #790

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Windfisch
Copy link

Mostly changes or adds #include-statements to account for moved files or missing unistd.h.

IWYU (include what you use) is a tool that automatically determines
which #include statements should be in a source file, to avoid strange
transitive include dependencies that might be fragile
The Tracking class writes entries for each frame in mlRelativeFramePoses,
mlpReferences, mlFrameTimes and mlbLost; these values belong together
logically, so they have been fused into a struct TrackedFrame and a single
list tracked_frames.
@buemi
Copy link

buemi commented Mar 13, 2020

Hi. I still have strange problem using OpenCV4. I receive these messages: [ 62%] Built target ORB_SLAM2
Scanning dependencies of target mono_euroc
[ 65%] Building CXX object CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o
[ 68%] Linking CXX executable ../Examples/Monocular/mono_euroc
CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o: In function cvflann::anyimpl::big_any_policy<cv::String>::static_delete(void**)': mono_euroc.cc:(.text._ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv[_ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv]+0x15): undefined reference to cv::String::deallocate()'
CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o: In function cvflann::anyimpl::big_any_policy<cv::String>::move(void* const*, void**)': mono_euroc.cc:(.text._ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5_[_ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5_]+0x10): undefined reference to cv::String::deallocate()'
mono_euroc.cc:(.text.ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5[ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5]+0x24): undefined reference to cv::String::deallocate()' CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o: In function main':
mono_euroc.cc:(.text.startup+0x398): undefined reference to cv::imread(cv::String const&, int)' mono_euroc.cc:(.text.startup+0x4d8): undefined reference to cv::String::deallocate()'
mono_euroc.cc:(.text.startup+0xa6d): undefined reference to cv::String::allocate(unsigned long)' mono_euroc.cc:(.text.startup+0xd32): undefined reference to cv::String::deallocate()'
../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, double&, double)' ../lib/libORB_SLAM2.so: undefined reference to cv::line(cv::InputOutputArray const&, cv::Point, cv::Point_, cv::Scalar_ const&, int, int, int)'
../lib/libORB_SLAM2.so: undefined reference to cv::rectangle(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::getTextSize(cv::String const&, int, double, int, int*)'
../lib/libORB_SLAM2.so: undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, int&, int)'
../lib/libORB_SLAM2.so: undefined reference to cv::operator<<(cv::FileStorage&, cv::String const&)' ../lib/libORB_SLAM2.so: undefined reference to cv::Mat::diag(cv::Mat const&)'
../lib/libORB_SLAM2.so: undefined reference to cv::write(cv::FileStorage&, cv::String const&, double)' ../lib/libORB_SLAM2.so: undefined reference to cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, float&, float)' ../lib/libORB_SLAM2.so: undefined reference to cv::eigen(cv::InputArray const&, cv::OutputArray const&, cv::OutputArray const&)'
../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, cv::String&, cv::String const&)' ../lib/libORB_SLAM2.so: undefined reference to cv::putText(cv::InputOutputArray const&, cv::String const&, cv::Point, int, double, cv::Scalar
, int, int, bool)'
../lib/libORB_SLAM2.so: undefined reference to cv::namedWindow(cv::String const&, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::write(cv::FileStorage&, cv::String const&, int)'
../lib/libORB_SLAM2.so: undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)' ../lib/libORB_SLAM2.so: undefined reference to cv::FileStorage::operator[](cv::String const&) const'
../lib/libORB_SLAM2.so: undefined reference to cv::circle(cv::_InputOutputArray const&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::InputArray::getMat(int) const'
collect2: error: ld returned 1 exit status
CMakeFiles/mono_euroc.dir/build.make:121: recipe for target '../Examples/Monocular/mono_euroc' failed
make[2]: *** [../Examples/Monocular/mono_euroc] Error 1
CMakeFiles/Makefile2:81: recipe for target 'CMakeFiles/mono_euroc.dir/all' failed
make[1]: *** [CMakeFiles/mono_euroc.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
buemi@CTNCWD7002:~/Antonio/ORB_SLAM2-master/build$ make -j1 >errors.txt
CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o: In function cvflann::anyimpl::big_any_policy<cv::String>::static_delete(void**)': mono_euroc.cc:(.text._ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv[_ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv]+0x15): undefined reference to cv::String::deallocate()'
CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o: In function cvflann::anyimpl::big_any_policy<cv::String>::move(void* const*, void**)': mono_euroc.cc:(.text._ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5_[_ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5_]+0x10): undefined reference to cv::String::deallocate()'
mono_euroc.cc:(.text.ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5[ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE4moveEPKPvPS5]+0x24): undefined reference to cv::String::deallocate()' CMakeFiles/mono_euroc.dir/Examples/Monocular/mono_euroc.cc.o: In function main':
mono_euroc.cc:(.text.startup+0x398): undefined reference to cv::imread(cv::String const&, int)' mono_euroc.cc:(.text.startup+0x4d8): undefined reference to cv::String::deallocate()'
mono_euroc.cc:(.text.startup+0xa6d): undefined reference to cv::String::allocate(unsigned long)' mono_euroc.cc:(.text.startup+0xd32): undefined reference to cv::String::deallocate()'
../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, double&, double)' ../lib/libORB_SLAM2.so: undefined reference to cv::line(cv::InputOutputArray const&, cv::Point, cv::Point
, cv::Scalar const&, int, int, int)'
../lib/libORB_SLAM2.so: undefined reference to cv::rectangle(cv::_InputOutputArray const&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::getTextSize(cv::String const&, int, double, int, int*)'
../lib/libORB_SLAM2.so: undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, int&, int)'
../lib/libORB_SLAM2.so: undefined reference to cv::operator<<(cv::FileStorage&, cv::String const&)' ../lib/libORB_SLAM2.so: undefined reference to cv::Mat::diag(cv::Mat const&)'
../lib/libORB_SLAM2.so: undefined reference to cv::write(cv::FileStorage&, cv::String const&, double)' ../lib/libORB_SLAM2.so: undefined reference to cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, float&, float)' ../lib/libORB_SLAM2.so: undefined reference to cv::eigen(cv::_InputArray const&, cv::_OutputArray const&, cv::OutputArray const&)'
../lib/libORB_SLAM2.so: undefined reference to cv::read(cv::FileNode const&, cv::String&, cv::String const&)' ../lib/libORB_SLAM2.so: undefined reference to cv::putText(cv::InputOutputArray const&, cv::String const&, cv::Point, int, double, cv::Scalar
, int, int, bool)'
../lib/libORB_SLAM2.so: undefined reference to cv::namedWindow(cv::String const&, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::write(cv::FileStorage&, cv::String const&, int)'
../lib/libORB_SLAM2.so: undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)' ../lib/libORB_SLAM2.so: undefined reference to cv::FileStorage::operator[](cv::String const&) const'
../lib/libORB_SLAM2.so: undefined reference to cv::circle(cv::_InputOutputArray const&, cv::Point_<int>, int, cv::Scalar_<double> const&, int, int, int)' ../lib/libORB_SLAM2.so: undefined reference to cv::InputArray::getMat(int) const'
collect2: error: ld returned 1 exit status
make[2]: *** [../Examples/Monocular/mono_euroc] Error 1
make[1]: *** [CMakeFiles/mono_euroc.dir/all] Error 2
make: *** [all] Error 2

@Windfisch
Copy link
Author

you are missing libraries at the linking step.
Figure out, which .so files in /usr/lib/ (or whereever your opencv libs are) have these. Then figure out how to add them to the linking step. (make V=1) should print you the commands, adding them to the last linking step by hand should suffice as a workaround.
Then figure out how to "properly" add this to the cmakefiles.txt.

@buemi
Copy link

buemi commented Mar 20, 2020

Thank you, I really appreciate your help.
Unfortunately, is not clear to me how to add the libraries path to the last linking step, since the CMakeList doesn't seem to directly containing the linker command.

@codieboomboom
Copy link

Thank you, this works awesomely!

@zhuangxiaopi
Copy link

use this work , I find the tracking time are increasing and the tracking precision is downing ,.

@codieboomboom
Copy link

@zhuangxiaopi how did you measure the performance? Was it running on your camera or another rosbag ?

@zhuangxiaopi
Copy link

zhuangxiaopi commented Sep 26, 2020 via email

@collenjones
Copy link

using build.sh I get "ORB_SLAM2/src/ORBmatcher.cc:30:9: fatal error: 'stdint-gcc.h' file not found" - any idea how to fix that?

Are you using GCC? I'm using clang and had to change this to #include <cstdint>

@GSORF
Copy link

GSORF commented Jul 24, 2021

Thank you for this pull request. Works perfectly fine on Ubuntu 20.04 (uname -a: "Linux akp-VirtualBox 5.8.0-59-generic #66~20.04.1-Ubuntu SMP Thu Jun 17 11:14:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux").

Why is this not yet merged in master?

@Windfisch
Copy link
Author

Glad it worked for you. Because this repo seems unmaintained, the maintainer was last seen 2017 :(

@GSORF
Copy link

GSORF commented Jul 24, 2021

Glad it worked for you. Because this repo seems unmaintained, the maintainer was last seen 2017 :(

Yeah I understand that ORB-SLAM3 is superior now and everyone should upgrade. However, many implementations still use ORB-SLAM2, so this is really a pity. Thank YOU for being active and responding quickly, though. Great work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants