108 operator const char*()
const {
return NULL; }
124 Array() : m_data(NULL), m_count(0), m_owner(false) {}
133 Array(
const T* data,
int count) : m_owner(false) { _setData(data, count); }
164 void _setData(
const T* data,
int count,
bool isOwner =
false)
175 m_data =
new T[count];
176 memcpy((
void*)m_data, data, count*
sizeof(T));
186 if (m_owner && m_data != NULL)
298 this->resolutionX = resolutionX;
299 this->resolutionY = resolutionY;
308 void setFps(
int fps) { this->fps = fps; }
366 m_videoModes._setData(NULL, 0);
397 const char*
getUri()
const {
return uri; }
472 return m_pFrame->dataSize;
482 return m_pFrame->data;
505 return static_cast<const VideoMode&
>(m_pFrame->videoMode);
517 return m_pFrame->timestamp;
532 return m_pFrame->frameIndex;
543 return m_pFrame->width;
553 return m_pFrame->height;
562 return m_pFrame->croppingEnabled ==
TRUE;
571 return m_pFrame->cropOriginX;
580 return m_pFrame->cropOriginY;
590 return m_pFrame->stride;
598 return m_pFrame != NULL;
607 if (m_pFrame != NULL)
617 setReference(pFrame);
710 virtual void* allocateFrameBuffer(
int size) = 0;
711 virtual void freeFrameBuffer(
void* data) = 0;
733 VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true)
760 return m_stream != NULL;
779 inline void destroy();
903 if (pAllocator == NULL)
1043 bool getCropping(
int* pOriginX,
int* pOriginY,
int* pWidth,
int* pHeight)
const 1046 bool enabled =
false;
1054 *pWidth = cropping.
width;
1055 *pHeight = cropping.
height;
1077 cropping.
width = width;
1078 cropping.
height = height;
1105 return enabled ==
TRUE;
1124 float horizontal = 0;
1152 return setProperty(propertyId, &value,
sizeof(T));
1167 int size =
sizeof(T);
1168 return getProperty(propertyId, value, &size);
1217 return invoke(commandId, &value,
sizeof(T));
1244 m_sensorInfo._setInternal(NULL);
1286 Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true)
1306 if (m_device != NULL)
1341 inline Status open(
const char* uri);
1348 inline void close();
1361 return m_deviceInfo;
1374 for (i = 0; (i <
ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1376 if (m_aSensorInfo[i].getSensorType() == sensorType)
1394 m_aSensorInfo[i]._setInternal(pInfo);
1409 for (i = 0; (i <
ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i)
1411 if (m_aSensorInfo[i].getSensorType() == sensorType)
1413 return &m_aSensorInfo[i];
1429 m_aSensorInfo[i]._setInternal(pInfo);
1430 return &m_aSensorInfo[i];
1486 int size =
sizeof(value);
1544 return m_device != NULL;
1600 return setProperty(propertyId, &value,
sizeof(T));
1615 int size =
sizeof(T);
1616 return getProperty(propertyId, value, &size);
1655 return invoke(propertyId, &value,
sizeof(T));
1669 inline Status _openEx(
const char* uri,
const char* mode);
1679 m_aSensorInfo[i]._setInternal(NULL);
1791 return repeat ==
TRUE;
1844 int numOfFrames = -1;
1855 return m_pDevice != NULL;
1878 if (pDevice != NULL)
1951 return m_pStream->getProperty<T>(propertyId, value);
1958 return m_pStream->setProperty<T>(propertyId, value);
1964 m_pStream = pStream;
2007 m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback;
2008 m_deviceConnectedCallbacks.deviceDisconnected = NULL;
2009 m_deviceConnectedCallbacks.deviceStateChanged = NULL;
2010 m_deviceConnectedCallbacksHandle = NULL;
2028 virtual void onDeviceConnected(
const DeviceInfo*) = 0;
2062 m_deviceDisconnectedCallbacks.deviceConnected = NULL;
2063 m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback;
2064 m_deviceDisconnectedCallbacks.deviceStateChanged = NULL;
2065 m_deviceDisconnectedCallbacksHandle = NULL;
2080 virtual void onDeviceDisconnected(
const DeviceInfo*) = 0;
2110 m_deviceStateChangedCallbacks.deviceConnected = NULL;
2111 m_deviceStateChangedCallbacks.deviceDisconnected = NULL;
2112 m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback;
2113 m_deviceStateChangedCallbacksHandle = NULL;
2191 int m_deviceInfoCount;
2207 static const int ONI_MAX_STREAMS = 50;
2210 if (streamCount > ONI_MAX_STREAMS)
2212 printf(
"Too many streams for wait: %d > %d\n", streamCount, ONI_MAX_STREAMS);
2216 *pReadyStreamIndex = -1;
2217 for (
int i = 0; i < streamCount; ++i)
2219 if (pStreams[i] != NULL)
2381 #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM 2391 static Status setLogAndroidOutput(
bool bAndroidOutput)
2393 return (
Status)oniSetLogAndroidOutput(bAndroidOutput);
2453 float depthX, depthY, depthZ;
2455 *pDepthX = (int)depthX;
2456 *pDepthY = (int)depthY;
2608 if (!isValid() || !stream.
isValid())
2615 allowLossyCompression);
2682 _setHandle(streamHandle);
2699 if (m_pCameraSettings != NULL)
2701 delete m_pCameraSettings;
2702 m_pCameraSettings = NULL;
2705 if (m_stream != NULL)
2732 _setHandle(deviceHandle);
2756 _setHandle(deviceHandle);
2763 if (m_device == NULL)
2765 m_device = deviceHandle;
2785 if (m_pPlaybackControl != NULL)
2787 delete m_pPlaybackControl;
2788 m_pPlaybackControl = NULL;
2791 if (m_device != NULL)
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)
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
ONI_C_API OniStatus oniCoordinateConverterD2C(OniStreamHandle depthStream, int colorX, int colorY, OniDepthPixel depthZ, int *pDepthX, int *pDepthY)
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)
struct _OniRecorder * OniRecorderHandle
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)
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)
static Status initialize()
OniVideoMode * pSupportedVideoModes
Status setProperty(int propertyId, const T &value)
OniCallbackHandle m_callbackHandle
ParamsRegistrationMode getSoftwareRegistratorMode()
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
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
ONI_C_API OniStatus oniCoordinateConverterC2D(OniStreamHandle depthStream, int colorX, int colorY, OniDepthPixel depthZ, int *pDepthX, int *pDepthY)
ONI_C_API void oniStreamfilter(OniStreamHandle stream, void *buf, int newVal, int maxSpeckleSize, int maxDiff)
static Status convertWorldToDepth(const VideoStream &depthStream, float worldX, float worldY, float worldZ, float *pDepthX, float *pDepthY, float *pDepthZ)
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 convertC2DCoordinateByIntrinsic(const VideoStream &depthStream, int colorX, int colorY, DepthPixel depthZ, int *pDepthX, int *pDepthY)
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)
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)
void * getHandle(const std::string &name)
uint64_t getTimestamp() const
void setSoftwareRegistrator(ParamsRegistrationMode mode)
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()
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)
struct _OniDevice * OniDeviceHandle
Status setMirroringEnabled(bool isEnabled)
void filterSpeckles(void *buf, int newVal, int maxSpeckleSize, int maxDiff)
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)
struct _OniStream * OniStreamHandle
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)
static const _NullString ANY_DEVICE
static Status convertD2CCoordinateByIntrinsic(const VideoStream &depthStream, int depthX, int depthY, DepthPixel depthZ, int *pColorX, int *pColorY)
Status getProperty(int propertyId, void *data, int *dataSize) const