-
Notifications
You must be signed in to change notification settings - Fork 0
/
helperVisualizeMatchedFeaturesStereo.m
63 lines (45 loc) · 2.03 KB
/
helperVisualizeMatchedFeaturesStereo.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
classdef helperVisualizeMatchedFeaturesStereo < handle
%helperVisualizeMatchedFeaturesStereo show the matched features in a frame
%
% This is an example helper class that is subject to change or removal
% in future releases.
% Copyright 2019-2020 The MathWorks, Inc.
properties (Access = private)
Image
Feature
end
methods (Access = public)
function obj = helperVisualizeMatchedFeaturesStereo(I1, I2, points1, points2, matchedPairs)
% Plot image
hFig = figure;
hAxes = newplot(hFig);
% Set figure visibility and position
hFig.Visible = 'on';
movegui(hFig, [200 200]);
% Show the image and features
obj.Image = showMatchedFeatures(I1, I2, points1(matchedPairs(:, 1)), ...
points2(matchedPairs(:, 2)), 'montage', 'Parent', hAxes, ...
'PlotOptions', {'ro','g+',''});
title(hAxes, 'Matched Features in Current Frame');
hold(hAxes, 'on');
obj.Feature = findobj(hAxes.Parent,'Type','Line');
end
function updatePlot(obj, I1, I2, points1, points2, trackedFeatureIdx, matchedPairs)
[~, ia, ib] = intersect(trackedFeatureIdx, matchedPairs(:, 1), 'stable');
points1 = points1(trackedFeatureIdx(ia));
points2 = points2(matchedPairs(ib, 2));
% Stereo image
obj.Image.CData = [I1, I2];
% Connecting lines
obj.Feature(1).XData = NaN;
obj.Feature(1).YData = NaN;
% Right image
obj.Feature(2).XData = points2.Location(:,1) + size(I1, 2);
obj.Feature(2).YData = points2.Location(:,2);
% Left image
obj.Feature(3).XData = points1.Location(:,1);
obj.Feature(3).YData = points1.Location(:,2);
drawnow limitrate
end
end
end