Ejemplo n.º 1
0
    def check_down_position(self, wrist_position, elbow_position,
                            shoulder_position):
        print(wrist_position, elbow_position, shoulder_position)
        if check_close(wrist_position, elbow_position) and check_close(
                elbow_position, shoulder_position):
            return True

        return False
Ejemplo n.º 2
0
 def check_up_position(self, shoulder_x_position, elbow_x_position,
                       wrist_x_position):
     if check_close(shoulder_x_position, elbow_x_position) and check_close(
             elbow_x_position, wrist_x_position):
         self.logger.debug("Good up position")
         return True
     else:
         self.logger.debug("Good up position")
         return False
Ejemplo n.º 3
0
    def check_up_position(self, nose_position, wrist_y_position,
                          wrist_x_position, elbow_x_position,
                          shoulder_x_position):
        if nose_position < wrist_y_position + 10 and check_close(
                wrist_x_position, elbow_x_position) and check_close(
                    elbow_x_position, shoulder_x_position):
            return True

        return False
Ejemplo n.º 4
0
    def check_up_position(self, hip_x_position, knee_x_position,
                          shoulder_x_position, elbow_x_position,
                          wrist_x_position):
        if check_close(hip_x_position, shoulder_x_position) and check_close(
                knee_x_position, hip_x_position) and check_close(
                    elbow_x_position, shoulder_x_position) and check_close(
                        elbow_x_position, wrist_x_position):
            return True

        return False
Ejemplo n.º 5
0
 def check_up_position(self, shoulder_x_position, hip_x_position,
                       knee_x_position, shoulder_y_position,
                       wrist_y_position, elbow_y_position):
     print(shoulder_y_position, elbow_y_position)
     if check_close4(shoulder_x_position, hip_x_position) and check_close4(hip_x_position, knee_x_position) \
             and check_close(shoulder_y_position, elbow_y_position):
         self.logger.debug("Good up position: " + str(hip_x_position) +
                           " - " + str(knee_x_position) + " - " +
                           str(shoulder_x_position))
         return True
     else:
         self.logger.debug("Good up position: " + str(hip_x_position) +
                           " - " + str(knee_x_position) + " - " +
                           str(shoulder_x_position))
         return False
Ejemplo n.º 6
0
 def check_down_position(self, hip_y_position, knee_y_position,
                         shoulder_y_position, wrist_y_position,
                         elbow_y_position):
     print(hip_y_position, knee_y_position, shoulder_y_position,
           elbow_y_position)
     if (hip_y_position > knee_y_position or check_close5(
             hip_y_position, knee_y_position)) and check_close(
                 shoulder_y_position, elbow_y_position):
         self.logger.debug("Good down position: " + str(hip_y_position) +
                           " - " + str(knee_y_position))
         return True
     else:
         self.logger.debug("Bad down position: " + str(hip_y_position) +
                           " - " + str(knee_y_position))
         return False
Ejemplo n.º 7
0
 def check_down_position(self, wrist_position, shoulder_position):
     if check_close(wrist_position[0],
                    shoulder_position[0]) and check_close(
                        wrist_position[1], shoulder_position[1]):
         return True
     return False
Ejemplo n.º 8
0
    def check_exercise(self):
        list_of_frames = {}
        was_no_rep = False
        last_value_x = 0
        last_value_y = 0
        new_value_y = 0
        first_rep_detected = False
        first_rep_y_value = 0
        going_down = False  # movement starts by going down
        for i in range(0, self.json_reader.number_of_files):
            value, trust = self.json_reader.get_values(i, (HIP_VALUE, ))

            if self.counted_reps == self.reps:
                break

            if not trust or value == 0:
                continue

            if i == 0:
                last_value_x = value[0]
                last_value_y = value[1]
                continue

            new_value_y = value[1]

            heel_position_left, heel_position_right = self.get_heel_value(i)
            bigtoe_position_left, bigtoe_position_right = self.get_bigtoe_value(
                i)
            if check_close(heel_position_left[0], bigtoe_position_left[0]):
                self.check_body_orientation(bigtoe_position_left[0],
                                            heel_position_left[0])
            else:
                self.check_body_orientation(bigtoe_position_right[0],
                                            heel_position_right[0])

            if not going_down and last_value_y > new_value_y:
                if first_rep_detected is True and new_value_y < first_rep_y_value + 50:
                    pass

                elif not self.check_if_still_going_up(new_value_y, i):
                    knee_position_left, knee_position_right = self.get_knee_value(
                        i)
                    shoulder_position = self.get_shoulder_value(i)
                    heel_position_left, heel_position_right = self.get_heel_value(
                        i)
                    if not self.check_down_position(
                            last_value_y, knee_position_left,
                            knee_position_right, shoulder_position,
                            heel_position_left, heel_position_right):
                        print("fez mal baixo ", i)
                        # self.correct_reps += 1
                        was_no_rep = True
                    else:
                        print("fez bem baixo ", i, last_value_y, new_value_y)
                        was_no_rep = False

                    going_down = True

            elif going_down and last_value_y < new_value_y:
                if not self.check_if_still_going_down(new_value_y, i):
                    knee_position_left, knee_position_right = self.get_knee_value(
                        i)
                    shoulder_position = self.get_shoulder_value(i)
                    self.counted_reps += 1

                    #print(last_value_x, shoulder_position[0], knee_x_position)
                    if first_rep_detected is False:
                        first_rep_detected = True
                        first_rep_y_value = last_value_y
                    if self.check_up_position(
                            shoulder_position, last_value_x,
                            knee_position_left,
                            knee_position_right) and not was_no_rep:
                        print("fez bem cima ", i, first_rep_y_value)
                        self.correct_reps += 1
                        list_of_frames[i] = "rep"
                    else:
                        print("fez mal cima ", i)
                        self.no_reps += 1
                        list_of_frames[i] = "no rep"
                        #if self.no_reps + self.correct_reps == self.counted_reps:
                        #self.no_reps -= 1

                    going_down = False

            last_value_y = value[1]
            last_value_x = value[0]

        return self.correct_reps, self.no_reps, list_of_frames