-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathNormalEstimation.lua
124 lines (102 loc) · 2.93 KB
/
NormalEstimation.lua
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
local ffi = require 'ffi'
local torch = require 'torch'
local utils = require 'pcl.utils'
local pcl = require 'pcl.PointTypes'
local NormalEstimation = torch.class('pcl.NormalEstimation', pcl)
local func_by_type = {}
local function init()
local NormalEstimation_method_names = {
'new',
'delete',
'setInputCloud',
'setIndices',
'getViewPoint',
'setViewPoint',
'useSensorOriginAsViewPoint',
'setSearchMethod_Octree',
'setSearchMethod_KdTree',
'setKSearch',
'getKSearch',
'setRadiusSearch',
'getRadiusSearch',
'compute',
'setNumberOfThreads'
}
for k,v in pairs(utils.type_key_map) do
func_by_type[k] = utils.create_typed_methods("pcl_NormalEstimation_TYPE_KEY_", NormalEstimation_method_names, v)
end
end
init()
function pcl.PointCloud:estimateNormalsK(k, search)
local search = search or pcl.KdTree(self.pointType)
local ne = pcl.NormalEstimation()
ne:setSearchMethod(search)
ne:setKSearch(30)
ne:setInputCloud(self)
return ne:compute()
end
function pcl.PointCloud:estimateNormalsRadius(radius, search)
local search = search or pcl.KdTree(self.pointType)
local ne = pcl.NormalEstimation()
ne:setSearchMethod(search)
ne:setRadiusSearch(radius)
ne:setInputCloud(self)
return ne:compute()
end
function NormalEstimation:__init(pointType)
pointType = pcl.pointType(pointType or pcl.PointXYZ)
rawset(self, 'f', func_by_type[pointType])
self.pointType = pointType
self.o = self.f.new()
end
function NormalEstimation:cdata()
return self.o
end
function NormalEstimation:setInputCloud(cloud)
self.f.setInputCloud(self.o, cloud:cdata())
end
function NormalEstimation:setIndices(indices)
self.f.setIndices(self.o, indices:cdata())
end
function NormalEstimation:getViewPoint()
local pt = torch.FloatTensor()
self.f.getViewPoint(self.o, pt:cdata())
return pt
end
function NormalEstimation:setViewPoint(pt)
self.f.setViewPoint(self.o, pt:cdata())
end
function NormalEstimation:useSensorOriginAsViewPoint()
self.f.useSensorOriginAsViewPoint()
end
function NormalEstimation:setSearchMethod(search)
if torch.isTypeOf(search, pcl.KdTree) then
self.f.setSearchMethod_KdTree(self.o, search:cdata())
elseif torch.isTypeOf(search, pcl.Octree) then
self.f.setSearchMethod_Octree(self.o, search:cdata())
else
error("unsupported search method")
end
end
function NormalEstimation:setKSearch(k)
self.f.setKSearch(self.o, k)
end
function NormalEstimation:getKSearch()
return self.f.getKSearch()
end
function NormalEstimation:setRadiusSearch(radius)
self.f.setRadiusSearch(self.o, radius)
end
function NormalEstimation:getRadiusSearch()
return self.f.getRadiusSearch(self.o)
end
function NormalEstimation:compute(output)
if not output then
output = pcl.PointCloud(pcl.Normal)
end
self.f.compute(self.o, output:cdata())
return output
end
function NormalEstimation:setNumberOfThreads(num_threads)
self.f.setNumberOfThreads(self.o, num_threads)
end