diff --git a/Exercise3/pull_up_1.py b/Exercise3/pull_up_1.py index 1e05e26..9efb09e 100644 --- a/Exercise3/pull_up_1.py +++ b/Exercise3/pull_up_1.py @@ -129,10 +129,16 @@ class PullUp_1(BaseExercise): hip_2_x = self.detector.findPosition(img, False)[24][1] hip_2_y = self.detector.findPosition(img, False)[24][2] + hand_1_y = (wrist_1_y + index_1_y) / 2 + hand_2_y = (wrist_2_y + index_2_y) / 2 + head_1_y = (mouth_1_y + eye_1_y) / 2 + head_2_y = (mouth_2_y + eye_2_y) / 2 + h_range = mouth_1_y - hand_1_y + # 成功概率 - self.per = np.interp(elbow_1, (157, 100), (0, 100)) + self.per = np.interp(h_range, (90, 0), (0, 100)) # 显示进度栏 - self.bar = np.interp(elbow_1, (157, 100), (280, 62)) + self.bar = np.interp(h_range, (90, 0), (280, 62)) if self.pre_pos == 0: self.pre_pos = 1 self.speak_driver.add_speak("请进入准备状态") @@ -147,21 +153,16 @@ class PullUp_1(BaseExercise): self.starttime = time.time() self.initial_wrist_1_y = wrist_1_y self.initial_wrist_2_y = wrist_2_y - self.initial_height_left = math.sqrt( - math.pow(shoulder_2_x - hip_2_x, 2) + math.pow(shoulder_2_y - hip_2_y, 2)) * math.cos( - math.pi / 4) - self.initial_height_right = math.sqrt( - math.pow(shoulder_1_x - hip_1_x, 2) + math.pow(shoulder_1_y - hip_1_y, 2)) * math.cos( - math.pi / 4) + # self.initial_height_left = math.sqrt( + # math.pow(shoulder_2_x - hip_2_x, 2) + math.pow(shoulder_2_y - hip_2_y, 2)) * math.cos( + # math.pi / 5) + # self.initial_height_right = math.sqrt( + # math.pow(shoulder_1_x - hip_1_x, 2) + math.pow(shoulder_1_y - hip_1_y, 2)) * math.cos( + # math.pi / 5) elif self.pre_pos == 1 and self.form == 1: - 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)) - hand_1_y = (wrist_1_y + index_1_y) / 2 - hand_2_y = (wrist_2_y + index_2_y) / 2 - head_1_y = (mouth_1_y + eye_1_y) / 2 - head_2_y = (mouth_2_y + eye_2_y) / 2 - h_range = head_1_y - hand_1_y + # 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 @@ -170,16 +171,16 @@ class PullUp_1(BaseExercise): 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 - if self.t > 4: - self.state = 1 - self.t = 0 - if self.body_state == 0: - self.speak_driver.add_speak('摆幅过大') - self.body_state = 1 + # if height_left < self.initial_height_left and height_right < self.initial_height_right: + # self.t += 1 + # if self.t > 4: + # self.state = 1 + # self.t = 0 + # if self.body_state == 0: + # self.speak_driver.add_speak('摆幅过大') + # self.body_state = 1 - if elbow_1 > 155 and elbow_2 > 155 and head_1_y > hand_1_y and head_2_y > hand_2_y: + if elbow_1 > 150 and elbow_2 > 150 and head_1_y > hand_1_y and head_2_y > hand_2_y: self.feedback = "上升" self.state = 0 if self.direction == 0: @@ -190,40 +191,41 @@ class PullUp_1(BaseExercise): self._time = 0 self.body_state = 0 - if head_1_y < hand_1_y and head_2_y < hand_2_y and not self.had_done: + if mouth_1_y < hand_1_y or mouth_2_y < hand_2_y and not self.had_done: self.feedback = "下落" if self.state == 0: if self.direction == 1: self._time += 1 if self._time > 2: + self.t = 0 self.count += 0.5 self.direction = 0 self._time = 0 if self.count % 1 == 0: - self.speak_driver.speed_control(200) + self.speak_driver.speed_control(320) self.speak_driver.add_speak("{}".format(int(self.count))) if self.count == 1: self.initial_wrist_1_y = wrist_1_y self.initial_wrist_2_y = wrist_2_y - if h_range < 20 and self.is_storard == 1: - self.time += 1 - if self.time > 3: - self.is_storard = 2 - self.time = 0 - elif head_1_y < hand_1_y and head_2_y < hand_2_y and self.is_storard == 2: - self.time += 1 - if self.time > 3: - self.is_storard = 3 - self.time = 0 - elif h_range > 30 and self.is_storard == 2: - self.time += 1 - if self.time > 3: - self.is_storard = 1 - self.speak_driver.add_speak('未过杠') - self.time = 0 - elif h_range > 30 and self.is_storard == 3: - self.time += 1 - if self.time > 3: - self.is_storard = 1 - self.time = 0 + # if h_range < 20 and self.is_storard == 1: + # self.time += 1 + # if self.time > 3: + # self.is_storard = 2 + # self.time = 0 + # elif head_1_y < hand_1_y and head_2_y < hand_2_y and self.is_storard == 2: + # self.time += 1 + # if self.time > 3: + # self.is_storard = 3 + # self.time = 0 + # elif h_range > 30 and self.is_storard == 2: + # self.time += 1 + # if self.time > 3: + # self.is_storard = 1 + # self.speak_driver.add_speak('未过杠') + # self.time = 0 + # elif h_range > 30 and self.is_storard == 3: + # self.time += 1 + # if self.time > 3: + # self.is_storard = 1 + # self.time = 0 diff --git a/Exercise3/tricep_dip.py b/Exercise3/tricep_dip.py index eed5bb2..bc66912 100644 --- a/Exercise3/tricep_dip.py +++ b/Exercise3/tricep_dip.py @@ -198,7 +198,7 @@ class Tricep_dip_1(BaseExercise): self.count += 0.5 self.state = 1 self.end_test = 0 - self.speak_driver.speed_control(200) + self.speak_driver.speed_control(320) self.speak_driver.add_speak("{}".format(int(self.count))) elif self.dir == 2 and self.pre_pos == 1 and self.form == 1: @@ -227,6 +227,6 @@ class Tricep_dip_1(BaseExercise): self.count += 0.5 self.state = 1 self.end_test = 0 - self.speak_driver.speed_control(200) + self.speak_driver.speed_control(320) self.speak_driver.add_speak("{}".format(int(self.count)))