Closed lichq closed 9 months ago
hi, yes, the output of image_main
will tell you the translation, rotation and scale between the two input images.
With your sequence of images, are you running image_main
multiple times?
E.g.
./image_main im0.jpg im1.jpg
./image_main im1.jpg im2.jpg
./image_main im2.jpg im3.jpg
...
In that case, each output x, y will be the translation between each pair of inputs.
Since you have a sequence, my suggestion would be to adapt video_main
read a sequence of images. You should get the same result (i.e. translation, scale, rotation between every consecutive frame), but slightly more efficient since it preprocesses each frame only once.
yeah, thank you for your reply. I write a file reading stream based on image_main, so it just like running image_main multiple times. What I want to ask is that, for example, the pose of im0 is (0, 0, 0) (x, y, theta), and the result between im0 and im1 is (1, 1, 1, 3.14), im1 and im2 is (1, 1, 1, 3.14). so, the pose of im2 is (0, 0, 0)? If I want to draw a trajectory, in order to get the global pose of each image, I should multiplication. like Tn,n-1Tn-1,n-2 ... *T1, 0
in the example you gave, im2 would be (2, 2, 6.28) with respect to im0, since the translations and rotations should be added, and scaling should be multiplied.
If the result is in the form: (x, y, theta, scale), where x and y are in pixels, theta in degrees, and scale is unitless. im0 -> im1 = (1, 1, 10, 0.9) im1 -> im2 = (1, 1, 10, 0.9)
then the transformation of im2 with respect to im0 will be: im0 -> im2 = (2, 2, 20, 0.81)
in the example you gave, im2 would be (2, 2, 6.28) with respect to im0, since the translations and rotations should be added, and scaling should be multiplied.
If the result is in the form: (x, y, theta, scale), where x and y are in pixels, theta in degrees, and scale is unitless. im0 -> im1 = (1, 1, 10, 0.9) im1 -> im2 = (1, 1, 10, 0.9)
then the transformation of im2 with respect to im0 will be: im0 -> im2 = (2, 2, 20, 0.81)
In this case, if we assume im0 pose is (0, 0), so the pose of im2 is (2 cos(20) + 2 sin(20), 2 cos(20) - 2 sin(20)), right?
aah, yes of course, you're right that the first rotation affects the next transformation. I should have thought a bit more about that before answering!
The transformation matrix is in the form:
$$ T^n_{n+1} = \begin{bmatrix} cos(\theta) & -sin(\theta) & t_x \ sin(\theta) & cos(\theta) & t_y \ 0 & 0 & 1 \ \end{bmatrix} * \begin{bmatrix} scale &0 & 0 \ 0 & scale & 0 \ 0 & 0 & 1 \ \end{bmatrix} $$
So transformation from im0 to im1:
$$ T^0_1 = \begin{bmatrix} 0.9 cos(10) & -0.9 sin(10) & 1\ 0.9 sin(10) & 0.9 cos(10) & 1\ 0&0&1\ \end{bmatrix}$$
Transformation from im1 to im2:
$$ T^1_2 = \begin{bmatrix} 0.9 cos(10) & -0.9 sin(10) & 1\ 0.9 sin(10) & 0.9 cos(10) & 1\ 0&0&1\ \end{bmatrix}$$
Transformation from im0 to im2:
$$ T^0_2 = T^0_1 * T^1_2 =
\begin{bmatrix}
0.761 & -0.277 & 1.73\
0.277 & 0.761 & 2.04 \
0&0&1\
\end{bmatrix}$$
Final translation of im2 w.r.t im0 is hence (1.73, 2.04)
, final rotation is arccos(0.761 / 0.9 / 0.9) = 20 degrees
, final scaling = 0.81
Hi, thank you for your contribution. I have a question about the meaning of the result. I just use a sequence of images and get a series of the result from image_main. I found that if I draw the trajectory as x and y are global pose, it looks good. But as I understand that x and y should be a translation from the last pose right? I am not sure.. Could you give me some suggestions about this? thank you!