librealsense_mex.cpp
Go to the documentation of this file.
1 #include "MatlabParamParser.h"
2 #include "Factory.h"
3 #include "librealsense2/rs.hpp"
6 
7 #pragma comment(lib, "libmx.lib")
8 #pragma comment(lib, "libmex.lib")
9 #pragma comment(lib, "libmat.lib")
10 #pragma comment(lib, "realsense2.lib")
11 
13 
14 void make_factory(){
15  factory = new Factory();
16 
17  // rs_frame.hpp
18  {
19  ClassFactory stream_profile_factory("rs2::stream_profile");
20  stream_profile_factory.record("new", 1, 0, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
21  {
23  });
24  stream_profile_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
25  {
26  MatlabParamParser::destroy<rs2::stream_profile>(inv[0]);
27  });
28  stream_profile_factory.record("stream_index", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
29  {
30  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
31  outv[0] = MatlabParamParser::wrap(thiz.stream_index());
32  });
33  stream_profile_factory.record("stream_type", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
34  {
35  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
36  outv[0] = MatlabParamParser::wrap(thiz.stream_type());
37  });
38  stream_profile_factory.record("format", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
39  {
40  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
41  outv[0] = MatlabParamParser::wrap(thiz.format());
42  });
43  stream_profile_factory.record("fps", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
44  {
45  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
46  outv[0] = MatlabParamParser::wrap(thiz.fps());
47  });
48  stream_profile_factory.record("unique_id", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
49  {
50  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
51  outv[0] = MatlabParamParser::wrap(thiz.unique_id());
52  });
53  stream_profile_factory.record("clone", 1, 4, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
54  {
55  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
56  auto type = MatlabParamParser::parse<rs2_stream>(inv[1]);
57  auto index = MatlabParamParser::parse<int>(inv[2]);
58  auto format = MatlabParamParser::parse<rs2_format>(inv[3]);
59  outv[0] = MatlabParamParser::wrap(thiz.clone(type, index, format));
60  });
61  stream_profile_factory.record("operator==", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
62  {
63  auto rhs = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
64  auto lhs = MatlabParamParser::parse<rs2::stream_profile>(inv[1]);
65  MatlabParamParser::wrap(rhs == lhs);
66  });
67  stream_profile_factory.record("is", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
68  {
69  // TODO: something more maintainable?
70  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
71  auto type = MatlabParamParser::parse<std::string>(inv[1]);
72  if (type == "stream_profile")
73  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::stream_profile>());
74  else if (type == "video_stream_profile")
76  else if (type == "motion_stream_profile")
78  else {
79  mexWarnMsgTxt("rs2::stream_profile::is: invalid type parameter");
80  outv[0] = MatlabParamParser::wrap(false);
81  }
82  });
83  stream_profile_factory.record("as", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
84  {
85  // TODO: something more maintainable?
86  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
87  auto type = MatlabParamParser::parse<std::string>(inv[1]);
88  if (type == "stream_profile")
89  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::stream_profile>());
90  else if (type == "video_stream_profile")
92  else if (type == "motion_stream_profile")
94  else {
95  mexWarnMsgTxt("rs2::stream_profile::as: invalid type parameter");
96  outv[0] = MatlabParamParser::wrap(uint64_t(0));
97  }
98  });
99  stream_profile_factory.record("stream_name", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
100  {
101  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
102  outv[0] = MatlabParamParser::wrap(thiz.stream_name());
103  });
104  stream_profile_factory.record("is_default", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
105  {
106  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
107  outv[0] = MatlabParamParser::wrap(thiz.is_default());
108  });
109  stream_profile_factory.record("operator bool", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
110  {
111  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
112  outv[0] = MatlabParamParser::wrap(bool(thiz));
113  });
114  stream_profile_factory.record("get_extrinsics_to", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
115  {
116  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
117  auto to = MatlabParamParser::parse<rs2::stream_profile>(inv[1]);
118  outv[0] = MatlabParamParser::wrap(thiz.get_extrinsics_to(to));
119  });
120  // rs2::stream_profile::register_extrinsics_to [?]
121  stream_profile_factory.record("is_cloned", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
122  {
123  auto thiz = MatlabParamParser::parse<rs2::stream_profile>(inv[0]);
124  outv[0] = MatlabParamParser::wrap(thiz.is_cloned());
125  });
126  factory->record(stream_profile_factory);
127  }
128  {
129  ClassFactory video_stream_profile_factory("rs2::video_stream_profile");
130  // rs2::video_stream_profile::constructor(rs2::stream_profile) [?]
131  video_stream_profile_factory.record("width", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
132  {
133  auto thiz = MatlabParamParser::parse<rs2::video_stream_profile>(inv[0]);
134  outv[0] = MatlabParamParser::wrap(thiz.width());
135  });
136  video_stream_profile_factory.record("height", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
137  {
138  auto thiz = MatlabParamParser::parse<rs2::video_stream_profile>(inv[0]);
139  outv[0] = MatlabParamParser::wrap(thiz.height());
140  });
141  video_stream_profile_factory.record("get_intrinsics", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
142  {
143  auto thiz = MatlabParamParser::parse<rs2::video_stream_profile>(inv[0]);
144  outv[0] = MatlabParamParser::wrap(thiz.get_intrinsics());
145  });
146  factory->record(video_stream_profile_factory);
147  }
148  {
149  ClassFactory motion_stream_profile_factory("rs2::motion_stream_profile");
150  // rs2::motion_stream_profile::constructor(rs2::stream_profile) [?]
151  motion_stream_profile_factory.record("get_motion_intrinsics", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
152  {
153  auto thiz = MatlabParamParser::parse<rs2::motion_stream_profile>(inv[0]);
154  outv[0] = MatlabParamParser::wrap(thiz.get_motion_intrinsics());
155  });
156  factory->record(motion_stream_profile_factory);
157  }
158  //{
159  // ClassFactory pose_stream_profile_factory("rs2::pose_stream_profile");
160  // // rs2::pose_stream_profile::constructor(rs2::stream_profile) [?]
161  // factory->record(pose_stream_profile_factory);
162  //}
163  {
164  ClassFactory frame_factory("rs2::frame");
165  // rs2::frame::constructor() [?]
166  frame_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
167  {
168  MatlabParamParser::destroy<rs2::frame>(inv[0]);
169  });
170  // rs2::frame::operator= [?/HOW]
171  // rs2::frame::copy constructor [?/HOW]
172  // rs2::frame::swap [?/HOW]
173  // rs2::frame::keep [TODO/HOW]
174  frame_factory.record("operator bool", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
175  {
176  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
177  outv[0] = MatlabParamParser::wrap(bool(thiz));
178  });
179  frame_factory.record("get_timestamp", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
180  {
181  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
182  outv[0] = MatlabParamParser::wrap(thiz.get_timestamp());
183  });
184  frame_factory.record("get_frame_timestamp_domain", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
185  {
186  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
187  outv[0] = MatlabParamParser::wrap(thiz.get_frame_timestamp_domain());
188  });
189  frame_factory.record("get_frame_metadata", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
190  {
191  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
192  auto frame_metadata = MatlabParamParser::parse<rs2_frame_metadata_value>(inv[1]);
193  outv[0] = MatlabParamParser::wrap(thiz.get_frame_metadata(frame_metadata));
194  });
195  frame_factory.record("supports_frame_metadata", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
196  {
197  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
198  auto frame_metadata = MatlabParamParser::parse<rs2_frame_metadata_value>(inv[1]);
199  outv[0] = MatlabParamParser::wrap(thiz.supports_frame_metadata(frame_metadata));
200  });
201  frame_factory.record("get_frame_number", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
202  {
203  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
204  outv[0] = MatlabParamParser::wrap(thiz.get_frame_number());
205  });
206  frame_factory.record("get_data", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
207  {
208  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
209  size_t n_bytes = 0;
210  if (auto vf = thiz.as<rs2::video_frame>()) {
211  n_bytes = vf.get_height() * vf.get_stride_in_bytes();
212  } // TODO: support more frame types?
213 
214  switch (thiz.get_profile().format()) {
215  case RS2_FORMAT_RAW10:
216  // TODO: Do the bit hackery ourselves?
217  mexWarnMsgTxt("Raw10 data provided as unsigned byte array.");
220  case RS2_FORMAT_Y8: case RS2_FORMAT_RAW8:
221  if (n_bytes == 0) {
222  n_bytes = 1;
223  mexWarnMsgTxt("Can't detect frame dims, sending only first pixel");
224  }
225  outv[0] = MatlabParamParser::wrap_array(reinterpret_cast<const uint8_t*>(thiz.get_data()), n_bytes);
226  break;
228  case RS2_FORMAT_Y16: case RS2_FORMAT_RAW16:
229  case RS2_FORMAT_FG:
230  if (n_bytes == 0) {
231  n_bytes = 2;
232  mexWarnMsgTxt("Can't detect frame dims, sending only first pixel");
233  }
234  outv[0] = MatlabParamParser::wrap_array(reinterpret_cast<const uint16_t*>(thiz.get_data()), n_bytes / 2);
235  break;
238  if (n_bytes == 0) {
239  n_bytes = 4;
240  mexWarnMsgTxt("Can't detect frame dims, sending only first pixel");
241  }
242  outv[0] = MatlabParamParser::wrap_array(reinterpret_cast<const float*>(thiz.get_data()), n_bytes / 4);
243  break;
244  case RS2_FORMAT_UYVY: case RS2_FORMAT_YUYV:
245  if (n_bytes == 0) {
246  n_bytes = 4;
247  mexWarnMsgTxt("Can't detect frame dims, sending only first pixel");
248  }
249  outv[0] = MatlabParamParser::wrap_array(reinterpret_cast<const uint32_t*>(thiz.get_data()), n_bytes / 4);
250  break;
251  default:
252  mexWarnMsgTxt("This format isn't supported yet. Sending unsigned byte stream");
253  if (n_bytes == 0) {
254  n_bytes = 1;
255  mexWarnMsgTxt("Can't detect frame dims, sending only first pixel");
256  }
257  outv[0] = MatlabParamParser::wrap_array(reinterpret_cast<const uint8_t*>(thiz.get_data()), n_bytes);
258  }
259  });
260  frame_factory.record("get_profile", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
261  {
262  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
263  outv[0] = MatlabParamParser::wrap(thiz.get_profile());
264  });
265  frame_factory.record("is", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
266  {
267  // TODO: something more maintainable?
268  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
269  auto type = MatlabParamParser::parse<std::string>(inv[1]);
270  if (type == "frame")
271  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::frame>());
272  else if (type == "video_frame")
273  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::video_frame>());
274  else if (type == "points")
275  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::points>());
276  else if (type == "depth_frame")
277  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::depth_frame>());
278  else if (type == "disparity_frame")
279  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::disparity_frame>());
280  else if (type == "motion_frame")
281  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::motion_frame>());
282  else if (type == "pose_frame")
283  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::pose_frame>());
284  else if (type == "frameset")
285  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::frameset>());
286  else {
287  mexWarnMsgTxt("rs2::frame::is: invalid type parameter");
288  outv[0] = MatlabParamParser::wrap(false);
289  }
290  });
291  frame_factory.record("as", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
292  {
293  // TODO: something more maintainable?
294  auto thiz = MatlabParamParser::parse<rs2::frame>(inv[0]);
295  auto type = MatlabParamParser::parse<std::string>(inv[1]);
296  if (type == "frame")
297  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::frame>());
298  else if (type == "video_frame")
299  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::video_frame>());
300  else if (type == "points")
301  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::points>());
302  else if (type == "depth_frame")
303  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::depth_frame>());
304  else if (type == "disparity_frame")
305  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::disparity_frame>());
306  else if (type == "motion_frame")
307  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::motion_frame>());
308  else if (type == "pose_frame")
309  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::pose_frame>());
310  else if (type == "frameset")
311  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::frameset>());
312  else {
313  mexWarnMsgTxt("rs2::frame::as: invalid type parameter");
314  outv[0] = MatlabParamParser::wrap(uint64_t(0));
315  }
316  });
317  factory->record(frame_factory);
318  }
319  {
320  ClassFactory video_frame_factory("rs2::video_frame");
321  // rs2::video_frame::constructor() [?]
322  video_frame_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
323  {
324  MatlabParamParser::destroy<rs2::video_frame>(inv[0]);
325  });
326  video_frame_factory.record("get_width", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
327  {
328  auto thiz = MatlabParamParser::parse<rs2::video_frame>(inv[0]);
329  outv[0] = MatlabParamParser::wrap(thiz.get_width());
330  });
331  video_frame_factory.record("get_height", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
332  {
333  auto thiz = MatlabParamParser::parse<rs2::video_frame>(inv[0]);
334  outv[0] = MatlabParamParser::wrap(thiz.get_height());
335  });
336  video_frame_factory.record("get_stride_in_bytes", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
337  {
338  auto thiz = MatlabParamParser::parse<rs2::video_frame>(inv[0]);
339  outv[0] = MatlabParamParser::wrap(thiz.get_stride_in_bytes());
340  });
341  video_frame_factory.record("get_bits_per_pixel", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
342  {
343  auto thiz = MatlabParamParser::parse<rs2::video_frame>(inv[0]);
344  outv[0] = MatlabParamParser::wrap(thiz.get_bits_per_pixel());
345  });
346  video_frame_factory.record("get_bytes_per_pixel", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
347  {
348  auto thiz = MatlabParamParser::parse<rs2::video_frame>(inv[0]);
349  outv[0] = MatlabParamParser::wrap(thiz.get_bytes_per_pixel());
350  });
351  factory->record(video_frame_factory);
352  }
353  {
354  ClassFactory points_factory("rs2::points");
355  // rs2::points::constructor() [?]
356  // rs2::points::constrcutor(rs2::frame) [?]
357  points_factory.record("get_vertices", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
358  {
359  auto thiz = MatlabParamParser::parse<rs2::points>(inv[0]);
360  // TODO: turn into matrix instead of column?
361  outv[0] = MatlabParamParser::wrap_array(thiz.get_vertices(), thiz.size());
362  });
363  points_factory.record("export_to_ply", 0, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
364  {
365  auto thiz = MatlabParamParser::parse<rs2::points>(inv[0]);
366  auto fname = MatlabParamParser::parse<std::string>(inv[1]);
367  auto texture = MatlabParamParser::parse<rs2::video_frame>(inv[2]);
368  thiz.export_to_ply(fname, texture);
369  });
370  points_factory.record("get_texture_coordinates", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
371  {
372  auto thiz = MatlabParamParser::parse<rs2::points>(inv[0]);
373  // TODO: turn into matrix instead of column?
374  outv[0] = MatlabParamParser::wrap_array(thiz.get_texture_coordinates(), thiz.size());
375  });
376  points_factory.record("size", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
377  {
378  auto thiz = MatlabParamParser::parse<rs2::points>(inv[0]);
379  outv[0] = MatlabParamParser::wrap(thiz.size());
380  });
381  factory->record(points_factory);
382  }
383  {
384  ClassFactory depth_frame_factory("rs2::depth_frame");
385  // rs2::depth_frame::constructor() [?]
386  depth_frame_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
387  {
388  MatlabParamParser::destroy<rs2::depth_frame>(inv[0]);
389  });
390  depth_frame_factory.record("get_distance", 1, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
391  {
392  auto thiz = MatlabParamParser::parse<rs2::depth_frame>(inv[0]);
393  auto x = MatlabParamParser::parse<int>(inv[1]);
394  auto y = MatlabParamParser::parse<int>(inv[2]);
395  outv[0] = MatlabParamParser::wrap(thiz.get_distance(x, y));
396  });
397  depth_frame_factory.record("get_units", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
398  {
399  auto thiz = MatlabParamParser::parse<rs2::depth_frame>(inv[0]);
400  outv[0] = MatlabParamParser::wrap(thiz.get_units());
401  });
402  factory->record(depth_frame_factory);
403  }
404  {
405  ClassFactory disparity_frame_factory("rs2::disparity_frame");
406  // rs2::disparity_frame::constructor(rs2::frame) [?]
407  disparity_frame_factory.record("get_baseline", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
408  {
409  auto thiz = MatlabParamParser::parse<rs2::disparity_frame>(inv[0]);
410  outv[0] = MatlabParamParser::wrap(thiz.get_baseline());
411  });
412  factory->record(disparity_frame_factory);
413  }
414  {
415  ClassFactory motion_frame_factory("rs2::motion_frame");
416  // rs2::motion_frame::constructor(rs2::frame) [?]
417  motion_frame_factory.record("get_motion_data", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
418  {
419  auto thiz = MatlabParamParser::parse<rs2::motion_frame>(inv[0]);
420  outv[0] = MatlabParamParser::wrap(thiz.get_motion_data());
421  });
422  factory->record(motion_frame_factory);
423  }
424  {
425  ClassFactory pose_frame_factory("rs2::pose_frame");
426  // rs2::pose_frame::constructor(rs2::frame) [?]
427  pose_frame_factory.record("get_pose_data", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
428  {
429  auto thiz = MatlabParamParser::parse<rs2::pose_frame>(inv[0]);
430  outv[0] = MatlabParamParser::wrap(thiz.get_pose_data());
431  });
432  factory->record(pose_frame_factory);
433  }
434  {
435  ClassFactory frameset_factory("rs2::frameset");
436  // rs2::frameset::constructor() [?]
437  // rs2::frameset::constructor(frame) [?]
438  frameset_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
439  {
440  MatlabParamParser::destroy<rs2::frameset>(inv[0]);
441  });
442  frameset_factory.record("first_or_default", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
443  {
444  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
445  auto s = MatlabParamParser::parse<rs2_stream>(inv[1]);
446  outv[0] = MatlabParamParser::wrap(thiz.first_or_default(s));
447  });
448  frameset_factory.record("first", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
449  {
450  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
451  auto s = MatlabParamParser::parse<rs2_stream>(inv[1]);
452  // try/catch moved to outer framework
453  outv[0] = MatlabParamParser::wrap(thiz.first(s));
454  });
455  frameset_factory.record("get_depth_frame", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
456  {
457  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
458  // try/catch moved to outer framework
459  outv[0] = MatlabParamParser::wrap(thiz.get_depth_frame());
460  });
461  frameset_factory.record("get_color_frame", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
462  {
463  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
464  // try/catch moved to outer framework
465  outv[0] = MatlabParamParser::wrap(thiz.get_color_frame());
466  });
467  frameset_factory.record("get_infrared_frame", 1, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
468  {
469  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
470  // try/catch moved to outer framework
471  if (inc == 1)
472  outv[0] = MatlabParamParser::wrap(thiz.get_infrared_frame());
473  else {
474  auto index = MatlabParamParser::parse<size_t>(inv[1]);
475  outv[0] = MatlabParamParser::wrap(thiz.get_infrared_frame(index));
476  }
477  });
478  frameset_factory.record("get_fisheye_frame", 1, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
479  {
480  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
481  // try/catch moved to outer framework
482  if (inc == 1)
483  outv[0] = MatlabParamParser::wrap(thiz.get_fisheye_frame());
484  else {
485  auto index = MatlabParamParser::parse<size_t>(inv[1]);
486  outv[0] = MatlabParamParser::wrap(thiz.get_fisheye_frame(index));
487  }
488  });
489  frameset_factory.record("get_pose_frame", 1, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
490  {
491  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
492  // try/catch moved to outer framework
493  if (inc == 1)
494  outv[0] = MatlabParamParser::wrap(thiz.get_pose_frame());
495  else {
496  auto index = MatlabParamParser::parse<size_t>(inv[1]);
497  outv[0] = MatlabParamParser::wrap(thiz.get_pose_frame(index));
498  }
499  });
500  frameset_factory.record("size", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
501  {
502  auto thiz = MatlabParamParser::parse<rs2::frameset>(inv[0]);
503  outv[0] = MatlabParamParser::wrap(thiz.size());
504  });
505  // rs2::frameset::foreach [?/Callbacks]
506  // rs2::frameset::operator[] [?/HOW]
507  // rs2::frameset::iterator+begin+end [Pure Matlab?]
508  factory->record(frameset_factory);
509  }
510 
511  // rs_sensor.hpp
512  // rs2::notification [?]
513  {
514  ClassFactory options_factory("rs2::options");
515  options_factory.record("supports#rs2_option", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
516  {
517  auto thiz = MatlabParamParser::parse<rs2::options>(inv[0]);
518  auto option = MatlabParamParser::parse<rs2_option>(inv[1]);
519  outv[0] = MatlabParamParser::wrap(thiz.supports(option));
520  });
521  options_factory.record("get_option_description", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
522  {
523  auto thiz = MatlabParamParser::parse<rs2::options>(inv[0]);
524  auto option = MatlabParamParser::parse<rs2_option>(inv[1]);
525  outv[0] = MatlabParamParser::wrap(thiz.get_option_description(option));
526  });
527  options_factory.record("get_option_value_description", 1, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
528  {
529  auto thiz = MatlabParamParser::parse<rs2::options>(inv[0]);
530  auto option = MatlabParamParser::parse<rs2_option>(inv[1]);
531  auto val = MatlabParamParser::parse<float>(inv[2]);
532  outv[0] = MatlabParamParser::wrap(thiz.get_option_value_description(option, val));
533  });
534  options_factory.record("get_option", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
535  {
536  auto thiz = MatlabParamParser::parse<rs2::options>(inv[0]);
537  auto option = MatlabParamParser::parse<rs2_option>(inv[1]);
538  outv[0] = MatlabParamParser::wrap(thiz.get_option(option));
539  });
540  options_factory.record("get_option_range", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
541  {
542  auto thiz = MatlabParamParser::parse<rs2::options>(inv[0]);
543  auto option = MatlabParamParser::parse<rs2_option>(inv[1]);
544  outv[0] = MatlabParamParser::wrap(thiz.get_option_range(option));
545  });
546  options_factory.record("set_option", 0, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
547  {
548  auto thiz = MatlabParamParser::parse<rs2::options>(inv[0]);
549  auto option = MatlabParamParser::parse<rs2_option>(inv[1]);
550  auto val = MatlabParamParser::parse<float>(inv[2]);
551  thiz.set_option(option, val);
552  });
553  options_factory.record("is_option_read_only", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
554  {
555  auto thiz = MatlabParamParser::parse<rs2::options>(inv[0]);
556  auto option = MatlabParamParser::parse<rs2_option>(inv[1]);
557  outv[0] = MatlabParamParser::wrap(thiz.is_option_read_only(option));
558  });
559  // rs2::options::operator= [?/HOW]
560  options_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
561  {
562  MatlabParamParser::destroy<rs2::options>(inv[0]);
563  });
564  factory->record(options_factory);
565  }
566  {
567  ClassFactory sensor_factory("rs2::sensor");
568  // rs2::sensor::constructor() [?]
569  sensor_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
570  {
571  MatlabParamParser::destroy<rs2::sensor>(inv[0]);
572  });
573  sensor_factory.record("open#stream_profile", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
574  {
575  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
576  auto profile = MatlabParamParser::parse<rs2::stream_profile>(inv[1]);
577  thiz.open(profile);
578  });
579  sensor_factory.record("supports#rs2_camera_info", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
580  {
581  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
582  auto info = MatlabParamParser::parse<rs2_camera_info>(inv[1]);
583  outv[0] = MatlabParamParser::wrap(thiz.supports(info));
584  });
585  sensor_factory.record("get_info", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
586  {
587  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
588  auto info = MatlabParamParser::parse<rs2_camera_info>(inv[1]);
589  outv[0] = MatlabParamParser::wrap(thiz.get_info(info));
590  });
591  sensor_factory.record("open#vec_stream_profile", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
592  {
593  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
594  auto profiles = MatlabParamParser::parse<std::vector<rs2::stream_profile>>(inv[1]);
595  thiz.open(profiles);
596  });
597  sensor_factory.record("close", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
598  {
599  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
600  thiz.close();
601  });
602  // rs2::sensor::start(*) [?/Which/Callbacks]
603  sensor_factory.record("start#frame_queue", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
604  {
605  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
606  auto queue = MatlabParamParser::parse<rs2::frame_queue>(inv[1]);
607  thiz.start(queue);
608  });
609  sensor_factory.record("stop", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
610  {
611  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
612  thiz.stop();
613  });
614  sensor_factory.record("get_stream_profiles", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
615  {
616  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
617  MatlabParamParser::wrap(thiz.get_stream_profiles());
618  });
619  // rs2::sensor::operator= [?]
620  sensor_factory.record("operator bool", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
621  {
622  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
623  outv[0] = MatlabParamParser::wrap(bool(thiz));
624  });
625  sensor_factory.record("is", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
626  {
627  // TODO: something more maintainable?
628  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
629  auto type = MatlabParamParser::parse<std::string>(inv[1]);
630  if (type == "sensor")
631  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::sensor>());
632  else if (type == "roi_sensor")
633  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::roi_sensor>());
634  else if (type == "depth_sensor")
635  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::depth_sensor>());
636  else if (type == "depth_stereo_sensor")
638  else {
639  mexWarnMsgTxt("rs2::sensor::is: invalid type parameter");
640  outv[0] = MatlabParamParser::wrap(false);
641  }
642  });
643  sensor_factory.record("as", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
644  {
645  // TODO: something more maintainable?
646  auto thiz = MatlabParamParser::parse<rs2::sensor>(inv[0]);
647  auto type = MatlabParamParser::parse<std::string>(inv[1]);
648  if (type == "sensor")
649  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::sensor>());
650  else if (type == "roi_sensor")
651  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::roi_sensor>());
652  else if (type == "depth_sensor")
653  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::depth_sensor>());
654  else if (type == "depth_stereo_sensor")
656  else {
657  mexWarnMsgTxt("rs2::sensor::as: invalid type parameter");
658  outv[0] = MatlabParamParser::wrap(uint64_t(0));
659  }
660  });
661  sensor_factory.record("operator==", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
662  {
663  auto rhs = MatlabParamParser::parse<rs2::sensor>(inv[0]);
664  auto lhs = MatlabParamParser::parse<rs2::sensor>(inv[1]);
665  MatlabParamParser::wrap(rhs == lhs);
666  });
667  factory->record(sensor_factory);
668  }
669  {
670  ClassFactory roi_sensor_factory("rs2::roi_sensor");
671  // rs2::roi_sensor::constructor(rs2::sensor) [?]
672  roi_sensor_factory.record("set_region_of_interest", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
673  {
674  auto thiz = MatlabParamParser::parse<rs2::roi_sensor>(inv[0]);
675  auto roi = MatlabParamParser::parse<rs2::region_of_interest>(inv[1]);
676  thiz.set_region_of_interest(roi);
677  });
678  roi_sensor_factory.record("get_region_of_interest", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
679  {
680  auto thiz = MatlabParamParser::parse<rs2::roi_sensor>(inv[0]);
681  outv[0] = MatlabParamParser::wrap(thiz.get_region_of_interest());
682  });
683  // rs2::roi_sensor::operator bool [?]
684  factory->record(roi_sensor_factory);
685  }
686  {
687  ClassFactory depth_sensor_factory("rs2::depth_sensor");
688  // rs2::depth_sensor::constructor(rs2::sensor) [?]
689  depth_sensor_factory.record("get_depth_scale", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
690  {
691  auto thiz = MatlabParamParser::parse<rs2::depth_sensor>(inv[0]);
692  outv[0] = MatlabParamParser::wrap(thiz.get_depth_scale());
693  });
694  // rs2::depth_sensor::operator bool [?]
695  factory->record(depth_sensor_factory);
696  }
697  {
698  ClassFactory depth_stereo_sensor_factory("rs2::depth_stereo_sensor");
699  // rs2::depth_stereo_sensor::constructor(rs2::sensor) [?]
700  depth_stereo_sensor_factory.record("get_stereo_baseline", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
701  {
702  auto thiz = MatlabParamParser::parse<rs2::depth_stereo_sensor>(inv[0]);
703  outv[0] = MatlabParamParser::wrap(thiz.get_stereo_baseline());
704  });
705  factory->record(depth_stereo_sensor_factory);
706  }
707 
708  // rs_device.hpp
709  {
710  ClassFactory device_factory("rs2::device");
711  // rs2::device::constructor() [?]
712  // extra helper function for constructing device from device_list
713  device_factory.record("init", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
714  {
715  auto list = MatlabParamParser::parse<rs2::device_list>(inv[0]);
716  auto idx = MatlabParamParser::parse<uint32_t>(inv[1]);
717  outv[0] = MatlabParamParser::wrap(list[idx]);
718  MatlabParamParser::destroy<rs2::device_list>(inv[0]);
719  });
720  // destructor in case device was never initialized
721  device_factory.record("delete#uninit", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
722  {
723  MatlabParamParser::destroy<rs2::device_list>(inv[0]);
724  });
725  // destructor in case device was initialized
726  device_factory.record("delete#init", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
727  {
728  MatlabParamParser::destroy<rs2::device>(inv[0]);
729  });
730  device_factory.record("query_sensors", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
731  {
732  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
733  outv[0] = MatlabParamParser::wrap(thiz.query_sensors());
734  });
735  device_factory.record("first", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
736  {
737  // TODO: better, more maintainable implementation?
738  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
739  auto type = MatlabParamParser::parse<std::string>(inv[1]);
740  try {
741  if (type == "sensor")
742  outv[0] = MatlabParamParser::wrap(thiz.first<rs2::sensor>());
743  else if (type == "roi_sensor")
744  outv[0] = MatlabParamParser::wrap(thiz.first<rs2::roi_sensor>());
745  else if (type == "depth_sensor")
746  outv[0] = MatlabParamParser::wrap(thiz.first<rs2::depth_sensor>());
747  else if (type == "depth_stereo_sensor")
748  outv[0] = MatlabParamParser::wrap(thiz.first<rs2::depth_stereo_sensor>());
749  else mexErrMsgTxt("rs2::device::first: Could not find requested sensor type!");
750  }
751  catch (rs2::error) {
752  mexErrMsgTxt("rs2::device::first: Could not find requested sensor type!");
753  }
754  });
755  device_factory.record("supports", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
756  {
757  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
758  auto info = MatlabParamParser::parse<rs2_camera_info>(inv[1]);
759  outv[0] = MatlabParamParser::wrap(thiz.supports(info));
760  });
761  device_factory.record("get_info", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
762  {
763  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
764  auto info = MatlabParamParser::parse<rs2_camera_info>(inv[1]);
765  outv[0] = MatlabParamParser::wrap(thiz.get_info(info));
766  });
767  device_factory.record("hardware_reset", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
768  {
769  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
770  thiz.hardware_reset();
771  });
772  // rs2::device::operator= [?]
773  device_factory.record("operator bool", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
774  {
775  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
776  outv[0] = MatlabParamParser::wrap(bool(thiz));
777  });
778  device_factory.record("is", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
779  {
780  // TODO: something more maintainable?
781  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
782  auto type = MatlabParamParser::parse<std::string>(inv[1]);
783  if (type == "device")
784  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::device>());
785  else if (type == "debug_protocol") {
786  mexWarnMsgTxt("rs2::device::is: Debug Protocol not supported in MATLAB");
787  outv[0] = MatlabParamParser::wrap(false);
788  }
789  else if (type == "advanced_mode")
790  outv[0] = MatlabParamParser::wrap(thiz.is<rs400::advanced_mode>());
791  else if (type == "recorder")
792  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::recorder>());
793  else if (type == "playback")
794  outv[0] = MatlabParamParser::wrap(thiz.is<rs2::playback>());
795  else {
796  mexWarnMsgTxt("rs2::device::is: invalid type parameter");
797  outv[0] = MatlabParamParser::wrap(false);
798  }
799  });
800  device_factory.record("as", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
801  {
802  // TODO: something more maintainable?
803  auto thiz = MatlabParamParser::parse<rs2::device>(inv[0]);
804  auto type = MatlabParamParser::parse<std::string>(inv[1]);
805  if (type == "device")
806  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::device>());
807  else if (type == "debug_protocol") {
808  mexErrMsgTxt("rs2::device::as: Debug Protocol not supported in MATLAB");
809 // outv[0] = MatlabParamParser::wrap(thiz.as<rs2::debug_protocol>());
810  }
811  else if (type == "advanced_mode")
812  outv[0] = MatlabParamParser::wrap(thiz.as<rs400::advanced_mode>());
813  else if (type == "recorder")
814  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::recorder>());
815  else if (type == "playback")
816  outv[0] = MatlabParamParser::wrap(thiz.as<rs2::playback>());
817  else {
818  mexWarnMsgTxt("rs2::device::as: invalid type parameter");
819  outv[0] = MatlabParamParser::wrap(false);
820  }
821  });
822  factory->record(device_factory);
823  }
824  // rs2::debug_protocol [?]
825  // rs2::device_list [Pure Matlab]
826 
827  // rs2_record_playback.hpp
828  {
829  ClassFactory playback_factory("rs2::playback");
830  // rs2::playback::constructor(rs2::device) [?]
831  playback_factory.record("pause", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
832  {
833  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
834  thiz.pause();
835  });
836  playback_factory.record("resume", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
837  {
838  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
839  thiz.resume();
840  });
841  playback_factory.record("file_name", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
842  {
843  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
844  outv[0] = MatlabParamParser::wrap(thiz.file_name());
845  });
846  playback_factory.record("get_position", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
847  {
848  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
849  outv[0] = MatlabParamParser::wrap(thiz.get_position());
850  });
851  playback_factory.record("get_duration", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
852  {
853  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
854  outv[0] = MatlabParamParser::wrap(thiz.get_duration());
855  });
856  playback_factory.record("seek", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
857  {
858  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
859  auto time = MatlabParamParser::parse<std::chrono::nanoseconds>(inv[1]);
860  thiz.seek(time);
861  });
862  playback_factory.record("is_real_time", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
863  {
864  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
865  outv[0] = MatlabParamParser::wrap(thiz.is_real_time());
866  });
867  playback_factory.record("set_real_time", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
868  {
869  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
870  auto real_time = MatlabParamParser::parse<bool>(inv[1]);
871  thiz.set_real_time(real_time);
872  });
873  playback_factory.record("set_playback_speed", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
874  {
875  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
876  auto speed = MatlabParamParser::parse<float>(inv[1]);
877  thiz.set_playback_speed(speed);
878  });
879  // rs2::playback::set_status_changed_callback() [?/Callbacks]
880  playback_factory.record("current_status", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
881  {
882  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
883  outv[0] = MatlabParamParser::wrap(thiz.current_status());
884  });
885  playback_factory.record("stop", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
886  {
887  auto thiz = MatlabParamParser::parse<rs2::playback>(inv[0]);
888  thiz.stop();
889  });
890  factory->record(playback_factory);
891  }
892  {
893  ClassFactory recorder_factory("rs2::recorder");
894  // rs2::recorder::constructor(rs2::device) [?]
895  recorder_factory.record("new#string_device", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
896  {
897  auto file = MatlabParamParser::parse<std::string>(inv[0]);
898  auto device = MatlabParamParser::parse<rs2::device>(inv[1]);
899  outv[0] = MatlabParamParser::wrap(rs2::recorder(file, device));
900  });
901  recorder_factory.record("pause", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
902  {
903  auto thiz = MatlabParamParser::parse<rs2::recorder>(inv[0]);
904  thiz.pause();
905  });
906  recorder_factory.record("resume", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
907  {
908  auto thiz = MatlabParamParser::parse<rs2::recorder>(inv[0]);
909  thiz.resume();
910  });
911  recorder_factory.record("filename", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
912  {
913  auto thiz = MatlabParamParser::parse<rs2::recorder>(inv[0]);
914  outv[0] = MatlabParamParser::wrap(thiz.filename());
915  });
916  factory->record(recorder_factory);
917  }
918 
919  // rs2_processing.hpp
920  // rs2::processing_block [?]
921  {
922  ClassFactory frame_queue_factory("rs2::frame_queue");
923  frame_queue_factory.record("new", 1, 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
924  {
925  if (inc == 0) {
927  }
928  else if (inc == 1) {
929  auto capacity = MatlabParamParser::parse<unsigned int>(inv[0]);
930  outv[0] = MatlabParamParser::wrap(rs2::frame_queue(capacity));
931  }
932  else if (inc == 2) {
933  auto capacity = MatlabParamParser::parse<unsigned int>(inv[0]);
934  auto keep_frames = MatlabParamParser::parse<bool>(inv[1]);
935  outv[0] = MatlabParamParser::wrap(rs2::frame_queue(capacity, keep_frames));
936  }
937  });
938  frame_queue_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
939  {
940  MatlabParamParser::destroy<rs2::frame_queue>(inv[0]);
941  });
942  // rs2::frame_queue::enqueue(frame) [?]
943  frame_queue_factory.record("wait_for_frame", 1, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
944  {
945  auto thiz = MatlabParamParser::parse<rs2::frame_queue>(inv[0]);
946  if (inc == 1) {
947  outv[0] = MatlabParamParser::wrap(thiz.wait_for_frame());
948  }
949  else if (inc == 2) {
950  auto timeout_ms = MatlabParamParser::parse<unsigned int>(inv[1]);
951  outv[0] = MatlabParamParser::wrap(thiz.wait_for_frame(timeout_ms));
952  }
953  });
954  frame_queue_factory.record("poll_for_frame", 2, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
955  {
956  auto thiz = MatlabParamParser::parse<rs2::frame_queue>(inv[0]);
957  auto type = MatlabParamParser::parse<std::string>(inv[1]);
958  if (type == "frame") {
959  auto f = rs2::frame();
960  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
961  outv[1] = MatlabParamParser::wrap(std::move(f));
962  } else if (type == "video_frame") {
963  auto f = rs2::video_frame(rs2::frame());
964  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
965  outv[1] = MatlabParamParser::wrap(std::move(f));
966  } else if (type == "points"){
967  auto f = rs2::points();
968  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
969  outv[1] = MatlabParamParser::wrap(std::move(f));
970  } else if (type == "depth_frame"){
971  auto f = rs2::depth_frame(rs2::frame());
972  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
973  outv[1] = MatlabParamParser::wrap(std::move(f));
974  } else if (type == "disparity_frame"){
976  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
977  outv[1] = MatlabParamParser::wrap(std::move(f));
978  } else if (type == "motion_frame"){
979  auto f = rs2::motion_frame(rs2::frame());
980  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
981  outv[1] = MatlabParamParser::wrap(std::move(f));
982  } else if (type == "pose_frame"){
983  auto f = rs2::pose_frame(rs2::frame());
984  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
985  outv[1] = MatlabParamParser::wrap(std::move(f));
986  } else if (type == "frameset"){
987  auto f = rs2::frameset();
988  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frame(&f));
989  outv[1] = MatlabParamParser::wrap(std::move(f));
990  } else {
991  mexWarnMsgTxt("rs2::frame_queue::poll_for_frame: invalid type parameter");
992  outv[0] = MatlabParamParser::wrap(false);
993  outv[1] = MatlabParamParser::wrap(rs2::frame());
994  }
995  });
996  frame_queue_factory.record("capacity", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
997  {
998  auto thiz = MatlabParamParser::parse<rs2::frame_queue>(inv[0]);
999  outv[0] = MatlabParamParser::wrap(thiz.capacity());
1000  });
1001  frame_queue_factory.record("keep_frames", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1002  {
1003  auto thiz = MatlabParamParser::parse<rs2::frame_queue>(inv[0]);
1004  outv[0] = MatlabParamParser::wrap(thiz.keep_frames());
1005  });
1006  factory->record(frame_queue_factory);
1007  }
1008 // TODO: need to understand how to call matlab functions from within C++ before async things can be implemented.
1009 // TODO: What to do about supports/get_info? Just attach to filter?
1010 // processing_block API is completely async.
1011 // {
1012 // ClassFactory processing_block_factory("rs2::processing_block");
1013 //
1014 // factory->record(processing_block_factory);
1015 // }
1016  {
1017  ClassFactory filter_factory("rs2::filter");
1018  filter_factory.record("process", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1019  {
1020  auto thiz = MatlabParamParser::parse<rs2::filter>(inv[0]);
1021  auto frame = MatlabParamParser::parse<rs2::frame>(inv[1]);
1022  outv[0] = MatlabParamParser::wrap(thiz.process(frame));
1023  });
1024  factory->record(filter_factory);
1025  }
1026  {
1027  ClassFactory pointcloud_factory("rs2::pointcloud");
1028  pointcloud_factory.record("new", 1, 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1029  {
1030  if (inc == 0) {
1032  return;
1033  }
1034  auto stream = MatlabParamParser::parse<rs2_stream>(inv[0]);
1035  if (inc == 1)
1037  else {
1038  auto index = MatlabParamParser::parse<int>(inv[1]);
1040  }
1041  });
1042  pointcloud_factory.record("calculate", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1043  {
1044  auto thiz = MatlabParamParser::parse<rs2::pointcloud>(inv[0]);
1045  auto depth = MatlabParamParser::parse<rs2::frame>(inv[1]);
1046  outv[0] = MatlabParamParser::wrap(thiz.calculate(depth));
1047  });
1048  pointcloud_factory.record("map_to", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1049  {
1050  auto thiz = MatlabParamParser::parse<rs2::pointcloud>(inv[0]);
1051  auto mapped = MatlabParamParser::parse<rs2::frame>(inv[1]);
1052  thiz.map_to(mapped);
1053  });
1054  factory->record(pointcloud_factory);
1055  }
1056  {
1057  ClassFactory syncer_factory("rs2::syncer");
1058  syncer_factory.record("new", 1, 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1059  {
1060  if (inc == 0) {
1061  outv[0] = MatlabParamParser::wrap(rs2::syncer());
1062  }
1063  else if (inc == 1) {
1064  auto queue_size = MatlabParamParser::parse<int>(inv[0]);
1065  outv[0] = MatlabParamParser::wrap(rs2::syncer(queue_size));
1066  }
1067  });
1068  syncer_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1069  {
1070  MatlabParamParser::destroy<rs2::syncer>(inv[0]);
1071  });
1072  syncer_factory.record("wait_for_frames", 1, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1073  {
1074  auto thiz = MatlabParamParser::parse<rs2::syncer>(inv[0]);
1075  if (inc == 1) {
1076  outv[0] = MatlabParamParser::wrap(thiz.wait_for_frames());
1077  }
1078  else if (inc == 2) {
1079  auto timeout_ms = MatlabParamParser::parse<unsigned int>(inv[1]);
1080  outv[0] = MatlabParamParser::wrap(thiz.wait_for_frames(timeout_ms));
1081  }
1082  });
1083  syncer_factory.record("poll_for_frames", 2, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1084  {
1085  auto thiz = MatlabParamParser::parse<rs2::syncer>(inv[0]);
1086  rs2::frameset fs;
1087  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frames(&fs));
1088  outv[1] = MatlabParamParser::wrap(std::move(fs));
1089  });
1090  factory->record(syncer_factory);
1091  }
1092  {
1093  ClassFactory align_factory("rs2::align");
1094  align_factory.record("new", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1095  {
1096  auto align_to = MatlabParamParser::parse<rs2_stream>(inv[0]);
1098  });
1099  // TODO: how does this interact with the processing_block variant? Why are the separate?
1100  align_factory.record("process", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1101  {
1102  auto thiz = MatlabParamParser::parse<rs2::align>(inv[0]);
1103  auto frame = MatlabParamParser::parse<rs2::frameset>(inv[1]);
1104  outv[0] = MatlabParamParser::wrap(thiz.process(frame));
1105  });
1106  factory->record(align_factory);
1107  }
1108  {
1109  ClassFactory colorizer_factory("rs2::colorizer");
1110  colorizer_factory.record("new", 1, 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1111  {
1112  if (inc == 0) outv[0] = MatlabParamParser::wrap(rs2::colorizer());
1113  else {
1114  auto color_scheme = MatlabParamParser::parse<float>(inv[0]);
1115  outv[0] = MatlabParamParser::wrap(rs2::colorizer(color_scheme));
1116  }
1117  });
1118  colorizer_factory.record("colorize", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1119  {
1120  auto thiz = MatlabParamParser::parse<rs2::colorizer>(inv[0]);
1121  auto depth = MatlabParamParser::parse<rs2::frame>(inv[1]);
1122  outv[0] = MatlabParamParser::wrap(thiz.colorize(depth));
1123  });
1124  factory->record(colorizer_factory);
1125  }
1126  {
1127  ClassFactory decimation_filter_factory("rs2::decimation_filter");
1128  decimation_filter_factory.record("new", 1, 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1129  {
1130  if (inc == 0) outv[0] = MatlabParamParser::wrap(rs2::decimation_filter());
1131  else {
1132  auto magnitude = MatlabParamParser::parse<float>(inv[0]);
1133  outv[0] = MatlabParamParser::wrap(rs2::decimation_filter(magnitude));
1134  }
1135  });
1136  factory->record(decimation_filter_factory);
1137  }
1138  {
1139  ClassFactory temporal_filter_factory("rs2::temporal_filter");
1140  temporal_filter_factory.record("new", 1, 0, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1141  {
1142  if (inc == 0) outv[0] = MatlabParamParser::wrap(rs2::temporal_filter());
1143  else if (inc == 3) {
1144  auto smooth_alpha = MatlabParamParser::parse<float>(inv[0]);
1145  auto smooth_delta = MatlabParamParser::parse<float>(inv[1]);
1146  auto persistence_control = MatlabParamParser::parse<int>(inv[2]);
1147  outv[0] = MatlabParamParser::wrap(rs2::temporal_filter(smooth_alpha, smooth_delta, persistence_control));
1148  }
1149  else mexErrMsgTxt("rs2::temporal_filter::new: Wrong number of Inputs");
1150  });
1151  factory->record(temporal_filter_factory);
1152  }
1153  {
1154  ClassFactory spatial_filter_factory("rs2::spatial_filter");
1155  spatial_filter_factory.record("new", 1, 0, 4, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1156  {
1157  if (inc == 0) outv[0] = MatlabParamParser::wrap(rs2::spatial_filter());
1158  else if (inc == 4) {
1159  auto smooth_alpha = MatlabParamParser::parse<float>(inv[0]);
1160  auto smooth_delta = MatlabParamParser::parse<float>(inv[1]);
1161  auto magnitude = MatlabParamParser::parse<float>(inv[2]);
1162  auto hole_fill = MatlabParamParser::parse<float>(inv[3]);
1163  outv[0] = MatlabParamParser::wrap(rs2::spatial_filter(smooth_alpha, smooth_delta, magnitude, hole_fill));
1164  }
1165  else mexErrMsgTxt("rs2::spatial_filter::new: Wrong number of Inputs");
1166  });
1167  factory->record(spatial_filter_factory);
1168  }
1169  {
1170  ClassFactory disparity_transform_factory("rs2::disparity_transform");
1171  disparity_transform_factory.record("new", 1, 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1172  {
1173  if (inc == 0) {
1175  }
1176  else if (inc == 1) {
1177  auto transform_to_disparity = MatlabParamParser::parse<bool>(inv[0]);
1178  outv[0] = MatlabParamParser::wrap(rs2::disparity_transform(transform_to_disparity));
1179  }
1180  });
1181  factory->record(disparity_transform_factory);
1182  }
1183  {
1184  ClassFactory hole_filling_filter_factory("rs2::hole_filling_filter");
1185  hole_filling_filter_factory.record("new", 1, 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1186  {
1187  if (inc == 0) outv[0] = MatlabParamParser::wrap(rs2::hole_filling_filter());
1188  else {
1189  auto mode = MatlabParamParser::parse<int>(inv[0]);
1191  }
1192  });
1193  factory->record(hole_filling_filter_factory);
1194  }
1195 
1196  // rs_export.hpp
1197  {
1198  ClassFactory save_to_ply_factory("rs2::save_to_ply");
1199  save_to_ply_factory.record("new", 1, 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1200  {
1201  if (inc == 0) {
1203  }
1204  else if (inc == 1) {
1205  auto filename = MatlabParamParser::parse<std::string>(inv[0]);
1207  }
1208  else if (inc == 2) {
1209  auto filename = MatlabParamParser::parse<std::string>(inv[0]);
1210  auto pc = MatlabParamParser::parse<rs2::pointcloud>(inv[1]);
1212  }
1213  });
1214  save_to_ply_factory.record("process", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1215  {
1216  auto thiz = MatlabParamParser::parse<rs2::save_to_ply>(inv[0]);
1217  auto frame = MatlabParamParser::parse<rs2::frameset>(inv[1]);
1218  outv[0] = MatlabParamParser::wrap(thiz.process(frame));
1219  });
1220  factory->record(save_to_ply_factory);
1221  }
1222  {
1223  ClassFactory save_single_frameset_factory("rs2::save_single_frameset");
1224  save_single_frameset_factory.record("new", 1, 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1225  {
1226  if (inc == 0) {
1228  }
1229  else if (inc == 1) {
1230  auto filename = MatlabParamParser::parse<std::string>(inv[0]);
1232  }
1233  });
1234  factory->record(save_single_frameset_factory);
1235  }
1236 
1237  // rs_context.hpp
1238  // rs2::event_information [?]
1239  {
1240  ClassFactory context_factory("rs2::context");
1241  // This lambda feels like it should be possible to generate automatically with templates
1242  context_factory.record("new", 1, 0, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1243  {
1245  });
1246  context_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1247  {
1248  MatlabParamParser::destroy<rs2::context>(inv[0]);
1249  });
1250  context_factory.record("query_devices", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1251  {
1252  auto thiz = MatlabParamParser::parse<rs2::context>(inv[0]);
1253  outv[0] = MatlabParamParser::wrap(thiz.query_devices());
1254  });
1255  context_factory.record("query_all_sensors", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1256  {
1257  auto thiz = MatlabParamParser::parse<rs2::context>(inv[0]);
1258  outv[0] = MatlabParamParser::wrap(thiz.query_all_sensors());
1259  });
1260  context_factory.record("get_sensor_parent", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1261  {
1262  auto thiz = MatlabParamParser::parse<rs2::context>(inv[0]);
1263  auto sensor = MatlabParamParser::parse<rs2::sensor>(inv[1]);
1264  outv[0] = MatlabParamParser::wrap(thiz.get_sensor_parent(sensor));
1265  });
1266  context_factory.record("load_device", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1267  {
1268  auto thiz = MatlabParamParser::parse<rs2::context>(inv[0]);
1269  auto file = MatlabParamParser::parse<std::string>(inv[1]);
1270  outv[0] = MatlabParamParser::wrap(thiz.load_device(file));
1271  });
1272  context_factory.record("unload_device", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1273  {
1274  auto thiz = MatlabParamParser::parse<rs2::context>(inv[0]);
1275  auto file = MatlabParamParser::parse<std::string>(inv[1]);
1276  thiz.unload_device(file);
1277  });
1278  context_factory.record("unload_tracking_module", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1279  {
1280  auto thiz = MatlabParamParser::parse<rs2::context>(inv[0]);
1281  thiz.unload_tracking_module();
1282  });
1283  factory->record(context_factory);
1284  }
1285  {
1286  ClassFactory device_hub_factory("rs2::device_hub");
1287  device_hub_factory.record("new", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1288  {
1289  auto ctx = MatlabParamParser::parse<rs2::context>(inv[0]);
1291  });
1292  device_hub_factory.record("delete", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1293  {
1294  MatlabParamParser::destroy<rs2::device_hub>(inv[0]);
1295  });
1296  device_hub_factory.record("wait_for_device", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1297  {
1298  auto thiz = MatlabParamParser::parse<rs2::device_hub>(inv[0]);
1299  outv[0] = MatlabParamParser::wrap(thiz.wait_for_device());
1300  });
1301  device_hub_factory.record("is_connected", 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1302  {
1303  auto thiz = MatlabParamParser::parse<rs2::device_hub>(inv[0]);
1304  auto dev = MatlabParamParser::parse<rs2::device>(inv[1]);
1305  outv[0] = MatlabParamParser::wrap(thiz.is_connected(dev));
1306  });
1307  factory->record(device_hub_factory);
1308  }
1309 
1310  // rs_pipeline.hpp
1311  {
1312  ClassFactory pipeline_profile_factory("rs2::pipeline_profile");
1313  // rs2::pipeline_profile::constructor() [?]
1314  pipeline_profile_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1315  {
1316  MatlabParamParser::destroy<rs2::pipeline_profile>(inv[0]);
1317  });
1318  pipeline_profile_factory.record("get_streams", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1319  {
1320  auto thiz = MatlabParamParser::parse<rs2::pipeline_profile>(inv[0]);
1321  outv[0] = MatlabParamParser::wrap(thiz.get_streams());
1322  });
1323  pipeline_profile_factory.record("get_stream", 1, 2, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1324  {
1325  auto thiz = MatlabParamParser::parse<rs2::pipeline_profile>(inv[0]);
1326  auto stream_type = MatlabParamParser::parse<rs2_stream>(inv[1]);
1327  if (inc == 2)
1328  outv[0] = MatlabParamParser::wrap(thiz.get_stream(stream_type));
1329  else {
1330  auto stream_index = MatlabParamParser::parse<int>(inv[2]);
1331  outv[0] = MatlabParamParser::wrap(thiz.get_stream(stream_type, stream_index));
1332  }
1333  });
1334  pipeline_profile_factory.record("get_device", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1335  {
1336  auto thiz = MatlabParamParser::parse<rs2::pipeline_profile>(inv[0]);
1337  outv[0] = MatlabParamParser::wrap(thiz.get_device());
1338  });
1339  // rs2::pipeline_profile::bool() [?]
1340  factory->record(pipeline_profile_factory);
1341  }
1342  {
1343  ClassFactory config_factory("rs2::config");
1344  config_factory.record("new", 1, 0, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1345  {
1346  outv[0] = MatlabParamParser::wrap(rs2::config());
1347  });
1348  config_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1349  {
1350  MatlabParamParser::destroy<rs2::config>(inv[0]);
1351  });
1352  config_factory.record("enable_stream#full", 0, 5, 7, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1353  {
1354  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1355  auto stream_type = MatlabParamParser::parse<rs2_stream>(inv[1]);
1356  auto stream_index = MatlabParamParser::parse<int>(inv[2]);
1357  auto width = MatlabParamParser::parse<int>(inv[3]);
1358  auto height = MatlabParamParser::parse<int>(inv[4]);
1359  if (inc == 5) {
1360  thiz.enable_stream(stream_type, stream_index, width, height);
1361  } else if (inc == 6) {
1362  auto format = MatlabParamParser::parse<rs2_format>(inv[5]);
1363  thiz.enable_stream(stream_type, stream_index, width, height, format);
1364  } else if (inc == 7) {
1365  auto format = MatlabParamParser::parse<rs2_format>(inv[5]);
1366  auto framerate = MatlabParamParser::parse<int>(inv[6]);
1367  thiz.enable_stream(stream_type, stream_index, width, height, format, framerate);
1368  }
1369  });
1370  config_factory.record("enable_stream#stream", 0, 2, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1371  {
1372  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1373  auto stream_type = MatlabParamParser::parse<rs2_stream>(inv[1]);
1374  if (inc == 2) {
1375  thiz.enable_stream(stream_type);
1376  } else if (inc == 3){
1377  auto stream_index = MatlabParamParser::parse<int>(inv[2]);
1378  thiz.enable_stream(stream_type, stream_index);
1379  }
1380  });
1381  config_factory.record("enable_stream#size", 0, 4, 6, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1382  {
1383  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1384  auto stream_type = MatlabParamParser::parse<rs2_stream>(inv[1]);
1385  auto width = MatlabParamParser::parse<int>(inv[2]);
1386  auto height = MatlabParamParser::parse<int>(inv[3]);
1387  if (inc == 4) {
1388  thiz.enable_stream(stream_type, width, height);
1389  } else if (inc == 5) {
1390  auto format = MatlabParamParser::parse<rs2_format>(inv[4]);
1391  thiz.enable_stream(stream_type, width, height, format);
1392  } else if (inc == 6) {
1393  auto format = MatlabParamParser::parse<rs2_format>(inv[4]);
1394  auto framerate = MatlabParamParser::parse<int>(inv[5]);
1395  thiz.enable_stream(stream_type, width, height, format, framerate);
1396  }
1397  });
1398  config_factory.record("enable_stream#format", 0, 3, 4, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1399  {
1400  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1401  auto stream_type = MatlabParamParser::parse<rs2_stream>(inv[1]);
1402  auto format = MatlabParamParser::parse<rs2_format>(inv[2]);
1403  if (inc == 3) {
1404  thiz.enable_stream(stream_type, format);
1405  } else if (inc == 4) {
1406  auto framerate = MatlabParamParser::parse<int>(inv[3]);
1407  thiz.enable_stream(stream_type, format, framerate);
1408  }
1409  });
1410  config_factory.record("enable_stream#extended", 0, 4, 5, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1411  {
1412  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1413  auto stream_type = MatlabParamParser::parse<rs2_stream>(inv[1]);
1414  auto stream_index = MatlabParamParser::parse<int>(inv[2]);
1415  auto format = MatlabParamParser::parse<rs2_format>(inv[3]);
1416  if (inc == 4) {
1417  thiz.enable_stream(stream_type, stream_index, format);
1418  } else if (inc == 5) {
1419  auto framerate = MatlabParamParser::parse<int>(inv[4]);
1420  thiz.enable_stream(stream_type, stream_index, format, framerate);
1421  }
1422  });
1423  config_factory.record("enable_all_streams", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1424  {
1425  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1426  thiz.enable_all_streams();
1427  });
1428  config_factory.record("enable_device", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1429  {
1430  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1431  auto serial = MatlabParamParser::parse<std::string>(inv[1]);
1432  thiz.enable_device(serial);
1433  });
1434  config_factory.record("enable_device_from_file", 0, 2, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1435  {
1436  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1437  auto file_name = MatlabParamParser::parse<std::string>(inv[1]);
1438  if (inc == 2)
1439  thiz.enable_device_from_file(file_name);
1440  else if (inc == 3) {
1441  auto repeat_playback = MatlabParamParser::parse<bool>(inv[2]);
1442  thiz.enable_device_from_file(file_name, repeat_playback);
1443  }
1444  });
1445  config_factory.record("enable_record_to_file", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1446  {
1447  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1448  auto file_name = MatlabParamParser::parse<std::string>(inv[1]);
1449  thiz.enable_record_to_file(file_name);
1450  });
1451  config_factory.record("disable_stream", 0, 2, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1452  {
1453  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1454  auto stream = MatlabParamParser::parse<rs2_stream>(inv[1]);
1455  if (inc == 2)
1456  thiz.disable_stream(stream);
1457  else if (inc == 3) {
1458  auto index = MatlabParamParser::parse<int>(inv[2]);
1459  thiz.disable_stream(stream, index);
1460  }
1461  });
1462  config_factory.record("disable_all_streams", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1463  {
1464  auto thiz = MatlabParamParser::parse<rs2::config>(inv[0]);
1465  thiz.disable_all_streams();
1466  });
1467  factory->record(config_factory);
1468  }
1469  {
1470  ClassFactory pipeline_factory("rs2::pipeline");
1471  pipeline_factory.record("new", 1, 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1472  {
1473  if (inc == 0) {
1475  } else if (inc == 1) {
1476  auto ctx = MatlabParamParser::parse<rs2::context>(inv[0]);
1478  }
1479  });
1480  pipeline_factory.record("delete", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1481  {
1482  MatlabParamParser::destroy<rs2::pipeline>(inv[0]);
1483  });
1484  pipeline_factory.record("start", 1, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1485  {
1486  auto thiz = MatlabParamParser::parse<rs2::pipeline>(inv[0]);
1487  if (inc == 1)
1488  outv[0] = MatlabParamParser::wrap(thiz.start());
1489  else if (inc == 2) {
1490  auto config = MatlabParamParser::parse<rs2::config>(inv[1]);
1491  outv[0] = MatlabParamParser::wrap(thiz.start(config));
1492  }
1493  });
1494  pipeline_factory.record("start#fq", 1, 2, 3, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1495  {
1496  auto thiz = MatlabParamParser::parse<rs2::pipeline>(inv[0]);
1497  if (inc == 2) {
1498  auto fq = MatlabParamParser::parse<rs2::frame_queue>(inv[1]);
1499  outv[0] = MatlabParamParser::wrap(thiz.start(fq));
1500  } else if (inc == 3) {
1501  auto config = MatlabParamParser::parse<rs2::config>(inv[1]);
1502  auto fq = MatlabParamParser::parse<rs2::frame_queue>(inv[2]);
1503  outv[0] = MatlabParamParser::wrap(thiz.start(config, fq));
1504  }
1505  });
1506  pipeline_factory.record("stop", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1507  {
1508  auto thiz = MatlabParamParser::parse<rs2::pipeline>(inv[0]);
1509  thiz.stop();
1510  });
1511  pipeline_factory.record("wait_for_frames", 1, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1512  {
1513  auto thiz = MatlabParamParser::parse<rs2::pipeline>(inv[0]);
1514  if (inc == 1) {
1515  outv[0] = MatlabParamParser::wrap(thiz.wait_for_frames());
1516  } else if (inc == 2) {
1517  auto timeout_ms = MatlabParamParser::parse<unsigned int>(inv[1]);
1518  outv[0] = MatlabParamParser::wrap(thiz.wait_for_frames(timeout_ms));
1519  }
1520  });
1521  pipeline_factory.record("poll_for_frames", 2, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1522  {
1523  auto thiz = MatlabParamParser::parse<rs2::pipeline>(inv[0]);
1524  rs2::frameset fs;
1525  outv[0] = MatlabParamParser::wrap(thiz.poll_for_frames(&fs));
1526  outv[1] = MatlabParamParser::wrap(std::move(fs));
1527  });
1528  pipeline_factory.record("get_active_profile", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[])
1529  {
1530  auto thiz = MatlabParamParser::parse<rs2::pipeline>(inv[0]);
1531  outv[0] = MatlabParamParser::wrap(thiz.get_active_profile());
1532  });
1533  factory->record(pipeline_factory);
1534  }
1535 
1536  // rs.hpp
1537  {
1538  ClassFactory free_funcs_factory("rs2");
1539  free_funcs_factory.record("log_to_console", 0, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) {
1540  auto min_severity = MatlabParamParser::parse<rs2_log_severity>(inv[0]);
1541  rs2::log_to_console(min_severity);
1542  });
1543  free_funcs_factory.record("log_to_file", 0, 1, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) {
1544  auto min_severity = MatlabParamParser::parse<rs2_log_severity>(inv[0]);
1545  if (inc == 1)
1546  rs2::log_to_file(min_severity);
1547  else if (inc == 2) {
1548  auto file_path = MatlabParamParser::parse<const char *>(inv[1]);
1549  rs2::log_to_file(min_severity, file_path);
1550  }
1551  });
1552  free_funcs_factory.record("log", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) {
1553  auto severity = MatlabParamParser::parse<rs2_log_severity>(inv[0]);
1554  auto message = MatlabParamParser::parse<const char *>(inv[1]);
1555  rs2::log(severity, message);
1556  });
1557  factory->record(free_funcs_factory);
1558  }
1559 
1560  // rs_advanced_mode.hpp
1561  {
1562  ClassFactory advanced_mode_factory("rs400::advanced_mode");
1563  advanced_mode_factory.record("is_enabled", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) {
1564  auto thiz = MatlabParamParser::parse<rs400::advanced_mode>(inv[0]);
1565  outv[0] = MatlabParamParser::wrap(thiz.is_enabled());
1566  });
1567  advanced_mode_factory.record("toggle_advanced_mode", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) {
1568  auto thiz = MatlabParamParser::parse<rs400::advanced_mode>(inv[0]);
1569  auto enable = MatlabParamParser::parse<bool>(inv[1]);
1570  thiz.toggle_advanced_mode(enable);
1571  });
1572  advanced_mode_factory.record("serialize_json", 1, 1, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) {
1573  auto thiz = MatlabParamParser::parse<rs400::advanced_mode>(inv[0]);
1574  outv[0] = MatlabParamParser::wrap(thiz.serialize_json());
1575  });
1576  advanced_mode_factory.record("load_json", 0, 2, [](int outc, mxArray* outv[], int inc, const mxArray* inv[]) {
1577  auto thiz = MatlabParamParser::parse<rs400::advanced_mode>(inv[0]);
1578  auto json_content = MatlabParamParser::parse<std::string>(inv[1]);
1579  thiz.load_json(json_content);
1580  });
1581  factory->record(advanced_mode_factory);
1582  }
1583 
1584  mexAtExit([]() { delete factory; });
1585 }
1586 
1587 void mexFunction(int nOutParams, mxArray *outParams[], int nInParams, const mxArray *inParams[])
1588 {
1589  // does this need to be made threadsafe? also maybe better idea than global object?
1590  if (!factory) make_factory();
1591 
1592  if (nInParams < 2) {
1593  mexErrMsgTxt("At least class and command name are needed.");
1594  return;
1595  }
1596 
1597  auto cname = MatlabParamParser::parse<std::string>(inParams[0]);
1598  auto fname = MatlabParamParser::parse<std::string>(inParams[1]);
1599 
1600  auto f_data = factory->get(cname, fname);
1601  if (!f_data.f) {
1602  mexErrMsgTxt("Unknown Command received.");
1603  return;
1604  }
1605 
1606  if (f_data.out != nOutParams) {
1607  std::string errmsg = cname + "::" + fname.substr(0, fname.find("#", 0)) + ": Wrong number of outputs";
1608  mexErrMsgTxt(errmsg.c_str());
1609  }
1610 
1611  if (f_data.in_min > nInParams - 2 || f_data.in_max < nInParams - 2) {
1612  std::string errmsg = cname + "::" + fname.substr(0, fname.find("#", 0)) + ": Wrong number of inputs";
1613  mexErrMsgTxt(errmsg.c_str());
1614  }
1615 
1616  try {
1617  f_data.f(nOutParams, outParams, nInParams - 2, inParams + 2); // "eat" the two function specifiers
1618  } catch (std::exception &e) {
1619  mexErrMsgTxt(e.what());
1620  } catch (...) {
1621  mexErrMsgTxt("An unknown error occured");
1622  }
1623 }
GLenum GLuint GLenum GLsizei const GLchar * message
void mexFunction(int nOutParams, mxArray *outParams[], int nInParams, const mxArray *inParams[])
GLint y
GLenum GLuint GLenum severity
func_data get(std::string c, std::string f)
Definition: Factory.h:53
pose inv(pose const &p)
Definition: test-pose.cpp:178
GLdouble s
Factory * factory
void log(rs2_log_severity severity, const char *message)
Definition: rs.hpp:149
GLint GLint GLsizei GLsizei GLsizei depth
GLsizei const GLchar *const * string
GLuint GLuint stream
Definition: glext.h:1790
e
Definition: rmse.py:177
static mxArray * wrap(T &&var)
The texture class.
Definition: example.hpp:402
GLuint index
GLuint GLfloat * val
def info(name, value, persistent=False)
Definition: test.py:301
void record(ClassFactory cls)
Definition: Factory.h:51
GLdouble f
GLenum mode
Definition: getopt.h:41
GLdouble x
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum format
unsigned __int64 uint64_t
Definition: stdint.h:90
void log_to_file(rs2_log_severity min_severity, const char *file_path=nullptr)
Definition: rs.hpp:26
void record(std::string fname, int out, int in, std::function< mxFunc > func)
Definition: Factory.h:27
void log_to_console(rs2_log_severity min_severity)
Definition: rs.hpp:19
fname
Definition: rmse.py:13
GLboolean enable
Definition: glext.h:5688
GLenum type
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
void make_factory()
YYCODETYPE lhs
Definition: sqlite3.c:132469
auto device
Definition: pyrs_net.cpp:17
GLint GLsizei width
GLdouble GLdouble GLint GLint const GLdouble * points
static std::enable_if<!is_basic_type< T >::value &&!traits_trampoline::use_cells< T >::value, mxArray * >::type wrap_array(const T *var, size_t length)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:21