OpenNI.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * *
3 * OpenNI 2.x Alpha *
4 * Copyright (C) 2012 PrimeSense Ltd. *
5 * *
6 * This file is part of OpenNI. *
7 * *
8 * Licensed under the Apache License, Version 2.0 (the "License"); *
9 * you may not use this file except in compliance with the License. *
10 * You may obtain a copy of the License at *
11 * *
12 * http://www.apache.org/licenses/LICENSE-2.0 *
13 * *
14 * Unless required by applicable law or agreed to in writing, software *
15 * distributed under the License is distributed on an "AS IS" BASIS, *
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
17 * See the License for the specific language governing permissions and *
18 * limitations under the License. *
19 * *
20 *****************************************************************************/
21 #ifndef OPENNI_H
22 #define OPENNI_H
23 
24 #include "OniPlatform.h"
25 #include "OniProperties.h"
26 #include "OniEnums.h"
27 
28 #include "OniCAPI.h"
29 #include "OniCProperties.h"
30 #include "OniCTypes.h"
31 
35 namespace openni
36 {
37 
40 
43 
44 // structs
46 typedef struct
47 {
49  int major;
51  int minor;
55  int build;
56 } Version;
57 
59 typedef struct
60 {
61  /* Red value of this pixel. */
63  /* Green value of this pixel. */
65  /* Blue value of this pixel. */
67 } RGB888Pixel;
68 
74 typedef struct
75 {
85 
91 typedef struct
92 {
102 
105 {
106 public:
108  operator const char*() const { return NULL; }
109 };
110 
111 static const _NullString ANY_DEVICE;
112 
117 template<class T>
118 class Array
119 {
120 public:
124  Array() : m_data(NULL), m_count(0), m_owner(false) {}
125 
133  Array(const T* data, int count) : m_owner(false) { _setData(data, count); }
134 
139  {
140  clear();
141  }
142 
147  int getSize() const { return m_count; }
148 
152  const T& operator[](int index) const {return m_data[index];}
153 
164  void _setData(const T* data, int count, bool isOwner = false)
165  {
166  clear();
167  m_count = count;
168  m_owner = isOwner;
169  if (!isOwner)
170  {
171  m_data = data;
172  }
173  else
174  {
175  m_data = new T[count];
176  memcpy((void*)m_data, data, count*sizeof(T));
177  }
178  }
179 
180 private:
181  Array(const Array<T>&);
182  Array<T>& operator=(const Array<T>&);
183 
184  void clear()
185  {
186  if (m_owner && m_data != NULL)
187  delete []m_data;
188  m_owner = false;
189  m_data = NULL;
190  m_count = 0;
191  }
192 
193  const T* m_data;
194  int m_count;
195  bool m_owner;
196 };
197 
198 // Forward declaration of all
199 class SensorInfo;
200 class VideoStream;
201 class VideoFrameRef;
202 class Device;
203 class OpenNI;
204 class CameraSettings;
205 class PlaybackControl;
206 
221 class VideoMode : private OniVideoMode
222 {
223 public:
230  {}
231 
237  VideoMode(const VideoMode& other)
238  {
239  *this = other;
240  }
241 
249  {
250  setPixelFormat(other.getPixelFormat());
251  setResolution(other.getResolutionX(), other.getResolutionY());
252  setFps(other.getFps());
253 
254  return *this;
255  }
256 
261  PixelFormat getPixelFormat() const { return (PixelFormat)pixelFormat; }
262 
267  int getResolutionX() const { return resolutionX; }
268 
273  int getResolutionY() const {return resolutionY;}
274 
279  int getFps() const { return fps; }
280 
287  void setPixelFormat(PixelFormat format) { this->pixelFormat = (OniPixelFormat)format; }
288 
296  void setResolution(int resolutionX, int resolutionY)
297  {
298  this->resolutionX = resolutionX;
299  this->resolutionY = resolutionY;
300  }
301 
308  void setFps(int fps) { this->fps = fps; }
309 
310  friend class SensorInfo;
311  friend class VideoStream;
312  friend class VideoFrameRef;
313 };
314 
333 {
334 public:
339  SensorType getSensorType() const { return (SensorType)m_pInfo->sensorType; }
340 
348  const Array<VideoMode>& getSupportedVideoModes() const { return m_videoModes; }
349 
350 private:
351  SensorInfo(const SensorInfo&);
352  SensorInfo& operator=(const SensorInfo&);
353 
354  SensorInfo() : m_pInfo(NULL), m_videoModes(NULL, 0) {}
355 
356  SensorInfo(const OniSensorInfo* pInfo) : m_pInfo(NULL), m_videoModes(NULL, 0)
357  {
358  _setInternal(pInfo);
359  }
360 
361  void _setInternal(const OniSensorInfo* pInfo)
362  {
363  m_pInfo = pInfo;
364  if (pInfo == NULL)
365  {
366  m_videoModes._setData(NULL, 0);
367  }
368  else
369  {
370  m_videoModes._setData(static_cast<VideoMode*>(pInfo->pSupportedVideoModes), pInfo->numSupportedVideoModes);
371  }
372  }
373 
376 
377  friend class VideoStream;
378  friend class Device;
379 };
380 
390 class DeviceInfo : private OniDeviceInfo
391 {
392 public:
397  const char* getUri() const { return uri; }
399  const char* getVendor() const { return vendor; }
401  const char* getName() const { return name; }
403  uint16_t getUsbVendorId() const { return usbVendorId; }
405  uint16_t getUsbProductId() const { return usbProductId; }
406 
407  friend class Device;
408  friend class OpenNI;
409 };
410 
425 {
426 public:
432  {
433  m_pFrame = NULL;
434  }
435 
440  {
441  release();
442  }
443 
449  VideoFrameRef(const VideoFrameRef& other) : m_pFrame(NULL)
450  {
451  _setFrame(other.m_pFrame);
452  }
453 
460  {
461  _setFrame(other.m_pFrame);
462  return *this;
463  }
464 
470  inline int getDataSize() const
471  {
472  return m_pFrame->dataSize;
473  }
474 
480  inline const void* getData() const
481  {
482  return m_pFrame->data;
483  }
484 
491  inline SensorType getSensorType() const
492  {
493  return (SensorType)m_pFrame->sensorType;
494  }
495 
503  inline const VideoMode& getVideoMode() const
504  {
505  return static_cast<const VideoMode&>(m_pFrame->videoMode);
506  }
507 
515  inline uint64_t getTimestamp() const
516  {
517  return m_pFrame->timestamp;
518  }
519 
530  inline int getFrameIndex() const
531  {
532  return m_pFrame->frameIndex;
533  }
534 
541  inline int getWidth() const
542  {
543  return m_pFrame->width;
544  }
545 
551  inline int getHeight() const
552  {
553  return m_pFrame->height;
554  }
555 
560  inline bool getCroppingEnabled() const
561  {
562  return m_pFrame->croppingEnabled == TRUE;
563  }
564 
569  inline int getCropOriginX() const
570  {
571  return m_pFrame->cropOriginX;
572  }
573 
578  inline int getCropOriginY() const
579  {
580  return m_pFrame->cropOriginY;
581  }
582 
588  inline int getStrideInBytes() const
589  {
590  return m_pFrame->stride;
591  }
592 
596  inline bool isValid() const
597  {
598  return m_pFrame != NULL;
599  }
600 
605  void release()
606  {
607  if (m_pFrame != NULL)
608  {
609  oniFrameRelease(m_pFrame);
610  m_pFrame = NULL;
611  }
612  }
613 
615  void _setFrame(OniFrame* pFrame)
616  {
617  setReference(pFrame);
618  if (pFrame != NULL)
619  {
620  oniFrameAddRef(pFrame);
621  }
622  }
623 
626  {
627  return m_pFrame;
628  }
629 
630 private:
631  friend class VideoStream;
632  inline void setReference(OniFrame* pFrame)
633  {
634  // Initial - don't addref. This is the reference from OpenNI
635  release();
636  m_pFrame = pFrame;
637  }
638 
639  OniFrame* m_pFrame; // const!!?
640 };
641 
664 {
665 public:
674  {
675  public:
679  NewFrameListener() : m_callbackHandle(NULL)
680  {
681  }
682 
684  {
685  }
686 
690  virtual void onNewFrame(VideoStream&) = 0;
691 
692  private:
693  friend class VideoStream;
694 
695  static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void* pCookie)
696  {
697  NewFrameListener* pListener = (NewFrameListener*)pCookie;
698  VideoStream stream;
699  stream._setHandle(streamHandle);
700  pListener->onNewFrame(stream);
701  stream._setHandle(NULL);
702  }
704  };
705 
707  {
708  public:
709  virtual ~FrameAllocator() {}
710  virtual void* allocateFrameBuffer(int size) = 0;
711  virtual void freeFrameBuffer(void* data) = 0;
712 
713  private:
714  friend class VideoStream;
715 
717  {
718  FrameAllocator* pThis = (FrameAllocator*)pCookie;
719  return pThis->allocateFrameBuffer(size);
720  }
721 
722  static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void* data, void* pCookie)
723  {
724  FrameAllocator* pThis = (FrameAllocator*)pCookie;
725  pThis->freeFrameBuffer(data);
726  }
727  };
728 
733  VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true)
734  {}
735 
740  explicit VideoStream(OniStreamHandle handle) : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(false)
741  {
742  _setHandle(handle);
743  }
744 
750  {
751  destroy();
752  }
753 
758  bool isValid() const
759  {
760  return m_stream != NULL;
761  }
762 
772  inline Status create(const Device& device, SensorType sensorType);
773 
779  inline void destroy();
780 
789  const SensorInfo& getSensorInfo() const
790  {
791  return m_sensorInfo;
792  }
793 
795 
797  Status rc = getProperty(STREAM_PROPERTY_SOFTWARE_REGISTRATION, &mode);
798  if (rc != STATUS_OK)
799  {
801  }
802  return mode;
803  }
804 
806  setProperty(STREAM_PROPERTY_SOFTWARE_REGISTRATION, (int)mode);
807  }
808 
813  {
814  if (!isValid())
815  {
816  return STATUS_ERROR;
817  }
818 
819  return (Status)oniStreamStart(m_stream);
820  }
821 
825  void stop()
826  {
827  if (!isValid())
828  {
829  return;
830  }
831 
832  oniStreamStop(m_stream);
833  }
834 
846  {
847  if (!isValid())
848  {
849  return STATUS_ERROR;
850  }
851 
852  OniFrame* pOniFrame;
853  Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame);
854 
855  pFrame->setReference(pOniFrame);
856  return rc;
857  }
858 
867  {
868  if (!isValid())
869  {
870  return STATUS_ERROR;
871  }
872 
873  return (Status)oniStreamRegisterNewFrameCallback(m_stream, pListener->callback, pListener, &pListener->m_callbackHandle);
874  }
875 
881  {
882  if (!isValid())
883  {
884  return;
885  }
886 
888  pListener->m_callbackHandle = NULL;
889  }
890 
897  {
898  if (!isValid())
899  {
900  return STATUS_ERROR;
901  }
902 
903  if (pAllocator == NULL)
904  {
905  return (Status)oniStreamSetFrameBuffersAllocator(m_stream, NULL, NULL, NULL);
906  }
907  else
908  {
909  return (Status)oniStreamSetFrameBuffersAllocator(m_stream, pAllocator->allocateFrameBufferCallback, pAllocator->freeFrameBufferCallback, pAllocator);
910  }
911  }
912 
918  {
919  return m_stream;
920  }
921 
926  CameraSettings* getCameraSettings() {return m_pCameraSettings;}
927 
938  Status getProperty(int propertyId, void* data, int* dataSize) const
939  {
940  if (!isValid())
941  {
942  return STATUS_ERROR;
943  }
944 
945  return (Status)oniStreamGetProperty(m_stream, propertyId, data, dataSize);
946  }
947 
958  Status setProperty(int propertyId, const void* data, int dataSize)
959  {
960  if (!isValid())
961  {
962  return STATUS_ERROR;
963  }
964 
965  return (Status)oniStreamSetProperty(m_stream, propertyId, data, dataSize);
966  }
967 
975  {
976  VideoMode videoMode;
977  getProperty<OniVideoMode>(STREAM_PROPERTY_VIDEO_MODE, static_cast<OniVideoMode*>(&videoMode));
978  return videoMode;
979  }
980 
989  Status setVideoMode(const VideoMode& videoMode)
990  {
991  return setProperty<OniVideoMode>(STREAM_PROPERTY_VIDEO_MODE, static_cast<const OniVideoMode&>(videoMode));
992  }
993 
999  int getMaxPixelValue() const
1000  {
1001  int maxValue;
1002  Status rc = getProperty<int>(STREAM_PROPERTY_MAX_VALUE, &maxValue);
1003  if (rc != STATUS_OK)
1004  {
1005  return 0;
1006  }
1007  return maxValue;
1008  }
1009 
1015  int getMinPixelValue() const
1016  {
1017  int minValue;
1018  Status rc = getProperty<int>(STREAM_PROPERTY_MIN_VALUE, &minValue);
1019  if (rc != STATUS_OK)
1020  {
1021  return 0;
1022  }
1023  return minValue;
1024  }
1025 
1030  bool isCroppingSupported() const
1031  {
1032  return isPropertySupported(STREAM_PROPERTY_CROPPING);
1033  }
1034 
1043  bool getCropping(int* pOriginX, int* pOriginY, int* pWidth, int* pHeight) const
1044  {
1045  OniCropping cropping;
1046  bool enabled = false;
1047 
1048  Status rc = getProperty<OniCropping>(STREAM_PROPERTY_CROPPING, &cropping);
1049 
1050  if (rc == STATUS_OK)
1051  {
1052  *pOriginX = cropping.originX;
1053  *pOriginY = cropping.originY;
1054  *pWidth = cropping.width;
1055  *pHeight = cropping.height;
1056  enabled = (cropping.enabled == TRUE);
1057  }
1058 
1059  return enabled;
1060  }
1061 
1071  Status setCropping(int originX, int originY, int width, int height)
1072  {
1073  OniCropping cropping;
1074  cropping.enabled = true;
1075  cropping.originX = originX;
1076  cropping.originY = originY;
1077  cropping.width = width;
1078  cropping.height = height;
1079  return setProperty<OniCropping>(STREAM_PROPERTY_CROPPING, cropping);
1080  }
1081 
1087  {
1088  OniCropping cropping;
1089  cropping.enabled = false;
1090  return setProperty<OniCropping>(STREAM_PROPERTY_CROPPING, cropping);
1091  }
1092 
1097  bool getMirroringEnabled() const
1098  {
1099  OniBool enabled;
1100  Status rc = getProperty<OniBool>(STREAM_PROPERTY_MIRRORING, &enabled);
1101  if (rc != STATUS_OK)
1102  {
1103  return false;
1104  }
1105  return enabled == TRUE;
1106  }
1107 
1113  Status setMirroringEnabled(bool isEnabled)
1114  {
1115  return setProperty<OniBool>(STREAM_PROPERTY_MIRRORING, isEnabled ? TRUE : FALSE);
1116  }
1117 
1123  {
1124  float horizontal = 0;
1125  getProperty<float>(STREAM_PROPERTY_HORIZONTAL_FOV, &horizontal);
1126  return horizontal;
1127  }
1128 
1134  {
1135  float vertical = 0;
1136  getProperty<float>(STREAM_PROPERTY_VERTICAL_FOV, &vertical);
1137  return vertical;
1138  }
1139 
1149  template <class T>
1150  Status setProperty(int propertyId, const T& value)
1151  {
1152  return setProperty(propertyId, &value, sizeof(T));
1153  }
1154 
1164  template <class T>
1165  Status getProperty(int propertyId, T* value) const
1166  {
1167  int size = sizeof(T);
1168  return getProperty(propertyId, value, &size);
1169  }
1170 
1176  bool isPropertySupported(int propertyId) const
1177  {
1178  if (!isValid())
1179  {
1180  return false;
1181  }
1182 
1183  return oniStreamIsPropertySupported(m_stream, propertyId) == TRUE;
1184  }
1185 
1195  Status invoke(int commandId, void* data, int dataSize)
1196  {
1197  if (!isValid())
1198  {
1199  return STATUS_ERROR;
1200  }
1201 
1202  return (Status)oniStreamInvoke(m_stream, commandId, data, dataSize);
1203  }
1204 
1214  template <class T>
1215  Status invoke(int commandId, T& value)
1216  {
1217  return invoke(commandId, &value, sizeof(T));
1218  }
1219 
1225  bool isCommandSupported(int commandId) const
1226  {
1227  if (!isValid())
1228  {
1229  return false;
1230  }
1231 
1232  return (Status)oniStreamIsCommandSupported(m_stream, commandId) == TRUE;
1233  }
1234 
1235  void filterSpeckles(void* buf, int newVal, int maxSpeckleSize, int maxDiff){
1236  oniStreamfilter(m_stream, buf, newVal, maxSpeckleSize, maxDiff);
1237  }
1238 
1239 private:
1240  friend class Device;
1241 
1243  {
1244  m_sensorInfo._setInternal(NULL);
1245  m_stream = stream;
1246 
1247  if (stream != NULL)
1248  {
1249  m_sensorInfo._setInternal(oniStreamGetSensorInfo(m_stream));
1250  }
1251  }
1252 
1253 private:
1254  VideoStream(const VideoStream& other);
1255  VideoStream& operator=(const VideoStream& other);
1256 
1261 };
1262 
1279 class Device
1280 {
1281 public:
1286  Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true)
1287  {
1288  clearSensors();
1289  }
1290 
1295  explicit Device(OniDeviceHandle handle) : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(false)
1296  {
1297  _setHandle(handle);
1298  }
1299 
1305  {
1306  if (m_device != NULL)
1307  {
1308  close();
1309  }
1310  }
1311 
1341  inline Status open(const char* uri);
1342 
1348  inline void close();
1349 
1359  const DeviceInfo& getDeviceInfo() const
1360  {
1361  return m_deviceInfo;
1362  }
1363 
1371  bool hasSensor(SensorType sensorType)
1372  {
1373  int i;
1374  for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1375  {
1376  if (m_aSensorInfo[i].getSensorType() == sensorType)
1377  {
1378  return true;
1379  }
1380  }
1381 
1382  if (i == ONI_MAX_SENSORS)
1383  {
1384  return false;
1385  }
1386 
1387  const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType);
1388 
1389  if (pInfo == NULL)
1390  {
1391  return false;
1392  }
1393 
1394  m_aSensorInfo[i]._setInternal(pInfo);
1395 
1396  return true;
1397  }
1398 
1407  {
1408  int i;
1409  for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1410  {
1411  if (m_aSensorInfo[i].getSensorType() == sensorType)
1412  {
1413  return &m_aSensorInfo[i];
1414  }
1415  }
1416 
1417  // not found. check to see we have additional space
1418  if (i == ONI_MAX_SENSORS)
1419  {
1420  return NULL;
1421  }
1422 
1423  const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType);
1424  if (pInfo == NULL)
1425  {
1426  return NULL;
1427  }
1428 
1429  m_aSensorInfo[i]._setInternal(pInfo);
1430  return &m_aSensorInfo[i];
1431  }
1432 
1438  {
1439  return m_device;
1440  }
1441 
1446  PlaybackControl* getPlaybackControl() {return m_pPlaybackControl;}
1447 
1459  Status getProperty(int propertyId, void* data, int* dataSize) const
1460  {
1461  return (Status)oniDeviceGetProperty(m_device, propertyId, data, dataSize);
1462  }
1463 
1475  Status setProperty(int propertyId, const void* data, int dataSize)
1476  {
1477  return (Status)oniDeviceSetProperty(m_device, propertyId, data, dataSize);
1478  }
1479 
1480  void setGain(int gain) {
1481  oniDeviceSetProperty(m_device, OBEXTENSION_ID_IR_GAIN, &gain, sizeof(gain));
1482  }
1483 
1484  int getGain() {
1485  int value = 0;
1486  int size = sizeof(value);
1487  oniDeviceGetProperty(m_device, openni::OBEXTENSION_ID_IR_GAIN, (uint16_t *)&value, &size);
1488  return value;
1489  }
1498  {
1500  }
1501 
1510  {
1511  ImageRegistrationMode mode;
1512  Status rc = getProperty<ImageRegistrationMode>(DEVICE_PROPERTY_IMAGE_REGISTRATION, &mode);
1513  if (rc != STATUS_OK)
1514  {
1515  return IMAGE_REGISTRATION_OFF;
1516  }
1517  return mode;
1518  }
1519 
1534  {
1535  return setProperty<ImageRegistrationMode>(DEVICE_PROPERTY_IMAGE_REGISTRATION, mode);
1536  }
1537 
1542  bool isValid() const
1543  {
1544  return m_device != NULL;
1545  }
1546 
1551  bool isFile() const
1552  {
1553  return isPropertySupported(DEVICE_PROPERTY_PLAYBACK_SPEED) &&
1554  isPropertySupported(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED) &&
1555  isCommandSupported(DEVICE_COMMAND_SEEK);
1556  }
1557 
1567  {
1568  Status rc = STATUS_OK;
1569 
1570  if (isEnabled)
1571  {
1572  rc = (Status)oniDeviceEnableDepthColorSync(m_device);
1573  }
1574  else
1575  {
1577  }
1578 
1579  return rc;
1580  }
1581 
1583  {
1584  return oniDeviceGetDepthColorSyncEnabled(m_device) == TRUE;
1585  }
1586 
1597  template <class T>
1598  Status setProperty(int propertyId, const T& value)
1599  {
1600  return setProperty(propertyId, &value, sizeof(T));
1601  }
1602 
1612  template <class T>
1613  Status getProperty(int propertyId, T* value) const
1614  {
1615  int size = sizeof(T);
1616  return getProperty(propertyId, value, &size);
1617  }
1618 
1624  bool isPropertySupported(int propertyId) const
1625  {
1626  return oniDeviceIsPropertySupported(m_device, propertyId) == TRUE;
1627  }
1628 
1638  Status invoke(int commandId, void* data, int dataSize)
1639  {
1640  return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize);
1641  }
1642 
1652  template <class T>
1653  Status invoke(int propertyId, T& value)
1654  {
1655  return invoke(propertyId, &value, sizeof(T));
1656  }
1657 
1663  bool isCommandSupported(int commandId) const
1664  {
1665  return oniDeviceIsCommandSupported(m_device, commandId) == TRUE;
1666  }
1667 
1669  inline Status _openEx(const char* uri, const char* mode);
1670 
1671 private:
1672  Device(const Device&);
1673  Device& operator=(const Device&);
1674 
1676  {
1677  for (int i = 0; i < ONI_MAX_SENSORS; ++i)
1678  {
1679  m_aSensorInfo[i]._setInternal(NULL);
1680  }
1681  }
1682 
1683  inline Status _setHandle(OniDeviceHandle deviceHandle);
1684 
1685 private:
1687 
1690  SensorInfo m_aSensorInfo[ONI_MAX_SENSORS];
1691 
1693 };
1694 
1709 {
1710 public:
1711 
1718  {
1719  detach();
1720  }
1721 
1742  float getSpeed() const
1743  {
1744  if (!isValid())
1745  {
1746  return 0.0f;
1747  }
1748  float speed;
1749  Status rc = m_pDevice->getProperty<float>(DEVICE_PROPERTY_PLAYBACK_SPEED, &speed);
1750  if (rc != STATUS_OK)
1751  {
1752  return 1.0f;
1753  }
1754  return speed;
1755  }
1763  Status setSpeed(float speed)
1764  {
1765  if (!isValid())
1766  {
1767  return STATUS_NO_DEVICE;
1768  }
1769  return m_pDevice->setProperty<float>(DEVICE_PROPERTY_PLAYBACK_SPEED, speed);
1770  }
1771 
1777  bool getRepeatEnabled() const
1778  {
1779  if (!isValid())
1780  {
1781  return false;
1782  }
1783 
1784  OniBool repeat;
1785  Status rc = m_pDevice->getProperty<OniBool>(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, &repeat);
1786  if (rc != STATUS_OK)
1787  {
1788  return false;
1789  }
1790 
1791  return repeat == TRUE;
1792  }
1793 
1803  {
1804  if (!isValid())
1805  {
1806  return STATUS_NO_DEVICE;
1807  }
1808 
1809  return m_pDevice->setProperty<OniBool>(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, repeat ? TRUE : FALSE);
1810  }
1811 
1822  Status seek(const VideoStream& stream, int frameIndex)
1823  {
1824  if (!isValid())
1825  {
1826  return STATUS_NO_DEVICE;
1827  }
1828  OniSeek seek;
1829  seek.frameIndex = frameIndex;
1830  seek.stream = stream._getHandle();
1831  return m_pDevice->invoke(DEVICE_COMMAND_SEEK, seek);
1832  }
1833 
1842  int getNumberOfFrames(const VideoStream& stream) const
1843  {
1844  int numOfFrames = -1;
1845  Status rc = stream.getProperty<int>(STREAM_PROPERTY_NUMBER_OF_FRAMES, &numOfFrames);
1846  if (rc != STATUS_OK)
1847  {
1848  return 0;
1849  }
1850  return numOfFrames;
1851  }
1852 
1853  bool isValid() const
1854  {
1855  return m_pDevice != NULL;
1856  }
1857 private:
1859  {
1860  if (!device->isValid() || !device->isFile())
1861  {
1862  return STATUS_ERROR;
1863  }
1864 
1865  detach();
1866  m_pDevice = device;
1867 
1868  return STATUS_OK;
1869  }
1870  void detach()
1871  {
1872  m_pDevice = NULL;
1873  }
1874 
1875  friend class Device;
1876  PlaybackControl(Device* pDevice) : m_pDevice(NULL)
1877  {
1878  if (pDevice != NULL)
1879  {
1880  attach(pDevice);
1881  }
1882  }
1883 
1885 };
1886 
1888 {
1889 public:
1890  // setters
1892  {
1893  return setProperty(STREAM_PROPERTY_AUTO_EXPOSURE, enabled ? TRUE : FALSE);
1894  }
1896  {
1897  return setProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, enabled ? TRUE : FALSE);
1898  }
1899 
1901  {
1902  OniBool enabled = FALSE;
1903 
1904  Status rc = getProperty(STREAM_PROPERTY_AUTO_EXPOSURE, &enabled);
1905  return rc == STATUS_OK && enabled == TRUE;
1906  }
1908  {
1909  OniBool enabled = FALSE;
1910 
1911  Status rc = getProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, &enabled);
1912  return rc == STATUS_OK && enabled == TRUE;
1913  }
1914 
1915  Status setGain(int gain)
1916  {
1917  return setProperty(STREAM_PROPERTY_GAIN, gain);
1918  }
1919  Status setExposure(int exposure)
1920  {
1921  return setProperty(STREAM_PROPERTY_EXPOSURE, exposure);
1922  }
1923  int getGain()
1924  {
1925  int gain;
1926  Status rc = getProperty(STREAM_PROPERTY_GAIN, &gain);
1927  if (rc != STATUS_OK)
1928  {
1929  return 100;
1930  }
1931  return gain;
1932  }
1934  {
1935  int exposure;
1936  Status rc = getProperty(STREAM_PROPERTY_EXPOSURE, &exposure);
1937  if (rc != STATUS_OK)
1938  {
1939  return 0;
1940  }
1941  return exposure;
1942  }
1943 
1944  bool isValid() const {return m_pStream != NULL;}
1945 private:
1946  template <class T>
1947  Status getProperty(int propertyId, T* value) const
1948  {
1949  if (!isValid()) return STATUS_NOT_SUPPORTED;
1950 
1951  return m_pStream->getProperty<T>(propertyId, value);
1952  }
1953  template <class T>
1954  Status setProperty(int propertyId, const T& value)
1955  {
1956  if (!isValid()) return STATUS_NOT_SUPPORTED;
1957 
1958  return m_pStream->setProperty<T>(propertyId, value);
1959  }
1960 
1961  friend class VideoStream;
1963  {
1964  m_pStream = pStream;
1965  }
1966 
1968 };
1969 
1970 
1983 class OpenNI
1984 {
1985 public:
1986 
2003  {
2004  public:
2006  {
2007  m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback;
2008  m_deviceConnectedCallbacks.deviceDisconnected = NULL;
2009  m_deviceConnectedCallbacks.deviceStateChanged = NULL;
2010  m_deviceConnectedCallbacksHandle = NULL;
2011  }
2012 
2014  {
2015  }
2016 
2028  virtual void onDeviceConnected(const DeviceInfo*) = 0;
2029  private:
2031  {
2032  DeviceConnectedListener* pListener = (DeviceConnectedListener*)pCookie;
2033  pListener->onDeviceConnected(static_cast<const DeviceInfo*>(pInfo));
2034  }
2035 
2036  friend class OpenNI;
2039 
2040  };
2058  {
2059  public:
2061  {
2062  m_deviceDisconnectedCallbacks.deviceConnected = NULL;
2063  m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback;
2064  m_deviceDisconnectedCallbacks.deviceStateChanged = NULL;
2065  m_deviceDisconnectedCallbacksHandle = NULL;
2066  }
2067 
2069  {
2070  }
2071 
2080  virtual void onDeviceDisconnected(const DeviceInfo*) = 0;
2081  private:
2083  {
2085  pListener->onDeviceDisconnected(static_cast<const DeviceInfo*>(pInfo));
2086  }
2087 
2088  friend class OpenNI;
2091  };
2106  {
2107  public:
2109  {
2110  m_deviceStateChangedCallbacks.deviceConnected = NULL;
2111  m_deviceStateChangedCallbacks.deviceDisconnected = NULL;
2112  m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback;
2113  m_deviceStateChangedCallbacksHandle = NULL;
2114  }
2115 
2117  {
2118  }
2119 
2126  virtual void onDeviceStateChanged(const DeviceInfo*, DeviceState) = 0;
2127  private:
2129  {
2131  pListener->onDeviceStateChanged(static_cast<const DeviceInfo*>(pInfo), DeviceState(state));
2132  }
2133 
2134  friend class OpenNI;
2137  };
2138 
2145  {
2146  return (Status)oniInitialize(ONI_API_VERSION); // provide version of API, to make sure proper struct sizes are used
2147  }
2148 
2153  static void shutdown()
2154  {
2155  oniShutdown();
2156  }
2157 
2162  {
2163  OniVersion oniVersion = oniGetVersion();
2164  Version version;
2165  version.major = oniVersion.major;
2166  version.minor = oniVersion.minor;
2167  version.maintenance = oniVersion.maintenance;
2168  version.build = oniVersion.build;
2169  return version;
2170  }
2171 
2179  static const char* getExtendedError()
2180  {
2181  return oniGetExtendedError();
2182  }
2183 
2188  static void enumerateDevices(Array<DeviceInfo>* deviceInfoList)
2189  {
2190  OniDeviceInfo* m_pDeviceInfos;
2191  int m_deviceInfoCount;
2192  oniGetDeviceList(&m_pDeviceInfos, &m_deviceInfoCount);
2193  deviceInfoList->_setData((DeviceInfo*)m_pDeviceInfos, m_deviceInfoCount, true);
2194  oniReleaseDeviceList(m_pDeviceInfos);
2195  }
2196 
2205  static Status waitForAnyStream(VideoStream** pStreams, int streamCount, int* pReadyStreamIndex, int timeout = TIMEOUT_FOREVER)
2206  {
2207  static const int ONI_MAX_STREAMS = 50;
2208  OniStreamHandle streams[ONI_MAX_STREAMS];
2209 
2210  if (streamCount > ONI_MAX_STREAMS)
2211  {
2212  printf("Too many streams for wait: %d > %d\n", streamCount, ONI_MAX_STREAMS);
2213  return STATUS_BAD_PARAMETER;
2214  }
2215 
2216  *pReadyStreamIndex = -1;
2217  for (int i = 0; i < streamCount; ++i)
2218  {
2219  if (pStreams[i] != NULL)
2220  {
2221  streams[i] = pStreams[i]->_getHandle();
2222  }
2223  else
2224  {
2225  streams[i] = NULL;
2226  }
2227  }
2228  Status rc = (Status)oniWaitForAnyStream(streams, streamCount, pReadyStreamIndex, timeout);
2229 
2230  return rc;
2231  }
2232 
2241  {
2242  if (pListener->m_deviceConnectedCallbacksHandle != NULL)
2243  {
2244  return STATUS_ERROR;
2245  }
2247  }
2256  {
2257  if (pListener->m_deviceDisconnectedCallbacksHandle != NULL)
2258  {
2259  return STATUS_ERROR;
2260  }
2262  }
2271  {
2272  if (pListener->m_deviceStateChangedCallbacksHandle != NULL)
2273  {
2274  return STATUS_ERROR;
2275  }
2277  }
2286  {
2288  pListener->m_deviceConnectedCallbacksHandle = NULL;
2289  }
2298  {
2300  pListener->m_deviceDisconnectedCallbacksHandle = NULL;
2301  }
2310  {
2312  pListener->m_deviceStateChangedCallbacksHandle = NULL;
2313  }
2314 
2323  static Status setLogOutputFolder(const char *strLogOutputFolder)
2324  {
2325  return (Status)oniSetLogOutputFolder(strLogOutputFolder);
2326  }
2327 
2337  static Status getLogFileName(char *strFileName, int nBufferSize)
2338  {
2339  return (Status)oniGetLogFileName(strFileName, nBufferSize);
2340  }
2341 
2350  static Status setLogMinSeverity(int nMinSeverity)
2351  {
2352  return(Status) oniSetLogMinSeverity(nMinSeverity);
2353  }
2354 
2363  static Status setLogConsoleOutput(bool bConsoleOutput)
2364  {
2365  return (Status)oniSetLogConsoleOutput(bConsoleOutput);
2366  }
2367 
2376  static Status setLogFileOutput(bool bFileOutput)
2377  {
2378  return (Status)oniSetLogFileOutput(bFileOutput);
2379  }
2380 
2381  #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM
2382 
2391  static Status setLogAndroidOutput(bool bAndroidOutput)
2392  {
2393  return (Status)oniSetLogAndroidOutput(bAndroidOutput);
2394  }
2395  #endif
2396 
2397 private:
2399  {
2400  }
2401 };
2402 
2439 {
2440 public:
2451  static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, int* pDepthX, int* pDepthY, DepthPixel* pDepthZ)
2452  {
2453  float depthX, depthY, depthZ;
2454  Status rc = (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, &depthX, &depthY, &depthZ);
2455  *pDepthX = (int)depthX;
2456  *pDepthY = (int)depthY;
2457  *pDepthZ = (DepthPixel)depthZ;
2458  return rc;
2459  }
2460 
2471  static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ)
2472  {
2473  return (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, pDepthX, pDepthY, pDepthZ);
2474  }
2475 
2486  static Status convertDepthToWorld(const VideoStream& depthStream, int depthX, int depthY, DepthPixel depthZ, float* pWorldX, float* pWorldY, float* pWorldZ)
2487  {
2488  return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), float(depthX), float(depthY), float(depthZ), pWorldX, pWorldY, pWorldZ);
2489  }
2490 
2501  static Status convertDepthToWorld(const VideoStream& depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ)
2502  {
2503  return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), depthX, depthY, depthZ, pWorldX, pWorldY, pWorldZ);
2504  }
2505 
2517  static Status convertDepthToColor(const VideoStream& depthStream, const VideoStream& colorStream, int depthX, int depthY, DepthPixel depthZ, int* pColorX, int* pColorY)
2518  {
2519  return (Status)oniCoordinateConverterDepthToColor(depthStream._getHandle(), colorStream._getHandle(), depthX, depthY, depthZ, pColorX, pColorY);
2520  }
2521 
2522  static Status convertC2DCoordinateByIntrinsic(const VideoStream& depthStream, int colorX, int colorY, DepthPixel depthZ, int* pDepthX, int* pDepthY)
2523  {
2524  return (Status)oniCoordinateConverterC2D(depthStream._getHandle(), colorX, colorY, depthZ, pDepthX, pDepthY);
2525  }
2526  static Status convertD2CCoordinateByIntrinsic(const VideoStream& depthStream, int depthX, int depthY, DepthPixel depthZ, int* pColorX, int* pColorY)
2527  {
2528  return (Status)oniCoordinateConverterD2C(depthStream._getHandle(), depthX, depthY, depthZ, pColorX, pColorY);
2529  }
2530 };
2531 
2547 {
2548 public:
2553  Recorder() : m_recorder(NULL)
2554  {
2555  }
2556 
2561  {
2562  destroy();
2563  }
2564 
2576  Status create(const char* fileName)
2577  {
2578  if (!isValid())
2579  {
2580  return (Status)oniCreateRecorder(fileName, &m_recorder);
2581  }
2582  return STATUS_ERROR;
2583  }
2584 
2591  bool isValid() const
2592  {
2593  return NULL != getHandle();
2594  }
2595 
2606  Status attach(VideoStream& stream, bool allowLossyCompression = false)
2607  {
2608  if (!isValid() || !stream.isValid())
2609  {
2610  return STATUS_ERROR;
2611  }
2613  m_recorder,
2614  stream._getHandle(),
2615  allowLossyCompression);
2616  }
2617 
2625  {
2626  if (!isValid())
2627  {
2628  return STATUS_ERROR;
2629  }
2630  return (Status)oniRecorderStart(m_recorder);
2631  }
2632 
2636  void stop()
2637  {
2638  if (isValid())
2639  {
2640  oniRecorderStop(m_recorder);
2641  }
2642  }
2643 
2647  void destroy()
2648  {
2649  if (isValid())
2650  {
2651  oniRecorderDestroy(&m_recorder);
2652  }
2653  }
2654 
2655 private:
2656  Recorder(const Recorder&);
2657  Recorder& operator=(const Recorder&);
2658 
2663  {
2664  return m_recorder;
2665  }
2666 
2667 
2669 };
2670 
2671 // Implemetation
2672 Status VideoStream::create(const Device& device, SensorType sensorType)
2673 {
2674  OniStreamHandle streamHandle;
2675  Status rc = (Status)oniDeviceCreateStream(device._getHandle(), (OniSensorType)sensorType, &streamHandle);
2676  if (rc != STATUS_OK)
2677  {
2678  return rc;
2679  }
2680 
2681  m_isOwner = true;
2682  _setHandle(streamHandle);
2683 
2684  if (isPropertySupported(STREAM_PROPERTY_AUTO_WHITE_BALANCE) && isPropertySupported(STREAM_PROPERTY_AUTO_EXPOSURE))
2685  {
2686  m_pCameraSettings = new CameraSettings(this);
2687  }
2688 
2689  return STATUS_OK;
2690 }
2691 
2693 {
2694  if (!isValid())
2695  {
2696  return;
2697  }
2698 
2699  if (m_pCameraSettings != NULL)
2700  {
2701  delete m_pCameraSettings;
2702  m_pCameraSettings = NULL;
2703  }
2704 
2705  if (m_stream != NULL)
2706  {
2707  if(m_isOwner)
2708  oniStreamDestroy(m_stream);
2709  m_stream = NULL;
2710  }
2711 }
2712 
2713 Status Device::open(const char* uri)
2714 {
2715  //If we are not the owners, we stick with our own device
2716  if(!m_isOwner)
2717  {
2718  if(isValid()){
2719  return STATUS_OK;
2720  }else{
2721  return STATUS_OUT_OF_FLOW;
2722  }
2723  }
2724 
2725  OniDeviceHandle deviceHandle;
2726  Status rc = (Status)oniDeviceOpen(uri, &deviceHandle);
2727  if (rc != STATUS_OK)
2728  {
2729  return rc;
2730  }
2731 
2732  _setHandle(deviceHandle);
2733 
2734  return STATUS_OK;
2735 }
2736 
2737 Status Device::_openEx(const char* uri, const char* mode)
2738 {
2739  //If we are not the owners, we stick with our own device
2740  if(!m_isOwner)
2741  {
2742  if(isValid()){
2743  return STATUS_OK;
2744  }else{
2745  return STATUS_OUT_OF_FLOW;
2746  }
2747  }
2748 
2749  OniDeviceHandle deviceHandle;
2750  Status rc = (Status)oniDeviceOpenEx(uri, mode, &deviceHandle);
2751  if (rc != STATUS_OK)
2752  {
2753  return rc;
2754  }
2755 
2756  _setHandle(deviceHandle);
2757 
2758  return STATUS_OK;
2759 }
2760 
2762 {
2763  if (m_device == NULL)
2764  {
2765  m_device = deviceHandle;
2766 
2767  clearSensors();
2768 
2769  oniDeviceGetInfo(m_device, &m_deviceInfo);
2770 
2771  if (isFile())
2772  {
2773  m_pPlaybackControl = new PlaybackControl(this);
2774  }
2775 
2776  // Read deviceInfo
2777  return STATUS_OK;
2778  }
2779 
2780  return STATUS_OUT_OF_FLOW;
2781 }
2782 
2784 {
2785  if (m_pPlaybackControl != NULL)
2786  {
2787  delete m_pPlaybackControl;
2788  m_pPlaybackControl = NULL;
2789  }
2790 
2791  if (m_device != NULL)
2792  {
2793  if(m_isOwner)
2794  {
2795  oniDeviceClose(m_device);
2796  }
2797 
2798  m_device = NULL;
2799  }
2800 }
2801 
2802 }
2803 
2804 #endif // OPENNI_H
VideoStream * m_pStream
Definition: OpenNI.h:1967
Status create(const Device &device, SensorType sensorType)
Definition: OpenNI.h:2672
static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void *pCookie)
Definition: OpenNI.h:695
static void ONI_CALLBACK_TYPE deviceStateChangedCallback(const OniDeviceInfo *pInfo, OniDeviceState state, void *pCookie)
Definition: OpenNI.h:2128
ONI_C_API const char * oniGetExtendedError()
ONI_C_API OniStatus oniCoordinateConverterWorldToDepth(OniStreamHandle depthStream, float worldX, float worldY, float worldZ, float *pDepthX, float *pDepthY, float *pDepthZ)
int getCropOriginX() const
Definition: OpenNI.h:569
Status setVideoMode(const VideoMode &videoMode)
Definition: OpenNI.h:989
ONI_C_API OniStatus oniDeviceGetInfo(OniDeviceHandle device, OniDeviceInfo *pInfo)
struct OniCallbackHandleImpl * OniCallbackHandle
Definition: OniCTypes.h:41
OniImageRegistrationMode
Definition: OniCEnums.h:72
ONI_C_API void oniStreamStop(OniStreamHandle stream)
const DeviceInfo & getDeviceInfo() const
Definition: OpenNI.h:1359
ONI_C_API OniStatus oniRecorderStart(OniRecorderHandle recorder)
bool isCommandSupported(int commandId) const
Definition: OpenNI.h:1663
static Status convertDepthToWorld(const VideoStream &depthStream, int depthX, int depthY, DepthPixel depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Definition: OpenNI.h:2486
SensorType getSensorType() const
Definition: OpenNI.h:339
ONI_C_API OniStatus oniCoordinateConverterD2C(OniStreamHandle depthStream, int colorX, int colorY, OniDepthPixel depthZ, int *pDepthX, int *pDepthY)
DeviceState
Definition: OniEnums.h:67
Status setFrameBuffersAllocator(FrameAllocator *pAllocator)
Definition: OpenNI.h:896
ONI_C_API OniStatus oniStreamReadFrame(OniStreamHandle stream, OniFrame **pFrame)
ONI_C_API const OniSensorInfo * oniStreamGetSensorInfo(OniStreamHandle stream)
int getNumberOfFrames(const VideoStream &stream) const
Definition: OpenNI.h:1842
const SensorInfo & getSensorInfo() const
Definition: OpenNI.h:789
PixelFormat
Definition: OniEnums.h:50
void setFps(int fps)
Definition: OpenNI.h:308
Array< VideoMode > m_videoModes
Definition: OpenNI.h:375
OniDeviceHandle m_device
Definition: OpenNI.h:1688
#define FALSE
Definition: OniCTypes.h:34
bool getAutoExposureEnabled() const
Definition: OpenNI.h:1900
int numSupportedVideoModes
Definition: OniCTypes.h:71
ONI_C_API OniStatus oniDeviceOpen(const char *uri, OniDeviceHandle *pDevice)
ONI_C_API OniStatus oniDeviceOpenEx(const char *uri, const char *mode, OniDeviceHandle *pDevice)
bool isPropertySupported(int propertyId) const
Definition: OpenNI.h:1176
bool getCropping(int *pOriginX, int *pOriginY, int *pWidth, int *pHeight) const
Definition: OpenNI.h:1043
bool m_isOwner
Definition: OpenNI.h:1692
Status setAutoWhiteBalanceEnabled(bool enabled)
Definition: OpenNI.h:1895
OniCallbackHandle m_deviceConnectedCallbacksHandle
Definition: OpenNI.h:2038
Status create(const char *fileName)
Definition: OpenNI.h:2576
ONI_C_API OniStatus oniStreamGetProperty(OniStreamHandle stream, int propertyId, void *data, int *pDataSize)
ONI_C_API OniStatus oniDeviceCreateStream(OniDeviceHandle device, OniSensorType sensorType, OniStreamHandle *pStream)
ONI_C_API OniStatus oniDeviceInvoke(OniDeviceHandle device, int commandId, void *data, int dataSize)
Array(const T *data, int count)
Definition: OpenNI.h:133
int getResolutionY() const
Definition: OpenNI.h:273
ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void *data, int dataSize)
OniStreamHandle m_stream
Definition: OpenNI.h:1257
const SensorInfo * getSensorInfo(SensorType sensorType)
Definition: OpenNI.h:1406
int getWidth() const
Definition: OpenNI.h:541
static void ONI_CALLBACK_TYPE deviceConnectedCallback(const OniDeviceInfo *pInfo, void *pCookie)
Definition: OpenNI.h:2030
Status attach(VideoStream &stream, bool allowLossyCompression=false)
Definition: OpenNI.h:2606
struct _OniRecorder * OniRecorderHandle
Definition: OniCTypes.h:103
OniFrame * _getFrame()
Definition: OpenNI.h:625
ONI_C_API OniStatus oniStreamRegisterNewFrameCallback(OniStreamHandle stream, OniNewFrameCallback handler, void *pCookie, OniCallbackHandle *pHandle)
unsigned short uint16_t
bool isValid() const
Definition: OpenNI.h:1853
Status invoke(int commandId, T &value)
Definition: OpenNI.h:1215
ONI_C_API OniBool oniDeviceIsCommandSupported(OniDeviceHandle device, int commandId)
ONI_C_API OniBool oniDeviceGetDepthColorSyncEnabled(OniDeviceHandle device)
virtual void onDeviceConnected(const DeviceInfo *)=0
CameraSettings * m_pCameraSettings
Definition: OpenNI.h:1259
Status invoke(int propertyId, T &value)
Definition: OpenNI.h:1653
int OniBool
Definition: OniCTypes.h:28
ONI_C_API OniStatus oniDeviceEnableDepthColorSync(OniDeviceHandle device)
Status invoke(int commandId, void *data, int dataSize)
Definition: OpenNI.h:1638
unsigned __int64 uint64_t
ONI_C_API OniStatus oniSetLogConsoleOutput(OniBool bConsoleOutput)
OniDeviceCallbacks m_deviceConnectedCallbacks
Definition: OpenNI.h:2037
const void * getData() const
Definition: OpenNI.h:480
void removeNewFrameListener(NewFrameListener *pListener)
Definition: OpenNI.h:880
virtual void onDeviceDisconnected(const DeviceInfo *)=0
OniDeviceState
Definition: OniCEnums.h:64
VideoMode getVideoMode() const
Definition: OpenNI.h:974
Status setExposure(int exposure)
Definition: OpenNI.h:1919
ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, void *data, int *pDataSize)
OniStreamHandle stream
Definition: OniCTypes.h:219
static Status waitForAnyStream(VideoStream **pStreams, int streamCount, int *pReadyStreamIndex, int timeout=TIMEOUT_FOREVER)
Definition: OpenNI.h:2205
bool getCroppingEnabled() const
Definition: OpenNI.h:560
ONI_C_API OniStatus oniGetLogFileName(char *strFileName, int nBufferSize)
static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void *data, void *pCookie)
Definition: OpenNI.h:722
bool getAutoWhiteBalanceEnabled() const
Definition: OpenNI.h:1907
static Status addDeviceConnectedListener(DeviceConnectedListener *pListener)
Definition: OpenNI.h:2240
int getMinPixelValue() const
Definition: OpenNI.h:1015
ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream)
static void enumerateDevices(Array< DeviceInfo > *deviceInfoList)
Definition: OpenNI.h:2188
static Version getVersion()
Definition: OpenNI.h:2161
PlaybackControl(Device *pDevice)
Definition: OpenNI.h:1876
bool isCommandSupported(int commandId) const
Definition: OpenNI.h:1225
ONI_C_API void oniShutdown()
static void *ONI_CALLBACK_TYPE allocateFrameBufferCallback(int size, void *pCookie)
Definition: OpenNI.h:716
SensorType
Definition: OniEnums.h:41
static Status setLogOutputFolder(const char *strLogOutputFolder)
Definition: OpenNI.h:2323
ONI_C_API OniStatus oniCreateRecorder(const char *fileName, OniRecorderHandle *pRecorder)
int frameIndex
Definition: OniCTypes.h:218
const T & operator[](int index) const
Definition: OpenNI.h:152
void _setHandle(OniStreamHandle stream)
Definition: OpenNI.h:1242
const char * getVendor() const
Definition: OpenNI.h:399
unsigned char uint8_t
ONI_C_API OniStatus oniDeviceClose(OniDeviceHandle device)
Status setRepeatEnabled(bool repeat)
Definition: OpenNI.h:1802
Status setGain(int gain)
Definition: OpenNI.h:1915
int getFps() const
Definition: OpenNI.h:279
ONI_C_API void oniUnregisterDeviceCallbacks(OniCallbackHandle handle)
int m_count
Definition: OpenNI.h:194
static void removeDeviceConnectedListener(DeviceConnectedListener *pListener)
Definition: OpenNI.h:2285
bool isValid() const
Definition: OpenNI.h:1542
void _setFrame(OniFrame *pFrame)
Definition: OpenNI.h:615
ONI_C_API OniStatus oniStreamSetProperty(OniStreamHandle stream, int propertyId, const void *data, int dataSize)
Status seek(const VideoStream &stream, int frameIndex)
Definition: OpenNI.h:1822
ONI_C_API void oniStreamDestroy(OniStreamHandle stream)
Status
Definition: OniEnums.h:28
static Status addDeviceStateChangedListener(DeviceStateChangedListener *pListener)
Definition: OpenNI.h:2270
ImageRegistrationMode getImageRegistrationMode() const
Definition: OpenNI.h:1509
void setGain(int gain)
Definition: OpenNI.h:1480
uint16_t getUsbVendorId() const
Definition: OpenNI.h:403
ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId)
ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId)
CameraSettings * getCameraSettings()
Definition: OpenNI.h:926
ImageRegistrationMode
Definition: OniEnums.h:75
CameraSettings(VideoStream *pStream)
Definition: OpenNI.h:1962
virtual void onDeviceStateChanged(const DeviceInfo *, DeviceState)=0
Status invoke(int commandId, void *data, int dataSize)
Definition: OpenNI.h:1195
virtual void onNewFrame(VideoStream &)=0
int getSize() const
Definition: OpenNI.h:147
int minor
Definition: OniCTypes.h:49
ONI_C_API OniVersion oniGetVersion()
OniCallbackHandle m_deviceDisconnectedCallbacksHandle
Definition: OpenNI.h:2090
Status getProperty(int propertyId, void *data, int *dataSize) const
Definition: OpenNI.h:1459
static Status setLogMinSeverity(int nMinSeverity)
Definition: OpenNI.h:2350
static Status initialize()
Definition: OpenNI.h:2144
OniVideoMode * pSupportedVideoModes
Definition: OniCTypes.h:72
void close()
Definition: OpenNI.h:2783
uint16_t DepthPixel
Definition: OpenNI.h:39
Status setProperty(int propertyId, const T &value)
Definition: OpenNI.h:1598
OniCallbackHandle m_callbackHandle
Definition: OpenNI.h:703
OniSensorType
Definition: OniCEnums.h:38
ParamsRegistrationMode getSoftwareRegistratorMode()
Definition: OpenNI.h:794
ONI_C_API OniStatus oniDeviceSetProperty(OniDeviceHandle device, int propertyId, const void *data, int dataSize)
bool isCroppingSupported() const
Definition: OpenNI.h:1030
ONI_C_API void oniStreamUnregisterNewFrameCallback(OniStreamHandle stream, OniCallbackHandle handle)
#define TRUE
Definition: OniCTypes.h:31
int maintenance
Definition: OniCTypes.h:51
Status setCropping(int originX, int originY, int width, int height)
Definition: OpenNI.h:1071
VideoMode & operator=(const VideoMode &other)
Definition: OpenNI.h:248
static void removeDeviceStateChangedListener(DeviceStateChangedListener *pListener)
Definition: OpenNI.h:2309
VideoMode(const VideoMode &other)
Definition: OpenNI.h:237
ONI_C_API OniStatus oniReleaseDeviceList(OniDeviceInfo *pDevices)
ONI_C_API OniStatus oniRecorderAttachStream(OniRecorderHandle recorder, OniStreamHandle stream, OniBool allowLossyCompression)
static void ONI_CALLBACK_TYPE deviceDisconnectedCallback(const OniDeviceInfo *pInfo, void *pCookie)
Definition: OpenNI.h:2082
static void removeDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
Definition: OpenNI.h:2297
static const char * getExtendedError()
Definition: OpenNI.h:2179
bool m_owner
Definition: OpenNI.h:195
void _setData(const T *data, int count, bool isOwner=false)
Definition: OpenNI.h:164
int getGain()
Definition: OpenNI.h:1484
#define ONI_API_VERSION
Definition: OniVersion.h:41
Status setAutoExposureEnabled(bool enabled)
Definition: OpenNI.h:1891
Status setImageRegistrationMode(ImageRegistrationMode mode)
Definition: OpenNI.h:1533
static void shutdown()
Definition: OpenNI.h:2153
OniStreamHandle _getHandle() const
Definition: OpenNI.h:917
const T * m_data
Definition: OpenNI.h:193
Status open(const char *uri)
Definition: OpenNI.h:2713
float getHorizontalFieldOfView() const
Definition: OpenNI.h:1122
int getDataSize() const
Definition: OpenNI.h:470
ONI_C_API OniStatus oniCoordinateConverterDepthToWorld(OniStreamHandle depthStream, float depthX, float depthY, float depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Status resetCropping()
Definition: OpenNI.h:1086
Status setProperty(int propertyId, const void *data, int dataSize)
Definition: OpenNI.h:1475
int getFrameIndex() const
Definition: OpenNI.h:530
static const int TIMEOUT_FOREVER
Definition: OniEnums.h:89
const char * getUri() const
Definition: OpenNI.h:397
void _setInternal(const OniSensorInfo *pInfo)
Definition: OpenNI.h:361
Status _openEx(const char *uri, const char *mode)
Definition: OpenNI.h:2737
uint16_t Grayscale16Pixel
Definition: OpenNI.h:42
void destroy()
Definition: OpenNI.h:2647
VideoStream(OniStreamHandle handle)
Definition: OpenNI.h:740
ONI_C_API OniBool oniStreamIsCommandSupported(OniStreamHandle stream, int commandId)
virtual void * allocateFrameBuffer(int size)=0
ONI_C_API const OniSensorInfo * oniDeviceGetSensorInfo(OniDeviceHandle device, OniSensorType sensorType)
bool isFile() const
Definition: OpenNI.h:1551
OniRecorderHandle getHandle() const
Definition: OpenNI.h:2662
ONI_C_API OniBool oniDeviceIsImageRegistrationModeSupported(OniDeviceHandle device, OniImageRegistrationMode mode)
int build
Definition: OniCTypes.h:53
ONI_C_API OniStatus oniRegisterDeviceCallbacks(OniDeviceCallbacks *pCallbacks, void *pCookie, OniCallbackHandle *pHandle)
bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const
Definition: OpenNI.h:1497
void setResolution(int resolutionX, int resolutionY)
Definition: OpenNI.h:296
void setPixelFormat(PixelFormat format)
Definition: OpenNI.h:287
Status start()
Definition: OpenNI.h:812
const char * getName() const
Definition: OpenNI.h:401
ONI_C_API OniStatus oniInitialize(int apiVersion)
Status getProperty(int propertyId, T *value) const
Definition: OpenNI.h:1165
OniCallbackHandle m_deviceStateChangedCallbacksHandle
Definition: OpenNI.h:2136
ONI_C_API OniStatus oniCoordinateConverterC2D(OniStreamHandle depthStream, int colorX, int colorY, OniDepthPixel depthZ, int *pDepthX, int *pDepthY)
ONI_C_API void oniStreamfilter(OniStreamHandle stream, void *buf, int newVal, int maxSpeckleSize, int maxDiff)
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, float *pDepthX, float *pDepthY, float *pDepthZ)
Definition: OpenNI.h:2471
PlaybackControl * getPlaybackControl()
Definition: OpenNI.h:1446
float getSpeed() const
Definition: OpenNI.h:1742
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, int *pDepthX, int *pDepthY, DepthPixel *pDepthZ)
Definition: OpenNI.h:2451
int maintenance
Definition: OpenNI.h:53
Status _setHandle(OniDeviceHandle deviceHandle)
Definition: OpenNI.h:2761
bool isValid() const
Definition: OpenNI.h:2591
ONI_C_API void oniRecorderStop(OniRecorderHandle recorder)
DeviceInfo m_deviceInfo
Definition: OpenNI.h:1689
Status start()
Definition: OpenNI.h:2624
static Status convertC2DCoordinateByIntrinsic(const VideoStream &depthStream, int colorX, int colorY, DepthPixel depthZ, int *pDepthX, int *pDepthY)
Definition: OpenNI.h:2522
static Status setLogConsoleOutput(bool bConsoleOutput)
Definition: OpenNI.h:2363
bool isValid() const
Definition: OpenNI.h:596
float getVerticalFieldOfView() const
Definition: OpenNI.h:1133
static Status getLogFileName(char *strFileName, int nBufferSize)
Definition: OpenNI.h:2337
bool getRepeatEnabled() const
Definition: OpenNI.h:1777
OniDeviceCallbacks m_deviceDisconnectedCallbacks
Definition: OpenNI.h:2089
ONI_C_API OniStatus oniGetDeviceList(OniDeviceInfo **pDevices, int *pNumDevices)
Status readFrame(VideoFrameRef *pFrame)
Definition: OpenNI.h:845
ONI_C_API OniStatus oniRecorderDestroy(OniRecorderHandle *pRecorder)
Status setProperty(int propertyId, const T &value)
Definition: OpenNI.h:1954
#define ONI_CALLBACK_TYPE
ONI_C_API OniStatus oniSetLogOutputFolder(const char *strOutputFolder)
void clear()
Definition: OpenNI.h:184
OniDeviceCallbacks m_deviceStateChangedCallbacks
Definition: OpenNI.h:2135
ParamsRegistrationMode
Definition: OniEnums.h:81
void clearSensors()
Definition: OpenNI.h:1675
const Array< VideoMode > & getSupportedVideoModes() const
Definition: OpenNI.h:348
bool isValid() const
Definition: OpenNI.h:1944
OniFrame * m_pFrame
Definition: OpenNI.h:639
bool isPropertySupported(int propertyId) const
Definition: OpenNI.h:1624
PixelFormat getPixelFormat() const
Definition: OpenNI.h:261
bool getMirroringEnabled() const
Definition: OpenNI.h:1097
VideoFrameRef(const VideoFrameRef &other)
Definition: OpenNI.h:449
ONI_C_API void oniFrameAddRef(OniFrame *pFrame)
Device(OniDeviceHandle handle)
Definition: OpenNI.h:1295
void * getHandle(const std::string &name)
uint64_t getTimestamp() const
Definition: OpenNI.h:515
void setSoftwareRegistrator(ParamsRegistrationMode mode)
Definition: OpenNI.h:805
ONI_C_API OniStatus oniWaitForAnyStream(OniStreamHandle *pStreams, int numStreams, int *pStreamIndex, int timeout)
int getResolutionX() const
Definition: OpenNI.h:267
Status addNewFrameListener(NewFrameListener *pListener)
Definition: OpenNI.h:866
Status setProperty(int propertyId, const T &value)
Definition: OpenNI.h:1150
Status attach(Device *device)
Definition: OpenNI.h:1858
Status setSpeed(float speed)
Definition: OpenNI.h:1763
bool hasSensor(SensorType sensorType)
Definition: OpenNI.h:1371
virtual void freeFrameBuffer(void *data)=0
OniPixelFormat
Definition: OniCEnums.h:47
int major
Definition: OniCTypes.h:47
ONI_C_API OniStatus oniStreamSetFrameBuffersAllocator(OniStreamHandle stream, OniFrameAllocBufferCallback alloc, OniFrameFreeBufferCallback free, void *pCookie)
int getCropOriginY() const
Definition: OpenNI.h:578
Status getProperty(int propertyId, T *value) const
Definition: OpenNI.h:1947
int getStrideInBytes() const
Definition: OpenNI.h:588
Status setProperty(int propertyId, const void *data, int dataSize)
Definition: OpenNI.h:958
bool getDepthColorSyncEnabled()
Definition: OpenNI.h:1582
int getHeight() const
Definition: OpenNI.h:551
OniDeviceHandle _getHandle() const
Definition: OpenNI.h:1437
bool isValid() const
Definition: OpenNI.h:758
ONI_C_API OniStatus oniCoordinateConverterDepthToColor(OniStreamHandle depthStream, OniStreamHandle colorStream, int depthX, int depthY, OniDepthPixel depthZ, int *pColorX, int *pColorY)
int getMaxPixelValue() const
Definition: OpenNI.h:999
const OniSensorInfo * m_pInfo
Definition: OpenNI.h:374
#define ONI_MAX_SENSORS
Definition: OniCTypes.h:38
void setReference(OniFrame *pFrame)
Definition: OpenNI.h:632
static Status setLogFileOutput(bool bFileOutput)
Definition: OpenNI.h:2376
struct _OniDevice * OniDeviceHandle
Definition: OniCTypes.h:97
Status setMirroringEnabled(bool isEnabled)
Definition: OpenNI.h:1113
void filterSpeckles(void *buf, int newVal, int maxSpeckleSize, int maxDiff)
Definition: OpenNI.h:1235
PlaybackControl * m_pPlaybackControl
Definition: OpenNI.h:1686
SensorInfo m_sensorInfo
Definition: OpenNI.h:1258
void * pCookie
Definition: OniDriverAPI.h:35
SensorInfo(const OniSensorInfo *pInfo)
Definition: OpenNI.h:356
ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput)
Status getProperty(int propertyId, T *value) const
Definition: OpenNI.h:1613
ONI_C_API OniStatus oniSetLogMinSeverity(int nMinSeverity)
SensorType getSensorType() const
Definition: OpenNI.h:491
Status setDepthColorSyncEnabled(bool isEnabled)
Definition: OpenNI.h:1566
ONI_C_API void oniDeviceDisableDepthColorSync(OniDeviceHandle device)
static Status convertDepthToWorld(const VideoStream &depthStream, float depthX, float depthY, float depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Definition: OpenNI.h:2501
struct _OniStream * OniStreamHandle
Definition: OniCTypes.h:100
const VideoMode & getVideoMode() const
Definition: OpenNI.h:503
OniRecorderHandle m_recorder
Definition: OpenNI.h:2668
ONI_C_API void oniFrameRelease(OniFrame *pFrame)
uint16_t getUsbProductId() const
Definition: OpenNI.h:405
static Status convertDepthToColor(const VideoStream &depthStream, const VideoStream &colorStream, int depthX, int depthY, DepthPixel depthZ, int *pColorX, int *pColorY)
Definition: OpenNI.h:2517
static Status addDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
Definition: OpenNI.h:2255
VideoFrameRef & operator=(const VideoFrameRef &other)
Definition: OpenNI.h:459
static const _NullString ANY_DEVICE
Definition: OpenNI.h:111
static Status convertD2CCoordinateByIntrinsic(const VideoStream &depthStream, int depthX, int depthY, DepthPixel depthZ, int *pColorX, int *pColorY)
Definition: OpenNI.h:2526
Status getProperty(int propertyId, void *data, int *dataSize) const
Definition: OpenNI.h:938


astra_camera
Author(s): Tim Liu
autogenerated on Wed Dec 16 2020 03:54:34