# How to calculate a 3D orientation from 2D vanishing lines on an image?

Let say I have a image that represent a 3D scene. I did not have the 3D camera orientation of that scene (left, up and forward vectors) and i'd like to calculate it.

On that picture, I draw the following segments : A1, A2 and B1, B2.

A1 and A2 are vanishing lines for the plane defined by left and up axis.

B1 and B2 are vanishing lines for the plane defined by forward and up axis.

As input, I only have 2D coordinates of segments (in screen space), so eight coordinates in total. This is the "handles "of the segments on the picture. I also have P0, a 2D position (in screen space) of the origin of the up / left / forward axis (not sure if this information is needed).

Is there a way, from that information, to retrieve the 3D orientation (in world space) of the 3D scene (so the left, up and forward vectors) ?

Once the forward and left vector are calculated getting the up one is trivial : cross product would do.

EDIT : As Peethor stated, there was some missing information to get what I wanted. I have update question and picture to add more details and make it more clear.

• And why don't you have their 3D coordinates ? – concept3d Jan 21 '15 at 12:23
• Where are these 2D coordinates? World Space or Screen Space? For World space you just use the same 2D coordinate but with Z as 0. For Screen Space, then you'll have to unproject them, which is just multiply by the inverse proj and world matrices. – Gustavo Maciel Jan 21 '15 at 12:37
• @concept3d : what i want is find 3D orientation from a 2D picture. – tigrou Jan 21 '15 at 12:42
• @tigrou Ok, can you tell us why do you want to do this? I always like to hear reasons to consider different solutions. Also what kind of image is it? Why it is not part of the 3D data ? If you don't know the depth of the pixels (can read the depth buffer) there is no way you can get the 3D position of these points. – concept3d Jan 21 '15 at 13:07
• @tigrou I hoped to tell me why you want to do this? why you can't have the data in your game/engine/app ? – concept3d Jan 21 '15 at 13:15