A open source project to develop live xG prediction models from photo and video input using Computer Vision.
Preprocessing
A component of any xG model is a player's position relative to the goal, intuitively we understand some positions are more difficult than others. I.e. A headon shot 10 yards out is easier than a shot 5 yards out but hugging the touchline. A easy way to quantify these positions is to derive a theta using the player's position and either goal posts. This theta can be used as a representation of an angle to goal. Simply, the larger the theta the better the chance. In order to derive a theta we must preprocess our images such that there is a sense of uniformity. We then can input keypoints to a standarized function and have that function return a theta.
2D Representation |
Real World Example |
Luckily we have standarized anchors that we can use to transform our photos to commonly align with each other. We will use the 6-yard box (and possibly the 16-yard box as well) to transform on the xy plane, we are unconcerned about the z-axis at the moment.
Base Image, with Anchor Points |
Input Image, with Input Points |
After using the input and anchor points we get the following transformed image which is now we can now derive theta from.
Anchor Image |
Transformed Image |
Full transform visualization:
See perspective_preprocessing.ipynb for code.