What you need to know to calculate distance from the goal:
- Height of the camera image
- Vertical FOV
- Y-distance from the center of the image to some known point on the goal (such as the center of the U)
- The distance from that point to the ground
- The distance from the camera to the ground
- The angle from the camera to the ground
From these, you can calculate the angle of the target point above the horizontal and the distance from the camera to the target point by constructing a right triangle, with the height difference between the camera and the target image as the vertical leg, and the angle you just found as the angle opposite that leg.
Sorry about the poor formatting, I'm on mobile