1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #ifndef LIBREALSENSE_RS_HPP
5 #define LIBREALSENSE_RS_HPP
6 
7 #include "rsutil.h"
8 #include <cmath>
9 #include <cstdint>
10 #include <cstring>
11 #include <sstream>
12 #include <stdexcept>
13 
14 namespace rs
15 {
16     enum class stream : int32_t
17     {
18         depth                            = 0, ///< Native stream of depth data produced by RealSense device
19         color                            = 1, ///< Native stream of color data captured by RealSense device
20         infrared                         = 2, ///< Native stream of infrared data captured by RealSense device
21         infrared2                        = 3, ///< Native stream of infrared data captured from a second viewpoint by RealSense device
22         points                           = 4, ///< Synthetic stream containing point cloud data generated by deprojecting the depth image
23         rectified_color                  = 5, ///< Synthetic stream containing undistorted color data with no extrinsic rotation from the depth stream
24         color_aligned_to_depth           = 6, ///< Synthetic stream containing color data but sharing intrinsics of depth stream
25         infrared2_aligned_to_depth       = 7, ///< Synthetic stream containing second viewpoint infrared data but sharing intrinsics of depth stream
26         depth_aligned_to_color           = 8, ///< Synthetic stream containing depth data but sharing intrinsics of color stream
27         depth_aligned_to_rectified_color = 9, ///< Synthetic stream containing depth data but sharing intrinsics of rectified color stream
28         depth_aligned_to_infrared2       = 10 ///< Synthetic stream containing depth data but sharing intrinsics of second viewpoint infrared stream
29     };
30 
31     enum class format : int32_t
32     {
33         any         = 0,
34         z16         = 1,  ///< 16 bit linear depth values. The depth is meters is equal to depth scale * pixel value
35         disparity16 = 2,  ///< 16 bit linear disparity values. The depth in meters is equal to depth scale / pixel value
36         xyz32f      = 3,  ///< 32 bit floating point 3D coordinates.
37         yuyv        = 4,
38         rgb8        = 5,
39         bgr8        = 6,
40         rgba8       = 7,
41         bgra8       = 8,
42         y8          = 9,
43         y16         = 10,
44         raw10       = 11  ///< Four 10-bit luminance values encoded into a 5-byte macropixel
45     };
46 
47     enum class preset : int32_t
48     {
49         best_quality      = 0,
50         largest_image     = 1,
51         highest_framerate = 2
52     };
53 
54     enum class distortion : int32_t
55     {
56         none                   = 0, ///< Rectilinear images, no distortion compensation required
57         modified_brown_conrady = 1, ///< Equivalent to Brown-Conrady distortion, except that tangential distortion is applied to radially distorted points
58         inverse_brown_conrady  = 2  ///< Equivalent to Brown-Conrady distortion, except undistorts image instead of distorting it
59     };
60 
61     enum class option : int32_t
62     {
63         color_backlight_compensation                    = 0,
64         color_brightness                                = 1,
65         color_contrast                                  = 2,
66         color_exposure                                  = 3,  ///< Controls exposure time of color camera. Setting any value will disable auto exposure.
67         color_gain                                      = 4,
68         color_gamma                                     = 5,
69         color_hue                                       = 6,
70         color_saturation                                = 7,
71         color_sharpness                                 = 8,
72         color_white_balance                             = 9,  ///< Controls white balance of color image. Setting any value will disable auto white balance.
73         color_enable_auto_exposure                      = 10, ///< Set to 1 to enable automatic exposure control, or 0 to return to manual control
74         color_enable_auto_white_balance                 = 11, ///< Set to 1 to enable automatic white balance control, or 0 to return to manual control
75         f200_laser_power                                = 12, ///< 0 - 15
76         f200_accuracy                                   = 13, ///< 0 - 3
77         f200_motion_range                               = 14, ///< 0 - 100
78         f200_filter_option                              = 15, ///< 0 - 7
79         f200_confidence_threshold                       = 16, ///< 0 - 15
80         sr300_dynamic_fps                               = 17, ///< {2, 5, 15, 30, 60}
81         sr300_auto_range_enable_motion_versus_range     = 18,
82         sr300_auto_range_enable_laser                   = 19,
83         sr300_auto_range_min_motion_versus_range        = 20,
84         sr300_auto_range_max_motion_versus_range        = 21,
85         sr300_auto_range_start_motion_versus_range      = 22,
86         sr300_auto_range_min_laser                      = 23,
87         sr300_auto_range_max_laser                      = 24,
88         sr300_auto_range_start_laser                    = 25,
89         sr300_auto_range_upper_threshold                = 26,
90         sr300_auto_range_lower_threshold                = 27,
91         sr300_wakeup_dev_phase1_period                  = 28,
92         sr300_wakeup_dev_phase1_fps                     = 29,
93         sr300_wakeup_dev_phase2_period                  = 30,
94         sr300_wakeup_dev_phase2_fps                     = 31,
95         sr300_wakeup_dev_reset                          = 32,
96         sr300_wake_on_usb_reason                        = 33 ,
97         sr300_wake_on_usb_confidence                    = 34,
98         r200_lr_auto_exposure_enabled                   = 35, ///< {0, 1}
99         r200_lr_gain                                    = 36, ///< 100 - 1600 (Units of 0.01)
100         r200_lr_exposure                                = 37, ///< > 0 (Units of 0.1 ms)
101         r200_emitter_enabled                            = 38, ///< {0, 1}
102         r200_depth_units                                = 39, ///< micrometers per increment in integer depth values, 1000 is default (mm scale)
103         r200_depth_clamp_min                            = 40, ///< {0 - USHORT_MAX}. Can only be set before streaming starts.
104         r200_depth_clamp_max                            = 41, ///< {0 - USHORT_MAX}. Can only be set before streaming starts.
105         r200_disparity_multiplier                       = 42, ///< {0 - 1000}. The increments in integer disparity values corresponding to one pixel of disparity. Can only be set before streaming starts.
106         r200_disparity_shift                            = 43, ///< {0 - 512}. Can only be set before streaming starts.
107         r200_auto_exposure_mean_intensity_set_point     = 44,
108         r200_auto_exposure_bright_ratio_set_point       = 45,
109         r200_auto_exposure_kp_gain                      = 46,
110         r200_auto_exposure_kp_exposure                  = 47,
111         r200_auto_exposure_kp_dark_threshold            = 48,
112         r200_auto_exposure_top_edge                     = 49,
113         r200_auto_exposure_bottom_edge                  = 50,
114         r200_auto_exposure_left_edge                    = 51,
115         r200_auto_exposure_right_edge                   = 52,
116         r200_depth_control_estimate_median_decrement    = 53,
117         r200_depth_control_estimate_median_increment    = 54,
118         r200_depth_control_median_threshold             = 55,
119         r200_depth_control_score_minimum_threshold      = 56,
120         r200_depth_control_score_maximum_threshold      = 57,
121         r200_depth_control_texture_count_threshold      = 58,
122         r200_depth_control_texture_difference_threshold = 59,
123         r200_depth_control_second_peak_threshold        = 60,
124         r200_depth_control_neighbor_threshold           = 61,
125         r200_depth_control_lr_threshold                 = 62
126     };
127 
128     struct float2 { float x,y; };
129     struct float3 { float x,y,z; };
130 
131     struct intrinsics : rs_intrinsics
132     {
hfovrs::intrinsics133         float       hfov() const                                                        { return (atan2f(ppx + 0.5f, fx) + atan2f(width - (ppx + 0.5f), fx)) * 57.2957795f; }
vfovrs::intrinsics134         float       vfov() const                                                        { return (atan2f(ppy + 0.5f, fy) + atan2f(height - (ppy + 0.5f), fy)) * 57.2957795f; }
modelrs::intrinsics135         distortion  model() const                                                       { return (distortion)rs_intrinsics::model; }
136 
137                     // Helpers for mapping between pixel coordinates and texture coordinates
pixel_to_texcoordrs::intrinsics138         float2      pixel_to_texcoord(const float2 & pixel) const                       { return {(pixel.x+0.5f)/width, (pixel.y+0.5f)/height}; }
texcoord_to_pixelrs::intrinsics139         float2      texcoord_to_pixel(const float2 & coord) const                       { return {coord.x*width - 0.5f, coord.y*height - 0.5f}; }
140 
141                     // Helpers for mapping from image coordinates into 3D space
deprojectrs::intrinsics142         float3      deproject(const float2 & pixel, float depth) const                  { float3 point; rs_deproject_pixel_to_point(&point.x, this, &pixel.x, depth); return point; }
deproject_from_texcoordrs::intrinsics143         float3      deproject_from_texcoord(const float2 & coord, float depth) const    { return deproject(texcoord_to_pixel(coord), depth); }
144 
145                     // Helpers for mapping from 3D space into image coordinates
projectrs::intrinsics146         float2      project(const float3 & point) const                                 { float2 pixel; rs_project_point_to_pixel(&pixel.x, this, &point.x); return pixel; }
project_to_texcoordrs::intrinsics147         float2      project_to_texcoord(const float3 & point) const                     { return pixel_to_texcoord(project(point)); }
148 
operator ==rs::intrinsics149         bool        operator == (const intrinsics & r) const                            { return memcmp(this, &r, sizeof(r)) == 0; }
150 
151     };
152     struct extrinsics : rs_extrinsics
153     {
is_identityrs::extrinsics154         bool        is_identity() const                                                 { return rotation[0] == 1 && rotation[4] == 1 && translation[0] == 0 && translation[1] == 0 && translation[2] == 0; }
transformrs::extrinsics155         float3      transform(const float3 & point) const                               { float3 p; rs_transform_point_to_point(&p.x, this, &point.x); return p; }
156 
157     };
158     class context;
159     class device;
160 
161     class error : public std::runtime_error
162     {
163         std::string function, args;
164     public:
error(rs_error * err)165         error(rs_error * err) : std::runtime_error(rs_get_error_message(err)), function(rs_get_failed_function(err)), args(rs_get_failed_args(err)) { rs_free_error(err); }
get_failed_function() const166         const std::string & get_failed_function() const { return function; }
get_failed_args() const167         const std::string & get_failed_args() const { return args; }
handle(rs_error * e)168         static void handle(rs_error * e) { if(e) throw error(e); }
169     };
170 
171     class context
172     {
173         rs_context * handle;
174         context(const context &) = delete;
175         context & operator = (const context &) = delete;
176     public:
context()177         context()
178         {
179             rs_error * e = nullptr;
180             handle = rs_create_context(4, &e);
181             error::handle(e);
182         }
183 
~context()184         ~context()
185         {
186             rs_delete_context(handle, nullptr);
187         }
188 
189         /// determine number of connected devices
190         /// \return  the count of devices
get_device_count() const191         int get_device_count() const
192         {
193             rs_error * e = nullptr;
194             auto r = rs_get_device_count(handle, &e);
195             error::handle(e);
196             return r;
197         }
198 
199         /// retrieve connected device by index
200         /// \param[in] index  the zero based index of device to retrieve
201         /// \return           the requested device
get_device(int index)202         device * get_device(int index)
203         {
204             rs_error * e = nullptr;
205             auto r = rs_get_device(handle, index, &e);
206             error::handle(e);
207             return (device *)r;
208         }
209     };
210 
211     class device
212     {
213         device() = delete;
214         device(const device &) = delete;
215         device & operator = (const device &) = delete;
216         ~device() = delete;
217     public:
218         /// retrieve a human readable device model string
219         /// \return  the model string, such as "Intel RealSense F200" or "Intel RealSense R200"
get_name() const220         const char * get_name() const
221         {
222             rs_error * e = nullptr;
223             auto r = rs_get_device_name((const rs_device *)this, &e);
224             error::handle(e);
225             return r;
226         }
227 
228         /// retrieve the unique serial number of the device
229         /// \return  the serial number, in a format specific to the device model
get_serial() const230         const char * get_serial() const
231         {
232             rs_error * e = nullptr;
233             auto r = rs_get_device_serial((const rs_device *)this, &e);
234             error::handle(e);
235             return r;
236         }
237 
238         /// retrieve the version of the firmware currently installed on the device
239         /// \return  firmware version string, in a format is specific to device model
get_firmware_version() const240         const char * get_firmware_version() const
241         {
242             rs_error * e = nullptr;
243             auto r = rs_get_device_firmware_version((const rs_device *)this, &e);
244             error::handle(e);
245             return r;
246         }
247 
248         /// retrieve extrinsic transformation between the viewpoints of two different streams
249         /// \param[in] from_stream  stream whose coordinate space we will transform from
250         /// \param[in] to_stream    stream whose coordinate space we will transform to
251         /// \return                 the transformation between the two streams
get_extrinsics(stream from_stream,stream to_stream) const252         extrinsics get_extrinsics(stream from_stream, stream to_stream) const
253         {
254             rs_error * e = nullptr;
255             extrinsics extrin;
256             rs_get_device_extrinsics((const rs_device *)this, (rs_stream)from_stream, (rs_stream)to_stream, &extrin, &e);
257             error::handle(e);
258             return extrin;
259         }
260 
261         /// retrieve mapping between the units of the depth image and meters
262         /// \return  depth in meters corresponding to a depth value of 1
get_depth_scale() const263         float get_depth_scale() const
264         {
265             rs_error * e = nullptr;
266             auto r = rs_get_device_depth_scale((const rs_device *)this, &e);
267             error::handle(e);
268             return r;
269         }
270 
271         /// determine if the device allows a specific option to be queried and set
272         /// \param[in] option  the option to check for support
273         /// \return            true if the option can be queried and set
supports_option(option option) const274         bool supports_option(option option) const
275         {
276             rs_error * e = nullptr;
277             auto r = rs_device_supports_option((const rs_device *)this, (rs_option)option, &e);
278             error::handle(e);
279             return r != 0;
280         }
281 
282         /// determine the number of streaming modes available for a given stream
283         /// \param[in] stream  the stream whose modes will be enumerated
284         /// \return            the count of available modes
get_stream_mode_count(stream stream) const285         int get_stream_mode_count(stream stream) const
286         {
287             rs_error * e = nullptr;
288             auto r = rs_get_stream_mode_count((const rs_device *)this, (rs_stream)stream, &e);
289             error::handle(e);
290             return r;
291         }
292 
293         /// determine the properties of a specific streaming mode
294         /// \param[in] stream      the stream whose mode will be queried
295         /// \param[in] index       the zero based index of the streaming mode
296         /// \param[out] width      the width of a frame image in pixels
297         /// \param[out] height     the height of a frame image in pixels
298         /// \param[out] format     the pixel format of a frame image
299         /// \param[out] framerate  the number of frames which will be streamed per second
get_stream_mode(stream stream,int index,int & width,int & height,format & format,int & framerate) const300         void get_stream_mode(stream stream, int index, int & width, int & height, format & format, int & framerate) const
301         {
302             rs_error * e = nullptr;
303             rs_get_stream_mode((const rs_device *)this, (rs_stream)stream, index, &width, &height, (rs_format *)&format, &framerate, &e);
304             error::handle(e);
305         }
306 
307         /// enable a specific stream and request specific properties
308         /// \param[in] stream     the stream to enable
309         /// \param[in] width      the desired width of a frame image in pixels, or 0 if any width is acceptable
310         /// \param[in] height     the desired height of a frame image in pixels, or 0 if any height is acceptable
311         /// \param[in] format     the pixel format of a frame image, or ANY if any format is acceptable
312         /// \param[in] framerate  the number of frames which will be streamed per second, or 0 if any framerate is acceptable
enable_stream(stream stream,int width,int height,format format,int framerate)313         void enable_stream(stream stream, int width, int height, format format, int framerate)
314         {
315             rs_error * e = nullptr;
316             rs_enable_stream((rs_device *)this, (rs_stream)stream, width, height, (rs_format)format, framerate, &e);
317             error::handle(e);
318         }
319 
320         /// enable a specific stream and request properties using a preset
321         /// \param[in] stream  the stream to enable
322         /// \param[in] preset  the preset to use to enable the stream
enable_stream(stream stream,preset preset)323         void enable_stream(stream stream, preset preset)
324         {
325             rs_error * e = nullptr;
326             rs_enable_stream_preset((rs_device *)this, (rs_stream)stream, (rs_preset)preset, &e);
327             error::handle(e);
328         }
329 
330         /// disable a specific stream
331         /// \param[in] stream  the stream to disable
disable_stream(stream stream)332         void disable_stream(stream stream)
333         {
334             rs_error * e = nullptr;
335             rs_disable_stream((rs_device *)this, (rs_stream)stream, &e);
336             error::handle(e);
337         }
338 
339         /// determine if a specific stream is enabled
340         /// \param[in] stream  the stream to check
341         /// \return            true if the stream is currently enabled
is_stream_enabled(stream stream) const342         bool is_stream_enabled(stream stream) const
343         {
344             rs_error * e = nullptr;
345             auto r = rs_is_stream_enabled((const rs_device *)this, (rs_stream)stream, &e);
346             error::handle(e);
347             return r != 0;
348         }
349 
350         /// retrieve the width in pixels of a specific stream, equivalent to the width field from the stream's intrinsics
351         /// \param[in] stream  the stream whose width to retrieve
352         /// \return            the width in pixels of images from this stream
get_stream_width(stream stream) const353         int get_stream_width(stream stream) const
354         {
355             rs_error * e = nullptr;
356             auto r = rs_get_stream_width((const rs_device *)this, (rs_stream)stream, &e);
357             error::handle(e);
358             return r;
359         }
360 
361         /// retrieve the height in pixels of a specific stream, equivalent to the height field from the stream's intrinsics
362         /// \param[in] stream  the stream whose height to retrieve
363         /// \return            the height in pixels of images from this stream
get_stream_height(stream stream) const364         int get_stream_height(stream stream) const
365         {
366             rs_error * e = nullptr;
367             auto r = rs_get_stream_height((const rs_device *)this, (rs_stream)stream, &e);
368             error::handle(e);
369             return r;
370         }
371 
372         /// retrieve the pixel format for a specific stream
373         /// \param[in] stream  the stream whose format to retrieve
374         /// \return            the pixel format of the stream
get_stream_format(stream stream) const375         format get_stream_format(stream stream) const
376         {
377             rs_error * e = nullptr;
378             auto r = rs_get_stream_format((const rs_device *)this, (rs_stream)stream, &e);
379             error::handle(e);
380             return (format)r;
381         }
382 
383         /// retrieve the framerate for a specific stream
384         /// \param[in] stream  the stream whose framerate to retrieve
385         /// \return            the framerate of the stream, in frames per second
get_stream_framerate(stream stream) const386         int get_stream_framerate(stream stream) const
387         {
388             rs_error * e = nullptr;
389             auto r = rs_get_stream_framerate((const rs_device *)this, (rs_stream)stream, &e);
390             error::handle(e);
391             return r;
392         }
393 
394         /// retrieve intrinsic camera parameters for a specific stream
395         /// \param[in] stream  the stream whose parameters to retrieve
396         /// \return            the intrinsic parameters of the stream
get_stream_intrinsics(stream stream) const397         intrinsics get_stream_intrinsics(stream stream) const
398         {
399             rs_error * e = nullptr;
400             intrinsics intrin;
401             rs_get_stream_intrinsics((const rs_device *)this, (rs_stream)stream, &intrin, &e);
402             error::handle(e);
403             return intrin;
404         }
405 
406         /// begin streaming on all enabled streams for this device
407         ///
start()408         void start()
409         {
410             rs_error * e = nullptr;
411             rs_start_device((rs_device *)this, &e);
412             error::handle(e);
413         }
414 
415         /// end streaming on all streams for this device
416         ///
stop()417         void stop()
418         {
419             rs_error * e = nullptr;
420             rs_stop_device((rs_device *)this, &e);
421             error::handle(e);
422         }
423 
424         /// determine if the device is currently streaming
425         /// \return  true if the device is currently streaming
is_streaming() const426         bool is_streaming() const
427         {
428             rs_error * e = nullptr;
429             auto r = rs_is_device_streaming((const rs_device *)this, &e);
430             error::handle(e);
431             return r != 0;
432         }
433 
434         /// retrieve the available range of values of a supported option
435         /// \param[in] option  the option whose range should be queried
436         /// \param[out] min    the minimum value which will be accepted for this option
437         /// \param[out] max    the maximum value which will be accepted for this option
438         /// \param[out] step   the granularity of options which accept discrete values, or zero if the option accepts continuous values
get_option_range(option option,double & min,double & max,double & step)439         void get_option_range(option option, double & min, double & max, double & step)
440         {
441             rs_error * e = nullptr;
442             rs_get_device_option_range((rs_device *)this, (rs_option)option, &min, &max, &step, &e);
443             error::handle(e);
444         }
445 
446         /// efficiently retrieve the value of an arbitrary number of options, using minimal hardware IO
447         /// \param[in] options  the array of options which should be queried
448         /// \param[in] count    the length of the options and values arrays
449         /// \param[out] values  the array which will receive the values of the queried options
get_options(const option * options,int count,double * values)450         void get_options(const option * options, int count, double * values)
451         {
452             rs_error * e = nullptr;
453             rs_get_device_options((rs_device *)this, (const rs_option *)options, count, values, &e);
454             error::handle(e);
455         }
456 
457         /// efficiently set the value of an arbitrary number of options, using minimal hardware IO
458         /// \param[in] options  the array of options which should be set
459         /// \param[in] count    the length of the options and values arrays
460         /// \param[in] values   the array of values to which the options should be set
set_options(const option * options,int count,const double * values)461         void set_options(const option * options, int count, const double * values)
462         {
463             rs_error * e = nullptr;
464             rs_set_device_options((rs_device *)this, (const rs_option *)options, count, values, &e);
465             error::handle(e);
466         }
467 
468         /// retrieve the current value of a single option
469         /// \param[in] option  the option whose value should be retrieved
470         /// \return            the value of the option
get_option(option option)471         double get_option(option option)
472         {
473             rs_error * e = nullptr;
474             auto r = rs_get_device_option((rs_device *)this, (rs_option)option, &e);
475             error::handle(e);
476             return r;
477         }
478 
479         /// set the current value of a single option
480         /// \param[in] option  the option whose value should be set
481         /// \param[in] value   the value of the option
set_option(option option,double value)482         void set_option(option option, double value)
483         {
484             rs_error * e = nullptr;
485             rs_set_device_option((rs_device *)this, (rs_option)option, value, &e);
486             error::handle(e);
487         }
488 
489         /// block until new frames are available
490         ///
wait_for_frames()491         void wait_for_frames()
492         {
493             rs_error * e = nullptr;
494             rs_wait_for_frames((rs_device *)this, &e);
495             error::handle(e);
496         }
497 
498         /// check if new frames are available, without blocking
499         /// \return  true if new frames are available, false if no new frames have arrived
poll_for_frames()500         bool poll_for_frames()
501         {
502             rs_error * e = nullptr;
503             auto r = rs_poll_for_frames((rs_device *)this, &e);
504             error::handle(e);
505             return r != 0;
506         }
507 
508         /// retrieve the time at which the latest frame on a stream was captured
509         /// \param[in] stream  the stream whose latest frame we are interested in
510         /// \return            the timestamp of the frame, in milliseconds since the device was started
get_frame_timestamp(stream stream) const511         int get_frame_timestamp(stream stream) const
512         {
513             rs_error * e = nullptr;
514             auto r = rs_get_frame_timestamp((const rs_device *)this, (rs_stream)stream, &e);
515             error::handle(e);
516             return r;
517         }
518 
519         /// retrieve the contents of the latest frame on a stream
520         /// \param[in] stream  the stream whose latest frame we are interested in
521         /// \return            the pointer to the start of the frame data
get_frame_data(stream stream) const522         const void * get_frame_data(stream stream) const
523         {
524             rs_error * e = nullptr;
525             auto r = rs_get_frame_data((const rs_device *)this, (rs_stream)stream, &e);
526             error::handle(e);
527             return r;
528         }
529     };
530 
operator <<(std::ostream & o,stream stream)531     inline std::ostream & operator << (std::ostream & o, stream stream) { return o << rs_stream_to_string((rs_stream)stream); }
operator <<(std::ostream & o,format format)532     inline std::ostream & operator << (std::ostream & o, format format) { return o << rs_format_to_string((rs_format)format); }
operator <<(std::ostream & o,preset preset)533     inline std::ostream & operator << (std::ostream & o, preset preset) { return o << rs_preset_to_string((rs_preset)preset); }
operator <<(std::ostream & o,distortion distortion)534     inline std::ostream & operator << (std::ostream & o, distortion distortion) { return o << rs_distortion_to_string((rs_distortion)distortion); }
operator <<(std::ostream & o,option option)535     inline std::ostream & operator << (std::ostream & o, option option) { return o << rs_option_to_string((rs_option)option); }
536 
537     enum class log_severity : int32_t
538     {
539         debug = 0, // Detailed information about ordinary operations
540         info  = 1, // Terse information about ordinary operations
541         warn  = 2, // Indication of possible failure
542         error = 3, // Indication of definite failure
543         fatal = 4, // Indication of unrecoverable failure
544         none  = 5, // No logging will occur
545     };
546 
log_to_console(log_severity min_severity)547     inline void log_to_console(log_severity min_severity)
548     {
549         rs_error * e = nullptr;
550         rs_log_to_console((rs_log_severity)min_severity, &e);
551         error::handle(e);
552     }
553 
log_to_file(log_severity min_severity,const char * file_path)554     inline void log_to_file(log_severity min_severity, const char * file_path)
555     {
556         rs_error * e = nullptr;
557         rs_log_to_file((rs_log_severity)min_severity, file_path, &e);
558         error::handle(e);
559     }
560 
561     // Additional utilities
apply_depth_control_preset(device * device,int preset)562     void apply_depth_control_preset(device * device, int preset) { rs_apply_depth_control_preset((rs_device *)device, preset); }
apply_ivcam_preset(device * device,int preset)563     void apply_ivcam_preset(device * device, int preset) { rs_apply_ivcam_preset((rs_device *)device, preset); }
564 }
565 #endif
566