4 #ifndef LIBREALSENSE_RS2_FRAME_HPP 5 #define LIBREALSENSE_RS2_FRAME_HPP 14 class processing_block;
18 class pipeline_profile;
20 class video_stream_profile;
120 std::stringstream ss;
140 operator bool()
const {
return _profile !=
nullptr; }
190 explicit operator std::shared_ptr<rs2_stream_profile>() {
return _clone; }
199 std::shared_ptr<rs2_stream_profile>
_clone;
406 other.frame_ref =
nullptr;
408 frame_number = other.frame_number;
409 profile = other.profile;
427 : frame_ref(other.frame_ref)
431 frame_number = other.frame_number;
432 profile = other.profile;
441 std::swap(frame_ref, other.frame_ref);
444 std::swap(frame_number, other.frame_number);
445 std::swap(profile, other.profile);
469 operator bool()
const {
return frame_ref !=
nullptr; }
658 unsigned long long frame_number = 0;
750 return (e ==
nullptr);
756 operator const float*()
const {
return &
x; }
760 operator const float*()
const {
return &
u; }
800 return (
const vertex*)res;
811 std::swap(texture.frame_ref, ptr);
876 return (
const vertex*)res;
888 return (uint8_t * )res;
1036 auto data =
reinterpret_cast<const float*
>(
get_data());
1037 return rs2_vector{ data[0], data[1], data[2] };
1168 :
frame(f), _size(0)
1197 result = std::move(frm);
1211 if (!frm)
throw error(
"Frame of requested stream type was not found!");
1364 auto count =
size();
1365 for (
size_t i = 0; i < count; i++)
1370 action(
frame(fref));
1388 throw error(
"Requested index is out of range!");
1422 T on_frame_function;
1428 on_frame_function(
frame{ fref });
1434 #endif // LIBREALSENSE_RS2_FRAME_HPP Definition: rs_types.hpp:115
void rs2_register_extrinsics(const rs2_stream_profile *from, const rs2_stream_profile *to, rs2_extrinsics extrin, rs2_error **error)
stream_profile clone(rs2_stream type, int index, rs2_format format, int width, int height, const rs2_intrinsics &intr) const
Definition: rs_frame.hpp:277
Definition: rs_frame.hpp:293
iterator begin() const
Definition: rs_frame.hpp:1413
frame apply_filter(filter_interface &filter)
Definition: rs_frame.hpp:619
Definition: rs_frame.hpp:22
int get_bytes_per_pixel() const
Definition: rs_frame.hpp:733
depth_frame(const frame &f)
Definition: rs_frame.hpp:944
Definition: rs_frame.hpp:662
Definition: rs_types.hpp:26
void rs2_export_to_ply(const rs2_frame *frame, const char *fname, rs2_frame *texture, rs2_error **error)
Definition: rs_sensor.hpp:103
float rs2_depth_frame_get_units(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:369
video_stream_profile()
Definition: rs_frame.hpp:213
void release() override
Definition: rs_frame.hpp:1431
void add_ref() const
Definition: rs_frame.hpp:630
Definition: rs_types.h:215
int rs2_get_frame_points_count(const rs2_frame *frame, rs2_error **error)
frame first(rs2_stream s, rs2_format f=RS2_FORMAT_ANY) const
Definition: rs_frame.hpp:1208
const rs2_stream_profile * rs2_get_frame_stream_profile(const rs2_frame *frame, rs2_error **error)
rs2_sensor * rs2_get_frame_sensor(const rs2_frame *frame, rs2_error **error)
rs2_motion_device_intrinsic get_motion_intrinsics() const
Definition: rs_frame.hpp:315
int _uid
Definition: rs_frame.hpp:202
stream_profile()
Definition: rs_frame.hpp:28
Definition: rs_pipeline.hpp:18
int rs2_is_frame_extendable_to(const rs2_frame *frame, rs2_extension extension_type, rs2_error **error)
rs2_format format() const
Definition: rs_frame.hpp:44
Definition: rs_types.h:160
void rs2_get_video_stream_resolution(const rs2_stream_profile *mode, int *width, int *height, rs2_error **error)
Definition: rs_frame.hpp:763
void register_extrinsics_to(const stream_profile &to, rs2_extrinsics extrinsics)
Definition: rs_frame.hpp:171
frame operator*()
Definition: rs_frame.hpp:1407
Definition: rs_frame.hpp:325
void rs2_keep_frame(rs2_frame *frame)
void rs2_get_extrinsics(const rs2_stream_profile *from, const rs2_stream_profile *to, rs2_extrinsics *extrin, rs2_error **error)
std::string stream_name() const
Definition: rs_frame.hpp:113
frameset()
Definition: rs_frame.hpp:1162
float y
Definition: rs_frame.hpp:755
inference_frame()
Definition: rs_frame.hpp:1087
int _index
Definition: rs_frame.hpp:201
Definition: rs_sensor.h:53
Definition: rs_sensor.h:72
const vertex * get_vertices() const
Definition: rs_frame.hpp:871
rs2_calib_target_type
Calibration target type.
Definition: rs_frame.h:169
pose_frame get_pose_frame(const size_t index=0) const
Definition: rs_frame.hpp:1308
unsigned int rs2_get_frame_object_detection_count(const rs2_frame *frame, rs2_error **error)
Definition: rs_sensor.h:57
Definition: rs_types.h:162
frame(frame &&other) noexcept
Definition: rs_frame.hpp:404
Definition: rs_frame.hpp:1156
object_detection_frame()
Definition: rs_frame.hpp:1112
Definition: rs_types.h:210
bool is() const
Definition: rs_frame.hpp:92
void export_to_ply(const std::string &fname, video_frame texture)
Definition: rs_frame.hpp:808
rs2_time_t rs2_get_frame_timestamp(const rs2_frame *frame, rs2_error **error)
int rs2_stream_profile_is(const rs2_stream_profile *mode, rs2_extension type, rs2_error **error)
Definition: rs_context.hpp:11
rs2_pixel * rs2_get_frame_texture_coordinates(const rs2_frame *frame, rs2_error **error)
rs2_vertex * rs2_get_frame_labeled_vertices(const rs2_frame *frame, rs2_error **error)
double get_timestamp() const
Definition: rs_frame.hpp:500
labeled_points get_labeled_point_cloud_frame() const
Definition: rs_frame.hpp:1252
bool is() const
Definition: rs_frame.hpp:596
size_t size() const
Definition: rs_frame.hpp:828
float u
Definition: rs_frame.hpp:759
int rs2_supports_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
Definition: rs_types.h:216
Definition: rs_processing.hpp:250
size_t size() const
Definition: rs_frame.hpp:892
object_detection_frame(const frame &f)
Definition: rs_frame.hpp:1118
rs2_stream_profile * rs2_clone_stream_profile(const rs2_stream_profile *mode, rs2_stream stream, int index, rs2_format format, rs2_error **error)
float z
Definition: rs_frame.hpp:755
int fps() const
Definition: rs_frame.hpp:49
Definition: rs_frame.hpp:838
void reset()
Definition: rs_frame.hpp:637
iterator & operator++()
Definition: rs_frame.hpp:1403
struct rs2_sensor rs2_sensor
Definition: rs_types.h:317
labeled_points(const frame &f)
Definition: rs_frame.hpp:850
Definition: rs_sensor.h:51
rs2_extrinsics get_extrinsics_to(const stream_profile &to) const
Definition: rs_frame.hpp:157
int rs2_get_frame_height(const rs2_frame *frame, rs2_error **error)
std::shared_ptr< rs2_stream_profile > _clone
Definition: rs_frame.hpp:199
pose_frame(const frame &f)
Definition: rs_frame.hpp:1057
object_detection_frame get_object_detection_frame(const size_t index=0) const
Definition: rs_frame.hpp:1330
void swap(frame &other)
Definition: rs_frame.hpp:439
Definition: rs_types.h:170
Definition: rs_frame.hpp:1391
frame & operator=(frame other)
Definition: rs_frame.hpp:416
Definition: rs_sensor.h:76
Definition: rs_frame.hpp:1012
frame_callback(T on_frame)
Definition: rs_frame.hpp:1424
int rs2_get_frame_stride_in_bytes(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:1420
rs2_vector get_motion_data() const
Definition: rs_frame.hpp:1034
frame(rs2_frame *ref)
Definition: rs_frame.hpp:380
const rs2_stream_profile * _profile
Definition: rs_frame.hpp:198
frame first_or_default(rs2_stream s, rs2_format f=RS2_FORMAT_ANY) const
Definition: rs_frame.hpp:1191
rs2::frame process(rs2::frame frame) const override
Definition: rs_processing.hpp:369
video_frame(const frame &f)
Definition: rs_frame.hpp:669
void rs2_get_stream_profile_data(const rs2_stream_profile *mode, rs2_stream *stream, rs2_format *format, int *index, int *unique_id, int *framerate, rs2_error **error)
void * rs2_get_frame_labels(const rs2_frame *frame, rs2_error **error)
points()
Definition: rs_frame.hpp:769
std::forward_iterator_tag iterator_category
Definition: rs_frame.hpp:1396
float get_distance(int x, int y) const
Definition: rs_frame.hpp:961
video_frame get_color_frame(const size_t index=0) const
Definition: rs_frame.hpp:1228
Definition: rs_processing.hpp:17
Definition: rs_frame.hpp:1081
int rs2_embedded_frames_count(rs2_frame *composite, rs2_error **error)
int rs2_is_stream_profile_default(const rs2_stream_profile *mode, rs2_error **error)
int _framerate
Definition: rs_frame.hpp:203
Definition: rs_types.h:163
motion_frame(const frame &f)
Definition: rs_frame.hpp:1019
Definition: rs_types.h:219
~frame()
Definition: rs_frame.hpp:452
int rs2_get_frame_width(const rs2_frame *frame, rs2_error **error)
Definition: rs_frame.hpp:1106
float rs2_depth_frame_get_distance(const rs2_frame *frame_ref, int x, int y, rs2_error **error)
frame operator[](size_t index) const
Definition: rs_frame.hpp:1378
RS2_STREAM_MOTION / RS2_FORMAT_COMBINED_MOTION content is similar to ROS2's Imu message.
Definition: rs_sensor.h:118
Definition: rs_types.h:161
rs2_timestamp_domain rs2_get_frame_timestamp_domain(const rs2_frame *frameset, rs2_error **error)
Definition: rs_types.h:110
rs2_format _format
Definition: rs_frame.hpp:204
void rs2_delete_stream_profile(rs2_stream_profile *mode)
motion_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:300
Definition: rs_types.h:169
void foreach_rs(T action) const
Definition: rs_frame.hpp:1361
rs2_timestamp_domain get_frame_timestamp_domain() const
Definition: rs_frame.hpp:511
bool extract_target_dimensions(rs2_calib_target_type calib_type, float *target_dims, unsigned int target_dims_size) const
Definition: rs_frame.hpp:745
unsigned int get_detection_count() const
Definition: rs_frame.hpp:1133
T as() const
Definition: rs_frame.hpp:103
T as() const
Definition: rs_frame.hpp:606
video_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:219
struct rs2_stream_profile rs2_stream_profile
Definition: rs_types.h:304
Definition: rs_sensor.h:71
unsigned int get_width() const
Definition: rs_frame.hpp:901
virtual ~filter_interface()=default
rs2_format
A stream's format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:69
unsigned int rs2_get_frame_labeled_points_height(const rs2_frame *frame, rs2_error **error)
Definition: rs_processing.hpp:429
bool is_default() const
Definition: rs_frame.hpp:134
void keep()
Definition: rs_frame.hpp:463
unsigned long long rs2_get_frame_number(const rs2_frame *frame, rs2_error **error)
int stream_index() const
Definition: rs_frame.hpp:34
video_frame get_infrared_frame(const size_t index=0) const
Definition: rs_frame.hpp:1263
const texture_coordinate * get_texture_coordinates() const
Definition: rs_frame.hpp:820
int get_bits_per_pixel() const
Definition: rs_frame.hpp:721
void rs2_get_frame_object_detection(const rs2_frame *frame, unsigned int index, rs2_object_detection *detection, rs2_error **error)
unsigned int get_height() const
Definition: rs_frame.hpp:913
bool operator==(const video_stream_profile &other) const
Definition: rs_frame.hpp:258
bool operator==(const iterator &other) const
Definition: rs_frame.hpp:1404
static void handle(rs2_error *e)
Definition: rs_types.hpp:167
Definition: rs_sensor.h:50
rs2_sensor * get_sensor()
Definition: rs_frame.hpp:471
int rs2_get_frame_data_size(const rs2_frame *frame, rs2_error **error)
rs2_combined_motion get_combined_motion_data() const
Definition: rs_frame.hpp:1044
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:47
void rs2_extract_target_dimensions(const rs2_frame *frame, rs2_calib_target_type calib_type, float *target_dims, unsigned int target_dims_size, rs2_error **error)
const uint8_t * get_labels() const
Definition: rs_frame.hpp:883
Definition: rs_sensor.h:63
Definition: rs_processing.hpp:360
int get_height() const
Definition: rs_frame.hpp:697
unsigned int rs2_get_frame_labeled_points_bits_per_pixel(const rs2_frame *frame, rs2_error **error)
const rs2_stream_profile * get() const
Definition: rs_frame.hpp:146
bool _default
Definition: rs_frame.hpp:207
Definition: rs_frame.hpp:982
void rs2_get_video_stream_intrinsics(const rs2_stream_profile *mode, rs2_intrinsics *intrinsics, rs2_error **error)
Definition: rs_sensor.h:52
unsigned long long get_frame_number() const
Definition: rs_frame.hpp:547
inference_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:347
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:111
Definition: rs_types.h:159
inference_frame(const frame &f)
Definition: rs_frame.hpp:1095
iterator end() const
Definition: rs_frame.hpp:1414
iterator(const frameset *owner, size_t index=0)
Definition: rs_frame.hpp:1402
bool is_cloned()
Definition: rs_frame.hpp:178
3D vector in Euclidean coordinate space
Definition: rs_types.h:99
virtual rs2::frame process(rs2::frame frame) const =0
int get_width() const
Definition: rs_frame.hpp:685
const void * get_data() const
Definition: rs_frame.hpp:571
const char * rs2_stream_to_string(rs2_stream stream)
void on_frame(rs2_frame *fref) override
Definition: rs_frame.hpp:1426
Definition: rs_sensor.h:49
long long rs2_metadata_type
Definition: rs_types.h:341
float get_units() const
Definition: rs_frame.hpp:973
points(const frame &f)
Definition: rs_frame.hpp:775
Definition: rs_frame.hpp:362
Definition: rs_types.h:166
int get_stride_in_bytes() const
Definition: rs_frame.hpp:709
unsigned int rs2_get_frame_labeled_points_width(const rs2_frame *frame, rs2_error **error)
rs2_vertex * rs2_get_frame_vertices(const rs2_frame *frame, rs2_error **error)
disparity_frame(const frame &f)
Definition: rs_frame.hpp:989
int width() const
Definition: rs_frame.hpp:236
void rs2_frame_add_ref(rs2_frame *frame, rs2_error **error)
Video stream intrinsics.
Definition: rs_types.h:60
rs2_stream_profile * rs2_clone_video_stream_profile(const rs2_stream_profile *mode, rs2_stream stream, int index, rs2_format format, int width, int height, const rs2_intrinsics *intr, rs2_error **error)
Definition: rs_processing.hpp:699
int height() const
Definition: rs_frame.hpp:241
const char * rs2_get_stream_profile_name(const rs2_stream_profile *profile, rs2_error **error)
rs2_pose get_pose_data() const
Definition: rs_frame.hpp:1071
bool operator!=(const iterator &other) const
Definition: rs_frame.hpp:1405
unsigned int get_bits_per_pixel() const
Definition: rs_frame.hpp:925
bool operator==(const stream_profile &rhs)
Definition: rs_frame.hpp:79
Motion device intrinsics: scale, bias, and variances.
Definition: rs_types.h:73
depth_frame get_depth_frame() const
Definition: rs_frame.hpp:1219
Definition: rs_processing.hpp:133
float rs2_depth_stereo_frame_get_baseline(const rs2_frame *frame_ref, rs2_error **error)
Definition: rs_frame.hpp:344
stream_profile(const rs2_stream_profile *profile)
Definition: rs_frame.hpp:179
void rs2_release_frame(rs2_frame *frame)
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:523
frameset(const frame &f)
Definition: rs_frame.hpp:1167
Definition: rs_frame.hpp:758
int rs2_get_frame_labeled_points_count(const rs2_frame *frame, rs2_error **error)
rs2_frame * rs2_extract_frame(rs2_frame *composite, int index, rs2_error **error)
size_t size() const
Definition: rs_frame.hpp:1351
Definition: rs_types.h:171
rs2_metadata_type rs2_get_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
Definition: rs_types.h:172
labeled_points()
Definition: rs_frame.hpp:844
struct rs2_error rs2_error
Definition: rs_types.h:293
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
Definition: rs_frame.hpp:535
rs2_stream stream_type() const
Definition: rs_frame.hpp:39
float x
Definition: rs_frame.hpp:755
Definition: rs_frame.hpp:210
Definition: rs_frame.hpp:1050
frame(const frame &other)
Definition: rs_frame.hpp:426
rs2_intrinsics get_intrinsics() const
Definition: rs_frame.hpp:249
const int get_data_size() const
Definition: rs_frame.hpp:559
void rs2_get_motion_intrinsics(const rs2_stream_profile *mode, rs2_motion_device_intrinsic *intrinsics, rs2_error **error)
video_frame get_fisheye_frame(const size_t index=0) const
Definition: rs_frame.hpp:1286
rs2_frame * get() const
Definition: rs_frame.hpp:616
void rs2_pose_frame_get_pose_data(const rs2_frame *frame, rs2_pose *pose, rs2_error **error)
frame()
Definition: rs_frame.hpp:375
Definition: rs_sensor.h:62
float v
Definition: rs_frame.hpp:759
stream_profile clone(rs2_stream type, int index, rs2_format format) const
Definition: rs_frame.hpp:63
int rs2_get_frame_bits_per_pixel(const rs2_frame *frame, rs2_error **error)
rs2_frame_metadata_value
Per-Frame-Metadata is the set of read-only properties that might be exposed for each individual frame...
Definition: rs_frame.h:29
rs2_object_detection get_detection(unsigned int index) const
Definition: rs_frame.hpp:1146
struct rs2_frame rs2_frame
Definition: rs_types.h:296
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)
std::ptrdiff_t difference_type
Definition: rs_frame.hpp:1398
float get_baseline(void) const
Definition: rs_frame.hpp:1003
Object detection result from algorithm.
Definition: rs_types.h:123
pose_stream_profile(const stream_profile &sp)
Definition: rs_frame.hpp:332
rs2_stream _type
Definition: rs_frame.hpp:205
Definition: rs_frame.hpp:754
stream_profile get_profile() const
Definition: rs_frame.hpp:583
const vertex * get_vertices() const
Definition: rs_frame.hpp:795
Definition: rs_frame.hpp:937
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
Definition: rs_frame.h:19
int unique_id() const
Definition: rs_frame.hpp:54