2

First time asking a question on the stack exchange, hopefully this is the right place.

I can't seem to develop a close enough approximation algorithm for my situation as I'm not exactly the best in terms of 3D math.

I have a 3d environment in which I can access the position and rotation of any object, including my camera, as well as run trace lines from any two points to get distances between a point and a point of collision. I also have my camera's field of view. I do not have any form of access to the world/view/projection matrices however.

I also have a collection of 2d images that are basically a set of screenshots of the 3d environment from the camera, each collection is from the same point and angle and the average set is taken at about an average of a 60 degree angle down from the horizon.

I have been able to get to the point of using "registration point entities" that can be placed in the 3d world that represent the corners of the 2d image, and then when a point is picked on the 2d image it is read as a coordinate with range 0-1, which is then interpolated between the 3d positions of the registration points. This seems to work well, but only if the image is a perfect top down angle. When the camera is tilted and another dimension of perspective is introduced, the results become more grossly inaccurate as there no compensation for this perspective.

I don't need to be able to calculate the height of a point, say a window on a sky scraper, but at least the coordinate at the base of the image plane, or which if I extend a line out from my image from a specified image space point I need at least the point that the line will intersect with the ground if there was nothing in the way.

All of the material I found about this says to just deproject the point using the world/view/projection matrices, which I find straightforward in itself except I don't have access to these matrices, just data I can collect at screenshot time and other algorithms use complex maths I simply don't grasp yet.

One end goal of this would be able to place markers in the 3d environment where a user clicks in the image, while not being able to run a simple deprojection from the user's view.

Any help would be appreciated, thanks.

Edit: Herp derp, while my implementation for doing so is a bit odd due to the limitations of my situation, the solution essentially boiled down to ananthonline's answer about simply recalculating the view/projection matrices.

Allar
  • 140
  • 8
  • Are you able to "take screenshots" of artificial/reference objects you can place in this 3D environment? If yes, you might be able to reverse engineer the view/projection matrices. – Ani May 14 '12 at 18:59
  • I can't have anything visual that isn't the 3D environment at hand show up in these images, however I can introduce things that won't be rendered to the 3d environment which can provide position/rotation/trace line checks, or anything that you wouldn't need direct rendering pipeline access to. – Allar May 14 '12 at 19:06
  • One more question: between position, rotation and FOV of the camera, could you not calculate the View/Projection matrices of the camera (http://www.songho.ca/opengl/gl_projectionmatrix.html) - thus allowing you to unproject known 3D points? – Ani May 14 '12 at 19:18
  • I had an issue of not having any world data to unproject onto after doing so, but reading your comment sparked a chain of thought that allowed for this to no longer being an issue. Now I feel kind of stupid :). I would upvote your comment if I had the reputation to do so, but if you supply an answer I'll gladly close this question. – Allar May 14 '12 at 19:38
  • Done, the comment above rephrased as an answer. – Ani May 14 '12 at 19:42

1 Answers1

0

Between position, rotation and FOV of the camera, could you not calculate the View/Projection matrices of the camera (songho.ca/opengl/gl_projectionmatrix.html) - thus allowing you to unproject known 3D points?

Ani
  • 10,826
  • 3
  • 27
  • 46