Rs2Base.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Driver/OniDriverAPI.h>
4 
5 #include <librealsense2/rs.h>
7 
8 #include <vector>
9 #include <list>
10 #include <map>
11 #include <mutex>
12 #include <thread>
13 
14 #pragma warning(disable:4100) // unreferenced formal parameter
15 #pragma warning(disable:4505) // unreferenced local function has been removed
16 
17 #define ONI_MAX_DEPTH 10000
18 #define RS2_EMULATE_PRIMESENSE_HARDWARE // HACK: NiTE only runs on PrimeSense SoC
19 
20 //#define RS2_TRACE_NOT_SUPPORTED_CMDS
21 //#define RS2_TRACE_NOT_SUPPORTED_PROPS
22 
23 #if 0
24  // DEV MODE
25  #define PROF_ENABLED
26  #define PROF_MUTEX_IMPL oni::driver::Rs2Mutex
27  #define PROF_SCOPED_MUTEX_IMPL oni::driver::Rs2ScopedMutex
28 #else
29  #define INIT_PROFILER
30  #define SHUT_PROFILER
31  #define NAMED_PROFILER(name)
32  #define SCOPED_PROFILER
33 #endif
34 
35 #if defined(NDEBUG)
36  #define RS2_ASSERT(cond)
37 #else
38  #define RS2_ASSERT assert
39 #endif
40 
41 #define rsTraceError(format, ...) printf("[RS2] ERROR at FILE %s LINE %d FUNC %s\n\t" format "\n", __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__)
42 #define rsTraceFunc(format, ...) printf("[RS2] %s " format "\n", __FUNCTION__, ## __VA_ARGS__)
43 #define rsLogDebug(format, ...) printf("[RS2] " format "\n", ## __VA_ARGS__)
44 
45 namespace oni { namespace driver {
46 
47 typedef std::mutex Rs2Mutex;
48 typedef std::lock_guard<std::mutex> Rs2ScopedMutex;
49 
50 class Rs2Error
51 {
52 public:
53  inline Rs2Error() : m_error(nullptr) {}
54  inline ~Rs2Error() { release(); }
55  inline void release() { if (m_error) { rs2_free_error(m_error); m_error = nullptr; } }
56  inline rs2_error** operator&() { release(); return &m_error; }
57 
58  inline bool success() const { return m_error ? false : true; }
59  inline const char* get_message() const { return rs2_get_error_message(m_error); }
61 
62 private:
64 };
65 
67 OniSensorType convertStreamType(rs2_stream type);
68 rs2_stream convertStreamType(OniSensorType type);
69 
72 OniPixelFormat convertPixelFormat(rs2_format type);
73 rs2_format convertPixelFormat(OniPixelFormat type);
74 
75 }} // namespace
76 
77 #if defined(PROF_ENABLED)
78 #include "Profiler.h"
79 #endif
Exposes RealSense processing-block functionality for C compilers.
rs2_exception_type
Exception types are the different categories of errors that RealSense API might return.
Definition: rs_types.h:30
void rs2_free_error(rs2_error *error)
Definition: rs.cpp:1256
rs2_error ** operator&()
Definition: Rs2Base.h:56
OniSensorType convertStreamType(rs2_stream type)
Definition: Rs2Base.cpp:19
bool isSupportedPixelFormat(rs2_format type)
Definition: Rs2Base.cpp:47
Exposes librealsense functionality for C compilers.
bool isSupportedStreamType(rs2_stream type)
Definition: Rs2Base.cpp:7
int getPixelFormatBytes(rs2_format type)
Definition: Rs2Base.cpp:61
Definition: Rs2Base.cpp:3
const char * rs2_get_error_message(const rs2_error *error)
Definition: rs.cpp:1259
rs2_error * m_error
Definition: Rs2Base.h:63
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
const char * get_message() const
Definition: Rs2Base.h:59
rs2_exception_type rs2_get_librealsense_exception_type(const rs2_error *error)
Definition: rs.cpp:1260
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
std::lock_guard< std::mutex > Rs2ScopedMutex
Definition: Rs2Base.h:48
GLenum type
bool success() const
Definition: Rs2Base.h:58
rs2_exception_type get_type() const
Definition: Rs2Base.h:60
std::mutex Rs2Mutex
Definition: Rs2Base.h:47
OniPixelFormat convertPixelFormat(rs2_format type)
Definition: Rs2Base.cpp:76


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:40