Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
Loading...
Searching...
No Matches
rs_types.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_TYPES_HPP
5#define LIBREALSENSE_RS2_TYPES_HPP
6
7#include "../rs.h"
8#include "../h/rs_context.h"
9#include "../h/rs_device.h"
10#include "../h/rs_frame.h"
11#include "../h/rs_processing.h"
13#include "../h/rs_sensor.h"
14#include "../h/rs_pipeline.h"
15
16#include <string>
17#include <vector>
18#include <memory>
19#include <functional>
20#include <exception>
21#include <iterator>
22#include <sstream>
23#include <chrono>
24
26{
27 virtual void on_frame(rs2_frame * f) = 0;
28 virtual void release() = 0;
30};
31typedef std::shared_ptr<rs2_frame_callback> rs2_frame_callback_sptr;
32
34{
35 virtual void on_frame(rs2_frame * f, rs2_source * source) = 0;
36 virtual void release() = 0;
38};
39typedef std::shared_ptr<rs2_frame_processor_callback> rs2_frame_processor_callback_sptr;
40
42{
43 virtual void on_notification(rs2_notification* n) = 0;
44 virtual void release() = 0;
46};
47typedef std::shared_ptr<rs2_notifications_callback> rs2_notifications_callback_sptr;
48
49typedef void ( *log_callback_function_ptr )(rs2_log_severity severity, rs2_log_message const * msg );
50
57typedef std::shared_ptr<rs2_software_device_destruction_callback> rs2_software_device_destruction_callback_sptr;
58
60{
61 virtual void on_log( rs2_log_severity severity, rs2_log_message const & msg ) noexcept = 0;
62 virtual void release() = 0;
63 virtual ~rs2_log_callback() {}
64};
65typedef std::shared_ptr< rs2_log_callback > rs2_log_callback_sptr;
66
68{
69 virtual void on_calibration_change( rs2_calibration_status ) noexcept = 0;
70 virtual void release() = 0;
72};
73typedef std::shared_ptr<rs2_calibration_change_callback> rs2_calibration_change_callback_sptr;
74
76{
77 virtual void on_devices_changed(rs2_device_list* removed, rs2_device_list* added) = 0;
78 virtual void release() = 0;
80};
81typedef std::shared_ptr<rs2_devices_changed_callback> rs2_devices_changed_callback_sptr;
82
89typedef std::shared_ptr<rs2_playback_status_changed_callback> rs2_playback_status_changed_callback_sptr;
90
92{
93 virtual void on_update_progress(const float update_progress) = 0;
94 virtual void release() = 0;
96};
97typedef std::shared_ptr<rs2_update_progress_callback> rs2_update_progress_callback_sptr;
98
100{
101 virtual void on_value_changed( rs2_options_list * list ) = 0;
102 virtual void release() = 0;
104};
105typedef std::shared_ptr< rs2_options_changed_callback > rs2_options_changed_callback_sptr;
106
107namespace rs2
108{
109 class error : public std::runtime_error
110 {
111 std::string function, args;
113 public:
114 explicit error(rs2_error* err) : runtime_error(rs2_get_error_message(err))
115 {
116 function = (nullptr != rs2_get_failed_function(err)) ? rs2_get_failed_function(err) : std::string();
117 args = (nullptr != rs2_get_failed_args(err)) ? rs2_get_failed_args(err) : std::string();
119 rs2_free_error(err);
120 }
121
122 explicit error(const std::string& message) : runtime_error(message.c_str())
123 {
124 function = "";
125 args = "";
127 }
128
129 const std::string& get_failed_function() const
130 {
131 return function;
132 }
133
134 const std::string& get_failed_args() const
135 {
136 return args;
137 }
138
139 rs2_exception_type get_type() const { return type; }
140
141 static void handle(rs2_error* e);
142 };
143
144 #define RS2_ERROR_CLASS(name, base) \
145 class name : public base\
146 {\
147 public:\
148 explicit name(rs2_error* e) noexcept : base(e) {}\
149 }
150
151 RS2_ERROR_CLASS(recoverable_error, error);
152 RS2_ERROR_CLASS(unrecoverable_error, error);
153 RS2_ERROR_CLASS(camera_disconnected_error, unrecoverable_error);
154 RS2_ERROR_CLASS(backend_error, unrecoverable_error);
155 RS2_ERROR_CLASS(device_in_recovery_mode_error, unrecoverable_error);
156 RS2_ERROR_CLASS(invalid_value_error, recoverable_error);
157 RS2_ERROR_CLASS(wrong_api_call_sequence_error, recoverable_error);
158 RS2_ERROR_CLASS(not_implemented_error, recoverable_error);
159 #undef RS2_ERROR_CLASS
160
161 inline void error::handle(rs2_error* e)
162 {
163 if (e)
164 {
166 switch (h) {
168 throw camera_disconnected_error(e);
170 throw backend_error(e);
172 throw invalid_value_error(e);
174 throw wrong_api_call_sequence_error(e);
176 throw not_implemented_error(e);
178 throw device_in_recovery_mode_error(e);
179 default:
180 throw error(e);
181 }
182 }
183 }
184
185 class context;
186 class device;
187 class device_list;
188 class syncer;
189 class device_base;
190 class roi_sensor;
191 class frame;
192
194 {
195 float min;
196 float max;
197 float def;
198 float step;
199 };
200
202 {
203 int min_x;
204 int min_y;
205 int max_x;
206 int max_y;
207 };
208}
209
210inline std::ostream & operator << (std::ostream & o, rs2_vector v) { return o << v.x << ", " << v.y << ", " << v.z; }
211inline std::ostream & operator << (std::ostream & o, rs2_quaternion q) { return o << q.x << ", " << q.y << ", " << q.z << ", " << q.w; }
212
213#endif // LIBREALSENSE_RS2_TYPES_HPP
Definition rs_context.hpp:97
Definition rs_device.hpp:1018
Definition rs_device.hpp:20
Definition rs_types.hpp:110
rs2_exception_type get_type() const
Definition rs_types.hpp:139
error(rs2_error *err)
Definition rs_types.hpp:114
const std::string & get_failed_function() const
Definition rs_types.hpp:129
error(const std::string &message)
Definition rs_types.hpp:122
static void handle(rs2_error *e)
Definition rs_types.hpp:161
const std::string & get_failed_args() const
Definition rs_types.hpp:134
Definition rs_frame.hpp:346
Definition rs_sensor.hpp:422
Definition rs_processing.hpp:642
Definition rs_processing_gl.hpp:13
Exposes librealsense functionality for C compilers.
Exposes RealSense context functionality for C compilers.
Exposes RealSense device functionality for C compilers.
rs2_calibration_status
Definition rs_device.h:415
Exposes RealSense frame functionality for C compilers.
Exposes RealSense processing-block functionality for C compilers.
Exposes RealSense processing-block functionality for C compilers.
Exposes record and playback functionality for C compilers.
rs2_playback_status
Definition rs_record_playback.h:20
Exposes RealSense sensor functionality for C compilers.
rs2_exception_type rs2_get_librealsense_exception_type(const rs2_error *error)
rs2_log_severity
Severity of the librealsense logger.
Definition rs_types.h:121
struct rs2_log_message rs2_log_message
Definition rs_types.h:228
void rs2_free_error(rs2_error *error)
const char * rs2_get_failed_args(const rs2_error *error)
struct rs2_source rs2_source
Definition rs_types.h:243
const char * rs2_get_error_message(const rs2_error *error)
struct rs2_notification rs2_notification
Definition rs_types.h:256
const char * rs2_get_failed_function(const rs2_error *error)
struct rs2_device_list rs2_device_list
Definition rs_types.h:235
struct rs2_error rs2_error
Definition rs_types.h:227
rs2_exception_type
Exception types are the different categories of errors that RealSense API might return.
Definition rs_types.h:31
@ RS2_EXCEPTION_TYPE_NOT_IMPLEMENTED
Definition rs_types.h:37
@ RS2_EXCEPTION_TYPE_CAMERA_DISCONNECTED
Definition rs_types.h:33
@ RS2_EXCEPTION_TYPE_BACKEND
Definition rs_types.h:34
@ RS2_EXCEPTION_TYPE_INVALID_VALUE
Definition rs_types.h:35
@ RS2_EXCEPTION_TYPE_UNKNOWN
Definition rs_types.h:32
@ RS2_EXCEPTION_TYPE_DEVICE_IN_RECOVERY_MODE
Definition rs_types.h:38
@ RS2_EXCEPTION_TYPE_WRONG_API_CALL_SEQUENCE
Definition rs_types.h:36
struct rs2_options_list rs2_options_list
Definition rs_types.h:253
struct rs2_frame rs2_frame
Definition rs_types.h:230
std::shared_ptr< rs2_frame_callback > rs2_frame_callback_sptr
Definition rs_types.hpp:31
std::ostream & operator<<(std::ostream &o, rs2_vector v)
Definition rs_types.hpp:210
#define RS2_ERROR_CLASS(name, base)
Definition rs_types.hpp:144
std::shared_ptr< rs2_devices_changed_callback > rs2_devices_changed_callback_sptr
Definition rs_types.hpp:81
std::shared_ptr< rs2_log_callback > rs2_log_callback_sptr
Definition rs_types.hpp:65
std::shared_ptr< rs2_notifications_callback > rs2_notifications_callback_sptr
Definition rs_types.hpp:47
std::shared_ptr< rs2_frame_processor_callback > rs2_frame_processor_callback_sptr
Definition rs_types.hpp:39
std::shared_ptr< rs2_options_changed_callback > rs2_options_changed_callback_sptr
Definition rs_types.hpp:105
std::shared_ptr< rs2_playback_status_changed_callback > rs2_playback_status_changed_callback_sptr
Definition rs_types.hpp:89
std::shared_ptr< rs2_calibration_change_callback > rs2_calibration_change_callback_sptr
Definition rs_types.hpp:73
void(* log_callback_function_ptr)(rs2_log_severity severity, rs2_log_message const *msg)
Definition rs_types.hpp:49
std::shared_ptr< rs2_update_progress_callback > rs2_update_progress_callback_sptr
Definition rs_types.hpp:97
std::shared_ptr< rs2_software_device_destruction_callback > rs2_software_device_destruction_callback_sptr
Definition rs_types.hpp:57
Definition rs_types.hpp:194
float def
Definition rs_types.hpp:197
float step
Definition rs_types.hpp:198
float max
Definition rs_types.hpp:196
float min
Definition rs_types.hpp:195
Definition rs_types.hpp:202
int min_x
Definition rs_types.hpp:203
int max_y
Definition rs_types.hpp:206
int max_x
Definition rs_types.hpp:205
int min_y
Definition rs_types.hpp:204
Definition rs_types.hpp:68
virtual void on_calibration_change(rs2_calibration_status) noexcept=0
virtual ~rs2_calibration_change_callback()
Definition rs_types.hpp:71
Definition rs_types.hpp:76
virtual void on_devices_changed(rs2_device_list *removed, rs2_device_list *added)=0
virtual ~rs2_devices_changed_callback()
Definition rs_types.hpp:79
Definition rs_types.hpp:26
virtual ~rs2_frame_callback()
Definition rs_types.hpp:29
virtual void on_frame(rs2_frame *f)=0
virtual void release()=0
Definition rs_types.hpp:34
virtual ~rs2_frame_processor_callback()
Definition rs_types.hpp:37
virtual void on_frame(rs2_frame *f, rs2_source *source)=0
Definition rs_types.hpp:60
virtual void release()=0
virtual ~rs2_log_callback()
Definition rs_types.hpp:63
virtual void on_log(rs2_log_severity severity, rs2_log_message const &msg) noexcept=0
Definition rs_types.hpp:42
virtual void on_notification(rs2_notification *n)=0
virtual ~rs2_notifications_callback()
Definition rs_types.hpp:45
virtual void release()=0
Definition rs_types.hpp:100
virtual void on_value_changed(rs2_options_list *list)=0
virtual ~rs2_options_changed_callback()
Definition rs_types.hpp:103
Definition rs_types.hpp:84
virtual void on_playback_status_changed(rs2_playback_status status)=0
virtual ~rs2_playback_status_changed_callback()
Definition rs_types.hpp:87
Quaternion used to represent rotation
Definition rs_types.h:104
float y
Definition rs_types.h:105
float z
Definition rs_types.h:105
float w
Definition rs_types.h:105
float x
Definition rs_types.h:105
virtual ~rs2_software_device_destruction_callback()
Definition rs_types.hpp:55
Definition rs_types.hpp:92
virtual ~rs2_update_progress_callback()
Definition rs_types.hpp:95
virtual void on_update_progress(const float update_progress)=0
3D vector in Euclidean coordinate space
Definition rs_types.h:98
float x
Definition rs_types.h:99
float y
Definition rs_types.h:99
float z
Definition rs_types.h:99