HemiStereo SDK
The C++ Software Development Kit for the HemiStereo 3D sensing device.
device.h
Go to the documentation of this file.
1 
5 #ifndef OSP_DEVICE_H
6 #define OSP_DEVICE_H
7 
8 #include <atomic>
9 #include <cassert>
10 #include <chrono>
11 #include <iostream>
12 #include <list>
13 #include <memory>
14 
15 #include <osp/calib/camera.h>
16 #include <osp/exports/sdk_export.h>
17 #include <osp/types/mat.h>
18 #include <osp/types/range.h>
19 #include <osp/types/size.h>
20 
21 namespace osp {
22 
26 class OSP_SDK_EXPORT Status
27 {
28 public:
29  enum class Code
30  {
31  Success,
32  Unavailable,
33  Unauthenticated,
34  InvalidArgument,
35  PermissionDenied,
36  Unknown
37  };
38 
39  Status(Code code, std::string errMsg = std::string());
40 
45  bool ok();
46 
51  Code statusCode();
52 
57  std::string errorMessage();
58 
59 private:
60  Code m_code;
61  std::string m_errMsg;
62 };
63 
67 struct Frame
68 {
72  struct Metadata
73  {
74  Metadata()
75  : timestamp(0)
76  , sensorAnalogGain(0)
77  , sensorExposureTime(0)
78  , sensorSensitivity(0)
79  , ispDigitalGain(0)
80  , sceneLux(0)
81  , achievedFps(0)
82  {}
83 
84  int64_t timestamp;
86  uint64_t sensorExposureTime;
87  uint32_t sensorSensitivity;
89  float sceneLux;
90  float achievedFps;
91  };
92 
94  Matrix<uint8_t, 3> sourceImage0;
95  Matrix<uint8_t, 3> sourceImage1;
96  Matrix<uint8_t, 3> sourceImage2;
97  Matrix<uint8_t, 3> image;
98  Matrix<uint16_t, 1> distanceMap;
99  Matrix<Point3d<float>> pointcloud;
100 };
101 
103 {
104  std::string password;
105 };
106 
107 enum class CameraModelType
108 {
109  Camera0,
110  Camera1,
111  Camera2,
112 // StereoLeftA,
113 // StereoRightA,
114 // StereoLeftB,
115 // StereoRightB,
116  Target
117 };
118 
120 {
121  Quality,
122  Fast
123 };
124 
126 {
127  Low,
128  Middle,
129  High,
130 };
131 
132 enum class TemperatureSensor
133 {
134  CPU,
135  GPU,
136  Board
137 };
138 
140 {
141  None,
142  Lossless,
143  Lossy
144 };
145 
151 {
152  StreamSettings() : imageCompression{ImageCompression::None} {}
153 
155 };
156 
158 {
159  // not implemented
160 };
161 
163 {
165  {
166  ScanLineLeftRight = 1 << 0,
167  ScanLineTopLeftBottomRight = 1 << 1,
168  ScanLineTopBottom = 1 << 2,
169  ScanLineTopRightBottomLeft = 1 << 3,
170  ScanLineRightLeft = 1 << 4,
171  ScanLineBottomRightTopLeft = 1 << 5,
172  ScanLineBottomTop = 1 << 6,
173  ScanLineBottomLeftTopRight = 1 << 7,
176  ScanLineCross = ScanLineLeftRight | ScanLineRightLeft | ScanLineTopBottom | ScanLineBottomTop,
177 
178  ScanLineAll = 0xFF
179  };
180 
182  : maxDisparity(96)
183  , p1(8)
184  , p2(32)
185  , sad(3)
186  , ctWinSize(3)
187  , hcWinSize(5)
188  , clip(31)
189  , maxDiff(5)
190  , uniqueness(15)
191  , scanlines(ScanLineAll)
192  , filterTopArea(false)
193  , pyramidalStereo(true)
194  {}
195 
196  int32_t maxDisparity;
197  int32_t p1;
198  int32_t p2;
199  int32_t sad;
200  int32_t ctWinSize;
201  int32_t hcWinSize;
202  int32_t clip;
203  int32_t maxDiff;
204  int32_t uniqueness;
206  int scanlines;
210 };
211 
217 {
218  StereoMatchingBmParams bmParams;
219  StereoMatchingSgmParams sgmParams;
220 };
221 
222 
226 OSP_SDK_EXPORT bool operator==(const StereoMatchingBmParams &lhs, const StereoMatchingBmParams &rhs);
227 OSP_SDK_EXPORT bool operator==(const StereoMatchingSgmParams &lhs, const StereoMatchingSgmParams &rhs);
228 OSP_SDK_EXPORT bool operator==(const StereoMatchingParams &lhs, const StereoMatchingParams &rhs);
229 
233 class OSP_SDK_EXPORT Device
234 {
235 public:
236  class Private;
237 
241  struct Info
242  {
243  std::string type;
244  std::string serialNumber;
245  std::string uri;
247  };
248 
252  enum class CaptureMode
253  {
254  RAW,
255  RGBD
256  };
257 
262  {
263  Binocular,
264  Trinocular
265  };
266 
270  virtual ~Device();
271 
277  Status open(std::string uri);
278 
282  void close();
283 
289  Status login(const PasswordCredentials &credentials);
290 
294  void logout();
295 
301  bool setPasswordCredentials(const PasswordCredentials &credentials);
302 
307  Info info();
308 
313  bool reboot();
314 
319  bool poweroff();
320 
325  Status start();
326 
330  void stop();
331 
336  bool running();
337 
343  std::unique_ptr<osp::Frame> getFrame(std::chrono::milliseconds timeout = std::chrono::milliseconds(0));
344 
350  float temperature(TemperatureSensor sensor);
351 
357  Camera getCameraModel(CameraModelType type);
358 
364  void setCameraModel(CameraModelType type, Camera model);
365 
369  void saveCurrentCameraModelsAsDefault();
370 
375  void setExtrinsic(Extrinsic extrinsic);
376 
381  Extrinsic getExtrinsic();
382 
387  CaptureMode captureMode() const;
388 
394  Status setCaptureMode(CaptureMode mode);
395 
400  bool exposureAutoLock();
401 
406  Range<uint64_t> exposureRange();
407 
412  float exposureCompensation();
413 
418  Range<float> gainRange();
419 
424  Range<float> digitalGainRange();
425 
430  float frameRate();
431 
438  bool setExposureAutoLock(bool lock);
439 
449  bool setExposureRange(Range<uint64_t> range);
450 
456  bool setExposureCompensation(float ev);
457 
463  bool setGainRange(Range<float> range);
464 
470  bool setDigitalGainRange(Range<float> range);
471 
477  bool setFrameRate(float frameRate);
478 
483  StereoConfiguration stereoConfiguration();
484 
490  bool setStereoConfiguration(StereoConfiguration config);
491 
496  StereoMatchingMode stereoMatchingMode();
497 
503  bool setStereoMatchingMode(StereoMatchingMode mode);
504 
509  osp::Size<size_t> stereoMatchingResolution();
510 
516  bool setStereoMatchingResolution(const osp::Size<size_t> &resolution);
517 
522  StreamSettings streamSettings() const;
523 
528  void setStreamSettings(const StreamSettings &streamSettings);
529 
530 
535  StereoMatchingParams stereoMatchingParams() const;
536 
541  bool setStereoMatchingParams(const StereoMatchingParams &stereoMatchingParams);
542 
543 
544 protected:
545  Device();
546 
547 private:
548  std::unique_ptr<Private> m_p;
549 };
550 
555 class OSP_SDK_EXPORT DeviceManager
556 {
557 public:
558  class Private;
559  virtual ~DeviceManager();
560 
565  static DeviceManager &get();
566 
571  std::vector<Device::Info> getDevices();
572 
579  std::unique_ptr<Device> request(const Device::Info &info, bool useTls = false);
580 
587  std::unique_ptr<Device> request(const std::string &uri, bool useTls = false);
588 
592  void rescan();
593 
594 protected:
595  DeviceManager();
596 
597 private:
598  std::unique_ptr<Private> m_p;
599 };
600 
601 }
602 
603 #endif // OSP_DEVICE_H
StereoMatchingResolution
Definition: device.h:125
Matrix< uint8_t, 3 > image
Definition: device.h:97
std::string type
Definition: device.h:243
The StereoMatchingParams struct contains all parameters used by the stereo algorithms.
Definition: device.h:216
ImageCompression
Definition: device.h:139
bool passwordRequired
Definition: device.h:246
int scanlines
Definition: device.h:206
int32_t sad
Definition: device.h:199
The osp namespace.
Definition: buffer.h:6
Definition: device.h:102
CaptureMode
The capture modes.
Definition: device.h:252
int32_t hcWinSize
Definition: device.h:201
std::string serialNumber
Definition: device.h:244
int32_t ctWinSize
Definition: device.h:200
The Device class controls a single sensor device.
Definition: device.h:233
ImageCompression imageCompression
Definition: device.h:154
uint32_t sensorSensitivity
Definition: device.h:87
Matrix< uint8_t, 3 > sourceImage0
Definition: device.h:94
Matrix< Point3d< float > > pointcloud
Definition: device.h:99
std::string uri
Definition: device.h:245
Structure that holds the sensor data.
Definition: device.h:67
OSP_SDK_EXPORT bool operator==(const StereoMatchingBmParams &lhs, const StereoMatchingBmParams &rhs)
Comparison operators.
float sensorAnalogGain
Definition: device.h:85
ScanLineDirection
Definition: device.h:164
The Metadata struct holds additional information about the Frame.
Definition: device.h:72
float achievedFps
Definition: device.h:90
bool pyramidalStereo
Definition: device.h:208
int32_t clip
Definition: device.h:202
The DeviceManager class provides device discovery and opens new connections to devices.
Definition: device.h:555
Definition: device.h:157
StereoMatchingMode
Definition: device.h:119
Matrix< uint16_t, 1 > distanceMap
Definition: device.h:98
int32_t p2
Definition: device.h:198
bool filterTopArea
Definition: device.h:207
int32_t p1
Definition: device.h:197
int32_t maxDisparity
Definition: device.h:196
int32_t maxDiff
Definition: device.h:203
Code
Definition: device.h:29
A simple status class.
Definition: device.h:26
int64_t timestamp
Definition: device.h:84
Definition: device.h:162
The StreamSettings struct defines the settings that are used for streaming the data from the sensor d...
Definition: device.h:150
int32_t uniqueness
Definition: device.h:204
float ispDigitalGain
Definition: device.h:88
Matrix< uint8_t, 3 > sourceImage2
Definition: device.h:96
uint64_t sensorExposureTime
Definition: device.h:86
Metadata metadata
Definition: device.h:93
Matrix< uint8_t, 3 > sourceImage1
Definition: device.h:95
The Info struct holds some information about a device.
Definition: device.h:241
float sceneLux
Definition: device.h:89
StereoConfiguration
The stereo configuration modes.
Definition: device.h:261