0 引言

最近在VSCode下搞开发,于是将pcl库迁移到这个环境下,用来跑一些依赖pcl的开源的代码以及自己做一些快速开发等。

1 pcl编译

主要参考了这篇博客,链接如下。

https://blog.csdn.net/e_small/article/details/79581484

我编译时遇到的主要问题也是在这篇博客的留言下解决的。我安装了Anaconda,结果编译出错,我还一直找不着错哪儿了。。。解决方式记录如下。

$ sudo gedit ~/.bashrc   # 打开环境变量文件 将Anaconda的环境变量给注销掉
$ source /etc/profile # 使环境变量生效
$ python # 测试目前系统默认的python是不是改正了

然后再重新编译。

另外,在编译时,我改变了CMakeList.txt中的配置,采用的方式是

$ mkdir build
$ cd build
$ cmake-gui .. # 打开cmake界面,把一些不需要编译的东西去掉(比如我为了提高编译成功率,去掉了cuda选项),客户端点击configuration-》 generation 即可完成cmake,再回到终端继续make
$ make -j8 # 采用8个线程同时进行编译,有时候可以极大提高编译速度
$ sudo make install # 安装,该命令将pcl库的头文件、动态链接库文件、静态链接库文件和其他文件拷贝到/usr 的各个子目录下

2 opencv 编译

参考如下链接。

https://www.cnblogs.com/darkknightzh/p/5638117.html

3 VSCode下pcl配置文件编写

直接把自己的配置文件贴出来给大家看好了。

 lauch.json

{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",       
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask":"build",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

tasks.json

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks":[ // 可以有多个参数
{
"label": "build", // 编译任务名
"type": "shell", // 编译任务的类型,通常为shell/process类型
"command": "g++", // 编译命令
"args":[
"-g",
"${workspaceFolder}/${fileBasename}", // include path指令
"-I", "/usr/local/include/pcl-1.8",
"-I", "/usr/include/eigen3",
"-I", "/usr/include/vtk-5.10",
"-I", "/usr/include/qhull",
"-I", "/usr/include/flann",
"-I", "/usr/include/boost",
// lib 库文件地址
"-L", "/usr/local/lib",
"-l", "pcl_io",
"-l", "pcl_visualization",
"-l", "pcl_common",
"-l", "vtkFiltering",
"-l", "vtkCommon",
"-l", "vtkRendering",
"-l", "vtkGraphics",
"-L", "/usr/include/x86_64-linux-gnu",
"-l", "boost_system",
"-o", // 生成指定名称的可执行文件
"${workspaceFolder}/${fileBasenameNoExtension}.out"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "cmakebuild",
"type": "shell",
"command": "cd build && cmake ../ && make",
"args": []
}
]
}

其中,采用cmake方式进行编译时的CMakeLists.txt文件是这样写的。

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(myPCLProject)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS}) add_executable (cloud_viewer cloud_viewer.cpp)
target_link_libraries (cloud_viewer ${PCL_LIBRARIES})

c_cpp_properties.json,主要是给intelliSense看的,避免写代码时,intelliSense瞎比划红线报错。

{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}",
"/usr/local/include/pcl-1.8",
"/usr/include",
"/usr/include/vtk-5.10",
"/usr/include/qhull",
"/usr/include/flann",
"/usr/include/boost",
"/usr/include/eigen3",
"/usr/include/eigen3/Eigen/",
"/usr/include/x86_64-linux-gnu/sys"
],
"defines": [],
"browse":{
"path":[
"/usr/include",
"/usr/local/include/pcl-1.8"
]
},
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version":
}

3 测试代码

是官网的一段可视化代码,展示如下。

#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/cloud_viewer.h> int user_data;
void
viewerOneOff (pcl::visualization::PCLVisualizer& viewer)
{
viewer.setBackgroundColor (0.0, 0.0, 0.0);
pcl::PointXYZ o;
o.x = 1.0;
o.y = ;
o.z = ;
viewer.addSphere (o, 0.25, "sphere", );
std::cout << "i only run once" << std::endl;
} void
viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
{
static unsigned count = ;
std::stringstream ss;
ss << "Once per viewer loop: " << count++;
viewer.removeShape ("text", );
viewer.addText (ss.str(), , , "text", ); //FIXME: possible race condition here:
user_data++;
} int
main ()
{
//pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile ("bun4.pcd", *cloud); pcl::visualization::CloudViewer viewer("Cloud Viewer"); //blocks until the cloud is actually rendered
viewer.showCloud(cloud); //use the following functions to get access to the underlying more advanced/powerful
//PCLVisualizer //This will only get called once
viewer.runOnVisualizationThreadOnce (viewerOneOff); //This will get called once per visualization iteration
viewer.runOnVisualizationThread (viewerPsycho);
while (!viewer.wasStopped ())
{
//you can also do cool processing here
//FIXME: Note that this is running in a separate thread from viewerPsycho
//and you should guard against race conditions yourself...
user_data++;
}
return ;
}

4 效果图

        

50 ubuntu下pcl编译以及用 VSCode配置pcl / opencv开发环境的更多相关文章

  1. Mac上利用VScode配置c/c++开发环境

    Mac上利用VScode配置c/c++开发环境 哭辽,Typora里面最好不要插入表情,不然保存会闪退 首先你要有一个vscode 在扩展里面下载c/c++ 第一步 ⬆+com+p 打开命令模式:选择 ...

  2. 在windows下用eclipse + pydev插件来配置python的开发环境

    在windows下用eclipse + pydev插件来配置python的开发环境 一.安装 python 可以到网上下个Windows版的python,官网为:https://www.python. ...

  3. VsCode配置C/C++开发环境

    Visual Studio Code(VS Code)是基于 Electron 开发,支持 Windows.Linux 和 macOS 操作系统.内置了对JavaScript,TypeScript和N ...

  4. Mac OS中使用VScode配置C语言开发环境

    个人博客 chinazt.cc 闲话少叙,直奔主题 下载VSCode https://code.visualstudio.com/download 安装C/C++插件 需要两个插件: 1. cppto ...

  5. vscode配置java+gradle开发环境

    1.安装扩展包Java Extension Pack,里面包含java开发所必须的扩展 2.安装java jdk,8版本就是1.8版本,根据需要安装不同的版本 3.下载gradle,将bin文件夹添加 ...

  6. ubuntu下boost编译安装

    ubuntu下boost编译安装 boost 安装 1.依赖安装 apt-get install mpi-default-dev libicu-dev python-dev python3-dev l ...

  7. ubuntu下如何编译C语言

    ubuntu下如何编译C语言     如果没有gcc编译器的话,使用以下命令获取 ~# sudo apt-get install gcc同时要下载辅助工具 ~# sudo apt-get instal ...

  8. Ubuntu下配置C/C++开发环境

    在 Ubuntu 下配置 C/C++ 开发环境 转自:白巴的临时空间 Submitted by 白巴 on 2009-04-27 19:52:12. 学习笔记 虽然 Ubuntu 的版本已经是9.04 ...

  9. ubuntu下整合eclipse和javah生成jni头文件开发android的native程序

    0:前言: 这两天一直在研究用android的jni调用第三方库,上网搜方法,但是都是泛泛而谈,没有demo,经过我几番折磨,写了n多的helloword工程,总是不成功,工程名字也就由helloow ...

随机推荐

  1. linux挂载群辉的NFS共享文件夹

    mount -t nfs 192.168.137.136:/volume1/NFSfile /NFSfile -o proto=tcp -o nolock  df -h   #查看挂载点    

  2. spring 新建mybatis ...

    一. 创建bean类 package com.feilong.blog.dao; public class Message { private int id; private String autho ...

  3. Packet for query is too large (1986748 > 1048576). You can change this value on the server by 异常

    场景:mybatis动态拼接,批量添加数据,因为数据太多,凭借过多,导致MySql数据库中插入大于1m的数据时,提示该异常. 解决办法:修改mysql的属性 max_allowed_packet即可. ...

  4. vue 多选框 checkbox 父到子传值

    vue多选功能, 修改时选中的状态不能从当前组件中得到,从父组件中传过来. 这里 新增和修改封装了一个组件,在点击确定按钮后,会发送新增或修改请求,重新渲染页面.但是在点击[新增]/ [修改]按钮时, ...

  5. OpenGL Download

    { https://www.opengl.org/ }

  6. Delphi实现获取句柄并发送消息的方法(FindWindow、FindWindowEx、EnumChildWindows、SendMessage)

    Delphi实现获取句柄并发送消息的方法 本文以实例形式详细说明了Delphi获取句柄并发送消息的方法,具体用法说明如下: 查找另外一个窗口的句柄: handle := FindWindow(nil, ...

  7. HTML5的新增功能有哪些?

    HTML5 将成为 HTML.XHTML 以及 HTML DOM 的新标准. 新的功能: 1.用于绘画的 canvas 元素 2.用于媒介回放的 video 和 audio 元素 3.对本地离线存储的 ...

  8. Repeatable Read

    在Repeatable Read隔离级别下,一个事务可能会遇到幻读(Phantom Read)的问题. 幻读是指,在一个事务中,第一次查询某条记录,发现没有,但是,当试图更新这条不存在的记录时,竟然能 ...

  9. 【LeetCode 26】删除排序数组中的重复项

    题目链接 [题解] 沙比提 [代码] class Solution { public: int removeDuplicates(vector<int>& nums) { if ( ...

  10. STL————bitset

    C++的 bitset 在 bitset 头文件中,它是一种类似数组的结构,它的每一个元素只能是0或1,每个元素仅用1bit空间. bitset<> bitset1; //无参构造,长度为 ...