It may be resulted from the different versions of OpenCV used in ./build.sh and ./build_ros.sh. In ORB_SLAM3/Thirdparty/DBoW2/CMakeLists.txt and ORB_SLAM3/CMakeLists.txt, it requires opencv 4. But in ORB_SLAM3/Examples/ROS/ORB_SLAM3/CMakeLists.txt, it requires opencv 3. I have installed opencv4.1.0 outside and opencv3.3.1 in ros. Finally it leads to the segmentation fault. To solve it, modify CMakeLists.txt to require opencv 3.
亲测有效 !!!记得重新编译