forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensor.m
78 lines (75 loc) · 3.61 KB
/
sensor.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
% Wraps librealsense2 sensor class
classdef sensor < realsense.options
methods
% Constructor
function this = sensor(handle)
this = this@realsense.options(handle);
end
% Destructor (uses base class destructor)
% Functions
function open(this, profiles)
narginchk(2, 2)
validateattributes(profiles, {'realsense.stream_profile'}, {'nonempty', 'vector'}, '', 'profiles', 2);
if isscalar(profiles)
realsense.librealsense_mex('rs2::sensor', 'open#stream_profile', this.objectHandle, profiles.objectHandle);
else
realsense.librealsense_mex('rs2::sensor', 'open#vec_stream_profile', this.objectHandle, profiles);
end
end
function value = supports_camera_info(this, info)
narginchk(2, 2)
validateattributes(info, {'realsense.camera_info', 'numeric'},{'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.camera_info.count)}, '', 'info', 2);
value = realsense.librealsense_mex('rs2::sensor', 'supports#rs2_camera_info', this.objectHandle, int64(info));
end
function value = get_info(this, info)
narginchk(2, 2)
validateattributes(info, {'realsense.camera_info', 'numeric'},{'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.camera_info.count)}, '', 'info', 2);
value = realsense.librealsense_mex('rs2::sensor', 'get_info', this.objectHandle, int64(info));
end
function close(this)
realsense.librealsense_mex('rs2::sensor', 'close', this.objectHandle);
end
% TODO: start [etc?]
function start(this, queue)
narginchk(2, 2);
validateattributes(queue, {'realsense.frame_queue'}, {'scalar'}, '', 'queue', 2);
realsense.librealsense_mex('rs2::sensor', 'start', this.objectHandle, queue.objectHandle);
end
function stop(this)
realsense.librealsense_mex('rs2::sensor', 'stop', this.objectHandle);
end
function profiles = get_stream_profiles(this)
arr = realsense.librealsense_mex('rs2::sensor', 'get_stream_profiles', this.objectHandle);
% TODO: Might be cell array
profiles = arrayfun(@(x) realsense.stream_profile(x{:}{:}), arr, 'UniformOutput', false);
end
function l = logical(this)
l = realsense.librealsense_mex('rs2::sensor', 'operator bool', this.objectHandle);
end
function value = is(this, type)
narginchk(2, 2);
% C++ function validates contents of type
validateattributes(type, {'char', 'string'}, {'scalartext'}, '', 'type', 2);
out = realsense.librealsense_mex('rs2::sensor', 'is', this.objectHandle, type);
value = logical(out);
end
function sensor = as(this, type)
narginchk(2, 2);
% C++ function validates contents of type
validateattributes(type, {'char', 'string'}, {'scalartext'}, '', 'type', 2);
out = realsense.librealsense_mex('rs2::sensor', 'as', this.objectHandle, type);
switch type
case 'sensor'
sensor = realsense.sensor(out);
case 'roi_sensor'
sensor = realsense.roi_sensor(out);
case 'depth_sensor'
sensor = realsense.depth_sensor(out);
case 'depth_stereo_sensor'
sensor = realsense.depth_stereo_sensor(out);;
end
end
% Operators
% TODO: operator==
end
end