-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtry_Fast.m
65 lines (39 loc) · 1.32 KB
/
try_Fast.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
56
57
58
59
60
61
62
63
64
65
clear all
clc
addpath('ShanzhaiCV');
global matlab_or_octave
matlab_or_octave=1;
if (matlab_or_octave==0) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% octave
pkg load image
end
image_org=imread('./data/1403715550312143104.png');
[rows, cols] = size(image_org);
image=image_org(rows/2+1:rows,cols/2+1:cols,:);
%
% image_new=image(1:57,138:246,:);
%
% imwrite(image_new, 'image_new.png');
threshold=20;
nonmaxSuppression=1;
pts = cv_FAST(image, threshold, nonmaxSuppression);
%pts =[31,9,10];
% figure
% imshow(image); hold on;
% plot(corners(:, 1), corners(:, 2), 'r+');
win_size = [5, 5]; % 窗口大小
zero_zone = [-1, -1]; % 禁用区域
term_crit.type = "CV_TERMCRIT_ITER+EPS"; % 终止条件 [最大迭代次数, epsilon]
term_crit.epsilon=0.001;
term_crit.max_iter=20;
% cv::Size win_size = cv::Size(5, 5);
% cv::Size zero_zone = cv::Size(-1, -1);
% cv::TermCriteria term_crit = cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 20, 0.001);
%
pts_refined = cv_cornerSubPix(image, pts(:,1:2), win_size, zero_zone, term_crit);
%%
figure;
imshow(image); hold on;
plot(pts_refined(:,1), pts_refined(:,2), 'g.', 'MarkerSize', 7);
plot(pts(:,1), pts(:,2), 'r.', 'MarkerSize', 7);
%plot(29.57, 11.6, 'b.', 'MarkerSize', 5);
legend('Refined Corners','Initial Corners');