在自己的项目中使用PCL

发布时间:2022-07-04 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了在自己的项目中使用PCL脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

在自己的项目中使用PCL项目设置:1、创建cpp文件,如pcd_write.cpp,文件内容如下例:

#include <iostream>#include <pcl/io/pcd_io.h>#include <pcl/point_types.h>int main (int argc, char** argv){ pcl::PointCloud<pcl::PointXYZ> cloud; // Fill in the cloud data cloud.width = 5; cloud.height = 1; cloud.is_dense = false; cloud.points.resize (cloud.width * cloud.height); for (auto& point: cloud) { point.x = 1024 * rand () / (RAND_MAX + 1.0f); point.y = 1024 * rand () / (RAND_MAX + 1.0f); point.z = 1024 * rand () / (RAND_MAX + 1.0f); } pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud); std::cerr << "Saved " << cloud.size () << " data points to test_pcd.pcd." << std::endl; for (const auto& point: cloud) std::cerr << " " << point.x << " " << point.y << " " << point.z << std::endl; return (0);}2、创建txt文件,如CMakeLists.txt,文件内容如下例:cmake_minimum_required(VERSION 2.6 FATAL_ERROR)project(MY_GRAND_PROJECT)find_package(PCL 1.3 REQUIRED COMPONENTS common io)include_directories(${PCL_INCLUDE_DIRS})link_directories(${PCL_LIBRARY_DIRS})add_definitions(${PCL_DEFINITIONS})add_executable(pcd_write_test pcd_write.cpp)target_link_libraries(pcd_write_test ${PCL_LIBRARIES})3、创建名为build的文件夹,通过终端在cpp文件夹里输入如下指令:mkdir build 在build文件夹下终端中输入:cmake .. 完成后输入:make 生成可执行文件,输入:./pcd_write 可生成pcd文件,我们可以使用pcd viewer工具来打开pcd文件,指令为:pcl_viewer test_pcd.pcd

 

小总结:在自己的项目中使用pcl还需勤加练习,熟悉基本流程后,方能大展拳脚 嘿嘿~

脚本宝典总结

以上是脚本宝典为你收集整理的在自己的项目中使用PCL全部内容,希望文章能够帮你解决在自己的项目中使用PCL所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: