Rs2Base.cpp
Go to the documentation of this file.
1 #include "Rs2Base.h"
2 
3 namespace oni { namespace driver {
4 
5 // StreamType
6 
8 {
9  switch (type)
10  {
11  case RS2_STREAM_DEPTH:
12  case RS2_STREAM_COLOR:
14  return true;
15  }
16  return false;
17 }
18 
20 {
21  switch (type)
22  {
23  case RS2_STREAM_DEPTH: return ONI_SENSOR_DEPTH;
24  case RS2_STREAM_COLOR: return ONI_SENSOR_COLOR;
25  case RS2_STREAM_INFRARED: return ONI_SENSOR_IR;
26  }
27  rsTraceError("Invalid rs2_stream=%d", (int)type);
28  RS2_ASSERT(false);
29  return (OniSensorType)0;
30 }
31 
33 {
34  switch (type)
35  {
36  case ONI_SENSOR_DEPTH: return RS2_STREAM_DEPTH;
37  case ONI_SENSOR_COLOR: return RS2_STREAM_COLOR;
38  case ONI_SENSOR_IR: return RS2_STREAM_INFRARED;
39  }
40  rsTraceError("Invalid OniSensorType=%d", (int)type);
41  RS2_ASSERT(false);
42  return (rs2_stream)0;
43 }
44 
45 // PixelFormat
46 
48 {
49  switch (type)
50  {
51  case RS2_FORMAT_Z16:
52  case RS2_FORMAT_YUYV:
53  case RS2_FORMAT_RGB8:
54  case RS2_FORMAT_Y8:
55  case RS2_FORMAT_Y16:
56  return true;
57  }
58  return false;
59 }
60 
62 {
63  switch (type)
64  {
65  case RS2_FORMAT_Z16: return 2;
66  case RS2_FORMAT_YUYV: return 2;
67  case RS2_FORMAT_RGB8: return 3;
68  case RS2_FORMAT_Y8: return 1;
69  case RS2_FORMAT_Y16: return 2;
70  }
71  rsTraceError("Invalid rs2_format=%d", (int)type);
72  RS2_ASSERT(false);
73  return 0;
74 }
75 
77 {
78  switch (type)
79  {
80  case RS2_FORMAT_Z16: return ONI_PIXEL_FORMAT_DEPTH_1_MM;
81  case RS2_FORMAT_YUYV: return ONI_PIXEL_FORMAT_YUYV;
82  case RS2_FORMAT_RGB8: return ONI_PIXEL_FORMAT_RGB888;
83  case RS2_FORMAT_Y8: return ONI_PIXEL_FORMAT_GRAY8;
84  case RS2_FORMAT_Y16: return ONI_PIXEL_FORMAT_GRAY16;
85  }
86  rsTraceError("Invalid rs2_format=%d", (int)type);
87  RS2_ASSERT(false);
88  return (OniPixelFormat)0;
89 }
90 
92 {
93  switch (type)
94  {
95  case ONI_PIXEL_FORMAT_DEPTH_1_MM: return RS2_FORMAT_Z16;
96  case ONI_PIXEL_FORMAT_YUYV: return RS2_FORMAT_YUYV;
97  case ONI_PIXEL_FORMAT_RGB888: return RS2_FORMAT_RGB8;
98  case ONI_PIXEL_FORMAT_GRAY8: return RS2_FORMAT_Y8;
99  case ONI_PIXEL_FORMAT_GRAY16: return RS2_FORMAT_Y16;
100  }
101  rsTraceError("Invalid OniPixelFormat=%d", (int)type);
102  RS2_ASSERT(false);
103  return (rs2_format)0;
104 }
105 
106 }} // namespace
OniSensorType convertStreamType(rs2_stream type)
Definition: Rs2Base.cpp:19
bool isSupportedPixelFormat(rs2_format type)
Definition: Rs2Base.cpp:47
bool isSupportedStreamType(rs2_stream type)
Definition: Rs2Base.cpp:7
#define rsTraceError(format,...)
Definition: Rs2Base.h:41
int getPixelFormatBytes(rs2_format type)
Definition: Rs2Base.cpp:61
Definition: Rs2Base.cpp:3
rs2_format
A stream's format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
GLenum type
OniPixelFormat convertPixelFormat(rs2_format type)
Definition: Rs2Base.cpp:76
#define RS2_ASSERT
Definition: Rs2Base.h:38


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