OpenNI.h
Go to the documentation of this file.
/*****************************************************************************
* *
* OpenNI 2.x Alpha *
* Copyright (C) 2012 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
*****************************************************************************/
#ifndef _OPENNI_H_
#define _OPENNI_H_
#include "OniPlatform.h"
#include "OniProperties.h"
#include "OniEnums.h"
#include "OniCAPI.h"
#include "OniCProperties.h"
namespace openni
{
typedef uint16_t DepthPixel;
typedef uint16_t Grayscale16Pixel;
// structs
typedef struct
{
int major;
int minor;
int maintenance;
int build;
} Version;
typedef struct
{
/* Red value of this pixel. */
uint8_t r;
/* Green value of this pixel. */
uint8_t g;
/* Blue value of this pixel. */
uint8_t b;
} RGB888Pixel;
typedef struct
{
uint8_t u;
uint8_t y1;
uint8_t v;
uint8_t y2;
} YUV422DoublePixel;
#if ONI_PLATFORM != ONI_PLATFORM_WIN32
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic push
#endif
static const char* ANY_DEVICE = NULL;
#if ONI_PLATFORM != ONI_PLATFORM_WIN32
#pragma GCC diagnostic pop
#endif
template<class T>
class Array
{
public:
Array() : m_data(NULL), m_count(0), m_owner(false) {}
Array(const T* data, int count) : m_owner(false) { _setData(data, count); }
~Array()
{
clear();
}
int getSize() const { return m_count; }
const T& operator[](int index) const {return m_data[index];}
void _setData(const T* data, int count, bool isOwner = false)
{
clear();
m_count = count;
m_owner = isOwner;
if (!isOwner)
{
m_data = data;
}
else
{
m_data = new T[count];
memcpy((void*)m_data, data, count*sizeof(T));
}
}
private:
Array(const Array<T>&);
Array<T>& operator=(const Array<T>&);
void clear()
{
if (m_owner && m_data != NULL)
delete []m_data;
m_owner = false;
m_data = NULL;
m_count = 0;
}
const T* m_data;
int m_count;
bool m_owner;
};
// Forward declaration of all
class SensorInfo;
class VideoStream;
class VideoFrameRef;
class Device;
class OpenNI;
class CameraSettings;
class PlaybackControl;
class VideoMode : private OniVideoMode
{
public:
VideoMode()
{}
VideoMode(const VideoMode& other)
{
*this = other;
}
VideoMode& operator=(const VideoMode& other)
{
setPixelFormat(other.getPixelFormat());
setResolution(other.getResolutionX(), other.getResolutionY());
setFps(other.getFps());
return *this;
}
PixelFormat getPixelFormat() const { return (PixelFormat)pixelFormat; }
int getResolutionX() const { return resolutionX; }
int getResolutionY() const {return resolutionY;}
int getFps() const { return fps; }
void setPixelFormat(PixelFormat format) { this->pixelFormat = (OniPixelFormat)format; }
void setResolution(int resolutionX, int resolutionY)
{
this->resolutionX = resolutionX;
this->resolutionY = resolutionY;
}
void setFps(int fps) { this->fps = fps; }
friend class SensorInfo;
friend class VideoStream;
friend class VideoFrameRef;
};
class SensorInfo
{
public:
SensorType getSensorType() const { return (SensorType)m_pInfo->sensorType; }
const Array<VideoMode>& getSupportedVideoModes() const { return m_videoModes; }
private:
SensorInfo(const SensorInfo&);
SensorInfo& operator=(const SensorInfo&);
SensorInfo() : m_pInfo(NULL), m_videoModes(NULL, 0) {}
SensorInfo(const OniSensorInfo* pInfo) : m_pInfo(NULL), m_videoModes(NULL, 0)
{
_setInternal(pInfo);
}
void _setInternal(const OniSensorInfo* pInfo)
{
m_pInfo = pInfo;
if (pInfo == NULL)
{
m_videoModes._setData(NULL, 0);
}
else
{
m_videoModes._setData(static_cast<VideoMode*>(pInfo->pSupportedVideoModes), pInfo->numSupportedVideoModes);
}
}
const OniSensorInfo* m_pInfo;
Array<VideoMode> m_videoModes;
friend class VideoStream;
friend class Device;
};
class DeviceInfo : private OniDeviceInfo
{
public:
const char* getUri() const { return uri; }
const char* getVendor() const { return vendor; }
const char* getName() const { return name; }
uint16_t getUsbVendorId() const { return usbVendorId; }
uint16_t getUsbProductId() const { return usbProductId; }
friend class Device;
friend class OpenNI;
};
class VideoFrameRef
{
public:
VideoFrameRef()
{
m_pFrame = NULL;
}
~VideoFrameRef()
{
release();
}
VideoFrameRef(const VideoFrameRef& other) : m_pFrame(NULL)
{
_setFrame(other.m_pFrame);
}
VideoFrameRef& operator=(const VideoFrameRef& other)
{
_setFrame(other.m_pFrame);
return *this;
}
inline int getDataSize() const
{
return m_pFrame->dataSize;
}
inline const void* getData() const
{
return m_pFrame->data;
}
inline SensorType getSensorType() const
{
return (SensorType)m_pFrame->sensorType;
}
inline const VideoMode& getVideoMode() const
{
return static_cast<const VideoMode&>(m_pFrame->videoMode);
}
inline uint64_t getTimestamp() const
{
return m_pFrame->timestamp;
}
inline int getFrameIndex() const
{
return m_pFrame->frameIndex;
}
inline int getWidth() const
{
return m_pFrame->width;
}
inline int getHeight() const
{
return m_pFrame->height;
}
inline bool getCroppingEnabled() const
{
return m_pFrame->croppingEnabled == TRUE;
}
inline int getCropOriginX() const
{
return m_pFrame->cropOriginX;
}
inline int getCropOriginY() const
{
return m_pFrame->cropOriginY;
}
inline int getStrideInBytes() const
{
return m_pFrame->stride;
}
inline bool isValid() const
{
return m_pFrame != NULL;
}
void release()
{
if (m_pFrame != NULL)
{
oniFrameRelease(m_pFrame);
m_pFrame = NULL;
}
}
void _setFrame(OniFrame* pFrame)
{
setReference(pFrame);
if (pFrame != NULL)
{
oniFrameAddRef(pFrame);
}
}
OniFrame* _getFrame()
{
return m_pFrame;
}
private:
friend class VideoStream;
inline void setReference(OniFrame* pFrame)
{
// Initial - don't addref. This is the reference from OpenNI
release();
m_pFrame = pFrame;
}
OniFrame* m_pFrame; // const!!?
};
class VideoStream
{
public:
class NewFrameListener
{
public:
NewFrameListener() : m_callbackHandle(NULL)
{
}
virtual ~NewFrameListener()
{
}
virtual void onNewFrame(VideoStream&) = 0;
private:
friend class VideoStream;
static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void* pCookie)
{
NewFrameListener* pListener = (NewFrameListener*)pCookie;
VideoStream stream;
stream._setHandle(streamHandle);
pListener->onNewFrame(stream);
stream._setHandle(NULL);
}
OniCallbackHandle m_callbackHandle;
};
class FrameAllocator
{
public:
virtual ~FrameAllocator() {}
virtual void* allocateFrameBuffer(int size) = 0;
virtual void freeFrameBuffer(void* data) = 0;
private:
friend class VideoStream;
static void* ONI_CALLBACK_TYPE allocateFrameBufferCallback(int size, void* pCookie)
{
FrameAllocator* pThis = (FrameAllocator*)pCookie;
return pThis->allocateFrameBuffer(size);
}
static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void* data, void* pCookie)
{
FrameAllocator* pThis = (FrameAllocator*)pCookie;
pThis->freeFrameBuffer(data);
}
};
VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true)
{}
explicit VideoStream(OniStreamHandle handle) : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(false)
{
_setHandle(handle);
}
~VideoStream()
{
destroy();
}
bool isValid() const
{
return m_stream != NULL;
}
inline Status create(const Device& device, SensorType sensorType);
inline void destroy();
const SensorInfo& getSensorInfo() const
{
return m_sensorInfo;
}
Status start()
{
if (!isValid())
{
return STATUS_ERROR;
}
return (Status)oniStreamStart(m_stream);
}
void stop()
{
if (!isValid())
{
return;
}
oniStreamStop(m_stream);
}
Status readFrame(VideoFrameRef* pFrame)
{
if (!isValid())
{
return STATUS_ERROR;
}
OniFrame* pOniFrame;
Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame);
pFrame->setReference(pOniFrame);
return rc;
}
Status addNewFrameListener(NewFrameListener* pListener)
{
if (!isValid())
{
return STATUS_ERROR;
}
return (Status)oniStreamRegisterNewFrameCallback(m_stream, pListener->callback, pListener, &pListener->m_callbackHandle);
}
void removeNewFrameListener(NewFrameListener* pListener)
{
if (!isValid())
{
return;
}
oniStreamUnregisterNewFrameCallback(m_stream, pListener->m_callbackHandle);
pListener->m_callbackHandle = NULL;
}
Status setFrameBuffersAllocator(FrameAllocator* pAllocator)
{
if (!isValid())
{
return STATUS_ERROR;
}
if (pAllocator == NULL)
{
return (Status)oniStreamSetFrameBuffersAllocator(m_stream, NULL, NULL, NULL);
}
else
{
return (Status)oniStreamSetFrameBuffersAllocator(m_stream, pAllocator->allocateFrameBufferCallback, pAllocator->freeFrameBufferCallback, pAllocator);
}
}
OniStreamHandle _getHandle() const
{
return m_stream;
}
CameraSettings* getCameraSettings() {return m_pCameraSettings;}
Status getProperty(int propertyId, void* data, int* dataSize) const
{
if (!isValid())
{
return STATUS_ERROR;
}
return (Status)oniStreamGetProperty(m_stream, propertyId, data, dataSize);
}
Status setProperty(int propertyId, const void* data, int dataSize)
{
if (!isValid())
{
return STATUS_ERROR;
}
return (Status)oniStreamSetProperty(m_stream, propertyId, data, dataSize);
}
VideoMode getVideoMode() const
{
VideoMode videoMode;
getProperty<OniVideoMode>(STREAM_PROPERTY_VIDEO_MODE, static_cast<OniVideoMode*>(&videoMode));
return videoMode;
}
Status setVideoMode(const VideoMode& videoMode)
{
return setProperty<OniVideoMode>(STREAM_PROPERTY_VIDEO_MODE, static_cast<const OniVideoMode&>(videoMode));
}
int getMaxPixelValue() const
{
int maxValue;
Status rc = getProperty<int>(STREAM_PROPERTY_MAX_VALUE, &maxValue);
if (rc != STATUS_OK)
{
return 0;
}
return maxValue;
}
int getMinPixelValue() const
{
int minValue;
Status rc = getProperty<int>(STREAM_PROPERTY_MIN_VALUE, &minValue);
if (rc != STATUS_OK)
{
return 0;
}
return minValue;
}
bool isCroppingSupported() const
{
return isPropertySupported(STREAM_PROPERTY_CROPPING);
}
bool getCropping(int* pOriginX, int* pOriginY, int* pWidth, int* pHeight) const
{
OniCropping cropping;
bool enabled = false;
Status rc = getProperty<OniCropping>(STREAM_PROPERTY_CROPPING, &cropping);
if (rc == STATUS_OK)
{
*pOriginX = cropping.originX;
*pOriginY = cropping.originY;
*pWidth = cropping.width;
*pHeight = cropping.height;
enabled = (cropping.enabled == TRUE);
}
return enabled;
}
Status setCropping(int originX, int originY, int width, int height)
{
OniCropping cropping;
cropping.enabled = true;
cropping.originX = originX;
cropping.originY = originY;
cropping.width = width;
cropping.height = height;
return setProperty<OniCropping>(STREAM_PROPERTY_CROPPING, cropping);
}
Status resetCropping()
{
OniCropping cropping;
cropping.enabled = false;
return setProperty<OniCropping>(STREAM_PROPERTY_CROPPING, cropping);
}
bool getMirroringEnabled() const
{
OniBool enabled;
Status rc = getProperty<OniBool>(STREAM_PROPERTY_MIRRORING, &enabled);
if (rc != STATUS_OK)
{
return false;
}
return enabled == TRUE;
}
Status setMirroringEnabled(bool isEnabled)
{
return setProperty<OniBool>(STREAM_PROPERTY_MIRRORING, isEnabled ? TRUE : FALSE);
}
float getHorizontalFieldOfView() const
{
float horizontal = 0;
getProperty<float>(STREAM_PROPERTY_HORIZONTAL_FOV, &horizontal);
return horizontal;
}
float getVerticalFieldOfView() const
{
float vertical = 0;
getProperty<float>(STREAM_PROPERTY_VERTICAL_FOV, &vertical);
return vertical;
}
template <class T>
Status setProperty(int propertyId, const T& value)
{
return setProperty(propertyId, &value, sizeof(T));
}
template <class T>
Status getProperty(int propertyId, T* value) const
{
int size = sizeof(T);
return getProperty(propertyId, value, &size);
}
bool isPropertySupported(int propertyId) const
{
if (!isValid())
{
return false;
}
return oniStreamIsPropertySupported(m_stream, propertyId) == TRUE;
}
Status invoke(int commandId, void* data, int dataSize)
{
if (!isValid())
{
return STATUS_ERROR;
}
return (Status)oniStreamInvoke(m_stream, commandId, data, dataSize);
}
template <class T>
Status invoke(int commandId, T& value)
{
return invoke(commandId, &value, sizeof(T));
}
bool isCommandSupported(int commandId) const
{
if (!isValid())
{
return false;
}
return (Status)oniStreamIsCommandSupported(m_stream, commandId) == TRUE;
}
private:
friend class Device;
void _setHandle(OniStreamHandle stream)
{
m_sensorInfo._setInternal(NULL);
m_stream = stream;
if (stream != NULL)
{
m_sensorInfo._setInternal(oniStreamGetSensorInfo(m_stream));
}
}
private:
VideoStream(const VideoStream& other);
VideoStream& operator=(const VideoStream& other);
OniStreamHandle m_stream;
SensorInfo m_sensorInfo;
CameraSettings* m_pCameraSettings;
bool m_isOwner;
};
class Device
{
public:
Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true)
{
clearSensors();
}
explicit Device(OniDeviceHandle handle) : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(false)
{
_setHandle(handle);
}
~Device()
{
if (m_device != NULL)
{
close();
}
}
inline Status open(const char* uri);
inline void close();
const DeviceInfo& getDeviceInfo() const
{
return m_deviceInfo;
}
bool hasSensor(SensorType sensorType)
{
int i;
for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
{
if (m_aSensorInfo[i].getSensorType() == sensorType)
{
return true;
}
}
if (i == ONI_MAX_SENSORS)
{
return false;
}
const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType);
if (pInfo == NULL)
{
return false;
}
m_aSensorInfo[i]._setInternal(pInfo);
return true;
}
const SensorInfo* getSensorInfo(SensorType sensorType)
{
int i;
for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
{
if (m_aSensorInfo[i].getSensorType() == sensorType)
{
return &m_aSensorInfo[i];
}
}
// not found. check to see we have additional space
if (i == ONI_MAX_SENSORS)
{
return NULL;
}
const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType);
if (pInfo == NULL)
{
return NULL;
}
m_aSensorInfo[i]._setInternal(pInfo);
return &m_aSensorInfo[i];
}
OniDeviceHandle _getHandle() const
{
return m_device;
}
PlaybackControl* getPlaybackControl() {return m_pPlaybackControl;}
Status getProperty(int propertyId, void* data, int* dataSize) const
{
return (Status)oniDeviceGetProperty(m_device, propertyId, data, dataSize);
}
Status setProperty(int propertyId, const void* data, int dataSize)
{
return (Status)oniDeviceSetProperty(m_device, propertyId, data, dataSize);
}
bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const
{
return (oniDeviceIsImageRegistrationModeSupported(m_device, (OniImageRegistrationMode)mode) == TRUE);
}
ImageRegistrationMode getImageRegistrationMode() const
{
ImageRegistrationMode mode;
Status rc = getProperty<ImageRegistrationMode>(DEVICE_PROPERTY_IMAGE_REGISTRATION, &mode);
if (rc != STATUS_OK)
{
return IMAGE_REGISTRATION_OFF;
}
return mode;
}
Status setImageRegistrationMode(ImageRegistrationMode mode)
{
return setProperty<ImageRegistrationMode>(DEVICE_PROPERTY_IMAGE_REGISTRATION, mode);
}
bool isValid() const
{
return m_device != NULL;
}
bool isFile() const
{
return isPropertySupported(DEVICE_PROPERTY_PLAYBACK_SPEED) &&
isPropertySupported(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED) &&
isCommandSupported(DEVICE_COMMAND_SEEK);
}
Status setDepthColorSyncEnabled(bool isEnabled)
{
Status rc = STATUS_OK;
if (isEnabled)
{
rc = (Status)oniDeviceEnableDepthColorSync(m_device);
}
else
{
oniDeviceDisableDepthColorSync(m_device);
}
return rc;
}
bool getDepthColorSyncEnabled()
{
return oniDeviceGetDepthColorSyncEnabled(m_device) == TRUE;
}
template <class T>
Status setProperty(int propertyId, const T& value)
{
return setProperty(propertyId, &value, sizeof(T));
}
template <class T>
Status getProperty(int propertyId, T* value) const
{
int size = sizeof(T);
return getProperty(propertyId, value, &size);
}
bool isPropertySupported(int propertyId) const
{
return oniDeviceIsPropertySupported(m_device, propertyId) == TRUE;
}
Status invoke(int commandId, void* data, int dataSize)
{
return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize);
}
template <class T>
Status invoke(int propertyId, T& value)
{
return invoke(propertyId, &value, sizeof(T));
}
bool isCommandSupported(int commandId) const
{
return oniDeviceIsCommandSupported(m_device, commandId) == TRUE;
}
inline Status _openEx(const char* uri, const char* mode);
private:
Device(const Device&);
Device& operator=(const Device&);
void clearSensors()
{
for (int i = 0; i < ONI_MAX_SENSORS; ++i)
{
m_aSensorInfo[i]._setInternal(NULL);
}
}
inline Status _setHandle(OniDeviceHandle deviceHandle);
private:
PlaybackControl* m_pPlaybackControl;
OniDeviceHandle m_device;
DeviceInfo m_deviceInfo;
SensorInfo m_aSensorInfo[ONI_MAX_SENSORS];
bool m_isOwner;
};
class PlaybackControl
{
public:
~PlaybackControl()
{
detach();
}
float getSpeed() const
{
if (!isValid())
{
return 0.0f;
}
float speed;
Status rc = m_pDevice->getProperty<float>(DEVICE_PROPERTY_PLAYBACK_SPEED, &speed);
if (rc != STATUS_OK)
{
return 1.0f;
}
return speed;
}
Status setSpeed(float speed)
{
if (!isValid())
{
return STATUS_NO_DEVICE;
}
return m_pDevice->setProperty<float>(DEVICE_PROPERTY_PLAYBACK_SPEED, speed);
}
bool getRepeatEnabled() const
{
if (!isValid())
{
return false;
}
OniBool repeat;
Status rc = m_pDevice->getProperty<OniBool>(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, &repeat);
if (rc != STATUS_OK)
{
return false;
}
return repeat == TRUE;
}
Status setRepeatEnabled(bool repeat)
{
if (!isValid())
{
return STATUS_NO_DEVICE;
}
return m_pDevice->setProperty<OniBool>(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, repeat ? TRUE : FALSE);
}
Status seek(const VideoStream& stream, int frameIndex)
{
if (!isValid())
{
return STATUS_NO_DEVICE;
}
OniSeek seek;
seek.frameIndex = frameIndex;
seek.stream = stream._getHandle();
return m_pDevice->invoke(DEVICE_COMMAND_SEEK, seek);
}
int getNumberOfFrames(const VideoStream& stream) const
{
int numOfFrames = -1;
Status rc = stream.getProperty<int>(STREAM_PROPERTY_NUMBER_OF_FRAMES, &numOfFrames);
if (rc != STATUS_OK)
{
return 0;
}
return numOfFrames;
}
bool isValid() const
{
return m_pDevice != NULL;
}
private:
Status attach(Device* device)
{
if (!device->isValid() || !device->isFile())
{
return STATUS_ERROR;
}
detach();
m_pDevice = device;
return STATUS_OK;
}
void detach()
{
m_pDevice = NULL;
}
friend class Device;
PlaybackControl(Device* pDevice) : m_pDevice(NULL)
{
if (pDevice != NULL)
{
attach(pDevice);
}
}
Device* m_pDevice;
};
class CameraSettings
{
public:
// setters
Status setAutoExposureEnabled(bool enabled)
{
return setProperty(STREAM_PROPERTY_AUTO_EXPOSURE, enabled ? TRUE : FALSE);
}
Status setAutoWhiteBalanceEnabled(bool enabled)
{
return setProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, enabled ? TRUE : FALSE);
}
bool getAutoExposureEnabled() const
{
OniBool enabled = FALSE;
Status rc = getProperty(STREAM_PROPERTY_AUTO_EXPOSURE, &enabled);
return rc == STATUS_OK && enabled == TRUE;
}
bool getAutoWhiteBalanceEnabled() const
{
OniBool enabled = FALSE;
Status rc = getProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, &enabled);
return rc == STATUS_OK && enabled == TRUE;
}
Status setGain(int gain)
{
return setProperty(STREAM_PROPERTY_GAIN, gain);
}
Status setExposure(int exposure)
{
return setProperty(STREAM_PROPERTY_EXPOSURE, exposure);
}
int getGain()
{
int gain;
Status rc = getProperty(STREAM_PROPERTY_GAIN, &gain);
if (rc != STATUS_OK)
{
return 100;
}
return gain;
}
int getExposure()
{
int exposure;
Status rc = getProperty(STREAM_PROPERTY_EXPOSURE, &exposure);
if (rc != STATUS_OK)
{
return 0;
}
return exposure;
}
bool isValid() const {return m_pStream != NULL;}
private:
template <class T>
Status getProperty(int propertyId, T* value) const
{
if (!isValid()) return STATUS_NOT_SUPPORTED;
return m_pStream->getProperty<T>(propertyId, value);
}
template <class T>
Status setProperty(int propertyId, const T& value)
{
if (!isValid()) return STATUS_NOT_SUPPORTED;
return m_pStream->setProperty<T>(propertyId, value);
}
friend class VideoStream;
CameraSettings(VideoStream* pStream)
{
m_pStream = pStream;
}
VideoStream* m_pStream;
};
class OpenNI
{
public:
class DeviceConnectedListener
{
public:
DeviceConnectedListener()
{
m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback;
m_deviceConnectedCallbacks.deviceDisconnected = NULL;
m_deviceConnectedCallbacks.deviceStateChanged = NULL;
m_deviceConnectedCallbacksHandle = NULL;
}
virtual ~DeviceConnectedListener()
{
}
virtual void onDeviceConnected(const DeviceInfo*) = 0;
private:
static void ONI_CALLBACK_TYPE deviceConnectedCallback(const OniDeviceInfo* pInfo, void* pCookie)
{
DeviceConnectedListener* pListener = (DeviceConnectedListener*)pCookie;
pListener->onDeviceConnected(static_cast<const DeviceInfo*>(pInfo));
}
friend class OpenNI;
OniDeviceCallbacks m_deviceConnectedCallbacks;
OniCallbackHandle m_deviceConnectedCallbacksHandle;
};
class DeviceDisconnectedListener
{
public:
DeviceDisconnectedListener()
{
m_deviceDisconnectedCallbacks.deviceConnected = NULL;
m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback;
m_deviceDisconnectedCallbacks.deviceStateChanged = NULL;
m_deviceDisconnectedCallbacksHandle = NULL;
}
virtual ~DeviceDisconnectedListener()
{
}
virtual void onDeviceDisconnected(const DeviceInfo*) = 0;
private:
static void ONI_CALLBACK_TYPE deviceDisconnectedCallback(const OniDeviceInfo* pInfo, void* pCookie)
{
DeviceDisconnectedListener* pListener = (DeviceDisconnectedListener*)pCookie;
pListener->onDeviceDisconnected(static_cast<const DeviceInfo*>(pInfo));
}
friend class OpenNI;
OniDeviceCallbacks m_deviceDisconnectedCallbacks;
OniCallbackHandle m_deviceDisconnectedCallbacksHandle;
};
class DeviceStateChangedListener
{
public:
DeviceStateChangedListener()
{
m_deviceStateChangedCallbacks.deviceConnected = NULL;
m_deviceStateChangedCallbacks.deviceDisconnected = NULL;
m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback;
m_deviceStateChangedCallbacksHandle = NULL;
}
virtual ~DeviceStateChangedListener()
{
}
virtual void onDeviceStateChanged(const DeviceInfo*, DeviceState) = 0;
private:
static void ONI_CALLBACK_TYPE deviceStateChangedCallback(const OniDeviceInfo* pInfo, OniDeviceState state, void* pCookie)
{
DeviceStateChangedListener* pListener = (DeviceStateChangedListener*)pCookie;
pListener->onDeviceStateChanged(static_cast<const DeviceInfo*>(pInfo), DeviceState(state));
}
friend class OpenNI;
OniDeviceCallbacks m_deviceStateChangedCallbacks;
OniCallbackHandle m_deviceStateChangedCallbacksHandle;
};
static Status initialize()
{
return (Status)oniInitialize(ONI_API_VERSION); // provide version of API, to make sure proper struct sizes are used
}
static void shutdown()
{
oniShutdown();
}
static Version getVersion()
{
OniVersion oniVersion = oniGetVersion();
Version version;
version.major = oniVersion.major;
version.minor = oniVersion.minor;
version.maintenance = oniVersion.maintenance;
version.build = oniVersion.build;
return version;
}
static const char* getExtendedError()
{
return oniGetExtendedError();
}
static void enumerateDevices(Array<DeviceInfo>* deviceInfoList)
{
OniDeviceInfo* m_pDeviceInfos;
int m_deviceInfoCount;
oniGetDeviceList(&m_pDeviceInfos, &m_deviceInfoCount);
deviceInfoList->_setData((DeviceInfo*)m_pDeviceInfos, m_deviceInfoCount, true);
oniReleaseDeviceList(m_pDeviceInfos);
}
static Status waitForAnyStream(VideoStream** pStreams, int streamCount, int* pReadyStreamIndex, int timeout = TIMEOUT_FOREVER)
{
static const int ONI_MAX_STREAMS = 50;
OniStreamHandle streams[ONI_MAX_STREAMS];
if (streamCount > ONI_MAX_STREAMS)
{
printf("Too many streams for wait: %d > %d\n", streamCount, ONI_MAX_STREAMS);
return STATUS_BAD_PARAMETER;
}
*pReadyStreamIndex = -1;
for (int i = 0; i < streamCount; ++i)
{
if (pStreams[i] != NULL)
{
streams[i] = pStreams[i]->_getHandle();
}
else
{
streams[i] = NULL;
}
}
Status rc = (Status)oniWaitForAnyStream(streams, streamCount, pReadyStreamIndex, timeout);
return rc;
}
static Status addDeviceConnectedListener(DeviceConnectedListener* pListener)
{
if (pListener->m_deviceConnectedCallbacksHandle != NULL)
{
return STATUS_ERROR;
}
return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceConnectedCallbacks, pListener, &pListener->m_deviceConnectedCallbacksHandle);
}
static Status addDeviceDisconnectedListener(DeviceDisconnectedListener* pListener)
{
if (pListener->m_deviceDisconnectedCallbacksHandle != NULL)
{
return STATUS_ERROR;
}
return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceDisconnectedCallbacks, pListener, &pListener->m_deviceDisconnectedCallbacksHandle);
}
static Status addDeviceStateChangedListener(DeviceStateChangedListener* pListener)
{
if (pListener->m_deviceStateChangedCallbacksHandle != NULL)
{
return STATUS_ERROR;
}
return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceStateChangedCallbacks, pListener, &pListener->m_deviceStateChangedCallbacksHandle);
}
static void removeDeviceConnectedListener(DeviceConnectedListener* pListener)
{
oniUnregisterDeviceCallbacks(pListener->m_deviceConnectedCallbacksHandle);
pListener->m_deviceConnectedCallbacksHandle = NULL;
}
static void removeDeviceDisconnectedListener(DeviceDisconnectedListener* pListener)
{
oniUnregisterDeviceCallbacks(pListener->m_deviceDisconnectedCallbacksHandle);
pListener->m_deviceDisconnectedCallbacksHandle = NULL;
}
static void removeDeviceStateChangedListener(DeviceStateChangedListener* pListener)
{
oniUnregisterDeviceCallbacks(pListener->m_deviceStateChangedCallbacksHandle);
pListener->m_deviceStateChangedCallbacksHandle = NULL;
}
static Status setLogOutputFolder(const char *strLogOutputFolder)
{
return (Status)oniSetLogOutputFolder(strLogOutputFolder);
}
static Status getLogFileName(char *strFileName, int nBufferSize)
{
return (Status)oniGetLogFileName(strFileName, nBufferSize);
}
static Status setLogMinSeverity(int nMinSeverity)
{
return(Status) oniSetLogMinSeverity(nMinSeverity);
}
static Status setLogConsoleOutput(bool bConsoleOutput)
{
return (Status)oniSetLogConsoleOutput(bConsoleOutput);
}
static Status setLogFileOutput(bool bFileOutput)
{
return (Status)oniSetLogFileOutput(bFileOutput);
}
#if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM
static Status setLogAndroidOutput(bool bAndroidOutput)
{
return (Status)oniSetLogAndroidOutput(bAndroidOutput);
}
#endif
private:
OpenNI()
{
}
};
class CoordinateConverter
{
public:
static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, int* pDepthX, int* pDepthY, DepthPixel* pDepthZ)
{
float depthX, depthY, depthZ;
Status rc = (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, &depthX, &depthY, &depthZ);
*pDepthX = (int)depthX;
*pDepthY = (int)depthY;
*pDepthZ = (DepthPixel)depthZ;
return rc;
}
static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ)
{
return (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, pDepthX, pDepthY, pDepthZ);
}
static Status convertDepthToWorld(const VideoStream& depthStream, int depthX, int depthY, DepthPixel depthZ, float* pWorldX, float* pWorldY, float* pWorldZ)
{
return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), float(depthX), float(depthY), float(depthZ), pWorldX, pWorldY, pWorldZ);
}
static Status convertDepthToWorld(const VideoStream& depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ)
{
return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), depthX, depthY, depthZ, pWorldX, pWorldY, pWorldZ);
}
static Status convertDepthToColor(const VideoStream& depthStream, const VideoStream& colorStream, int depthX, int depthY, DepthPixel depthZ, int* pColorX, int* pColorY)
{
return (Status)oniCoordinateConverterDepthToColor(depthStream._getHandle(), colorStream._getHandle(), depthX, depthY, depthZ, pColorX, pColorY);
}
};
class Recorder
{
public:
Recorder() : m_recorder(NULL)
{
}
~Recorder()
{
destroy();
}
Status create(const char* fileName)
{
if (!isValid())
{
return (Status)oniCreateRecorder(fileName, &m_recorder);
}
return STATUS_ERROR;
}
bool isValid() const
{
return NULL != getHandle();
}
Status attach(VideoStream& stream, bool allowLossyCompression = false)
{
if (!isValid() || !stream.isValid())
{
return STATUS_ERROR;
}
return (Status)oniRecorderAttachStream(
m_recorder,
stream._getHandle(),
allowLossyCompression);
}
Status start()
{
if (!isValid())
{
return STATUS_ERROR;
}
return (Status)oniRecorderStart(m_recorder);
}
void stop()
{
if (isValid())
{
oniRecorderStop(m_recorder);
}
}
void destroy()
{
if (isValid())
{
oniRecorderDestroy(&m_recorder);
}
}
private:
Recorder(const Recorder&);
Recorder& operator=(const Recorder&);
OniRecorderHandle getHandle() const
{
return m_recorder;
}
OniRecorderHandle m_recorder;
};
// Implemetation
Status VideoStream::create(const Device& device, SensorType sensorType)
{
OniStreamHandle streamHandle;
Status rc = (Status)oniDeviceCreateStream(device._getHandle(), (OniSensorType)sensorType, &streamHandle);
if (rc != STATUS_OK)
{
return rc;
}
m_isOwner = true;
_setHandle(streamHandle);
if (isPropertySupported(STREAM_PROPERTY_AUTO_WHITE_BALANCE) && isPropertySupported(STREAM_PROPERTY_AUTO_EXPOSURE))
{
m_pCameraSettings = new CameraSettings(this);
}
return STATUS_OK;
}
void VideoStream::destroy()
{
if (!isValid())
{
return;
}
if (m_pCameraSettings != NULL)
{
delete m_pCameraSettings;
m_pCameraSettings = NULL;
}
if (m_stream != NULL)
{
if(m_isOwner)
oniStreamDestroy(m_stream);
m_stream = NULL;
}
}
Status Device::open(const char* uri)
{
//If we are not the owners, we stick with our own device
if(!m_isOwner)
{
if(isValid()){
return STATUS_OK;
}else{
return STATUS_OUT_OF_FLOW;
}
}
OniDeviceHandle deviceHandle;
Status rc = (Status)oniDeviceOpen(uri, &deviceHandle);
if (rc != STATUS_OK)
{
return rc;
}
_setHandle(deviceHandle);
return STATUS_OK;
}
Status Device::_openEx(const char* uri, const char* mode)
{
//If we are not the owners, we stick with our own device
if(!m_isOwner)
{
if(isValid()){
return STATUS_OK;
}else{
return STATUS_OUT_OF_FLOW;
}
}
OniDeviceHandle deviceHandle;
Status rc = (Status)oniDeviceOpenEx(uri, mode, &deviceHandle);
if (rc != STATUS_OK)
{
return rc;
}
_setHandle(deviceHandle);
return STATUS_OK;
}
Status Device::_setHandle(OniDeviceHandle deviceHandle)
{
if (m_device == NULL)
{
m_device = deviceHandle;
clearSensors();
oniDeviceGetInfo(m_device, &m_deviceInfo);
if (isFile())
{
m_pPlaybackControl = new PlaybackControl(this);
}
// Read deviceInfo
return STATUS_OK;
}
return STATUS_OUT_OF_FLOW;
}
void Device::close()
{
if (m_pPlaybackControl != NULL)
{
delete m_pPlaybackControl;
m_pPlaybackControl = NULL;
}
if (m_device != NULL)
{
if(m_isOwner)
{
oniDeviceClose(m_device);
}
m_device = NULL;
}
}
}
#endif // _OPEN_NI_HPP_
OniEnums.h
openni::Array
Definition OpenNI.h:101
openni::Array::getSize
int getSize() const
Definition OpenNI.h:129
openni::Array::Array
Array()
Definition OpenNI.h:106
openni::Array::Array
Array(const T *data, int count)
Definition OpenNI.h:115
openni::Array::operator[]
const T & operator[](int index) const
Definition OpenNI.h:134
openni::Array::~Array
~Array()
Definition OpenNI.h:120
openni::CameraSettings
Definition OpenNI.h:1841
openni::CameraSettings::setAutoExposureEnabled
Status setAutoExposureEnabled(bool enabled)
Definition OpenNI.h:1844
openni::CameraSettings::setExposure
Status setExposure(int exposure)
Definition OpenNI.h:1872
openni::CameraSettings::setGain
Status setGain(int gain)
Definition OpenNI.h:1868
openni::CameraSettings::getAutoWhiteBalanceEnabled
bool getAutoWhiteBalanceEnabled() const
Definition OpenNI.h:1860
openni::CameraSettings::VideoStream
friend class VideoStream
Definition OpenNI.h:1914
openni::CameraSettings::getGain
int getGain()
Definition OpenNI.h:1876
openni::CameraSettings::getExposure
int getExposure()
Definition OpenNI.h:1886
openni::CameraSettings::isValid
bool isValid() const
Definition OpenNI.h:1897
openni::CameraSettings::setAutoWhiteBalanceEnabled
Status setAutoWhiteBalanceEnabled(bool enabled)
Definition OpenNI.h:1848
openni::CameraSettings::getAutoExposureEnabled
bool getAutoExposureEnabled() const
Definition OpenNI.h:1853
openni::CoordinateConverter
Definition OpenNI.h:2393
openni::CoordinateConverter::convertDepthToWorld
static Status convertDepthToWorld(const VideoStream &depthStream, int depthX, int depthY, DepthPixel depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Definition OpenNI.h:2440
openni::CoordinateConverter::convertWorldToDepth
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, int *pDepthX, int *pDepthY, DepthPixel *pDepthZ)
Definition OpenNI.h:2405
openni::CoordinateConverter::convertDepthToColor
static Status convertDepthToColor(const VideoStream &depthStream, const VideoStream &colorStream, int depthX, int depthY, DepthPixel depthZ, int *pColorX, int *pColorY)
Definition OpenNI.h:2471
openni::CoordinateConverter::convertDepthToWorld
static Status convertDepthToWorld(const VideoStream &depthStream, float depthX, float depthY, float depthZ, float *pWorldX, float *pWorldY, float *pWorldZ)
Definition OpenNI.h:2455
openni::CoordinateConverter::convertWorldToDepth
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, float *pDepthX, float *pDepthY, float *pDepthZ)
Definition OpenNI.h:2425
openni::Device
Definition OpenNI.h:1243
openni::Device::setProperty
Status setProperty(int propertyId, const T &value)
Definition OpenNI.h:1551
openni::Device::Device
Device()
Definition OpenNI.h:1249
openni::Device::close
void close()
Definition OpenNI.h:2728
openni::Device::open
Status open(const char *uri)
Definition OpenNI.h:2658
openni::Device::setImageRegistrationMode
Status setImageRegistrationMode(ImageRegistrationMode mode)
Definition OpenNI.h:1486
openni::Device::isPropertySupported
bool isPropertySupported(int propertyId) const
Definition OpenNI.h:1577
openni::Device::getProperty
Status getProperty(int propertyId, T *value) const
Definition OpenNI.h:1566
openni::Device::isFile
bool isFile() const
Definition OpenNI.h:1504
openni::Device::Device
Device(OniDeviceHandle handle)
Definition OpenNI.h:1258
openni::Device::~Device
~Device()
Definition OpenNI.h:1267
openni::Device::invoke
Status invoke(int commandId, void *data, int dataSize)
Definition OpenNI.h:1591
openni::Device::isCommandSupported
bool isCommandSupported(int commandId) const
Definition OpenNI.h:1616
openni::Device::isImageRegistrationModeSupported
bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const
Definition OpenNI.h:1450
openni::Device::setDepthColorSyncEnabled
Status setDepthColorSyncEnabled(bool isEnabled)
Definition OpenNI.h:1519
openni::Device::getPlaybackControl
PlaybackControl * getPlaybackControl()
Definition OpenNI.h:1409
openni::Device::invoke
Status invoke(int propertyId, T &value)
Definition OpenNI.h:1606
openni::Device::getSensorInfo
const SensorInfo * getSensorInfo(SensorType sensorType)
Definition OpenNI.h:1369
openni::Device::getProperty
Status getProperty(int propertyId, void *data, int *dataSize) const
Definition OpenNI.h:1422
openni::Device::getDeviceInfo
const DeviceInfo & getDeviceInfo() const
Definition OpenNI.h:1322
openni::Device::setProperty
Status setProperty(int propertyId, const void *data, int dataSize)
Definition OpenNI.h:1438
openni::Device::getDepthColorSyncEnabled
bool getDepthColorSyncEnabled()
Definition OpenNI.h:1535
openni::Device::getImageRegistrationMode
ImageRegistrationMode getImageRegistrationMode() const
Definition OpenNI.h:1462
openni::Device::isValid
bool isValid() const
Definition OpenNI.h:1495
openni::Device::hasSensor
bool hasSensor(SensorType sensorType)
Definition OpenNI.h:1334
openni::DeviceInfo
Definition OpenNI.h:373
openni::DeviceInfo::OpenNI
friend class OpenNI
Definition OpenNI.h:390
openni::DeviceInfo::Device
friend class Device
Definition OpenNI.h:389
openni::DeviceInfo::getUri
const char * getUri() const
Definition OpenNI.h:379
openni::DeviceInfo::getVendor
const char * getVendor() const
Definition OpenNI.h:381
openni::DeviceInfo::getName
const char * getName() const
Definition OpenNI.h:383
openni::DeviceInfo::getUsbProductId
uint16_t getUsbProductId() const
Definition OpenNI.h:387
openni::DeviceInfo::getUsbVendorId
uint16_t getUsbVendorId() const
Definition OpenNI.h:385
openni::OpenNI::DeviceConnectedListener
Definition OpenNI.h:1956
openni::OpenNI::DeviceConnectedListener::OpenNI
friend class OpenNI
Definition OpenNI.h:1989
openni::OpenNI::DeviceConnectedListener::~DeviceConnectedListener
virtual ~DeviceConnectedListener()
Definition OpenNI.h:1966
openni::OpenNI::DeviceConnectedListener::DeviceConnectedListener
DeviceConnectedListener()
Definition OpenNI.h:1958
openni::OpenNI::DeviceConnectedListener::onDeviceConnected
virtual void onDeviceConnected(const DeviceInfo *)=0
openni::OpenNI::DeviceDisconnectedListener
Definition OpenNI.h:2011
openni::OpenNI::DeviceDisconnectedListener::OpenNI
friend class OpenNI
Definition OpenNI.h:2041
openni::OpenNI::DeviceDisconnectedListener::onDeviceDisconnected
virtual void onDeviceDisconnected(const DeviceInfo *)=0
openni::OpenNI::DeviceDisconnectedListener::DeviceDisconnectedListener
DeviceDisconnectedListener()
Definition OpenNI.h:2013
openni::OpenNI::DeviceDisconnectedListener::~DeviceDisconnectedListener
virtual ~DeviceDisconnectedListener()
Definition OpenNI.h:2021
openni::OpenNI::DeviceStateChangedListener
Definition OpenNI.h:2059
openni::OpenNI::DeviceStateChangedListener::OpenNI
friend class OpenNI
Definition OpenNI.h:2087
openni::OpenNI::DeviceStateChangedListener::onDeviceStateChanged
virtual void onDeviceStateChanged(const DeviceInfo *, DeviceState)=0
openni::OpenNI::DeviceStateChangedListener::DeviceStateChangedListener
DeviceStateChangedListener()
Definition OpenNI.h:2061
openni::OpenNI::DeviceStateChangedListener::~DeviceStateChangedListener
virtual ~DeviceStateChangedListener()
Definition OpenNI.h:2069
openni::OpenNI
Definition OpenNI.h:1937
openni::OpenNI::initialize
static Status initialize()
Definition OpenNI.h:2097
openni::OpenNI::addDeviceConnectedListener
static Status addDeviceConnectedListener(DeviceConnectedListener *pListener)
Definition OpenNI.h:2193
openni::OpenNI::setLogConsoleOutput
static Status setLogConsoleOutput(bool bConsoleOutput)
Definition OpenNI.h:2317
openni::OpenNI::shutdown
static void shutdown()
Definition OpenNI.h:2106
openni::OpenNI::removeDeviceConnectedListener
static void removeDeviceConnectedListener(DeviceConnectedListener *pListener)
Definition OpenNI.h:2238
openni::OpenNI::setLogMinSeverity
static Status setLogMinSeverity(int nMinSeverity)
Definition OpenNI.h:2304
openni::OpenNI::getExtendedError
static const char * getExtendedError()
Definition OpenNI.h:2132
openni::OpenNI::setLogOutputFolder
static Status setLogOutputFolder(const char *strLogOutputFolder)
Definition OpenNI.h:2276
openni::OpenNI::setLogFileOutput
static Status setLogFileOutput(bool bFileOutput)
Definition OpenNI.h:2330
openni::OpenNI::addDeviceDisconnectedListener
static Status addDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
Definition OpenNI.h:2208
openni::OpenNI::addDeviceStateChangedListener
static Status addDeviceStateChangedListener(DeviceStateChangedListener *pListener)
Definition OpenNI.h:2223
openni::OpenNI::getVersion
static Version getVersion()
Definition OpenNI.h:2114
openni::OpenNI::removeDeviceStateChangedListener
static void removeDeviceStateChangedListener(DeviceStateChangedListener *pListener)
Definition OpenNI.h:2262
openni::OpenNI::waitForAnyStream
static Status waitForAnyStream(VideoStream **pStreams, int streamCount, int *pReadyStreamIndex, int timeout=TIMEOUT_FOREVER)
Definition OpenNI.h:2158
openni::OpenNI::getLogFileName
static Status getLogFileName(char *strFileName, int nBufferSize)
Definition OpenNI.h:2290
openni::OpenNI::enumerateDevices
static void enumerateDevices(Array< DeviceInfo > *deviceInfoList)
Definition OpenNI.h:2141
openni::OpenNI::removeDeviceDisconnectedListener
static void removeDeviceDisconnectedListener(DeviceDisconnectedListener *pListener)
Definition OpenNI.h:2250
openni::PlaybackControl
Definition OpenNI.h:1662
openni::PlaybackControl::~PlaybackControl
~PlaybackControl()
Definition OpenNI.h:1670
openni::PlaybackControl::setSpeed
Status setSpeed(float speed)
Definition OpenNI.h:1716
openni::PlaybackControl::getNumberOfFrames
int getNumberOfFrames(const VideoStream &stream) const
Definition OpenNI.h:1795
openni::PlaybackControl::Device
friend class Device
Definition OpenNI.h:1828
openni::PlaybackControl::getRepeatEnabled
bool getRepeatEnabled() const
Definition OpenNI.h:1730
openni::PlaybackControl::seek
Status seek(const VideoStream &stream, int frameIndex)
Definition OpenNI.h:1775
openni::PlaybackControl::setRepeatEnabled
Status setRepeatEnabled(bool repeat)
Definition OpenNI.h:1755
openni::PlaybackControl::isValid
bool isValid() const
Definition OpenNI.h:1806
openni::PlaybackControl::getSpeed
float getSpeed() const
Definition OpenNI.h:1695
openni::Recorder
Definition OpenNI.h:2492
openni::Recorder::~Recorder
~Recorder()
Definition OpenNI.h:2505
openni::Recorder::stop
void stop()
Definition OpenNI.h:2581
openni::Recorder::destroy
void destroy()
Definition OpenNI.h:2592
openni::Recorder::create
Status create(const char *fileName)
Definition OpenNI.h:2521
openni::Recorder::Recorder
Recorder()
Definition OpenNI.h:2498
openni::Recorder::attach
Status attach(VideoStream &stream, bool allowLossyCompression=false)
Definition OpenNI.h:2551
openni::Recorder::isValid
bool isValid() const
Definition OpenNI.h:2536
openni::Recorder::start
Status start()
Definition OpenNI.h:2569
openni::SensorInfo
Definition OpenNI.h:315
openni::SensorInfo::getSensorType
SensorType getSensorType() const
Definition OpenNI.h:321
openni::SensorInfo::VideoStream
friend class VideoStream
Definition OpenNI.h:359
openni::SensorInfo::Device
friend class Device
Definition OpenNI.h:360
openni::SensorInfo::getSupportedVideoModes
const Array< VideoMode > & getSupportedVideoModes() const
Definition OpenNI.h:330
openni::VideoFrameRef
Definition OpenNI.h:407
openni::VideoFrameRef::~VideoFrameRef
~VideoFrameRef()
Definition OpenNI.h:421
openni::VideoFrameRef::getCroppingEnabled
bool getCroppingEnabled() const
Definition OpenNI.h:542
openni::VideoFrameRef::operator=
VideoFrameRef & operator=(const VideoFrameRef &other)
Definition OpenNI.h:441
openni::VideoFrameRef::getTimestamp
uint64_t getTimestamp() const
Definition OpenNI.h:497
openni::VideoFrameRef::getFrameIndex
int getFrameIndex() const
Definition OpenNI.h:512
openni::VideoFrameRef::VideoStream
friend class VideoStream
Definition OpenNI.h:613
openni::VideoFrameRef::isValid
bool isValid() const
Definition OpenNI.h:578
openni::VideoFrameRef::getDataSize
int getDataSize() const
Definition OpenNI.h:452
openni::VideoFrameRef::getCropOriginY
int getCropOriginY() const
Definition OpenNI.h:560
openni::VideoFrameRef::getHeight
int getHeight() const
Definition OpenNI.h:533
openni::VideoFrameRef::release
void release()
Definition OpenNI.h:587
openni::VideoFrameRef::getSensorType
SensorType getSensorType() const
Definition OpenNI.h:473
openni::VideoFrameRef::getCropOriginX
int getCropOriginX() const
Definition OpenNI.h:551
openni::VideoFrameRef::getWidth
int getWidth() const
Definition OpenNI.h:523
openni::VideoFrameRef::getStrideInBytes
int getStrideInBytes() const
Definition OpenNI.h:570
openni::VideoFrameRef::VideoFrameRef
VideoFrameRef(const VideoFrameRef &other)
Definition OpenNI.h:431
openni::VideoFrameRef::getData
const void * getData() const
Definition OpenNI.h:462
openni::VideoFrameRef::getVideoMode
const VideoMode & getVideoMode() const
Definition OpenNI.h:485
openni::VideoFrameRef::VideoFrameRef
VideoFrameRef()
Definition OpenNI.h:413
openni::VideoMode
Definition OpenNI.h:204
openni::VideoMode::setResolution
void setResolution(int resolutionX, int resolutionY)
Definition OpenNI.h:278
openni::VideoMode::SensorInfo
friend class SensorInfo
Definition OpenNI.h:292
openni::VideoMode::VideoFrameRef
friend class VideoFrameRef
Definition OpenNI.h:294
openni::VideoMode::VideoStream
friend class VideoStream
Definition OpenNI.h:293
openni::VideoMode::VideoMode
VideoMode(const VideoMode &other)
Definition OpenNI.h:219
openni::VideoMode::VideoMode
VideoMode()
Definition OpenNI.h:211
openni::VideoMode::getResolutionX
int getResolutionX() const
Definition OpenNI.h:249
openni::VideoMode::getResolutionY
int getResolutionY() const
Definition OpenNI.h:255
openni::VideoMode::getPixelFormat
PixelFormat getPixelFormat() const
Definition OpenNI.h:243
openni::VideoMode::setFps
void setFps(int fps)
Definition OpenNI.h:290
openni::VideoMode::operator=
VideoMode & operator=(const VideoMode &other)
Definition OpenNI.h:230
openni::VideoMode::getFps
int getFps() const
Definition OpenNI.h:261
openni::VideoMode::setPixelFormat
void setPixelFormat(PixelFormat format)
Definition OpenNI.h:269
openni::VideoStream::FrameAllocator
Definition OpenNI.h:689
openni::VideoStream::FrameAllocator::allocateFrameBuffer
virtual void * allocateFrameBuffer(int size)=0
openni::VideoStream::FrameAllocator::~FrameAllocator
virtual ~FrameAllocator()
Definition OpenNI.h:691
openni::VideoStream::FrameAllocator::VideoStream
friend class VideoStream
Definition OpenNI.h:696
openni::VideoStream::FrameAllocator::freeFrameBuffer
virtual void freeFrameBuffer(void *data)=0
openni::VideoStream::NewFrameListener
Definition OpenNI.h:656
openni::VideoStream::NewFrameListener::VideoStream
friend class VideoStream
Definition OpenNI.h:675
openni::VideoStream::NewFrameListener::onNewFrame
virtual void onNewFrame(VideoStream &)=0
openni::VideoStream::NewFrameListener::NewFrameListener
NewFrameListener()
Definition OpenNI.h:661
openni::VideoStream::NewFrameListener::~NewFrameListener
virtual ~NewFrameListener()
Definition OpenNI.h:665
openni::VideoStream
Definition OpenNI.h:646
openni::VideoStream::~VideoStream
~VideoStream()
Definition OpenNI.h:731
openni::VideoStream::start
Status start()
Definition OpenNI.h:779
openni::VideoStream::isValid
bool isValid() const
Definition OpenNI.h:740
openni::VideoStream::readFrame
Status readFrame(VideoFrameRef *pFrame)
Definition OpenNI.h:812
openni::VideoStream::create
Status create(const Device &device, SensorType sensorType)
Definition OpenNI.h:2617
openni::VideoStream::isCommandSupported
bool isCommandSupported(int commandId) const
Definition OpenNI.h:1192
openni::VideoStream::getCropping
bool getCropping(int *pOriginX, int *pOriginY, int *pWidth, int *pHeight) const
Definition OpenNI.h:1010
openni::VideoStream::getCameraSettings
CameraSettings * getCameraSettings()
Definition OpenNI.h:893
openni::VideoStream::getSensorInfo
const SensorInfo & getSensorInfo() const
Definition OpenNI.h:771
openni::VideoStream::getMaxPixelValue
int getMaxPixelValue() const
Definition OpenNI.h:966
openni::VideoStream::removeNewFrameListener
void removeNewFrameListener(NewFrameListener *pListener)
Definition OpenNI.h:847
openni::VideoStream::Device
friend class Device
Definition OpenNI.h:1203
openni::VideoStream::setVideoMode
Status setVideoMode(const VideoMode &videoMode)
Definition OpenNI.h:956
openni::VideoStream::stop
void stop()
Definition OpenNI.h:792
openni::VideoStream::getVerticalFieldOfView
float getVerticalFieldOfView() const
Definition OpenNI.h:1100
openni::VideoStream::setCropping
Status setCropping(int originX, int originY, int width, int height)
Definition OpenNI.h:1038
openni::VideoStream::setFrameBuffersAllocator
Status setFrameBuffersAllocator(FrameAllocator *pAllocator)
Definition OpenNI.h:863
openni::VideoStream::getProperty
Status getProperty(int propertyId, T *value) const
Definition OpenNI.h:1132
openni::VideoStream::setProperty
Status setProperty(int propertyId, const void *data, int dataSize)
Definition OpenNI.h:925
openni::VideoStream::addNewFrameListener
Status addNewFrameListener(NewFrameListener *pListener)
Definition OpenNI.h:833
openni::VideoStream::invoke
Status invoke(int commandId, T &value)
Definition OpenNI.h:1182
openni::VideoStream::setProperty
Status setProperty(int propertyId, const T &value)
Definition OpenNI.h:1117
openni::VideoStream::isCroppingSupported
bool isCroppingSupported() const
Definition OpenNI.h:997
openni::VideoStream::getVideoMode
VideoMode getVideoMode() const
Definition OpenNI.h:941
openni::VideoStream::getProperty
Status getProperty(int propertyId, void *data, int *dataSize) const
Definition OpenNI.h:905
openni::VideoStream::getHorizontalFieldOfView
float getHorizontalFieldOfView() const
Definition OpenNI.h:1089
openni::VideoStream::invoke
Status invoke(int commandId, void *data, int dataSize)
Definition OpenNI.h:1162
openni::VideoStream::VideoStream
VideoStream(OniStreamHandle handle)
Definition OpenNI.h:722
openni::VideoStream::VideoStream
VideoStream()
Definition OpenNI.h:715
openni::VideoStream::isPropertySupported
bool isPropertySupported(int propertyId) const
Definition OpenNI.h:1143
openni::VideoStream::destroy
void destroy()
Definition OpenNI.h:2637
openni::VideoStream::getMinPixelValue
int getMinPixelValue() const
Definition OpenNI.h:982
openni::VideoStream::resetCropping
Status resetCropping()
Definition OpenNI.h:1053
openni::VideoStream::setMirroringEnabled
Status setMirroringEnabled(bool isEnabled)
Definition OpenNI.h:1080
openni::VideoStream::getMirroringEnabled
bool getMirroringEnabled() const
Definition OpenNI.h:1064
openni
Definition OpenNI.h:35
openni::Grayscale16Pixel
uint16_t Grayscale16Pixel
Definition OpenNI.h:41
openni::SensorType
SensorType
Definition OniEnums.h:42
openni::TIMEOUT_FOREVER
static const int TIMEOUT_FOREVER
Definition OniEnums.h:82
openni::ImageRegistrationMode
ImageRegistrationMode
Definition OniEnums.h:76
openni::IMAGE_REGISTRATION_OFF
@ IMAGE_REGISTRATION_OFF
Definition OniEnums.h:77
openni::PixelFormat
PixelFormat
Definition OniEnums.h:51
openni::DepthPixel
uint16_t DepthPixel
Definition OpenNI.h:38
openni::Status
Status
Definition OniEnums.h:29
openni::STATUS_OUT_OF_FLOW
@ STATUS_OUT_OF_FLOW
Definition OniEnums.h:35
openni::STATUS_ERROR
@ STATUS_ERROR
Definition OniEnums.h:31
openni::STATUS_NO_DEVICE
@ STATUS_NO_DEVICE
Definition OniEnums.h:36
openni::STATUS_OK
@ STATUS_OK
Definition OniEnums.h:30
openni::STATUS_BAD_PARAMETER
@ STATUS_BAD_PARAMETER
Definition OniEnums.h:34
openni::STATUS_NOT_SUPPORTED
@ STATUS_NOT_SUPPORTED
Definition OniEnums.h:33
openni::ANY_DEVICE
static const char * ANY_DEVICE
Definition OpenNI.h:90
openni::DeviceState
DeviceState
Definition OniEnums.h:68
openni::RGB888Pixel
Definition OpenNI.h:59
openni::RGB888Pixel::b
uint8_t b
Definition OpenNI.h:65
openni::RGB888Pixel::r
uint8_t r
Definition OpenNI.h:61
openni::RGB888Pixel::g
uint8_t g
Definition OpenNI.h:63
openni::Version
Definition OpenNI.h:46
openni::Version::major
int major
Definition OpenNI.h:48
openni::Version::build
int build
Definition OpenNI.h:54
openni::Version::maintenance
int maintenance
Definition OpenNI.h:52
openni::Version::minor
int minor
Definition OpenNI.h:50
openni::YUV422DoublePixel
Definition OpenNI.h:74
openni::YUV422DoublePixel::u
uint8_t u
Definition OpenNI.h:76
openni::YUV422DoublePixel::y2
uint8_t y2
Definition OpenNI.h:82
openni::YUV422DoublePixel::v
uint8_t v
Definition OpenNI.h:80
openni::YUV422DoublePixel::y1
uint8_t y1
Definition OpenNI.h:78