Browse Source

Merge remote-tracking branch 'origin/dev' into dev

lyc8503 3 years ago
parent
commit
d5a7129a22

+ 1 - 1
backend_refactor/service/ai/video/video_score/balancebeam.py

@@ -55,7 +55,7 @@ def cal_balancebeam(result):
 
     satisfied_pics = []
     highest_wrist = 1000
-    highest_wrist_index = 0
+    highest_wrist_index = list(result.keys())[0]
     begin_index = 0
     finish_index = 0
     is_begin = False

+ 4 - 4
backend_refactor/service/ai/video/video_score/jump.py

@@ -46,7 +46,7 @@ def cal_jump(result):
     # first socre
     min_wrist_height = float(result[list(result.keys())[0]]["wrist_heigh"])
     min_hip_angle = float(result[list(result.keys())[0]]["hip_right_angle"])
-    min_wrist_index = 0
+    min_wrist_index = list(result.keys())[0]
     for index in result:
         if float(result[index]["leg_heigh"]) >= initial_ankle_height - 3:
             if float(result[index]["hip_right_angle"]) <= min_hip_angle and float(
@@ -100,8 +100,8 @@ def cal_jump(result):
     re["2"]["index"] = min_hip_angle_index
     # third score
     max_hip_angle = float(result[min_hip_angle_index]["knee_right_angle"])
-    max_hip_index = "1"
-    highest_ankle_index = "1"
+    max_hip_index = list(result.keys())[0]
+    highest_ankle_index = list(result.keys())[0]
     min_ankle_height = initial_ankle_height
     for index in result:
         if float(index) > float(leave_index):
@@ -138,7 +138,7 @@ def cal_jump(result):
     re["4"]["index"] = highest_ankle_index
     # fifth score
     lowest_ankle_height = float(result[reland_index]["leg_heigh"])
-    lowest_ankle_index = "1"
+    lowest_ankle_index = list(result.keys())[0]
     for index in result:
         if int(index) <= int(highest_ankle_index):
             continue

+ 1 - 1
backend_refactor/service/ai/video/video_score/jumpwithboth.py

@@ -70,7 +70,7 @@ def cal_jumpwithboth(result):
     result_ig = result
     re = {}
     highest_ankle = 10000
-    highest_ankle_index = 0
+    highest_ankle_index = list(result.keys())[0]
 
     for index in result:
         if float(result[index]["leg_heigh"]) < float(highest_ankle) and float(

+ 9 - 5
backend_refactor/service/ai/video/video_score/pingban.py

@@ -58,7 +58,7 @@ def cal_pingban(result):
         if float(result[index]["knee_right_angle"]) < 100 and float(result[index]["knee_left_angle"]) < 100:
             is_prepared = True
     # prepared posture: when knee at its lowest,number is highest
-    first_index = "1"
+    first_index = list(result.keys())[0]
     first_score = 0
     if is_prepared:
         lowest_knee = float(result_ig[list(result.keys())[0]]["knee_heigh"])
@@ -81,7 +81,7 @@ def cal_pingban(result):
         re["1"]["is_prepared"] = False
     # second posture
     max_knee_angle = float(result_ig[list(result.keys())[0]]["hip_right_angle"])
-    max_knee_angle_index = "1"
+    max_knee_angle_index = list(result.keys())[0]
     second_pics = []
     satisfied_index = []
     for index in result:
@@ -92,9 +92,13 @@ def cal_pingban(result):
                 result_ig = is_zero(result_ig, index)
                 satisfied_index.append(index)
                 second_pics.append(result_ig[index])
-                if float(result[index]["hip_right_angle"]) > float(max_knee_angle):
-                    max_knee_angle = result[index]["hip_right_angle"]
-                    max_knee_angle_index = index
+            if float(result[index]["hip_right_angle"]) > float(max_knee_angle):
+                max_knee_angle = result[index]["hip_right_angle"]
+                max_knee_angle_index = index
+    if len(satisfied_index) == 0:
+        result_ig = is_zero(result_ig, max_knee_angle_index)
+        satisfied_index.append(max_knee_angle_index)
+        second_pics.append(result_ig[max_knee_angle_index])
     pingban_2_score = cal_second_score(second_pics)
     total_score = pingban_2_score
     if first_score != 0:

+ 1 - 1
backend_refactor/service/ai/video/video_score/sitforward.py

@@ -35,7 +35,7 @@ def cal_sitforward(result):
     result_ig = result
     re = {}
     highest_wrist_x = result[list(result.keys())[0]]["wrist_x"]
-    highest_weist_index = 0
+    highest_weist_index = list(result.keys())[0]
 
     for index in result:
         if float(result[index]["wrist_x"]) < float(highest_wrist_x) and float(result[index]["wrist_x"]) != 0:

+ 2 - 2
backend_refactor/service/ai/video/video_score/standing.py

@@ -61,13 +61,13 @@ def cal_standing(result):
     result_ig = result
     re = {}
     mode = "knee_left_angle"
-    begin_index = 0
+    begin_index = list(result.keys())[0]
     finish_index = 0
     highest_ankle_index = 0
     highest_ankle = 1000
     satisfied_pics = []
     minest_knee_angle = 180
-    minest_knee_angle_index = 0
+    minest_knee_angle_index = list(result.keys())[0]
 
     for index in result:
         if float(result[index]["knee_right_angle"]) < 165:

+ 1 - 1
backend_refactor/service/ai/video/video_score/tennisthrow.py

@@ -95,7 +95,7 @@ def cal_tennisthrow(result):
     result_ig = is_zero(result_ig, highest_wrist_index)
     third_score = cal_average_score(result_ig[highest_wrist_index], hand, 3)
     # first score
-    farrest_distance_index = 0
+    farrest_distance_index = list(result.keys())[0]
     farrest_distance = 0
     for index in result:
         if float(index) < float(highest_wrist_index):

+ 8 - 4
backend_refactor/service/ai/video/video_score/turnaround.py

@@ -101,7 +101,7 @@ def cal_turnaround(result):
     re = {}
     satisfied_pics = []
     max_distance = 0
-    max_distance_index = 0
+    max_distance_index = list(result.keys())[0]
     key_index = 0
     satisfied_index = []
     for index in result:
@@ -114,10 +114,14 @@ def cal_turnaround(result):
             result_ig = is_zero(result_ig, index)
             satisfied_index.append(index)
             satisfied_pics.append(result_ig[index])
-        # if float(result[index]["foot_distance"]) > float(max_distance):
-        #     max_distance = result[index]["foot_distance"]
-        #     max_distance_index = index
+        if float(result[index]["foot_distance"]) > float(max_distance):
+            max_distance = result[index]["foot_distance"]
+            max_distance_index = index
         key_index += 1
+    if len(satisfied_index) == 0:
+        result_ig = is_zero(result_ig, max_distance_index)
+        satisfied_index.append(max_distance_index)
+        satisfied_pics.append(result_ig[max_distance_index])
     first_score = cal_average_score(satisfied_pics, 1)
     re["1"] = result_ig[satisfied_index[0]]
     # re["1"]["max_distance"] = max_distance