FrontPoseDetector is a Python-based tool that leverages OpenCV and MediaPipe to detect whether a person is in a front-facing pose in both images and live video feeds. This tool can be useful for various applications, such as fitness tracking, gesture recognition, and many more.
- Python 3.x
- OpenCV
- MediaPipe
You can install the required packages using pip:
pip install opencv-python mediapipe
This script processes an image to detect whether the subject is in a front pose.
calculate_angle(v1, v2)
: Calculates the angle between two vectors.is_front_pose(landmarks)
: Determines if the detected pose is a front pose based on specific landmark visibility and angles.
- Load an image using OpenCV.
- Resize and convert the image to RGB.
- Use MediaPipe to process the image and extract pose landmarks.
- Check if the pose is a front pose using the
is_front_pose
function. - Draw landmarks on the image and display the result.
To run the script:
python frontPose.py
This script captures video from the webcam and detects if the subject is in a front pose in real-time. It also captures a photo if hands are detected in front of the chest and verifies the front pose in the captured image.
calculate_angle(v1, v2)
: Calculates the angle between two vectors.is_front_pose(landmarks)
: Determines if the detected pose is a front pose based on specific landmark visibility and angles.is_hand_in_front_of_chest(landmarks)
: Checks if any hand is in front of the chest.capture_photo()
: Captures a photo from the webcam.countdown_and_capture()
: Counts down and captures a photo.handle_hands_in_front()
: Handles the event when hands are detected in front.
- Initialize the webcam capture.
- Process each frame to detect pose landmarks.
- Check if hands are in front of the chest and handle the event accordingly.
- Display the pose landmarks on the video feed.
To run the script:
python frontVidpose.py
Front Pose | Not in Front Pose |
---|---|
The FrontVidpose.py
script opens the webcam and processes the video feed in real-time. When the user shows hand gestures in front of the chest, the tool starts a countdown (5 seconds). After the countdown, it captures a photo and checks if the user is in a front pose. The captured photo is then saved.