So, I have been working on a cricket ball tracking project and have managed to do ball detection and tracking fairly successfully. The next step is to predict the future trajectory, using polynomial regression.
Below is an illustration of the stage I am at. The blue dots represent the last few ball locations before the ball reaches the batsman.
Now, if I were to apply regression on these points to predict the future path (i.e. where the ball would go if it is not intercepted), I might get something like this:
The issue is, if I were to carry this red line on, it would appear to pass above the stumps and carry on due to the perspective from which the video is taken when in reality, the ball would actually go on to hit the stumps and not carry on past the batsman. However, this is the only viewing angle I have.
(For reference, the stumps are the three sticks at either end of a cricket pitch:
In the image on which I've plotted ball positions, the batsman is partially obscuring the stumps.)
I am unsure on how to fix this issue however.
Is it possible to apply some kind of perspective transform to the video frames so that the viewing angle is improved, and the predicted trajectory might more closely match reality?
Alternatively, is it possible to compute the height of the ball above the ground? Then I can compare this to the height of the stumps (known, both in pixels in the video frames, and in real life). I also know the (x,y) coordinates of a single point when the ball is in contact with the ground (height = 0).
Lastly, I believe I can also calculate approximate 3D depths - i.e. at any point, how far along the pitch is the ball - if this may help. I haven't tried to implement this, however, because I wasn't sure how depths would fix my problem.
Any suggestions would be much appreciated because this is the last hurdle on a project I've spent a lot of hours on!