<p>Unsure if this is the right network to post this, but maybe someone can help...</p>
<p>I'm working on a personal project where, with the help of AI, I want to automatically estimate the perspective of a given image.</p>
<p>I've been able to programatically estimate and draw the position of the horizon, as seen below. This is based on how &quot;quickly&quot; cars farther away shrink in the image.</p>
<p><a href="https://i.sstatic.net/q7fKtm.png" rel="noreferrer"><img src="https://i.sstatic.net/q7fKtm.png" alt="enter image description here" /></a></p>
<p>Not sure the above is useful, but now I want to draw a grid on the plane. Something like:</p>
<p><a href="https://i.sstatic.net/9LOFgm.png" rel="noreferrer"><img src="https://i.sstatic.net/9LOFgm.png" alt="enter image description here" /></a></p>
<p>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. Any ideas?</p>

CC BY-SA 4.0
2020-12-06T22:40:02.770Z
If you know the delta (shrinkage) between cars (it won't be that accurate as cars may have different sizes) maybe you can use that information to feed somehow a perspective matrix transform. I'd start by plotting the centroids of the rectangles in a 3d grid and manually tuning the input parameters for a perspective projection matrix, I think you could get fancier and use simulated annealing or something similar to do so too.
Felipe Gutierrez
CC BY-SA 4.0
2020-12-21T16:06:11.377Z
Note: your horizon estimate is a bit high.
joojaa
<projections><perspective><camera>
Project grid on 2d plane based on camera perspective
Chris
# Project grid on 2d plane based on camera perspective

(Asked by: username_0 on 2020-12-06)

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 and draw 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.sstatic.net/q7fKtm.png)](https://i.sstatic.net/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.sstatic.net/9LOFgm.png)](https://i.sstatic.net/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. Any ideas?

**Tags:** projections, perspective, camera

> **Comments:**
> **username_1**: If you know the delta (shrinkage) between cars (it won't be that accurate as cars may have different sizes) maybe you can use that information to feed somehow a perspective matrix transform. I'd start by plotting the centroids of the rectangles in a 3d grid and manually tuning the input parameters for a perspective projection matrix, I think you could get fancier and use simulated annealing or something similar to do so too.  
> **username_2**: Note: your horizon estimate is a bit high.  

---

## 0 answers

