From e35b3fd7b1cf9d9768815f1f35b1292fd8d43d4d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 7 Nov 2019 17:55:02 +0100 Subject: [PATCH] Added slider and improved behavior of video analysis --- rowers/interactiveplots.py | 3 + rowers/templates/embedded_video.html | 98 ++++++++++++++++++++++++---- rowers/templates/menu_workout.html | 10 +-- rowers/templates/workout_form.html | 1 + rowers/views/workoutviews.py | 25 ++++--- 5 files changed, 110 insertions(+), 27 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 3673ded8..138a9346 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -1899,6 +1899,9 @@ def leaflet_chart_video(lat,lon,name=""): "Nautical": nautical, }},{{ "Navionics":navionics, + }}, + {{ + position:'topleft' }}).addTo(mymap); var marker = L.marker([{latbegin}, {longbegin}]).addTo(mymap); diff --git a/rowers/templates/embedded_video.html b/rowers/templates/embedded_video.html index 16e63d22..e0a8f0d7 100644 --- a/rowers/templates/embedded_video.html +++ b/rowers/templates/embedded_video.html @@ -15,15 +15,54 @@ {% block main %} + {% language 'en' %}

Video Analysis for {{ workout.name }}

    -
  • -
    - {{ mapdiv | safe}} - -
    +
  • + Data Time + + seconds
  • Video Time @@ -40,11 +79,21 @@ m/s
  • -
  • +
  • +
    + {{ mapdiv | safe}} + +
    +
    + +
    +
  • +
  • {% endlanguage %} {% endblock %} diff --git a/rowers/templates/menu_workout.html b/rowers/templates/menu_workout.html index c9eea26c..f6edffd0 100644 --- a/rowers/templates/menu_workout.html +++ b/rowers/templates/menu_workout.html @@ -45,6 +45,11 @@  Compare
  • +
  • + +  Video Analysis + +
  • {% if user.is_authenticated and workout|may_edit:request %}
  • @@ -74,11 +79,6 @@  Map
  • -
  • - -  Video Analysis - -
  •  Force Curve diff --git a/rowers/templates/workout_form.html b/rowers/templates/workout_form.html index 0b78dd32..ebc2f18b 100644 --- a/rowers/templates/workout_form.html +++ b/rowers/templates/workout_form.html @@ -173,6 +173,7 @@ $('#id_workouttype').change(); {% endfor %} {% for video in videos %}
  • +
    {{ video.name }}
    diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index afa2b791..eb3c146b 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -69,6 +69,10 @@ def workout_video_view(request,id=''): form = VideoAnalysisCreateForm(request.POST) if form.is_valid(): video_id = form.cleaned_data['url'] + try: + video_id = get_video_id(form.cleaned_data['url']) + except (TypeError,ValueError): + pass delay = form.cleaned_data['delay'] if 'save_button' in request.POST: analysis.name = form.cleaned_data['name'] @@ -101,8 +105,8 @@ def workout_video_view(request,id=''): df2 = df.resample('1s').mean().interpolate() - mask = df2['time'] < delay - df2 = df2.mask(mask).dropna() + #mask = df2['time'] < delay + #df2 = df2.mask(mask).dropna() df2['time'] = (df2['time']-df2['time'].min()) boatspeed = (100*df2['velo']).astype(int)/100. @@ -112,8 +116,8 @@ def workout_video_view(request,id=''): coordinates.set_index(pd.to_timedelta(coordinates['time'],unit='s'),inplace=True) coordinates = coordinates.resample('1s').mean().interpolate() - mask = coordinates['time'] < delay - coordinates = coordinates.mask(mask).dropna() + #mask = coordinates['time'] < delay + #coordinates = coordinates.mask(mask).dropna() coordinates['time'] = coordinates['time']-coordinates['time'].min() latitude = coordinates['latitude'] longitude = coordinates['longitude'] @@ -158,6 +162,7 @@ def workout_video_view(request,id=''): 'form':form, 'breadcrumbs':breadcrumbs, 'analysis':analysis, + 'maxtime':coordinates['time'].max(), }) @@ -206,8 +211,8 @@ def workout_video_create_view(request,id=0): df2 = df.resample('1s').mean().interpolate() - mask = df2['time'] < delay - df2 = df2.mask(mask).dropna() + #mask = df2['time'] < delay + #df2 = df2.mask(mask).dropna() df2['time'] = (df2['time']-df2['time'].min()) boatspeed = (100*df2['velo']).astype(int)/100. @@ -217,8 +222,8 @@ def workout_video_create_view(request,id=0): coordinates.set_index(pd.to_timedelta(coordinates['time'],unit='s'),inplace=True) coordinates = coordinates.resample('1s').mean().interpolate() - mask = coordinates['time'] < delay - coordinates = coordinates.mask(mask).dropna() + #mask = coordinates['time'] < delay + #coordinates = coordinates.mask(mask).dropna() coordinates['time'] = coordinates['time']-coordinates['time'].min() latitude = coordinates['latitude'] longitude = coordinates['longitude'] @@ -251,6 +256,8 @@ def workout_video_create_view(request,id=0): ] + analysis = {'delay':delay} + return render(request, 'embedded_video.html', { @@ -261,7 +268,9 @@ def workout_video_create_view(request,id=0): 'mapdiv': mapdiv, 'video_id': video_id, 'form':form, + 'analysis':analysis, 'breadcrumbs':breadcrumbs, + 'maxtime':coordinates['time'].max() }) # Show the EMpower Oarlock generated Stroke Profile