-
Notifications
You must be signed in to change notification settings - Fork 6
/
EstimateFeaturePoints.m
56 lines (53 loc) · 1.91 KB
/
EstimateFeaturePoints.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function [fPts] = EstimateFeaturePoints(im,method)
%ESTIMATEFEATUREPOINTS Summary of this function goes here
% Detailed explanation goes here
if ~exist('method','var')
method = 'SURF';
end
ROI = [10 10 size(im,2)-20 size(im,1)-20];
if strcmp(method,'SURF')
kPts = detectSURFFeatures(rgb2gray(im), 'MetricThreshold', 100, 'ROI', ROI);
[desc,kPts] = extractFeatures(rgb2gray(im), kPts, 'Method', 'Auto',...
'Upright', false);
loc = kPts.Location';
fPts = {loc,desc};
elseif strcmp(method,'KAZE')
kPts = detectKAZEFeatures(rgb2gray(im), 'Threshold', 2e-4, 'ROI', ROI);
[desc,kPts] = extractFeatures(rgb2gray(im), kPts, 'Method', 'Auto',...
'Upright', false);
loc = kPts.Location';
fPts = {loc,desc};
elseif strcmp(method,'FAST')
kPts = detectFASTFeatures(rgb2gray(im), 'MinQuality', 3e-2,...
'MinContrast', 3e-2, 'ROI', ROI);
[desc,kPts] = extractFeatures(rgb2gray(im), kPts, 'Method', 'Auto',...
'Upright', false);
loc = kPts.Location';
fPts = {loc,desc};
elseif strcmp(method,'BRISK')
kPts = detectBRISKFeatures(rgb2gray(im), 'MinQuality', 6e-2, 'MinContrast',...
6e-2, 'ROI', ROI);
[desc,kPts] = extractFeatures(rgb2gray(im), kPts, 'Method', 'Auto',...
'Upright', false);
loc = kPts.Location';
fPts = {loc,desc};
% Non-native:
elseif strcmp(method,'SIFT')
im = vl_imdown(single(rgb2gray(im)));
[kPts,desc] = vl_sift(im,'Levels',12,'EdgeThresh',100,'Magnif',2);
loc = 2*kPts(1:2,:);
fPts = {loc,desc'};
elseif strcmp(method,'AKAZE')
d = cv.AKAZE('Threshold',2e-4);
[kPts,desc] = d.detectAndCompute(im);
loc = vertcat(kPts.pt)';
fPts = {loc,binaryFeatures(desc)};
elseif strcmp(method,'ORB')
d = cv.ORB('MaxFeatures',1e5,'FastThreshold',16);
[kPts,desc] = d.detectAndCompute(im);
loc = vertcat(kPts.pt)';
fPts = {loc,binaryFeatures(desc)};
else
error('Unknown method')
end
end