MCPcopy Create free account
hub / github.com/MetaSLAM/SphereVLAD / LaserProjection

Class LaserProjection

utils/pointProcess.py:47–202  ·  view source on GitHub ↗

Class that contains LaserScan with x,y,z,r

Source from the content-addressed store, hash-verified

45
46
47class LaserProjection(object):
48 """Class that contains LaserScan with x,y,z,r"""
49
50 def __init__(self, device, top_size=[64, 64], z_range=[-100.0, 100.0], sph_size=[64, 64], fov_range=[-90, 90], max_dis=30, sph_ocu=16, visib_thresh=3.0, visib_radius=25):
51 #! For top down view
52 self.proj_H = (int)(top_size[0]/2)
53 self.proj_W = (int)(top_size[1]/2)
54 self.proj_Z_min = z_range[0]
55 self.proj_Z_max = z_range[1]
56
57 self.device = device
58
59 #! For spherical view
60 self.sph_H = sph_size[0]
61 self.sph_W = sph_size[1]
62 self.sph_down = fov_range[0]
63 self.sph_up = fov_range[1]
64
65 #! Set sph occlusion factor
66 self.sph_ocu = sph_ocu
67
68 #! For activate range
69 self.max_dis = max_dis
70
71 self.visib_thresh = visib_thresh
72 self.visib_radius = visib_radius
73
74 def proj(self, pt):
75 sph_proj = self.do_sph_projection(pt)
76 sph_proj = sph_proj.reshape([1, self.sph_H, self.sph_W])
77 sph_proj = torch.from_numpy(sph_proj).to(
78 self.device, dtype=torch.float)
79 return sph_proj
80
81 def proj_img(self, pt):
82 sph_proj = self.do_sph_projection(pt)
83 sph_proj = sph_proj.reshape([self.sph_H, self.sph_W, 1])
84 return sph_proj
85
86 def do_top_projection(self, points):
87 """ Project a pointcloud into a BEV picture
88 """
89
90 # get scan components
91 scan_x = points[:, 0]
92 scan_y = points[:, 1]
93 scan_z = points[:, 2]
94
95 # get projections in image coords
96 proj_x = scan_x/self.max_dis
97 proj_y = scan_y/self.max_dis
98
99 # scale to image size using angular resolution
100 proj_x = (proj_x + 1.0)*self.proj_W # in [0.0, 2W]
101 proj_y = (proj_y + 1.0)*self.proj_H # in [0.0, 2H]
102
103 # round and clamp for use as index
104 proj_x = np.floor(proj_x)

Callers 2

__init__Method · 0.90
generate_dataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected