podlaczenie do servera
This commit is contained in:
parent
7f68677a3b
commit
edde8cf6be
@ -38,7 +38,7 @@ const Hero = () => {
|
|||||||
var bodyPart = "";
|
var bodyPart = "";
|
||||||
var technique = "";
|
var technique = "";
|
||||||
var actionType = "";
|
var actionType = "";
|
||||||
var possition = "";
|
var shooterPossition = "";
|
||||||
|
|
||||||
//zamiana procentowych pozycji na kartezyjskie
|
//zamiana procentowych pozycji na kartezyjskie
|
||||||
function konwerturX(x){
|
function konwerturX(x){
|
||||||
@ -115,6 +115,18 @@ const Hero = () => {
|
|||||||
function loadPlayers(){
|
function loadPlayers(){
|
||||||
var players = document.querySelectorAll('.player')
|
var players = document.querySelectorAll('.player')
|
||||||
|
|
||||||
|
|
||||||
|
//zgranie informacji z list
|
||||||
|
var bodyPartList = document.getElementById('bodyPartList')
|
||||||
|
var actionTypeList = document.getElementById('actionTypeList')
|
||||||
|
var possitionList = document.getElementById('possitionList')
|
||||||
|
var shootTypeList = document.getElementById('shootTypeList')
|
||||||
|
|
||||||
|
bodyPart = bodyPartList.value
|
||||||
|
actionType = actionTypeList.value
|
||||||
|
shooterPossition = possitionList.value
|
||||||
|
technique = shootTypeList.value
|
||||||
|
|
||||||
// wyczyszczenie list zawierajacych lokalizacje zawodnikow
|
// wyczyszczenie list zawierajacych lokalizacje zawodnikow
|
||||||
defenders = []
|
defenders = []
|
||||||
stricers = []
|
stricers = []
|
||||||
@ -249,16 +261,11 @@ const Hero = () => {
|
|||||||
function sentQuestion() {
|
function sentQuestion() {
|
||||||
|
|
||||||
loadPlayers()
|
loadPlayers()
|
||||||
|
|
||||||
var ball = document.querySelector('.football');
|
if (numer_od_shooters > 0) {
|
||||||
|
|
||||||
if (ball) {
|
|
||||||
// Użyj backticksów zamiast zwykłych cudzysłowów
|
// Użyj backticksów zamiast zwykłych cudzysłowów
|
||||||
//console.log('Wysyłanie wartości: ', ball);
|
|
||||||
shooterX = konwerturX(ball.style.left)
|
fetch(`http://127.0.0.1:5000/get_model?shooter=${shooter}&goalkeeper=${goalkeeper}&defenders=${defenders}&strickers=${stricers}&bodyPart=4${bodyPart}&technique=${technique}&actionType=${actionType}&shooterPossition=${shooterPossition}`).then(
|
||||||
shooterY = konwetujY(ball.style.top)
|
|
||||||
console.log('Wysyłanie wartości: ', shooterX, shooterY);
|
|
||||||
fetch(`http://127.0.0.1:5000/get_model?x=${shooter[0]}&y=${shooter[1]}`).then(
|
|
||||||
res => res.json()
|
res => res.json()
|
||||||
).then(
|
).then(
|
||||||
data => {
|
data => {
|
||||||
@ -357,62 +364,50 @@ const Hero = () => {
|
|||||||
{/* Listy zwijane */}
|
{/* Listy zwijane */}
|
||||||
|
|
||||||
<div className="top-bar">
|
<div className="top-bar">
|
||||||
{/* new version */}
|
|
||||||
<div className="dropdown">
|
<form className="dropdown" id = "bodyPartList">
|
||||||
<button onClick={() => setIsOpen(!isOpen)} className="dropbtn">
|
<select className="dropbtn">
|
||||||
Część ciała
|
<option value = "prawa">Noga Prawa</option>
|
||||||
</button>
|
<option value = "lewa">Noga Lewa</option>
|
||||||
{isOpen && (
|
<option value = "glowa">Głowa</option>
|
||||||
<div className="cho-dropdown_body_part">
|
<option value = "inna" >Inna</option>
|
||||||
<a a href="#">Noga Prawa</a>
|
</select>
|
||||||
<a a href="#">Noga Lewa</a>
|
</form>
|
||||||
<a a href="#">Głowa</a>
|
|
||||||
<a a href="#">Inna</a>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div className="dropdown">
|
<form className="dropdown" id = "shootTypeList">
|
||||||
<button onClick={toggleDropdown} className="dropbtn">Technika strzału</button>
|
<select className="dropbtn">
|
||||||
{isOpen && (
|
<option value="zwykly"> Zwykły </option>
|
||||||
<div className="cho-dropdown_technique_name">
|
<option value = "voley"> Wolej </option>
|
||||||
<a href="#"> Zwykły </a>
|
<option value = "pol-voley"> Półwolej </option>
|
||||||
<a href="#"> Wolej </a>
|
<option value = "lob"> Lob </option>
|
||||||
<a href="#"> Półwolej </a>
|
<option value = "szczupak"> Szczupak </option>
|
||||||
<a href="#"> Lob </a>
|
<option value = "z_gory"> Kopnięcie z góry </option>
|
||||||
<a href="#"> Szczupak </a>
|
<option value = "pietka"> Piętka </option>
|
||||||
<a href="#"> Kopnięcie z góry </a>
|
</select>
|
||||||
<a href="#"> Piętka </a>
|
</form>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div className="dropdown">
|
<form className="dropdown" id = "actionTypeList">
|
||||||
<button onClick={toggleDropdown} className="dropbtn">Typ akcji</button>
|
<select className="dropbtn">
|
||||||
{isOpen && (
|
<option value = "pozycyjny"> Atak Pozycyjny </option>
|
||||||
<div className="cho-dropdown_type_name">
|
<option value = "wolny"> Rzut Wolny </option>
|
||||||
<a href="#"> Atak Pozycyjny </a>
|
<option value = "karny"> Rzut Karny </option>
|
||||||
<a href="#"> Rzut Wolny </a>
|
<option value= "rozny"> Rzut Rozny </option>
|
||||||
<a href="#"> Rzut Karny </a>
|
<option value="rozpoczecie"> Rozpoczęcie </option>
|
||||||
<a href="#"> Rzut Rozny </a>
|
</select>
|
||||||
<a href="#"> Rozpoczęcie </a>
|
</form>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="dropdown">
|
|
||||||
<button onClick={toggleDropdown} className="dropbtn">Pozycja strzelającego</button>
|
<form className="dropdown" id = "possitionList">
|
||||||
{isOpen && (
|
<select className="dropbtn">
|
||||||
<div className="cho-dropdown_position_name">
|
<option value= "napastnik" > Napastnik </option>
|
||||||
<a href="#"> Bramkarz </a>
|
<option value = "bramkarz"> Bramkarz </option>
|
||||||
<a href="#"> Obrońca </a>
|
<option value = "obronca"> Obrońca </option>
|
||||||
<a href="#"> Pomocnik </a>
|
<option value = "pomocnik"> Pomocnik </option>
|
||||||
<a href="#"> Napastnik </a>
|
|
||||||
</div>
|
</select>
|
||||||
)}
|
</form>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="cho-minute">
|
<div className="cho-minute">
|
||||||
<label htmlFor="gameMinute" className="label-large"></label>
|
<label htmlFor="gameMinute" className="label-large"></label>
|
||||||
|
@ -20,12 +20,13 @@ def loc2distance(x, y):
|
|||||||
def loc2locdistance(x1, y1, x2, y2):
|
def loc2locdistance(x1, y1, x2, y2):
|
||||||
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
|
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
|
||||||
|
|
||||||
|
#Konwertuje string zawierajacy liczby odzielone , i konwertuje do float
|
||||||
# model Api
|
def konwertujDoListy(listaString):
|
||||||
# @app.route("/members")
|
listaString = listaString.split(",")
|
||||||
# def members():
|
listaFloat = []
|
||||||
# return{"members":["Member1","Member2","Member3"]}
|
for elem in listaString:
|
||||||
|
listaFloat.append(float(elem))
|
||||||
|
return listaFloat
|
||||||
# zapytanie o regresje logistyczną na podstawie pozycji piłki
|
# zapytanie o regresje logistyczną na podstawie pozycji piłki
|
||||||
|
|
||||||
# @app.route("/LRegresion<x>&<y>")
|
# @app.route("/LRegresion<x>&<y>")
|
||||||
@ -79,19 +80,24 @@ def get_model():
|
|||||||
|
|
||||||
# x = int(x[0:2])
|
# x = int(x[0:2])
|
||||||
# y = int(y[0:2])
|
# y = int(y[0:2])
|
||||||
x = request.args.get('x', type=float)
|
shooter = request.args.get('shooter')
|
||||||
y = request.args.get('y', type=float)
|
shooter = konwertujDoListy(shooter)
|
||||||
|
|
||||||
|
print("wprowadzone dane:")
|
||||||
|
print("x strzelca: " + str(shooter[0]))
|
||||||
|
print("y strzelca: " + str(shooter[1]))
|
||||||
|
|
||||||
## change model on xgboost
|
## change model on xgboost
|
||||||
## add angle, match minutes and number of players
|
## add angle, match minutes and number of players
|
||||||
|
|
||||||
|
angle = loc2angle(x = shooter[0], y = shooter[1])
|
||||||
|
dist = loc2distance(x = shooter[0], y = shooter[1])
|
||||||
|
|
||||||
angle = loc2angle(x = x, y = y)
|
if shooter[0] is None and shooter[1] is None:
|
||||||
dist = loc2distance(x = x, y = y)
|
|
||||||
|
|
||||||
if y is None and x is None:
|
|
||||||
return jsonify({"error": "Brak wymaganych parametrów"}), 400
|
return jsonify({"error": "Brak wymaganych parametrów"}), 400
|
||||||
|
|
||||||
response = LogisticRegression_predict_proba(position_x=x,
|
response = LogisticRegression_predict_proba(position_x=shooter[0],
|
||||||
position_y=y,
|
position_y=shooter[1],
|
||||||
distance_to_goalM = dist,
|
distance_to_goalM = dist,
|
||||||
angle = angle,
|
angle = angle,
|
||||||
match_minute=13,
|
match_minute=13,
|
||||||
@ -99,13 +105,11 @@ def get_model():
|
|||||||
Number_Intervening_Teammates=0,
|
Number_Intervening_Teammates=0,
|
||||||
isFoot=1,
|
isFoot=1,
|
||||||
isHead=0)
|
isHead=0)
|
||||||
#print(x)
|
|
||||||
#print(y)
|
|
||||||
#print(response)
|
#print(response)
|
||||||
res = str(response)
|
res = str(response)
|
||||||
#return {"response":res}
|
#return {"response":res}
|
||||||
return jsonify({"response":res})
|
return jsonify({"response":res})
|
||||||
|
|
||||||
# uruchomienie serwera
|
# uruchomienie serwera
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug = True)
|
app.run(debug = True)
|
Loading…
Reference in New Issue
Block a user