I am trying to simulate the structure from motion.
- consider for a case where the motion is in x direction. I created the matching points as given below where there is a movement of 50 pixels in x direction only.
Previous Image co-ordinate
[0] {x=50.000 y=50.00 } [1] {x=100.00 y=50.00 }
[2] {x=150.00 y=50.00 } [3] {x=200.00 y=50.00 }
[4] {x=250.00 y=50.00 } [5] {x=300.00 y=50.00 }
[6] {x=50.000 y=100.0 } [7] {x=100.00 y=100.0 }
[8] {x=150.00 y=100.0 } [9] {x=200.00 y=100.0 }
[10] {x=250.00 y=100.0 } [11] {x=300.00 y=100.0 }
[12] {x=50.000 y=150.0 } [13] {x=100.00 y=150.0 }
[14] {x=150.00 y=150.0 } [15] {x=200.00 y=150.0 }
Current Image co-ordinate
[0] {x=100.0 y=50.0 } [1] {x=150.0 y=50.0 }
[2] {x=200.0 y=50.0 } [3] {x=250.0 y=50.0 }
[4] {x=300.0 y=50.0 } [5] {x=350.0 y=50.0 }
[6] {x=100.0 y=100. } [7] {x=150.0 y=100. }
[8] {x=200.0 y=100. } [9] {x=250.0 y=100. }
[10] {x=300.0 y=100. } [11] {x=350.0 y=100. }
[12] {x=100.0 y=150. } [13] {x=150.0 y=150. }
[14] {x=200.0 y=150. } [15] {x=250.0 y=150. }
Intrinsic Matrix
6.2821272+002 0. 3.474665e+002
0. 6.2886809e+002 2.4486120e+002
0. 0. 1.
with known Intrinsic matrix I calculated the fundamental matrix using opencv function(cvFindFundamentalMatrix
)
int fm_count = cvFindFundamentalMat( pMatPtsImgPrev, pMatPtsImgCurr,
pFundMat,CV_FM_RANSAC ,0.2,0.99, status);
the average pixex error is verymuch close to zero.
then find essential matrix from using the formula given below
E = CameraMatrix^T * F * CameraMatrix.
Essential matrix with X offset -6.227048e-030, 1.8018814e-014, 4.30140591e-015 3.1235024e-014, 2.7432764e-015, 7.02982759 9.885755751e-015, -7.0298275, 3.10862446e-015
Then decompose rotation and translation matrix as given in the below link using SVD - SVD decomp = SVD(E);
Extract Translation and Rotation from Fundamental Matrix
when decomposed the rotation angles Rx =0deg Ry =0deg and Rz =0deg.
This seems to be fine as the rotation is either 0 or 180deg.
When the co-ordinate is changed with translation in y direction only as the co-ordinates given below
Previous co-ordinate
[0] {x=50.00 y=50.00 } [1] {x=100.0 y=50.00 }
[2] {x=150.0 y=50.00 } [3] {x=200.0 y=50.00 }
[4] {x=250.0 y=50.00 } [5] {x=300.0 y=50.00 }
[6] {x=50.00 y=100.0 } [7] {x=100.0 y=100.0 }
[8] {x=150.0 y=100.0 } [9] {x=200.0 y=100.0 }
[10] {x=250.0 y=100.0 } [11] {x=300.0 y=100.0 }
[12] {x=50.00 y=150.0 } [13] {x=100.0 y=150.0 }
[14] {x=150.0 y=150.0 } [15] {x=200.0 y=150.0 }
Current co-ordinate
[0] {x=50.00 y=100.0 } [1] {x=100.0 y=100.0 }
[2] {x=150.0 y=100.0 } [3] {x=200.0 y=100.0 }
[4] {x=250.0 y=100.0 } [5] {x=300.0 y=100.0 }
[6] {x=50.00 y=150.0 } [7] {x=100.0 y=150.0 }
[8] {x=150.0 y=150.0 } [9] {x=200.0 y=150.0 }
[10] {x=250.0 y=150.0 } [11] {x=300.0 y=150.0 }
[12] {x=50.00 y=200.0 } [13] {x=100.0 y=200.0 }
[14] {x=150.0 y=200.0 } [15] {x=200.0 y=200.0 }
the same procedure and same intrinsic matrix is used to construct fundamental matrix and essential matrix.
Essential matrix with Y offset
-2.791314e-030, 2.5449611e-015, 5.095796479e-016
4.3544169e-015, -0.039722588, 0.99921074
] 1.78226326e-015, -0.999210746, -0.03972258
but the rotation decomposed is Rx=-2.27653561deg Ry = 180, and Rz = 0
What I am not understanding is how come Rx has some value as the translation is in either X and y direction, what i feel is the rotations should be either 0 or 180deg.
Kindy give me some hint so that if there is any problem in my code.