forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pipeline.m
67 lines (66 loc) · 3.18 KB
/
pipeline.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
% Wraps librealsense2 pipeline class
classdef pipeline < handle
properties (SetAccess = protected, Hidden = true)
objectHandle;
end
methods
% Constructor
function this = pipeline(ctx)
if nargin == 0
this.objectHandle = realsense.librealsense_mex('rs2::pipeline', 'new');
else
validateattributes(ctx, {'realsense.context'}, {'scalar'});
this.objectHandle = realsense.librealsense_mex('rs2::pipeline', 'new', ctx.objectHandle);
end
end
% Destructor
function delete(this)
if (this.objectHandle ~= 0)
realsense.librealsense_mex('rs2::pipeline', 'delete', this.objectHandle);
end
end
% Functions
function pipeline_profile = start(this, varargin)
narginchk(1, 3);
if nargin == 1
out = realsense.librealsense_mex('rs2::pipeline', 'start', this.objectHandle);
elseif nargin == 2
validateattributes(varargin{1}, {'realsense.config', 'realsense.frame_queue'}, {'scalar'}, '', 'config_or_framequeue', 2);
if isa(varargin{1}, 'realsense.config')
out = realsense.librealsense_mex('rs2::pipeline', 'start', this.objectHandle, varargin{1}.objectHandle);
else
out = realsense.librealsense_mex('rs2::pipeline', 'start#fq', this.objectHandle, varargin{1}.objectHandle);
end
else
validateattributes(varargin{1}, {'realsense.config'}, {'scalar'}, '', 'config', 2);
validateattributes(varargin{2}, {'realsense.frame_queue'}, {'scalar'}, '', 'frame_queue', 2);
out = realsense.librealsense_mex('rs2::pipeline', 'start#fq', this.objectHandle, varargin{1}.objectHandle, varargin{2}.objectHandle);
end
pipeline_profile = realsense.pipeline_profile(out);
end
function stop(this)
realsense.librealsense_mex('rs2::pipeline', 'stop', this.objectHandle);
end
function frames = wait_for_frames(this, timeout_ms)
narginchk(1, 2);
if nargin == 1
out = realsense.librealsense_mex('rs2::pipeline', 'wait_for_frames', this.objectHandle);
else
if isduration(timeout_ms)
timeout_ms = milliseconds(timeout_ms);
end
validateattributes(timeout_ms, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'timeout_ms', 2);
out = realsense.librealsense_mex('rs2::pipeline', 'wait_for_frames', this.objectHandle, double(timeout_ms));
end
frames = realsense.frameset(out);
end
function [res, frames] = poll_for_frames(this)
[res, out] = realsense.librealsense_mex('rs2::pipeline', 'poll_for_frames', this.objectHandle);
frames = realsense.frameset(out);
end
function profile = get_active_profile(this)
out = realsense.librealsense_mex('rs2::pipeline', 'get_active_profile', this.objectHandle);
profile = realsense.pipeline_profile(out);
end
end
end