惠州营销网站建设公司,灰色行业seo大神,椒江建设网保障性阳光工程网站,网站建设域名费写在前面 本文内容 以PCL 1.14.0#xff0c;Open3D0.14.1为例#xff0c;对基于PCL、Open3D开发的代码进行源码debug#xff1b; 如何学习、上手点云算法系列#xff1a; 如何学习、上手点云算法(一)#xff1a;点云基础 如何学习、上手点云算法(二)#xff1a;点云处理相…写在前面 本文内容 以PCL 1.14.0Open3D0.14.1为例对基于PCL、Open3D开发的代码进行源码debug 如何学习、上手点云算法系列 如何学习、上手点云算法(一)点云基础 如何学习、上手点云算法(二)点云处理相关开源算法库、软件、工具 如何学习、上手点云算法(三)用VsCode、Visual Studio来debug基于PCL、Open3D的代码 更多点云基础、算法相关内容请关注专栏 点云处理基础 点云配准(PointCloud Registration) Open3D点云处理 PCL点云处理 点云算法 平台/环境 Windows10, CMake, Open3D, PCL 转载请注明出处 https://blog.csdn.net/qq_41102371/article/details/136504094 目录 写在前面PCL准备编译debug版本配置launch.jsonVisual Studio Open3D准备添加open3d测试调试 参考完 PCL
准备
安装PCL1.14.0: PCL1.14.0安装、使用教程 VsCode配置PCL: VsCode配置PCL、Open3D自动补全 在此基础上下载debug需要的pdb文件https://github.com/PointCloudLibrary/pcl/releases
打开压缩包 将pdb文件复制到之前装PCL的bin路径下我这里是 D:\carlos\install\PCL 1.14.0\bin
注PDB文件的作用见vs2019配置opencvcontrib-440 PCL1.10.0 源码单步调试
编译debug版本
在VsCode配置PCL、Open3D自动补全和的基础上新建一个compile_debug.bat:
cmake -DCMAKE_BUILD_TYPEDebug ^
-DPCL_DIRD:/carlos/install/PCL 1.14.0/cmake ^
-S ./ -B ./build_debugcmake --build ./build_debug --config Debug --target ALL_BUILD然后使用compile_debug.bat进行编译完了会自动生成build_debug
配置launch.json
创建launch 添加配置 修改配置 program就是我们debug的程序对象environment就是为当前程序添加PCL的环境变量让其能找到PCL、VTK、FLANN等的动态库(.dll) 示例
{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid830387version: 0.2.0,configurations: [{name: (Windows) Launch,type: cppvsdbg,request: launch,program: ${workspaceFolder}/build_debug/Debug/statistical_removal.exe,args: [],stopAtEntry: false,cwd: ${fileDirname},environment: [{name: PATH,value: D:/carlos/install/PCL 1.14.0/bin;D:/carlos/install/PCL 1.14.0/3rdParty/FLANN/bin;D:/carlos/install/PCL 1.14.0/3rdParty/VTK/bin;D:/carlos/install/PCL 1.14.0/3rdParty/Qhull/bin;D:/carlos/install/PCL 1.14.0/3rdParty/OpenNI2/Tools;$(PATH)}],console: externalTerminal}]
}在statistical_removal.cpp中随便加一个断点然后使用F5或者右上角的Debug C/C File 开始debug 然后就可以看到程序运行到了断点处左侧有变量状态自己添加监控线程的显示
Visual Studio
打开文件夹找到.sln文件双击打开 鼠标右键将statistical_removal设置为启动项目 再点开最下面的属性Debug–调试–环境–编辑输入
PATH;D:\carlos\install\PCL 1.14.0\bin;
D:\carlos\install\PCL 1.14.0\3rdParty\FLANN\bin;
D:\carlos\install\PCL 1.14.0\3rdParty\VTK\bin;
D:\carlos\install\PCL 1.14.0\3rdParty\Qhull\bin;
D:\carlos\install\PCL 1.14.0\3rdParty\OpenNI2\Tools;
$(PATH)确定
Open3D
准备
Open3D没有像PCL提供Debug版的lib和对应的pdb文件需要自己编译在Open3D0.14.1编译、安装、demo使用教程中我们已经编译好了debug版本现在需要去build_debug/lib/Debug中找到pdb文件 然后将pdb文件复制到install的目录中
添加open3d测试
在上面PCL示例project中我们添加一个open3d的测试在编译脚本中添加open3d的debug版的路径 compile_debug.bat:
cmake -DCMAKE_BUILD_TYPEDebug ^
-DPCL_DIRD:/carlos/install/PCL 1.14.0/cmake ^
-DOpen3D_DIRD:/carlos/install/open3d141_d/CMake ^
-S ./ -B ./build_debugcmake --build ./build_debug --config Debug --target ALL_BUILD添加一个测试代码test_open3d.cpp该代码作用是平面拟合并把拟合出的平面与剩下点云用不同颜色显示
#include open3d/Open3D.hint main()
{std::shared_ptropen3d::geometry::PointCloud pcd(new open3d::geometry::PointCloud);open3d::io::ReadPointCloud(./table_scene_lms400.pcd, *pcd);pcd-SegmentPlane();pcd-PaintUniformColor({1, 0, 0});open3d::visualization::DrawGeometries({pcd});return 0;
}修改CMakeLists.txt
cmake_minimum_required(VERSION 3.18)project(statistical_removal)# PCL
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
# PCL test
add_executable(statistical_removal statistical_removal.cpp)
target_link_libraries(statistical_removal ${PCL_LIBRARIES})# Open3D
option(STATIC_WINDOWS_RUNTIME Use static (MT/MTd) Windows runtime ON)
if(STATIC_WINDOWS_RUNTIME)set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$$CONFIG:Debug:Debug)
else()set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$$CONFIG:Debug:DebugDLL)
endif()
find_package(Open3D REQUIRED)
include_directories(${Open3D_INCLUDE_DIRS})# Open3D test
add_executable(test_open3d test_open3d.cpp)
target_link_libraries(test_open3d ${Open3D_LIBRARIES})然后使用compile_debug.bat进行编译
调试
修改launch.json
{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid830387version: 0.2.0,configurations: [{name: (Windows) Launch,type: cppvsdbg,request: launch,// program: ${workspaceFolder}/build_debug/Debug/statistical_removal.exe,program: ${workspaceFolder}/build_debug/Debug/test_open3d.exe,args: [],stopAtEntry: false,cwd: ${fileDirname},environment: [{name: PATH,value: D:/carlos/install/PCL 1.14.0/bin;D:/carlos/install/PCL 1.14.0/3rdParty/FLANN/bin;D:/carlos/install/PCL 1.14.0/3rdParty/VTK/bin;D:/carlos/install/PCL 1.14.0/3rdParty/Qhull/bin;D:/carlos/install/PCL 1.14.0/3rdParty/OpenNI2/Tools;$(PATH)}],console: externalTerminal}]
}在源码添加断点开始调试 平面分割结果可视化
用Visual Studio debug参照上面PCL示例打开.sln设置启动项 但是Open3D是静态库所以不用设置环境变量就可以了另外用Visual Studio调试前把代码中点云读取路径改成绝对路径再重新编译一下不然会找不到点云
参考
https://code.visualstudio.com/docs/cpp/launch-json-reference 其余文中已列出
完
主要做激光/影像三维重建配准、分割等常用点云算法熟悉open3d、pcl等开源点云库技术交流、咨询可私信