ubuntu16.04下realsense+gflw+QT做的3d云点图

前端之家收集整理的这篇文章主要介绍了ubuntu16.04下realsense+gflw+QT做的3d云点图前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

之前发表了一片文章错误的,现在得及时纠正过来。

QT版本是5.5

glfw安装教程:https://blog.csdn.net/parry_liu/article/details/73801097

realsense安装教程:https://blog.csdn.net/Sparta_117/article/details/77851876

一下是官方的例子:

.pro文件

  1. INCLUDEPATH += /usr/local/include \
  1. /usr/local/include/opencv \
  1. /usr/local/include/opencv2\
  1. /usr/local/include/librealsense2\
  1. LIBS += /usr/local/lib/libopencv_calib3d.so \
  1. /usr/local/lib/libopencv_core.so \
  1. /usr/local/lib/libopencv_features2d.so \
  1. /usr/local/lib/libopencv_flann.so \
  1. /usr/local/lib/libopencv_highgui.so \
  1. /usr/local/lib/libopencv_imgcodecs.so \
  1. /usr/local/lib/libopencv_imgproc.so \
  1. /usr/local/lib/libopencv_ml.so \
  1. /usr/local/lib/libopencv_objdetect.so \
  1. /usr/local/lib/libopencv_photo.so \
  1. /usr/local/lib/libopencv_shape.so \
  1. /usr/local/lib/libopencv_stitching.so \
  1. /usr/local/lib/libopencv_superres.so \
  1. /usr/local/lib/libopencv_videoio.so \
  1. /usr/local/lib/libopencv_video.so \
  1. /usr/local/lib/libopencv_videostab.so\
  1. /usr/local/lib/librealsense2.so
  1. LIBS += -lglut -lGLU -lGL\
  1. -lpthread
  1. LIBS+= -L/usr/local/lib -lglfw3

main.cpp文件:

  1. #include <librealsense2/rs.hpp> // Include RealSense Cross Platform API
  1. #include "example.hpp" // Include short list of convenience functions for rendering
  1. #include <algorithm> // std::min, std::max
  1. // Helper functions
  1. void register_glfw_callbacks(window& app, glfw_state& app_state);
  1. int main(int argc, char * argv[]) try
  1. {
  1. // Create a simple OpenGL window for rendering:
  1. window app(1280, 720, "RealSense Pointcloud Example");
  1. // Construct an object to manage view state
  1. glfw_state app_state;
  1. // register callbacks to allow manipulation of the pointcloud
  1. register_glfw_callbacks(app, app_state);
  1. // Declare pointcloud object, for calculating pointclouds and texture mappings
  1. rs2::pointcloud pc;
  1. // We want the points object to be persistent so we can display the last cloud when a frame drops
  1. rs2::points points;
  1. // Declare RealSense pipeline, encapsulating the actual device and sensors
  1. rs2::pipeline pipe;
  1. // Start streaming with default recommended configuration
  1. pipe.start();
  1. while (app) // Application still alive?
  1. {
  1. // Wait for the next set of frames from the camera
  1. auto frames = pipe.wait_for_frames();
  1. auto depth = frames.get_depth_frame();
  1. // Generate the pointcloud and texture mappings
  1. points = pc.calculate(depth);
  1. auto color = frames.get_color_frame();
  1. // Tell pointcloud object to map to this color frame
  1. pc.map_to(color);
  1. // Upload the color frame to OpenGL
  1. app_state.tex.upload(color);
  1. // Draw the pointcloud
  1. draw_pointcloud(app.width(), app.height(), app_state, points);
  1. }
  1. return EXIT_SUCCESS;
  1. }
  1. catch (const rs2::error & e)
  1. {
  1. std::cerr << "RealSense error calling " << e.get_Failed_function() << "(" << e.get_Failed_args() << "):\n " << e.what() << std::endl;
  1. return EXIT_FAILURE;
  1. }
  1. catch (const std::exception & e)
  1. {
  1. std::cerr << e.what() << std::endl;
  1. return EXIT_FAILURE;
  1. }


一个坑

在编译的适合报错了:

  1. /usr/bin/ld: //usr/local/lib/libglfw3.a(vulkan.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
  2. //lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
  3. collect2: error: ld returned 1 exit status
强行百度了一番 发现 .pro文件还要加上
  1. LIBS+=-L/usr/local/lib -lglfw3 -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lGL -lpthread -ldl

就可以执行成功了。

猜你在找的Ubuntu相关文章