-
Notifications
You must be signed in to change notification settings - Fork 12
/
10_GRSD_descriptors.py
59 lines (45 loc) · 1.6 KB
/
10_GRSD_descriptors.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
# @Time : DATE:2021/9/25
# @Author : yan
# @Email : [email protected]
# @File : 10_GRSD_descriptors.py
import pclpy
from pclpy import pcl
import numpy as np
import sys
import matplotlib.pyplot as plt
import pyvista as pv
if __name__ == '__main__':
# 加载点云
cloud = pcl.PointCloud.PointXYZ()
reader = pcl.io.PCDReader()
reader.read("../../data/min_cut_segmentation_tutorial.pcd", cloud)
# 构造法线估计类
ne = pcl.features.NormalEstimation.PointXYZ_Normal()
ne.setInputCloud(cloud)
tree = pcl.search.KdTree.PointXYZ()
ne.setSearchMethod(tree)
cloud_normals = pcl.PointCloud.Normal()
ne.setRadiusSearch(0.3)
# 计算法线
ne.compute(cloud_normals)
# Create the GASD estimation class, and pass the input dataset to it
grsd = pcl.features.GRSDEstimation.PointXYZ_Normal_GRSDSignature21()
grsd.setInputCloud(cloud)
grsd.setRadiusSearch(0.1)
tree = pcl.search.KdTree.PointXYZ()
grsd.setSearchMethod(tree)
grsd.setInputNormals(cloud_normals)
descriptors = pcl.PointCloud.GRSDSignature21()
grsd.compute(descriptors)
plt.plot(descriptors.histogram[0])
plt.show()
viewer = pcl.visualization.PCLVisualizer("3D viewer")
viewer.setBackgroundColor(0, 0, 0)
rgb = pcl.visualization.PointCloudColorHandlerCustom.PointXYZ(cloud, 0.0, 255.0, 0.0)
viewer.addPointCloud(cloud, rgb, "sample cloud")
viewer.setPointCloudRenderingProperties(0, 1, "sample cloud")
viewer.addCoordinateSystem(1)
viewer.initCameraParameters()
while not viewer.wasStopped():
viewer.spinOnce(10)