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. Oracle数据库创建与连接

    一.Oracle数据库的安装 1.下载Oracle数据库 网址:Oracle 数据库软件下载 | Oracle 技术网 | Oracle 由于需要注册,所以我就没有采用这种下载方式,  右击该网页查看 ...

  2. Debug - SpringBoot - Error starting ApplicationContext. To display the auto-configuration report re-runyour application

    Error log 2019-12-07 22:33:03.959 ERROR 3760 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ** ...

  3. 【Codeforces Beta Round #88 C】Cycle

    [Link]:http://codeforces.com/problemset/problem/117/C [Description] 问你一张图里面有没有一个三元环,有的话就输出. [Solutio ...

  4. Android中的onWindowFocusChanged()方法详解

    Android中获取手机屏幕的高度和宽度,我们知道在onCreate方法中获取到的值都是为0的,有人说可以在onClick方法中获取值,这个也是个方法 ,但在onWindowFocusChanged方 ...

  5. Android中的Service 与 Thread 的区别

    很多时候,你可能会问,为什么要用 Service,而不用 Thread 呢,因为用 Thread 是很方便的,比起 Service 也方便多了,下面我详细的来解释一下. 1). Thread:Thre ...

  6. Springboot Excle导入导出

    Springboot Excle导入导出 导入操作:Excle批量导入 导出操作:下载模版 开发笔记 pom.xml <!-- Excle相关jar --> <dependency& ...

  7. [bzoj2839]集合计数 题解 (组合数+容斥)

    Description 一个有N个元素的集合有2^N个不同子集(包含空集),现在要在这2^N个集合中取出若干集合(至少一个),使得 它们的交集的元素个数为K,求取法的方案数,答案模1000000007 ...

  8. JSP自定义标签(转)

    1. TagSupport与BodyTagSupport的区别 TagSupport与BodyTagSupport的区别主要是标签处理类是否需要与标签体交互,如果不需要交互的就用TagSupport, ...

  9. (转)Linux 多线程编程---pthread_testcancel()等讲解

    1.   所谓线程就是“一个进程内部的一个控制序列”.也就是一个进程内部的并行的基础! 2.    Linux进程可以看成只有一个控制线程:      一个进程在同一时刻只做一件事情.有了多个控制线程 ...

  10. P1537 弹珠

    P1537 弹珠 题目描述 玛莎和比尔各自有自己的弹珠收藏.他们想重新分配收藏品,使两人能平等拥有弹珠.如果所有的弹珠的价值相同,那么他们就可以平分.但不幸的是,有一些弹珠更大,或者更美丽,所以,玛莎 ...