forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame_queue.m
69 lines (67 loc) · 2.82 KB
/
frame_queue.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
% Wraps librealsense2 frame_queue class
classdef frame_queue < handle
properties (SetAccess = private, Hidden = true)
objectHandle;
end
methods
% Constructor
function this = frame_queue(capacity)
if nargin == 0
this.objectHandle = realsense.librealsense_mex('rs2::frame_queue', 'new');
else
validateattributes(capacity, {'numeric'}, {'scalar', 'positive', 'real', 'integer'});
this.objectHandle = realsense.librealsense_mex('rs2::frame_queue', 'new', uint64(capacity));
end
end
% Destructor
function delete(this)
if (this.objectHandle ~= 0)
realsense.librealsense_mex('rs2::frame_queue', 'delete', this.objectHandle);
end
end
% Functions
function frame = wait_for_frame(this, timeout_ms)
narginchk(1, 2);
if nargin == 1
out = realsense.librealsense_mex('rs2::frame_queue', 'wait_for_frame', 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::frame_queue', 'wait_for_frame', this.objectHandle, double(timeout_ms));
end
frame = realsense.frame(out);
end
function [res, frame] = poll_for_frame(this, type)
narginchk(2, 2);
% C++ function validates contents of type
validateattributes(type, {'char', 'string'}, {'scalartext'}, '', 'type', 2);
[res, out] = realsense.librealsense_mex('rs2::frame_queue', 'poll_for_frame', this.objectHandle, type)
switch type
case 'frame'
frame = realsense.frame(out);
case 'video_frame'
frame = realsense.video_frame(out);
case 'points'
frame = realsense.points(out);
case 'depth_frame'
frame = realsense.depth_frame(out);
case 'disparity_frame'
frame = realsense.disparity_frame(out);
case 'motion_frame'
frame = realsense.motion_frame(out);
case 'pose_frame'
frame = realsense.pose_frame(out);
case 'frameset'
frame = realsense.frameset(out);
end
end
function cap = capacity(this)
cap = realsense.librealsense_mex('rs2::frame_queue', 'capacity', this.objectHandle);
end
function keep = keep_frames(this)
cap = realsense.librealsense_mex('rs2::frame_queue', 'keep_frames', this.objectHandle);
end
end
end