extcal.m
上传用户:kellyonhid
上传日期:2013-10-12
资源大小:932k
文件大小:2k
源码类别:

3D图形编程

开发平台:

Visual C++

  1. function [pos,iter,res,er,C]=extcal(name,data,cpar)
  2. %EXTCAL Calculates the extrinsic camera parameters for a single image 
  3. %from 3D - 2D correspondences.
  4. %
  5. %Usage:
  6. %   [pos,iter,res,er,C]=extcal(name,data,cpar)         
  7. %
  8. %where
  9. %   name = string that is specific to the camera and the framegrabber.
  10. %          This string must be defined in configc.m
  11. %   data = matrix that contains the 3-D coordinates of the
  12. %          control points (in fixed right-handed frame) and corresponding
  13. %          image observations (in image frame, origin in the upper left
  14. %          corner and the y-axis downwards) 
  15. %          Dimensions: (n x 5) matrix, format: [wx wy wz ix iy]
  16. %   cpar = intrinsic parameters of the camera (from calibration)
  17. %   pos  = camera position and orientation
  18. %   iter = number of iterations used
  19. %   res  = residual (sum of squared errors)
  20. %   er   = remaining error for each point
  21. %   C    = error covariance matrix of the estimated parameters
  22. %   Version 2.1b  25.08.1998
  23. %   Janne Heikkila, University of Oulu, Finland
  24. if ~isstr(name)
  25.   error('The first argument should be the camera type');
  26. end
  27. sys=configc(name);
  28. n=length(data);
  29. if norm(data(:,3))
  30.   [ipos,foc,u0,v0,b1,b2]=dlt(sys,data);
  31. else
  32.   [ipos,foc,u0,v0,b1,b2]=dlt2d(sys,data);
  33. end
  34. [pos,iter,res,er,J,succ]=lmoptc(sys,data,n,ipos(:),0,cpar);
  35. q=ones(n,1)*std(reshape(er,n,2));
  36. Q=spdiags(q(:).^2,1,2*n,2*n);
  37. X=inv(J'*J)*J';
  38. C=full(X*Q*X');
  39. disp(sprintf('Standard error in pixels: %f',std(er(:))));
  40. disp(sprintf('Standard deviation of the estimated extrinsic parameters:'));
  41. disp(sprintf('%.5f ',sqrt(diag(C)')));