For your own reference, segment errors are usually caused by accessing illegal memory. In your case, the problem seems to be related to the cv::getTextSize() function.
Here are some possible solutions:
Check that the input parameters are correct: cv::getTextSize() requires arguments such as the string, font, font scale, and line width. If these arguments are incorrect, a segment error will result. Make sure you pass the correct parameters.
Check the version of the OpenCV library: When using the OpenCV library, make sure you are using the ORB_SLAM2 compatible version. If you install OpenCV 4.0, but ORB_SLAM2 needs OpenCV 3.0 or earlier, it can cause segment errors. You can try demoting OpenCV to version 3.0 and then recompiling ORB_SLAM2.
Check the code logic: In addition to the cv::getTextSize() function, other code logic may be causing the segment error. You can use gdb or other debugging tools to find the location of segment errors and step through them.
Check hardware resources: When ORB_SLAM2 runs, make sure your computer's hardware resources are adequate. Segment errors can also occur if your computer is low on memory or CPU.
Hope you find these solutions helpful!