解析MATLAB中的SFM

该博客详细介绍了在MATLAB中进行结构从运动(SFM)的步骤,包括预处理图像、相机参数设定、特征匹配、相对姿态估计、全局三维重建及点云显示等关键过程,展示了MATLAB在计算机视觉领域的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

close all;
clear all;

%% 预处理
% 导入数据
imageDir = 'C:\Users\lenovo\Desktop\卫星测试';
imds = imageDatastore(imageDir);


% 灰度图转化
images = cell(1, numel(imds.Files));
for i = 1:numel(imds.Files)
    I = readimage(imds, i);
    if ndims(I)==3
        images{i} = rgb2gray(I);
    else
        images{i} = I;
    end
end

% 导入相机参数,相机定标 
[iR, iC] = size(images{i});
IntrinsicMatrix = [(iR+iC)/2   0       0;
                      0     (iR+iC)/2  0;
                  iR/2  iC/2  1];
cameraParams = cameraParameters('IntrinsicMatrix',IntrinsicMatrix);

%% 参考帧(第一帧)提取参考稀疏点,主要用来估计相机外参
% 1、镜面扭曲还原
I = undistortImage(images{1}, cameraParams);

% 2、提取特征
border = 5;
roi = [border, border, size(I, 2)- 2*border, size(I, 1)- 2*border];
prevPoints   = detectSURFFeatures(I); %, 'NumOctaves', 8, 'ROI', roi);
prevFeatures = extractFeatures(I, prevPoints, 'Upright', true);

% 3、构造测量集
vSet = viewSet;
viewId = 1;
vSet = addView(vSet, viewId, 'Points', prevPoints, 'Orientation', ...
    eye(3, 'like', prevPoints.Location), 'Location', ...
    zeros(1, 3, 'like', prevPoints.Location));

%% 后继帧操作
for i = 2:numel(images)
    % Undistort the current image.
    I = undistortImage(images{i}, cameraParams);

    % Detect, extract and match features.
    currPoints   = detectSURFFea

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值