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 
34 namespace openni
35 {
36 
39 
42 
43 // structs
45 typedef struct
46 {
48  int major;
50  int minor;
54  int build;
55 } Version;
56 
58 typedef struct
59 {
60  /* Red value of this pixel. */
62  /* Green value of this pixel. */
64  /* Blue value of this pixel. */
66 } RGB888Pixel;
67 
73 typedef struct
74 {
84 
86 #if ONI_PLATFORM != ONI_PLATFORM_WIN32
87 #pragma GCC diagnostic ignored "-Wunused-variable"
88 #pragma GCC diagnostic push
89 #endif
90 static const char* ANY_DEVICE = NULL;
91 #if ONI_PLATFORM != ONI_PLATFORM_WIN32
92 #pragma GCC diagnostic pop
93 #endif
94 
99 template<class T>
100 class Array
101 {
102 public:
106  Array() : m_data(NULL), m_count(0), m_owner(false) {}
107 
115  Array(const T* data, int count) : m_owner(false) { _setData(data, count); }
116 
121  {
122  clear();
123  }
124 
129  int getSize() const { return m_count; }
130 
134  const T& operator[](int index) const {return m_data[index];}
135 
146  void _setData(const T* data, int count, bool isOwner = false)
147  {
148  clear();
149  m_count = count;
150  m_owner = isOwner;
151  if (!isOwner)
152  {
153  m_data = data;
154  }
155  else
156  {
157  m_data = new T[count];
158  memcpy((void*)m_data, data, count*sizeof(T));
159  }
160  }
161 
162 private:
163  Array(const Array<T>&);
164  Array<T>& operator=(const Array<T>&);
165 
166  void clear()
167  {
168  if (m_owner && m_data != NULL)
169  delete []m_data;
170  m_owner = false;
171  m_data = NULL;
172  m_count = 0;
173  }
174 
175  const T* m_data;
176  int m_count;
177  bool m_owner;
178 };
179 
180 // Forward declaration of all
181 class SensorInfo;
182 class VideoStream;
183 class VideoFrameRef;
184 class Device;
185 class OpenNI;
186 class CameraSettings;
187 class PlaybackControl;
188 
203 class VideoMode : private OniVideoMode
204 {
205 public:
212  {}
213 
219  VideoMode(const VideoMode& other)
220  {
221  *this = other;
222  }
223 
231  {
232  setPixelFormat(other.getPixelFormat());
233  setResolution(other.getResolutionX(), other.getResolutionY());
234  setFps(other.getFps());
235 
236  return *this;
237  }
238 
243  PixelFormat getPixelFormat() const { return (PixelFormat)pixelFormat; }
244 
249  int getResolutionX() const { return resolutionX; }
250 
255  int getResolutionY() const {return resolutionY;}
256 
261  int getFps() const { return fps; }
262 
269  void setPixelFormat(PixelFormat format) { this->pixelFormat = (OniPixelFormat)format; }
270 
278  void setResolution(int resolutionX, int resolutionY)
279  {
280  this->resolutionX = resolutionX;
281  this->resolutionY = resolutionY;
282  }
283 
290  void setFps(int fps) { this->fps = fps; }
291 
292  friend class SensorInfo;
293  friend class VideoStream;
294  friend class VideoFrameRef;
295 };
296 
315 {
316 public:
321  SensorType getSensorType() const { return (SensorType)m_pInfo->sensorType; }
322 
330  const Array<VideoMode>& getSupportedVideoModes() const { return m_videoModes; }
331 
332 private:
333  SensorInfo(const SensorInfo&);
335 
336  SensorInfo() : m_pInfo(NULL), m_videoModes(NULL, 0) {}
337 
338  SensorInfo(const OniSensorInfo* pInfo) : m_pInfo(NULL), m_videoModes(NULL, 0)
339  {
340  _setInternal(pInfo);
341  }
342 
343  void _setInternal(const OniSensorInfo* pInfo)
344  {
345  m_pInfo = pInfo;
346  if (pInfo == NULL)
347  {
348  m_videoModes._setData(NULL, 0);
349  }
350  else
351  {
352  m_videoModes._setData(static_cast<VideoMode*>(pInfo->pSupportedVideoModes), pInfo->numSupportedVideoModes);
353  }
354  }
355 
358 
359  friend class VideoStream;
360  friend class Device;
361 };
362 
372 class DeviceInfo : private OniDeviceInfo
373 {
374 public:
379  const char* getUri() const { return uri; }
381  const char* getVendor() const { return vendor; }
383  const char* getName() const { return name; }
385  uint16_t getUsbVendorId() const { return usbVendorId; }
387  uint16_t getUsbProductId() const { return usbProductId; }
388 
389  friend class Device;
390  friend class OpenNI;
391 };
392 
407 {
408 public:
414  {
415  m_pFrame = NULL;
416  }
417 
422  {
423  release();
424  }
425 
431  VideoFrameRef(const VideoFrameRef& other) : m_pFrame(NULL)
432  {
433  _setFrame(other.m_pFrame);
434  }
435 
442  {
443  _setFrame(other.m_pFrame);
444  return *this;
445  }
446 
452  inline int getDataSize() const
453  {
454  return m_pFrame->dataSize;
455  }
456 
462  inline const void* getData() const
463  {
464  return m_pFrame->data;
465  }
466 
473  inline SensorType getSensorType() const
474  {
475  return (SensorType)m_pFrame->sensorType;
476  }
477 
485  inline const VideoMode& getVideoMode() const
486  {
487  return static_cast<const VideoMode&>(m_pFrame->videoMode);
488  }
489 
497  inline uint64_t getTimestamp() const
498  {
499  return m_pFrame->timestamp;
500  }
501 
512  inline int getFrameIndex() const
513  {
514  return m_pFrame->frameIndex;
515  }
516 
523  inline int getWidth() const
524  {
525  return m_pFrame->width;
526  }
527 
533  inline int getHeight() const
534  {
535  return m_pFrame->height;
536  }
537 
542  inline bool getCroppingEnabled() const
543  {
544  return m_pFrame->croppingEnabled == TRUE;
545  }
546 
551  inline int getCropOriginX() const
552  {
553  return m_pFrame->cropOriginX;
554  }
555 
560  inline int getCropOriginY() const
561  {
562  return m_pFrame->cropOriginY;
563  }
564 
570  inline int getStrideInBytes() const
571  {
572  return m_pFrame->stride;
573  }
574 
578  inline bool isValid() const
579  {
580  return m_pFrame != NULL;
581  }
582 
587  void release()
588  {
589  if (m_pFrame != NULL)
590  {
591  oniFrameRelease(m_pFrame);
592  m_pFrame = NULL;
593  }
594  }
595 
597  void _setFrame(OniFrame* pFrame)
598  {
599  setReference(pFrame);
600  if (pFrame != NULL)
601  {
602  oniFrameAddRef(pFrame);
603  }
604  }
605 
608  {
609  return m_pFrame;
610  }
611 
612 private:
613  friend class VideoStream;
614  inline void setReference(OniFrame* pFrame)
615  {
616  // Initial - don't addref. This is the reference from OpenNI
617  release();
618  m_pFrame = pFrame;
619  }
620 
621  OniFrame* m_pFrame; // const!!?
622 };
623 
646 {
647 public:
656  {
657  public:
661  NewFrameListener() : m_callbackHandle(NULL)
662  {
663  }
664 
666  {
667  }
668 
672  virtual void onNewFrame(VideoStream&) = 0;
673 
674  private:
675  friend class VideoStream;
676 
677  static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void* pCookie)
678  {
679  NewFrameListener* pListener = (NewFrameListener*)pCookie;
680  VideoStream stream;
681  stream._setHandle(streamHandle);
682  pListener->onNewFrame(stream);
683  stream._setHandle(NULL);
684  }
686  };
687 
689  {
690  public:
691  virtual ~FrameAllocator() {}
692  virtual void* allocateFrameBuffer(int size) = 0;
693  virtual void freeFrameBuffer(void* data) = 0;
694 
695  private:
696  friend class VideoStream;
697 
699  {
700  FrameAllocator* pThis = (FrameAllocator*)pCookie;
701  return pThis->allocateFrameBuffer(size);
702  }
703 
704  static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void* data, void* pCookie)
705  {
706  FrameAllocator* pThis = (FrameAllocator*)pCookie;
707  pThis->freeFrameBuffer(data);
708  }
709  };
710 
715  VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true)
716  {}
717 
722  explicit VideoStream(OniStreamHandle handle) : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(false)
723  {
724  _setHandle(handle);
725  }
726 
732  {
733  destroy();
734  }
735 
740  bool isValid() const
741  {
742  return m_stream != NULL;
743  }
744 
754  inline Status create(const Device& device, SensorType sensorType);
755 
761  inline void destroy();
762 
771  const SensorInfo& getSensorInfo() const
772  {
773  return m_sensorInfo;
774  }
775 
780  {
781  if (!isValid())
782  {
783  return STATUS_ERROR;
784  }
785 
786  return (Status)oniStreamStart(m_stream);
787  }
788 
792  void stop()
793  {
794  if (!isValid())
795  {
796  return;
797  }
798 
799  oniStreamStop(m_stream);
800  }
801 
813  {
814  if (!isValid())
815  {
816  return STATUS_ERROR;
817  }
818 
819  OniFrame* pOniFrame;
820  Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame);
821 
822  pFrame->setReference(pOniFrame);
823  return rc;
824  }
825 
834  {
835  if (!isValid())
836  {
837  return STATUS_ERROR;
838  }
839 
840  return (Status)oniStreamRegisterNewFrameCallback(m_stream, pListener->callback, pListener, &pListener->m_callbackHandle);
841  }
842 
848  {
849  if (!isValid())
850  {
851  return;
852  }
853 
855  pListener->m_callbackHandle = NULL;
856  }
857 
864  {
865  if (!isValid())
866  {
867  return STATUS_ERROR;
868  }
869 
870  if (pAllocator == NULL)
871  {
872  return (Status)oniStreamSetFrameBuffersAllocator(m_stream, NULL, NULL, NULL);
873  }
874  else
875  {
876  return (Status)oniStreamSetFrameBuffersAllocator(m_stream, pAllocator->allocateFrameBufferCallback, pAllocator->freeFrameBufferCallback, pAllocator);
877  }
878  }
879 
885  {
886  return m_stream;
887  }
888 
893  CameraSettings* getCameraSettings() {return m_pCameraSettings;}
894 
905  Status getProperty(int propertyId, void* data, int* dataSize) const
906  {
907  if (!isValid())
908  {
909  return STATUS_ERROR;
910  }
911 
912  return (Status)oniStreamGetProperty(m_stream, propertyId, data, dataSize);
913  }
914 
925  Status setProperty(int propertyId, const void* data, int dataSize)
926  {
927  if (!isValid())
928  {
929  return STATUS_ERROR;
930  }
931 
932  return (Status)oniStreamSetProperty(m_stream, propertyId, data, dataSize);
933  }
934 
942  {
943  VideoMode videoMode;
944  getProperty<OniVideoMode>(STREAM_PROPERTY_VIDEO_MODE, static_cast<OniVideoMode*>(&videoMode));
945  return videoMode;
946  }
947 
956  Status setVideoMode(const VideoMode& videoMode)
957  {
958  return setProperty<OniVideoMode>(STREAM_PROPERTY_VIDEO_MODE, static_cast<const OniVideoMode&>(videoMode));
959  }
960 
966  int getMaxPixelValue() const
967  {
968  int maxValue;
969  Status rc = getProperty<int>(STREAM_PROPERTY_MAX_VALUE, &maxValue);
970  if (rc != STATUS_OK)
971  {
972  return 0;
973  }
974  return maxValue;
975  }
976 
982  int getMinPixelValue() const
983  {
984  int minValue;
985  Status rc = getProperty<int>(STREAM_PROPERTY_MIN_VALUE, &minValue);
986  if (rc != STATUS_OK)
987  {
988  return 0;
989  }
990  return minValue;
991  }
992 
997  bool isCroppingSupported() const
998  {
999  return isPropertySupported(STREAM_PROPERTY_CROPPING);
1000  }
1001 
1010  bool getCropping(int* pOriginX, int* pOriginY, int* pWidth, int* pHeight) const
1011  {
1012  OniCropping cropping;
1013  bool enabled = false;
1014 
1015  Status rc = getProperty<OniCropping>(STREAM_PROPERTY_CROPPING, &cropping);
1016 
1017  if (rc == STATUS_OK)
1018  {
1019  *pOriginX = cropping.originX;
1020  *pOriginY = cropping.originY;
1021  *pWidth = cropping.width;
1022  *pHeight = cropping.height;
1023  enabled = (cropping.enabled == TRUE);
1024  }
1025 
1026  return enabled;
1027  }
1028 
1038  Status setCropping(int originX, int originY, int width, int height)
1039  {
1040  OniCropping cropping;
1041  cropping.enabled = true;
1042  cropping.originX = originX;
1043  cropping.originY = originY;
1044  cropping.width = width;
1045  cropping.height = height;
1046  return setProperty<OniCropping>(STREAM_PROPERTY_CROPPING, cropping);
1047  }
1048 
1054  {
1055  OniCropping cropping;
1056  cropping.enabled = false;
1057  return setProperty<OniCropping>(STREAM_PROPERTY_CROPPING, cropping);
1058  }
1059 
1064  bool getMirroringEnabled() const
1065  {
1066  OniBool enabled;
1067  Status rc = getProperty<OniBool>(STREAM_PROPERTY_MIRRORING, &enabled);
1068  if (rc != STATUS_OK)
1069  {
1070  return false;
1071  }
1072  return enabled == TRUE;
1073  }
1074 
1080  Status setMirroringEnabled(bool isEnabled)
1081  {
1082  return setProperty<OniBool>(STREAM_PROPERTY_MIRRORING, isEnabled ? TRUE : FALSE);
1083  }
1084 
1090  {
1091  float horizontal = 0;
1092  getProperty<float>(STREAM_PROPERTY_HORIZONTAL_FOV, &horizontal);
1093  return horizontal;
1094  }
1095 
1101  {
1102  float vertical = 0;
1103  getProperty<float>(STREAM_PROPERTY_VERTICAL_FOV, &vertical);
1104  return vertical;
1105  }
1106 
1116  template <class T>
1117  Status setProperty(int propertyId, const T& value)
1118  {
1119  return setProperty(propertyId, &value, sizeof(T));
1120  }
1121 
1131  template <class T>
1132  Status getProperty(int propertyId, T* value) const
1133  {
1134  int size = sizeof(T);
1135  return getProperty(propertyId, value, &size);
1136  }
1137 
1143  bool isPropertySupported(int propertyId) const
1144  {
1145  if (!isValid())
1146  {
1147  return false;
1148  }
1149 
1150  return oniStreamIsPropertySupported(m_stream, propertyId) == TRUE;
1151  }
1152 
1162  Status invoke(int commandId, void* data, int dataSize)
1163  {
1164  if (!isValid())
1165  {
1166  return STATUS_ERROR;
1167  }
1168 
1169  return (Status)oniStreamInvoke(m_stream, commandId, data, dataSize);
1170  }
1171 
1181  template <class T>
1182  Status invoke(int commandId, T& value)
1183  {
1184  return invoke(commandId, &value, sizeof(T));
1185  }
1186 
1192  bool isCommandSupported(int commandId) const
1193  {
1194  if (!isValid())
1195  {
1196  return false;
1197  }
1198 
1199  return (Status)oniStreamIsCommandSupported(m_stream, commandId) == TRUE;
1200  }
1201 
1202 private:
1203  friend class Device;
1204 
1206  {
1207  m_sensorInfo._setInternal(NULL);
1208  m_stream = stream;
1209 
1210  if (stream != NULL)
1211  {
1212  m_sensorInfo._setInternal(oniStreamGetSensorInfo(m_stream));
1213  }
1214  }
1215 
1216 private:
1217  VideoStream(const VideoStream& other);
1218  VideoStream& operator=(const VideoStream& other);
1219 
1224 };
1225 
1242 class Device
1243 {
1244 public:
1249  Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true)
1250  {
1251  clearSensors();
1252  }
1253 
1258  explicit Device(OniDeviceHandle handle) : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(false)
1259  {
1260  _setHandle(handle);
1261  }
1262 
1268  {
1269  if (m_device != NULL)
1270  {
1271  close();
1272  }
1273  }
1274 
1304  inline Status open(const char* uri);
1305 
1311  inline void close();
1312 
1322  const DeviceInfo& getDeviceInfo() const
1323  {
1324  return m_deviceInfo;
1325  }
1326 
1334  bool hasSensor(SensorType sensorType)
1335  {
1336  int i;
1337  for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1338  {
1339  if (m_aSensorInfo[i].getSensorType() == sensorType)
1340  {
1341  return true;
1342  }
1343  }
1344 
1345  if (i == ONI_MAX_SENSORS)
1346  {
1347  return false;
1348  }
1349 
1350  const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType);
1351 
1352  if (pInfo == NULL)
1353  {
1354  return false;
1355  }
1356 
1357  m_aSensorInfo[i]._setInternal(pInfo);
1358 
1359  return true;
1360  }
1361 
1370  {
1371  int i;
1372  for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1373  {
1374  if (m_aSensorInfo[i].getSensorType() == sensorType)
1375  {
1376  return &m_aSensorInfo[i];
1377  }
1378  }
1379 
1380  // not found. check to see we have additional space
1381  if (i == ONI_MAX_SENSORS)
1382  {
1383  return NULL;
1384  }
1385 
1386  const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType);
1387  if (pInfo == NULL)
1388  {
1389  return NULL;
1390  }
1391 
1392  m_aSensorInfo[i]._setInternal(pInfo);
1393  return &m_aSensorInfo[i];
1394  }
1395 
1401  {
1402  return m_device;
1403  }
1404 
1409  PlaybackControl* getPlaybackControl() {return m_pPlaybackControl;}
1410 
1422  Status getProperty(int propertyId, void* data, int* dataSize) const
1423  {
1424  return (Status)oniDeviceGetProperty(m_device, propertyId, data, dataSize);
1425  }
1426 
1438  Status setProperty(int propertyId, const void* data, int dataSize)
1439  {
1440  return (Status)oniDeviceSetProperty(m_device, propertyId, data, dataSize);
1441  }
1442 
1451  {
1453  }
1454 
1463  {
1464  ImageRegistrationMode mode;
1465  Status rc = getProperty<ImageRegistrationMode>(DEVICE_PROPERTY_IMAGE_REGISTRATION, &mode);
1466  if (rc != STATUS_OK)
1467  {
1468  return IMAGE_REGISTRATION_OFF;
1469  }
1470  return mode;
1471  }
1472 
1487  {
1488  return setProperty<ImageRegistrationMode>(DEVICE_PROPERTY_IMAGE_REGISTRATION, mode);
1489  }
1490 
1495  bool isValid() const
1496  {
1497  return m_device != NULL;
1498  }
1499 
1504  bool isFile() const
1505  {
1506  return isPropertySupported(DEVICE_PROPERTY_PLAYBACK_SPEED) &&
1507  isPropertySupported(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED) &&
1508  isCommandSupported(DEVICE_COMMAND_SEEK);
1509  }
1510 
1520  {
1521  Status rc = STATUS_OK;
1522 
1523  if (isEnabled)
1524  {
1525  rc = (Status)oniDeviceEnableDepthColorSync(m_device);
1526  }
1527  else
1528  {
1530  }
1531 
1532  return rc;
1533  }
1534 
1536  {
1537  return oniDeviceGetDepthColorSyncEnabled(m_device) == TRUE;
1538  }
1539 
1550  template <class T>
1551  Status setProperty(int propertyId, const T& value)
1552  {
1553  return setProperty(propertyId, &value, sizeof(T));
1554  }
1555 
1565  template <class T>
1566  Status getProperty(int propertyId, T* value) const
1567  {
1568  int size = sizeof(T);
1569  return getProperty(propertyId, value, &size);
1570  }
1571 
1577  bool isPropertySupported(int propertyId) const
1578  {
1579  return oniDeviceIsPropertySupported(m_device, propertyId) == TRUE;
1580  }
1581 
1591  Status invoke(int commandId, void* data, int dataSize)
1592  {
1593  return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize);
1594  }
1595 
1605  template <class T>
1606  Status invoke(int propertyId, T& value)
1607  {
1608  return invoke(propertyId, &value, sizeof(T));
1609  }
1610 
1616  bool isCommandSupported(int commandId) const
1617  {
1618  return oniDeviceIsCommandSupported(m_device, commandId) == TRUE;
1619  }
1620 
1622  inline Status _openEx(const char* uri, const char* mode);
1623 
1624 private:
1625  Device(const Device&);
1626  Device& operator=(const Device&);
1627 
1629  {
1630  for (int i = 0; i < ONI_MAX_SENSORS; ++i)
1631  {
1632  m_aSensorInfo[i]._setInternal(NULL);
1633  }
1634  }
1635 
1636  inline Status _setHandle(OniDeviceHandle deviceHandle);
1637 
1638 private:
1640 
1643  SensorInfo m_aSensorInfo[ONI_MAX_SENSORS];
1644 
1646 };
1647 
1662 {
1663 public:
1664 
1671  {
1672  detach();
1673  }
1674 
1695  float getSpeed() const
1696  {
1697  if (!isValid())
1698  {
1699  return 0.0f;
1700  }
1701  float speed;
1702  Status rc = m_pDevice->getProperty<float>(DEVICE_PROPERTY_PLAYBACK_SPEED, &speed);
1703  if (rc != STATUS_OK)
1704  {
1705  return 1.0f;
1706  }
1707  return speed;
1708  }
1716  Status setSpeed(float speed)
1717  {
1718  if (!isValid())
1719  {
1720  return STATUS_NO_DEVICE;
1721  }
1722  return m_pDevice->setProperty<float>(DEVICE_PROPERTY_PLAYBACK_SPEED, speed);
1723  }
1724 
1730  bool getRepeatEnabled() const
1731  {
1732  if (!isValid())
1733  {
1734  return false;
1735  }
1736 
1737  OniBool repeat;
1738  Status rc = m_pDevice->getProperty<OniBool>(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, &repeat);
1739  if (rc != STATUS_OK)
1740  {
1741  return false;
1742  }
1743 
1744  return repeat == TRUE;
1745  }
1746 
1756  {
1757  if (!isValid())
1758  {
1759  return STATUS_NO_DEVICE;
1760  }
1761 
1762  return m_pDevice->setProperty<OniBool>(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, repeat ? TRUE : FALSE);
1763  }
1764 
1775  Status seek(const VideoStream& stream, int frameIndex)
1776  {
1777  if (!isValid())
1778  {
1779  return STATUS_NO_DEVICE;
1780  }
1781  OniSeek seek;
1782  seek.frameIndex = frameIndex;
1783  seek.stream = stream._getHandle();
1784  return m_pDevice->invoke(DEVICE_COMMAND_SEEK, seek);
1785  }
1786 
1795  int getNumberOfFrames(const VideoStream& stream) const
1796  {
1797  int numOfFrames = -1;
1798  Status rc = stream.getProperty<int>(STREAM_PROPERTY_NUMBER_OF_FRAMES, &numOfFrames);
1799  if (rc != STATUS_OK)
1800  {
1801  return 0;
1802  }
1803  return numOfFrames;
1804  }
1805 
1806  bool isValid() const
1807  {
1808  return m_pDevice != NULL;
1809  }
1810 private:
1812  {
1813  if (!device->isValid() || !device->isFile())
1814  {
1815  return STATUS_ERROR;
1816  }
1817 
1818  detach();
1819  m_pDevice = device;
1820 
1821  return STATUS_OK;
1822  }
1823  void detach()
1824  {
1825  m_pDevice = NULL;
1826  }
1827 
1828  friend class Device;
1829  PlaybackControl(Device* pDevice) : m_pDevice(NULL)
1830  {
1831  if (pDevice != NULL)
1832  {
1833  attach(pDevice);
1834  }
1835  }
1836 
1838 };
1839 
1841 {
1842 public:
1843  // setters
1845  {
1846  return setProperty(STREAM_PROPERTY_AUTO_EXPOSURE, enabled ? TRUE : FALSE);
1847  }
1849  {
1850  return setProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, enabled ? TRUE : FALSE);
1851  }
1852 
1854  {
1855  OniBool enabled = FALSE;
1856 
1857  Status rc = getProperty(STREAM_PROPERTY_AUTO_EXPOSURE, &enabled);
1858  return rc == STATUS_OK && enabled == TRUE;
1859  }
1861  {
1862  OniBool enabled = FALSE;
1863 
1864  Status rc = getProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, &enabled);
1865  return rc == STATUS_OK && enabled == TRUE;
1866  }
1867 
1868  Status setGain(int gain)
1869  {
1870  return setProperty(STREAM_PROPERTY_GAIN, gain);
1871  }
1872  Status setExposure(int exposure)
1873  {
1874  return setProperty(STREAM_PROPERTY_EXPOSURE, exposure);
1875  }
1876  int getGain()
1877  {
1878  int gain;
1879  Status rc = getProperty(STREAM_PROPERTY_GAIN, &gain);
1880  if (rc != STATUS_OK)
1881  {
1882  return 100;
1883  }
1884  return gain;
1885  }
1887  {
1888  int exposure;
1889  Status rc = getProperty(STREAM_PROPERTY_EXPOSURE, &exposure);
1890  if (rc != STATUS_OK)
1891  {
1892  return 0;
1893  }
1894  return exposure;
1895  }
1896 
1897  bool isValid() const {return m_pStream != NULL;}
1898 private:
1899  template <class T>
1900  Status getProperty(int propertyId, T* value) const
1901  {
1902  if (!isValid()) return STATUS_NOT_SUPPORTED;
1903 
1904  return m_pStream->getProperty<T>(propertyId, value);
1905  }
1906  template <class T>
1907  Status setProperty(int propertyId, const T& value)
1908  {
1909  if (!isValid()) return STATUS_NOT_SUPPORTED;
1910 
1911  return m_pStream->setProperty<T>(propertyId, value);
1912  }
1913 
1914  friend class VideoStream;
1916  {
1917  m_pStream = pStream;
1918  }
1919 
1921 };
1922 
1923 
1936 class OpenNI
1937 {
1938 public:
1939 
1956  {
1957  public:
1959  {
1960  m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback;
1961  m_deviceConnectedCallbacks.deviceDisconnected = NULL;
1962  m_deviceConnectedCallbacks.deviceStateChanged = NULL;
1963  m_deviceConnectedCallbacksHandle = NULL;
1964  }
1965 
1967  {
1968  }
1969 
1981  virtual void onDeviceConnected(const DeviceInfo*) = 0;
1982  private:
1984  {
1985  DeviceConnectedListener* pListener = (DeviceConnectedListener*)pCookie;
1986  pListener->onDeviceConnected(static_cast<const DeviceInfo*>(pInfo));
1987  }
1988 
1989  friend class OpenNI;
1992 
1993  };
2011  {
2012  public:
2014  {
2015  m_deviceDisconnectedCallbacks.deviceConnected = NULL;
2016  m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback;
2017  m_deviceDisconnectedCallbacks.deviceStateChanged = NULL;
2018  m_deviceDisconnectedCallbacksHandle = NULL;
2019  }
2020 
2022  {
2023  }
2024 
2033  virtual void onDeviceDisconnected(const DeviceInfo*) = 0;
2034  private:
2036  {
2038  pListener->onDeviceDisconnected(static_cast<const DeviceInfo*>(pInfo));
2039  }
2040 
2041  friend class OpenNI;
2044  };
2059  {
2060  public:
2062  {
2063  m_deviceStateChangedCallbacks.deviceConnected = NULL;
2064  m_deviceStateChangedCallbacks.deviceDisconnected = NULL;
2065  m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback;
2066  m_deviceStateChangedCallbacksHandle = NULL;
2067  }
2068 
2070  {
2071  }
2072 
2079  virtual void onDeviceStateChanged(const DeviceInfo*, DeviceState) = 0;
2080  private:
2082  {
2084  pListener->onDeviceStateChanged(static_cast<const DeviceInfo*>(pInfo), DeviceState(state));
2085  }
2086 
2087  friend class OpenNI;
2090  };
2091 
2098  {
2099  return (Status)oniInitialize(ONI_API_VERSION); // provide version of API, to make sure proper struct sizes are used
2100  }
2101 
2106  static void shutdown()
2107  {
2108  oniShutdown();
2109  }
2110 
2115  {
2116  OniVersion oniVersion = oniGetVersion();
2117  Version version;
2118  version.major = oniVersion.major;
2119  version.minor = oniVersion.minor;
2120  version.maintenance = oniVersion.maintenance;
2121  version.build = oniVersion.build;
2122  return version;
2123  }
2124 
2132  static const char* getExtendedError()
2133  {
2134  return oniGetExtendedError();
2135  }
2136 
2141  static void enumerateDevices(Array<DeviceInfo>* deviceInfoList)
2142  {
2143  OniDeviceInfo* m_pDeviceInfos;
2144  int m_deviceInfoCount;
2145  oniGetDeviceList(&m_pDeviceInfos, &m_deviceInfoCount);
2146  deviceInfoList->_setData((DeviceInfo*)m_pDeviceInfos, m_deviceInfoCount, true);
2147  oniReleaseDeviceList(m_pDeviceInfos);
2148  }
2149 
2158  static Status waitForAnyStream(VideoStream** pStreams, int streamCount, int* pReadyStreamIndex, int timeout = TIMEOUT_FOREVER)
2159  {
2160  static const int ONI_MAX_STREAMS = 50;
2161  OniStreamHandle streams[ONI_MAX_STREAMS];
2162 
2163  if (streamCount > ONI_MAX_STREAMS)
2164  {
2165  printf("Too many streams for wait: %d > %d\n", streamCount, ONI_MAX_STREAMS);
2166  return STATUS_BAD_PARAMETER;
2167  }
2168 
2169  *pReadyStreamIndex = -1;
2170  for (int i = 0; i < streamCount; ++i)
2171  {
2172  if (pStreams[i] != NULL)
2173  {
2174  streams[i] = pStreams[i]->_getHandle();
2175  }
2176  else
2177  {
2178  streams[i] = NULL;
2179  }
2180  }
2181  Status rc = (Status)oniWaitForAnyStream(streams, streamCount, pReadyStreamIndex, timeout);
2182 
2183  return rc;
2184  }
2185 
2194  {
2195  if (pListener->m_deviceConnectedCallbacksHandle != NULL)
2196  {
2197  return STATUS_ERROR;
2198  }
2200  }
2209  {
2210  if (pListener->m_deviceDisconnectedCallbacksHandle != NULL)
2211  {
2212  return STATUS_ERROR;
2213  }
2215  }
2224  {
2225  if (pListener->m_deviceStateChangedCallbacksHandle != NULL)
2226  {
2227  return STATUS_ERROR;
2228  }
2230  }
2239  {
2241  pListener->m_deviceConnectedCallbacksHandle = NULL;
2242  }
2251  {
2253  pListener->m_deviceDisconnectedCallbacksHandle = NULL;
2254  }
2263  {
2265  pListener->m_deviceStateChangedCallbacksHandle = NULL;
2266  }
2267 
2276  static Status setLogOutputFolder(const char *strLogOutputFolder)
2277  {
2278  return (Status)oniSetLogOutputFolder(strLogOutputFolder);
2279  }
2280 
2290  static Status getLogFileName(char *strFileName, int nBufferSize)
2291  {
2292  return (Status)oniGetLogFileName(strFileName, nBufferSize);
2293  }
2294 
2304  static Status setLogMinSeverity(int nMinSeverity)
2305  {
2306  return(Status) oniSetLogMinSeverity(nMinSeverity);
2307  }
2308 
2317  static Status setLogConsoleOutput(bool bConsoleOutput)
2318  {
2319  return (Status)oniSetLogConsoleOutput(bConsoleOutput);
2320  }
2321 
2330  static Status setLogFileOutput(bool bFileOutput)
2331  {
2332  return (Status)oniSetLogFileOutput(bFileOutput);
2333  }
2334 
2335  #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM
2336 
2345  static Status setLogAndroidOutput(bool bAndroidOutput)
2346  {
2347  return (Status)oniSetLogAndroidOutput(bAndroidOutput);
2348  }
2349  #endif
2350 
2351 private:
2353  {
2354  }
2355 };
2356 
2393 {
2394 public:
2405  static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, int* pDepthX, int* pDepthY, DepthPixel* pDepthZ)
2406  {
2407  float depthX, depthY, depthZ;
2408  Status rc = (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, &depthX, &depthY, &depthZ);
2409  *pDepthX = (int)depthX;
2410  *pDepthY = (int)depthY;
2411  *pDepthZ = (DepthPixel)depthZ;
2412  return rc;
2413  }
2414 
2425  static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ)
2426  {
2427  return (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, pDepthX, pDepthY, pDepthZ);
2428  }
2429 
2440  static Status convertDepthToWorld(const VideoStream& depthStream, int depthX, int depthY, DepthPixel depthZ, float* pWorldX, float* pWorldY, float* pWorldZ)
2441  {
2442  return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), float(depthX), float(depthY), float(depthZ), pWorldX, pWorldY, pWorldZ);
2443  }
2444 
2455  static Status convertDepthToWorld(const VideoStream& depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ)
2456  {
2457  return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), depthX, depthY, depthZ, pWorldX, pWorldY, pWorldZ);
2458  }
2459 
2471  static Status convertDepthToColor(const VideoStream& depthStream, const VideoStream& colorStream, int depthX, int depthY, DepthPixel depthZ, int* pColorX, int* pColorY)
2472  {
2473  return (Status)oniCoordinateConverterDepthToColor(depthStream._getHandle(), colorStream._getHandle(), depthX, depthY, depthZ, pColorX, pColorY);
2474  }
2475 };
2476 
2492 {
2493 public:
2498  Recorder() : m_recorder(NULL)
2499  {
2500  }
2501 
2506  {
2507  destroy();
2508  }
2509 
2521  Status create(const char* fileName)
2522  {
2523  if (!isValid())
2524  {
2525  return (Status)oniCreateRecorder(fileName, &m_recorder);
2526  }
2527  return STATUS_ERROR;
2528  }
2529 
2536  bool isValid() const
2537  {
2538  return NULL != getHandle();
2539  }
2540 
2551  Status attach(VideoStream& stream, bool allowLossyCompression = false)
2552  {
2553  if (!isValid() || !stream.isValid())
2554  {
2555  return STATUS_ERROR;
2556  }
2558  m_recorder,
2559  stream._getHandle(),
2560  allowLossyCompression);
2561  }
2562 
2570  {
2571  if (!isValid())
2572  {
2573  return STATUS_ERROR;
2574  }
2575  return (Status)oniRecorderStart(m_recorder);
2576  }
2577 
2581  void stop()
2582  {
2583  if (isValid())
2584  {
2585  oniRecorderStop(m_recorder);
2586  }
2587  }
2588 
2592  void destroy()
2593  {
2594  if (isValid())
2595  {
2596  oniRecorderDestroy(&m_recorder);
2597  }
2598  }
2599 
2600 private:
2601  Recorder(const Recorder&);
2602  Recorder& operator=(const Recorder&);
2603 
2608  {
2609  return m_recorder;
2610  }
2611 
2612 
2614 };
2615 
2616 // Implemetation
2618 {
2619  OniStreamHandle streamHandle;
2620  Status rc = (Status)oniDeviceCreateStream(device._getHandle(), (OniSensorType)sensorType, &streamHandle);
2621  if (rc != STATUS_OK)
2622  {
2623  return rc;
2624  }
2625 
2626  m_isOwner = true;
2627  _setHandle(streamHandle);
2628 
2629  if (isPropertySupported(STREAM_PROPERTY_AUTO_WHITE_BALANCE) && isPropertySupported(STREAM_PROPERTY_AUTO_EXPOSURE))
2630  {
2631  m_pCameraSettings = new CameraSettings(this);
2632  }
2633 
2634  return STATUS_OK;
2635 }
2636 
2638 {
2639  if (!isValid())
2640  {
2641  return;
2642  }
2643 
2644  if (m_pCameraSettings != NULL)
2645  {
2646  delete m_pCameraSettings;
2647  m_pCameraSettings = NULL;
2648  }
2649 
2650  if (m_stream != NULL)
2651  {
2652  if(m_isOwner)
2653  oniStreamDestroy(m_stream);
2654  m_stream = NULL;
2655  }
2656 }
2657 
2658 Status Device::open(const char* uri)
2659 {
2660  //If we are not the owners, we stick with our own device
2661  if(!m_isOwner)
2662  {
2663  if(isValid()){
2664  return STATUS_OK;
2665  }else{
2666  return STATUS_OUT_OF_FLOW;
2667  }
2668  }
2669 
2670  OniDeviceHandle deviceHandle;
2671  Status rc = (Status)oniDeviceOpen(uri, &deviceHandle);
2672  if (rc != STATUS_OK)
2673  {
2674  return rc;
2675  }
2676 
2677  _setHandle(deviceHandle);
2678 
2679  return STATUS_OK;
2680 }
2681 
2682 Status Device::_openEx(const char* uri, const char* mode)
2683 {
2684  //If we are not the owners, we stick with our own device
2685  if(!m_isOwner)
2686  {
2687  if(isValid()){
2688  return STATUS_OK;
2689  }else{
2690  return STATUS_OUT_OF_FLOW;
2691  }
2692  }
2693 
2694  OniDeviceHandle deviceHandle;
2695  Status rc = (Status)oniDeviceOpenEx(uri, mode, &deviceHandle);
2696  if (rc != STATUS_OK)
2697  {
2698  return rc;
2699  }
2700 
2701  _setHandle(deviceHandle);
2702 
2703  return STATUS_OK;
2704 }
2705 
2707 {
2708  if (m_device == NULL)
2709  {
2710  m_device = deviceHandle;
2711 
2712  clearSensors();
2713 
2714  oniDeviceGetInfo(m_device, &m_deviceInfo);
2715 
2716  if (isFile())
2717  {
2718  m_pPlaybackControl = new PlaybackControl(this);
2719  }
2720 
2721  // Read deviceInfo
2722  return STATUS_OK;
2723  }
2724 
2725  return STATUS_OUT_OF_FLOW;
2726 }
2727 
2729 {
2730  if (m_pPlaybackControl != NULL)
2731  {
2732  delete m_pPlaybackControl;
2733  m_pPlaybackControl = NULL;
2734  }
2735 
2736  if (m_device != NULL)
2737  {
2738  if(m_isOwner)
2739  {
2740  oniDeviceClose(m_device);
2741  }
2742 
2743  m_device = NULL;
2744  }
2745 }
2746 
2747 
2748 }
2749 
2750 #endif // _OPEN_NI_HPP_
VideoStream * m_pStream
Definition: OpenNI.h:1920
Status create(const Device &device, SensorType sensorType)
Definition: OpenNI.h:2617
static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void *pCookie)
Definition: OpenNI.h:677
static void ONI_CALLBACK_TYPE deviceStateChangedCallback(const OniDeviceInfo *pInfo, OniDeviceState state, void *pCookie)
Definition: OpenNI.h:2081
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:551
Status setVideoMode(const VideoMode &videoMode)
Definition: OpenNI.h:956
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:1322
ONI_C_API OniStatus oniRecorderStart(OniRecorderHandle recorder)
_OniDevice * OniDeviceHandle
Definition: OniCTypes.h:85
bool isCommandSupported(int commandId) const
Definition: OpenNI.h:1616
static Status convertDepthToWorld(const VideoStream &depthStream, int depthX, int depthY, DepthPixel depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Definition: OpenNI.h:2440
SensorType getSensorType() const
Definition: OpenNI.h:321
DeviceState
Definition: OniEnums.h:67
Status setFrameBuffersAllocator(FrameAllocator *pAllocator)
Definition: OpenNI.h:863
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:1795
const SensorInfo & getSensorInfo() const
Definition: OpenNI.h:771
PixelFormat
Definition: OniEnums.h:50
void setFps(int fps)
Definition: OpenNI.h:290
Array< VideoMode > m_videoModes
Definition: OpenNI.h:357
OniDeviceHandle m_device
Definition: OpenNI.h:1641
#define FALSE
Definition: OniCTypes.h:34
bool getAutoExposureEnabled() const
Definition: OpenNI.h:1853
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:1143
bool getCropping(int *pOriginX, int *pOriginY, int *pWidth, int *pHeight) const
Definition: OpenNI.h:1010
bool m_isOwner
Definition: OpenNI.h:1645
Status setAutoWhiteBalanceEnabled(bool enabled)
Definition: OpenNI.h:1848
OniCallbackHandle m_deviceConnectedCallbacksHandle
Definition: OpenNI.h:1991
Status create(const char *fileName)
Definition: OpenNI.h:2521
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:115
int getResolutionY() const
Definition: OpenNI.h:255
ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void *data, int dataSize)
OniStreamHandle m_stream
Definition: OpenNI.h:1220
const SensorInfo * getSensorInfo(SensorType sensorType)
Definition: OpenNI.h:1369
int getWidth() const
Definition: OpenNI.h:523
static void ONI_CALLBACK_TYPE deviceConnectedCallback(const OniDeviceInfo *pInfo, void *pCookie)
Definition: OpenNI.h:1983
Status attach(VideoStream &stream, bool allowLossyCompression=false)
Definition: OpenNI.h:2551
OniFrame * _getFrame()
Definition: OpenNI.h:607
ONI_C_API OniStatus oniStreamRegisterNewFrameCallback(OniStreamHandle stream, OniNewFrameCallback handler, void *pCookie, OniCallbackHandle *pHandle)
unsigned short uint16_t
bool isValid() const
Definition: OpenNI.h:1806
Status invoke(int commandId, T &value)
Definition: OpenNI.h:1182
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:1222
Status invoke(int propertyId, T &value)
Definition: OpenNI.h:1606
int OniBool
Definition: OniCTypes.h:28
ONI_C_API OniStatus oniDeviceEnableDepthColorSync(OniDeviceHandle device)
Status invoke(int commandId, void *data, int dataSize)
Definition: OpenNI.h:1591
unsigned __int64 uint64_t
ONI_C_API OniStatus oniSetLogConsoleOutput(OniBool bConsoleOutput)
OniDeviceCallbacks m_deviceConnectedCallbacks
Definition: OpenNI.h:1990
const void * getData() const
Definition: OpenNI.h:462
void removeNewFrameListener(NewFrameListener *pListener)
Definition: OpenNI.h:847
virtual void onDeviceDisconnected(const DeviceInfo *)=0
OniDeviceState
Definition: OniCEnums.h:64
VideoMode getVideoMode() const
Definition: OpenNI.h:941
Status setExposure(int exposure)
Definition: OpenNI.h:1872
ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, void *data, int *pDataSize)
_OniRecorder * OniRecorderHandle
Definition: OniCTypes.h:91
OniStreamHandle stream
Definition: OniCTypes.h:190
static Status waitForAnyStream(VideoStream **pStreams, int streamCount, int *pReadyStreamIndex, int timeout=TIMEOUT_FOREVER)
Definition: OpenNI.h:2158
bool getCroppingEnabled() const
Definition: OpenNI.h:542
ONI_C_API OniStatus oniGetLogFileName(char *strFileName, int nBufferSize)
static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void *data, void *pCookie)
Definition: OpenNI.h:704
bool getAutoWhiteBalanceEnabled() const
Definition: OpenNI.h:1860
static Status addDeviceConnectedListener(DeviceConnectedListener *pListener)
Definition: OpenNI.h:2193
int getMinPixelValue() const
Definition: OpenNI.h:982
ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream)
static void enumerateDevices(Array< DeviceInfo > *deviceInfoList)
Definition: OpenNI.h:2141
static Version getVersion()
Definition: OpenNI.h:2114
PlaybackControl(Device *pDevice)
Definition: OpenNI.h:1829
bool isCommandSupported(int commandId) const
Definition: OpenNI.h:1192
ONI_C_API void oniShutdown()
static void *ONI_CALLBACK_TYPE allocateFrameBufferCallback(int size, void *pCookie)
Definition: OpenNI.h:698
SensorType
Definition: OniEnums.h:41
static Status setLogOutputFolder(const char *strLogOutputFolder)
Definition: OpenNI.h:2276
ONI_C_API OniStatus oniCreateRecorder(const char *fileName, OniRecorderHandle *pRecorder)
int frameIndex
Definition: OniCTypes.h:189
const T & operator[](int index) const
Definition: OpenNI.h:134
void _setHandle(OniStreamHandle stream)
Definition: OpenNI.h:1205
const char * getVendor() const
Definition: OpenNI.h:381
unsigned char uint8_t
ONI_C_API OniStatus oniDeviceClose(OniDeviceHandle device)
Status setRepeatEnabled(bool repeat)
Definition: OpenNI.h:1755
Status setGain(int gain)
Definition: OpenNI.h:1868
int getFps() const
Definition: OpenNI.h:261
ONI_C_API void oniUnregisterDeviceCallbacks(OniCallbackHandle handle)
int m_count
Definition: OpenNI.h:176
static void removeDeviceConnectedListener(DeviceConnectedListener *pListener)
Definition: OpenNI.h:2238
bool isValid() const
Definition: OpenNI.h:1495
void _setFrame(OniFrame *pFrame)
Definition: OpenNI.h:597
ONI_C_API OniStatus oniStreamSetProperty(OniStreamHandle stream, int propertyId, const void *data, int dataSize)
Status seek(const VideoStream &stream, int frameIndex)
Definition: OpenNI.h:1775
ONI_C_API void oniStreamDestroy(OniStreamHandle stream)
Status
Definition: OniEnums.h:28
static Status addDeviceStateChangedListener(DeviceStateChangedListener *pListener)
Definition: OpenNI.h:2223
ImageRegistrationMode getImageRegistrationMode() const
Definition: OpenNI.h:1462
uint16_t getUsbVendorId() const
Definition: OpenNI.h:385
ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId)
ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId)
CameraSettings * getCameraSettings()
Definition: OpenNI.h:893
ImageRegistrationMode
Definition: OniEnums.h:75
CameraSettings(VideoStream *pStream)
Definition: OpenNI.h:1915
virtual void onDeviceStateChanged(const DeviceInfo *, DeviceState)=0
Status invoke(int commandId, void *data, int dataSize)
Definition: OpenNI.h:1162
virtual void onNewFrame(VideoStream &)=0
int getSize() const
Definition: OpenNI.h:129
int minor
Definition: OniCTypes.h:49
ONI_C_API OniVersion oniGetVersion()
OniCallbackHandle m_deviceDisconnectedCallbacksHandle
Definition: OpenNI.h:2043
Status getProperty(int propertyId, void *data, int *dataSize) const
Definition: OpenNI.h:1422
static Status setLogMinSeverity(int nMinSeverity)
Definition: OpenNI.h:2304
Array< T > & operator=(const Array< T > &)
static Status initialize()
Definition: OpenNI.h:2097
OniVideoMode * pSupportedVideoModes
Definition: OniCTypes.h:72
void close()
Definition: OpenNI.h:2728
uint16_t DepthPixel
Definition: OpenNI.h:38
Status setProperty(int propertyId, const T &value)
Definition: OpenNI.h:1551
OniCallbackHandle m_callbackHandle
Definition: OpenNI.h:685
OniSensorType
Definition: OniCEnums.h:38
ONI_C_API OniStatus oniDeviceSetProperty(OniDeviceHandle device, int propertyId, const void *data, int dataSize)
bool isCroppingSupported() const
Definition: OpenNI.h:997
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:1038
VideoMode & operator=(const VideoMode &other)
Definition: OpenNI.h:230
static void removeDeviceStateChangedListener(DeviceStateChangedListener *pListener)
Definition: OpenNI.h:2262
VideoMode(const VideoMode &other)
Definition: OpenNI.h:219
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:2035
static void removeDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
Definition: OpenNI.h:2250
static const char * getExtendedError()
Definition: OpenNI.h:2132
bool m_owner
Definition: OpenNI.h:177
void _setData(const T *data, int count, bool isOwner=false)
Definition: OpenNI.h:146
#define ONI_API_VERSION
Definition: OniVersion.h:38
Status setAutoExposureEnabled(bool enabled)
Definition: OpenNI.h:1844
Status setImageRegistrationMode(ImageRegistrationMode mode)
Definition: OpenNI.h:1486
static void shutdown()
Definition: OpenNI.h:2106
OniStreamHandle _getHandle() const
Definition: OpenNI.h:884
const T * m_data
Definition: OpenNI.h:175
Status open(const char *uri)
Definition: OpenNI.h:2658
float getHorizontalFieldOfView() const
Definition: OpenNI.h:1089
int getDataSize() const
Definition: OpenNI.h:452
ONI_C_API OniStatus oniCoordinateConverterDepthToWorld(OniStreamHandle depthStream, float depthX, float depthY, float depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Status resetCropping()
Definition: OpenNI.h:1053
Status setProperty(int propertyId, const void *data, int dataSize)
Definition: OpenNI.h:1438
int getFrameIndex() const
Definition: OpenNI.h:512
static const int TIMEOUT_FOREVER
Definition: OniEnums.h:82
const char * getUri() const
Definition: OpenNI.h:379
void _setInternal(const OniSensorInfo *pInfo)
Definition: OpenNI.h:343
Status _openEx(const char *uri, const char *mode)
Definition: OpenNI.h:2682
uint16_t Grayscale16Pixel
Definition: OpenNI.h:41
MyFreenectDevice * device
void destroy()
Definition: OpenNI.h:2592
VideoStream(OniStreamHandle handle)
Definition: OpenNI.h:722
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:1504
OniRecorderHandle getHandle() const
Definition: OpenNI.h:2607
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:1450
void setResolution(int resolutionX, int resolutionY)
Definition: OpenNI.h:278
void setPixelFormat(PixelFormat format)
Definition: OpenNI.h:269
Status start()
Definition: OpenNI.h:779
const char * getName() const
Definition: OpenNI.h:383
ONI_C_API OniStatus oniInitialize(int apiVersion)
Status getProperty(int propertyId, T *value) const
Definition: OpenNI.h:1132
OniCallbackHandle m_deviceStateChangedCallbacksHandle
Definition: OpenNI.h:2089
double fps
Definition: regview.c:74
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, float *pDepthX, float *pDepthY, float *pDepthZ)
Definition: OpenNI.h:2425
PlaybackControl * getPlaybackControl()
Definition: OpenNI.h:1409
float getSpeed() const
Definition: OpenNI.h:1695
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, int *pDepthX, int *pDepthY, DepthPixel *pDepthZ)
Definition: OpenNI.h:2405
int maintenance
Definition: OpenNI.h:52
Status _setHandle(OniDeviceHandle deviceHandle)
Definition: OpenNI.h:2706
bool isValid() const
Definition: OpenNI.h:2536
ONI_C_API void oniRecorderStop(OniRecorderHandle recorder)
DeviceInfo m_deviceInfo
Definition: OpenNI.h:1642
Status start()
Definition: OpenNI.h:2569
static Status setLogConsoleOutput(bool bConsoleOutput)
Definition: OpenNI.h:2317
bool isValid() const
Definition: OpenNI.h:578
float getVerticalFieldOfView() const
Definition: OpenNI.h:1100
static Status getLogFileName(char *strFileName, int nBufferSize)
Definition: OpenNI.h:2290
bool getRepeatEnabled() const
Definition: OpenNI.h:1730
OniDeviceCallbacks m_deviceDisconnectedCallbacks
Definition: OpenNI.h:2042
ONI_C_API OniStatus oniGetDeviceList(OniDeviceInfo **pDevices, int *pNumDevices)
Status readFrame(VideoFrameRef *pFrame)
Definition: OpenNI.h:812
ONI_C_API OniStatus oniRecorderDestroy(OniRecorderHandle *pRecorder)
Status setProperty(int propertyId, const T &value)
Definition: OpenNI.h:1907
#define ONI_CALLBACK_TYPE
static const char * ANY_DEVICE
Definition: OpenNI.h:90
ONI_C_API OniStatus oniSetLogOutputFolder(const char *strOutputFolder)
void clear()
Definition: OpenNI.h:166
OniDeviceCallbacks m_deviceStateChangedCallbacks
Definition: OpenNI.h:2088
void clearSensors()
Definition: OpenNI.h:1628
const Array< VideoMode > & getSupportedVideoModes() const
Definition: OpenNI.h:330
bool isValid() const
Definition: OpenNI.h:1897
OniFrame * m_pFrame
Definition: OpenNI.h:621
bool isPropertySupported(int propertyId) const
Definition: OpenNI.h:1577
PixelFormat getPixelFormat() const
Definition: OpenNI.h:243
bool getMirroringEnabled() const
Definition: OpenNI.h:1064
VideoFrameRef(const VideoFrameRef &other)
Definition: OpenNI.h:431
ONI_C_API void oniFrameAddRef(OniFrame *pFrame)
Device(OniDeviceHandle handle)
Definition: OpenNI.h:1258
uint64_t getTimestamp() const
Definition: OpenNI.h:497
ONI_C_API OniStatus oniWaitForAnyStream(OniStreamHandle *pStreams, int numStreams, int *pStreamIndex, int timeout)
capture state
Definition: micview.c:53
int getResolutionX() const
Definition: OpenNI.h:249
Status addNewFrameListener(NewFrameListener *pListener)
Definition: OpenNI.h:833
Status setProperty(int propertyId, const T &value)
Definition: OpenNI.h:1117
Status attach(Device *device)
Definition: OpenNI.h:1811
Status setSpeed(float speed)
Definition: OpenNI.h:1716
bool hasSensor(SensorType sensorType)
Definition: OpenNI.h:1334
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:560
Status getProperty(int propertyId, T *value) const
Definition: OpenNI.h:1900
int getStrideInBytes() const
Definition: OpenNI.h:570
Status setProperty(int propertyId, const void *data, int dataSize)
Definition: OpenNI.h:925
bool getDepthColorSyncEnabled()
Definition: OpenNI.h:1535
int getHeight() const
Definition: OpenNI.h:533
OniDeviceHandle _getHandle() const
Definition: OpenNI.h:1400
bool isValid() const
Definition: OpenNI.h:740
_OniStream * OniStreamHandle
Definition: OniCTypes.h:88
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:966
const OniSensorInfo * m_pInfo
Definition: OpenNI.h:356
#define ONI_MAX_SENSORS
Definition: OniCTypes.h:38
void setReference(OniFrame *pFrame)
Definition: OpenNI.h:614
static Status setLogFileOutput(bool bFileOutput)
Definition: OpenNI.h:2330
Status setMirroringEnabled(bool isEnabled)
Definition: OpenNI.h:1080
PlaybackControl * m_pPlaybackControl
Definition: OpenNI.h:1639
SensorInfo m_sensorInfo
Definition: OpenNI.h:1221
void * pCookie
Definition: OniDriverAPI.h:35
SensorInfo(const OniSensorInfo *pInfo)
Definition: OpenNI.h:338
ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput)
Status getProperty(int propertyId, T *value) const
Definition: OpenNI.h:1566
ONI_C_API OniStatus oniSetLogMinSeverity(int nMinSeverity)
SensorType getSensorType() const
Definition: OpenNI.h:473
Status setDepthColorSyncEnabled(bool isEnabled)
Definition: OpenNI.h:1519
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:2455
const VideoMode & getVideoMode() const
Definition: OpenNI.h:485
OniRecorderHandle m_recorder
Definition: OpenNI.h:2613
ONI_C_API void oniFrameRelease(OniFrame *pFrame)
uint16_t getUsbProductId() const
Definition: OpenNI.h:387
static Status convertDepthToColor(const VideoStream &depthStream, const VideoStream &colorStream, int depthX, int depthY, DepthPixel depthZ, int *pColorX, int *pColorY)
Definition: OpenNI.h:2471
static Status addDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
Definition: OpenNI.h:2208
VideoFrameRef & operator=(const VideoFrameRef &other)
Definition: OpenNI.h:441
Status getProperty(int propertyId, void *data, int *dataSize) const
Definition: OpenNI.h:905


libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Thu Jun 6 2019 19:25:38