Bläddra i källkod

fix bugs in ai/video z4

张许妍 4 år sedan
förälder
incheckning
1801cdcbf5

+ 1 - 1
backend_refactor/service/ai/video/inner_analyze.py

@@ -181,7 +181,7 @@ def analyse_npy_side_jump(data):
     result = {}
     result = {}
     if len(data) != 25:
     if len(data) != 25:
         # logging.warning("Data len is not 25, skipping.")
         # logging.warning("Data len is not 25, skipping.")
-        return
+        return {}
 
 
     data = data[0]
     data = data[0]
 
 

+ 2 - 0
backend_refactor/service/ai/video/video_score/balancebeam.py

@@ -61,6 +61,8 @@ def cal_balancebeam(result):
     is_begin = False
     is_begin = False
     end_index = 0
     end_index = 0
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["neck_centre_angle"]) > 135 and is_begin == False:
         if float(result[index]["neck_centre_angle"]) > 135 and is_begin == False:
             is_begin = True
             is_begin = True
             begin_index = index
             begin_index = index

+ 10 - 0
backend_refactor/service/ai/video/video_score/jump.py

@@ -38,6 +38,8 @@ def cal_jump(result):
     initial_ankle_height = float(result[list(result.keys())[0]]["leg_heigh"])
     initial_ankle_height = float(result[list(result.keys())[0]]["leg_heigh"])
     min_ankle_height = initial_ankle_height
     min_ankle_height = initial_ankle_height
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["leg_heigh"]) < initial_ankle_height - 3:
         if float(result[index]["leg_heigh"]) < initial_ankle_height - 3:
             if float(result[index]["leg_heigh"]) < float(min_ankle_height) and float(
             if float(result[index]["leg_heigh"]) < float(min_ankle_height) and float(
                     result[index]["leg_heigh"]) != 0.0:
                     result[index]["leg_heigh"]) != 0.0:
@@ -48,6 +50,8 @@ def cal_jump(result):
     min_hip_angle = float(result[list(result.keys())[0]]["hip_right_angle"])
     min_hip_angle = float(result[list(result.keys())[0]]["hip_right_angle"])
     min_wrist_index = list(result.keys())[0]
     min_wrist_index = list(result.keys())[0]
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["leg_heigh"]) >= initial_ankle_height - 3:
         if float(result[index]["leg_heigh"]) >= initial_ankle_height - 3:
             if float(result[index]["hip_right_angle"]) <= min_hip_angle and float(
             if float(result[index]["hip_right_angle"]) <= min_hip_angle and float(
                     result[index]["hip_right_angle"]) != 0.0:
                     result[index]["hip_right_angle"]) != 0.0:
@@ -60,6 +64,8 @@ def cal_jump(result):
         #     break
         #     break
     leave_index = min_hip_angle_index
     leave_index = min_hip_angle_index
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(index) < float(min_hip_angle_index):
         if float(index) < float(min_hip_angle_index):
             if float(result[index]["leg_heigh"]) >= initial_ankle_height - 3:
             if float(result[index]["leg_heigh"]) >= initial_ankle_height - 3:
                 if float(result[index]["wrist_heigh"]) <= min_wrist_height and float(
                 if float(result[index]["wrist_heigh"]) <= min_wrist_height and float(
@@ -104,6 +110,8 @@ def cal_jump(result):
     highest_ankle_index = list(result.keys())[0]
     highest_ankle_index = list(result.keys())[0]
     min_ankle_height = initial_ankle_height
     min_ankle_height = initial_ankle_height
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(index) > float(leave_index):
         if float(index) > float(leave_index):
             if float(result[index]["leg_heigh"]) < initial_ankle_height - 3:
             if float(result[index]["leg_heigh"]) < initial_ankle_height - 3:
                 if float(result[index]["knee_right_angle"]) >= float(max_hip_angle):
                 if float(result[index]["knee_right_angle"]) >= float(max_hip_angle):
@@ -140,6 +148,8 @@ def cal_jump(result):
     lowest_ankle_height = float(result[reland_index]["leg_heigh"])
     lowest_ankle_height = float(result[reland_index]["leg_heigh"])
     lowest_ankle_index = list(result.keys())[0]
     lowest_ankle_index = list(result.keys())[0]
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if int(index) <= int(highest_ankle_index):
         if int(index) <= int(highest_ankle_index):
             continue
             continue
         else:
         else:

+ 4 - 0
backend_refactor/service/ai/video/video_score/jumpwithboth.py

@@ -73,6 +73,8 @@ def cal_jumpwithboth(result):
     highest_ankle_index = list(result.keys())[0]
     highest_ankle_index = list(result.keys())[0]
 
 
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["leg_heigh"]) < float(highest_ankle) and float(
         if float(result[index]["leg_heigh"]) < float(highest_ankle) and float(
                 result[index]["leg_heigh"]) != 0.0:
                 result[index]["leg_heigh"]) != 0.0:
             highest_ankle = float(result[index]["leg_heigh"])
             highest_ankle = float(result[index]["leg_heigh"])
@@ -91,6 +93,8 @@ def cal_jumpwithboth(result):
     ground_height = max(float(result[list(result.keys())[0]]["leg_left_heigh"]),
     ground_height = max(float(result[list(result.keys())[0]]["leg_left_heigh"]),
                         float(result[list(result.keys())[0]]["leg_right_heigh"]))
                         float(result[list(result.keys())[0]]["leg_right_heigh"]))
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if index == list(result.keys())[0]: continue
         if index == list(result.keys())[0]: continue
         if float(result[str(int(index) - 1)]["leg_heigh"]) <= float(result[index]["leg_heigh"]) and float(
         if float(result[str(int(index) - 1)]["leg_heigh"]) <= float(result[index]["leg_heigh"]) and float(
                 result[index]["leg_heigh"]) >= ground_height:
                 result[index]["leg_heigh"]) >= ground_height:

+ 8 - 0
backend_refactor/service/ai/video/video_score/pingban.py

@@ -48,6 +48,8 @@ def cal_pingban(result):
     re = {}
     re = {}
     # clean the data
     # clean the data
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["knee_right_angle"]) == 0.0:
         if float(result[index]["knee_right_angle"]) == 0.0:
             result_ig[index]["knee_right_angle"] = result[index]["knee_left_angle"]
             result_ig[index]["knee_right_angle"] = result[index]["knee_left_angle"]
         if float(result[index]["knee_left_angle"]) == 0.0:
         if float(result[index]["knee_left_angle"]) == 0.0:
@@ -55,6 +57,8 @@ def cal_pingban(result):
     # whether it has prepared posture
     # whether it has prepared posture
     is_prepared = False
     is_prepared = False
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["knee_right_angle"]) < 100 and float(result[index]["knee_left_angle"]) < 100:
         if float(result[index]["knee_right_angle"]) < 100 and float(result[index]["knee_left_angle"]) < 100:
             is_prepared = True
             is_prepared = True
     # prepared posture: when knee at its lowest,number is highest
     # prepared posture: when knee at its lowest,number is highest
@@ -63,6 +67,8 @@ def cal_pingban(result):
     if is_prepared:
     if is_prepared:
         lowest_knee = float(result_ig[list(result.keys())[0]]["knee_heigh"])
         lowest_knee = float(result_ig[list(result.keys())[0]]["knee_heigh"])
         for index in result:
         for index in result:
+            if len(result[index]) == 0:
+                continue
             if float(lowest_knee) < float(result[index]["knee_heigh"]):
             if float(lowest_knee) < float(result[index]["knee_heigh"]):
                 lowest_knee = result[index]["knee_heigh"]
                 lowest_knee = result[index]["knee_heigh"]
                 first_index = index
                 first_index = index
@@ -85,6 +91,8 @@ def cal_pingban(result):
     second_pics = []
     second_pics = []
     satisfied_index = []
     satisfied_index = []
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(index) < float(first_index):
         if float(index) < float(first_index):
             continue
             continue
         else:
         else:

+ 2 - 0
backend_refactor/service/ai/video/video_score/sitforward.py

@@ -38,6 +38,8 @@ def cal_sitforward(result):
     highest_weist_index = list(result.keys())[0]
     highest_weist_index = list(result.keys())[0]
 
 
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["wrist_x"]) < float(highest_wrist_x) and float(result[index]["wrist_x"]) != 0:
         if float(result[index]["wrist_x"]) < float(highest_wrist_x) and float(result[index]["wrist_x"]) != 0:
             highest_wrist_x = result[index]["wrist_x"]
             highest_wrist_x = result[index]["wrist_x"]
             highest_weist_index = index
             highest_weist_index = index

+ 4 - 0
backend_refactor/service/ai/video/video_score/standing.py

@@ -70,9 +70,13 @@ def cal_standing(result):
     minest_knee_angle_index = list(result.keys())[0]
     minest_knee_angle_index = list(result.keys())[0]
 
 
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["knee_right_angle"]) < 165:
         if float(result[index]["knee_right_angle"]) < 165:
             mode = "knee_right_angle"
             mode = "knee_right_angle"
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index][mode]) < 168:
         if float(result[index][mode]) < 168:
             if begin_index == 0:
             if begin_index == 0:
                 begin_index = index
                 begin_index = index

+ 6 - 0
backend_refactor/service/ai/video/video_score/tennisthrow.py

@@ -72,6 +72,8 @@ def cal_tennisthrow(result):
     highest_wrist = 1000
     highest_wrist = 1000
     highest_wrist_index = 0
     highest_wrist_index = 0
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["wrist_left_heigh"]) < float(neck_height) and float(
         if float(result[index]["wrist_left_heigh"]) < float(neck_height) and float(
                 result[index]["wrist_left_heigh"]) != 0:
                 result[index]["wrist_left_heigh"]) != 0:
             print(float(result[index]["wrist_left_heigh"]))
             print(float(result[index]["wrist_left_heigh"]))
@@ -81,6 +83,8 @@ def cal_tennisthrow(result):
     print(hand)
     print(hand)
     # third score
     # third score
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if hand == "elbow_right_angle":
         if hand == "elbow_right_angle":
             if float(result[index]["wrist_right_heigh"]) < float(highest_wrist) and float(
             if float(result[index]["wrist_right_heigh"]) < float(highest_wrist) and float(
                     result[index]["wrist_right_heigh"]) != 0:
                     result[index]["wrist_right_heigh"]) != 0:
@@ -98,6 +102,8 @@ def cal_tennisthrow(result):
     farrest_distance_index = list(result.keys())[0]
     farrest_distance_index = list(result.keys())[0]
     farrest_distance = 0
     farrest_distance = 0
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(index) < float(highest_wrist_index):
         if float(index) < float(highest_wrist_index):
             if hand == "elbow_right_angle":
             if hand == "elbow_right_angle":
                 if float(result[index]["wrist_right_distance"]) > float(farrest_distance) and float(
                 if float(result[index]["wrist_right_distance"]) > float(farrest_distance) and float(

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

@@ -105,6 +105,8 @@ def cal_turnaround(result):
     key_index = 0
     key_index = 0
     satisfied_index = []
     satisfied_index = []
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(result[index]["foot_distance"]) > float(
         if float(result[index]["foot_distance"]) > float(
                 result[list(result.keys())[key_index - 1]]["foot_distance"]) and float(
                 result[list(result.keys())[key_index - 1]]["foot_distance"]) and float(
             result[index]["foot_distance"]) < float(
             result[index]["foot_distance"]) < float(
@@ -134,6 +136,8 @@ def cal_turnaround(result):
     lowest_midhip = 0
     lowest_midhip = 0
     lowest_midhip_index = 0
     lowest_midhip_index = 0
     for index in result:
     for index in result:
+        if len(result[index]) == 0:
+            continue
         if float(lowest_midhip) < float(result[index]["midhip_heigh"]) and float(
         if float(lowest_midhip) < float(result[index]["midhip_heigh"]) and float(
                 result[index]["midhip_heigh"]) != 0:
                 result[index]["midhip_heigh"]) != 0:
             lowest_midhip = result[index]["midhip_heigh"]
             lowest_midhip = result[index]["midhip_heigh"]