From 7ecf0a5000b71f54e7db2816aeca5b9881368ba5 Mon Sep 17 00:00:00 2001 From: Lior Ramati Date: Tue, 7 Aug 2018 18:54:02 +0300 Subject: [PATCH] lots of work on matlab half of the wrapper --- wrappers/matlab/camera_info.m | 15 +++++ wrappers/matlab/depth_frame.m | 7 ++- wrappers/matlab/depth_sensor.m | 16 +++++ wrappers/matlab/depth_stereo_sensor.m | 16 +++++ wrappers/matlab/device.m | 56 +++++++++++------- wrappers/matlab/disparity_frame.m | 16 +++++ wrappers/matlab/format.m | 25 ++++++++ wrappers/matlab/frame.m | 30 +++++----- wrappers/matlab/frame_metadata_value.m | 41 +++++++++---- wrappers/matlab/frameset.m | 31 ++++++---- wrappers/matlab/librealsense_mex.vcxproj | 12 ++++ .../matlab/librealsense_mex.vcxproj.filters | 36 ++++++++++++ wrappers/matlab/motion_frame.m | 16 +++++ wrappers/matlab/motion_stream_profile.m | 16 +++++ wrappers/matlab/option.m | 48 +++++++++++++++ wrappers/matlab/options.m | 58 +++++++++++++++++++ wrappers/matlab/points.m | 31 ++++++++++ wrappers/matlab/pose_frame.m | 16 +++++ wrappers/matlab/roi_sensor.m | 36 ++++++++++++ wrappers/matlab/sensor.m | 48 +++++++++++---- wrappers/matlab/stream.m | 22 +++---- wrappers/matlab/stream_profile.m | 44 +++++++++++--- wrappers/matlab/timestamp_domain.m | 8 +-- wrappers/matlab/video_stream_profile.m | 22 +++++++ 24 files changed, 574 insertions(+), 92 deletions(-) create mode 100644 wrappers/matlab/camera_info.m create mode 100644 wrappers/matlab/depth_sensor.m create mode 100644 wrappers/matlab/depth_stereo_sensor.m create mode 100644 wrappers/matlab/disparity_frame.m create mode 100644 wrappers/matlab/format.m create mode 100644 wrappers/matlab/motion_frame.m create mode 100644 wrappers/matlab/motion_stream_profile.m create mode 100644 wrappers/matlab/option.m create mode 100644 wrappers/matlab/options.m create mode 100644 wrappers/matlab/points.m create mode 100644 wrappers/matlab/pose_frame.m create mode 100644 wrappers/matlab/video_stream_profile.m diff --git a/wrappers/matlab/camera_info.m b/wrappers/matlab/camera_info.m new file mode 100644 index 0000000000..071bc3cf25 --- /dev/null +++ b/wrappers/matlab/camera_info.m @@ -0,0 +1,15 @@ +classdef camera_info < int64 + enumeration + name ( 0) + serial_number ( 1) + firmware_version ( 2) + recommended_firmware_version ( 3) + physical_port ( 4) + debug_op_code ( 5) + advanced_mode ( 6) + product_id ( 7) + camera_locked ( 8) + usb_type_descriptor ( 9) + count (10) + end +end \ No newline at end of file diff --git a/wrappers/matlab/depth_frame.m b/wrappers/matlab/depth_frame.m index a275930505..61af9ae734 100644 --- a/wrappers/matlab/depth_frame.m +++ b/wrappers/matlab/depth_frame.m @@ -9,8 +9,11 @@ % Destructor (uses base class destructor) % Functions - function width = get_distance(this, x, y) - realsense.librealsense_mex('rs2::depth_frame', 'get_distance', this.objectHandle, int64(x), int64(y)); + function distance = get_distance(this, x, y) + narginchk(3, 3); + validateattributes(x, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'x', 2); + validateattributes(y, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'y', 2); + distance = realsense.librealsense_mex('rs2::depth_frame', 'get_distance', this.objectHandle, int64(x), int64(y)); end end end \ No newline at end of file diff --git a/wrappers/matlab/depth_sensor.m b/wrappers/matlab/depth_sensor.m new file mode 100644 index 0000000000..cee4c9eb2e --- /dev/null +++ b/wrappers/matlab/depth_sensor.m @@ -0,0 +1,16 @@ +% Wraps librealsense2 depth_sensor class +classdef depth_sensor < sensor + methods + % Constructor + function this = depth_sensor(handle) + this = this@realsense.sensor(handle); + end + + % Destructor (uses base class destructor) + + % Functions + function scale = get_depth_scale(this) + scale = realsense.librealsense_mex('rs2::depth_sensor', 'get_depth_scale', this.objectHandle); + end + emd +end \ No newline at end of file diff --git a/wrappers/matlab/depth_stereo_sensor.m b/wrappers/matlab/depth_stereo_sensor.m new file mode 100644 index 0000000000..c5a0eede42 --- /dev/null +++ b/wrappers/matlab/depth_stereo_sensor.m @@ -0,0 +1,16 @@ +% Wraps librealsense2 depth_stereo_sensor class +classdef depth_stereo_sensor < depth_sensor + methods + % Constructor + function this = depth_stereo_sensor(handle) + this = this@realsense.depth_sensor(handle); + end + + % Destructor (uses base class destructor) + + % Functions + function scale = get_stereo_baseline(this) + scale = realsense.librealsense_mex('rs2::depth_stereo_sensor', 'get_stereo_baseline', this.objectHandle); + end + emd +end \ No newline at end of file diff --git a/wrappers/matlab/device.m b/wrappers/matlab/device.m index f76481fcd5..8f074cebb0 100644 --- a/wrappers/matlab/device.m +++ b/wrappers/matlab/device.m @@ -15,11 +15,14 @@ function do_init(this) methods % Constructor function this = device(handle, index) + narginchk(1, 2); + validateattributes(handle, {'uint64'}, {'scalar'}); this.objectHandle = handle; if (nargin == 1) % constructed from device this.id = -1; else % lazily "constructed" from device_list - this.id = index; + validateattributes(index, {'numeric'}, {'scalar', 'real', 'integer'}); + this.id = int64(index); end end % Destructor @@ -40,37 +43,48 @@ function delete(this) [sensor_array{1:nargout}] = arrayfun(@realsense.sensor, arr, 'UniformOutput', false); end function sensor = first(this, type) + narginchk(2, 2); + % C++ function validates contents of type + validateattributes(type, {'char', 'string'}, {'scalartext'}, '', 'type', 2); this.do_init(); out = realsense.librealsense_mex('rs2::device', 'first', 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); - end + sensor = realsense.sensor(out).as(type); + end + function value = supports(this, info) + narginchk(2, 2); + validateattributes(info, {'realsense.camera_info', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.camera_info.count}, '', 'info', 2); + this.do_init(); + value = realsense.librealsense_mex('rs2::device', 'supports', this.objectHandle, int64(info)); + end + function value = get_info(this, info) + narginchk(2, 2); + validateattributes(info, {'realsense.camera_info', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.camera_info.count}, '', 'info', 2); + this.do_init(); + info = realsense.librealsense_mex('rs2::device', 'get_info', this.objectHandle, int64(info)); end -% function value = supports(this, info) -% this.do_init(); -% value = realsense.librealsense_mex('rs2::device', 'supports', this.objectHandle, info); -% end -% function info = get_info(this, info) % TODO: name output var -% this.do_init(); -% info = realsense.librealsense_mex('rs2::device', 'get_info', this.objectHandle, info); -% end function hardware_reset(this) this.do_init(); realsense.librealsense_mex('rs2::device', 'hardware_reset', this.objectHandle); end function value = is(this, type) + narginchk(2, 2); + % C++ function validates contents of type + validateattributes(type, {'char', 'string'}, {'scalartext'}, '', 'type', 2); this.do_init(); out = realsense.librealsense_mex('rs2::device', 'is', this.objectHandle, type); end % function dev = as(this, type) -% this.do_init(); -% out = realsense.librealsense_mex('rs2::device', 'as', this.objectHandle, type); -% switch (type) -% case '' +% % validation and initialization done in is +% if ~this.is(type) +% error('cannot downcast dev to requested type'); +% end +% switch type +% case 'debug_protocol' +% case 'advanced_mode' +% case 'recorder' +% realsense.recorder(this) +% case 'playback' +% end +% end end end diff --git a/wrappers/matlab/disparity_frame.m b/wrappers/matlab/disparity_frame.m new file mode 100644 index 0000000000..5d30bae0ac --- /dev/null +++ b/wrappers/matlab/disparity_frame.m @@ -0,0 +1,16 @@ +% Wraps librealsense2 disparity_frame class +classdef disparity_frame < realsense.depth_frame + methods + % Constructor + function this = disparity_frame(handle) + this = this@realsense.depth_frame(handle); + end + + % Destructor (uses base class destructor) + + % Functions + function baseline = get_baseline(this) + baseline = realsense.librealsense_mex('rs2::disparity_frame', 'get_baseline', this.objectHandle); + end + end +end \ No newline at end of file diff --git a/wrappers/matlab/format.m b/wrappers/matlab/format.m new file mode 100644 index 0000000000..c18925abaa --- /dev/null +++ b/wrappers/matlab/format.m @@ -0,0 +1,25 @@ +classdef format < int64 + enumeration + any ( 0) + z16 ( 1) + disparity16 ( 2) + xyz32f ( 3) + yuyv ( 4) + rgb8 ( 5) + bgr8 ( 6) + rgba8 ( 7) + bgra8 ( 8) + y8 ( 9) + y16 (10) + raw10 (11) + raw16 (12) + raw8 (13) + uyvy (14) + motion_raw (15) + motion_xyz32f (16) + gpio_raw (17) + six_dof (18) + disparity32 (19) + count (20) + end +end \ No newline at end of file diff --git a/wrappers/matlab/frame.m b/wrappers/matlab/frame.m index ebae82bcbd..21a0286e5d 100644 --- a/wrappers/matlab/frame.m +++ b/wrappers/matlab/frame.m @@ -6,9 +6,7 @@ methods % Constructor function this = frame(handle) - if nargin == 0 - handle = 0; - end + validateattributes(handle, {'uint64'}, {'scalar'}); this.objectHandle = handle; end % Destructor @@ -19,32 +17,36 @@ function delete(this) end % Functions + % TODO: keep function timestamp = get_timestamp(this) timestamp = realsense.librealsense_mex('rs2::frame', 'get_timestamp', this.objectHandle); end function domain = get_frame_timestamp_domain(this) - domain = realsense.frame_timestamp_domain(realsense.librealsense_mex('rs2::frame', 'get_frame_timestamp_domain', this.objectHandle)); + ret = realsense.librealsense_mex('rs2::frame', 'get_frame_timestamp_domain', this.objectHandle); + domain = realsense.timestamp_domain(ret); end function metadata = get_frame_metadata(this, frame_metadata) - if (~isa(frame_metadata, 'frame_metadata')) - error('frame_metadata must be a frame_metadata'); - end - metadata = realsense.librealsense_mex('rs2::frame', 'get_frame_metadata', this.objectHandle, uint64(frame_metadata)); + narginchk(2, 2); + validateattributes(frame_metadata, {'realsense.frame_metadata_value', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.frame_metadata_value.count}, '', 'frame_metadata', 2); + metadata = realsense.librealsense_mex('rs2::frame', 'get_frame_metadata', this.objectHandle, int64(frame_metadata)); end function value = supports_frame_metadata(this, frame_metadata) - if (~isa(frame_metadata, 'frame_metadata')) - error('frame_metadata must be a frame_metadata'); - end - value = realsense.librealsense_mex('rs2::frame', 'supports_frame_metadata', this.objectHandle, uint64(frame_metadata)); + narginchk(2, 2); + validateattributes(frame_metadata, {'realsense.frame_metadata_value', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.frame_metadata_value.count}, '', 'frame_metadata', 2); + value = realsense.librealsense_mex('rs2::frame', 'supports_frame_metadata', this.objectHandle, int64(frame_metadata)); end function frame_number = get_frame_number(this) - timestamp = realsense.librealsense_mex('rs2::frame', 'get_frame_number', this.objectHandle); + frame_number = realsense.librealsense_mex('rs2::frame', 'get_frame_number', this.objectHandle); end function data = get_data(this) data = realsense.librealsense_mex('rs2::frame', 'get_data', this.objectHandle); end function profile = get_profile(this) - profile = realsense.stream_profile(realsense.librealsense_mex('rs2::frame', 'get_profile', this.objectHandle)); + ret = realsense.librealsense_mex('rs2::frame', 'get_profile', this.objectHandle); + % TODO: stream_profile takes two args + profile = realsense.stream_profile(ret); end + % TODO: is [frame, video_frame, points, depth_frame, disparity_frame, motion_frame, pose_frame, frameset] + % TODO: as [frame, video_frame, points, depth_frame, disparity_frame, motion_frame, pose_frame, frameset] end end \ No newline at end of file diff --git a/wrappers/matlab/frame_metadata_value.m b/wrappers/matlab/frame_metadata_value.m index db1743ed74..d86ccafc73 100644 --- a/wrappers/matlab/frame_metadata_value.m +++ b/wrappers/matlab/frame_metadata_value.m @@ -1,13 +1,34 @@ -classdef frame_metadata_value < uint64 +classdef frame_metadata_value < int64 enumeration - Frame_Counter (0) - Frame_Timestamp (1) - Sensor_Timestamp (2) - Actual_Exposure (3) - Gain_Level (4) - Auto_Exposure (5) - White_Balance (6) - Time_Of_Arrival (7) - Count (8) + frame_counter ( 0) + frame_timestamp ( 1) + sensor_timestamp ( 2) + actual_exposure ( 3) + gain_level ( 4) + auto_exposure ( 5) + white_balance ( 6) + time_of_arrival ( 7) + temperature ( 8) + backend_timestamp ( 9) + actual_fps (10) + frame_laser_power (11) + frame_laser_power_mode (12) + exposure_priority (13) + exposure_roi_left (14) + exposure_roi_right (15) + exposure_roi_top (16) + exposure_roi_bottom (17) + brightness (18) + contrast (19) + saturation (20) + sharpness (21) + auto_white_balance_temperature (22) + backlight_compensation (23) + hue (24) + gamma (25) + manual_white_balance (26) + power_line_frequency (27) + low_light_compensation (28) + count (29) end end \ No newline at end of file diff --git a/wrappers/matlab/frameset.m b/wrappers/matlab/frameset.m index 5b788ffb46..008509074b 100644 --- a/wrappers/matlab/frameset.m +++ b/wrappers/matlab/frameset.m @@ -1,4 +1,4 @@ -% Wraps librealsense2 video_frame class +% Wraps librealsense2 frameset class classdef frameset < realsense.frame methods % Constructor @@ -10,25 +10,32 @@ % Functions function frame = first_or_default(this, s) - if (~isa(s, 'stream')) - error('s must be a stream'); - end - frame = realsense.frame(realsense.librealsense_mex('rs2::frameset', 'first_or_default', this.objectHandle, uint64_t(s))); + narginchk(2, 2); + validateattributes(s, {'realsense.stream', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.stream.count}, '', 's', 2); + ret = realsense.librealsense_mex('rs2::frameset', 'first_or_default', this.objectHandle, int64_t(s)); + frame = realsense.frame(ret); end function frame = first(this, s) - if (~isa(s, 'stream')) - error('s must be a stream'); - end - frame = realsense.frame(realsense.librealsense_mex('rs2::frameset', 'first', this.objectHandle, uint64_t(s))); + narginchk(2, 2); + validateattributes(s, {'realsense.stream', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.stream.count}, '', 's', 2); + ret = realsense.librealsense_mex('rs2::frameset', 'first', this.objectHandle, int64_t(s)); + frame = realsense.frame(ret); end function depth_frame = get_depth_frame(this) - depth_frame = realsense.depth_frame(realsense.librealsense_mex('rs2::frameset', 'get_depth_frame', this.objectHandle)); + ret = realsense.librealsense_mex('rs2::frameset', 'get_depth_frame', this.objectHandle); + depth_frame = realsense.depth_frame(ret); end - function video_frame = get_color_frame(this) - video_frame = realsense.video_frame(realsense.librealsense_mex('rs2::frameset', 'get_color_frame', this.objectHandle)); + function color_frame = get_color_frame(this) + ret = realsense.librealsense_mex('rs2::frameset', 'get_color_frame', this.objectHandle); + color_frame = realsense.video_frame(ret); end + function infrared_frame = get_infrared_frame(this) + ret = realsense.librealsense_mex('rs2::frameset', 'get_infrared_frame', this.objectHandle); + infrared_frame = realsense.video_frame(ret); + enda function size = get_size(this) size = realsense.librealsense_mex('rs2::frameset', 'get_size', this.objectHandle); end + % TODO: iterator protocol? end end \ No newline at end of file diff --git a/wrappers/matlab/librealsense_mex.vcxproj b/wrappers/matlab/librealsense_mex.vcxproj index d01c4bc709..5c0a6ab7ec 100644 --- a/wrappers/matlab/librealsense_mex.vcxproj +++ b/wrappers/matlab/librealsense_mex.vcxproj @@ -162,21 +162,33 @@ + + + + + + + + + + + + diff --git a/wrappers/matlab/librealsense_mex.vcxproj.filters b/wrappers/matlab/librealsense_mex.vcxproj.filters index f9a384d89d..80927081a4 100644 --- a/wrappers/matlab/librealsense_mex.vcxproj.filters +++ b/wrappers/matlab/librealsense_mex.vcxproj.filters @@ -94,5 +94,41 @@ Matlab Files\Examples + + Matlab Files\Enums + + + Matlab Files\Classes + + + Matlab Files\Classes + + + Matlab Files\Classes + + + Matlab Files\Classes + + + Matlab Files\Classes + + + Matlab Files\Classes + + + Matlab Files\Classes + + + Matlab Files\Enums + + + Matlab Files\Enums + + + Matlab Files\Classes + + + Matlab Files\Classes + \ No newline at end of file diff --git a/wrappers/matlab/motion_frame.m b/wrappers/matlab/motion_frame.m new file mode 100644 index 0000000000..57ab5bbaf0 --- /dev/null +++ b/wrappers/matlab/motion_frame.m @@ -0,0 +1,16 @@ +% Wraps librealsense2 motion_frame class +classdef motion_frame < realsense.frame + methods + % Constructor + function this = motion_frame(handle) + this = this@realsense.frame(handle); + end + + % Destructor (uses base class destructor) + + % Functions + function motion_data = get_motion_data(this) + motion_data = realsense.librealsense_mex('rs2::motion_frame', 'get_motion_data', this.objectHandle); + end + end +end \ No newline at end of file diff --git a/wrappers/matlab/motion_stream_profile.m b/wrappers/matlab/motion_stream_profile.m new file mode 100644 index 0000000000..cb16e11b08 --- /dev/null +++ b/wrappers/matlab/motion_stream_profile.m @@ -0,0 +1,16 @@ +% Wraps librealsense2 motion_stream_profile class +classdef motion_stream_profile < realsense.stream_profile + methods + % Constructor + function this = motion_stream_profile(ownHandle, handle) + this = this@realsense.stream_profile(ownHandle, handle); + end + + % Destructor (uses base class destructor) + + % Functions + function motion_intrinsics = get_motion_intrinsics(this) + intrinsics = realsense.librealsense_mex('rs2::motion_stream_profile', 'get_motion_intrinsics', this.objectHandle); + end + end +end \ No newline at end of file diff --git a/wrappers/matlab/option.m b/wrappers/matlab/option.m new file mode 100644 index 0000000000..ed91a14c6f --- /dev/null +++ b/wrappers/matlab/option.m @@ -0,0 +1,48 @@ +classdef option < int64 + enumeration + backlight_compensation ( 0) + brightness ( 1) + contrast ( 2) + exposure ( 3) + gain ( 4) + gamma ( 5) + hue ( 6) + saturation ( 7) + sharpness ( 8) + white_balance ( 9) + enable_auto_exposure (10) + enable_auto_white_balance (11) + visual_preset (12) + laser_power (13) + accuracy (14) + motion_range (15) + filter_option (16) + confidence_threshold (17) + emitter_enabled (18) + frames_queue_size (19) + total_frame_drops (20) + auto_exposure_mode (21) + power_line_frequency (22) + asic_temperature (23) + error_polling_enabled (24) + projector_temperature (25) + output_trigger_enabled (26) + motion_module_temperature (27) + depth_units (28) + enable_motion_correction (29) + auto_exposure_priority (30) + color_scheme (31) + histogram_equalization_enabled (32) + min_distance (33) + max_distance (34) + texture_source (35) + filter_magnitude (36) + filter_smooth_alpha (37) + filter_smooth_delta (38) + holes_fill (39) + stereo_baseline (40) + auto_exposure_converge_step (41) + inter_cam_sync_mode (42) + count (43) + end +end \ No newline at end of file diff --git a/wrappers/matlab/options.m b/wrappers/matlab/options.m new file mode 100644 index 0000000000..b74100e5f4 --- /dev/null +++ b/wrappers/matlab/options.m @@ -0,0 +1,58 @@ +% Wraps librealsense2 options class +classdef options < handle + properties (SetAccess = protected, Hidden = true) + objectHandle; + end + methods + % Constructor + function this = options(handle) + validateattributes(handle, {'uint64'}, {'scalar'}); + this.objectHandle = handle; + end + % Destructor + function delete(this) + if this.objectHandle ~= 0 + realsense.librealsense_mex('rs2::options', 'delete', this.objectHandle); + end + end + + % Functions + function value = supports_option(this, option) + narginchk(2, 2); + validateattributes(option, {'realsense.option', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.option.count}, '', 'option', 2); + value = realsense.librealsense_mex('rs2::options', 'supports#rs2_option', this.objectHandle, int64(option)); + end + function option_description = get_option_description(this, option) + narginchk(2, 2); + validateattributes(option, {'realsense.option', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.option.count}, '', 'option', 2); + option_description = realsense.librealsense_mex('rs2::options', 'get_option_description', this.objectHandle, int64(option)); + end + function option_value_description = get_option_value_description(this, option, val) + narginchk(3, 3); + validateattributes(option, {'realsense.option', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.option.count}, '', 'option', 2); + validateattributes(val, {'numeric'}, {'scalar', 'real'}, '', 'val', 3); + option_value_description = realsense.librealsense_mex('rs2::options', 'get_option_value_description', this.objectHandle, int64(option), double(val)); + end + function value = get_option(this, option) + narginchk(2, 2); + validateattributes(option, {'realsense.option', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.option.count}, '', 'option', 2); + value = realsense.librealsense_mex('rs2::options', 'get_option', this.objectHandle, int64(option)); + end + function option_range = get_option_range(this, option) + narginchk(2, 2); + validateattributes(option, {'realsense.option', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.option.count}, '', 'option', 2); + option_range = realsense.librealsense_mex('rs2::options', 'get_option_range', this.objectHandle, int64(option)); + end + function set_option(this, option, val) + narginchk(3, 3); + validateattributes(option, {'realsense.option', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.option.count}, '', 'option', 2); + validateattributes(val, {'numeric'}, {'scalar', 'real'}, '', 'val', 3); + realsense.librealsense_mex('rs2::options', 'set_option', this.objectHandle, int64(option), double(val)); + end + function value = is_option_read_only(this, option) + narginchk(2, 2); + validateattributes(option, {'realsense.option', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.option.count}, '', 'option', 2); + value = realsense.librealsense_mex('rs2::options', 'is_option_read_only', this.objectHandle, int64(option)); + end + end +end \ No newline at end of file diff --git a/wrappers/matlab/points.m b/wrappers/matlab/points.m new file mode 100644 index 0000000000..03e33c79ac --- /dev/null +++ b/wrappers/matlab/points.m @@ -0,0 +1,31 @@ +% Wraps librealsense2 points class +classdef points < realsense.frame + methods + % Constructor + function this = points(handle) + this = this@realsense.frame(handle); + end + + % Destructor (uses base class destructor) + + % Functions + function vertcies = get_vertices(this) + vertices = realsense.librealsense_mex('rs2::points', 'get_vertices', this.objectHandle); + end + function export_to_ply(this, fname, texture) + narginchk(3, 3) + validateattributes(fname, {'char'}, {'scalartext', 'nonempty'}, '', 'fname', 2); + validateattributes(texture, {'realsense.frame'}, {'scalar'}, '', 'texture', 3); + if ~texture.is('video_frame') + error('Expected input number 3, texture, to be a video_frame'); + end + realsense.librealsense_mex('rs2::points', 'export_to_ply', this.objectHandle, fname, texture.objectHandle); + end + function texture_coordinates = get_texture_coordinates(this) + texture_coordinates = realsense.librealsense_mex('rs2::points', 'get_texture_coordinates', this.objectHandle); + end + function s = size(this) + realsense.librealsense_mex('rs2::points', 'size', this.objectHandle); + end + end +end \ No newline at end of file diff --git a/wrappers/matlab/pose_frame.m b/wrappers/matlab/pose_frame.m new file mode 100644 index 0000000000..a53b6ef4ee --- /dev/null +++ b/wrappers/matlab/pose_frame.m @@ -0,0 +1,16 @@ +% Wraps librealsense2 pose_frame class +classdef pose_frame < realsense.frame + methods + % Constructor + function this = pose_frame(handle) + this = this@realsense.frame(handle); + end + + % Destructor (uses base class destructor) + + % Functions + function pose_data = get_pose_data(this) + pose_data = realsense.librealsense_mex('rs2::pose_frame', 'get_pose_data', this.objectHandle); + end + end +end \ No newline at end of file diff --git a/wrappers/matlab/roi_sensor.m b/wrappers/matlab/roi_sensor.m index 4f91a56259..45465de372 100644 --- a/wrappers/matlab/roi_sensor.m +++ b/wrappers/matlab/roi_sensor.m @@ -1,2 +1,38 @@ +% Wraps librealsense2 roi_sensor class classdef roi_sensor < sensor + methods + % Constructor + function this = roi_sensor(handle) + this = this@realsense.sensor(handle); + end + + % Destructor (uses base class destructor) + + % Functions + function set_region_of_interest(this, roi) + narginchk(2, 2) + validateattributes(roi, {'struct'}, {'scalar'}, '', 'roi', 2); + if ~isfield(roi, 'min_x') + error('Expected input number 2, roi, to have a min_x field');; + end + validateattributes(roi.min_x, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'roi.min_x', 2); + if ~isfield(roi, 'min_y') + error('Expected input number 2, roi, to have a min_y field');; + end + validateattributes(roi.min_y, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'roi.min_y', 2); + if ~isfield(roi, 'max_x') + error('Expected input number 2, roi, to have a max_x field');; + end + validateattributes(roi.max_x, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'roi.max_x', 2); + if ~isfield(roi, 'max_y') + error('Expected input number 2, roi, to have a min_x field');; + end + validateattributes(roi.max_y, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'roi.max_y', 2); + input = struct('min_x', int64(roi.min_x), 'min_y', int64(roi.min_y), 'max_x', int64(max_x), 'max_y', int64(max_y)); + realsense.librealsense_mex('rs2::roi_sensor', 'set_region_of_interest', this.objectHandle, input); + end + function roi = get_region_of_interest(this) + roi = realsense.librealsense_mex('rs2::roi_sensor', 'get_region_of_interest', this.objectHandle); + end + emd end \ No newline at end of file diff --git a/wrappers/matlab/sensor.m b/wrappers/matlab/sensor.m index aa53c11a49..7413904eca 100644 --- a/wrappers/matlab/sensor.m +++ b/wrappers/matlab/sensor.m @@ -1,21 +1,47 @@ % Wraps librealsense2 sensor class -classdef sensor < handle - properties (SetAccess = protected, Hidden = true) - objectHandle; - end +classdef sensor < realsense.options methods % Constructor function this = sensor(handle) - this.objectHandle = handle; + this = this@realsense.options(handle); end - % Destructor - function delete(this) - if (this.objectHandle ~= 0) - realsense.librealsense_mex('rs2::sensor', 'delete', this.objectHandle); + + % 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', '<=', 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', '<=', 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 [frame_queue, etc?] + function stop(this) + realsense.librealsense_mex('rs2::sensor', 'stop', this.objectHandle); + end + function profiles = get_stream_profiles(this) + profiles = realsense.librealsense_mex('rs2::sensor', 'get_stream_profiles', this.objectHandle); + end + % TODO: is [sensor, roi_sensor, depth_sensor, depth_stereo_sensor] + % TODO: as [sensor, roi_sensor, depth_sensor, depth_stereo_sensor] - % Functions - + % Operators + % TODO: operator== end end diff --git a/wrappers/matlab/stream.m b/wrappers/matlab/stream.m index 3c34699dd8..401489654a 100644 --- a/wrappers/matlab/stream.m +++ b/wrappers/matlab/stream.m @@ -1,13 +1,15 @@ -classdef stream < uint64 +classdef stream < int64 enumeration - Any (0) - Depth (1) - Color (2) - Infrared (3) - Fisheye (4) - Gyro (5) - Accel (6) - Gpio (7) - Count (8) + any ( 0) + depth ( 1) + color ( 2) + infrared ( 3) + fisheye ( 4) + gyro ( 5) + accel ( 6) + gpio ( 7) + pose ( 8) + confidence ( 9) + count (10) end end \ No newline at end of file diff --git a/wrappers/matlab/stream_profile.m b/wrappers/matlab/stream_profile.m index 9ebedc7af0..dbc59a8003 100644 --- a/wrappers/matlab/stream_profile.m +++ b/wrappers/matlab/stream_profile.m @@ -1,12 +1,15 @@ % Wraps librealsense2 stream_profile class classdef stream_profile < handle - properties (SetAccess = private, Hidden = true) + properties (SetAccess = protected, Hidden = true) objectOwnHandle; objectHandle; end methods % Constructor function this = stream_profile(ownHandle, handle) + narginchk(2, 2); + validateattributes(ownHandle, {'uint64'}, {'scalar'}); + validateattributes(handle, {'uint64'}, {'scalar'}); this.objectOwnHandle = ownHandle; this.objectHandle = handle; end @@ -21,20 +24,45 @@ function delete(this) function index = stream_index(this) index = realsense.librealsense_mex('rs2::stream_profile', 'stream_index', this.objectHandle); end - % TODO: stream_type, format + function type = stream_type(this) + type = realsense.stream(realsense.librealsense_mex('rs2::stream_profile', 'stream_type', this.objectHandle)); + end + function fmt = format(this) + fmt = realsense.format(realsense.librealsense_mex('rs2::stream_profile', 'format', this.objectHandle)); + end function f = fps(this) - f = realsense.librealsense_mex('re2::stream_profile', 'fps', this.objectHandle); + f = realsense.librealsense_mex('rs2::stream_profile', 'fps', this.objectHandle); end function id = unique_id(this) - id = realsense.librealsense_mex('re2::stream_profile', 'unique_id', this.objectHandle); + id = realsense.librealsense_mex('rs2::stream_profile', 'unique_id', this.objectHandle); + end + function profile = clone(this, type, index, fmt) + narginchk(4, 4); + validateattributes(type, {'realsense.stream', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.stream.count}, '', 'type', 2); + validateattributes(index, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'index', 3); + validateattributes(fmt, {'realsense.format', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.format.count}, '', 'fmt', 4); + out = realsense.librealsense_mex('rs2::stream_profile', 'clone', this.objectHandle, int64(type), int64(index), int64(fmt)); + % TODO: stream_profile gets two args + realsense.stream_profile(out); end - % TODO: clone + % TODO: is [stream_profile, video_stream_profile, motion_stream_profile] + % TODO: as [stream_profile, video_stream_profile, motion_stream_profile] function name = stream_name(this) - id = realsense.librealsense_mex('re2::stream_profile', 'stream_name', this.objectHandle); + id = realsense.librealsense_mex('rs2::stream_profile', 'stream_name', this.objectHandle); end function value = is_default(this) - value = realsense.librealsense_mex('re2::stream_profile', 'is_default', this.objectHandle); + value = realsense.librealsense_mex('rs2::stream_profile', 'is_default', this.objectHandle); end - % TODO: get_extrinsics_to + function extrinsics = get_extrinsics_to(this, to) + narginchk(2, 2); + validateattributes(to, {'realsense.stream_profile'}, {'scalar'}, '', 'to', 2); + extrinsics = realsense.librealsense_mex('rs2::stream_profile', 'get_extrinsics_to', this.objectHandle, to.objectHandle); + end + function value = is_cloned(this) + value = realsense.librealsense_mex('rs2::stream_profile', 'is_cloned', this.objectHandle) + end + + % Operators + % TODO: operator== end end \ No newline at end of file diff --git a/wrappers/matlab/timestamp_domain.m b/wrappers/matlab/timestamp_domain.m index 989fa61e8c..37a4fc39c3 100644 --- a/wrappers/matlab/timestamp_domain.m +++ b/wrappers/matlab/timestamp_domain.m @@ -1,7 +1,7 @@ -classdef timestamp_domain < uint64 +classdef timestamp_domain < int64 enumeration - Hardware_Clock (0) - System_Time (1) - Count (2) + hardware_clock (0) + system_time (1) + count (2) end end \ No newline at end of file diff --git a/wrappers/matlab/video_stream_profile.m b/wrappers/matlab/video_stream_profile.m new file mode 100644 index 0000000000..227a607567 --- /dev/null +++ b/wrappers/matlab/video_stream_profile.m @@ -0,0 +1,22 @@ +% Wraps librealsense2 video_stream_profile class +classdef video_stream_profile < realsense.stream_profile + methods + % Constructor + function this = video_stream_profile(ownHandle, handle) + this = this@realsense.stream_profile(ownHandle, handle); + end + + % Destructor (uses base class destructor) + + % Functions + function w = width(this) + w = realsense.librealsense_mex('rs2::video_stream_profile', 'width', this.objectHandle); + end + function h = heigh(this) + h = realsense.librealsense_mex('rs2::video_stream_profile', 'height', this.objectHandle); + end + function intrinsics = get_intrinsics(this) + intrinsics = realsense.librealsense_mex('rs2::video_stream_profile', 'get_intrinsics', this.objectHandle); + end + end +end \ No newline at end of file