Skip to content

Commit 5957309

Browse files
Pandorolucasb-eyer
authored andcommitted
Added a function similiar to generate_cut_outs which just generates raw cutouts.
1 parent 2b063e9 commit 5957309

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

__init__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,32 @@ def generate_cut_outs(scan, standard_depth=4.0, window_size=48, threshold_distan
288288
cut_outs[i,:] = scipy.interpolate.interp1d(np.linspace(0,1, num=len(window), endpoint=True), window, assume_sorted=True, copy=False, **kw)(np.linspace(0,1,num=npts, endpoint=True))
289289

290290
return cut_outs
291+
292+
293+
def generate_cut_outs_raw(scan, window_size=48, border=29.99):
294+
'''
295+
Generate window cut outs that all have a fixed number of rays independent of depth.
296+
This means objects close to the scanner will cover more rays and those far away fewer.
297+
All cut outs will contain the raw values from the input scan.
298+
299+
- `scan` an iterable of radii within a laser scan.
300+
- `window_size` the window of laser rays that will be extracted everywhere.
301+
- `border` the radius value to fill the half of the outermost windows with.
302+
'''
303+
s_np = np.fromiter(iter(scan), dtype=np.float32)
304+
N = len(s_np)
305+
306+
cut_outs = np.zeros((N, window_size), dtype=np.float32)
307+
308+
start = -window_size//2 + np.arange(N)
309+
end = start + window_size
310+
s_np_extended = np.append(s_np, border)
311+
312+
for i in range(N):
313+
# Get the window.
314+
sample_points = np.arange(start[i], end[i])
315+
sample_points[sample_points < 0] = -1
316+
sample_points[sample_points >= N] = -1
317+
cut_outs[i,:] = s_np_extended[sample_points]
318+
319+
return cut_outs

0 commit comments

Comments
 (0)