mexopencv-利用orb feature detector 提取和匹配特征

1.安装配置好环境后,由于时间急需,第一次利用mexopecv进行测试,提取图片的ORB特征点,并进行匹配试验。



2.匹配的程序编写调式过程中,有几个问题:

   参数的理解,各个函数模块的组合(参考opencv 的实现例子)

3.代码

%orb feature detector test
%vl_sift matlab 自我测试数据对比
function ouput = test_orb(flag)
addpath('D:\\work\\SLAM\\MonoSLAMMatlab\\tools\\mexopencv\\');
% import cv.*;
imageFile1 = '1.pgm';
imageFile2 = '2.pgm';
% Load image
image1 = imread(imageFile1);
image2 = imread(imageFile2);
if ndims(image1) == 3 
    image1 = rgb2gray(image1);
end
if ndims(image2) == 3
    image2 = rgb2gray(image2);
end

% I = rgb2gray(image1); % Conversion to single is recommended
% J = rgb2gray(image2); % in the documentation

rand('state',0);
% uv=rand(2,1);
if flag ~= 1 
A = image1(20:200,20:200);
B = image2(20:200,20:200);
else
 A = image1;
 B = image2;   
end

    [K1 D1] = cv.ORB(A,'NFeatures',500);
    [K2 D2] = cv.ORB(B,'NFeatures',500);

    % Where 1.5 = ratio between euclidean distance of NN2/NN1
    im1 = cv.drawKeypoints(A,K1);
    subplot(2,1,1);
    hold on;
    imshow(im1);
    
    im2 = cv.drawKeypoints(B,K2);
    subplot(2,1,2);
    imshow(im2);
    hold off;
    %定义匹配的类对象
    matcher = cv.DescriptorMatcher('BruteForce-Hamming');
    matcher.add(D1);
    matcher.train();
    matcher_img = matcher.match(D2);     
    im3 = cv.drawMatches(A,K1,B,K2,matcher_img);
    figure;
    imshow(im3);
%     [matches score] = vl_ubcmatch(D1,D2,1.5); 
%    figure01=figure;
%     h1=subplot(1,2,1);
%     imshow(uint8(A));
%     hold on;
    %展示匹配点
    
%     plot(F1(1,matches(1,:)),F1(2,matches(1,:)),'b*');
% 
%     h2=subplot(1,2,2);
%     imshow(uint8(B));
%     hold on;
%     
%     plot(F2(1,matches(2,:)),F2(2,matches(2,:)),'r*');
%     


end


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值