freealise commited on
Commit
05c175b
·
verified ·
1 Parent(s): c465f9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -753,12 +753,29 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
753
  if len(locations) > 0:
754
  avg[0] = avg[0] / len(locations)
755
  avg[1] = avg[1] / len(locations)
756
-
 
 
 
 
 
757
  for k, location in enumerate(locations):
758
  lat = vincenty((location["lat"], 0), (avg[0], 0)) * 1000
759
  lng = vincenty((0, location["lng"]), (0, avg[1])) * 1000
760
  locations[k]["lat"] = float(lat / 2.5 * 111 * np.sign(location["lat"]-avg[0]))
761
  locations[k]["lng"] = float(lng / 2.5 * 111 * np.sign(location["lng"]-avg[1]))
 
 
 
 
 
 
 
 
 
 
 
 
762
  print(locations)
763
  # 2.5m is height of camera on google street view car,
764
  # distance from center of sphere to pavement roughly 255 - 144 = 111 units
@@ -766,7 +783,7 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
766
  # Process the video and get the path of the output video
767
  output_video_path = make_video(uploaded_video,encoder=model_type,blur_data=blurin,o=boffset,b=bsize)
768
 
769
- return output_video_path + (json.dumps(locations),)
770
 
771
  submit.click(on_submit, inputs=[input_video, model_type, blur_in, boffset, bsize, coords], outputs=[processed_video, processed_zip, output_frame, output_mask, output_depth, coords])
772
 
 
753
  if len(locations) > 0:
754
  avg[0] = avg[0] / len(locations)
755
  avg[1] = avg[1] / len(locations)
756
+
757
+ vtt = "WEBVTT\n\n"
758
+ h = [0,0]
759
+ m = [0,0]
760
+ s = [0,1]
761
+
762
  for k, location in enumerate(locations):
763
  lat = vincenty((location["lat"], 0), (avg[0], 0)) * 1000
764
  lng = vincenty((0, location["lng"]), (0, avg[1])) * 1000
765
  locations[k]["lat"] = float(lat / 2.5 * 111 * np.sign(location["lat"]-avg[0]))
766
  locations[k]["lng"] = float(lng / 2.5 * 111 * np.sign(location["lng"]-avg[1]))
767
+
768
+ for l, sec in enumerate(s):
769
+ s[l] = s[l] + 1
770
+ if s[l] == 60:
771
+ s[l] = 0
772
+ m[l] = m[l] + 1
773
+ if m[l] == 60:
774
+ m[l] = 0
775
+ h[l] = h[l] + 1
776
+
777
+ vtt = vtt + str(k+1) + "\n" + str(h[0]).zfill(2) + ":" + str(m[0]).zfill(2) + ":" + str(s[0]).zfill(2) + ".000 --> " + str(h[1]).zfill(2) + ":" + str(m[1]).zfill(2) + ":" + str(s[1]).zfill(2) + ".000\n" + locations[k]["lat"] + "," + locations[k]["lng"] + " " + locations[k]["heading"] + "," + locations[k]["pitch"] + "\n\n"
778
+
779
  print(locations)
780
  # 2.5m is height of camera on google street view car,
781
  # distance from center of sphere to pavement roughly 255 - 144 = 111 units
 
783
  # Process the video and get the path of the output video
784
  output_video_path = make_video(uploaded_video,encoder=model_type,blur_data=blurin,o=boffset,b=bsize)
785
 
786
+ return output_video_path + vtt #(json.dumps(locations),)
787
 
788
  submit.click(on_submit, inputs=[input_video, model_type, blur_in, boffset, bsize, coords], outputs=[processed_video, processed_zip, output_frame, output_mask, output_depth, coords])
789