Hi, Why i am getting different values in diagonal of rotational matrix???
4 views (last 30 days)
Show older comments
I am trying to map four different corner points in two successive frames in my database. In my method i store location of this four points in one array.Now in second frame i detect all four points location, and i use B=XA equation to estimate the rotation and translation of the points.Here B array of the locations of corner points in new frame and A is the array of the locations of corner point in old frame.I use mrdivide inbuilt matlab function.
Here is my code
if i==1
arr=[c1(1) c1(2);c2(1) c2(2);c3(1) c3(2);c4(1) c4(2)];
k=25;
p1=[c1(1);c1(2);1]
p2=[c2(1);c2(2);1]
p3=[c3(1);c3(2);1]
p4=[c4(1);c4(2);1]
A=[p1 p2 p3 p4]
else
arr(:,:,i)=[c1(1) c1(2);c2(1) c2(2);c3(1) c3(2);c4(1) c4(2)];
p1_=[c1(1);c1(2);1]
p2_=[c2(1);c2(2);1]
p3_=[c3(1);c3(2);1]
p4_=[c4(1);c4(2);1]
B=[p1_ p2_ p3_ p4_]
end
Ans(:,:,i)=mrdivide(B,A)
As per my knowledge in 2*2 rotational matrix diagonal values same only sign differ, But i didn't get same diagonal values.
My output matrix is:
Ans(:,:,2) =
1.0070 -0.0099 2.0088
0.0225 0.9805 -7.3538
0.0000 0.0000 1.0000
plz plz help me. I m too confused. Thanks in advance.
0 Comments
Accepted Answer
Walter Roberson
on 17 Jan 2016
Motion of rotation is non-linear. You are inputting 4 coordinate pairs for nonlinear motion and asking for 3 outputs as if it is a linear system. If it were a linear system then the 4th coordinate pair would be linearly dependent on the other three and would add no new information (beyond a small amount of noise) and you would get proper information back. But because it is not a linear system, The mrdivide algorithm has to do a least squared fit to find the closest linear system to represent the non-linear data, and the least squared fit does not happen to have exact 1 on the diagonal.
Now if it happened that your system had no rotation between the two frames, only translation, then we would be more concerned.
0 Comments
More Answers (1)
Matt J
on 17 Jan 2016
Edited: Matt J
on 18 Jan 2016
If both the following were true,
(1) You detect the corner points locations with insignificant error,
(2) The roto-translation model is a perfectly exact model relating the two sets of points,
then I would expect mrdivide to give you a proper rotation matrix for R=Ans(1:2,1:2,i), within tolerances for floating point errors. However, I suspect that neither of these are true. I suspect you have noise in your corner location computations. Also, if your camera was not oriented with its imaging plane parallel to the plane of the points in A and B, then there will be projective distortion between the 2 frames and a pure rototranslation will not be an accurate model of the transformation between them.
Regardless, you can force R=Ans(1:2,1:2,i) to be a proper rotation matrix by including further constraining equations on R,
R*R.'= eye(2)
det(R)>0
As Walter mentions, however, these additional equations are nonlinear, so mrdivide isn't an adequate tool. Instead, you can use ABSOR ( Download ) to do an appropriately constrained estimate,
out = absor( A(1:2,:), B(1:2,:) );
Ans(:,:,i) = out.M;
0 Comments
See Also
Categories
Find more on Image Filtering and Enhancement in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!