• 大小: 14.61MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-21
  • 语言: Matlab
  • 标签: 三维重建  matlab  

资源简介

三维重建 的matlab 代码 可以入门使用,希望对你有帮助

资源截图

代码片段和文件信息

function graph = bundleAdjustment(graph adjustFocalLength)

% convert from Rt matrix to AngleAxis
nCam=length(graph.frames);
Mot = zeros(32nCam);
for camera=1:nCam
    Mot(:1camera) = RotationMatrix2AngleAxis(graph.Mot(:1:3camera));
    Mot(:2camera) = graph.Mot(:4camera);
end



Str = graph.Str;
f  = graph.f;


% assume px py=0
px = 0;
py = 0;



residuals = reprojectionResidual(graph.ObsIdxgraph.ObsValpxpyfMotStr);
fprintf(‘initial error = %f\n‘ 2*sqrt(sum(residuals.^2)/length(residuals)));

% bundle adjustment using lsqnonlin in Matlab (Levenberg-Marquardt)
options = optimoptions(@lsqnonlin‘Algorithm‘‘levenberg-marquardt‘‘Display‘‘off‘);

% adjust structure [for homework]
% !!! fill in your code here
%fprintf(‘error = %f\n‘ 2*sqrt(resnorm/length(residuals)));

% adjust motion [for homework]
% !!! fill in your code here
%fprintf(‘error = %f\n‘ 2*sqrt(resnorm/length(residuals)));

% adjust motion and structure
[vecresnormresidualsexitflag] = lsqnonlin(@(x) reprojectionResidual(graph.ObsIdxgraph.ObsValpxpyfx) [Mot(:); Str(:)][][]options);
[MotStr] = unpackMotStrf(nCamvec);
fprintf(‘error = %f\n‘ 2*sqrt(resnorm/length(residuals)));


if exist(‘adjustFocalLength‘‘var‘) && adjustFocalLength
    % adjust focal length motion and structure
    [vecresnormresidualsexitflag] = lsqnonlin(@(x) reprojectionResidual(graph.ObsIdxgraph.ObsValpxpyx) [f; Mot(:); Str(:)][][]options);
    [MotStrf] = unpackMotStrf(nCamvec);
    fprintf(‘error = %f\n‘ resnorm/length(residuals));
    graph.f = f;
end


%residuals = reprojectionResidual(graph.ObsIdxgraph.ObsValpxpyfMotStr);
%fprintf(‘final error = %f\n‘ 2*sqrt(sum(residuals.^2)/length(residuals)));


for camera=1:nCam
    graph.Mot(::camera) = [AngleAxis2RotationMatrix(Mot(:1camera))  Mot(:2camera)];    
end
graph.Str = Str;


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-16 10:48  三维重建  matlab\
     文件         222  2014-11-15 15:22  三维重建  matlab\._SFMedu2
     文件       24580  2014-11-15 15:22  三维重建  matlab\.DS_Store
     文件        1856  2014-09-03 18:08  三维重建  matlab\bundleAdjustment.m
     目录           0  2018-03-16 10:48  三维重建  matlab\denseMatch\
     文件       15364  2014-11-15 15:23  三维重建  matlab\denseMatch\.DS_Store
     文件        1899  2014-09-02 22:42  三维重建  matlab\denseMatch\denseMatch.m
     目录           0  2018-03-16 10:48  三维重建  matlab\denseMatch\priority_queue_1.0\
     文件       15364  2014-11-15 15:22  三维重建  matlab\denseMatch\priority_queue_1.0\.DS_Store
     文件         104  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\CHANGES
     文件        1340  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\license.txt
     文件       13658  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\MyHeap.h
     文件       13341  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\MyHeap_old.h
     文件        1760  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_create.cpp
     文件        1270  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_create.m
     文件       10444  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_create.mexa64
     文件       14896  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_create.mexmaci
     文件       14736  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_create.mexmaci64
     文件       10752  2014-11-12 23:29  三维重建  matlab\denseMatch\priority_queue_1.0\pq_create.mexw64
     文件        1795  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_delete.cpp
     文件         570  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_delete.m
     文件        8359  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_delete.mexa64
     文件        9520  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_delete.mexmaci
     文件        9408  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_delete.mexmaci64
     文件        7680  2014-11-12 23:30  三维重建  matlab\denseMatch\priority_queue_1.0\pq_delete.mexw64
     文件        7872  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_demo.cpp
     文件        1014  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_demo.m
     文件       39971  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_demo.mexa64
     文件        2033  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_pop.cpp
     文件         725  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_pop.m
     文件       15872  2012-08-25 15:06  三维重建  matlab\denseMatch\priority_queue_1.0\pq_pop.mexa64
............此处省略3931个文件信息

评论

共有 条评论