Skip to content

tabish3210/Machine-Learning-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The provided Python script is a program that uses the Mediapipe library for pose detection to create a simple arm curl counter. Let me explain the main components and functionality of the script:

Libraries Used:

  • cv2 (OpenCV): Used for computer vision tasks, such as reading video frames, drawing on images, and displaying the video feed.

  • mediapipe: Google's Mediapipe library, which provides solutions for various computer vision tasks, including holistic pose estimation.

  • math: Standard Python math library, used for mathematical calculations.

  • tkinter: A GUI library for creating the application window and components.

  • PIL (Pillow): Python Imaging Library, used for working with images.

Classes:

1. ArmCurlCounter:

  • Attributes:

    • in_curl_position_left and in_curl_position_right: Flags to track if the left and right arms are in the curl position.
    • reps_count_left and reps_count_right: Counters for the number of arm curls on the left and right sides.
  • Methods:

    • calculate_angle(a, b, c): Computes the angle between three points.
    • process_frame(frame, landmarks): Analyzes the frame and landmarks to detect arm curls and update counters.
    • draw_lines(frame, landmarks, connections): Draws lines connecting landmarks on the video frame.
    • draw_landmarks(frame, landmarks): Draws circles at the landmark positions on the video frame.

2. ArmCurlApp:

  • Attributes:

    • video_source: The source of the video (default is the camera).
    • vid: OpenCV VideoCapture object for capturing video frames.
    • arm_curl_counter: An instance of the ArmCurlCounter class.
    • canvas, label_reps, btn_exit: Tkinter GUI components.
  • Methods:

    • __init__(root, title): Initializes the application window, video capture, and GUI components.
    • exit_app(): Releases the video capture and destroys the Tkinter window.
    • update(): Updates the video feed, processes frames, and updates GUI components.
    • get_landmarks(frame): Uses Mediapipe to detect pose landmarks in a frame.
    • convert_to_photo(frame): Converts an OpenCV image to a Tkinter PhotoImage.

Execution:

  • The __main__ block initializes the Holistic model from Mediapipe with specific confidence thresholds.
  • An instance of the ArmCurlApp class is created, starting the Tkinter main event loop.

Functionality:

  1. The script captures video frames from the specified source (default is the camera).

  2. Pose landmarks are detected using the Holistic model.

  3. The ArmCurlCounter class processes the landmarks to detect arm curls and updates the counters.

  4. The GUI displays the video feed, drawn lines connecting landmarks, and the current count of arm curls.

  5. The "Exit" button can be used to close the application.

Note:

  • The script assumes that Mediapipe is properly installed, and the Holistic model is available.

  • It is important to have the required libraries (cv2, mediapipe, math, tkinter, PIL) installed before running the script.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages