freealise commited on
Commit
13d584d
1 Parent(s): 3d0dbc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -611,19 +611,26 @@ with gr.Blocks(css=css) as demo:
611
  def on_submit(uploaded_video,model_type,coordinates):
612
  global locations
613
  locations = []
 
614
 
615
  if not coordinates:
616
  locations = json.loads(example_coords)
617
  for k, location in enumerate(locations):
618
  locations[k] = location["latLng"]
619
- locations[k]["lat"] = locations[k]["lat"] - locations[0]["lat"]
620
- locations[k]["lng"] = locations[k]["lng"] - locations[0]["lng"]
621
  else:
622
  locations = json.loads(coordinates)
623
  for k, location in enumerate(locations):
624
  locations[k] = location["location"]["latLng"]
625
- locations[k]["lat"] = locations[k]["lat"] - locations[0]["lat"]
626
- locations[k]["lng"] = locations[k]["lng"] - locations[0]["lng"]
 
 
 
 
 
 
627
  print(locations)
628
 
629
  # Process the video and get the path of the output video
 
611
  def on_submit(uploaded_video,model_type,coordinates):
612
  global locations
613
  locations = []
614
+ avg = [0, 0]
615
 
616
  if not coordinates:
617
  locations = json.loads(example_coords)
618
  for k, location in enumerate(locations):
619
  locations[k] = location["latLng"]
620
+ avg[0] = avg[0] + locations[k]["lat"]
621
+ avg[1] = avg[1] + locations[k]["lng"]
622
  else:
623
  locations = json.loads(coordinates)
624
  for k, location in enumerate(locations):
625
  locations[k] = location["location"]["latLng"]
626
+ avg[0] = avg[0] + locations[k]["lat"]
627
+ avg[1] = avg[1] + locations[k]["lng"]
628
+
629
+ avg[0] = avg[0] / len(locations)
630
+ avg[1] = avg[1] / len(locations)
631
+ for k, location in enumerate(locations):
632
+ locations[k]["lat"] = location["lat"] - avg[0]
633
+ locations[k]["lng"] = location["lng"] - avg[1]
634
  print(locations)
635
 
636
  # Process the video and get the path of the output video