2
\$\begingroup\$

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.

enter image description here

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.

\$\endgroup\$
  • \$\begingroup\$ And why don't you have their 3D coordinates ? \$\endgroup\$ – concept3d Jan 21 '15 at 12:23
  • \$\begingroup\$ 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. \$\endgroup\$ – Gustavo Maciel Jan 21 '15 at 12:37
  • \$\begingroup\$ @concept3d : what i want is find 3D orientation from a 2D picture. \$\endgroup\$ – tigrou Jan 21 '15 at 12:42
  • \$\begingroup\$ @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. \$\endgroup\$ – concept3d Jan 21 '15 at 13:07
  • \$\begingroup\$ @tigrou I hoped to tell me why you want to do this? why you can't have the data in your game/engine/app ? \$\endgroup\$ – concept3d Jan 21 '15 at 13:15
1
\$\begingroup\$

You can look into the Perspective n Point problem. I think that's what this issue is officially called.

\$\endgroup\$
0
\$\begingroup\$

Well, getting 2d orientation from 3d points can be done by multiplying it with the world, view, and projection matrices. You could reverse these calculations. The thing is, you don´t know depth. What you get is a line inside the viewing frustum , between the near and far clipping plane of the camera, that tells you where you see this point. But there is no way to know how far away from the camera it is.

UNLESS of course, these points are always on a certain plane, but that´s unlikely given the nature of your question.

You can't know which of the points on a line is closer to the camera, so you can't know how the plane is rotated, so you can't get the "up" vector

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.