Code covered by the BSD License  

Highlights from
Absolute Orientation

5.0

5.0 | 8 ratings Rate this file 37 Downloads (last 30 days) File Size: 2.38 KB File ID: #22422

Absolute Orientation

by

 

12 Dec 2008 (Updated )

Computes the transformation to register two corresponding 3D point sets.

| Watch this File

File Information
Description

[s R T error] = absoluteOrientationQuaternion( A, B, doScale)

Computes the orientation and position (and optionally the uniform scale factor) for the transformation between two corresponding 3D point sets Ai and Bi such as they are related by:

    Bi = sR*Ai+T

Implementation is based on the paper by Berthold K.P. Horn:
"Closed-from solution of absolute orientation using unit quaternions"
The paper can be downloaded here:
http://people.csail.mit.edu/bkph/papers/Absolute_Orientation.pdf

Authors:
Dr. Christian Wengert, Dr. Gerald Bianchi

Copyright:
ETH Zurich, Computer Vision Laboratory, Switzerland

Parameters:
A 3xN matrix representing the N 3D points
B 3xN matrix representing the N 3D points
doScale Flag indicating whether to estimate the uniform scale factor as well [default=0]

Return:
s The scale factor
R The 3x3 rotation matrix
T The 3x1 translation vector
err Residual error (optional)

Notes: Minimum 3D point number is N > 4

The residual error is being computed as the sum of the residuals:

for i=1:Npts
   d = (B(:,i) - (s*R*A(:,i) + T));
   err = err + norm(d);
 end

Example:

s=0.7;
R = [0.36 0.48 -0.8 ; -0.8 0.6 0 ; 0.48 0.64 0.6];
T= [45 -78 98]';
X = [ 0.272132 0.538001 0.755920 0.582317;
        0.728957 0.089360 0.507490 0.100513;
        0.578818 0.779569 0.136677 0.785203];
Y = s*R*X+repmat(T,1,4);

%Compute
[s2 R2 T2 error] = absoluteOrientationQuaternion( X, Y, 1);

error = 0;

%Add noise
Noise = [
-0.23 -0.01 0.03 -0.06;
0.07 -0.09 -0.037 -0.08;
0.009 0.09 -0.056 0.012];

Y = Y+Noise;
%Compute
[s2 R2 T2 error] = absoluteOrientationQuaternion( X, Y, 1);

error = 0.33

Acknowledgements

This file inspired Absolute Orientation Horn's Method.

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
22 Jul 2013 Saber

Great work.

06 Mar 2013 Daniell Algar

An extremely useful tool that works great in my current application!

Big thanks to the author

21 Feb 2013 Sina Abolhoseini

thank you man ... it was so helpful!

13 Dec 2011 Georg Stillfried

Just what I was looking for

03 Nov 2011 Peter

In your result, you compute the residual error as:
err =0;
for i=1:Na
d = (B(:,i) - (s*R*A(:,i) + T));
err = err + norm(d);
end

Wouldn't it be more appropriate to compute the sum of squared errors, because this is what you actually minimize? (so just use norm(d).^2 instead)

A nice addition would be to add the symmetric scale computation as mentioned later in the paper as a third option.

05 Feb 2011 Matt J

@Dirk-Jan, the method that you've shown is not a constrained least squares estimation. The transformation matrix that it produces is therefore not gauranteed to be of the form
[sR,T;zeros(1,3), 1].

If you add noise to X and Y, you will see that your method does not produce the same results as the absolute orientation solver, nor will it be in the desired family of transformations.

23 Jun 2010 Christian Wengert

Here is an interesting paper to the topic:

A Comparison of Four Algorithm s for Estimating tD Rigid Transformations

http://www.homepages.inf.ed.ac.uk/rbf/MY_DAI_OLD_FTP/rp765.pdf

Actually the Horn approach (unit quaternions) and the above mentioned (SVD?) are pretty much equivalent

19 Jun 2010 Dirk-Jan Kroon

What is the advantage of this absolute orientation method?

If I want the least-squares transformation matrix, with your coordinates it is simple :
s=0.7;
R = [0.36 0.48 -0.8 ; -0.8 0.6 0 ; 0.48 0.64 0.6];
T= [45 -78 98]';
X = [ 0.272132 0.538001 0.755920 0.582317;
0.728957 0.089360 0.507490 0.100513;
0.578818 0.779569 0.136677 0.785203];
Y = s*R*X+repmat(T,1,4);

>> X(4,:)=1; Y(4,:)=1;
>> Y/X

ans =

0.2520 0.3360 -0.5600 45.0000
-0.5600 0.4200 0.0000 -78.0000
0.3360 0.4480 0.4200 98.0000
0 0 0 1.0000

29 May 2010 Bryan Murawski

Great work, but I believe that there is a mistake in your error metric computation. If you want to compute the sum of the squared error like you're doing (I assume for performance reasons) you should divide by Na to compute the average squared error and then sqrt that quantity (ie. sqrt(err/Na)).

06 Mar 2009 Dave Ligthart

Great implementation!

15 Dec 2008 Christian Wengert

I am sorry for the inconvenience caused by the missing crossprod function files. I uploaded the new version and it should be online soon.
Cheers

15 Dec 2008 Thomas Pieper

Very good implementation of Horn's paper, but the functions crossprodquaternion and crossprodquaternion2 are still missing.

Updates
15 Dec 2008

Update, included the missing function crossprodQuaternion.
Sorry for that

15 Dec 2008

Missing functions added

09 Jun 2010

Based on Bryan Murawski's comments, I reviewed the computation of the residual error. Indeed, it seemed a bit strange, I thus changed the computation a bit so that it reflects the overall error of the transformation.

Contact us