安装 PCL 和 OPENCV
1
2
3
brew install pcl
brew install opencv
brew install cloudcompare
CLion 中的 CMakeLists.txt 编写
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
cmake_minimum_required(VERSION 3.21)
project(GlueSeg) # 项目名称
set(CMAKE_CXX_STANDARD 14)
# Opencv 配置
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
# PCL 配置
find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(GlueSeg main.cpp)
# 项目添加 Opencv 和 PCL 的链接
target_link_libraries(GlueSeg ${OpenCV_LIBS} ${PCL_LIBRARIES})
生成点云数据
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
int main ()
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// Fill in the cloud data
cloud.width = 200;
cloud.height = 200;
cloud.is_dense = false;
cloud.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);
}
生成的 pcd 文件可以使用
cloudcompare 软件
打开
参考
写在最后
感谢你在茫茫人海中找到我🕵🏼
🎉你是第 个读者
㊗️ 你平安喜乐,顺遂无忧!
希望你读完有所收获~
🥂🥂🥂