Overview

The golftracker creates a simplified model of a golf swing by extracing relevant information from the video.

Terminology

FrameDir

This is a directory where the frames from a video are stored and processed.

Tracker

Object that stores the x and y coordinate of the interesting point in the frame. Bulk of the tracker are generated by mediapiple with the following class name.

Nose, LeftEyeInner, LeftEye, LeftEyeOuter, RightEyeInner, RightEye, RightEyeOuter, 
LeftEar, RightEar, MouthLeft, MouthRight, LeftShoulder, RightShoulder, LeftElbow, RightElbow, LeftWrist, RightWrist, LeftPinky, RightPinky, LeftIndex, RightIndex, LeftThumb, RightThumb, 
LeftHip, RightHip, LeftKnee, RightKnee, LeftAnkle, RightAnkle, LeftHeel, RightHeel, 
LeftFootIndex, RightFootIndex

Some of the trackers by cv2 have the following class name.

ClubGrip, ClubToe, ClubHeel

Each of the tracker has a “add_” method that will create the tracker and add it to an associative array.

Trackers

This is a associative array that stores the reference to the tracker object. The key is the snakecase repr of the class name of the tracker.

Json File

Json file are a json repsentation of the trackers associative array.

Control Flow

The package works on each frame of the video. It follows the following sequence.

  1. Split the incoming video file into frames stored in a framedir.

  • The default frame dir is the name of the video file without the suffix.

  • The name of each frame is “frame_N.png”. For easy sorting the numbers are left aligned.

  1. Runs the google media pipe to create the first set of json files, one for each frame.

  • The name of the output json file is “frame_N_mp.json”

  1. Read the json tracker and use the LeftWrist and RightWrist to do object detection of the club.

  • The name of the output json file is “frame_N_gd.json”

  1. Merge the json files to produce the final json file for each frame.

  • The name of the output json file “frame_N.json”

  1. Create new frames using the final json files.

  • The name of the new frames are “out_N.png”

  1. Merge the frames to create the new video file.

  • By default the regex “out_.*” will select all the output frames.

  • The name of the new video file is specified by the user.