Question: Here is the execution section for the code of bicep curl counter using jupyter notebook where the angle is calculated by detecting the landmarks of


Here is the execution section for the code of bicep curl counter using jupyter notebook where the angle is calculated by detecting the landmarks of shoulder, elbow and wrist. The output of the code is to show the both correct and incorrect repetitions. But the incorrect count is not accurately showing. Need a solution for that.
jupyter bicep_curl_counter Last Checkpoint: 12/21/2021 (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help Trusted Python 3 (ipykernel) O + 1 Run Code In [38]: cap = cv2.videoCapture(0) # Curl counter variables counter = stage = None incorrect = 0 angle = o previous_angle = 0 ## Setup mediapipe instance with mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5) as pose: while cap. isopened(): ret, frame = cap.read() # Recolor image to RGB image = CV2.cvtcolor (frame, CV2.COLOR_BGR2RGB) image. flags.writeable = False # Make detection results = pose.process(image) # Recolor back to BGR image.flags.writeable = True image = cv2.cvtcolor (image, cv2.COLOR_RGB2BGR) # Extract Landmarks try: landmarks = results.pose_landmarks.landmark # Get coordinates shoulder = [landmarks[mp_pose.PoseLandmark. LEFT_SHOULDER.value].x, landmarks [mp_pose. PoseLandmark.LEFT_SHOULDER.value elbow = [landmarks[mp_pose. PoseLandmark.LEFT_ELBOW.value] .x, landmarks[mp_pose. PoseLandmark. LEFT_ELBOW. value].y] wrist = [landmarks[mp_pose. PoseLandmark.LEFT_WRIST.value] .x, landmarks[mp_pose.PoseLandmark.LEFT_WRIST.value].y] # Calculate angle jupyter bicep_curl_counter Last Checkpoint 12/21/2021 (autosaved) Logout File Edit View Insert Cell Kernel Widgets Help Trusted Python 3 (ipykernel) O + E n Run Code # Calculate angle previous_angle = angle angle = calculate_angle(shoulder, elbow, wrist) # Visualize angle CV2. putText(image, str(angle), tuple(np.multiply(elbow, [640, 480]).astype(int)), CV2. FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 2, CV2.LINE_AA ) # Curl counter Logic if stage == None : if previous_angle - angle 5 and stage =='down': stage="up" if angle > 150: counter +=1 print(counter) else: incorrect +=1 print(incorrect) elif previous_angle - angle 5 and stage =='down': stage="up" if angle > 150: counter +=1 print(counter) else: incorrect +=1 print(incorrect) elif previous_angle - angle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
