Update app.py
Browse files
app.py
CHANGED
|
@@ -118,21 +118,6 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
|
|
| 118 |
if idx < len(frames_list) - 1:
|
| 119 |
next_frame = frames_list[idx+1]
|
| 120 |
|
| 121 |
-
rgb = cv2.imread(frame).astype(np.uint8)
|
| 122 |
-
next_rgb = cv2.imread(next_frame).astype(np.uint8)
|
| 123 |
-
diff_f = np.abs(rgb - next_rgb)
|
| 124 |
-
diff = np.abs(rgb - bg)
|
| 125 |
-
|
| 126 |
-
lo = np.array([0,0,0])
|
| 127 |
-
hi = np.array([16,16,16])
|
| 128 |
-
mask_f = cv2.inRange(diff_f, lo, hi)
|
| 129 |
-
mask = cv2.inRange(diff, lo, hi)
|
| 130 |
-
m = cv2.bitwise_and(mask_f, mask)
|
| 131 |
-
rgb[m>0] = (255,255,255)
|
| 132 |
-
next_rgb[m>0] = (255,255,255)
|
| 133 |
-
cv2.imwrite(frame, rgb)
|
| 134 |
-
cv2.imwrite(next_frame, next_rgb)
|
| 135 |
-
|
| 136 |
interpolated_frames = do_interpolation(frame, next_frame, interpolation) # should return a list of 3 interpolated frames
|
| 137 |
break_interpolated_video = get_frames(interpolated_frames, "interpol", f"{idx}_", 0)
|
| 138 |
print(break_interpolated_video[0])
|
|
@@ -183,10 +168,18 @@ def infer(url_in,interpolation,fps_output,resize_n,winsize,o_flow):
|
|
| 183 |
alpha = 1.0/len(result_frames)
|
| 184 |
beta = (1.0 - alpha)
|
| 185 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
depth_frames.append(f"opticalfb{i}.png")
|
|
|
|
| 190 |
i+=1
|
| 191 |
prvs = nxt
|
| 192 |
|
|
|
|
| 118 |
if idx < len(frames_list) - 1:
|
| 119 |
next_frame = frames_list[idx+1]
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
interpolated_frames = do_interpolation(frame, next_frame, interpolation) # should return a list of 3 interpolated frames
|
| 122 |
break_interpolated_video = get_frames(interpolated_frames, "interpol", f"{idx}_", 0)
|
| 123 |
print(break_interpolated_video[0])
|
|
|
|
| 168 |
alpha = 1.0/len(result_frames)
|
| 169 |
beta = (1.0 - alpha)
|
| 170 |
res = cv2.addWeighted(rgb, alpha, res, beta, 0.0, res)
|
| 171 |
+
rgb = cv2.cvtColor(rgb, cv2.COLOR_GRAY2RGB)
|
| 172 |
+
|
| 173 |
+
lo = np.array([0,0,0])
|
| 174 |
+
hi = np.array([16,16,16])
|
| 175 |
+
mask = cv2.inRange(rgb, lo, hi)
|
| 176 |
+
#m = cv2.bitwise_and(mask_f, mask)
|
| 177 |
+
#diff = np.abs(rgba - bg)
|
| 178 |
+
fr1[mask>0] = (255,255,255,255)
|
| 179 |
+
|
| 180 |
+
cv2.imwrite(f"opticalfb{i}.png", fr1)
|
| 181 |
depth_frames.append(f"opticalfb{i}.png")
|
| 182 |
+
|
| 183 |
i+=1
|
| 184 |
prvs = nxt
|
| 185 |
|