(num_frames, x, y, z, path_type='')
| 27 | from collections import namedtuple |
| 28 | |
| 29 | def path_planning(num_frames, x, y, z, path_type=''): |
| 30 | if path_type == 'straight-line': |
| 31 | corner_points = np.array([[0, 0, 0], [(0 + x) * 0.5, (0 + y) * 0.5, (0 + z) * 0.5], [x, y, z]]) |
| 32 | corner_t = np.linspace(0, 1, len(corner_points)) |
| 33 | t = np.linspace(0, 1, num_frames) |
| 34 | cs = interp1d(corner_t, corner_points, axis=0, kind='quadratic') |
| 35 | spline = cs(t) |
| 36 | xs, ys, zs = [xx.squeeze() for xx in np.split(spline, 3, 1)] |
| 37 | elif path_type == 'double-straight-line': |
| 38 | corner_points = np.array([[-x, -y, -z], [0, 0, 0], [x, y, z]]) |
| 39 | corner_t = np.linspace(0, 1, len(corner_points)) |
| 40 | t = np.linspace(0, 1, num_frames) |
| 41 | cs = interp1d(corner_t, corner_points, axis=0, kind='quadratic') |
| 42 | spline = cs(t) |
| 43 | xs, ys, zs = [xx.squeeze() for xx in np.split(spline, 3, 1)] |
| 44 | elif path_type == 'circle': |
| 45 | xs, ys, zs = [], [], [] |
| 46 | for frame_id, bs_shift_val in enumerate(np.arange(-2.0, 2.0, (4./num_frames))): |
| 47 | xs += [np.cos(bs_shift_val * np.pi) * 1 * x] |
| 48 | ys += [np.sin(bs_shift_val * np.pi) * 1 * y] |
| 49 | zs += [np.cos(bs_shift_val * np.pi/2.) * 1 * z] |
| 50 | xs, ys, zs = np.array(xs), np.array(ys), np.array(zs) |
| 51 | |
| 52 | return xs, ys, zs |
| 53 | |
| 54 | def open_small_mask(mask, context, open_iteration, kernel): |
| 55 | np_mask = mask.cpu().data.numpy().squeeze().astype(np.uint8) |
no outgoing calls
no test coverage detected