Reputation: 957
I have a question.Lets say i captured a image from camera.after that i rotate my camera to rX,rY,rZ( pitch , Yaw , Roll ) and translate it to ( Tx , Ty , Tz ) and capture second image .Now where will a image pixel point(Px,Py) in first image will be in second image ?
Px,Py ( any pixel point in image - given )
rX,rY,rZ , Tx , Ty , Tz (camera rotation and translation vectors - given)
have to find new value of that pixel point after camera rotation.
Any equation or logic to solve this problem ? it may be easier but i couldn't find the solution.please help me.
thanks.
Upvotes: 2
Views: 605
Reputation: 64273
You can search for opengl transformation math
. The links should provide you the math behind rotation and translation in 3d.
For example, this link shows :
Rotations:
Rotation about the X axis by an angle a:
|1 0 0 0|
|0 cos(a) -sin(a) 0|
|0 sin(a) cos(a) 0|
|0 0 0 1|
Upvotes: 0
Reputation: 20038
You might want to read up on Epipolar Geometry. Without knowing anything else than image coordinates, your corresponding pixel could be anywhere along a line in the second image.
Upvotes: 1
Reputation: 67492
Unfortunately you don't have enough information to solve the problem. Let's see if I can make a drawing here to show you why:
/
cam1 < (1) (2) (3)
\
\ /
v
cam2
I hope this is clear. Let's say you take three pictures from cam1
, with some object located at (1)
, (2)
and (3)
. In all three cases the object is located exactly in the center of the picture.
Now you move the camera to the cam2
location, which involves a 90 degree counter clockwise rotation on Y plus some translation on X and Z.
For simplicity, let's say your Px,Py
is the center of the picture. The three pictures that you took with cam1
have the same object at that pixel, so whatever equations and calculations you come up with to locate that pixel in the cam2
pictures, they will have the same input for the three pictures, so they will also produce the same output. But clearly, that will be wrong, since from the cam2
location each of the three pictures that you take will see the object in a very different position, moving horizontally across the frame.
Do you see what's missing?
If you wanted to do this properly, you would need your cam1
device to also capture a depth map, so that for each pixel you also know how far away from the camera the object represented by it was. This is what will differentiate the three pictures where the object moves farther away from the camera.
If you had the depth for Px,Py
, then you can then do an inverse perspective projection from cam1
and obtain the 3D location of that pixel relative to cam1
. You will then apply the inverse rotation and translation to convert the point to the 3D space relative to cam2
, and then do a perspective projection from cam2
to find what will be the new pixel location.
Sorry for the bad news, I hope this helps!
Upvotes: 2