取消单双杠下杠判断

This commit is contained in:
渣渣和 2024-10-08 13:18:39 +08:00
parent 9a00408ac3
commit e9642b4763
3 changed files with 34 additions and 30 deletions

View File

@ -45,7 +45,7 @@ class PullUp_1(BaseExercise):
self.initial_wrist_2_y = 0
# 引体向上参数
self.corner = (0, 480, 240, 400)
self.corner = (0, 480, 250, 410)
MediapipeAlgorithmPlugin.set_corner(corner=self.corner)
MediapipeAlgorithmPlugin.set_config(config=self.config)
@ -165,12 +165,12 @@ class PullUp_1(BaseExercise):
# height_left = math.sqrt(math.pow(shoulder_2_x - hip_2_x, 2) + math.pow(shoulder_2_y - hip_2_y, 2))
# height_right = math.sqrt(math.pow(shoulder_1_x - hip_1_x, 2) + math.pow(shoulder_1_y - hip_1_y, 2))
if wrist_1_y - self.initial_wrist_1_y > 50 and wrist_2_y - self.initial_wrist_2_y > 50 and self.pre_pos == 1:
self.end_test += 1
if self.end_test > 10:
self.speak_driver.add_speak("双手已离开单杠,考试结束")
self.pre_pos = 2
self.had_done = True
# if wrist_1_y - self.initial_wrist_1_y > 50 and wrist_2_y - self.initial_wrist_2_y > 50 and self.pre_pos == 1:
# self.end_test += 1
# if self.end_test > 10:
# self.speak_driver.add_speak("双手已离开单杠,考试结束")
# self.pre_pos = 2
# self.had_done = True
# if height_left < self.initial_height_left and height_right < self.initial_height_right:
# self.t += 1
@ -192,7 +192,7 @@ class PullUp_1(BaseExercise):
self._time = 0
self.body_state = 0
if (head_1_y < hand_1_y or head_2_y < hand_2_y) and wrist_1_y - self.initial_wrist_1_y < 50 and wrist_2_y - self.initial_wrist_2_y < 50 and not self.had_done:
if (head_1_y <= hand_1_y or head_2_y <= hand_2_y) and wrist_1_y - self.initial_wrist_1_y < 50 and wrist_2_y - self.initial_wrist_2_y < 50:
self.feedback = "下落"
if self.state == 0:
if self.direction == 1:

View File

@ -147,10 +147,9 @@ class Tricep_dip_1(BaseExercise):
self.heel = heel_y
self.speak_driver.add_speak("上杠,听到提示声后开始考试")
if self.readiness_state == 1:
if elbow_1 > 157 and eye_1_y < wrist_1_y and eye_2_y < wrist_2_y and (shoulder_1 < 30 or shoulder_2 < 30) and heel_y < self.heel - 30:
# if elbow_1 > 157 and eye_1_y < wrist_1_y and eye_2_y < wrist_2_y and (shoulder_1 < 30 or shoulder_2 < 30):
if (elbow_1 > 157 or elbow_2 > 157)and eye_1_y < wrist_1_y and eye_2_y < wrist_2_y and (shoulder_1 < 30 or shoulder_2 < 30) and heel_y < self.heel - 30:
self.time_0 += 1
if self.time_0 > 30:
if self.time_0 > 15:
if vis_shoulder_1 > 0.8 and vis_shoulder_1 > vis_shoulder_2:
self.time_1 += 1
if self.time_1 > 3:
@ -174,14 +173,14 @@ class Tricep_dip_1(BaseExercise):
if self.dir == 1 and self.pre_pos == 1 and self.form == 1:
shoulder_angle = self.detector.findIncludedAngle(elbow_1_x, elbow_1_y, wrist_1_x, wrist_1_x)
if wrist_1_y - self.initial_wrist_1_y > 50 or heel_y > self.heel:
self.end_test += 1
if self.end_test > 10:
self.speak_driver.add_speak("双手已离开双杠,考试结束")
self.pre_pos = 2
self.had_done = True
# if wrist_1_y - self.initial_wrist_1_y > 50 or heel_y > self.heel- 5:
# self.end_test += 1
# if self.end_test > 10:
# self.speak_driver.add_speak("双手已离开双杠,考试结束")
# self.pre_pos = 2
# self.had_done = True
if elbow_1 <= 102 or shoulder_1_y >= elbow_1_y:
if elbow_1 <= 97 and shoulder_1_y >= elbow_1_y - 5:
self.feedback = "上升"
if self.state == 1:
self.time += 1
@ -190,7 +189,7 @@ class Tricep_dip_1(BaseExercise):
self.state = 0
self.time = 0
if elbow_1 >= 146 and shoulder_1_y < elbow_1_y and shoulder_1_y < self.initial_wrist_1_y - 60 and shoulder_angle > 60 and not self.had_done and self.count > 0 and wrist_1_y - self.initial_wrist_1_y < 50 and heel_y < self.heel - 5:
if elbow_1 >= 146 and shoulder_1_y < elbow_1_y and shoulder_1_y < self.initial_wrist_1_y - 60 and shoulder_angle > 60 and self.count > 0 and wrist_1_y - self.initial_wrist_1_y < 50 and heel_y < self.heel - 5:
self.feedback = "下落"
if self.state == 0:
self.time += 1
@ -203,14 +202,14 @@ class Tricep_dip_1(BaseExercise):
elif self.dir == 2 and self.pre_pos == 1 and self.form == 1:
shoulder_angle = self.detector.findIncludedAngle(elbow_2_x, elbow_2_y, wrist_2_x, wrist_2_x)
if wrist_2_y - self.initial_wrist_2_y > 50 or heel_y > self.heel -5:
self.end_test += 1
if self.end_test > 10:
self.speak_driver.add_speak("双手已离开双杠,考试结束")
self.pre_pos = 2
self.had_done = True
# if wrist_2_y - self.initial_wrist_2_y > 50 or heel_y > self.heel - 5:
# self.end_test += 1
# if self.end_test > 10:
# self.speak_driver.add_speak("双手已离开双杠,考试结束")
# self.pre_pos = 2
# self.had_done = True
if elbow_2 <= 102 or shoulder_2_y >= elbow_2_y :
if elbow_2 <= 97 and shoulder_2_y >= elbow_2_y - 5:
self.feedback = "上升"
if self.state == 1:
self.time += 1
@ -219,7 +218,7 @@ class Tricep_dip_1(BaseExercise):
self.state = 0
self.time = 0
if elbow_2 >= 146 and shoulder_2_y < elbow_2_y and shoulder_2_y < self.initial_wrist_2_y - 60 and shoulder_angle > 60 and not self.had_done and self.count > 0 and wrist_2_y - self.initial_wrist_2_y < 50 and heel_y < self.heel - 5:
if elbow_2 >= 146 and shoulder_2_y < elbow_2_y and shoulder_2_y < self.initial_wrist_2_y - 60 and shoulder_angle > 60 and self.count > 0 and wrist_2_y - self.initial_wrist_2_y < 50 and heel_y < self.heel - 5:
self.feedback = "下落"
if self.state == 0:
self.time += 1

View File

@ -488,7 +488,7 @@ class ExerciseBackend(LSZXBackend.base_driver.BaseDriver):
video_name = self.project.info[ID] + '_' + self.project.info[
"name"] + '_' + self.project.exercise_type + '_' + 'unknow'
# 开始屏幕录制
# video_recorder.write_start(video_name)
video_recorder.write_start(video_name)
self.project.start()
self.project.waiting_for_start()
# 清空传送管理端的成绩
@ -578,6 +578,13 @@ class ExerciseBackend(LSZXBackend.base_driver.BaseDriver):
self.send_sql_score_signal.set()
_count = count
_score = real_score
elif self.exercise_tag in {PULLUP, TRICEDIP} and had_done == False:
# 结束屏幕录制
video_name = self.project.info[ID] + '_' + self.project.info[
"name"] + '_' + self.project.exercise_type + '_' + str(real_score)
video_recorder.write_stop(video_name)
_count = count
_score = real_score
else:
_count = -1
_score = 0
@ -590,9 +597,7 @@ class ExerciseBackend(LSZXBackend.base_driver.BaseDriver):
_record = float(_result[0]['record'])
_score = float(_result[0]['score'])
if self.exercise_tag in {PUSHUP, PULLUP, SITUP, OVERHANG, TRICEDIP}:
print(111111)
if float(count) > _record or real_score > _score:
print(self.exercise_tag)
response_code = self.manager.update_counting_score(record=count, score=real_score,
person_id=person_id,
score_type=self.exercise_tag)