PCL可视化的时候偶尔会出现这样的,报错如下:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
Linx: ../../src/xcb_io.c:260: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
但是这个错误最搞人心态的是好像跟程序无关,多运行几次就能正常可视化🙃
上网搜索之后采用以下方案
先安装个包
sudo apt-get install libx11-dev
然后在头文件处增加
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
// 记得增加在Opencv头文件位置之后
#include <X11/Xlib.h>
在main函数中第一行增加
main()
{
XInitThreads();
}
在CMakeLists.txt文件里target增加 -lX11
有这样加的
target_link_libraries(Project_name -lX11)
也有这样加的,不是很懂,但是在这加默认会链接 -l
+X11
target_link_libraries(Project_name
${ABSOLUTE_TARGET_LIB} ${PCL_LIBRARIES} libpthread.so X11 ${OpenCV_LIBS} ${CLOUD_VIEWER} )
好像这样做了之后还是会偶然出现,有大佬知道怎么解决的希望可以评论一下,感恩🤞