stream.h
Go to the documentation of this file.
00001 // License: Apache 2.0. See LICENSE file in root directory.
00002 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
00003 
00004 #pragma once
00005 #ifndef LIBREALSENSE_STREAM_H
00006 #define LIBREALSENSE_STREAM_H
00007 
00008 #include "types.h"
00009 
00010 #include <memory> // For shared_ptr
00011 
00012 namespace rsimpl
00013 {
00014     struct stream_interface : rs_stream_interface
00015     {
00016         stream_interface(calibration_validator in_validator, rs_stream in_stream) : stream(in_stream), validator(in_validator){};
00017                                                                  
00018         virtual rs_extrinsics                   get_extrinsics_to(const rs_stream_interface & other) const override;
00019         virtual rsimpl::pose                    get_pose() const = 0;
00020         virtual int                             get_mode_count() const override { return 0; }
00021         virtual void                            get_mode(int /*mode*/, int * /*w*/, int * /*h*/, rs_format * /*f*/, int * /*fps*/) const override { throw std::logic_error("no modes"); }
00022         virtual rs_stream                       get_stream_type()const override { return stream; }
00023 
00024         const rs_stream   stream;
00025 
00026     protected:
00027         calibration_validator validator;
00028     };
00029     
00030     class frame_archive;
00031     class syncronizing_archive;
00032 
00033     struct native_stream final : public stream_interface
00034     {
00035         const device_config &                   config;
00036         
00037         std::vector<subdevice_mode_selection>   modes;
00038         std::shared_ptr<syncronizing_archive>   archive;
00039 
00040                                                 native_stream(device_config & config, rs_stream stream, calibration_validator in_validator);
00041 
00042         pose                                    get_pose() const override { return config.info.stream_poses[stream]; }
00043         float                                   get_depth_scale() const override { return config.depth_scale; }
00044         int                                     get_mode_count() const override { return (int)modes.size(); }
00045         void                                    get_mode(int mode, int * w, int * h, rs_format * f, int * fps) const override;
00046 
00047         bool                                    is_enabled() const override;
00048         subdevice_mode_selection                get_mode() const;
00049         rs_intrinsics                           get_intrinsics() const override;
00050         rs_intrinsics                           get_rectified_intrinsics() const override;
00051         rs_format                               get_format() const override { return get_mode().get_format(stream); }
00052         int                                     get_framerate() const override { return get_mode().get_framerate(); }
00053 
00054         double                                  get_frame_metadata(rs_frame_metadata frame_metadata) const override;
00055         bool                                    supports_frame_metadata(rs_frame_metadata frame_metadata) const override;
00056         unsigned long long                      get_frame_number() const override;
00057         double                                  get_frame_timestamp() const override;
00058         long long                               get_frame_system_time() const override;
00059         const uint8_t *                         get_frame_data() const override;
00060 
00061         int                                     get_frame_stride() const override;
00062         int                                     get_frame_bpp() const override;
00063     };
00064 
00065     class point_stream final : public stream_interface
00066     {
00067         const stream_interface &                source;
00068         mutable std::vector<uint8_t>            image;
00069         mutable unsigned long long              number;
00070     public:
00071         point_stream(const stream_interface & source) :stream_interface(calibration_validator(), RS_STREAM_POINTS), source(source), number() {}
00072 
00073         pose                                    get_pose() const override { return {{{1,0,0},{0,1,0},{0,0,1}}, source.get_pose().position}; }
00074         float                                   get_depth_scale() const override { return source.get_depth_scale(); }
00075 
00076         bool                                    is_enabled() const override { return source.is_enabled(); }
00077         rs_intrinsics                           get_intrinsics() const override { return source.get_intrinsics(); }
00078         rs_intrinsics                           get_rectified_intrinsics() const override { return source.get_rectified_intrinsics(); }
00079         rs_format                               get_format() const override { return RS_FORMAT_XYZ32F; }
00080         int                                     get_framerate() const override { return source.get_framerate(); }
00081 
00082         double                                  get_frame_metadata(rs_frame_metadata frame_metadata) const override { return source.get_frame_metadata(frame_metadata); }
00083         bool                                    supports_frame_metadata(rs_frame_metadata frame_metadata) const override { return source.supports_frame_metadata(frame_metadata); }
00084         unsigned long long                      get_frame_number() const override { return source.get_frame_number(); }
00085         double                                  get_frame_timestamp() const override{ return source.get_frame_timestamp(); }
00086         long long                               get_frame_system_time() const override { return source.get_frame_system_time(); }
00087         const uint8_t *                         get_frame_data() const override;
00088 
00089         int                                     get_frame_stride() const override { return source.get_frame_stride(); }
00090         int                                     get_frame_bpp() const override { return source.get_frame_bpp(); }
00091     };
00092 
00093     class rectified_stream final : public stream_interface
00094     {
00095         const stream_interface &                source;
00096         mutable std::vector<int>                table;
00097         mutable std::vector<uint8_t>            image;
00098         mutable unsigned long long              number;
00099     public:
00100         rectified_stream(const stream_interface & source) : stream_interface(calibration_validator(), RS_STREAM_RECTIFIED_COLOR), source(source), number() {}
00101 
00102         pose                                    get_pose() const override { return {{{1,0,0},{0,1,0},{0,0,1}}, source.get_pose().position}; }
00103         float                                   get_depth_scale() const override { return source.get_depth_scale(); }
00104 
00105         bool                                    is_enabled() const override { return source.is_enabled(); }
00106         rs_intrinsics                           get_intrinsics() const override { return source.get_rectified_intrinsics(); }
00107         rs_intrinsics                           get_rectified_intrinsics() const override { return source.get_rectified_intrinsics(); }
00108         rs_format                               get_format() const override { return source.get_format(); }
00109         int                                     get_framerate() const override { return source.get_framerate(); }
00110 
00111         double                                  get_frame_metadata(rs_frame_metadata frame_metadata) const override { return source.get_frame_metadata(frame_metadata); }
00112         bool                                    supports_frame_metadata(rs_frame_metadata frame_metadata) const override { return source.supports_frame_metadata(frame_metadata); }
00113         unsigned long long                      get_frame_number() const override { return source.get_frame_number(); }
00114         double                                  get_frame_timestamp() const override { return source.get_frame_timestamp(); }
00115         long long                               get_frame_system_time() const override { return source.get_frame_system_time(); }
00116         const uint8_t *                         get_frame_data() const override;
00117 
00118         int                                     get_frame_stride() const override { return source.get_frame_stride(); }
00119         int                                     get_frame_bpp() const override { return source.get_frame_bpp(); }
00120     };
00121 
00122     class aligned_stream final : public stream_interface
00123     {
00124         const stream_interface &                from, & to;
00125         mutable std::vector<uint8_t>            image;
00126         mutable unsigned long long              number;
00127     public:
00128         aligned_stream(const stream_interface & from, const stream_interface & to) :stream_interface(calibration_validator(), RS_STREAM_COLOR_ALIGNED_TO_DEPTH), from(from), to(to), number() {}
00129 
00130         pose                                    get_pose() const override { return to.get_pose(); }
00131         float                                   get_depth_scale() const override { return to.get_depth_scale(); }
00132 
00133         bool                                    is_enabled() const override { return from.is_enabled() && to.is_enabled(); }
00134         rs_intrinsics                           get_intrinsics() const override { return to.get_intrinsics(); }
00135         rs_intrinsics                           get_rectified_intrinsics() const override { return to.get_rectified_intrinsics(); }
00136         rs_format                               get_format() const override { return from.get_format(); }
00137         int                                     get_framerate() const override { return from.get_framerate(); }
00138 
00139         double                                  get_frame_metadata(rs_frame_metadata frame_metadata) const override { return from.get_frame_metadata(frame_metadata); }
00140         bool                                    supports_frame_metadata(rs_frame_metadata frame_metadata) const override { return from.supports_frame_metadata(frame_metadata); }
00141         unsigned long long                      get_frame_number() const override { return from.get_frame_number(); }
00142         double                                  get_frame_timestamp() const override { return from.get_frame_timestamp(); }
00143         long long                               get_frame_system_time() const override { return from.get_frame_system_time(); }
00144         const unsigned char *                   get_frame_data() const override;
00145 
00146         int                                     get_frame_stride() const override { return from.get_frame_stride(); }
00147         int                                     get_frame_bpp() const override { return from.get_frame_bpp(); }
00148     };
00149 }
00150 
00151 #endif


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Tue Jun 25 2019 19:54:39