diff --git a/wrappers/matlab/align.m b/wrappers/matlab/align.m index 02d4cf4835..84db472c16 100644 --- a/wrappers/matlab/align.m +++ b/wrappers/matlab/align.m @@ -1,12 +1,12 @@ % Wraps librealsense2 align class -classdef align < realsense.processing_block +classdef align < realsense.filter methods % Constructor function this = align(align_to) narginchk(1, 1); validateattributes(align_to, {'realsense.stream', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', realsense.stream.count}); this.objectHandle = realsense.librealsense_mex('rs2::align', 'new', int64(align_to)); - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor) diff --git a/wrappers/matlab/colorizer.m b/wrappers/matlab/colorizer.m index f5978741e0..fabc0c844c 100644 --- a/wrappers/matlab/colorizer.m +++ b/wrappers/matlab/colorizer.m @@ -1,5 +1,5 @@ % Wraps librealsense2 colorizer class -classdef colorizer < realsense.processing_block +classdef colorizer < realsense.filter methods % Constructor function this = colorizer(color_scheme) @@ -9,7 +9,7 @@ validateattributes(color_scheme, {'numeric'}, {'scalar', 'nonnegative', 'real'}); out = realsense.librealsense_mex('rs2::colorizer', 'new', double(color_scheme)); end - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor) diff --git a/wrappers/matlab/decimation_filter.m b/wrappers/matlab/decimation_filter.m index 1fec8cfbe7..9f83e4bae7 100644 --- a/wrappers/matlab/decimation_filter.m +++ b/wrappers/matlab/decimation_filter.m @@ -1,5 +1,5 @@ % Wraps librealsense2 decimation_filter class -classdef decimation_filter < realsense.processing_block +classdef decimation_filter < realsense.filter methods % Constructor function this = decimation_filter(magnitude) @@ -9,7 +9,7 @@ validateattributes(magnitude, {'numeric'}, {'scalar', 'nonnegative', 'real'}); out = realsense.librealsense_mex('rs2::decimation_filter', 'new', double(magnitude)); end - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor) diff --git a/wrappers/matlab/disparity_transform.m b/wrappers/matlab/disparity_transform.m index 7a8061102a..710576efaf 100644 --- a/wrappers/matlab/disparity_transform.m +++ b/wrappers/matlab/disparity_transform.m @@ -1,5 +1,5 @@ % Wraps librealsense2 disparity_transform class -classdef disparity_transform < realsense.processing_block +classdef disparity_transform < realsense.filter methods % Constructor function this = disparity_transform(transform_to_disparity) @@ -9,7 +9,7 @@ validateattributes(transform_to_disparity, {'logical', 'numeric'}, {'scalar', 'real'}); out = realsense.librealsense_mex('rs2::disparity_transform', 'new', logical(transform_to_disparity)); end - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor) diff --git a/wrappers/matlab/processing_block.m b/wrappers/matlab/filter.m similarity index 61% rename from wrappers/matlab/processing_block.m rename to wrappers/matlab/filter.m index 3695e8ba93..629094565f 100644 --- a/wrappers/matlab/processing_block.m +++ b/wrappers/matlab/filter.m @@ -1,8 +1,8 @@ -% Wraps librealsense2 processing_block class -classdef processing_block < realsense.options +% Wraps librealsense2 filter class +classdef filter < realsense.options methods % Constructor - function this = processing_block(handle) + function this = filter(handle) this = this@realsense.options(handle); end @@ -12,7 +12,7 @@ function out_frame = process(this, frame) narginchk(2, 2) validateattributes(frame, {'realsense.frame'}, {'scalar'}, '', 'frame', 2); - out = realsense.librealsense_mex('rs2::processing_block', 'process', this.objectHandle, frame.objectHandle); + out = realsense.librealsense_mex('rs2::filter', 'process', this.objectHandle, frame.objectHandle); out_frame = realsense.frame(out); end end diff --git a/wrappers/matlab/hole_filling_filter.m b/wrappers/matlab/hole_filling_filter.m index 438a4af5f5..93954ce54e 100644 --- a/wrappers/matlab/hole_filling_filter.m +++ b/wrappers/matlab/hole_filling_filter.m @@ -1,5 +1,5 @@ % Wraps librealsense2 hole_filling_filter class -classdef hole_filling_filter < realsense.processing_block +classdef hole_filling_filter < realsense.filter methods % Constructor function this = hole_filling_filter(mode) @@ -9,7 +9,7 @@ validateattributes(mode, {'numeric'}, {'scalar', 'real', 'integer'}); out = realsense.librealsense_mex('rs2::hole_filling_filter', 'new', int64(mode)); end - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor) diff --git a/wrappers/matlab/librealsense_mex.cpp b/wrappers/matlab/librealsense_mex.cpp index 16cac9ed07..4d462e2191 100644 --- a/wrappers/matlab/librealsense_mex.cpp +++ b/wrappers/matlab/librealsense_mex.cpp @@ -919,16 +919,22 @@ void make_factory(){ }); factory->record(frame_queue_factory); } +// TODO: need to understand how to call matlab functions from within C++ before async things can be implemented. +// processing_block API is completely async. +// { +// ClassFactory processing_block_factory("rs2::processing_block"); +// +// factory->record(processing_block_factory); +// } { - ClassFactory processing_block_factory("rs2::processing_block"); - processing_block_factory.record("process", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) + ClassFactory filter_factory("rs2::filter"); + filter_factory.record("process", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) { auto thiz = MatlabParamParser::parse(inv[0]); auto frame = MatlabParamParser::parse(inv[1]); outv[0] = MatlabParamParser::wrap(thiz.process(frame)); }); - // TODO: expose more functions? - factory->record(processing_block_factory); + factory->record(filter_factory); } { ClassFactory pointcloud_factory("rs2::pointcloud"); diff --git a/wrappers/matlab/pointcloud.m b/wrappers/matlab/pointcloud.m index 667ec84570..5e69e40eb7 100644 --- a/wrappers/matlab/pointcloud.m +++ b/wrappers/matlab/pointcloud.m @@ -1,5 +1,5 @@ % Wraps librealsense2 pointcloud class -classdef pointcloud < realsense.processing_block +classdef pointcloud < realsense.filter methods % Constructor function this = pointcloud(stream, index) @@ -14,7 +14,7 @@ validateattributes(index, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}); out = realsense.librealsense_mex('rs2::pointcloud', 'new', int64(stream), int64(index)); end - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor) diff --git a/wrappers/matlab/rs2_type_traits.h b/wrappers/matlab/rs2_type_traits.h index 38a291cc6c..18bd5c0591 100644 --- a/wrappers/matlab/rs2_type_traits.h +++ b/wrappers/matlab/rs2_type_traits.h @@ -21,6 +21,9 @@ template struct MatlabParamParser::type_traits struct MatlabParamParser::type_traits { + // since it is impossible to create an rs2::options object (you must cast from a deriving type) + // The carrier's job is to help jump bridge that gap. Each type that derives directly from rs2::options + // must be added to the carrier's logic struct carrier { void * ptr; enum class types { rs2_sensor, rs2_processing_block } type; diff --git a/wrappers/matlab/spatial_filter.m b/wrappers/matlab/spatial_filter.m index b12f9cef7b..0eb69859a9 100644 --- a/wrappers/matlab/spatial_filter.m +++ b/wrappers/matlab/spatial_filter.m @@ -1,5 +1,5 @@ % Wraps librealsense2 spatial_filter class -classdef spatial_filter < realsense.processing_block +classdef spatial_filter < realsense.filter methods % Constructor function this = spatial_filter(smooth_alpha, smooth_delta, magnitude, hole_fill) @@ -14,7 +14,7 @@ else % TODO: Error out on bad arg count end - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor) diff --git a/wrappers/matlab/temporal_filter.m b/wrappers/matlab/temporal_filter.m index ca72041b24..ae7eff3241 100644 --- a/wrappers/matlab/temporal_filter.m +++ b/wrappers/matlab/temporal_filter.m @@ -1,5 +1,5 @@ % Wraps librealsense2 temporal_filter class -classdef temporal_filter < realsense.processing_block +classdef temporal_filter < realsense.filter methods % Constructor function this = temporal_filter(smooth_alpha, smooth_delta, persistence_control) @@ -13,7 +13,7 @@ else % TODO: Error out on bad arg count end - this = this@realsense.processing_block(out); + this = this@realsense.filter(out); end % Destructor (uses base class destructor)