POV-Ray : Newsgroups : povray.pov4.discussion.general : A false projection matrix!!!! Server Time
21 Dec 2024 09:26:13 EST (-0500)
  A false projection matrix!!!! (Message 1 to 2 of 2)  
From: StudentPHD
Subject: A false projection matrix!!!!
Date: 18 Mar 2013 02:40:01
Message: <web.5146b5e68dc236d254c63d880@news.povray.org>
Hello,

I am developping an 3D reconstruction application. So I am generating some
testing images using pov ray. To achieve the 3D reconstruction, I have to
calculate the matrix projection.
I am developping all necessary functions and I calculate the matrix project p=
K*[R,-R*C] where R is the rotation matrix and C is the camera center and K is
the internal matrix of the camera.
my camera setting is like this:

camera {
                        location<0, 0, 0>
                        rotate<20,-45,0>
                        translate<300, 250, -300>
                        up <0,2,0>
                        right <2,0,0>
                        direction <0, 0, 1>
                        look_at <0,0,1>  }


The focal f=1, (norm[direction]), the angle =90 and the image is rendered as
600*800 pixels, so the matrix K=
(400 0 400.
0 -300  300.
0 0 1 ).


I calculate the rotation matrix like this:

Rx=RotationMatrix[20,{1,0,0}];
Ry=RotationMatrix[-45,{0,1,0}];
Rz=RotationMatrix[0,{0,0,1}];

R=Transpose[Rx,Ry,Rz].

C=[300,250,-300];

To check if my Matrix P is true or not.
1)  I photograph a cube using the camera above. I obtain its image 2D.
Therefore, I extract the coordinates of  3D corner of the cube and the
coordinate of its projection in the image 2D. for example corner 1= (100,0,-180)
its projection is (123,439).
2) I construct the same cube on matlab and I project it on 2D using the
projection matrix p and I get the coordinate 2D of the corners. I obtain the
results:

if I cancel the rotation and the translation (R=matrix identity and C=(0,0,0))
the coordinate of corners are maching very well, so P is correct

If I translate the camera, The corner are matching very well, so P is correct.

If I make a translation and rotation, the corners does not match, so P is not
correct. So where is the error in my code and  is the  camera setting is correct
(I mean that I rotate the camera then I translate it or the inverse, regarding
the calculation of the matrix P=K*[R,-R*C]) ?

Is the calculation of the R is false or what????!! thanks to help me


Post a reply to this message

From: Simon Copar
Subject: Re: A false projection matrix!!!!
Date: 20 Mar 2013 22:00:01
Message: <web.514a68bf3457eecef42173100@news.povray.org>
Povray executes the transformations in the order they are specified. Therefore,
your code transforms THE CAMERA first by rotating by 20 DEGREES around x, THEN
-45 DEGREES around y, then translate. Of course, transforming the camera is
inverse of transforming the object. So, if you are transforming the cube, you
first do the translation in reverse, then the rotations in reverse (basically,
matrix inverse).

> R=Transpose[Rx,Ry,Rz].

What syntax is that? Shouldn't this be Rz*Ry*Rx?

I hope this helps.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.