initial version of form working
This commit is contained in:
@@ -51,6 +51,11 @@ class FlexibleDecimalField(forms.DecimalField):
|
|||||||
value = value.replace('.', '').replace(',', '.')
|
value = value.replace('.', '').replace(',', '.')
|
||||||
return super(FlexibleDecimalField, self).to_python(value)
|
return super(FlexibleDecimalField, self).to_python(value)
|
||||||
|
|
||||||
|
# Video Analysis creation form
|
||||||
|
class VideoAnalysisCreateForm(forms.Form):
|
||||||
|
url = forms.CharField(max_length=255,required=True,label='YouTube Video URL')
|
||||||
|
delay = forms.IntegerField(initial=0,label='Delay (seconds)')
|
||||||
|
|
||||||
# BillingForm form
|
# BillingForm form
|
||||||
class BillingForm(forms.Form):
|
class BillingForm(forms.Form):
|
||||||
amount = FlexibleDecimalField(required=True,decimal_places=2,
|
amount = FlexibleDecimalField(required=True,decimal_places=2,
|
||||||
@@ -1380,7 +1385,3 @@ class FlexAxesForm(forms.Form):
|
|||||||
self.fields['xaxis'].choices = axchoicesbasicx
|
self.fields['xaxis'].choices = axchoicesbasicx
|
||||||
self.fields['yaxis1'].choices = axchoicesbasicy
|
self.fields['yaxis1'].choices = axchoicesbasicy
|
||||||
self.fields['yaxis2'].choices = axchoicesbasicy
|
self.fields['yaxis2'].choices = axchoicesbasicy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,11 @@
|
|||||||
<span id="time">
|
<span id="time">
|
||||||
</span> seconds
|
</span> seconds
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
SPM
|
||||||
|
<span id="spm">
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Boat Speed
|
Boat Speed
|
||||||
<span id="speed">
|
<span id="speed">
|
||||||
@@ -70,12 +75,13 @@
|
|||||||
var boatspeed = data["boatspeed"];
|
var boatspeed = data["boatspeed"];
|
||||||
var latitude = data["latitude"];
|
var latitude = data["latitude"];
|
||||||
var longitude = data["longitude"];
|
var longitude = data["longitude"];
|
||||||
|
var spm = data["spm"]
|
||||||
|
|
||||||
function onYouTubeIframeAPIReady() {
|
function onYouTubeIframeAPIReady() {
|
||||||
player = new YT.Player('player', {
|
player = new YT.Player('player', {
|
||||||
height: '390',
|
height: '390',
|
||||||
width: '640',
|
width: '640',
|
||||||
videoId: '9dLFC2q9RWc',
|
videoId: '{{ video_id }}',
|
||||||
events: {
|
events: {
|
||||||
'onReady': onPlayerReady
|
'onReady': onPlayerReady
|
||||||
}
|
}
|
||||||
@@ -92,8 +98,10 @@
|
|||||||
velo = boatspeed[Math.round(videotime)];
|
velo = boatspeed[Math.round(videotime)];
|
||||||
lat = latitude[Math.round(videotime)];
|
lat = latitude[Math.round(videotime)];
|
||||||
lon = longitude[Math.round(videotime)];
|
lon = longitude[Math.round(videotime)];
|
||||||
|
strokerate = spm[Math.round(videotime)];
|
||||||
document.getElementById("time").innerHTML = Math.round(videotime);
|
document.getElementById("time").innerHTML = Math.round(videotime);
|
||||||
document.getElementById("speed").innerHTML = velo;
|
document.getElementById("speed").innerHTML = velo;
|
||||||
|
document.getElementById("spm").innerHTML = strokerate;
|
||||||
var newLatLng = new L.LatLng(lat, lon);
|
var newLatLng = new L.LatLng(lat, lon);
|
||||||
marker.setLatLng(newLatLng);
|
marker.setLatLng(newLatLng);
|
||||||
}
|
}
|
||||||
@@ -117,6 +125,23 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="grid_4">
|
||||||
|
{% if not video_id %}
|
||||||
|
<p>
|
||||||
|
To load your video, paste the URL of your YouTube video in the form below,
|
||||||
|
and submit the form.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
<p>
|
||||||
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
<table>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="submit" value="submit">
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endlanguage %}
|
{% endlanguage %}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ from rowers.forms import (
|
|||||||
RaceResultFilterForm,PowerIntervalUpdateForm,FlexAxesForm,
|
RaceResultFilterForm,PowerIntervalUpdateForm,FlexAxesForm,
|
||||||
FlexOptionsForm,DataFrameColumnsForm,OteWorkoutTypeForm,
|
FlexOptionsForm,DataFrameColumnsForm,OteWorkoutTypeForm,
|
||||||
MetricsForm,DisqualificationForm,disqualificationreasons,
|
MetricsForm,DisqualificationForm,disqualificationreasons,
|
||||||
disqualifiers,SearchForm,BillingForm,PlanSelectForm
|
disqualifiers,SearchForm,BillingForm,PlanSelectForm,
|
||||||
|
VideoAnalysisCreateForm
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
@@ -1288,5 +1289,3 @@ def trydf(df,aantal,column):
|
|||||||
|
|
||||||
import rowers.teams as teams
|
import rowers.teams as teams
|
||||||
from rowers.models import C2WorldClassAgePerformance
|
from rowers.models import C2WorldClassAgePerformance
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from urllib.parse import urlparse, parse_qs
|
|||||||
|
|
||||||
def default(o):
|
def default(o):
|
||||||
if isinstance(o, numpy.int64): return int(o)
|
if isinstance(o, numpy.int64): return int(o)
|
||||||
|
if isinstance(o, numpy.int32): return int(o)
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
def get_video_id(url):
|
def get_video_id(url):
|
||||||
@@ -53,32 +54,59 @@ def workout_video_view(request,id=0):
|
|||||||
# get workout
|
# get workout
|
||||||
w = get_workout_permitted(request.user,id)
|
w = get_workout_permitted(request.user,id)
|
||||||
|
|
||||||
|
# get video ID and offset
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = VideoAnalysisCreateForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
url = form.cleaned_data['url']
|
||||||
|
delay = form.cleaned_data['delay']
|
||||||
|
video_id = get_video_id(url)
|
||||||
|
else:
|
||||||
|
video_id = None
|
||||||
|
delay = 0
|
||||||
|
else:
|
||||||
|
form = VideoAnalysisCreateForm()
|
||||||
|
video_id = None
|
||||||
|
delay = 0
|
||||||
|
|
||||||
# get data
|
# get data
|
||||||
df = getsmallrowdata_db(['time','velo'],ids=[w.id])
|
df = getsmallrowdata_db(['time','velo','spm'],ids=[w.id],
|
||||||
|
workstrokesonly=False,doclean=False,compute=False)
|
||||||
df['time'] = (df['time']-df['time'].min())/1000.
|
df['time'] = (df['time']-df['time'].min())/1000.
|
||||||
df.sort_values(by='time',inplace=True)
|
df.sort_values(by='time',inplace=True)
|
||||||
|
|
||||||
|
|
||||||
df.set_index(pd.to_timedelta(df['time'],unit='s'),inplace=True)
|
df.set_index(pd.to_timedelta(df['time'],unit='s'),inplace=True)
|
||||||
df2 = df.resample('1s').mean().interpolate()
|
df2 = df.resample('1s').mean().interpolate()
|
||||||
|
|
||||||
|
|
||||||
|
mask = df2['time'] < delay
|
||||||
|
df2 = df2.mask(mask).dropna()
|
||||||
|
df2['time'] = (df2['time']-df2['time'].min())
|
||||||
|
|
||||||
boatspeed = (100*df2['velo']).astype(int)/100.
|
boatspeed = (100*df2['velo']).astype(int)/100.
|
||||||
|
spm = (10*df2['spm']).astype(int)/10.
|
||||||
|
|
||||||
coordinates = dataprep.get_latlon_time(w.id)
|
coordinates = dataprep.get_latlon_time(w.id)
|
||||||
|
mask = coordinates['time'] < delay
|
||||||
|
coordinates = coordinates.mask(mask).dropna()
|
||||||
|
coordinates['time'] = coordinates['time']-coordinates['time'].min()
|
||||||
coordinates.set_index(pd.to_timedelta(coordinates['time'],unit='s'),inplace=True)
|
coordinates.set_index(pd.to_timedelta(coordinates['time'],unit='s'),inplace=True)
|
||||||
coordinates = coordinates.resample('1s').mean().interpolate()
|
coordinates = coordinates.resample('1s').mean().interpolate()
|
||||||
latitude = coordinates['latitude']
|
latitude = coordinates['latitude']
|
||||||
longitude = coordinates['longitude']
|
longitude = coordinates['longitude']
|
||||||
|
|
||||||
# get video
|
|
||||||
url = "https://www.youtube.com/watch?time_continue=496&v=9dLFC2q9RWc"
|
|
||||||
video_id = get_video_id(url)
|
|
||||||
|
|
||||||
# create map
|
# create map
|
||||||
mapscript, mapdiv = leaflet_chart_video(latitude,longitude,
|
mapscript, mapdiv = leaflet_chart_video(latitude,longitude,
|
||||||
w.name)
|
w.name)
|
||||||
|
|
||||||
# bundle data
|
# bundle data
|
||||||
data = {'boatspeed':[ v for v in boatspeed.values],
|
data = {
|
||||||
'latitude':[ l for l in latitude.values],
|
'boatspeed':[ v for v in boatspeed.values],
|
||||||
'longitude':[ l for l in longitude.values]}
|
'latitude':[ l for l in latitude.values],
|
||||||
|
'longitude':[ l for l in longitude.values],
|
||||||
|
'spm':[ s for s in spm.values ]
|
||||||
|
}
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
'embedded_video.html',
|
'embedded_video.html',
|
||||||
@@ -89,6 +117,7 @@ def workout_video_view(request,id=0):
|
|||||||
'mapscript': mapscript,
|
'mapscript': mapscript,
|
||||||
'mapdiv': mapdiv,
|
'mapdiv': mapdiv,
|
||||||
'video_id': video_id,
|
'video_id': video_id,
|
||||||
|
'form':form,
|
||||||
})
|
})
|
||||||
|
|
||||||
# Show the EMpower Oarlock generated Stroke Profile
|
# Show the EMpower Oarlock generated Stroke Profile
|
||||||
|
|||||||
Reference in New Issue
Block a user