CHWHC 4 år sedan
förälder
incheckning
dc00d9b8ed
2 ändrade filer med 82 tillägg och 10 borttagningar
  1. 2 2
      backend/db_project.py
  2. 80 8
      backend/flask_api.py

+ 2 - 2
backend/db_project.py

@@ -121,13 +121,13 @@ def lookup_data(id):
                          database="pose",
                          charset='utf8')
     cursor = db.cursor()
-    sql="select mode where id=%d"  %id
+    sql="select mode from video where id=%d"  %id
     cursor.execute(sql)
     result=cursor.fetchone()
     db.commit()
     cursor.close()
     db.close()
-    return result
+    return result[0]
 def process_db(id):
     db = pymysql.connect(host=ip_ad,
                          user="root",

+ 80 - 8
backend/flask_api.py

@@ -17,6 +17,7 @@ li_last = []
 # store dic_data's json format
 bJson = ""
 global_index = [6]
+global_video_index=0
 li_return = []
 img_return = []
 
@@ -162,29 +163,100 @@ def save_file(file):
     print(filename)
     print(save_name)
 #运行动态分析的入口
-def run_video(mode,ana=1):
-    num=add_new_data_dyna(mode)
+def run_video(mode,num,ana=1):
     q="./video/"+str(num)+".mp4"
-    #qqq=os.path.abspath(q)
-    #r="capture_image"+str(re["2"]["num"])+".png"
-    #a=os.path.join(qqq,r)
-    video_path=q
     re= api_dyna(q,mode,ana)
     return re
 
 def lookup_video(num,ana=0):
-
     q="./video/"+str(num)+".mp4"
-    video_path=q
     mode=lookup_data(num)
     re= api_dyna(q,mode,ana)
     return re
 
+###send a video and return a id marked the video (identical)
+@app.route('/get videoid',methods=['POST'])
+@cross_origin()
+def get_videoid():
+    dict_video_=request.form.to_dict()
+    dict_video_mp4=request.files.to_dict()
+    mode=dict_video_["mode"]
+    global global_video_index
+    global_video_index=int(add_new_data_dyna(mode))
+    for file in dict_video_mp4():
+        base="./video/"
+        filename=base+str(global_video_index)+".mp4"
+        file.save(filename)
+    return {"id":str(global_video_index)}
+
+
+
+##jump
+##result["jump_power"]["level"]/["path"]/["val"]
+##result["core_strength"]["level"]/["path"]  1 2 3 4
+##result["landing_position"]["level"]/["path"]["val"]
+##juanfu
+## result["head_power"]["level"]/["path"]/["val"]
+##result["core_strength"]["level"]/["path"]
+##result["body_stability"]["level"]/["val"]
+
+##pingban
+"""
+result["arm_strength"]["level"]/["path"]/["val"]
+result["stability"]["level"]/["path"]/["val"]
+result["standard"]["level"]/["path"]/["val"]
+"""
+##shendun
+"""
+result["leg_strength"]["level"]/["path"]
+"""
+##gaotaitui
+"""
+result["standard"]["level"]/["path"]
+"""
+
+@app.route('/get_video_data',methods=['POST'])
+@cross_origin()
+def get_video_data():
+    dict_video_=request.form.to_dict()
+    global global_video_index
+    global_video_index=int(dict_video_["id"])
+    mode=str(lookup_data(global_video_index))#get database mode
+    re=run_video(mode,global_video_index,1)
+    return re
+
+
+@app.route('/get_3D',methods=['POST'])
+@cross_origin()
+def get_3D():
+    return
+
+@app.route('/query_3D',methods=['POST'])
+@cross_origin()
+def query_video():
+    dict_video_=request.form.to_dict()
+    global  global_video_index
+    global_video_index=int(dict_video_["id"])
+    return lookup_video(global_video_index,0)
+
+@app.route('/query_video',methods=['POST'])
+@cross_origin()
+def query_3D():
+    return
+
+
+#result={xx:xx,xx:xx}
+#result={power:{val:xx,path:xx},strength:{val:xx,path:xx}}
+
+#1.锻炼建议
+#2.发送视频
+#3.
 
 @app.route('/send_form', methods=['POST'])
 @cross_origin()
 def send_form():
     text_data = request.form.to_dict()
+
     fileList = request.files.to_dict()
     global global_index
     global_index[0]=int(add_new_data())