Reputation: 1
Here is my bug. I have made sure openpose is installed correctly.
poses = posenet.estimate_poses(frame)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'posenet' has no attribute 'estimate_poses'
Here is my code:
import posenet
import cv2
# Create a webcam object
cap = cv2.VideoCapture(0)
# Start the webcam
while True:
# Get the current frame from the webcam
ret, frame = cap.read()
# Use PoseNet to track the pose of your body in the frame
poses = posenet.estimate_poses(frame)
# Check if you are doing a squat
for pose in poses:
# Get the position of your hips and knees
left_hip = pose['keypoints'][11]
right_hip = pose['keypoints'][12]
left_knee = pose['keypoints'][13]
right_knee = pose['keypoints'][14]
# Check if your hips are higher than your knees
if (left_hip['y'] > left_knee['y']) and (right_hip['y'] > right_knee['y']):
# If you are doing a squat, press the w key
cv2.waitKey(100)
cv2.putText(frame, "Squat!", (10, 100), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
# Display the pose of your body on the screen
cv2.imshow("PoseNet", frame)
# If the user presses the Esc key, stop the program
if cv2.waitKey(1) == 27:
break
# Release the webcam
cap.release()
cv2.destroyAllWindows()
Upvotes: 0
Views: 64