Skip to content

Commit

Permalink
Simulation of events #37
Browse files Browse the repository at this point in the history
  • Loading branch information
heming-langrenn committed Nov 18, 2024
1 parent 6bdd696 commit a529631
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 15 deletions.
5 changes: 4 additions & 1 deletion photo_service_gui/config/global_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
"SHOW_VIDEO": "False",
"VIDEO_URL": "https://harnaes.no/maalfoto/2023SkiMaal.mp4",
"DETECTION_BOX_MINIMUM_SIZE": "0.08",
"DETECTION_BOX_MAXIMUM_SIZE": "0.9"
"DETECTION_BOX_MAXIMUM_SIZE": "0.9",
"SIMULATION_CROSSINGS_START": "False",
"SIMULATION_START_LIST_FILE": "tests/files/startliste.csv",
"SIMULATION_FASTEST_TIME": "300"
}
5 changes: 5 additions & 0 deletions photo_service_gui/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ border-right: 1px solid #ddd;
color: black;
font-weight: bold;
}

.black {
color: black;
}

#white-text {
color: white;
}
Expand Down
4 changes: 2 additions & 2 deletions photo_service_gui/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<td>
<form action=/config method=post>
<input type="hidden" name=event_id value="{{ event_id }}">
<input type="submit" name=reset_config value=" Nullstill config ">
<input type="submit" name=reset_config class=black value=" Nullstill config ">
</form>
</td>
<td>
<form action=/config method=get>
<input type="submit" name=edit_config value=" Rediger config ">
<input type="submit" name=edit_config class=black value=" Rediger config ">
<input type="hidden" name=event_id value="{{ event_id }}">
<input type="hidden" name=action value="edit">
</form>
Expand Down
2 changes: 1 addition & 1 deletion photo_service_gui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<td id=headerblue align="right">
{% if username != "Gjest" %}
<form action="/" method="post">
<input type="submit" name=delete_event value=" Slett event ">
<input type="submit" name=delete_event class=black value=" Slett event ">
<input type="hidden" name=event_id value={{ oneevent.id }}>
</form>
{% endif %}
Expand Down
1 change: 1 addition & 0 deletions photo_service_gui/templates/open_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
{% else %}
<a id="myUsers" href="/users">Brukere</a>
<a id="mySettings" href="/settings">Globale innstillinger</a>
<a href="https://langrenn-sprint.github.io/docs" target="_blank">Docs</a>
<a href="/logout">Logg ut</a>
{% endif %}
</div>
Expand Down
30 changes: 28 additions & 2 deletions photo_service_gui/templates/video_events.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
mens informasjon sendes til Pubsub og legges på en meldingskø der interessenter kan abonnere på hendelsene.
<br><b>Configuration</b> - Mulighet for å skru av og på tjenestene (video analytics og pubsub) samt å stille inn video url og linje-koordinater.
<br><b>Status</b> - Her vises statusmeldinger for tjenesten. Både det som registreres på videoen og at meldingenr sendes videre til meldingskøen i Google (pubsub).<br>
<br><b>Simulering</b> - (For testing) Her er det mulig å få systemet til å generere passeringer. Krever at en startliste gis som input.<br>
</div>
<div id=spacer></div>
<! --- End Information --->
Expand Down Expand Up @@ -152,7 +153,7 @@
</tr>
<tr>
<td>Url</td>
<td><input type="text" id="video_url" name="video_url" value="{{ video_url }}" size="40"></td>
<td><input type="text" id="video_url" name="video_url" value="{{ video_url }}"></td>
</tr>
<tr>
<td></td>
Expand All @@ -173,14 +174,39 @@
<img id="photo_queue_latest" src="../static/no_image.png" title="Latest photo from vision AI detection" style="width:400px">
</td>
</tr>
<tr>
<td colspan="2">
<b><br>Simulation settings</b>
</td>
</tr>
<form action=/video_events method=post>
<tr>
<td>Start list</td>
<td>
<input type="text" name="sim_list" value="{{ sim_list }}">
<small>(file path or url - <a href="https://www.harnaes.no/sprint/web/startliste.csv">eksempel</a>)</small>
</td>
</tr>
<tr>
<td>Fastest time</td>
<td><input type="text" name="sim_fastest_time" value="{{ sim_fastest_time }}"></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="update_config" value=" Start simulering ">
<input type="hidden" name=event_id value="{{ event_id }}">
</td>
</tr>
</form>
</table>
</td>
<td>&nbsp;</td>
<td valign="top">
<span id="send_result"></span>
</td>
</tr>
</table>
</table>
<script>
// trigger every 5 seconds
window.setInterval(sync_status, 5000);
Expand Down
38 changes: 29 additions & 9 deletions photo_service_gui/views/video_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ async def get(self) -> web.Response:
"video_analytics_running": await ConfigAdapter().get_config(
user["token"], event, "VIDEO_ANALYTICS_RUNNING"
),
"sim_list": await ConfigAdapter().get_config(
user["token"], event, "SIMULATION_START_LIST_FILE"
),
"sim_fastest_time": await ConfigAdapter().get_config(
user["token"], event, "SIMULATION_FASTEST_TIME"
),
},
)
except Exception as e:
Expand Down Expand Up @@ -146,12 +152,26 @@ async def stop_video_analytics(token: str, event: dict) -> str:


async def update_config(token: str, event: dict, form: dict) -> str:
"""Draw trigger line with ultraltyics."""
await ConfigAdapter().update_config(
token, event, "TRIGGER_LINE_XYXYN", str(form["trigger_line_xyxyn"])
)
await ConfigAdapter().update_config(
token, event, "VIDEO_URL", str(form["video_url"])
)
await ConfigAdapter().update_config(token, event, "DRAW_TRIGGER_LINE", "True")
return "Video settings updated."
"""Draw trigger line or initiate simulation."""
informasjon = ""
if "trigger_line_xyxyn" in form.keys():
await ConfigAdapter().update_config(
token, event, "TRIGGER_LINE_XYXYN", str(form["trigger_line_xyxyn"])
)
await ConfigAdapter().update_config(
token, event, "VIDEO_URL", str(form["video_url"])
)
await ConfigAdapter().update_config(token, event, "DRAW_TRIGGER_LINE", "True")
informasjon = "Video settings updated."
elif "sim_list" in form.keys():
await ConfigAdapter().update_config(
token, event, "SIMULATION_START_LIST_FILE", str(form["sim_list"])
)
await ConfigAdapter().update_config(
token, event, "SIMULATION_FASTEST_TIME", str(form["sim_fastest_time"])
)
await ConfigAdapter().update_config(
token, event, "SIMULATION_CROSSINGS_START", "True"
)
informasjon = "Simulering av passeringer er initiert."
return informasjon

0 comments on commit a529631

Please sign in to comment.