86 #if ONI_PLATFORM != ONI_PLATFORM_WIN32 87 #pragma GCC diagnostic ignored "-Wunused-variable" 88 #pragma GCC diagnostic push 91 #if ONI_PLATFORM != ONI_PLATFORM_WIN32 92 #pragma GCC diagnostic pop 146 void _setData(
const T* data,
int count,
bool isOwner =
false)
158 memcpy((
void*)
m_data, data, count*
sizeof(T));
280 this->resolutionX = resolutionX;
281 this->resolutionY = resolutionY;
348 m_videoModes._setData(NULL, 0);
379 const char*
getUri()
const {
return uri; }
454 return m_pFrame->dataSize;
464 return m_pFrame->data;
487 return static_cast<const VideoMode&
>(m_pFrame->videoMode);
499 return m_pFrame->timestamp;
514 return m_pFrame->frameIndex;
525 return m_pFrame->width;
535 return m_pFrame->height;
544 return m_pFrame->croppingEnabled ==
TRUE;
553 return m_pFrame->cropOriginX;
562 return m_pFrame->cropOriginY;
572 return m_pFrame->stride;
580 return m_pFrame != NULL;
589 if (m_pFrame != NULL)
599 setReference(pFrame);
692 virtual void* allocateFrameBuffer(
int size) = 0;
693 virtual void freeFrameBuffer(
void* data) = 0;
715 VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true)
742 return m_stream != NULL;
761 inline void destroy();
870 if (pAllocator == NULL)
1010 bool getCropping(
int* pOriginX,
int* pOriginY,
int* pWidth,
int* pHeight)
const 1013 bool enabled =
false;
1021 *pWidth = cropping.
width;
1022 *pHeight = cropping.
height;
1044 cropping.
width = width;
1045 cropping.
height = height;
1072 return enabled ==
TRUE;
1091 float horizontal = 0;
1119 return setProperty(propertyId, &value,
sizeof(T));
1134 int size =
sizeof(T);
1135 return getProperty(propertyId, value, &size);
1184 return invoke(commandId, &value,
sizeof(T));
1207 m_sensorInfo._setInternal(NULL);
1249 Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true)
1269 if (m_device != NULL)
1304 inline Status open(
const char* uri);
1311 inline void close();
1324 return m_deviceInfo;
1337 for (i = 0; (i <
ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1339 if (m_aSensorInfo[i].getSensorType() == sensorType)
1357 m_aSensorInfo[i]._setInternal(pInfo);
1372 for (i = 0; (i <
ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1374 if (m_aSensorInfo[i].getSensorType() == sensorType)
1376 return &m_aSensorInfo[i];
1392 m_aSensorInfo[i]._setInternal(pInfo);
1393 return &m_aSensorInfo[i];
1497 return m_device != NULL;
1553 return setProperty(propertyId, &value,
sizeof(T));
1568 int size =
sizeof(T);
1569 return getProperty(propertyId, value, &size);
1608 return invoke(propertyId, &value,
sizeof(T));
1622 inline Status _openEx(
const char* uri,
const char* mode);
1632 m_aSensorInfo[i]._setInternal(NULL);
1744 return repeat ==
TRUE;
1797 int numOfFrames = -1;
1808 return m_pDevice != NULL;
1831 if (pDevice != NULL)
1904 return m_pStream->getProperty<T>(propertyId, value);
1911 return m_pStream->setProperty<T>(propertyId, value);
1917 m_pStream = pStream;
1960 m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback;
1961 m_deviceConnectedCallbacks.deviceDisconnected = NULL;
1962 m_deviceConnectedCallbacks.deviceStateChanged = NULL;
1963 m_deviceConnectedCallbacksHandle = NULL;
1981 virtual void onDeviceConnected(
const DeviceInfo*) = 0;
2015 m_deviceDisconnectedCallbacks.deviceConnected = NULL;
2016 m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback;
2017 m_deviceDisconnectedCallbacks.deviceStateChanged = NULL;
2018 m_deviceDisconnectedCallbacksHandle = NULL;
2033 virtual void onDeviceDisconnected(
const DeviceInfo*) = 0;
2063 m_deviceStateChangedCallbacks.deviceConnected = NULL;
2064 m_deviceStateChangedCallbacks.deviceDisconnected = NULL;
2065 m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback;
2066 m_deviceStateChangedCallbacksHandle = NULL;
2144 int m_deviceInfoCount;
2160 static const int ONI_MAX_STREAMS = 50;
2163 if (streamCount > ONI_MAX_STREAMS)
2165 printf(
"Too many streams for wait: %d > %d\n", streamCount, ONI_MAX_STREAMS);
2169 *pReadyStreamIndex = -1;
2170 for (
int i = 0; i < streamCount; ++i)
2172 if (pStreams[i] != NULL)
2335 #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM 2345 static Status setLogAndroidOutput(
bool bAndroidOutput)
2347 return (
Status)oniSetLogAndroidOutput(bAndroidOutput);
2407 float depthX, depthY, depthZ;
2409 *pDepthX = (int)depthX;
2410 *pDepthY = (int)depthY;
2538 return NULL != getHandle();
2553 if (!isValid() || !stream.
isValid())
2560 allowLossyCompression);
2627 _setHandle(streamHandle);
2644 if (m_pCameraSettings != NULL)
2646 delete m_pCameraSettings;
2647 m_pCameraSettings = NULL;
2650 if (m_stream != NULL)
2677 _setHandle(deviceHandle);
2701 _setHandle(deviceHandle);
2708 if (m_device == NULL)
2710 m_device = deviceHandle;
2730 if (m_pPlaybackControl != NULL)
2732 delete m_pPlaybackControl;
2733 m_pPlaybackControl = NULL;
2736 if (m_device != NULL)
2750 #endif // _OPEN_NI_HPP_
Status create(const Device &device, SensorType sensorType)
static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void *pCookie)
static void ONI_CALLBACK_TYPE deviceStateChangedCallback(const OniDeviceInfo *pInfo, OniDeviceState state, void *pCookie)
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
Status setVideoMode(const VideoMode &videoMode)
ONI_C_API OniStatus oniDeviceGetInfo(OniDeviceHandle device, OniDeviceInfo *pInfo)
struct OniCallbackHandleImpl * OniCallbackHandle
ONI_C_API void oniStreamStop(OniStreamHandle stream)
const DeviceInfo & getDeviceInfo() const
ONI_C_API OniStatus oniRecorderStart(OniRecorderHandle recorder)
_OniDevice * OniDeviceHandle
bool isCommandSupported(int commandId) const
static Status convertDepthToWorld(const VideoStream &depthStream, int depthX, int depthY, DepthPixel depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
SensorType getSensorType() const
Status setFrameBuffersAllocator(FrameAllocator *pAllocator)
ONI_C_API OniStatus oniStreamReadFrame(OniStreamHandle stream, OniFrame **pFrame)
ONI_C_API const OniSensorInfo * oniStreamGetSensorInfo(OniStreamHandle stream)
int getNumberOfFrames(const VideoStream &stream) const
const SensorInfo & getSensorInfo() const
Array< VideoMode > m_videoModes
bool getAutoExposureEnabled() const
int numSupportedVideoModes
ONI_C_API OniStatus oniDeviceOpen(const char *uri, OniDeviceHandle *pDevice)
ONI_C_API OniStatus oniDeviceOpenEx(const char *uri, const char *mode, OniDeviceHandle *pDevice)
DeviceDisconnectedListener()
bool isPropertySupported(int propertyId) const
bool getCropping(int *pOriginX, int *pOriginY, int *pWidth, int *pHeight) const
Status setAutoWhiteBalanceEnabled(bool enabled)
OniCallbackHandle m_deviceConnectedCallbacksHandle
Status create(const char *fileName)
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)
int getResolutionY() const
ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void *data, int dataSize)
const SensorInfo * getSensorInfo(SensorType sensorType)
DeviceConnectedListener()
static void ONI_CALLBACK_TYPE deviceConnectedCallback(const OniDeviceInfo *pInfo, void *pCookie)
Status attach(VideoStream &stream, bool allowLossyCompression=false)
ONI_C_API OniStatus oniStreamRegisterNewFrameCallback(OniStreamHandle stream, OniNewFrameCallback handler, void *pCookie, OniCallbackHandle *pHandle)
Status invoke(int commandId, T &value)
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
Status invoke(int propertyId, T &value)
ONI_C_API OniStatus oniDeviceEnableDepthColorSync(OniDeviceHandle device)
Status invoke(int commandId, void *data, int dataSize)
ONI_C_API OniStatus oniSetLogConsoleOutput(OniBool bConsoleOutput)
OniDeviceCallbacks m_deviceConnectedCallbacks
const void * getData() const
void removeNewFrameListener(NewFrameListener *pListener)
virtual void onDeviceDisconnected(const DeviceInfo *)=0
VideoMode getVideoMode() const
Status setExposure(int exposure)
ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, void *data, int *pDataSize)
_OniRecorder * OniRecorderHandle
static Status waitForAnyStream(VideoStream **pStreams, int streamCount, int *pReadyStreamIndex, int timeout=TIMEOUT_FOREVER)
bool getCroppingEnabled() const
ONI_C_API OniStatus oniGetLogFileName(char *strFileName, int nBufferSize)
static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void *data, void *pCookie)
bool getAutoWhiteBalanceEnabled() const
static Status addDeviceConnectedListener(DeviceConnectedListener *pListener)
int getMinPixelValue() const
ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream)
virtual ~NewFrameListener()
static void enumerateDevices(Array< DeviceInfo > *deviceInfoList)
static Version getVersion()
PlaybackControl(Device *pDevice)
bool isCommandSupported(int commandId) const
ONI_C_API void oniShutdown()
static void *ONI_CALLBACK_TYPE allocateFrameBufferCallback(int size, void *pCookie)
static Status setLogOutputFolder(const char *strLogOutputFolder)
ONI_C_API OniStatus oniCreateRecorder(const char *fileName, OniRecorderHandle *pRecorder)
DeviceStateChangedListener()
const T & operator[](int index) const
void _setHandle(OniStreamHandle stream)
const char * getVendor() const
ONI_C_API OniStatus oniDeviceClose(OniDeviceHandle device)
Status setRepeatEnabled(bool repeat)
ONI_C_API void oniUnregisterDeviceCallbacks(OniCallbackHandle handle)
static void removeDeviceConnectedListener(DeviceConnectedListener *pListener)
void _setFrame(OniFrame *pFrame)
ONI_C_API OniStatus oniStreamSetProperty(OniStreamHandle stream, int propertyId, const void *data, int dataSize)
Status seek(const VideoStream &stream, int frameIndex)
ONI_C_API void oniStreamDestroy(OniStreamHandle stream)
static Status addDeviceStateChangedListener(DeviceStateChangedListener *pListener)
ImageRegistrationMode getImageRegistrationMode() const
uint16_t getUsbVendorId() const
ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId)
ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId)
CameraSettings * getCameraSettings()
CameraSettings(VideoStream *pStream)
virtual void onDeviceStateChanged(const DeviceInfo *, DeviceState)=0
Status invoke(int commandId, void *data, int dataSize)
virtual void onNewFrame(VideoStream &)=0
ONI_C_API OniVersion oniGetVersion()
OniCallbackHandle m_deviceDisconnectedCallbacksHandle
virtual ~DeviceConnectedListener()
Status getProperty(int propertyId, void *data, int *dataSize) const
static Status setLogMinSeverity(int nMinSeverity)
Array< T > & operator=(const Array< T > &)
static Status initialize()
OniVideoMode * pSupportedVideoModes
Status setProperty(int propertyId, const T &value)
OniCallbackHandle m_callbackHandle
ONI_C_API OniStatus oniDeviceSetProperty(OniDeviceHandle device, int propertyId, const void *data, int dataSize)
bool isCroppingSupported() const
ONI_C_API void oniStreamUnregisterNewFrameCallback(OniStreamHandle stream, OniCallbackHandle handle)
Status setCropping(int originX, int originY, int width, int height)
VideoMode & operator=(const VideoMode &other)
static void removeDeviceStateChangedListener(DeviceStateChangedListener *pListener)
VideoMode(const VideoMode &other)
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)
static void removeDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
static const char * getExtendedError()
void _setData(const T *data, int count, bool isOwner=false)
Status setAutoExposureEnabled(bool enabled)
Status setImageRegistrationMode(ImageRegistrationMode mode)
OniStreamHandle _getHandle() const
virtual ~FrameAllocator()
Status open(const char *uri)
float getHorizontalFieldOfView() const
ONI_C_API OniStatus oniCoordinateConverterDepthToWorld(OniStreamHandle depthStream, float depthX, float depthY, float depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Status setProperty(int propertyId, const void *data, int dataSize)
int getFrameIndex() const
static const int TIMEOUT_FOREVER
const char * getUri() const
void _setInternal(const OniSensorInfo *pInfo)
Status _openEx(const char *uri, const char *mode)
uint16_t Grayscale16Pixel
MyFreenectDevice * device
VideoStream(OniStreamHandle handle)
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)
OniRecorderHandle getHandle() const
ONI_C_API OniBool oniDeviceIsImageRegistrationModeSupported(OniDeviceHandle device, OniImageRegistrationMode mode)
virtual ~DeviceStateChangedListener()
ONI_C_API OniStatus oniRegisterDeviceCallbacks(OniDeviceCallbacks *pCallbacks, void *pCookie, OniCallbackHandle *pHandle)
bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const
void setResolution(int resolutionX, int resolutionY)
void setPixelFormat(PixelFormat format)
const char * getName() const
ONI_C_API OniStatus oniInitialize(int apiVersion)
Status getProperty(int propertyId, T *value) const
OniCallbackHandle m_deviceStateChangedCallbacksHandle
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, float *pDepthX, float *pDepthY, float *pDepthZ)
PlaybackControl * getPlaybackControl()
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, int *pDepthX, int *pDepthY, DepthPixel *pDepthZ)
Status _setHandle(OniDeviceHandle deviceHandle)
ONI_C_API void oniRecorderStop(OniRecorderHandle recorder)
static Status setLogConsoleOutput(bool bConsoleOutput)
float getVerticalFieldOfView() const
static Status getLogFileName(char *strFileName, int nBufferSize)
bool getRepeatEnabled() const
OniDeviceCallbacks m_deviceDisconnectedCallbacks
ONI_C_API OniStatus oniGetDeviceList(OniDeviceInfo **pDevices, int *pNumDevices)
Status readFrame(VideoFrameRef *pFrame)
ONI_C_API OniStatus oniRecorderDestroy(OniRecorderHandle *pRecorder)
Status setProperty(int propertyId, const T &value)
static const char * ANY_DEVICE
ONI_C_API OniStatus oniSetLogOutputFolder(const char *strOutputFolder)
OniDeviceCallbacks m_deviceStateChangedCallbacks
const Array< VideoMode > & getSupportedVideoModes() const
bool isPropertySupported(int propertyId) const
PixelFormat getPixelFormat() const
bool getMirroringEnabled() const
VideoFrameRef(const VideoFrameRef &other)
ONI_C_API void oniFrameAddRef(OniFrame *pFrame)
Device(OniDeviceHandle handle)
uint64_t getTimestamp() const
ONI_C_API OniStatus oniWaitForAnyStream(OniStreamHandle *pStreams, int numStreams, int *pStreamIndex, int timeout)
int getResolutionX() const
Status addNewFrameListener(NewFrameListener *pListener)
Status setProperty(int propertyId, const T &value)
Status attach(Device *device)
Status setSpeed(float speed)
bool hasSensor(SensorType sensorType)
virtual void freeFrameBuffer(void *data)=0
ONI_C_API OniStatus oniStreamSetFrameBuffersAllocator(OniStreamHandle stream, OniFrameAllocBufferCallback alloc, OniFrameFreeBufferCallback free, void *pCookie)
int getCropOriginY() const
Status getProperty(int propertyId, T *value) const
int getStrideInBytes() const
Status setProperty(int propertyId, const void *data, int dataSize)
bool getDepthColorSyncEnabled()
OniDeviceHandle _getHandle() const
virtual ~DeviceDisconnectedListener()
_OniStream * OniStreamHandle
ONI_C_API OniStatus oniCoordinateConverterDepthToColor(OniStreamHandle depthStream, OniStreamHandle colorStream, int depthX, int depthY, OniDepthPixel depthZ, int *pColorX, int *pColorY)
int getMaxPixelValue() const
const OniSensorInfo * m_pInfo
void setReference(OniFrame *pFrame)
static Status setLogFileOutput(bool bFileOutput)
Status setMirroringEnabled(bool isEnabled)
PlaybackControl * m_pPlaybackControl
SensorInfo(const OniSensorInfo *pInfo)
ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput)
Status getProperty(int propertyId, T *value) const
ONI_C_API OniStatus oniSetLogMinSeverity(int nMinSeverity)
SensorType getSensorType() const
Status setDepthColorSyncEnabled(bool isEnabled)
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)
const VideoMode & getVideoMode() const
OniRecorderHandle m_recorder
ONI_C_API void oniFrameRelease(OniFrame *pFrame)
uint16_t getUsbProductId() const
static Status convertDepthToColor(const VideoStream &depthStream, const VideoStream &colorStream, int depthX, int depthY, DepthPixel depthZ, int *pColorX, int *pColorY)
static Status addDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
VideoFrameRef & operator=(const VideoFrameRef &other)
Status getProperty(int propertyId, void *data, int *dataSize) const