Archived

This topic is now archived and is closed to further replies.

darksauron

deprojection

Recommended Posts

Imagine you have a red ball and you know its size. You have a webcam wich record images of the ball. In the picture of the webcams you see the red ball, but you wants to knwo is position in 3D space. The first idea is to use alpha=sin(coord/f) where f is the focal of the webcam, alpha the angle of the ray from the webcam to the ball and coord x or y. But is there a way to do this with matrix or quaternion ? I know we use a projection matrix to do 3D->2D transform, but what about 3D->2D (when we know elements like the size of the ball, that give the distance of the object)?? The projection matrix doesn''t have an inverse but is there a way to use matrix and create an elegant way to do this kind of calculation ????

Share this post


Link to post
Share on other sites
You cannot unproject from a point in R^(n) to R^(n-1) completly.

However- if you have a ball and can measure the rate of the apparent shrinkage, and already know the radius, you probably could extrapolate from there.

~V''lion

Bugle4d

Share this post


Link to post
Share on other sites
hmm... If you unproject, the ball centre will be on the infinite line shooting through the screen.

But if you know the ball diameter in the real world, and you know the ball diameter in pixels on the screen, you can extrapolate the distance of the ball from the screen along that line, thus giving you the depth. Also, due to the pixelisation and the camera distortions, the accuracy will be pretty dire after a given range (both short and long range). A triangulation would be much better, with say 2 or 3 cameras But calibration could be a pain in the ass.

With one camera, it''s worth a try though. The maths are fairly simple.

As far as the unproject matrix, if you decompose your camera in bits of information, it should be easy to visualise (position, orientation, FOVX, FOVY, near plane, width and height in pixels). Plenty of code around. Look at implementations of gluUnproject().

http://pyopengl.sourceforge.net/documentation/manual/gluUnProject.3G.html

Share this post


Link to post
Share on other sites