基于SURF特征的目标检测

本文介绍如何使用Matlab进行SURF特征点检测与匹配,并实现目标图像在场景图像中的定位。步骤包括:读取图像、检测SURF特征点、提取特征描述子、匹配特征点、计算几何变换并定位目标。

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

转战matlab了。步骤说一下:
目标图obj 含目标的场景图scene

  1. 载入图像
  2. 分别检测SURF特征点
  3. 分别提取SURF描述子,即特征向量
  4. 用两个特征相互匹配
  5. 利用匹配结果计算两者之间的transform关系tform
  6. 根据obj位置与变换关系tform,在scene图上框出obj

代码,来自matlab,http://localhost:9090/vision/gs/object-detection-and-tracking.html#btt5qyu

%step1:读取图片
%读取object图片
boxImage = imread('stapleRemover.jpg');
%读取场景图片
sceneImage = imread('clutteredDesk.jpg');

%step2:检测特征点
boxPoints = detectSURFFeatures(boxImage);
scenePoints = detectSURFFeatures(sceneImage);

% figure; imshow(boxImage);
% title('Box Image中最强的100个feature points');
% hold on;
% plot(boxPoints.selectStrongest(100));

%step3 extract feature descriptors  提取出特征的描述子
%使用extractFeatures(),具体的feature类型是通过boxPoints位置的参数指定的,这里是SURF
%烂设计,为什么extractFeatures输入了boxPoints后,还要返回boxPoints?
[boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints);
[sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints);

%step4 find putative point matches
%Match the features using their descriptors.
boxPairs = matchFeatures(boxFeatures, sceneFeatures);
%Display putatively matched features.
matchedBoxPoints = boxPoints(boxPairs(:,1), :);
matchedScenePoints = scenePoints(boxPairs(:,2),:);
figure;
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints, matchedScenePoints, 'montage');
title('Putatively Matched Points (Including Outliers)');

%step5 locate the Object in the Scene Using Putative Matches
[tform, inlierBoxPoints, inlierScenePoints] = ...
    estimateGeometricTransform(matchedBoxPoints, matchedScenePoints, 'affine');
figure;
showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints, ...
    inlierScenePoints, 'montage');
title('Matched Points (Inliers Only)');

%Get the bounding polygon of the reference image.
boxPolygon = [1, 1;... % top-left
    size(boxImage,2), 1; ... % top-right
    size(boxImage, 2), size(boxImage, 1); ... % bottom-right
    1, size(boxImage, 1); ... % bottom-left
    1, 1]; % top-left again to close the polygon

% transform the polygon into the coordinate system of the target image
%将多边形变换到目标图片上,变换的结果表示了物体的位置
newBoxPolygon = transformPointsForward(tform, boxPolygon);

%display the detected object 显示被检测到的物体
figure; imshow(sceneImage);
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值