MCPcopy Create free account
hub / github.com/UVA-Computer-Vision-Lab/FrameINO / process_points

Function process_points

app.py:355–397  ·  view source on GitHub ↗
(traj_list, num_frames=81)

Source from the content-addressed store, hash-verified

353
354
355def process_points(traj_list, num_frames=81):
356
357
358 if len(traj_list) < 2: # First point
359 return [traj_list[0]] * num_frames
360
361 elif len(traj_list) >= num_frames:
362 raise gr.Info("The number of trajectory points is more than limits, we will do cropping!")
363 skip = len(traj_list) // num_frames
364 return traj_list[::skip][: num_frames - 1] + traj_list[-1:]
365
366 else:
367
368 insert_num = num_frames - len(traj_list)
369 insert_num_dict = {}
370 interval = len(traj_list) - 1
371 n = insert_num // interval
372 m = insert_num % interval
373
374 for i in range(interval):
375 insert_num_dict[i] = n
376
377 for i in range(m):
378 insert_num_dict[i] += 1
379
380 res = []
381 for i in range(interval):
382 insert_points = []
383 x0, y0 = traj_list[i]
384 x1, y1 = traj_list[i + 1]
385
386 delta_x = x1 - x0
387 delta_y = y1 - y0
388 for j in range(insert_num_dict[i]):
389 x = x0 + (j + 1) / (insert_num_dict[i] + 1) * delta_x
390 y = y0 + (j + 1) / (insert_num_dict[i] + 1) * delta_y
391 insert_points.append([int(x), int(y)])
392
393 res += traj_list[i : i + 1] + insert_points
394 res += traj_list[-1:]
395
396 # return
397 return res
398
399
400

Callers 1

fn_vis_realtime_trajFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected