Unsure if this is the right network to post this, but maybe someone can help...

I'm working on a personal project where, with the help of AI, I want to automatically estimate the perspective of a given image.

I've been able to programatically estimate the position of the horizon, as seen below. This is based on how "quickly" cars farther away shrink in the image.

[![enter image description here](https://i.stack.imgur.com/q7fKtm.png)](https://i.stack.imgur.com/q7fKtm.png)

Not sure the above is useful, but now I want to draw a grid on the plane. Something like:

[![enter image description here](https://i.stack.imgur.com/9LOFgm.png)](https://i.stack.imgur.com/9LOFgm.png)

This is where it's getting too complicated for me. I have no idea how to solve this. Not the drawing per se, but the mathematics behind it.

I first thought I needed to find the plane equation based on the coordinates of the bottom left and bottom right corners of each box, since these are the ones intersecting the plane (the tires touching the road).

I did manage to find the equation `ax + by + cy + d`, but I am not sure I am on the right track. Looking for some guidance if anyone has any ideas.

---

EDIT:

Just to clarify the unknowns:

* Distance to any object or horizon.
* Physical size of objects (in meters or otherwise)
* Height or angle of camera