开发者

Calculating 2D angles for 3D objects in perspective

Imagine a photo, with the face of a building marked out.

Its given that the face of the building is a rectangle, with 90 degree corners. However, because its a photo, perspective will be involved and the parallel edges of the face will converge on the horizon.

With such a rectangle, how do you calculate the angle in 2D of the vectors of the edges of a face that is at right angles to it?

In the image below, the blue is the face marked on the photo, and I'm wondering how to calculate the 2D vector of the red lines of the other face:

example http://img689.imageshack.us/img689/2060/leslievillestarbuckscor.jpg

So if you ignore the picture for a moment, and concentrate on the lines, is there enough information in one of the face outlines - the interior angles and such - to know the path of the face on the other side of the corner? What would the formula be?

Calculating 2D angles for 3D objects in perspective

We know that both are rectangles - that is that each corner is a right angle - and that they are at rig开发者_Go百科ht angles to each other. So how do you determine the vector of the second face using only knowledge of the position of the first?


It's quite easy, you should use basic 2 point perspective rules.

First of all you need 2 vanishing points, one to the left and one to the right of your object. They'll both stay on the same horizon line.

alt text http://img62.imageshack.us/img62/9669/perspectiveh.png

After having placed the horizon (that chooses the sight heigh) and the vanishing points (the positions of the points will change field of view) you can easily calculate where your lines go (of course you need to be able to calculate the line that crosses two points: i think you can do it)


Honestly, what I'd do is a Hough Transform on the image and determine a way to identify the red lines from the image. To find the red lines, I'd find any lines in the transform that touch your blue ones. The good thing about the transform is that you get angle information for free.

Since you know that you're looking at lines, you could also do a Radon Transform and look for peaks at particular angles; it's essentially the same thing.

Matlab has some nice functionality for this kind of work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜