From e9642b4763727b2600f60bb6080e7ed7c0eda1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A3=E6=B8=A3=E5=92=8C?= <2608761159@qq.com> Date: Tue, 8 Oct 2024 13:18:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8D=95=E5=8F=8C=E6=9D=A0?= =?UTF-8?q?=E4=B8=8B=E6=9D=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Exercise3/pull_up_1.py | 16 +++++++------- Exercise3/tricep_dip.py | 37 ++++++++++++++++----------------- LSZXBackend/exercise_backend.py | 11 +++++++--- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/Exercise3/pull_up_1.py b/Exercise3/pull_up_1.py index 21e6d3d..bbe7b5c 100644 --- a/Exercise3/pull_up_1.py +++ b/Exercise3/pull_up_1.py @@ -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: diff --git a/Exercise3/tricep_dip.py b/Exercise3/tricep_dip.py index 4f6da19..da00469 100644 --- a/Exercise3/tricep_dip.py +++ b/Exercise3/tricep_dip.py @@ -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 diff --git a/LSZXBackend/exercise_backend.py b/LSZXBackend/exercise_backend.py index dfe60d4..42fcc37 100644 --- a/LSZXBackend/exercise_backend.py +++ b/LSZXBackend/exercise_backend.py @@ -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)