(points)
| 43 | blur_kernel = bivariate_Gaussian(99, 10, 10, 0, grid=None, isotropic=True) |
| 44 | |
| 45 | def process_points(points): |
| 46 | frames = 16 |
| 47 | defualt_points = [[512,512]]*16 |
| 48 | |
| 49 | if len(points) < 2: |
| 50 | return defualt_points |
| 51 | elif len(points) >= frames: |
| 52 | skip = len(points)//frames |
| 53 | return points[::skip][:15] + points[-1:] |
| 54 | else: |
| 55 | insert_num = frames - len(points) |
| 56 | insert_num_dict = {} |
| 57 | interval = len(points) - 1 |
| 58 | n = insert_num // interval |
| 59 | m = insert_num % interval |
| 60 | for i in range(interval): |
| 61 | insert_num_dict[i] = n |
| 62 | for i in range(m): |
| 63 | insert_num_dict[i] += 1 |
| 64 | |
| 65 | res = [] |
| 66 | for i in range(interval): |
| 67 | insert_points = [] |
| 68 | x0,y0 = points[i] |
| 69 | x1,y1 = points[i+1] |
| 70 | |
| 71 | delta_x = x1 - x0 |
| 72 | delta_y = y1 - y0 |
| 73 | for j in range(insert_num_dict[i]): |
| 74 | x = x0 + (j+1)/(insert_num_dict[i]+1)*delta_x |
| 75 | y = y0 + (j+1)/(insert_num_dict[i]+1)*delta_y |
| 76 | insert_points.append([int(x), int(y)]) |
| 77 | |
| 78 | res += points[i:i+1] + insert_points |
| 79 | res += points[-1:] |
| 80 | return res |
| 81 | |
| 82 | def get_flow(points, video_len=16): |
| 83 | optical_flow = np.zeros((video_len, 256, 256, 2), dtype=np.float32) |
no outgoing calls
no test coverage detected