QT版本是5.5
glfw安装教程:https://blog.csdn.net/parry_liu/article/details/73801097
realsense安装教程:https://blog.csdn.net/Sparta_117/article/details/77851876
一下是官方的例子:
.pro文件:
@H_502_14@INCLUDEPATH += /usr/local/include \ @H_502_14@/usr/local/include/opencv \ @H_502_14@/usr/local/include/opencv2\ @H_502_14@/usr/local/include/librealsense2\ @H_502_14@LIBS += /usr/local/lib/libopencv_calib3d.so \ @H_502_14@/usr/local/lib/libopencv_core.so \ @H_502_14@/usr/local/lib/libopencv_features2d.so \ @H_502_14@/usr/local/lib/libopencv_flann.so \ @H_502_14@/usr/local/lib/libopencv_highgui.so \ @H_502_14@/usr/local/lib/libopencv_imgcodecs.so \ @H_502_14@/usr/local/lib/libopencv_imgproc.so \ @H_502_14@/usr/local/lib/libopencv_ml.so \ @H_502_14@/usr/local/lib/libopencv_objdetect.so \ @H_502_14@/usr/local/lib/libopencv_photo.so \ @H_502_14@/usr/local/lib/libopencv_shape.so \ @H_502_14@/usr/local/lib/libopencv_stitching.so \ @H_502_14@/usr/local/lib/libopencv_superres.so \ @H_502_14@/usr/local/lib/libopencv_videoio.so \ @H_502_14@/usr/local/lib/libopencv_video.so \ @H_502_14@/usr/local/lib/libopencv_videostab.so\ @H_502_14@/usr/local/lib/librealsense2.so @H_502_14@LIBS += -lglut -lGLU -lGL\ @H_502_14@-lpthread @H_502_14@LIBS+= -L/usr/local/lib -lglfw3main.cpp文件:
@H_502_14@#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API @H_502_14@#include "example.hpp" // Include short list of convenience functions for rendering @H_502_14@#include <algorithm> // std::min, std::max @H_502_14@// Helper functions @H_502_14@void register_glfw_callbacks(window& app, glfw_state& app_state); @H_502_14@int main(int argc, char * argv[]) try @H_502_14@{ @H_502_14@ // Create a simple OpenGL window for rendering: @H_502_14@ window app(1280, 720, "RealSense Pointcloud Example"); @H_502_14@ // Construct an object to manage view state @H_502_14@ glfw_state app_state; @H_502_14@ // register callbacks to allow manipulation of the pointcloud @H_502_14@ register_glfw_callbacks(app, app_state); @H_502_14@ // Declare pointcloud object, for calculating pointclouds and texture mappings @H_502_14@ rs2::pointcloud pc; @H_502_14@ // We want the points object to be persistent so we can display the last cloud when a frame drops @H_502_14@ rs2::points points; @H_502_14@ // Declare RealSense pipeline, encapsulating the actual device and sensors @H_502_14@ rs2::pipeline pipe; @H_502_14@ // Start streaming with default recommended configuration @H_502_14@ pipe.start(); @H_502_14@ while (app) // Application still alive? @H_502_14@ { @H_502_14@ // Wait for the next set of frames from the camera @H_502_14@ auto frames = pipe.wait_for_frames(); @H_502_14@ auto depth = frames.get_depth_frame(); @H_502_14@ // Generate the pointcloud and texture mappings @H_502_14@ points = pc.calculate(depth); @H_502_14@ auto color = frames.get_color_frame(); @H_502_14@ // Tell pointcloud object to map to this color frame @H_502_14@ pc.map_to(color); @H_502_14@ // Upload the color frame to OpenGL @H_502_14@ app_state.tex.upload(color); @H_502_14@ // Draw the pointcloud @H_502_14@ draw_pointcloud(app.width(), app.height(), app_state, points); @H_502_14@ } @H_502_14@ return EXIT_SUCCESS; @H_502_14@} @H_502_14@catch (const rs2::error & e) @H_502_14@{ @H_502_14@ std::cerr << "RealSense error calling " << e.get_Failed_function() << "(" << e.get_Failed_args() << "):\n " << e.what() << std::endl; @H_502_14@ return EXIT_FAILURE; @H_502_14@} @H_502_14@catch (const std::exception & e) @H_502_14@{ @H_502_14@ std::cerr << e.what() << std::endl; @H_502_14@ return EXIT_FAILURE; @H_502_14@}@H_502_1180@一个坑
@H_502_1180@在编译的适合报错了:
@H_502_1180@
/usr/bin/ld: //usr/local/lib/libglfw3.a(vulkan.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
强行百度了一番 发现 .pro文件还要加上 :
@H_502_14@LIBS+=-L/usr/local/lib -lglfw3 -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lGL -lpthread -ldl
就可以执行成功了。