NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #ifndef LIBREALSENSE_RS2_HPP
5 #define LIBREALSENSE_RS2_HPP
6 
7 #include "rs.h"
8 #include "hpp/rs_types.hpp"
9 #include "hpp/rs_context.hpp"
10 #include "hpp/rs_device.hpp"
11 #include "hpp/rs_frame.hpp"
12 #include "hpp/rs_processing.hpp"
13 #include "hpp/rs_record_playback.hpp"
14 #include "hpp/rs_sensor.hpp"
15 #include "hpp/rs_pipeline.hpp"
16 
17 namespace rs2
18 {
19  inline void log_to_console(rs2_log_severity min_severity)
20  {
21  rs2_error* e = nullptr;
22  rs2_log_to_console(min_severity, &e);
23  error::handle(e);
24  }
25 
26  inline void log_to_file(rs2_log_severity min_severity, const char * file_path = nullptr)
27  {
28  rs2_error* e = nullptr;
29  rs2_log_to_file(min_severity, file_path, &e);
30  error::handle(e);
31  }
32 
33  inline void reset_logger()
34  {
35  rs2_error* e = nullptr;
36  rs2_reset_logger(&e);
37  error::handle(e);
38  }
39 
40  // Enable rolling log file when used with rs2_log_to_file:
41  // Upon reaching (max_size/2) bytes, the log will be renamed with an ".old" suffix and a new log created. Any
42  // previous .old file will be erased.
43  // Must have permissions to remove/rename files in log file directory.
44  //
45  // @param max_size max file size in megabytes
46  //
47  inline void enable_rolling_log_file( unsigned max_size )
48  {
49  rs2_error * e = nullptr;
50  rs2_enable_rolling_log_file( max_size, &e );
51  error::handle( e );
52  }
53 
54  /*
55  Interface to the log message data we expose.
56  */
58  {
59  // Only log_callback should be creating us!
60  template< class T > friend class log_callback;
61 
62  log_message( rs2_log_message const & msg ) : _msg( msg ) {}
63 
64  public:
65  /* Returns the line-number in the file where the LOG() comment was issued */
66  size_t line_number() const
67  {
68  rs2_error* e = nullptr;
69  size_t ln = rs2_get_log_message_line_number( &_msg, &e );
70  error::handle( e );
71  return ln;
72  }
73  /* Returns the file in which the LOG() command was issued */
74  const char * filename() const
75  {
76  rs2_error* e = nullptr;
77  const char * path = rs2_get_log_message_filename( &_msg, &e );
78  error::handle( e );
79  return path;
80  }
81  /* Returns the raw message, as it was passed to LOG(), before any embelishments like level etc. */
82  const char* raw() const
83  {
84  rs2_error* e = nullptr;
85  const char* r = rs2_get_raw_log_message( &_msg, &e );
86  error::handle( e );
87  return r;
88  }
89  /*
90  Returns a complete log message, as defined by librealsense, with level, timestamp, etc.:
91  11/12 13:49:40,153 INFO [10604] (rs.cpp:2271) Framebuffer size changed to 1552 x 919
92  */
93  const char* full() const
94  {
95  rs2_error* e = nullptr;
96  const char* str = rs2_get_full_log_message( &_msg, &e );
97  error::handle( e );
98  return str;
99  }
100 
101  private:
102  rs2_log_message const & _msg;
103  };
104 
105  /*
106  Wrapper around any callback function that is given to log_to_callback.
107  */
108  template<class T>
110  {
111  T on_log_function;
112  public:
113  explicit log_callback( T on_log ) : on_log_function( on_log ) {}
114 
115  void on_log( rs2_log_severity severity, rs2_log_message const & msg ) noexcept override
116  {
117  on_log_function( severity, log_message( msg ));
118  }
119 
120  void release() override { delete this; }
121  };
122 
123  /*
124  Your callback should look like this, for example:
125  void callback( rs2_log_severity severity, rs2::log_message const & msg ) noexcept
126  {
127  std::cout << msg.build() << std::endl;
128  }
129  and, when initializing rs2:
130  rs2::log_to_callback( callback );
131  or:
132  rs2::log_to_callback(
133  []( rs2_log_severity severity, rs2::log_message const & msg ) noexcept
134  {
135  std::cout << msg.build() << std::endl;
136  })
137  */
138  template< typename S >
139  inline void log_to_callback( rs2_log_severity min_severity, S callback )
140  {
141  // We wrap the callback with an interface and pass it to librealsense, who will
142  // now manage its lifetime. Rather than deleting it, though, it will call its
143  // release() function, where (back in our context) it can be safely deleted:
144  rs2_error* e = nullptr;
145  rs2_log_to_callback_cpp( min_severity, new log_callback< S >( std::move( callback )), &e );
146  error::handle( e );
147  }
148 
149  inline void log(rs2_log_severity severity, const char* message)
150  {
151  rs2_error* e = nullptr;
152  rs2_log(severity, message, &e);
153  error::handle(e);
154  }
155 }
156 
157 inline std::ostream & operator << (std::ostream & o, rs2_stream stream) { return o << rs2_stream_to_string(stream); }
158 inline std::ostream & operator << (std::ostream & o, rs2_format format) { return o << rs2_format_to_string(format); }
159 inline std::ostream & operator << (std::ostream & o, rs2_distortion distortion) { return o << rs2_distortion_to_string(distortion); }
160 inline std::ostream & operator << (std::ostream & o, rs2_option option) { return o << rs2_option_to_string(option); } // This function is being deprecated. For existing options it will return option name, but for future API additions the user should call rs2_get_option_name instead.
161 inline std::ostream & operator << (std::ostream & o, rs2_log_severity severity) { return o << rs2_log_severity_to_string(severity); }
162 inline std::ostream & operator << (std::ostream & o, rs2::log_message const & msg ) { return o << msg.raw(); }
163 inline std::ostream & operator << (std::ostream & o, rs2_camera_info camera_info) { return o << rs2_camera_info_to_string(camera_info); }
164 inline std::ostream & operator << (std::ostream & o, rs2_frame_metadata_value metadata) { return o << rs2_frame_metadata_to_string(metadata); }
165 inline std::ostream & operator << (std::ostream & o, rs2_timestamp_domain domain) { return o << rs2_timestamp_domain_to_string(domain); }
166 inline std::ostream & operator << (std::ostream & o, rs2_notification_category notificaton) { return o << rs2_notification_category_to_string(notificaton); }
167 inline std::ostream & operator << (std::ostream & o, rs2_sr300_visual_preset preset) { return o << rs2_sr300_visual_preset_to_string(preset); }
168 inline std::ostream & operator << (std::ostream & o, rs2_exception_type exception_type) { return o << rs2_exception_type_to_string(exception_type); }
169 inline std::ostream & operator << (std::ostream & o, rs2_playback_status status) { return o << rs2_playback_status_to_string(status); }
170 inline std::ostream & operator << (std::ostream & o, rs2_l500_visual_preset preset) {return o << rs2_l500_visual_preset_to_string(preset);}
171 inline std::ostream & operator << (std::ostream & o, rs2_sensor_mode mode) { return o << rs2_sensor_mode_to_string(mode); }
172 inline std::ostream & operator << (std::ostream & o, rs2_calibration_type mode) { return o << rs2_calibration_type_to_string(mode); }
173 inline std::ostream & operator << (std::ostream & o, rs2_calibration_status mode) { return o << rs2_calibration_status_to_string(mode); }
174 
175 #endif // LIBREALSENSE_RS2_HPP
rs.h
Exposes librealsense functionality for C compilers.
rs2_log_severity_to_string
const char * rs2_log_severity_to_string(rs2_log_severity info)
rs2::log_message::full
const char * full() const
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:93
rs2_playback_status
rs2_playback_status
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_record_playback.h:19
rs2::log_callback
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:109
rs2_camera_info_to_string
const char * rs2_camera_info_to_string(rs2_camera_info info)
rs2_option_to_string
const char * rs2_option_to_string(rs2_option option)
rs2_log_message
struct rs2_log_message rs2_log_message
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_types.h:259
rs2_distortion
rs2_distortion
Distortion model: defines how pixel coordinates should be mapped to sensor coordinates.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_types.h:45
rs2_notification_category_to_string
const char * rs2_notification_category_to_string(rs2_notification_category category)
rs2::log_message::raw
const char * raw() const
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:82
rs2::log_message::filename
const char * filename() const
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:74
rs2_notification_category
rs2_notification_category
Category of the librealsense notification.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_types.h:17
rs2_enable_rolling_log_file
void rs2_enable_rolling_log_file(unsigned max_size, rs2_error **error)
Enable rolling log file when used with rs2_log_to_file: Upon reaching (max_size/2) bytes,...
rs2_l500_visual_preset_to_string
const char * rs2_l500_visual_preset_to_string(rs2_l500_visual_preset preset)
rs2_calibration_status
rs2_calibration_status
Used in device_calibration with rs2_calibration_change_callback.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_device.h:366
rs2_distortion_to_string
const char * rs2_distortion_to_string(rs2_distortion distortion)
rs2_calibration_type_to_string
const char * rs2_calibration_type_to_string(rs2_calibration_type)
rs2_reset_logger
void rs2_reset_logger(rs2_error **error)
rs2_camera_info
rs2_camera_info
Read-only strings that can be queried from the device.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_sensor.h:22
rs2_log_to_callback_cpp
void rs2_log_to_callback_cpp(rs2_log_severity min_severity, rs2_log_callback *callback, rs2_error **error)
rs2_get_full_log_message
const char * rs2_get_full_log_message(rs2_log_message const *msg, rs2_error **error)
rs2_get_log_message_filename
const char * rs2_get_log_message_filename(rs2_log_message const *msg, rs2_error **error)
rs2_exception_type
rs2_exception_type
Exception types are the different categories of errors that RealSense API might return.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_types.h:30
rs2_frame_metadata_to_string
const char * rs2_frame_metadata_to_string(rs2_frame_metadata_value metadata)
rs2_log_severity
rs2_log_severity
Severity of the librealsense logger.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_types.h:153
operator<<
std::ostream & operator<<(std::ostream &o, rs2_stream stream)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:157
rs2_exception_type_to_string
const char * rs2_exception_type_to_string(rs2_exception_type type)
rs2_timestamp_domain_to_string
const char * rs2_timestamp_domain_to_string(rs2_timestamp_domain info)
rs2_log
void rs2_log(rs2_log_severity severity, const char *message, rs2_error **error)
Add custom message into librealsense log.
rs2_calibration_status_to_string
const char * rs2_calibration_status_to_string(rs2_calibration_status)
rs2_log_callback
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_types.hpp:55
rs2::log_to_console
void log_to_console(rs2_log_severity min_severity)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:19
rs2_calibration_type
rs2_calibration_type
Used in device_calibration; enumerates the different calibration types available for that extension.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_device.h:354
rs2_sr300_visual_preset_to_string
const char * rs2_sr300_visual_preset_to_string(rs2_sr300_visual_preset preset)
rs2::reset_logger
void reset_logger()
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:33
rs2
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:17
rs2_get_log_message_line_number
unsigned rs2_get_log_message_line_number(rs2_log_message const *msg, rs2_error **error)
rs2::log_callback::log_callback
log_callback(T on_log)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:113
absl::move
constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t< T > && move(T &&t) noexcept
Definition: includes/opentelemetry/nostd/internal/absl/utility/utility.h:199
rs2::enable_rolling_log_file
void enable_rolling_log_file(unsigned max_size)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:47
rs2_format_to_string
const char * rs2_format_to_string(rs2_format format)
rs2::log_message
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:57
rs2_frame_metadata_value
rs2_frame_metadata_value
Per-Frame-Metadata is the set of read-only properties that might be exposed for each individual frame...
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_frame.h:29
rs2::log
void log(rs2_log_severity severity, const char *message)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:149
rs2_format
rs2_format
A stream's format identifies how binary data is encoded within a frame.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_sensor.h:59
rs2::log_message::line_number
size_t line_number() const
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:66
rs2_sensor_mode_to_string
const char * rs2_sensor_mode_to_string(rs2_sensor_mode preset)
rs2_option
rs2_option
Defines general configuration controls.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_option.h:22
rs2_l500_visual_preset
rs2_l500_visual_preset
For L500 devices: provides optimized settings (presets) for specific types of usage.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_option.h:153
rs2::log_callback::release
void release() override
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:120
rs2_sr300_visual_preset
rs2_sr300_visual_preset
For SR300 devices: provides optimized settings (presets) for specific types of usage.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_option.h:121
rs2_log_to_console
void rs2_log_to_console(rs2_log_severity min_severity, rs2_error **error)
rs2::error::handle
static void handle(rs2_error *e)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/hpp/rs_types.hpp:144
rs2_get_raw_log_message
const char * rs2_get_raw_log_message(rs2_log_message const *msg, rs2_error **error)
rs2::log_to_file
void log_to_file(rs2_log_severity min_severity, const char *file_path=nullptr)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:26
rs2_sensor_mode
rs2_sensor_mode
For setting the camera_mode option.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_option.h:167
rs2::log_to_callback
void log_to_callback(rs2_log_severity min_severity, S callback)
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:139
rs2::log_callback::on_log
void on_log(rs2_log_severity severity, rs2_log_message const &msg) noexcept override
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/rs.hpp:115
rs2_stream_to_string
const char * rs2_stream_to_string(rs2_stream stream)
rs2_playback_status_to_string
const char * rs2_playback_status_to_string(rs2_playback_status status)
rs2_log_to_file
void rs2_log_to_file(rs2_log_severity min_severity, const char *file_path, rs2_error **error)
rs2_stream
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_sensor.h:42
ds3d::v2xinfer::format
static std::string format(const char *fmt,...)
Definition: sources/libs/ds3d/inference_custom_lib/ds3d_v2x_infer_custom_preprocess/tensor.hpp:31
rs2_timestamp_domain
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_frame.h:19
rs2_error
struct rs2_error rs2_error
Definition: sources/libs/ds3d/3rdparty/realsense2/include/librealsense2/h/rs_types.h:258