forked from YJCITA/radar_camera_fusion_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelperUIConnector.m
104 lines (94 loc) · 4.3 KB
/
helperUIConnector.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
classdef helperUIConnector < driving.connector.Connector
%---------------------------------------------------------
% Properties to store internal state of the external tool
%---------------------------------------------------------
properties (Access = private)
customUI % holds Custom UI.
updateGTLDisplay = true; % Flag to distinguish the caller of
% slider value change event. The callers are:
% (1) frameChangeListener called by
% groundTruthLabeler.
% (2) mouse movement of slider.
end
methods
%------------------------------------------------------------------
% Constructor:
% A Constructor with no input argument must be defined. This
% constructor is expected to create an external tool. The external
% tool can be a custom display or a visualization tool.
%
% The Constructor is called by the Ground Truth Labeler app to
% instantiate the external tool.
%------------------------------------------------------------------
function this = helperUIConnector()
% Load custom data here in the constructor:
this.customUI = helperCustomUI('distanceData.mat');
end
end
methods
%------------------------------------------------------------------
%frameChangeListener Update external tool when a frame changes in the app.
% frameChangeListener(connObj) provides an option to
% synchronize the external tool with frame changes in the Ground
% Truth Labeler app. The app calls this method whenever a new
% frame is displayed in the app. This method must be implemented
% by the client class.
%
% Input:
% ------
% connObj - Connector object.
%
% See also driving.connector.Connector.dataSourceChangeListener
%------------------------------------------------------------------
function frameChangeListener(this)
% Move custom slider programmatically
this.updateGTLDisplay = false;
if ~endReached(this)
% Convert 'time' to index in the data to be plotted. ceil
% it to ensure that it is integral, as it is used to index
% into the data array.
index = ceil(this.CurrentTime*this.customUI.lengthOfData()/this.TimeVector(end));
this.customUI.updateUI(index);
end
this.updateGTLDisplay = true;
end
%------------------------------------------------------------------
%dataSourceChangeListener Update external tool when a new data
% source is loaded in the app.
% dataSourceChangeListener(connObj) provides an option to
% update the external tool when a new data source is loaded into
% the Ground Truth Labeler app. The app calls this method using
% the connObj object. You can optionally use this method to
% react to a new data source being connected to the app.
%
% A new data source can be a video, image sequence, or custom
% reader. A new data source can be loaded when loading a new
% session.
%
% Inputs:
% -------
% connObj - Connector object.
%
% See also driving.connector.Connector.frameChangeListener.
%------------------------------------------------------------------
function dataSourceChangeListener(this)
% Update states of the custom display
this.customUI.updateUI(1);
end
%------------------------------------------------------------------
% closeFig
% Callback internal to the custom display
%------------------------------------------------------------------
function closeFig(this, ~, ~)
% This display is closed by user; so set flag for GTL
disconnect(this);
closereq();
end
end
methods (Access = private)
%------------------------------------------------------------------
function flag = endReached(this)
flag = (this.CurrentTime >= this.TimeVector(end));
end
end
end