[37] | 1 | function drawscene(X,C,R,fig,ctypehint,scenetitle,camsId) |
---|
| 2 | |
---|
| 3 | % drawscene ... plots calibration points, cameras and their viewing axes |
---|
| 4 | % |
---|
| 5 | % drawscene(X,C,R,fig,ctypehint,scenetitle) |
---|
| 6 | % |
---|
| 7 | % X ............ 4xPOINTS matrix containg POINTS object points |
---|
| 8 | % C ............ 3xCAMS matrix containing the camera centers (in world coord.) |
---|
| 9 | % R ............ 3*CAMSx3 matrix containing camera rotation matrices |
---|
| 10 | % (needed for drawing the viewing axes) |
---|
| 11 | % fig .......... figure handle (defaults to 1) |
---|
| 12 | % ctypehint .... calibration object type of X (defaults to 'cloud') |
---|
| 13 | % scenetitle ... title of the plot (defaults to '') |
---|
| 14 | % camsIs ....... 1xCAMS vector with cameas Id (default is 1:CAMS |
---|
| 15 | |
---|
| 16 | % $Author: svoboda $ |
---|
| 17 | % $Revision: 2.0 $ |
---|
| 18 | % $Id: drawscene.m,v 2.0 2003/06/19 12:07:03 svoboda Exp $ |
---|
| 19 | % $State: Exp $ |
---|
| 20 | |
---|
| 21 | POINTS = size(X,2); |
---|
| 22 | CAMS = size(C,2); |
---|
| 23 | |
---|
| 24 | if nargin < 7 |
---|
| 25 | camsId = [1:CAMS]; |
---|
| 26 | end |
---|
| 27 | |
---|
| 28 | if (nargin < 3) |
---|
| 29 | error('not enough input arguments'); |
---|
| 30 | end |
---|
| 31 | if (nargin < 5) |
---|
| 32 | scenetitle = ''; |
---|
| 33 | end |
---|
| 34 | if (nargin < 4) |
---|
| 35 | ctypehint = 'cloud'; |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | figure(fig); clf |
---|
| 39 | title(scenetitle) |
---|
| 40 | grid on |
---|
| 41 | axis equal |
---|
| 42 | |
---|
| 43 | % plot camera positions (blue) |
---|
| 44 | drawcloud(C,fig,'b'); |
---|
| 45 | |
---|
| 46 | % plot calibration object (red) |
---|
| 47 | drawobject(X,ctypehint,fig,'r'); |
---|
| 48 | |
---|
| 49 | % Mean of all points |
---|
| 50 | centroid = mean(X(1:3,:)'); |
---|
| 51 | |
---|
| 52 | % plot viewing axes |
---|
| 53 | for i=1:CAMS |
---|
| 54 | axis_dir = -R(3*i,:); % 3rd row of i-th rotation matrix |
---|
| 55 | axis_len = 0.6*norm(C(1:3,i)-centroid'); |
---|
| 56 | endpoint = C(1:3,i)+axis_len*axis_dir'; |
---|
| 57 | line([C(1,i),endpoint(1)],[C(2,i),endpoint(2)],[C(3,i),endpoint(3)]); |
---|
| 58 | text(C(1,i),C(2,i),C(3,i),sprintf('%4d',camsId(i)),'Color','k'); |
---|
| 59 | end |
---|
| 60 | |
---|
| 61 | |
---|