RealSenseSensor.cpp
Go to the documentation of this file.
1 #include "RealSenseSensor.h"
2 #include "PCH.h"
3 
4 URealSenseSensor::URealSenseSensor(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
5 {
6  //REALSENSE_TRACE(TEXT("+URealSenseSensor_%p"), this);
7 }
8 
10 {
11  //REALSENSE_TRACE(TEXT("~URealSenseSensor_%p"), this);
12 
13  SetHandle(nullptr);
14 }
15 
17 {
19  RsSensor = Handle;
20 }
21 
23 {
24  return RsSensor;
25 }
26 
28 {
29  auto Option = NewNamedObject<URealSenseOption>(this, ObjName);
30  Option->SetHandle(Handle);
31  Option->SetType(Type);
32  return Option;
33 }
34 
36 {
37  Options.Empty();
38  StreamProfiles.Empty();
39 
42 
43  for (int i = 0; i < RS2_OPTION_COUNT; ++i)
44  {
46  {
47  Options.Add(NewOption((rs2_options*)RsSensor, (ERealSenseOptionType)i, TEXT("RealSenseOption")));
48  }
49  }
50 
52  if (ProfileList)
53  {
54  const int NumProfiles = rs2_get_stream_profiles_count(ProfileList, &e);
55  for (int Id = 0; Id < NumProfiles; Id++)
56  {
57  const rs2_stream_profile* Profile = rs2_get_stream_profile(ProfileList, Id, &e);
58  if (Profile)
59  {
60  rs2_stream Stream;
61  rs2_format Format;
62  int StreamId;
63  int ProfileId;
64  int Framerate;
65  rs2_get_stream_profile_data(Profile, &Stream, &Format, &StreamId, &ProfileId, &Framerate, &e);
66 
67  if (e.success())
68  {
69  if ((Stream == RS2_STREAM_DEPTH && Format == RS2_FORMAT_Z16)
70  || (Stream == RS2_STREAM_COLOR && Format == RS2_FORMAT_RGBA8)
71  || (Stream == RS2_STREAM_INFRARED && Format == RS2_FORMAT_Y8))
72  {
74  spi.StreamType = (ERealSenseStreamType)Stream;
75  spi.Format = (ERealSenseFormatType)Format;
76  spi.Rate = Framerate;
77  rs2_get_video_stream_resolution(Profile, &spi.Width, &spi.Height, &e);
78 
79  if (e.success())
80  {
81  StreamProfiles.Add(spi);
82  }
83  }
84  }
85  }
86  }
87  }
88 
89  for (auto* Option : Options)
90  {
91  Option->QueryData();
92  }
93 }
94 
96 {
98  const int Value = rs2_supports_option((const rs2_options*)RsSensor, (rs2_option)Option, &e);
99  return (e.success() && Value == (int)true);
100 }
101 
103 {
104  for (const auto& Iter : StreamProfiles)
105  {
106  if (Iter.StreamType == Profile.StreamType
107  && Iter.Format == Profile.Format
108  && Iter.Width == Profile.Width
109  && Iter.Height == Profile.Height
110  && Iter.Rate == Profile.Rate)
111  {
112  return true;
113  }
114  }
115  return false;
116 }
117 
119 {
120  URealSenseOption* Result = nullptr;
121 
122  for (auto* Option : Options)
123  {
124  if (Option->Type == OptionType)
125  {
126  Result = Option;
127  break;
128  }
129  }
130 
131  return Result;
132 }
bool SupportsOption(ERealSenseOptionType Option)
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
ERealSenseStreamType StreamType
void rs2_get_video_stream_resolution(const rs2_stream_profile *mode, int *width, int *height, rs2_error **error)
Definition: rs.cpp:466
void SetHandle(struct rs2_sensor *Handle)
ERealSenseOptionType
e
Definition: rmse.py:177
class URealSenseOption * GetOption(ERealSenseOptionType OptionType)
rs2_stream_profile_list * rs2_get_stream_profiles(rs2_sensor *sensor, rs2_error **error)
Definition: rs.cpp:327
int rs2_supports_option(const rs2_options *options, rs2_option option, rs2_error **error)
Definition: rs.cpp:679
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)
Definition: rs.cpp:484
bool success() const
void rs2_delete_sensor(rs2_sensor *sensor)
Definition: rs.cpp:320
const rs2_stream_profile * rs2_get_stream_profile(const rs2_stream_profile_list *list, int index, rs2_error **error)
Definition: rs.cpp:351
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
IMGUI_API void Value(const char *prefix, bool b)
Definition: imgui.cpp:9538
void SetHandle(struct rs2_options *Handle)
ERealSenseFormatType
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
bool SupportsProfile(FRealSenseStreamProfile Profile)
struct rs2_sensor * GetHandle()
ERealSenseStreamType
class URealSenseOption * NewOption(struct rs2_options *Handle, ERealSenseOptionType Type, const TCHAR *Name)
int i
FString uestr(const char *str)
Definition: Shared.h:38
TArray< FRealSenseStreamProfile > StreamProfiles
struct rs2_sensor * RsSensor
ERealSenseFormatType Format
const char * rs2_get_sensor_info(const rs2_sensor *sensor, rs2_camera_info info, rs2_error **error)
Definition: rs.cpp:724
int rs2_get_stream_profiles_count(const rs2_stream_profile_list *list, rs2_error **error)
Definition: rs.cpp:360
virtual ~URealSenseSensor()


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