Update app.py
Browse files
app.py
CHANGED
@@ -126,7 +126,27 @@ def infer(url_in,interpolation,fps_output):
|
|
126 |
|
127 |
files = final_vid
|
128 |
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
|
132 |
def logscale(linear):
|
@@ -175,15 +195,16 @@ with gr.Blocks() as demo:
|
|
175 |
with gr.Column():
|
176 |
video_output = gr.Video()
|
177 |
file_output = gr.File()
|
|
|
178 |
|
179 |
gr.Examples(
|
180 |
examples=[["./examples/streetview.mp4", 1, 1]],
|
181 |
fn=infer,
|
182 |
inputs=[url_input,interpolation_slider,fps_output_slider],
|
183 |
-
outputs=[video_output,file_output],
|
184 |
cache_examples=True
|
185 |
)
|
186 |
|
187 |
-
submit_btn.click(fn=infer, inputs=[url_input,interpolation_slider,fps_output_slider], outputs=[video_output, file_output])
|
188 |
|
189 |
demo.launch()
|
|
|
126 |
|
127 |
files = final_vid
|
128 |
|
129 |
+
depth_map = cv2.VideoCapture(final_vid)
|
130 |
+
|
131 |
+
ret, frame1 = depth_map.read()
|
132 |
+
prvs = cv2.cvtColor(frame1, cv2.COLOR_RGB2GRAY)
|
133 |
+
res = np.zeros_like(prvs)
|
134 |
+
while(1):
|
135 |
+
ret, frame2 = depth_map.read()
|
136 |
+
if not ret:
|
137 |
+
print('No frames grabbed!')
|
138 |
+
break
|
139 |
+
next = cv2.cvtColor(frame2, cv2.COLOR_RGB2GRAY)
|
140 |
+
flow = cv2.calcOpticalFlowFarneback(prvs, next, None, 0.5, 3, 15, 3, 5, 1.2, 0)
|
141 |
+
alpha = 0.5
|
142 |
+
beta = (1.0 - alpha)
|
143 |
+
res = cv2.addWeighted(flow, alpha, res, beta, 0.0)
|
144 |
+
prvs = next
|
145 |
+
|
146 |
+
cv2.imwrite('opticalfb.png', res)
|
147 |
+
cv2.destroyAllWindows()
|
148 |
+
|
149 |
+
return final_vid, files, 'opticalfb.png'
|
150 |
|
151 |
|
152 |
def logscale(linear):
|
|
|
195 |
with gr.Column():
|
196 |
video_output = gr.Video()
|
197 |
file_output = gr.File()
|
198 |
+
depth_output = gr.Image(image_mode="L")
|
199 |
|
200 |
gr.Examples(
|
201 |
examples=[["./examples/streetview.mp4", 1, 1]],
|
202 |
fn=infer,
|
203 |
inputs=[url_input,interpolation_slider,fps_output_slider],
|
204 |
+
outputs=[video_output,file_output,depth_output],
|
205 |
cache_examples=True
|
206 |
)
|
207 |
|
208 |
+
submit_btn.click(fn=infer, inputs=[url_input,interpolation_slider,fps_output_slider], outputs=[video_output, file_output, depth_output])
|
209 |
|
210 |
demo.launch()
|