[37] | 1 | % planarcams ... alignment under assumption of planar camera arrangements |
---|
| 2 | % |
---|
| 3 | % [align,cam] = planarmove(in,cam,config,idx) |
---|
| 4 | % in, cam, config ... see the main GOCAL script |
---|
| 5 | % idx ... indexes of cameras which are suppose to be in one plane |
---|
| 6 | % |
---|
| 7 | % align ... structures aligned wit the specified world frame |
---|
| 8 | % |
---|
| 9 | % $Id: planarcams.m,v 1.1 2003/07/03 15:36:55 svoboda Exp $ |
---|
| 10 | |
---|
| 11 | function [align,cam] = planarcams(in,cam,config,idx) |
---|
| 12 | |
---|
| 13 | % fit a plane to the reconstructed points and estimate normal |
---|
| 14 | |
---|
| 15 | plane.n = planefit(in.Ce(:,idx)'); |
---|
| 16 | |
---|
| 17 | new.n = [0,0,1]'; % align the xy plane horizontally |
---|
| 18 | |
---|
| 19 | rotaxis = cross(new.n,plane.n); |
---|
| 20 | rotangle = acos( (plane.n'*new.n)/norm(plane.n)*norm(new.n) ); |
---|
| 21 | |
---|
| 22 | R = nfi2r(rotaxis,rotangle); |
---|
| 23 | s = 3; |
---|
| 24 | t = [0,0,1]' - s*R*mean(in.Xe(1:3,:)')'; |
---|
| 25 | |
---|
| 26 | align.simT.s = s; |
---|
| 27 | align.simT.R = R; |
---|
| 28 | align.simT.t = t; |
---|
| 29 | |
---|
| 30 | [align.P, align.X] = align3d(in.Pe,in.Xe,align.simT); |
---|
| 31 | % save aligned data |
---|
| 32 | if 1 % SAVE_STEPHI | SAVE_PGUHA |
---|
| 33 | [align.Cst,align.Rot] = savecalpar(align.P,config); |
---|
| 34 | end |
---|
| 35 | drawscene(align.X,align.Cst',align.Rot,61,'cloud','Graphical Output Validation: Aligned data, TopView',config.cal.cams2use); |
---|
| 36 | |
---|
| 37 | set(gca,'CameraTarget',[0,0,0]); |
---|
| 38 | set(gca,'CameraPosition',[0,0,1]); |
---|
| 39 | |
---|
| 40 | figure(61), |
---|
| 41 | % print -depsc graphevalaligned.eps |
---|
| 42 | eval(['print -depsc ', config.paths.data, 'topview.eps']) |
---|
| 43 | |
---|
| 44 | drawscene(align.X,align.Cst',align.Rot,62,'cloud','Graphical Output Validation: Aligned data, SideView',config.cal.cams2use); |
---|
| 45 | |
---|
| 46 | set(gca,'CameraTarget',[0,0,0.9]); |
---|
| 47 | set(gca,'CameraPosition',[2,0,0.9]); |
---|
| 48 | |
---|
| 49 | figure(62), |
---|
| 50 | % print -depsc graphevalaligned.eps |
---|
| 51 | eval(['print -depsc ', config.paths.data, 'sideview.eps']) |
---|
| 52 | |
---|
| 53 | return |
---|
| 54 | |
---|
| 55 | |
---|