From 8b8c1588c5a511143fcddb49996bd445dbd6288f Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 9 May 2015 21:40:06 +0900 Subject: [PATCH 01/20] openni2: Copy OpenNI2-FreenectDriver from libfreenect 89f77f6d2c23876936af65766a4c140898bc3ea8 --- OpenNI2-FreenectDriver/CMakeLists.txt | 26 + OpenNI2-FreenectDriver/README.md | 59 + .../Android-Arm/OniPlatformAndroid-Arm.h | 43 + .../Include/Driver/OniDriverAPI.h | 378 +++ .../Include/Driver/OniDriverTypes.h | 54 + .../Include/Linux-Arm/OniPlatformLinux-Arm.h | 36 + .../Include/Linux-x86/OniPlatformLinux-x86.h | 102 + .../Include/MacOSX/OniPlatformMacOSX.h | 42 + .../Include/OniCAPI.h | 259 ++ .../Include/OniCEnums.h | 84 + .../Include/OniCProperties.h | 68 + .../Include/OniCTypes.h | 193 ++ .../Include/OniEnums.h | 86 + .../Include/OniPlatform.h | 72 + .../Include/OniProperties.h | 73 + .../Include/OniVersion.h | 43 + .../Include/OpenNI.h | 2750 +++++++++++++++++ .../Include/PS1080.h | 632 ++++ .../Include/PSLink.h | 199 ++ .../Include/PrimeSense.h | 229 ++ .../Include/Win32/OniPlatformWin32.h | 139 + OpenNI2-FreenectDriver/src/ColorStream.cpp | 84 + OpenNI2-FreenectDriver/src/ColorStream.hpp | 156 + OpenNI2-FreenectDriver/src/D2S.h | 1003 ++++++ OpenNI2-FreenectDriver/src/DepthStream.cpp | 146 + OpenNI2-FreenectDriver/src/DepthStream.hpp | 210 ++ OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 351 +++ OpenNI2-FreenectDriver/src/S2D.h | 207 ++ OpenNI2-FreenectDriver/src/Utility.hpp | 74 + OpenNI2-FreenectDriver/src/VideoStream.hpp | 202 ++ 30 files changed, 8000 insertions(+) create mode 100644 OpenNI2-FreenectDriver/CMakeLists.txt create mode 100644 OpenNI2-FreenectDriver/README.md create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h create mode 100644 OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h create mode 100644 OpenNI2-FreenectDriver/src/ColorStream.cpp create mode 100644 OpenNI2-FreenectDriver/src/ColorStream.hpp create mode 100644 OpenNI2-FreenectDriver/src/D2S.h create mode 100644 OpenNI2-FreenectDriver/src/DepthStream.cpp create mode 100644 OpenNI2-FreenectDriver/src/DepthStream.hpp create mode 100644 OpenNI2-FreenectDriver/src/DeviceDriver.cpp create mode 100644 OpenNI2-FreenectDriver/src/S2D.h create mode 100644 OpenNI2-FreenectDriver/src/Utility.hpp create mode 100644 OpenNI2-FreenectDriver/src/VideoStream.hpp diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt new file mode 100644 index 000000000..30f70dcee --- /dev/null +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -0,0 +1,26 @@ +###################################################################################### +# OpenNI2-FreenectDriver +###################################################################################### + +file(GLOB HEADERS src/*.hpp src/*.h) +file(GLOB SOURCES src/*.cpp) +add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES}) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") + +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver) +set_target_properties(FreenectDriver PROPERTIES + VERSION ${PROJECT_VER} + SOVERSION ${PROJECT_APIVER} + OUTPUT_NAME FreenectDriver) + +add_definitions(-DPROJECT_VER="${PROJECT_VER}") + +include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) +include_directories(${PROJECT_SOURCE_DIR}/src) +include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) + +target_link_libraries(FreenectDriver freenectstatic ${MATH_LIB}) + +install (TARGETS FreenectDriver + DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/OpenNI2-FreenectDriver") diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-FreenectDriver/README.md new file mode 100644 index 000000000..c5ae5c15e --- /dev/null +++ b/OpenNI2-FreenectDriver/README.md @@ -0,0 +1,59 @@ +OpenNI2-FreenectDriver +====================== + +OpenNI2-FreenectDriver is a bridge to libfreenect implemented as an OpenNI2 driver. +It allows OpenNI2 to use Kinect hardware on Linux and OSX. +OpenNI2-FreenectDriver is distributed under the [Apache 2](https://github.com/OpenKinect/libfreenect/blob/master/APACHE20) license. + +Install +------- +1. Download and unpack [OpenNI](http://structure.io/openni) 2.2.0.33 or higher. +2. Go to the top libfreenect directory and build it with the OpenNI2 driver. + + mkdir build + cd build + cmake .. -DBUILD_OPENNI2_DRIVER=ON + make + +3. Copy the driver to your OpenNI2 driver repository. You must first change `Repository` to match your project layout. + + Repository="/example/path/to/Samples/Bin/OpenNI2/Drivers/" + cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} + + # you could instead make a symlink to avoid copying after every build + # ln -s lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} + +OpenNI2-FreenectDriver is built with a static libfreenect, so you do not need to include libfreenect when deploying. +However, you will need to make sure target systems have libusb and all other dependencies listed in `ldd libFreenectDriver.so`. + +__________________________________________________ + +Structure +--------- +This driver is modeled on TestDevice.cpp and Drivers/Kinect/. +In the FreenectDriver namespace, it ties together the C++ interfaces of OpenNI2 and libfreenect using multiple inheritance. + +Driver inherits publically from oni::driver::DriverBase and privately from Freenect::Freenect. +libfreenect.hpp allows protected access to the Freenect context, so that FreenectDriver can call the Freenect's C API. +As a DriverBase, FreenectDriver manages devices and sets up device state callbacks. + +Device inherits publically from oni::driver::DeviceBase and Freenect::FreenectDevice. +Because of this, it can be built by Freenect::Freenect::createDevice() and it can define Device's depth and video callbacks. +Those callbacks trigger acquireFrame() in FreenectStream. + +VideoStream is a virtual base class inheriting from oni::driver::StreamBase. +It does generic frame setup in buildFrame() and then calls pure virtual populateFrame() to let derived classes finish the frame. +It also provides the base skeleton for setting and getting properties, which cascades down the inheritance tree. + +DepthStream and ColorStream are nearly identical in definition and implementation, both inheriting from VideoStream. +They differ mostly in the formats they use to process data and the video modes they support. +These two classes offer a system to store and report supported video modes. +To implement a new mode, simply add it to getSupportedVideoModes() and modify populateFrame() as necessary. + +__________________________________________________ + +Todo +---- +* support more FREENECT_RESOLUTION_\*, FREENECT_VIDEO_\*, and FREENECT_DEPTH_\* +* provide more OniVideoMode and OniStreamProperty +* implement remaining derived functions diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h new file mode 100644 index 000000000..0aae276b5 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h @@ -0,0 +1,43 @@ +/***************************************************************************** +* * +* 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 _ONI_PLATFORM_ANDROID_ARM_H_ +#define _ONI_PLATFORM_ANDROID_ARM_H_ + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING + +#define ONI_PLATFORM ONI_PLATFORM_ANDROID_ARM +#define ONI_PLATFORM_STRING "Android-Arm" + +#ifdef HAVE_ANDROID_OS + #define ONI_PLATFORM_ANDROID_OS + + #undef ONI_PLATFORM_STRING + #define ONI_PLATFORM_STRING "AndroidOS-Arm" +#endif + +#endif //_ONI_PLATFORM_LINUX_ARM_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h new file mode 100644 index 000000000..c41e1f660 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h @@ -0,0 +1,378 @@ +/***************************************************************************** +* * +* 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 _ONI_DRIVER_API_H_ +#define _ONI_DRIVER_API_H_ + +#include "OniPlatform.h" +#include "OniCTypes.h" +#include "OniCProperties.h" +#include "OniDriverTypes.h" +#include + +namespace oni { namespace driver { + +class DeviceBase; +class StreamBase; + +typedef void (ONI_CALLBACK_TYPE* DeviceConnectedCallback)(const OniDeviceInfo*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* DeviceDisconnectedCallback)(const OniDeviceInfo*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* DeviceStateChangedCallback)(const OniDeviceInfo* deviceId, int errorState, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* NewFrameCallback)(StreamBase* streamId, OniFrame*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* PropertyChangedCallback)(void* sender, int propertyId, const void* data, int dataSize, void* pCookie); + +class StreamServices : public OniStreamServices +{ +public: + int getDefaultRequiredFrameSize() + { + return OniStreamServices::getDefaultRequiredFrameSize(streamServices); + } + + OniFrame* acquireFrame() + { + return OniStreamServices::acquireFrame(streamServices); + } + + void addFrameRef(OniFrame* pFrame) + { + OniStreamServices::addFrameRef(streamServices, pFrame); + } + + void releaseFrame(OniFrame* pFrame) + { + OniStreamServices::releaseFrame(streamServices, pFrame); + } +}; + +class StreamBase +{ +public: + StreamBase() : m_newFrameCallback(NULL), m_propertyChangedCallback(NULL) {} + virtual ~StreamBase() {} + + virtual void setServices(StreamServices* pStreamServices) { m_pServices = pStreamServices; } + + virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} + + virtual int getRequiredFrameSize() { return getServices().getDefaultRequiredFrameSize(); } + + virtual OniStatus start() = 0; + virtual void stop() = 0; + + virtual void setNewFrameCallback(NewFrameCallback handler, void* pCookie) { m_newFrameCallback = handler; m_newFrameCallbackCookie = pCookie; } + virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } + + virtual void notifyAllProperties() { return; } + + virtual OniStatus convertDepthToColorCoordinates(StreamBase* /*colorStream*/, int /*depthX*/, int /*depthY*/, OniDepthPixel /*depthZ*/, int* /*pColorX*/, int* /*pColorY*/) { return ONI_STATUS_NOT_SUPPORTED; } + +protected: + void raiseNewFrame(OniFrame* pFrame) { (*m_newFrameCallback)(this, pFrame, m_newFrameCallbackCookie); } + void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } + + StreamServices& getServices() { return *m_pServices; } + +private: + StreamServices* m_pServices; + NewFrameCallback m_newFrameCallback; + void* m_newFrameCallbackCookie; + PropertyChangedCallback m_propertyChangedCallback; + void* m_propertyChangedCookie; +}; + +class DeviceBase +{ +public: + DeviceBase() {} + virtual ~DeviceBase() {} + + virtual OniStatus getSensorInfoList(OniSensorInfo** pSensorInfos, int* numSensors) = 0; + + virtual StreamBase* createStream(OniSensorType) = 0; + virtual void destroyStream(StreamBase* pStream) = 0; + + virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} + virtual OniStatus tryManualTrigger() {return ONI_STATUS_OK;} + + virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } + virtual void notifyAllProperties() { return; } + + virtual OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF); } + +protected: + void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } + +private: + PropertyChangedCallback m_propertyChangedCallback; + void* m_propertyChangedCookie; +}; + +class DriverServices +{ +public: + DriverServices(OniDriverServices* pDriverServices) : m_pDriverServices(pDriverServices) {} + + void errorLoggerAppend(const char* format, ...) + { + va_list args; + va_start(args, format); + m_pDriverServices->errorLoggerAppend(m_pDriverServices->driverServices, format, args); + va_end(args); + } + + void errorLoggerClear() + { + m_pDriverServices->errorLoggerClear(m_pDriverServices->driverServices); + } + + void log(int severity, const char* file, int line, const char* mask, const char* message) + { + m_pDriverServices->log(m_pDriverServices->driverServices, severity, file, line, mask, message); + } + +private: + OniDriverServices* m_pDriverServices; +}; + +class DriverBase +{ +public: + DriverBase(OniDriverServices* pDriverServices) : m_services(pDriverServices) + {} + + virtual ~DriverBase() {} + + virtual OniStatus initialize(DeviceConnectedCallback connectedCallback, DeviceDisconnectedCallback disconnectedCallback, DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) + { + m_deviceConnectedEvent = connectedCallback; + m_deviceDisconnectedEvent = disconnectedCallback; + m_deviceStateChangedEvent = deviceStateChangedCallback; + m_pCookie = pCookie; + return ONI_STATUS_OK; + } + + virtual DeviceBase* deviceOpen(const char* uri, const char* mode) = 0; + virtual void deviceClose(DeviceBase* pDevice) = 0; + + virtual void shutdown() = 0; + + virtual OniStatus tryDevice(const char* /*uri*/) { return ONI_STATUS_ERROR;} + + virtual void* enableFrameSync(StreamBase** /*pStreams*/, int /*streamCount*/) { return NULL; } + virtual void disableFrameSync(void* /*frameSyncGroup*/) {} + +protected: + void deviceConnected(const OniDeviceInfo* pInfo) { (m_deviceConnectedEvent)(pInfo, m_pCookie); } + void deviceDisconnected(const OniDeviceInfo* pInfo) { (m_deviceDisconnectedEvent)(pInfo, m_pCookie); } + void deviceStateChanged(const OniDeviceInfo* pInfo, int errorState) { (m_deviceStateChangedEvent)(pInfo, errorState, m_pCookie); } + + DriverServices& getServices() { return m_services; } + +private: + DeviceConnectedCallback m_deviceConnectedEvent; + DeviceDisconnectedCallback m_deviceDisconnectedEvent; + DeviceStateChangedCallback m_deviceStateChangedEvent; + void* m_pCookie; + + DriverServices m_services; +}; + +}} // oni::driver + +#define ONI_EXPORT_DRIVER(DriverClass) \ + \ +oni::driver::DriverBase* g_pDriver = NULL; \ + \ +/* As Driver */ \ +ONI_C_API_EXPORT void oniDriverCreate(OniDriverServices* driverServices) { \ + g_pDriver = XN_NEW(DriverClass, driverServices); \ +} \ +ONI_C_API_EXPORT void oniDriverDestroy() \ +{ \ + g_pDriver->shutdown(); \ + XN_DELETE(g_pDriver); g_pDriver = NULL; \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverInitialize(oni::driver::DeviceConnectedCallback deviceConnectedCallback, \ + oni::driver::DeviceDisconnectedCallback deviceDisconnectedCallback, \ + oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, \ + void* pCookie) \ +{ \ + return g_pDriver->initialize(deviceConnectedCallback, deviceDisconnectedCallback, deviceStateChangedCallback, pCookie); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverTryDevice(const char* uri) \ +{ \ + return g_pDriver->tryDevice(uri); \ +} \ + \ +/* As Device */ \ +ONI_C_API_EXPORT oni::driver::DeviceBase* oniDriverDeviceOpen(const char* uri, const char* mode) \ +{ \ + return g_pDriver->deviceOpen(uri, mode); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceClose(oni::driver::DeviceBase* pDevice) \ +{ \ + g_pDriver->deviceClose(pDevice); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceGetSensorInfoList(oni::driver::DeviceBase* pDevice, OniSensorInfo** pSensorInfos, \ + int* numSensors) \ +{ \ + return pDevice->getSensorInfoList(pSensorInfos, numSensors); \ +} \ + \ +ONI_C_API_EXPORT oni::driver::StreamBase* oniDriverDeviceCreateStream(oni::driver::DeviceBase* pDevice, \ + OniSensorType sensorType) \ +{ \ + return pDevice->createStream(sensorType); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverDeviceDestroyStream(oni::driver::DeviceBase* pDevice, oni::driver::StreamBase* pStream) \ +{ \ + return pDevice->destroyStream(pStream); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceSetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ + const void* data, int dataSize) \ +{ \ + return pDevice->setProperty(propertyId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceGetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ + void* data, int* pDataSize) \ +{ \ + return pDevice->getProperty(propertyId, data, pDataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsPropertySupported(oni::driver::DeviceBase* pDevice, int propertyId) \ +{ \ + return pDevice->isPropertySupported(propertyId); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceSetPropertyChangedCallback(oni::driver::DeviceBase* pDevice, \ + oni::driver::PropertyChangedCallback handler, void* pCookie) \ +{ \ + pDevice->setPropertyChangedCallback(handler, pCookie); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceNotifyAllProperties(oni::driver::DeviceBase* pDevice) \ +{ \ + pDevice->notifyAllProperties(); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceInvoke(oni::driver::DeviceBase* pDevice, int commandId, \ + void* data, int dataSize) \ +{ \ + return pDevice->invoke(commandId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsCommandSupported(oni::driver::DeviceBase* pDevice, int commandId) \ +{ \ + return pDevice->isCommandSupported(commandId); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceTryManualTrigger(oni::driver::DeviceBase* pDevice) \ +{ \ + return pDevice->tryManualTrigger(); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsImageRegistrationModeSupported(oni::driver::DeviceBase* pDevice, \ + OniImageRegistrationMode mode) \ +{ \ + return pDevice->isImageRegistrationModeSupported(mode); \ +} \ + \ +/* As Stream */ \ +ONI_C_API_EXPORT void oniDriverStreamSetServices(oni::driver::StreamBase* pStream, OniStreamServices* pServices) \ +{ \ + pStream->setServices((oni::driver::StreamServices*)pServices); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamSetProperty(oni::driver::StreamBase* pStream, int propertyId, \ + const void* data, int dataSize) \ +{ \ + return pStream->setProperty(propertyId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverStreamGetProperty(oni::driver::StreamBase* pStream, int propertyId, void* data, \ + int* pDataSize) \ +{ \ + return pStream->getProperty(propertyId, data, pDataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverStreamIsPropertySupported(oni::driver::StreamBase* pStream, int propertyId) \ +{ \ + return pStream->isPropertySupported(propertyId); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamSetPropertyChangedCallback(oni::driver::StreamBase* pStream, \ + oni::driver::PropertyChangedCallback handler, void* pCookie) \ +{ \ + pStream->setPropertyChangedCallback(handler, pCookie); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamNotifyAllProperties(oni::driver::StreamBase* pStream) \ +{ \ + pStream->notifyAllProperties(); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverStreamInvoke(oni::driver::StreamBase* pStream, int commandId, \ + void* data, int dataSize) \ +{ \ + return pStream->invoke(commandId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverStreamIsCommandSupported(oni::driver::StreamBase* pStream, int commandId) \ +{ \ + return pStream->isCommandSupported(commandId); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamStart(oni::driver::StreamBase* pStream) \ +{ \ + return pStream->start(); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamStop(oni::driver::StreamBase* pStream) \ +{ \ + pStream->stop(); \ +} \ + \ +ONI_C_API_EXPORT int oniDriverStreamGetRequiredFrameSize(oni::driver::StreamBase* pStream) \ +{ \ + return pStream->getRequiredFrameSize(); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverStreamSetNewFrameCallback(oni::driver::StreamBase* pStream, \ + oni::driver::NewFrameCallback handler, void* pCookie) \ +{ \ + pStream->setNewFrameCallback(handler, pCookie); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamConvertDepthToColorCoordinates(oni::driver::StreamBase* pDepthStream, \ + oni::driver::StreamBase* pColorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) \ +{ \ + return pDepthStream->convertDepthToColorCoordinates(pColorStream, depthX, depthY, depthZ, pColorX, pColorY); \ +} \ + \ +ONI_C_API_EXPORT void* oniDriverEnableFrameSync(oni::driver::StreamBase** pStreams, int streamCount) \ +{ \ + return g_pDriver->enableFrameSync(pStreams, streamCount); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverDisableFrameSync(void* frameSyncGroup) \ +{ \ + return g_pDriver->disableFrameSync(frameSyncGroup); \ +} \ + +#endif // _ONI_DRIVER_API_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h new file mode 100644 index 000000000..fe8cd44c9 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h @@ -0,0 +1,54 @@ +/***************************************************************************** +* * +* 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 _ONI_DRIVER_TYPES_H_ +#define _ONI_DRIVER_TYPES_H_ + +#include +#include + +#define ONI_STREAM_PROPERTY_PRIVATE_BASE XN_MAX_UINT16 + +typedef struct +{ + int dataSize; + void* data; +} OniGeneralBuffer; + +/////// DriverServices +struct OniDriverServices +{ + void* driverServices; + void (ONI_CALLBACK_TYPE* errorLoggerAppend)(void* driverServices, const char* format, va_list args); + void (ONI_CALLBACK_TYPE* errorLoggerClear)(void* driverServices); + void (ONI_CALLBACK_TYPE* log)(void* driverServices, int severity, const char* file, int line, const char* mask, const char* message); +}; + +struct OniStreamServices +{ + void* streamServices; + int (ONI_CALLBACK_TYPE* getDefaultRequiredFrameSize)(void* streamServices); + OniFrame* (ONI_CALLBACK_TYPE* acquireFrame)(void* streamServices); // returns a frame with size corresponding to getRequiredFrameSize() + void (ONI_CALLBACK_TYPE* addFrameRef)(void* streamServices, OniFrame* pframe); + void (ONI_CALLBACK_TYPE* releaseFrame)(void* streamServices, OniFrame* pframe); +}; + + +#endif // _ONI_DRIVER_TYPES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h new file mode 100644 index 000000000..fb96323bd --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h @@ -0,0 +1,36 @@ +/***************************************************************************** +* * +* 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 _ONI_PLATFORM_LINUX_ARM_H_ +#define _ONI_PLATFORM_LINUX_ARM_H_ + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING +#define ONI_PLATFORM ONI_PLATFORM_LINUX_ARM +#define ONI_PLATFORM_STRING "Linux-Arm" + +#endif //_ONI_PLATFORM_LINUX_ARM_H_ + diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h new file mode 100644 index 000000000..e5980f356 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h @@ -0,0 +1,102 @@ +/***************************************************************************** +* * +* 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 _ONI_PLATFORM_LINUX_X86_H_ +#define _ONI_PLATFORM_LINUX_X86_H_ + +//--------------------------------------------------------------------------- +// Prerequisites +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#define ONI_PLATFORM ONI_PLATFORM_LINUX_X86 +#define ONI_PLATFORM_STRING "Linux-x86" + +//--------------------------------------------------------------------------- +// Platform Capabilities +//--------------------------------------------------------------------------- +#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN + +#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 + +//--------------------------------------------------------------------------- +// Memory +//--------------------------------------------------------------------------- +/** The default memory alignment. */ +#define ONI_DEFAULT_MEM_ALIGN 16 + +/** The thread static declarator (using TLS). */ +#define ONI_THREAD_STATIC __thread + +//--------------------------------------------------------------------------- +// Files +//--------------------------------------------------------------------------- +/** The maximum allowed file path size (in bytes). */ +#define ONI_FILE_MAX_PATH 256 + +//--------------------------------------------------------------------------- +// Call back +//--------------------------------------------------------------------------- +/** The std call type. */ +#define ONI_STDCALL __stdcall + +/** The call back calling convention. */ +#define ONI_CALLBACK_TYPE + +/** The C and C++ calling convension. */ +#define ONI_C_DECL + +//--------------------------------------------------------------------------- +// Macros +//--------------------------------------------------------------------------- +/** Returns the date and time at compile time. */ +#define ONI_TIMESTAMP __DATE__ " " __TIME__ + +/** Converts n into a pre-processor string. */ +#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) +#define ONI_STRINGIFY_HELPER(n) #n + +//--------------------------------------------------------------------------- +// API Export/Import Macros +//--------------------------------------------------------------------------- +/** Indicates an exported shared library function. */ +#define ONI_API_EXPORT __attribute__ ((visibility("default"))) + +/** Indicates an imported shared library function. */ +#define ONI_API_IMPORT + +/** Indicates a deprecated function */ +#define ONI_API_DEPRECATED(msg) __attribute__((warning("This function is deprecated: " msg))) + +#endif //_ONI_PLATFORM_LINUX_X86_H_ + diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h new file mode 100644 index 000000000..251256ebb --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h @@ -0,0 +1,42 @@ +/***************************************************************************** +* * +* PrimeSense PSCommon Library * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of PSCommon. * +* * +* 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 _ONI_PLATFORM_MACOSX_H_ +#define _ONI_PLATFORM_MACOSX_H_ + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +#include + +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING +#define ONI_PLATFORM ONI_PLATFORM_MACOSX +#define ONI_PLATFORM_STRING "MacOSX" + +#define ONI_PLATFORM_HAS_NO_TIMED_OPS +#define ONI_PLATFORM_HAS_NO_CLOCK_GETTIME +#define ONI_PLATFORM_HAS_NO_SCHED_PARAM +#define ONI_PLATFORM_HAS_BUILTIN_SEMUN + +#undef ONI_THREAD_STATIC +#define ONI_THREAD_STATIC + +#endif //_ONI_PLATFORM_MACOSX_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h new file mode 100644 index 000000000..aea426d49 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h @@ -0,0 +1,259 @@ +/***************************************************************************** +* * +* 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 _ONI_C_API_H_ +#define _ONI_C_API_H_ + +#include "OniPlatform.h" +#include "OniCTypes.h" +#include "OniCProperties.h" +#include "OniVersion.h" + +/******************************************** General APIs */ + +/** Initialize OpenNI2. Use ONI_API_VERSION as the version. */ +ONI_C_API OniStatus oniInitialize(int apiVersion); +/** Shutdown OpenNI2 */ +ONI_C_API void oniShutdown(); + +/** + * Get the list of currently connected device. + * Each device is represented by its OniDeviceInfo. + * pDevices will be allocated inside. + */ +ONI_C_API OniStatus oniGetDeviceList(OniDeviceInfo** pDevices, int* pNumDevices); +/** Release previously allocated device list */ +ONI_C_API OniStatus oniReleaseDeviceList(OniDeviceInfo* pDevices); + +ONI_C_API OniStatus oniRegisterDeviceCallbacks(OniDeviceCallbacks* pCallbacks, void* pCookie, OniCallbackHandle* pHandle); +ONI_C_API void oniUnregisterDeviceCallbacks(OniCallbackHandle handle); + +/** Wait for any of the streams to have a new frame */ +ONI_C_API OniStatus oniWaitForAnyStream(OniStreamHandle* pStreams, int numStreams, int* pStreamIndex, int timeout); + +/** Get the current version of OpenNI2 */ +ONI_C_API OniVersion oniGetVersion(); + +/** Translate from format to number of bytes per pixel. Will return 0 for formats in which the number of bytes per pixel isn't fixed. */ +ONI_C_API int oniFormatBytesPerPixel(OniPixelFormat format); + +/** Get internal error */ +ONI_C_API const char* oniGetExtendedError(); + +/******************************************** Device APIs */ + +/** Open a device. Uri can be taken from the matching OniDeviceInfo. */ +ONI_C_API OniStatus oniDeviceOpen(const char* uri, OniDeviceHandle* pDevice); +/** Close a device */ +ONI_C_API OniStatus oniDeviceClose(OniDeviceHandle device); + +/** Get the possible configurations available for a specific source, or NULL if the source does not exist. */ +ONI_C_API const OniSensorInfo* oniDeviceGetSensorInfo(OniDeviceHandle device, OniSensorType sensorType); + +/** Get the OniDeviceInfo of a certain device. */ +ONI_C_API OniStatus oniDeviceGetInfo(OniDeviceHandle device, OniDeviceInfo* pInfo); + +/** Create a new stream in the device. The stream will originate from the source. */ +ONI_C_API OniStatus oniDeviceCreateStream(OniDeviceHandle device, OniSensorType sensorType, OniStreamHandle* pStream); + +ONI_C_API OniStatus oniDeviceEnableDepthColorSync(OniDeviceHandle device); +ONI_C_API void oniDeviceDisableDepthColorSync(OniDeviceHandle device); +ONI_C_API OniBool oniDeviceGetDepthColorSyncEnabled(OniDeviceHandle device); + +/** Set property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniStatus oniDeviceSetProperty(OniDeviceHandle device, int propertyId, const void* data, int dataSize); +/** Get property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, void* data, int* pDataSize); +/** Check if the property is supported by the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId); +/** Invoke an internal functionality of the device. */ +ONI_C_API OniStatus oniDeviceInvoke(OniDeviceHandle device, int commandId, void* data, int dataSize); +/** Check if a command is supported, for invoke */ +ONI_C_API OniBool oniDeviceIsCommandSupported(OniDeviceHandle device, int commandId); + +ONI_C_API OniBool oniDeviceIsImageRegistrationModeSupported(OniDeviceHandle device, OniImageRegistrationMode mode); + +/** @internal */ +ONI_C_API OniStatus oniDeviceOpenEx(const char* uri, const char* mode, OniDeviceHandle* pDevice); + +/******************************************** Stream APIs */ + +/** Destroy an existing stream */ +ONI_C_API void oniStreamDestroy(OniStreamHandle stream); + +/** Get the OniSensorInfo of the certain stream. */ +ONI_C_API const OniSensorInfo* oniStreamGetSensorInfo(OniStreamHandle stream); + +/** Start generating data from the stream. */ +ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream); +/** Stop generating data from the stream. */ +ONI_C_API void oniStreamStop(OniStreamHandle stream); + +/** Get the next frame from the stream. This function is blocking until there is a new frame from the stream. For timeout, use oniWaitForStreams() first */ +ONI_C_API OniStatus oniStreamReadFrame(OniStreamHandle stream, OniFrame** pFrame); + +/** Register a callback to when the stream has a new frame. */ +ONI_C_API OniStatus oniStreamRegisterNewFrameCallback(OniStreamHandle stream, OniNewFrameCallback handler, void* pCookie, OniCallbackHandle* pHandle); +/** Unregister a previously registered callback to when the stream has a new frame. */ +ONI_C_API void oniStreamUnregisterNewFrameCallback(OniStreamHandle stream, OniCallbackHandle handle); + +/** Set property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniStatus oniStreamSetProperty(OniStreamHandle stream, int propertyId, const void* data, int dataSize); +/** Get property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniStatus oniStreamGetProperty(OniStreamHandle stream, int propertyId, void* data, int* pDataSize); +/** Check if the property is supported the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId); +/** Invoke an internal functionality of the stream. */ +ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void* data, int dataSize); +/** Check if a command is supported, for invoke */ +ONI_C_API OniBool oniStreamIsCommandSupported(OniStreamHandle stream, int commandId); +/** Sets the stream buffer allocation functions. Note that this function may only be called while stream is not started. */ +ONI_C_API OniStatus oniStreamSetFrameBuffersAllocator(OniStreamHandle stream, OniFrameAllocBufferCallback alloc, OniFrameFreeBufferCallback free, void* pCookie); + +//// +/** Mark another user of the frame. */ +ONI_C_API void oniFrameAddRef(OniFrame* pFrame); +/** Mark that the frame is no longer needed. */ +ONI_C_API void oniFrameRelease(OniFrame* pFrame); + +// ONI_C_API OniStatus oniConvertRealWorldToProjective(OniStreamHandle stream, OniFloatPoint3D* pRealWorldPoint, OniFloatPoint3D* pProjectivePoint); +// ONI_C_API OniStatus oniConvertProjectiveToRealWorld(OniStreamHandle stream, OniFloatPoint3D* pProjectivePoint, OniFloatPoint3D* pRealWorldPoint); + +/** + * Creates a recorder that records to a file. + * @param [in] fileName The name of the file that will contain the recording. + * @param [out] pRecorder Points to the handle to the newly created recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniCreateRecorder(const char* fileName, OniRecorderHandle* pRecorder); + +/** + * Attaches a stream to a recorder. The amount of attached streams is virtually + * infinite. You cannot attach a stream after you have started a recording, if + * you do: an error will be returned by oniRecorderAttachStream. + * @param [in] recorder The handle to the recorder. + * @param [in] stream The handle to the stream. + * @param [in] allowLossyCompression Allows/denies lossy compression + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderAttachStream( + OniRecorderHandle recorder, + OniStreamHandle stream, + OniBool allowLossyCompression); + +/** + * Starts recording. There must be at least one stream attached to the recorder, + * if not: oniRecorderStart will return an error. + * @param[in] recorder The handle to the recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderStart(OniRecorderHandle recorder); + +/** + * Stops recording. You can resume recording via oniRecorderStart. + * @param[in] recorder The handle to the recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API void oniRecorderStop(OniRecorderHandle recorder); + +/** + * Stops recording if needed, and destroys a recorder. + * @param [in,out] recorder The handle to the recorder, the handle will be + * invalidated (nullified) when the function returns. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderDestroy(OniRecorderHandle* pRecorder); + +ONI_C_API OniStatus oniCoordinateConverterDepthToWorld(OniStreamHandle depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ); + +ONI_C_API OniStatus oniCoordinateConverterWorldToDepth(OniStreamHandle depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ); + +ONI_C_API OniStatus oniCoordinateConverterDepthToColor(OniStreamHandle depthStream, OniStreamHandle colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY); + +/******************************************** Log APIs */ + +/** + * Change the log output folder + + * @param const char * strOutputFolder [in] path to the desirebale folder + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogOutputFolder(const char* strOutputFolder); + +/** + * Get the current log file name + + * @param char * strFileName [out] hold the returned file name + * @param int nBufferSize [in] size of strFileName + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniGetLogFileName(char* strFileName, int nBufferSize); + +/** + * Set the Minimum severity for log produce + + * @param const char * strMask [in] Name of the logger + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogMinSeverity(int nMinSeverity); + +/** + * Configures if log entries will be printed to console. + + * @param OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogConsoleOutput(OniBool bConsoleOutput); + +/** + * Configures if log entries will be printed to a log file. + + * @param OniBool bFileOutput [in] TRUE to print log entries to the file, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput); + +#if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM +/** + * Configures if log entries will be printed to the Android log. + + * @param OniBool bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogAndroidOutput(OniBool bAndroidOutput); +#endif +#endif // _ONI_C_API_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h new file mode 100644 index 000000000..d7f513b8c --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h @@ -0,0 +1,84 @@ +/***************************************************************************** +* * +* 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 _ONI_C_ENUMS_H_ +#define _ONI_C_ENUMS_H_ + +/** Possible failure values */ +typedef enum +{ + ONI_STATUS_OK = 0, + ONI_STATUS_ERROR = 1, + ONI_STATUS_NOT_IMPLEMENTED = 2, + ONI_STATUS_NOT_SUPPORTED = 3, + ONI_STATUS_BAD_PARAMETER = 4, + ONI_STATUS_OUT_OF_FLOW = 5, + ONI_STATUS_NO_DEVICE = 6, + ONI_STATUS_TIME_OUT = 102, +} OniStatus; + +/** The source of the stream */ +typedef enum +{ + ONI_SENSOR_IR = 1, + ONI_SENSOR_COLOR = 2, + ONI_SENSOR_DEPTH = 3, + +} OniSensorType; + +/** All available formats of the output of a stream */ +typedef enum +{ + // Depth + ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, + ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, + ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, + ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, + + // Color + ONI_PIXEL_FORMAT_RGB888 = 200, + ONI_PIXEL_FORMAT_YUV422 = 201, + ONI_PIXEL_FORMAT_GRAY8 = 202, + ONI_PIXEL_FORMAT_GRAY16 = 203, + ONI_PIXEL_FORMAT_JPEG = 204, + ONI_PIXEL_FORMAT_YUYV = 205, +} OniPixelFormat; + +typedef enum +{ + ONI_DEVICE_STATE_OK = 0, + ONI_DEVICE_STATE_ERROR = 1, + ONI_DEVICE_STATE_NOT_READY = 2, + ONI_DEVICE_STATE_EOF = 3 +} OniDeviceState; + +typedef enum +{ + ONI_IMAGE_REGISTRATION_OFF = 0, + ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, +} OniImageRegistrationMode; + +enum +{ + ONI_TIMEOUT_NONE = 0, + ONI_TIMEOUT_FOREVER = -1, +}; + +#endif // _ONI_C_ENUMS_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h new file mode 100644 index 000000000..da13d58e4 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h @@ -0,0 +1,68 @@ +/***************************************************************************** +* * +* 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 _ONI_C_PROPERTIES_H_ +#define _ONI_C_PROPERTIES_H_ + +// Device properties +enum +{ + ONI_DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // By implementation + ONI_DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion + ONI_DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int + ONI_DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string + ONI_DEVICE_PROPERTY_ERROR_STATE = 4, // ?? + ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode + + // Files + ONI_DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float + ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool +}; + +// Stream properties +enum +{ + ONI_STREAM_PROPERTY_CROPPING = 0, // OniCropping* + ONI_STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians + ONI_STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians + ONI_STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* + + ONI_STREAM_PROPERTY_MAX_VALUE = 4, // int + ONI_STREAM_PROPERTY_MIN_VALUE = 5, // int + + ONI_STREAM_PROPERTY_STRIDE = 6, // int + ONI_STREAM_PROPERTY_MIRRORING = 7, // OniBool + + ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int + + // Camera + ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool + ONI_STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool + ONI_STREAM_PROPERTY_EXPOSURE = 102, // int + ONI_STREAM_PROPERTY_GAIN = 103, // int +}; + +// Device commands (for Invoke) +enum +{ + ONI_DEVICE_COMMAND_SEEK = 1, // OniSeek +}; + +#endif // _ONI_C_PROPERTIES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h new file mode 100644 index 000000000..122469495 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h @@ -0,0 +1,193 @@ +/***************************************************************************** +* * +* 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 _ONI_TYPES_H_ +#define _ONI_TYPES_H_ + +#include "OniPlatform.h" +#include "OniCEnums.h" + +/** Basic types **/ +typedef int OniBool; + +#ifndef TRUE +#define TRUE 1 +#endif //TRUE +#ifndef FALSE +#define FALSE 0 +#endif //FALSE + +#define ONI_MAX_STR 256 +#define ONI_MAX_SENSORS 10 + +struct OniCallbackHandleImpl; +typedef struct OniCallbackHandleImpl* OniCallbackHandle; + +/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ +typedef struct +{ + /** Major version number, incremented for major API restructuring. */ + int major; + /** Minor version number, incremented when significant new features added. */ + int minor; + /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ + int maintenance; + /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ + int build; +} OniVersion; + +typedef int OniHardwareVersion; + +/** Description of the output: format and resolution */ +typedef struct +{ + OniPixelFormat pixelFormat; + int resolutionX; + int resolutionY; + int fps; +} OniVideoMode; + +/** List of supported video modes by a specific source */ +typedef struct +{ + OniSensorType sensorType; + int numSupportedVideoModes; + OniVideoMode *pSupportedVideoModes; +} OniSensorInfo; + +/** Basic description of a device */ +typedef struct +{ + char uri[ONI_MAX_STR]; + char vendor[ONI_MAX_STR]; + char name[ONI_MAX_STR]; + uint16_t usbVendorId; + uint16_t usbProductId; +} OniDeviceInfo; + +struct _OniDevice; +typedef _OniDevice* OniDeviceHandle; + +struct _OniStream; +typedef _OniStream* OniStreamHandle; + +struct _OniRecorder; +typedef _OniRecorder* OniRecorderHandle; + +/** All information of the current frame */ +typedef struct +{ + int dataSize; + void* data; + + OniSensorType sensorType; + uint64_t timestamp; + int frameIndex; + + int width; + int height; + + OniVideoMode videoMode; + OniBool croppingEnabled; + int cropOriginX; + int cropOriginY; + + int stride; +} OniFrame; + +typedef void (ONI_CALLBACK_TYPE* OniNewFrameCallback)(OniStreamHandle stream, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniGeneralCallback)(void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniDeviceInfoCallback)(const OniDeviceInfo* pInfo, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniDeviceStateCallback)(const OniDeviceInfo* pInfo, OniDeviceState deviceState, void* pCookie); + +typedef void* (ONI_CALLBACK_TYPE* OniFrameAllocBufferCallback)(int size, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniFrameFreeBufferCallback)(void* data, void* pCookie); + +typedef struct +{ + OniDeviceInfoCallback deviceConnected; + OniDeviceInfoCallback deviceDisconnected; + OniDeviceStateCallback deviceStateChanged; +} OniDeviceCallbacks; + +typedef struct +{ + int enabled; + int originX; + int originY; + int width; + int height; +} OniCropping; + +// Pixel types +/** +Pixel type used to store depth images. +*/ +typedef uint16_t OniDepthPixel; + +/** +Pixel type used to store 16-bit grayscale images +*/ +typedef uint16_t OniGrayscale16Pixel; + +/** +Pixel type used to store 8-bit grayscale/bayer images +*/ +typedef uint8_t OniGrayscale8Pixel; + +#pragma pack (push, 1) + +/** Holds the value of a single color image pixel in 24-bit RGB format. */ +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; +} OniRGB888Pixel; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; + /** Overall luminance value of second pixel. */ + uint8_t y2; +} OniYUV422DoublePixel; + +#pragma pack (pop) + +typedef struct +{ + int frameIndex; + OniStreamHandle stream; +} OniSeek; + +#endif // _ONI_TYPES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h new file mode 100644 index 000000000..018f22271 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h @@ -0,0 +1,86 @@ +/***************************************************************************** +* * +* 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 _ONI_ENUMS_H_ +#define _ONI_ENUMS_H_ + +namespace openni +{ + +/** Possible failure values */ +typedef enum +{ + STATUS_OK = 0, + STATUS_ERROR = 1, + STATUS_NOT_IMPLEMENTED = 2, + STATUS_NOT_SUPPORTED = 3, + STATUS_BAD_PARAMETER = 4, + STATUS_OUT_OF_FLOW = 5, + STATUS_NO_DEVICE = 6, + STATUS_TIME_OUT = 102, +} Status; + +/** The source of the stream */ +typedef enum +{ + SENSOR_IR = 1, + SENSOR_COLOR = 2, + SENSOR_DEPTH = 3, + +} SensorType; + +/** All available formats of the output of a stream */ +typedef enum +{ + // Depth + PIXEL_FORMAT_DEPTH_1_MM = 100, + PIXEL_FORMAT_DEPTH_100_UM = 101, + PIXEL_FORMAT_SHIFT_9_2 = 102, + PIXEL_FORMAT_SHIFT_9_3 = 103, + + // Color + PIXEL_FORMAT_RGB888 = 200, + PIXEL_FORMAT_YUV422 = 201, + PIXEL_FORMAT_GRAY8 = 202, + PIXEL_FORMAT_GRAY16 = 203, + PIXEL_FORMAT_JPEG = 204, + PIXEL_FORMAT_YUYV = 205, +} PixelFormat; + +typedef enum +{ + DEVICE_STATE_OK = 0, + DEVICE_STATE_ERROR = 1, + DEVICE_STATE_NOT_READY = 2, + DEVICE_STATE_EOF = 3 +} DeviceState; + +typedef enum +{ + IMAGE_REGISTRATION_OFF = 0, + IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, +} ImageRegistrationMode; + +static const int TIMEOUT_NONE = 0; +static const int TIMEOUT_FOREVER = -1; + +} // namespace openni + +#endif // _ONI_ENUMS_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h new file mode 100644 index 000000000..65f6904dc --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h @@ -0,0 +1,72 @@ +/***************************************************************************** +* * +* 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 _ONI_PLATFORM_H_ +#define _ONI_PLATFORM_H_ + +// Supported platforms +#define ONI_PLATFORM_WIN32 1 +#define ONI_PLATFORM_LINUX_X86 2 +#define ONI_PLATFORM_LINUX_ARM 3 +#define ONI_PLATFORM_MACOSX 4 +#define ONI_PLATFORM_ANDROID_ARM 5 + +#if (defined _WIN32) +# ifndef RC_INVOKED +# if _MSC_VER < 1300 +# error OpenNI Platform Abstraction Layer - Win32 - Microsoft Visual Studio version below 2003 (7.0) are not supported! +# endif +# endif +# include "Win32/OniPlatformWin32.h" +#elif defined (ANDROID) && defined (__arm__) +# include "Android-Arm/OniPlatformAndroid-Arm.h" +#elif (__linux__ && (__i386__ || __x86_64__)) +# include "Linux-x86/OniPlatformLinux-x86.h" +#elif (__linux__ && __arm__) +# include "Linux-Arm/OniPlatformLinux-Arm.h" +#elif _ARC +# include "ARC/OniPlaformARC.h" +#elif (__APPLE__) +# include "MacOSX/OniPlatformMacOSX.h" +#else +# error Xiron Platform Abstraction Layer - Unsupported Platform! +#endif + +#ifdef __cplusplus +# define ONI_C extern "C" +# define ONI_C_API_EXPORT ONI_C ONI_API_EXPORT +# define ONI_C_API_IMPORT ONI_C ONI_API_IMPORT +# define ONI_CPP_API_EXPORT ONI_API_EXPORT +# define ONI_CPP_API_IMPORT ONI_API_IMPORT +#else // __cplusplus +# define ONI_C_API_EXPORT ONI_API_EXPORT +# define ONI_C_API_IMPORT ONI_API_IMPORT +#endif // __cplusplus + +#ifdef OPENNI2_EXPORT +# define ONI_C_API ONI_C_API_EXPORT +# define ONI_CPP_API ONI_CPP_API_EXPORT +#else // OPENNI2_EXPORT +# define ONI_C_API ONI_C_API_IMPORT +# define ONI_CPP_API ONI_CPP_API_IMPORT +#endif // OPENNI2_EXPORT + + +#endif // _ONI_PLATFORM_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h new file mode 100644 index 000000000..19b0805a9 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h @@ -0,0 +1,73 @@ +/***************************************************************************** +* * +* 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 _ONI_PROPERTIES_H_ +#define _ONI_PROPERTIES_H_ + +namespace openni +{ + +// Device properties +enum +{ + DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // string + DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion + DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int + DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string + DEVICE_PROPERTY_ERROR_STATE = 4, // ?? + DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode + + // Files + DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float + DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool +}; + +// Stream properties +enum +{ + STREAM_PROPERTY_CROPPING = 0, // OniCropping* + STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians + STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians + STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* + + STREAM_PROPERTY_MAX_VALUE = 4, // int + STREAM_PROPERTY_MIN_VALUE = 5, // int + + STREAM_PROPERTY_STRIDE = 6, // int + STREAM_PROPERTY_MIRRORING = 7, // OniBool + + STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int + + // Camera + STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool + STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool + STREAM_PROPERTY_EXPOSURE = 102, // int + STREAM_PROPERTY_GAIN = 103, // int + +}; + +// Device commands (for Invoke) +enum +{ + DEVICE_COMMAND_SEEK = 1, // OniSeek +}; + +} // namespace openni +#endif // _ONI_PROPERTIES_H_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h new file mode 100644 index 000000000..7aa13ed58 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h @@ -0,0 +1,43 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ +#include "OniPlatform.h" + +#define ONI_VERSION_MAJOR 2 +#define ONI_VERSION_MINOR 2 +#define ONI_VERSION_MAINTENANCE 0 +#define ONI_VERSION_BUILD 33 + +/** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */ +#define ONI_BRIEF_VERSION_STRING \ + ONI_STRINGIFY(ONI_VERSION_MAJOR) "." \ + ONI_STRINGIFY(ONI_VERSION_MINOR) "." \ + ONI_STRINGIFY(ONI_VERSION_MAINTENANCE) \ + " (Build " ONI_STRINGIFY(ONI_VERSION_BUILD) ")" + +/** OpenNI version (in numeric format): (OpenNI major version * 100000000 + OpenNI minor version * 1000000 + OpenNI maintenance version * 10000 + OpenNI build version). */ +#define ONI_VERSION (ONI_VERSION_MAJOR*100000000 + ONI_VERSION_MINOR*1000000 + ONI_VERSION_MAINTENANCE*10000 + ONI_VERSION_BUILD) +#define ONI_CREATE_API_VERSION(major, minor) ((major)*1000 + (minor)) +#define ONI_API_VERSION ONI_CREATE_API_VERSION(ONI_VERSION_MAJOR, ONI_VERSION_MINOR) + +/** OpenNI version (in string format): "Major.Minor.Maintenance.Build-Platform (MMM DD YYYY HH:MM:SS)". */ +#define ONI_VERSION_STRING \ + ONI_BRIEF_VERSION_STRING "-" \ + ONI_PLATFORM_STRING " (" ONI_TIMESTAMP ")" diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h new file mode 100644 index 000000000..52324b4eb --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h @@ -0,0 +1,2750 @@ +/***************************************************************************** +* * +* 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" + +/** +openni is the namespace of the entire C++ API of OpenNI +*/ +namespace openni +{ + +/** Pixel type used to store depth images. */ +typedef uint16_t DepthPixel; + +/** Pixel type used to store IR images. */ +typedef uint16_t Grayscale16Pixel; + +// structs +/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ +typedef struct +{ + /** Major version number, incremented for major API restructuring. */ + int major; + /** Minor version number, incremented when significant new features added. */ + int minor; + /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ + int maintenance; + /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ + int build; +} Version; + +/** Holds the value of a single color image pixel in 24-bit RGB format. */ +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; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; + /** Overall luminance value of second pixel. */ + uint8_t y2; +} YUV422DoublePixel; + +/** This special URI can be passed to @ref Device::open() when the application has no concern for a specific device. */ +#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 + +/** +Provides a simple array class used throughout the API. Wraps a primitive array +of objects, holding the elements and their count. +*/ +template +class Array +{ +public: + /** + Default constructor. Creates an empty Array and sets the element count to zero. + */ + Array() : m_data(NULL), m_count(0), m_owner(false) {} + + /** + Constructor. Creates new Array from an existing primitive array of known size. + + @tparam [in] T Object type this Array will contain. + @param [in] data Pointer to a primitive array of objects of type T. + @param [in] count Number of elements in the primitive array pointed to by data. + */ + Array(const T* data, int count) : m_owner(false) { _setData(data, count); } + + /** + Destructor. Destroys the Array object. + */ + ~Array() + { + clear(); + } + + /** + Getter function for the Array size. + @returns Current number of elements in the Array. + */ + int getSize() const { return m_count; } + + /** + Implements the array indexing operator for the Array class. + */ + const T& operator[](int index) const {return m_data[index];} + + /** + @internal + Setter function for data. Causes this array to wrap an existing primitive array + of specified type. The optional data ownership flag controls whether the primitive + array this Array wraps will be destroyed when this Array is deconstructed. + @param [in] T Type of objects array will contain. + @param [in] data Pointer to first object in list. + @param [in] count Number of objects in list. + @param [in] isOwner Optional flag to indicate data ownership + */ + 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&); + Array& operator=(const Array&); + + 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; + +/** +Encapsulates a group of settings for a @ref VideoStream. Settings stored include +frame rate, resolution, and pixel format. + +This class is used as an input for changing the settings of a @ref VideoStream, +as well as an output for reporting the current settings of that class. It is also used +by @ref SensorInfo to report available video modes of a stream. + +Recommended practice is to use @ref SensorInfo::getSupportedVideoModes() +to obtain a list of valid video modes, and then to use items from that list to pass +new settings to @ref VideoStream. This is much less likely to produce an +invalid video mode than instantiating and manually changing objects of this +class. +*/ +class VideoMode : private OniVideoMode +{ +public: + /** + Default constructor, creates an empty VideoMode object. Application programs should, in most + cases, use the copy constructor to copy an existing valid video mode. This is much less + error prone that creating and attempting to configure a new VideoMode from scratch. + */ + VideoMode() + {} + + /** + Copy constructor, creates a new VideoMode identical to an existing VideoMode. + + @param [in] other Existing VideoMode to copy. + */ + VideoMode(const VideoMode& other) + { + *this = other; + } + + /** + Assignment operator. Sets the pixel format, frame rate, and resolution of this + VideoMode to equal that of a different VideoMode. + + @param [in] other Existing VideoMode to copy settings from. + */ + VideoMode& operator=(const VideoMode& other) + { + setPixelFormat(other.getPixelFormat()); + setResolution(other.getResolutionX(), other.getResolutionY()); + setFps(other.getFps()); + + return *this; + } + + /** + Getter function for the pixel format of this VideoMode. + @returns Current pixel format setting of this VideoMode. + */ + PixelFormat getPixelFormat() const { return (PixelFormat)pixelFormat; } + + /** + Getter function for the X resolution of this VideoMode. + @returns Current horizontal resolution of this VideoMode, in pixels. + */ + int getResolutionX() const { return resolutionX; } + + /** + Getter function for the Y resolution of this VideoMode. + @returns Current vertical resolution of this VideoMode, in pixels. + */ + int getResolutionY() const {return resolutionY;} + + /** + Getter function for the frame rate of this VideoMode. + @returns Current frame rate, measured in frames per second. + */ + int getFps() const { return fps; } + + /** + Setter function for the pixel format of this VideoMode. Application use of this + function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() + to obtain a list of valid video modes. + @param [in] format Desired new pixel format for this VideoMode. + */ + void setPixelFormat(PixelFormat format) { this->pixelFormat = (OniPixelFormat)format; } + + /** + Setter function for the resolution of this VideoMode. Application use of this + function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() to + obtain a list of valid video modes. + @param [in] resolutionX Desired new horizontal resolution in pixels. + @param [in] resolutionY Desired new vertical resolution in pixels. + */ + void setResolution(int resolutionX, int resolutionY) + { + this->resolutionX = resolutionX; + this->resolutionY = resolutionY; + } + + /** + Setter function for the frame rate. Application use of this function is not recommended. + Instead, use @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid + video modes. + @param [in] fps Desired new frame rate, measured in frames per second. + */ + void setFps(int fps) { this->fps = fps; } + + friend class SensorInfo; + friend class VideoStream; + friend class VideoFrameRef; +}; + +/** +The SensorInfo class encapsulates all info related to a specific sensor in a specific +device. +A @ref Device object holds a SensorInfo object for each sensor it contains. +A @ref VideoStream object holds one SensorInfo object, describing the sensor used to produce that stream. + +A given SensorInfo object will contain the type of the sensor (Depth, IR or Color), and +a list of all video modes that the sensor can support. Each available video mode will have a single +VideoMode object that can be queried to get the details of that mode. + +SensorInfo objects should be the only source of VideoMode objects for the vast majority of +application programs. + +Application programs will never directly instantiate objects of type SensorInfo. In fact, no +public constructors are provided. SensorInfo objects should be obtained either from a Device or @ref VideoStream, +and in turn be used to provide available video modes for that sensor. +*/ +class SensorInfo +{ +public: + /** + Provides the sensor type of the sensor this object is associated with. + @returns Type of the sensor. + */ + SensorType getSensorType() const { return (SensorType)m_pInfo->sensorType; } + + /** + Provides a list of video modes that this sensor can support. This function is the + recommended method to be used by applications to obtain @ref VideoMode objects. + + @returns Reference to an array of @ref VideoMode objects, one for each supported + video mode. + */ + const Array& 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(pInfo->pSupportedVideoModes), pInfo->numSupportedVideoModes); + } + } + + const OniSensorInfo* m_pInfo; + Array m_videoModes; + + friend class VideoStream; + friend class Device; +}; + +/** +The DeviceInfo class encapsulates info related to a specific device. + +Applications will generally obtain objects of this type via calls to @ref OpenNI::enumerateDevices() or +@ref openni::Device::getDeviceInfo(), and then use the various accessor functions to obtain specific +information on that device. + +There should be no reason for application code to instantiate this object directly. +*/ +class DeviceInfo : private OniDeviceInfo +{ +public: + /** + Returns the device URI. URI can be used by @ref Device::open to open a specific device. + The URI string format is determined by the driver. + */ + const char* getUri() const { return uri; } + /** Returns a the vendor name for this device. */ + const char* getVendor() const { return vendor; } + /** Returns the device name for this device. */ + const char* getName() const { return name; } + /** Returns the USB VID code for this device. */ + uint16_t getUsbVendorId() const { return usbVendorId; } + /** Returns the USB PID code for this device. */ + uint16_t getUsbProductId() const { return usbProductId; } + + friend class Device; + friend class OpenNI; +}; + +/** +The @ref VideoFrameRef class encapsulates a single video frame - the output of a @ref VideoStream at a specific time. +The data contained will be a single frame of color, IR, or depth video, along with associated meta data. + +An object of type @ref VideoFrameRef does not actually hold the data of the frame, but only a reference to it. The +reference can be released by destroying the @ref VideoFrameRef object, or by calling the @ref release() method. The +actual data of the frame is freed when the last reference to it is released. + +The usual way to obtain @ref VideoFrameRef objects is by a call to @ref VideoStream.:readFrame(). + +All data references by a @ref VideoFrameRef is stored as a primitive array of pixels. Each pixel will be +of a type according to the configured pixel format (see @ref VideoMode). +*/ +class VideoFrameRef +{ +public: + /** + Default constructor. Creates a new empty @ref VideoFrameRef object. + This object will be invalid until initialized by a call to @ref VideoStream::readFrame(). + */ + VideoFrameRef() + { + m_pFrame = NULL; + } + + /** + Destroy this object and release the reference to the frame. + */ + ~VideoFrameRef() + { + release(); + } + + /** + Copy constructor. Creates a new @ref VideoFrameRef object. The newly created + object will reference the same frame current object references. + @param [in] other Another @ref VideoFrameRef object. + */ + VideoFrameRef(const VideoFrameRef& other) : m_pFrame(NULL) + { + _setFrame(other.m_pFrame); + } + + /** + Make this @ref VideoFrameRef object reference the same frame that the @c other frame references. + If this object referenced another frame before calling this method, the previous frame will be released. + @param [in] other Another @ref VideoFrameRef object. + */ + VideoFrameRef& operator=(const VideoFrameRef& other) + { + _setFrame(other.m_pFrame); + return *this; + } + + /** + Getter function for the size of the data contained by this object. Useful primarily + when allocating buffers. + @returns Current size of data pointed to by this object, measured in bytes. + */ + inline int getDataSize() const + { + return m_pFrame->dataSize; + } + + /** + Getter function for the array of data pointed to by this object. + @returns Pointer to the actual frame data array. Type of data + pointed to can be determined according to the pixel format (can be obtained by calling @ref getVideoMode()). + */ + inline const void* getData() const + { + return m_pFrame->data; + } + + /** + Getter function for the sensor type used to produce this frame. Used to determine whether + this is an IR, Color or Depth frame. See the @ref SensorType enumeration for all possible return + values from this function. + @returns The type of sensor used to produce this frame. + */ + inline SensorType getSensorType() const + { + return (SensorType)m_pFrame->sensorType; + } + + /** + Returns a reference to the @ref VideoMode object assigned to this frame. This object describes + the video mode the sensor was configured to when the frame was produced and can be used + to determine the pixel format and resolution of the data. It will also provide the frame rate + that the sensor was running at when it recorded this frame. + @returns Reference to the @ref VideoMode assigned to this frame. + */ + inline const VideoMode& getVideoMode() const + { + return static_cast(m_pFrame->videoMode); + } + + /** + Provides a timestamp for the frame. The 'zero' point for this stamp + is implementation specific, but all streams from the same device are guaranteed to use the same zero. + This value can therefore be used to compute time deltas between frames from the same device, + regardless of whether they are from the same stream. + @returns Timestamp of frame, measured in microseconds from an arbitrary zero + */ + inline uint64_t getTimestamp() const + { + return m_pFrame->timestamp; + } + + /** + Frames are provided sequential frame ID numbers by the sensor that produced them. If frame + synchronization has been enabled for a device via @ref Device::setDepthColorSyncEnabled(), then frame + numbers for corresponding frames of depth and color are guaranteed to match. + + If frame synchronization is not enabled, then there is no guarantee of matching frame indexes between + @ref VideoStream "VideoStreams". In the latter case, applications should use timestamps instead of frame indexes to + align frames in time. + @returns Index number for this frame. + */ + inline int getFrameIndex() const + { + return m_pFrame->frameIndex; + } + + /** + Gives the current width of this frame, measured in pixels. If cropping is enabled, this will be + the width of the cropping window. If cropping is not enabled, then this will simply be equal to + the X resolution of the @ref VideoMode used to produce this frame. + @returns Width of this frame in pixels. + */ + inline int getWidth() const + { + return m_pFrame->width; + } + + /** + Gives the current height of this frame, measured in pixels. If cropping is enabled, this will + be the length of the cropping window. If cropping is not enabled, then this will simply be equal + to the Y resolution of the @ref VideoMode used to produce this frame. + */ + inline int getHeight() const + { + return m_pFrame->height; + } + + /** + Indicates whether cropping was enabled when the frame was produced. + @return true if cropping is enabled, false otherwise + */ + inline bool getCroppingEnabled() const + { + return m_pFrame->croppingEnabled == TRUE; + } + + /** + Indicates the X coordinate of the upper left corner of the crop window. + @return Distance of crop origin from left side of image, in pixels. + */ + inline int getCropOriginX() const + { + return m_pFrame->cropOriginX; + } + + /** + Indicates the Y coordinate of the upper left corner of the crop window. + @return Distance of crop origin from top of image, in pixels. + */ + inline int getCropOriginY() const + { + return m_pFrame->cropOriginY; + } + + /** + Gives the length of one row of pixels, measured in bytes. Primarily useful + for indexing the array which contains the data. + @returns Stride of the array which contains the image for this frame, in bytes + */ + inline int getStrideInBytes() const + { + return m_pFrame->stride; + } + + /** + Check if this object references an actual frame. + */ + inline bool isValid() const + { + return m_pFrame != NULL; + } + + /** + Release the reference to the frame. Once this method is called, the object becomes invalid, and no method + should be called other than the assignment operator, or passing this object to a @ref VideoStream::readFrame() call. + */ + void release() + { + if (m_pFrame != NULL) + { + oniFrameRelease(m_pFrame); + m_pFrame = NULL; + } + } + + /** @internal */ + void _setFrame(OniFrame* pFrame) + { + setReference(pFrame); + if (pFrame != NULL) + { + oniFrameAddRef(pFrame); + } + } + + /** @internal */ + 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!!? +}; + +/** +The @ref VideoStream object encapsulates a single video stream from a device. Once created, it is used to start data flow +from the device, and to read individual frames of data. This is the central class used to obtain data in OpenNI. It +provides the ability to manually read data in a polling loop, as well as providing events and a Listener class that can be +used to implement event-driven data acquisition. + +Aside from the video data frames themselves, the class offers a number of functions used for obtaining information about a +@ref VideoStream. Field of view, available video modes, and minimum and maximum valid pixel values can all be obtained. + +In addition to obtaining data, the @ref VideoStream object is used to set all configuration properties that apply to a specific +stream (rather than to an entire device). In particular, it is used to control cropping, mirroring, and video modes. + +A pointer to a valid, initialized device that provides the desired stream type is required to create a stream. + +Several video streams can be created to stream data from the same sensor. This is useful if several components of an application +need to read frames separately. + +While some device might allow different streams +from the same sensor to have different configurations, most devices will have a single configuration for the sensor, +shared by all streams. +*/ +class VideoStream +{ +public: + /** + The @ref VideoStream::NewFrameListener class is provided to allow the implementation of event driven frame reading. To use + it, create a class that inherits from it and implement override the onNewFrame() method. Then, register + your created class with an active @ref VideoStream using the @ref VideoStream::addNewFrameListener() function. Once this is done, the + event handler function you implemented will be called whenever a new frame becomes available. You may call + @ref VideoStream::readFrame() from within the event handler. + */ + class NewFrameListener + { + public: + /** + Default constructor. + */ + NewFrameListener() : m_callbackHandle(NULL) + { + } + + virtual ~NewFrameListener() + { + } + + /** + Derived classes should implement this function to handle new frames. + */ + 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); + } + }; + + /** + Default constructor. Creates a new, non-valid @ref VideoStream object. The object created will be invalid until its create() function + is called with a valid Device. + */ + VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true) + {} + + /** + Handle constructor. Creates a VideoStream object based on the given initialized handle. + This object will not destroy the underlying handle when @ref destroy() or destructor is called + */ + explicit VideoStream(OniStreamHandle handle) : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(false) + { + _setHandle(handle); + } + + /** + Destructor. The destructor calls the destroy() function, but it is considered a best practice for applications to + call destroy() manually on any @ref VideoStream that they run create() on. + */ + ~VideoStream() + { + destroy(); + } + + /** + Checks to see if this object has been properly initialized and currently points to a valid stream. + @returns true if this object has been previously initialized, false otherwise. + */ + bool isValid() const + { + return m_stream != NULL; + } + + /** + Creates a stream of frames from a specific sensor type of a specific device. You must supply a reference to a + Device that supplies the sensor type requested. You can use @ref Device::hasSensor() to check whether a + given sensor is available on your target device before calling create(). + + @param [in] device A reference to the @ref Device you want to create the stream on. + @param [in] sensorType The type of sensor the stream should produce data from. + @returns Status code indicating success or failure for this operation. + */ + inline Status create(const Device& device, SensorType sensorType); + + /** + Destroy this stream. This function is currently called automatically by the destructor, but it is + considered a best practice for applications to manually call this function on any @ref VideoStream that they + call create() for. + */ + inline void destroy(); + + /** + Provides the @ref SensorInfo object associated with the sensor that is producing this @ref VideoStream. Note that + this function will return NULL if the stream has not yet been initialized with the create() function. + + @ref SensorInfo is useful primarily as a means of learning which video modes are valid for this VideoStream. + + @returns Reference to the SensorInfo object associated with the sensor providing this stream. + */ + const SensorInfo& getSensorInfo() const + { + return m_sensorInfo; + } + + /** + Starts data generation from this video stream. + */ + Status start() + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamStart(m_stream); + } + + /** + Stops data generation from this video stream. + */ + void stop() + { + if (!isValid()) + { + return; + } + + oniStreamStop(m_stream); + } + + /** + Read the next frame from this video stream, delivered as a @ref VideoFrameRef. This is the primary + method for manually obtaining frames of video data. + If no new frame is available, the call will block until one is available. + To avoid blocking, use @ref VideoStream::Listener to implement an event driven architecture. Another + alternative is to use @ref OpenNI::waitForAnyStream() to wait for new frames from several streams. + + @param [out] pFrame Pointer to a @ref VideoFrameRef object to hold the reference to the new frame. + @returns Status code to indicated success or failure of this function. + */ + Status readFrame(VideoFrameRef* pFrame) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + OniFrame* pOniFrame; + Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame); + + pFrame->setReference(pOniFrame); + return rc; + } + + /** + Adds a new Listener to receive this VideoStream onNewFrame event. See @ref VideoStream::NewFrameListener for + more information on implementing an event driven frame reading architecture. An instance of a listener can be added to only one source. + + @param [in] pListener Pointer to a @ref VideoStream::NewFrameListener object (or a derivative) that will respond to this event. + @returns Status code indicating success or failure of the operation. + */ + Status addNewFrameListener(NewFrameListener* pListener) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamRegisterNewFrameCallback(m_stream, pListener->callback, pListener, &pListener->m_callbackHandle); + } + + /** + Removes a Listener from this video stream list. The listener removed will no longer receive new frame events from this stream. + @param [in] pListener Pointer to the listener object to be removed. + */ + void removeNewFrameListener(NewFrameListener* pListener) + { + if (!isValid()) + { + return; + } + + oniStreamUnregisterNewFrameCallback(m_stream, pListener->m_callbackHandle); + pListener->m_callbackHandle = NULL; + } + + /** + Sets the frame buffers allocator for this video stream. + @param [in] pAllocator Pointer to the frame buffers allocator object. Pass NULL to return to default frame allocator. + @returns ONI_STATUS_OUT_OF_FLOW The frame buffers allocator cannot be set while stream is streaming. + */ + 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); + } + } + + /** + @internal + Get an internal handle. This handle can be used via the C API. + */ + OniStreamHandle _getHandle() const + { + return m_stream; + } + + /** + Gets an object through which several camera settings can be configured. + @returns NULL if the stream doesn't support camera settings. + */ + CameraSettings* getCameraSettings() {return m_pCameraSettings;} + + /** + General function for obtaining the value of stream specific properties. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of the getProperty function very often. + + @param [in] propertyId The numerical ID of the property to be queried. + @param [out] data Place to store the value of the property. + @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. + @returns Status code indicating success or failure of this operation. + */ + Status getProperty(int propertyId, void* data, int* dataSize) const + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamGetProperty(m_stream, propertyId, data, dataSize); + } + + /** + General function for setting the value of stream specific properties. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of the setProperty function very often. + + @param [in] propertyId The numerical ID of the property to be set. + @param [in] data Place to store the data to be written to the property. + @param [in] dataSize Size of the data to be written to the property. + @returns Status code indicating success or failure of this operation. + */ + Status setProperty(int propertyId, const void* data, int dataSize) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamSetProperty(m_stream, propertyId, data, dataSize); + } + + /** + Get the current video mode information for this video stream. + This includes its resolution, fps and stream format. + + @returns Current video mode information for this video stream. + */ + VideoMode getVideoMode() const + { + VideoMode videoMode; + getProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(&videoMode)); + return videoMode; + } + + /** + Changes the current video mode of this stream. Recommended practice is to use @ref Device::getSensorInfo(), and + then @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid video mode settings for this stream. Then, + pass a valid @ref VideoMode to @ref setVideoMode to ensure correct operation. + + @param [in] videoMode Desired new video mode for this stream. + returns Status code indicating success or failure of this operation. + */ + Status setVideoMode(const VideoMode& videoMode) + { + return setProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(videoMode)); + } + + /** + Provides the maximum possible value for pixels obtained by this stream. This is most useful for + getting the maximum possible value of depth streams. + @returns Maximum possible pixel value. + */ + int getMaxPixelValue() const + { + int maxValue; + Status rc = getProperty(STREAM_PROPERTY_MAX_VALUE, &maxValue); + if (rc != STATUS_OK) + { + return 0; + } + return maxValue; + } + + /** + Provides the smallest possible value for pixels obtains by this VideoStream. This is most useful + for getting the minimum possible value that will be reported by a depth stream. + @returns Minimum possible pixel value that can come from this stream. + */ + int getMinPixelValue() const + { + int minValue; + Status rc = getProperty(STREAM_PROPERTY_MIN_VALUE, &minValue); + if (rc != STATUS_OK) + { + return 0; + } + return minValue; + } + + /** + Checks whether this stream supports cropping. + @returns true if the stream supports cropping, false if it does not. + */ + bool isCroppingSupported() const + { + return isPropertySupported(STREAM_PROPERTY_CROPPING); + } + + /** + Obtains the current cropping settings for this stream. + @param [out] pOriginX X coordinate of the upper left corner of the cropping window + @param [out] pOriginY Y coordinate of the upper left corner of the cropping window + @param [out] pWidth Horizontal width of the cropping window, in pixels + @param [out] pHeight Vertical width of the cropping window, in pixels + returns true if cropping is currently enabled, false if it is not. + */ + bool getCropping(int* pOriginX, int* pOriginY, int* pWidth, int* pHeight) const + { + OniCropping cropping; + bool enabled = false; + + Status rc = getProperty(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; + } + + /** + Changes the cropping settings for this stream. You can use the @ref isCroppingSupported() + function to make sure cropping is supported before calling this function. + @param [in] originX New X coordinate of the upper left corner of the cropping window. + @param [in] originY New Y coordinate of the upper left corner of the cropping window. + @param [in] width New horizontal width for the cropping window, in pixels. + @param [in] height New vertical height for the cropping window, in pixels. + @returns Status code indicating success or failure of this operation. + */ + 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(STREAM_PROPERTY_CROPPING, cropping); + } + + /** + Disables cropping. + @returns Status code indicating success or failure of this operation. + */ + Status resetCropping() + { + OniCropping cropping; + cropping.enabled = false; + return setProperty(STREAM_PROPERTY_CROPPING, cropping); + } + + /** + Check whether mirroring is currently turned on for this stream. + @returns true if mirroring is currently enabled, false otherwise. + */ + bool getMirroringEnabled() const + { + OniBool enabled; + Status rc = getProperty(STREAM_PROPERTY_MIRRORING, &enabled); + if (rc != STATUS_OK) + { + return false; + } + return enabled == TRUE; + } + + /** + Enable or disable mirroring for this stream. + @param [in] isEnabled true to enable mirroring, false to disable it. + @returns Status code indicating the success or failure of this operation. + */ + Status setMirroringEnabled(bool isEnabled) + { + return setProperty(STREAM_PROPERTY_MIRRORING, isEnabled ? TRUE : FALSE); + } + + /** + Gets the horizontal field of view of frames received from this stream. + @returns Horizontal field of view, in radians. + */ + float getHorizontalFieldOfView() const + { + float horizontal = 0; + getProperty(STREAM_PROPERTY_HORIZONTAL_FOV, &horizontal); + return horizontal; + } + + /** + Gets the vertical field of view of frames received from this stream. + @returns Vertical field of view, in radians. + */ + float getVerticalFieldOfView() const + { + float vertical = 0; + getProperty(STREAM_PROPERTY_VERTICAL_FOV, &vertical); + return vertical; + } + + /** + Function for setting a value of a stream property using an arbitrary input type. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of this function very often. + @tparam [in] T Data type of the value to be passed to the property. + @param [in] propertyId The numerical ID of the property to be set. + @param [in] value Data to be sent to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status setProperty(int propertyId, const T& value) + { + return setProperty(propertyId, &value, sizeof(T)); + } + + /** + Function for getting the value from a property using an arbitrary output type. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of this function very often. + @tparam [in] T Data type of the value to be read. + @param [in] propertyId The numerical ID of the property to be read. + @param [in, out] value Pointer to a place to store the value read from the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status getProperty(int propertyId, T* value) const + { + int size = sizeof(T); + return getProperty(propertyId, value, &size); + } + + /** + Checks if a specific property is supported by the video stream. + @param [in] propertyId Property to be checked. + @returns true if the property is supported, false otherwise. + */ + bool isPropertySupported(int propertyId) const + { + if (!isValid()) + { + return false; + } + + return oniStreamIsPropertySupported(m_stream, propertyId) == TRUE; + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] data Data to be passed to the property. + @param [in] dataSize size of the buffer passed in @c data. + @returns Status code indicating success or failure of this operation. + */ + Status invoke(int commandId, void* data, int dataSize) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamInvoke(m_stream, commandId, data, dataSize); + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Type of data to be passed to the property. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] value Data to be passed to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status invoke(int commandId, T& value) + { + return invoke(commandId, &value, sizeof(T)); + } + + /** + Checks if a specific command is supported by the video stream. + @param [in] commandId Command to be checked. + @returns true if the command is supported, false otherwise. + */ + 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; +}; + +/** +The Device object abstracts a specific device; either a single hardware device, or a file +device holding a recording from a hardware device. It offers the ability to connect to +the device, and obtain information about its configuration and the data streams it can offer. + +It provides the means to query and change all configuration parameters that apply to the +device as a whole. This includes enabling depth/color image registration and frame +synchronization. + +Devices are used when creating and initializing @ref VideoStream "VideoStreams" -- you will need a valid pointer to +a Device in order to use the VideoStream.create() function. This, along with configuration, is +the primary use of this class for application developers. + +Before devices can be created, @ref OpenNI::initialize() must have been run to make the device drivers +on the system available to the API. +*/ +class Device +{ +public: + /** + Default constructor. Creates a new empty Device object. This object will be invalid until it is initialized by + calling its open() function. + */ + Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true) + { + clearSensors(); + } + + /** + Handle constructor. Creates a Device object based on the given initialized handle. + This object will not destroy the underlying handle when @ref close() or destructor is called + */ + explicit Device(OniDeviceHandle handle) : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(false) + { + _setHandle(handle); + } + + /** + The destructor calls the @ref close() function, but it is considered a best practice for applications to + call @ref close() manually on any @ref Device that they run @ref open() on. + */ + ~Device() + { + if (m_device != NULL) + { + close(); + } + } + + /** + Opens a device. This can either open a device chosen arbitrarily from all devices + on the system, or open a specific device selected by passing this function the device URI. + + To open any device, simply pass the constant@ref ANY_DEVICE to this function. If multiple + devices are connected to the system, then one of them will be opened. This procedure is most + useful when it is known that exactly one device is (or can be) connected to the system. In that case, + requesting a list of all devices and iterating through it would be a waste of effort. + + If multiple devices are (or may be) connected to a system, then a URI will be required to select + a specific device to open. There are two ways to obtain a URI: from a DeviceConnected event, or + by calling @ref OpenNI::enumerateDevices(). + + In the case of a DeviceConnected event, the @ref OpenNI::Listener will be provided with a DeviceInfo object + as an argument to its @ref OpenNI::Listener::onDeviceConnected "onDeviceConnected()" function. + The DeviceInfo.getUri() function can then be used to obtain the URI. + + If the application is not using event handlers, then it can also call the static function + @ref OpenNI::enumerateDevices(). This will return an array of @ref DeviceInfo objects, one for each device + currently available to the system. The application can then iterate through this list and + select the desired device. The URI is again obtained via the @ref DeviceInfo::getUri() function. + + Standard codes of type Status are returned indicating whether opening was successful. + + @param [in] uri String containing the URI of the device to be opened, or @ref ANY_DEVICE. + @returns Status code with the outcome of the open operation. + + @remark For opening a recording file, pass the file path as a uri. + */ + inline Status open(const char* uri); + + /** + Closes the device. This properly closes any files or shuts down hardware, as appropriate. This + function is currently called by the destructor if not called manually by application code, but it + is considered a best practice to manually close any device that was opened. + */ + inline void close(); + + /** + Provides information about this device in the form of a DeviceInfo object. This object can + be used to access the URI of the device, as well as various USB descriptor strings that might + be useful to an application. + + Note that valid device info will not be available if this device has not yet been opened. If you are + trying to obtain a URI to open a device, use OpenNI::enumerateDevices() instead. + @returns DeviceInfo object for this Device + */ + const DeviceInfo& getDeviceInfo() const + { + return m_deviceInfo; + } + + /** + This function checks to see if one of the specific sensor types defined in @ref SensorType is + available on this device. This allows an application to, for example, query for the presence + of a depth sensor, or color sensor. + @param [in] sensorType of sensor to query for + @returns true if the Device supports the sensor queried, false otherwise. + */ + 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; + } + + /** + Get the @ref SensorInfo for a specific sensor type on this device. The @ref SensorInfo + is useful primarily for determining which video modes are supported by the sensor. + @param [in] sensorType of sensor to get information about. + @returns SensorInfo object corresponding to the sensor type specified, or NULL if such a sensor + is not available from this device. + */ + 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]; + } + + /** + @internal + Get an internal handle. This handle can be used via the C API. + */ + OniDeviceHandle _getHandle() const + { + return m_device; + } + + /** + Gets an object through which playback of a file device can be controlled. + @returns NULL if this device is not a file device. + */ + PlaybackControl* getPlaybackControl() {return m_pPlaybackControl;} + + /** + Get the value of a general property of the device. + There are convenience functions for all the commonly used properties, such as + image registration and frame synchronization. It is expected for this reason + that this function will rarely be directly used by applications. + + @param [in] propertyId Numerical ID of the property you would like to check. + @param [out] data Place to store the value of the property. + @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. + @returns Status code indicating results of this operation. + */ + Status getProperty(int propertyId, void* data, int* dataSize) const + { + return (Status)oniDeviceGetProperty(m_device, propertyId, data, dataSize); + } + + /** + Sets the value of a general property of the device. + There are convenience functions for all the commonly used properties, such as + image registration and frame synchronization. It is expected for this reason + that this function will rarely be directly used by applications. + + @param [in] propertyId The numerical ID of the property to be set. + @param [in] data Place to store the data to be written to the property. + @param [in] dataSize Size of the data to be written to the property. + @returns Status code indicating results of this operation. + */ + Status setProperty(int propertyId, const void* data, int dataSize) + { + return (Status)oniDeviceSetProperty(m_device, propertyId, data, dataSize); + } + + /** + Checks to see if this device can support registration of color video and depth video. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + @returns true if image registration is supported by this device, false otherwise. + */ + bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const + { + return (oniDeviceIsImageRegistrationModeSupported(m_device, (OniImageRegistrationMode)mode) == TRUE); + } + + /** + Gets the current image registration mode of this device. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + @returns Current image registration mode. See @ref ImageRegistrationMode for possible return values. + */ + ImageRegistrationMode getImageRegistrationMode() const + { + ImageRegistrationMode mode; + Status rc = getProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, &mode); + if (rc != STATUS_OK) + { + return IMAGE_REGISTRATION_OFF; + } + return mode; + } + + /** + Sets the image registration on this device. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + + See @ref ImageRegistrationMode for a list of valid settings to pass to this function. + + It is a good practice to first check if the mode is supported by calling @ref isImageRegistrationModeSupported(). + + @param [in] mode Desired new value for the image registration mode. + @returns Status code for the operation. + */ + Status setImageRegistrationMode(ImageRegistrationMode mode) + { + return setProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, mode); + } + + /** + Checks whether this Device object is currently connected to an actual file or hardware device. + @returns true if the Device is connected, false otherwise. + */ + bool isValid() const + { + return m_device != NULL; + } + + /** + Checks whether this device is a file device (i.e. a recording). + @returns true if this is a file device, false otherwise. + */ + bool isFile() const + { + return isPropertySupported(DEVICE_PROPERTY_PLAYBACK_SPEED) && + isPropertySupported(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED) && + isCommandSupported(DEVICE_COMMAND_SEEK); + } + + /** + Used to turn the depth/color frame synchronization feature on and off. When frame synchronization + is enabled, the device will deliver depth and image frames that are separated in time + by some maximum value. When disabled, the phase difference between depth and image frame + generation cannot be guaranteed. + @param [in] isEnabled Set to TRUE to enable synchronization, FALSE to disable it + @returns Status code indicating success or failure of this operation + */ + 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; + } + + /** + Sets a property that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + + @tparam T Type of data to be passed to the property. + @param [in] propertyId The numerical ID of the property to be set. + @param [in] value Place to store the data to be written to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status setProperty(int propertyId, const T& value) + { + return setProperty(propertyId, &value, sizeof(T)); + } + + /** + Checks a property that provides an arbitrary data type as its output. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Data type of the value to be read. + @param [in] propertyId The numerical ID of the property to be read. + @param [in, out] value Pointer to a place to store the value read from the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status getProperty(int propertyId, T* value) const + { + int size = sizeof(T); + return getProperty(propertyId, value, &size); + } + + /** + Checks if a specific property is supported by the device. + @param [in] propertyId Property to be checked. + @returns true if the property is supported, false otherwise. + */ + bool isPropertySupported(int propertyId) const + { + return oniDeviceIsPropertySupported(m_device, propertyId) == TRUE; + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] data Data to be passed to the property. + @param [in] dataSize size of the buffer passed in @c data. + @returns Status code indicating success or failure of this operation. + */ + Status invoke(int commandId, void* data, int dataSize) + { + return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize); + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Type of data to be passed to the property. + @param [in] propertyId Numerical code of the property to be invoked. + @param [in] value Data to be passed to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status invoke(int propertyId, T& value) + { + return invoke(propertyId, &value, sizeof(T)); + } + + /** + Checks if a specific command is supported by the device. + @param [in] commandId Command to be checked. + @returns true if the command is supported, false otherwise. + */ + bool isCommandSupported(int commandId) const + { + return oniDeviceIsCommandSupported(m_device, commandId) == TRUE; + } + + /** @internal **/ + 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; +}; + +/** + * The PlaybackControl class provides access to a series of specific to playing back + * a recording from a file device. + * + * When playing a stream back from a recording instead of playing from a live device, + * it is possible to vary playback speed, change the current time location (ie + * fast forward / rewind / seek), specify whether the playback should be repeated at the end + * of the recording, and query the total size of the recording. + * + * Since none of these functions make sense in the context of a physical device, they are + * split out into a seperate playback control class. To use, simply create your file device, + * create a PlaybackControl, and then attach the PlaybackControl to the file device. + */ +class PlaybackControl +{ +public: + + /** + * Deconstructor. Destroys a PlaybackControl class. The deconstructor presently detaches + * from its recording automatically, but it is considered a best practice for applications to + * manually detach from any stream that was attached to. + */ + ~PlaybackControl() + { + detach(); + } + + /** + * Getter function for the current playback speed of this device. + * + * This value is expressed as a multiple of the speed the original + * recording was taken at. For example, if the original recording was at 30fps, and + * playback speed is set to 0.5, then the recording will play at 15fps. If playback speed + * is set to 2.0, then the recording would playback at 60fps. + * + * In addition, there are two "special" values. A playback speed of 0.0 indicates that the + * playback should occur as fast as the system is capable of returning frames. This is + * most useful when testing algorithms on large datasets, as it enables playback to be + * done at a much higher rate than would otherwise be possible. + * + * A value of -1 indicates that speed is "manual". In this mode, new frames will only + * become available when an application manually reads them. If used in a polling loop, + * this setting also enables systems to read and process frames limited only by + * available processing speeds. + * + * @returns Current playback speed of the device, measured as ratio of recording speed. + */ + float getSpeed() const + { + if (!isValid()) + { + return 0.0f; + } + float speed; + Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, &speed); + if (rc != STATUS_OK) + { + return 1.0f; + } + return speed; + } + /** + * Setter function for the playback speed of the device. For a full explaination of + * what this value means @see PlaybackControl::getSpeed(). + * + * @param [in] speed Desired new value of playback speed, as ratio of original recording. + * @returns Status code indicating success or failure of this operation. + */ + Status setSpeed(float speed) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, speed); + } + + /** + * Gets the current repeat setting of the file device. + * + * @returns true if repeat is enabled, false if not enabled. + */ + bool getRepeatEnabled() const + { + if (!isValid()) + { + return false; + } + + OniBool repeat; + Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, &repeat); + if (rc != STATUS_OK) + { + return false; + } + + return repeat == TRUE; + } + + /** + * Changes the current repeat mode of the device. If repeat mode is turned on, then the recording will + * begin playback again at the beginning after the last frame is read. If turned off, no more frames + * will become available after last frame is read. + * + * @param [in] repeat New value for repeat -- true to enable, false to disable + * @returns Status code indicating success or failure of this operations. + */ + Status setRepeatEnabled(bool repeat) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + + return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, repeat ? TRUE : FALSE); + } + + /** + * Seeks within a VideoStream to a given FrameID. Note that when this function is called on one + * stream, all other streams will also be changed to the corresponding place in the recording. The FrameIDs + * of different streams may not match, since FrameIDs may differ for streams that are not synchronized, but + * the recording will set all streams to the same moment in time. + * + * @param [in] stream Stream for which the frameIndex value is valid. + * @param [in] frameIndex Frame index to move playback to + * @returns Status code indicating success or failure of this operation + */ + 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); + } + + /** + * Provides the a count of frames that this recording contains for a given stream. This is useful + * both to determine the length of the recording, and to ensure that a valid Frame Index is set when using + * the @ref PlaybackControl::seek() function. + * + * @param [in] stream The video stream to count frames for + * @returns Number of frames in provided @ref VideoStream, or 0 if the stream is not part of the recording + */ + int getNumberOfFrames(const VideoStream& stream) const + { + int numOfFrames = -1; + Status rc = stream.getProperty(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 + Status getProperty(int propertyId, T* value) const + { + if (!isValid()) return STATUS_NOT_SUPPORTED; + + return m_pStream->getProperty(propertyId, value); + } + template + Status setProperty(int propertyId, const T& value) + { + if (!isValid()) return STATUS_NOT_SUPPORTED; + + return m_pStream->setProperty(propertyId, value); + } + + friend class VideoStream; + CameraSettings(VideoStream* pStream) + { + m_pStream = pStream; + } + + VideoStream* m_pStream; +}; + + +/** + * The OpenNI class is a static entry point to the library. It is used by every OpenNI 2.0 + * application to initialize the SDK and drivers to enable creation of valid device objects. + * + * It also defines a listener class and events that enable for event driven notification of + * device connection, device disconnection, and device configuration changes. + * + * In addition, it gives access to SDK version information and provides a function that allows + * you to wait for data to become available on any one of a list of streams (as opposed to + * waiting for data on one specific stream with functions provided by the VideoStream class) + * +*/ +class OpenNI +{ +public: + + /** + * The OpenNI::DeviceConnectedListener class provides a means of registering for, and responding to + * when a device is connected. + * + * onDeviceConnected is called whenever a new device is connected to the system (ie this event + * would be triggered when a new sensor is manually plugged into the host system running the + * application) + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceConnected method. Once you instantiate your class, use the + * OpenNI::addDeviceConnectedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceConnectedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceConnectedListener + { + public: + DeviceConnectedListener() + { + m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback; + m_deviceConnectedCallbacks.deviceDisconnected = NULL; + m_deviceConnectedCallbacks.deviceStateChanged = NULL; + m_deviceConnectedCallbacksHandle = NULL; + } + + virtual ~DeviceConnectedListener() + { + } + + /** + * Callback function for the onDeviceConnected event. This function will be + * called whenever this event occurs. When this happens, a pointer to the @ref DeviceInfo + * object for the newly connected device will be supplied. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + * + * If you wish to open the new device as it is connected, simply query the provided DeviceInfo + * object to obtain the URI of the device, and pass this URI to the Device.Open() function. + */ + 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(pInfo)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceConnectedCallbacks; + OniCallbackHandle m_deviceConnectedCallbacksHandle; + + }; + /** + * The OpenNI::DeviceDisconnectedListener class provides a means of registering for, and responding to + * when a device is disconnected. + * + * onDeviceDisconnected is called when a device is removed from the system. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceDisconnected method. Once you instantiate your class, use the + * OpenNI::addDeviceDisconnectedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceDisconnectedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceDisconnectedListener + { + public: + DeviceDisconnectedListener() + { + m_deviceDisconnectedCallbacks.deviceConnected = NULL; + m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback; + m_deviceDisconnectedCallbacks.deviceStateChanged = NULL; + m_deviceDisconnectedCallbacksHandle = NULL; + } + + virtual ~DeviceDisconnectedListener() + { + } + + /** + * Callback function for the onDeviceDisconnected event. This function will be + * called whenever this event occurs. When this happens, a pointer to the DeviceInfo + * object for the newly disconnected device will be supplied. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + */ + 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(pInfo)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceDisconnectedCallbacks; + OniCallbackHandle m_deviceDisconnectedCallbacksHandle; + }; + /** + * The OpenNI::DeviceStateChangedListener class provides a means of registering for, and responding to + * when a device's state is changed. + * + * onDeviceStateChanged is triggered whenever the state of a connected device is changed. + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceStateChanged method. Once you instantiate your class, use the + * OpenNI::addDeviceStateChangedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceStateChangedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceStateChangedListener + { + public: + DeviceStateChangedListener() + { + m_deviceStateChangedCallbacks.deviceConnected = NULL; + m_deviceStateChangedCallbacks.deviceDisconnected = NULL; + m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback; + m_deviceStateChangedCallbacksHandle = NULL; + } + + virtual ~DeviceStateChangedListener() + { + } + + /** + * Callback function for the onDeviceStateChanged event. This function will be + * called whenever this event occurs. When this happens, a pointer to a DeviceInfo + * object for the affected device will be supplied, as well as the new DeviceState + * value of that device. + */ + 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(pInfo), DeviceState(state)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceStateChangedCallbacks; + OniCallbackHandle m_deviceStateChangedCallbacksHandle; + }; + + /** + Initialize the library. + This will load all available drivers, and see which devices are available + It is forbidden to call any other method in OpenNI before calling @ref initialize(). + */ + static Status initialize() + { + return (Status)oniInitialize(ONI_API_VERSION); // provide version of API, to make sure proper struct sizes are used + } + + /** + Stop using the library. Unload all drivers, close all streams and devices. + Once @ref shutdown was called, no other calls to OpenNI is allowed. + */ + static void shutdown() + { + oniShutdown(); + } + + /** + * Returns the version of OpenNI + */ + 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; + } + + /** + * Retrieves the calling thread's last extended error information. The last extended error information is maintained + * on a per-thread basis. Multiple threads do not overwrite each other's last extended error information. + * + * The extended error information is cleared on every call to an OpenNI method, so you should call this method + * immediately after a call to an OpenNI method which have failed. + */ + static const char* getExtendedError() + { + return oniGetExtendedError(); + } + + /** + Fills up an array of @ref DeviceInfo objects with devices that are available. + @param [in,out] deviceInfoList An array to be filled with devices. + */ + static void enumerateDevices(Array* deviceInfoList) + { + OniDeviceInfo* m_pDeviceInfos; + int m_deviceInfoCount; + oniGetDeviceList(&m_pDeviceInfos, &m_deviceInfoCount); + deviceInfoList->_setData((DeviceInfo*)m_pDeviceInfos, m_deviceInfoCount, true); + oniReleaseDeviceList(m_pDeviceInfos); + } + + /** + Wait for a new frame from any of the streams provided. The function blocks until any of the streams + has a new frame available, or the timeout has passed. + @param [in] pStreams An array of streams to wait for. + @param [in] streamCount The number of streams in @c pStreams + @param [out] pReadyStreamIndex The index of the first stream that has new frame available. + @param [in] timeout [Optional] A timeout before returning if no stream has new data. Default value is @ref TIMEOUT_FOREVER. + */ + 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; + } + + /** + * Add a listener to the list of objects that receive the event when a device is connected. See the + * @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceConnectedListener(DeviceConnectedListener* pListener) + { + if (pListener->m_deviceConnectedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceConnectedCallbacks, pListener, &pListener->m_deviceConnectedCallbacksHandle); + } + /** + * Add a listener to the list of objects that receive the event when a device is disconnected. See the + * @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) + { + if (pListener->m_deviceDisconnectedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceDisconnectedCallbacks, pListener, &pListener->m_deviceDisconnectedCallbacksHandle); + } + /** + * Add a listener to the list of objects that receive the event when a device's state changes. See the + * @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceStateChangedListener(DeviceStateChangedListener* pListener) + { + if (pListener->m_deviceStateChangedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceStateChangedCallbacks, pListener, &pListener->m_deviceStateChangedCallbacksHandle); + } + /** + * Remove a listener from the list of objects that receive the event when a device is connected. See + * the @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceConnectedListener(DeviceConnectedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceConnectedCallbacksHandle); + pListener->m_deviceConnectedCallbacksHandle = NULL; + } + /** + * Remove a listener from the list of objects that receive the event when a device is disconnected. See + * the @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceDisconnectedCallbacksHandle); + pListener->m_deviceDisconnectedCallbacksHandle = NULL; + } + /** + * Remove a listener from the list of objects that receive the event when a device's state changes. See + * the @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceStateChangedListener(DeviceStateChangedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceStateChangedCallbacksHandle); + pListener->m_deviceStateChangedCallbacksHandle = NULL; + } + + /** + * Change the log output folder + + * @param const char * strLogOutputFolder [in] log required folder + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogOutputFolder(const char *strLogOutputFolder) + { + return (Status)oniSetLogOutputFolder(strLogOutputFolder); + } + + /** + * Get current log file name + + * @param char * strFileName [out] returned file name buffer + * @param int nBufferSize [in] Buffer size + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status getLogFileName(char *strFileName, int nBufferSize) + { + return (Status)oniGetLogFileName(strFileName, nBufferSize); + } + + /** + * Set minimum severity for log produce + + * @param const char * strMask [in] Logger name + * @param int nMinSeverity [in] Logger severity + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogMinSeverity(int nMinSeverity) + { + return(Status) oniSetLogMinSeverity(nMinSeverity); + } + + /** + * Configures if log entries will be printed to console. + + * @param const OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogConsoleOutput(bool bConsoleOutput) + { + return (Status)oniSetLogConsoleOutput(bConsoleOutput); + } + + /** + * Configures if log entries will be printed to file. + + * @param const OniBool bConsoleOutput [in] TRUE to print log entries to file, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogFileOutput(bool bFileOutput) + { + return (Status)oniSetLogFileOutput(bFileOutput); + } + + #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM + /** + * Configures if log entries will be printed to the Android log. + + * @param OniBool bAndroidOutput bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + + static Status setLogAndroidOutput(bool bAndroidOutput) + { + return (Status)oniSetLogAndroidOutput(bAndroidOutput); + } + #endif + +private: + OpenNI() + { + } +}; + +/** +The CoordinateConverter class converts points between the different coordinate systems. + +Depth and World coordinate systems + +OpenNI applications commonly use two different coordinate systems to represent depth. These two systems are referred to as Depth +and World representation. + +Depth coordinates are the native data representation. In this system, the frame is a map (two dimensional array), and each pixel is +assigned a depth value. This depth value represents the distance between the camera plane and whatever object is in the given +pixel. The X and Y coordinates are simply the location in the map, where the origin is the top-left corner of the field of view. + +World coordinates superimpose a more familiar 3D Cartesian coordinate system on the world, with the camera lens at the origin. +In this system, every point is specified by 3 points -- x, y and z. The x axis of this system is along a line that passes +through the infrared projector and CMOS imager of the camera. The y axis is parallel to the front face of the camera, and +perpendicular to the x axis (it will also be perpendicular to the ground if the camera is upright and level). The z axis +runs into the scene, perpendicular to both the x and y axis. From the perspective of the camera, an object moving from +left to right is moving along the increasing x axis. An object moving up is moving along the increasing y axis, and an object +moving away from the camera is moving along the increasing z axis. + +Mathematically, the Depth coordinate system is the projection of the scene on the CMOS. If the sensor's angular field of view and +resolution are known, then an angular size can be calculated for each pixel. This is how the conversion algorithms work. The +dependence of this calculation on FoV and resolution is the reason that a @ref VideoStream pointer must be provided to these +functions. The @ref VideoStream pointer is used to determine parameters for the specific points to be converted. + +Since Depth coordinates are a projective, the apparent size of objects in depth coordinates (measured in pixels) +will increase as an object moves closer to the sensor. The size of objects in the World coordinate system is independent of +distance from the sensor. + +Note that converting from Depth to World coordinates is relatively expensive computationally. It is generally not practical to convert +the entire raw depth map to World coordinates. A better approach is to have your computer vision algorithm work in Depth +coordinates for as long as possible, and only converting a few specific points to World coordinates right before output. + +Note that when converting from Depth to World or vice versa, the Z value remains the same. +*/ +class CoordinateConverter +{ +public: + /** + Converts a single point from the World coordinate system to the Depth coordinate system. + @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates + @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0 at far left of image + @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0 at top of image + @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in the @ref PixelFormat of depthStream + */ + 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; + } + + /** + Converts a single point from the World coordinate system to a floating point representation of the Depth coordinate system + @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates + @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0.0 at far left of the image + @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0.0 at the top of the image + @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in millimeters with 0.0 at the camera lens + */ + 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); + } + + /** + Converts a single point from the Depth coordinate system to the World coordinate system. + @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0 at the far left of the image + @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0 at the top of the image + @param [in] depthZ the Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream + @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates + */ + 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); + } + + /** + Converts a single point from a floating point representation of the Depth coordinate system to the World coordinate system. + @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0.0 at the far left of the image + @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0.0 at the top of the image + @param [in] depthZ Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream + @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates + */ + 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); + } + + /** + For a given depth point, provides the coordinates of the corresponding color value. Useful for superimposing the depth and color images. + This operation is the same as turning on registration, but is performed on a single pixel rather than the whole image. + @param [in] depthStream Reference to a openni::VideoStream that produced the depth value + @param [in] colorStream Reference to a openni::VideoStream that we want to find the appropriate color pixel in + @param [in] depthX X value of the depth point, given in Depth coordinates and measured in pixels + @param [in] depthY Y value of the depth point, given in Depth coordinates and measured in pixels + @param [in] depthZ Z(depth) value of the depth point, given in the @ref PixelFormat of depthStream + @param [out] pColorX The X coordinate of the color pixel that overlaps the given depth pixel, measured in pixels + @param [out] pColorY The Y coordinate of the color pixel that overlaps the given depth pixel, measured in pixels + */ + 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); + } +}; + +/** + * The Recorder class is used to record streams to an ONI file. + * + * After a recorder is instantiated, it must be initialized with a specific filename where + * the recording will be stored. The recorder is then attached to one or more streams. Once + * this is complete, the recorder can be told to start recording. The recorder will store + * every frame from every stream to the specified file. Later, this file can be used to + * initialize a file Device, and used to play back the same data that was recorded. + * + * Opening a file device is done by passing its path as the uri to the @ref Device::open() method. + * + * @see PlaybackControl for options available to play a reorded file. + * + */ +class Recorder +{ +public: + /** + * Creates a recorder. The recorder is not valid, i.e. @ref isValid() returns + * false. You must initialize the recorder before use with @ref create(). + */ + Recorder() : m_recorder(NULL) + { + } + + /** + * Destroys a recorder. This will also stop recording. + */ + ~Recorder() + { + destroy(); + } + + /** + * Initializes a recorder. You can initialize the recorder only once. Attempts + * to intialize more than once will result in an error code being returned. + * + * Initialization assigns the recorder to an output file that will be used for + * recording. Before use, the @ref attach() function must also be used to assign input + * data to the Recorder. + * + * @param [in] fileName The name of a file which will contain the recording. + * @returns Status code which indicates success or failure of the operation. + */ + Status create(const char* fileName) + { + if (!isValid()) + { + return (Status)oniCreateRecorder(fileName, &m_recorder); + } + return STATUS_ERROR; + } + + /** + * Verifies if the recorder is valid, i.e. if one can record with this recorder. A + * recorder object is not valid until the @ref create() method is called. + * + * @returns true if the recorder has been intialized, false otherwise. + */ + bool isValid() const + { + return NULL != getHandle(); + } + + /** + * Attaches a stream to the recorder. Note, this won't start recording, you + * should explicitly start it using @ref start() method. As soon as the recording + * process has been started, no more streams can be attached to the recorder. + * + * @param [in] stream The stream to be recorded. + * @param [in] allowLossyCompression [Optional] If this value is true, the recorder might use + * a lossy compression, which means that when the recording will be played-back, there might + * be small differences from the original frame. Default value is false. + */ + Status attach(VideoStream& stream, bool allowLossyCompression = false) + { + if (!isValid() || !stream.isValid()) + { + return STATUS_ERROR; + } + return (Status)oniRecorderAttachStream( + m_recorder, + stream._getHandle(), + allowLossyCompression); + } + + /** + * Starts recording. + * Once this method is called, the recorder will take all subsequent frames from the attached streams + * and store them in the file. + * You may not attach additional streams once recording was started. + */ + Status start() + { + if (!isValid()) + { + return STATUS_ERROR; + } + return (Status)oniRecorderStart(m_recorder); + } + + /** + * Stops recording. You may use @ref start() to resume the recording. + */ + void stop() + { + if (isValid()) + { + oniRecorderStop(m_recorder); + } + } + + /** + Destroys the recorder object. + */ + void destroy() + { + if (isValid()) + { + oniRecorderDestroy(&m_recorder); + } + } + +private: + Recorder(const Recorder&); + Recorder& operator=(const Recorder&); + + /** + * Returns a handle of this 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_ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h new file mode 100644 index 000000000..561f7664a --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h @@ -0,0 +1,632 @@ +/***************************************************************************** +* * +* 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 _PS1080_H_ +#define _PS1080_H_ + +#include + +/** The maximum permitted Xiron device name string length. */ +#define XN_DEVICE_MAX_STRING_LENGTH 200 + +/* + * private properties of PS1080 devices. + * + * @remarks + * properties structure is 0x1080XXYY where XX is range and YY is code. + * range values: + * F0 - device properties + * E0 - device commands + * 00 - common stream properties + * 10 - depth stream properties + * 20 - color stream properties + */ +enum +{ + /*******************************************************************/ + /* Device properties */ + /*******************************************************************/ + + /** unsigned long long (XnSensorUsbInterface) */ + XN_MODULE_PROPERTY_USB_INTERFACE = 0x1080F001, // "UsbInterface" + /** Boolean */ + XN_MODULE_PROPERTY_MIRROR = 0x1080F002, // "Mirror" + /** unsigned long long, get only */ + XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP = 0x1080F004, // "ResetSensorOnStartup" + /** unsigned long long, get only */ + XN_MODULE_PROPERTY_LEAN_INIT = 0x1080F005, // "LeanInit" + /** char[XN_DEVICE_MAX_STRING_LENGTH], get only */ + XN_MODULE_PROPERTY_SERIAL_NUMBER = 0x1080F006, // "ID" + /** XnVersions, get only */ + XN_MODULE_PROPERTY_VERSION = 0x1080F007, // "Version" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_FRAME_SYNC = 0x1080F008, + /** Boolean */ + XN_MODULE_PROPERTY_HOST_TIMESTAMPS = 0x1080FF77, // "HostTimestamps" + /** Boolean */ + XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN = 0x1080FF78, // "CloseStreamsOnShutdown" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_INTERVAL = 0x1080FF7F, // "FirmwareLogInterval" + /** Boolean */ + XN_MODULE_PROPERTY_PRINT_FIRMWARE_LOG = 0x1080FF80, // "FirmwareLogPrint" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_FILTER = 0x1080FF81, // "FirmwareLogFilter" + /** String, get only */ + XN_MODULE_PROPERTY_FIRMWARE_LOG = 0x1080FF82, // "FirmwareLog" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_CPU_INTERVAL = 0x1080FF83, // "FirmwareCPUInterval" + /** String, get only */ + XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME = 0x1080FF7A, // "PhysicalDeviceName" + /** String, get only */ + XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA = 0x1080FF7B, // "VendorSpecificData" + /** String, get only */ + XN_MODULE_PROPERTY_SENSOR_PLATFORM_STRING = 0x1080FF7C, // "SensorPlatformString" + + /*******************************************************************/ + /* Device commands (activated via SetProperty/GetProperty) */ + /*******************************************************************/ + + /** XnInnerParam */ + XN_MODULE_PROPERTY_FIRMWARE_PARAM = 0x1080E001, // "FirmwareParam" + /** unsigned long long, set only */ + XN_MODULE_PROPERTY_RESET = 0x1080E002, // "Reset" + /** XnControlProcessingData */ + XN_MODULE_PROPERTY_IMAGE_CONTROL = 0x1080E003, // "ImageControl" + /** XnControlProcessingData */ + XN_MODULE_PROPERTY_DEPTH_CONTROL = 0x1080E004, // "DepthControl" + /** XnAHBData */ + XN_MODULE_PROPERTY_AHB = 0x1080E005, // "AHB" + /** XnLedState */ + XN_MODULE_PROPERTY_LED_STATE = 0x1080E006, // "LedState" + /** Boolean */ + XN_MODULE_PROPERTY_EMITTER_STATE = 0x1080E007, // "EmitterState" + + /** XnCmosBlankingUnits */ + XN_MODULE_PROPERTY_CMOS_BLANKING_UNITS = 0x1080FF74, // "CmosBlankingUnits" + /** XnCmosBlankingTime */ + XN_MODULE_PROPERTY_CMOS_BLANKING_TIME = 0x1080FF75, // "CmosBlankingTime" + /** XnFlashFileList, get only */ + XN_MODULE_PROPERTY_FILE_LIST = 0x1080FF84, // "FileList" + /** XnParamFlashData, get only */ + XN_MODULE_PROPERTY_FLASH_CHUNK = 0x1080FF85, // "FlashChunk" + XN_MODULE_PROPERTY_FILE = 0x1080FF86, // "FlashFile" + /** Integer */ + XN_MODULE_PROPERTY_DELETE_FILE = 0x1080FF87, // "DeleteFile" + XN_MODULE_PROPERTY_FILE_ATTRIBUTES = 0x1080FF88, // "FileAttributes" + XN_MODULE_PROPERTY_TEC_SET_POINT = 0x1080FF89, // "TecSetPoint" + /** get only */ + XN_MODULE_PROPERTY_TEC_STATUS = 0x1080FF8A, // "TecStatus" + /** get only */ + XN_MODULE_PROPERTY_TEC_FAST_CONVERGENCE_STATUS = 0x1080FF8B, // "TecFastConvergenceStatus" + XN_MODULE_PROPERTY_EMITTER_SET_POINT = 0x1080FF8C, // "EmitterSetPoint" + /** get only */ + XN_MODULE_PROPERTY_EMITTER_STATUS = 0x1080FF8D, // "EmitterStatus" + XN_MODULE_PROPERTY_I2C = 0x1080FF8E, // "I2C" + /** Integer, set only */ + XN_MODULE_PROPERTY_BIST = 0x1080FF8F, // "BIST" + /** XnProjectorFaultData, set only */ + XN_MODULE_PROPERTY_PROJECTOR_FAULT = 0x1080FF90, // "ProjectorFault" + /** Boolean, set only */ + XN_MODULE_PROPERTY_APC_ENABLED = 0x1080FF91, // "APCEnabled" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_TEC_DEBUG_PRINT = 0x1080FF92, // "TecDebugPrint" + + /*******************************************************************/ + /* Common stream properties */ + /*******************************************************************/ + + /** unsigned long long */ + XN_STREAM_PROPERTY_INPUT_FORMAT = 0x10800001, // "InputFormat" + /** unsigned long long (XnCroppingMode) */ + XN_STREAM_PROPERTY_CROPPING_MODE = 0x10800002, // "CroppingMode" + + /*******************************************************************/ + /* Depth stream properties */ + /*******************************************************************/ + + /** unsigned long long */ + XN_STREAM_PROPERTY_CLOSE_RANGE = 0x1080F003, // "CloseRange" + /** XnPixelRegistration - get only */ + XN_STREAM_PROPERTY_PIXEL_REGISTRATION = 0x10801001, // "PixelRegistration" + /** unsigned long long */ + XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED = 0x10801002, // "WhiteBalancedEnabled" + /** unsigned long long */ + XN_STREAM_PROPERTY_GAIN = 0x10801003, // "Gain" + /** unsigned long long */ + XN_STREAM_PROPERTY_HOLE_FILTER = 0x10801004, // "HoleFilter" + /** unsigned long long (XnProcessingType) */ + XN_STREAM_PROPERTY_REGISTRATION_TYPE = 0x10801005, // "RegistrationType" + /** XnDepthAGCBin* */ + XN_STREAM_PROPERTY_AGC_BIN = 0x10801006, // "AGCBin" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_CONST_SHIFT = 0x10801007, // "ConstShift" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR = 0x10801008, // "PixelSizeFactor" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_MAX_SHIFT = 0x10801009, // "MaxShift" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_PARAM_COEFF = 0x1080100A, // "ParamCoeff" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_SHIFT_SCALE = 0x1080100B, // "ShiftScale" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE = 0x1080100C, // "ZPD" + /** double, get only */ + XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE = 0x1080100D, // "ZPPS" + /** double, get only */ + XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE = 0x1080100E, // "LDDIS" + /** double, get only */ + XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE = 0x1080100F, // "DCRCDIS" + /** OniDepthPixel[], get only */ + XN_STREAM_PROPERTY_S2D_TABLE = 0x10801010, // "S2D" + /** unsigned short[], get only */ + XN_STREAM_PROPERTY_D2S_TABLE = 0x10801011, // "D2S" + /** get only */ + XN_STREAM_PROPERTY_DEPTH_SENSOR_CALIBRATION_INFO = 0x10801012, + /** Boolean */ + XN_STREAM_PROPERTY_GMC_MODE = 0x1080FF44, // "GmcMode" + /** Boolean */ + XN_STREAM_PROPERTY_GMC_DEBUG = 0x1080FF45, // "GmcDebug" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION = 0x1080FF46, // "WavelengthCorrection" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION_DEBUG = 0x1080FF47, // "WavelengthCorrectionDebug" + + /*******************************************************************/ + /* Color stream properties */ + /*******************************************************************/ + /** Integer */ + XN_STREAM_PROPERTY_FLICKER = 0x10802001, // "Flicker" +}; + +typedef enum +{ + XN_SENSOR_FW_VER_UNKNOWN = 0, + XN_SENSOR_FW_VER_0_17 = 1, + XN_SENSOR_FW_VER_1_1 = 2, + XN_SENSOR_FW_VER_1_2 = 3, + XN_SENSOR_FW_VER_3_0 = 4, + XN_SENSOR_FW_VER_4_0 = 5, + XN_SENSOR_FW_VER_5_0 = 6, + XN_SENSOR_FW_VER_5_1 = 7, + XN_SENSOR_FW_VER_5_2 = 8, + XN_SENSOR_FW_VER_5_3 = 9, + XN_SENSOR_FW_VER_5_4 = 10, + XN_SENSOR_FW_VER_5_5 = 11, + XN_SENSOR_FW_VER_5_6 = 12, + XN_SENSOR_FW_VER_5_7 = 13, + XN_SENSOR_FW_VER_5_8 = 14, +} XnFWVer; + +typedef enum { + XN_SENSOR_VER_UNKNOWN = 0, + XN_SENSOR_VER_2_0 = 1, + XN_SENSOR_VER_3_0 = 2, + XN_SENSOR_VER_4_0 = 3, + XN_SENSOR_VER_5_0 = 4 +} XnSensorVer; + +typedef enum { + XN_SENSOR_HW_VER_UNKNOWN = 0, + XN_SENSOR_HW_VER_FPDB_10 = 1, + XN_SENSOR_HW_VER_CDB_10 = 2, + XN_SENSOR_HW_VER_RD_3 = 3, + XN_SENSOR_HW_VER_RD_5 = 4, + XN_SENSOR_HW_VER_RD1081 = 5, + XN_SENSOR_HW_VER_RD1082 = 6, + XN_SENSOR_HW_VER_RD109 = 7 +} XnHWVer; + +typedef enum { + XN_SENSOR_CHIP_VER_UNKNOWN = 0, + XN_SENSOR_CHIP_VER_PS1000 = 1, + XN_SENSOR_CHIP_VER_PS1080 = 2, + XN_SENSOR_CHIP_VER_PS1080A6 = 3 +} XnChipVer; + +typedef enum +{ + XN_CMOS_TYPE_IMAGE = 0, + XN_CMOS_TYPE_DEPTH = 1, + + XN_CMOS_COUNT +} XnCMOSType; + +typedef enum +{ + XN_IO_IMAGE_FORMAT_BAYER = 0, + XN_IO_IMAGE_FORMAT_YUV422 = 1, + XN_IO_IMAGE_FORMAT_JPEG = 2, + XN_IO_IMAGE_FORMAT_JPEG_420 = 3, + XN_IO_IMAGE_FORMAT_JPEG_MONO = 4, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 = 5, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER = 6, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUYV = 7, +} XnIOImageFormats; + +typedef enum +{ + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT = 0, + XN_IO_DEPTH_FORMAT_COMPRESSED_PS = 1, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_10_BIT = 2, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT = 3, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT = 4, +} XnIODepthFormats; + +typedef enum +{ + XN_RESET_TYPE_POWER = 0, + XN_RESET_TYPE_SOFT = 1, + XN_RESET_TYPE_SOFT_FIRST = 2, +} XnParamResetType; + +typedef enum XnSensorUsbInterface +{ + XN_SENSOR_USB_INTERFACE_DEFAULT = 0, + XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS = 1, + XN_SENSOR_USB_INTERFACE_BULK_ENDPOINTS = 2, + XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS_LOW_DEPTH = 3, +} XnSensorUsbInterface; + +typedef enum XnProcessingType +{ + XN_PROCESSING_DONT_CARE = 0, + XN_PROCESSING_HARDWARE = 1, + XN_PROCESSING_SOFTWARE = 2, +} XnProcessingType; + +typedef enum XnCroppingMode +{ + XN_CROPPING_MODE_NORMAL = 1, + XN_CROPPING_MODE_INCREASED_FPS = 2, + XN_CROPPING_MODE_SOFTWARE_ONLY = 3, +} XnCroppingMode; + +enum +{ + XN_ERROR_STATE_OK = 0, + XN_ERROR_STATE_DEVICE_PROJECTOR_FAULT = 1, + XN_ERROR_STATE_DEVICE_OVERHEAT = 2, +}; + +typedef enum XnFirmwareCroppingMode +{ + XN_FIRMWARE_CROPPING_MODE_DISABLED = 0, + XN_FIRMWARE_CROPPING_MODE_NORMAL = 1, + XN_FIRMWARE_CROPPING_MODE_INCREASED_FPS = 2, +} XnFirmwareCroppingMode; + +typedef enum +{ + XnLogFilterDebug = 0x0001, + XnLogFilterInfo = 0x0002, + XnLogFilterError = 0x0004, + XnLogFilterProtocol = 0x0008, + XnLogFilterAssert = 0x0010, + XnLogFilterConfig = 0x0020, + XnLogFilterFrameSync = 0x0040, + XnLogFilterAGC = 0x0080, + XnLogFilterTelems = 0x0100, + + XnLogFilterAll = 0xFFFF +} XnLogFilter; + +typedef enum +{ + XnFileAttributeReadOnly = 0x8000 +} XnFilePossibleAttributes; + +typedef enum +{ + XnFlashFileTypeFileTable = 0x00, + XnFlashFileTypeScratchFile = 0x01, + XnFlashFileTypeBootSector = 0x02, + XnFlashFileTypeBootManager = 0x03, + XnFlashFileTypeCodeDownloader = 0x04, + XnFlashFileTypeMonitor = 0x05, + XnFlashFileTypeApplication = 0x06, + XnFlashFileTypeFixedParams = 0x07, + XnFlashFileTypeDescriptors = 0x08, + XnFlashFileTypeDefaultParams = 0x09, + XnFlashFileTypeImageCmos = 0x0A, + XnFlashFileTypeDepthCmos = 0x0B, + XnFlashFileTypeAlgorithmParams = 0x0C, + XnFlashFileTypeReferenceQVGA = 0x0D, + XnFlashFileTypeReferenceVGA = 0x0E, + XnFlashFileTypeMaintenance = 0x0F, + XnFlashFileTypeDebugParams = 0x10, + XnFlashFileTypePrimeProcessor = 0x11, + XnFlashFileTypeGainControl = 0x12, + XnFlashFileTypeRegistartionParams = 0x13, + XnFlashFileTypeIDParams = 0x14, + XnFlashFileTypeSensorTECParams = 0x15, + XnFlashFileTypeSensorAPCParams = 0x16, + XnFlashFileTypeSensorProjectorFaultParams = 0x17, + XnFlashFileTypeProductionFile = 0x18, + XnFlashFileTypeUpgradeInProgress = 0x19, + XnFlashFileTypeWavelengthCorrection = 0x1A, + XnFlashFileTypeGMCReferenceOffset = 0x1B, + XnFlashFileTypeSensorNESAParams = 0x1C, + XnFlashFileTypeSensorFault = 0x1D, + XnFlashFileTypeVendorData = 0x1E, +} XnFlashFileType; + +typedef enum XnBistType +{ + //Auto tests + XN_BIST_IMAGE_CMOS = 1 << 0, + XN_BIST_IR_CMOS = 1 << 1, + XN_BIST_POTENTIOMETER = 1 << 2, + XN_BIST_FLASH = 1 << 3, + XN_BIST_FULL_FLASH = 1 << 4, + XN_BIST_PROJECTOR_TEST_MASK = 1 << 5, + XN_BIST_TEC_TEST_MASK = 1 << 6, + + // Manual tests + XN_BIST_NESA_TEST_MASK = 1 << 7, + XN_BIST_NESA_UNLIMITED_TEST_MASK = 1 << 8, + + // Mask of all the auto tests + XN_BIST_ALL = (0xFFFFFFFF & ~XN_BIST_NESA_TEST_MASK & ~XN_BIST_NESA_UNLIMITED_TEST_MASK), + +} XnBistType; + +typedef enum XnBistError +{ + XN_BIST_RAM_TEST_FAILURE = 1 << 0, + XN_BIST_IR_CMOS_CONTROL_BUS_FAILURE = 1 << 1, + XN_BIST_IR_CMOS_DATA_BUS_FAILURE = 1 << 2, + XN_BIST_IR_CMOS_BAD_VERSION = 1 << 3, + XN_BIST_IR_CMOS_RESET_FAILUE = 1 << 4, + XN_BIST_IR_CMOS_TRIGGER_FAILURE = 1 << 5, + XN_BIST_IR_CMOS_STROBE_FAILURE = 1 << 6, + XN_BIST_COLOR_CMOS_CONTROL_BUS_FAILURE = 1 << 7, + XN_BIST_COLOR_CMOS_DATA_BUS_FAILURE = 1 << 8, + XN_BIST_COLOR_CMOS_BAD_VERSION = 1 << 9, + XN_BIST_COLOR_CMOS_RESET_FAILUE = 1 << 10, + XN_BIST_FLASH_WRITE_LINE_FAILURE = 1 << 11, + XN_BIST_FLASH_TEST_FAILURE = 1 << 12, + XN_BIST_POTENTIOMETER_CONTROL_BUS_FAILURE = 1 << 13, + XN_BIST_POTENTIOMETER_FAILURE = 1 << 14, + XN_BIST_AUDIO_TEST_FAILURE = 1 << 15, + XN_BIST_PROJECTOR_TEST_LD_FAIL = 1 << 16, + XN_BIST_PROJECTOR_TEST_LD_FAILSAFE_TRIG_FAIL = 1 << 17, + XN_BIST_PROJECTOR_TEST_FAILSAFE_HIGH_FAIL = 1 << 18, + XN_BIST_PROJECTOR_TEST_FAILSAFE_LOW_FAIL = 1 << 19, + XN_TEC_TEST_HEATER_CROSSED = 1 << 20, + XN_TEC_TEST_HEATER_DISCONNETED = 1 << 21, + XN_TEC_TEST_TEC_CROSSED = 1 << 22, + XN_TEC_TEST_TEC_FAULT = 1 << 23, +} XnBistError; + +typedef enum XnDepthCMOSType +{ + XN_DEPTH_CMOS_NONE = 0, + XN_DEPTH_CMOS_MT9M001 = 1, + XN_DEPTH_CMOS_AR130 = 2, +} XnDepthCMOSType; + +typedef enum XnImageCMOSType +{ + XN_IMAGE_CMOS_NONE = 0, + XN_IMAGE_CMOS_MT9M112 = 1, + XN_IMAGE_CMOS_MT9D131 = 2, + XN_IMAGE_CMOS_MT9M114 = 3, +} XnImageCMOSType; + +#define XN_IO_MAX_I2C_BUFFER_SIZE 10 +#define XN_MAX_LOG_SIZE (6*1024) + +#pragma pack (push, 1) + +typedef struct XnSDKVersion +{ + unsigned char nMajor; + unsigned char nMinor; + unsigned char nMaintenance; + unsigned short nBuild; +} XnSDKVersion; + +typedef struct { + unsigned char nMajor; + unsigned char nMinor; + unsigned short nBuild; + unsigned int nChip; + unsigned short nFPGA; + unsigned short nSystemVersion; + + XnSDKVersion SDK; + + XnHWVer HWVer; + XnFWVer FWVer; + XnSensorVer SensorVer; + XnChipVer ChipVer; +} XnVersions; + +typedef struct +{ + unsigned short nParam; + unsigned short nValue; +} XnInnerParamData; + +typedef struct XnDepthAGCBin +{ + unsigned short nBin; + unsigned short nMin; + unsigned short nMax; +} XnDepthAGCBin; + +typedef struct XnControlProcessingData +{ + unsigned short nRegister; + unsigned short nValue; +} XnControlProcessingData; + +typedef struct XnAHBData +{ + unsigned int nRegister; + unsigned int nValue; + unsigned int nMask; +} XnAHBData; + +typedef struct XnPixelRegistration +{ + unsigned int nDepthX; + unsigned int nDepthY; + uint16_t nDepthValue; + unsigned int nImageXRes; + unsigned int nImageYRes; + unsigned int nImageX; // out + unsigned int nImageY; // out +} XnPixelRegistration; + +typedef struct XnLedState +{ + uint16_t nLedID; + uint16_t nState; +} XnLedState; + +typedef struct XnCmosBlankingTime +{ + XnCMOSType nCmosID; + float nTimeInMilliseconds; + uint16_t nNumberOfFrames; +} XnCmosBlankingTime; + +typedef struct XnCmosBlankingUnits +{ + XnCMOSType nCmosID; + uint16_t nUnits; + uint16_t nNumberOfFrames; +} XnCmosBlankingUnits; + +typedef struct XnI2CWriteData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nWriteSize; +} XnI2CWriteData; + +typedef struct XnI2CReadData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpReadBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nReadSize; + uint16_t nWriteSize; +} XnI2CReadData; + +typedef struct XnTecData +{ + uint16_t m_SetPointVoltage; + uint16_t m_CompensationVoltage; + uint16_t m_TecDutyCycle; //duty cycle on heater/cooler + uint16_t m_HeatMode; //TRUE - heat, FALSE - cool + int32_t m_ProportionalError; + int32_t m_IntegralError; + int32_t m_DerivativeError; + uint16_t m_ScanMode; //0 - crude, 1 - precise +} XnTecData; + +typedef struct XnTecFastConvergenceData +{ + int16_t m_SetPointTemperature; // set point temperature in celsius, + // scaled by factor of 100 (extra precision) + int16_t m_MeasuredTemperature; // measured temperature in celsius, + // scaled by factor of 100 (extra precision) + int32_t m_ProportionalError; // proportional error in system clocks + int32_t m_IntegralError; // integral error in system clocks + int32_t m_DerivativeError; // derivative error in system clocks + uint16_t m_ScanMode; // 0 - initial, 1 - crude, 2 - precise + uint16_t m_HeatMode; // 0 - idle, 1 - heat, 2 - cool + uint16_t m_TecDutyCycle; // duty cycle on heater/cooler in percents + uint16_t m_TemperatureRange; // 0 - cool, 1 - room, 2 - warm +} XnTecFastConvergenceData; + +typedef struct XnEmitterData +{ + uint16_t m_State; //idle, calibrating + uint16_t m_SetPointVoltage; //this is what should be written to the XML + uint16_t m_SetPointClocks; //target cross duty cycle + uint16_t m_PD_Reading; //current cross duty cycle in system clocks(high time) + uint16_t m_EmitterSet; //duty cycle on emitter set in system clocks (high time). + uint16_t m_EmitterSettingLogic; //TRUE = positive logic, FALSE = negative logic + uint16_t m_LightMeasureLogic; //TRUE - positive logic, FALSE - negative logic + uint16_t m_IsAPCEnabled; + uint16_t m_EmitterSetStepSize; // in MilliVolts + uint16_t m_ApcTolerance; // in system clocks (only valid up till v5.2) + uint16_t m_SubClocking; //in system clocks (only valid from v5.3) + uint16_t m_Precision; // (only valid from v5.3) +} XnEmitterData; + +typedef struct +{ + uint16_t nId; + uint16_t nAttribs; +} XnFileAttributes; + +typedef struct +{ + uint32_t nOffset; + const char* strFileName; + uint16_t nAttributes; +} XnParamFileData; + +typedef struct +{ + uint32_t nOffset; + uint32_t nSize; + unsigned char* pData; +} XnParamFlashData; + +typedef struct { + uint16_t nId; + uint16_t nType; + uint32_t nVersion; + uint32_t nOffset; + uint32_t nSize; + uint16_t nCrc; + uint16_t nAttributes; + uint16_t nReserve; +} XnFlashFile; + +typedef struct +{ + XnFlashFile* pFiles; + uint16_t nFiles; +} XnFlashFileList; + +typedef struct XnProjectorFaultData +{ + uint16_t nMinThreshold; + uint16_t nMaxThreshold; + int32_t bProjectorFaultEvent; +} XnProjectorFaultData; + +typedef struct XnBist +{ + uint32_t nTestsMask; + uint32_t nFailures; +} XnBist; + +#pragma pack (pop) + +#endif //_PS1080_H_ \ No newline at end of file diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h new file mode 100644 index 000000000..dd4d8992a --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h @@ -0,0 +1,199 @@ +#ifndef __XN_PRIME_CLIENT_PROPS_H__ +#define __XN_PRIME_CLIENT_PROPS_H__ + +#include + +enum +{ + /**** Device properties ****/ + + /* XnDetailedVersion, get only */ + LINK_PROP_FW_VERSION = 0x12000001, // "FWVersion" + /* Int, get only */ + LINK_PROP_VERSIONS_INFO_COUNT = 0x12000002, // "VersionsInfoCount" + /* General - array - XnComponentVersion * count elements, get only */ + LINK_PROP_VERSIONS_INFO = 0x12000003, // "VersionsInfo" + /* Int - 0 means off, 1 means on. */ + LINK_PROP_EMITTER_ACTIVE = 0x12000008, // "EmitterActive" + /* String. Set only */ + LINK_PROP_PRESET_FILE = 0x1200000a, // "PresetFile" + /* Get only */ + LINK_PROP_BOOT_STATUS = 0x1200000b, + + /**** Device commands ****/ + /* XnCommandGetFwStreams */ + LINK_COMMAND_GET_FW_STREAM_LIST = 0x1200F001, + /* XnCommandCreateStream */ + LINK_COMMAND_CREATE_FW_STREAM = 0x1200F002, + /* XnCommandDestroyStream */ + LINK_COMMAND_DESTROY_FW_STREAM = 0x1200F003, + /* XnCommandStartStream */ + LINK_COMMAND_START_FW_STREAM = 0x1200F004, + /* XnCommandStopStream */ + LINK_COMMAND_STOP_FW_STREAM = 0x1200F005, + /* XnCommandGetFwStreamVideoModeList */ + LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE_LIST = 0x1200F006, + /* XnCommandSetFwStreamVideoMode */ + LINK_COMMAND_SET_FW_STREAM_VIDEO_MODE = 0x1200F007, + /* XnCommandGetFwStreamVideoMode */ + LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE = 0x1200F008, + + /**** Stream properties ****/ + /* Int. 1 - Shifts 9.3, 2 - Grayscale16, 3 - YUV422, 4 - Bayer8 */ + LINK_PROP_PIXEL_FORMAT = 0x12001001, // "PixelFormat" + /* Int. 0 - None, 1 - 8z, 2 - 16z, 3 - 24z, 4 - 6-bit, 5 - 10-bit, 6 - 11-bit, 7 - 12-bit */ + LINK_PROP_COMPRESSION = 0x12001002, // "Compression" + + /**** Depth Stream properties ****/ + /* Real, get only */ + LINK_PROP_DEPTH_SCALE = 0x1200000b, // "DepthScale" + /* Int, get only */ + LINK_PROP_MAX_SHIFT = 0x12002001, // "MaxShift" + /* Int, get only */ + LINK_PROP_ZERO_PLANE_DISTANCE = 0x12002002, // "ZPD" + /* Int, get only */ + LINK_PROP_CONST_SHIFT = 0x12002003, // "ConstShift" + /* Int, get only */ + LINK_PROP_PARAM_COEFF = 0x12002004, // "ParamCoeff" + /* Int, get only */ + LINK_PROP_SHIFT_SCALE = 0x12002005, // "ShiftScale" + /* Real, get only */ + LINK_PROP_ZERO_PLANE_PIXEL_SIZE = 0x12002006, // "ZPPS" + /* Real, get only */ + LINK_PROP_ZERO_PLANE_OUTPUT_PIXEL_SIZE = 0x12002007, // "ZPOPS" + /* Real, get only */ + LINK_PROP_EMITTER_DEPTH_CMOS_DISTANCE = 0x12002008, // "LDDIS" + /* General - array - MaxShift * XnDepthPixel elements, get only */ + LINK_PROP_SHIFT_TO_DEPTH_TABLE = 0x12002009, // "S2D" + /* General - array - MaxDepth * uint16_t elements, get only */ + LINK_PROP_DEPTH_TO_SHIFT_TABLE = 0x1200200a, // "D2S" +}; + +typedef enum XnFileZone +{ + XN_ZONE_FACTORY = 0x0000, + XN_ZONE_UPDATE = 0x0001, +} XnFileZone; + +typedef enum XnBootErrorCode +{ + XN_BOOT_OK = 0x0000, + XN_BOOT_BAD_CRC = 0x0001, + XN_BOOT_UPLOAD_IN_PROGRESS = 0x0002, + XN_BOOT_FW_LOAD_FAILED = 0x0003, +} XnBootErrorCode; + +typedef enum XnFwStreamType +{ + XN_FW_STREAM_TYPE_COLOR = 0x0001, + XN_FW_STREAM_TYPE_IR = 0x0002, + XN_FW_STREAM_TYPE_SHIFTS = 0x0003, + XN_FW_STREAM_TYPE_AUDIO = 0x0004, + XN_FW_STREAM_TYPE_DY = 0x0005, + XN_FW_STREAM_TYPE_LOG = 0x0008, +} XnFwStreamType; + +typedef enum XnFwPixelFormat +{ + XN_FW_PIXEL_FORMAT_NONE = 0x0000, + XN_FW_PIXEL_FORMAT_SHIFTS_9_3 = 0x0001, + XN_FW_PIXEL_FORMAT_GRAYSCALE16 = 0x0002, + XN_FW_PIXEL_FORMAT_YUV422 = 0x0003, + XN_FW_PIXEL_FORMAT_BAYER8 = 0x0004, +} XnFwPixelFormat; + +typedef enum XnFwCompressionType +{ + XN_FW_COMPRESSION_NONE = 0x0000, + XN_FW_COMPRESSION_8Z = 0x0001, + XN_FW_COMPRESSION_16Z = 0x0002, + XN_FW_COMPRESSION_24Z = 0x0003, + XN_FW_COMPRESSION_6_BIT_PACKED = 0x0004, + XN_FW_COMPRESSION_10_BIT_PACKED = 0x0005, + XN_FW_COMPRESSION_11_BIT_PACKED = 0x0006, + XN_FW_COMPRESSION_12_BIT_PACKED = 0x0007, +} XnFwCompressionType; + +#pragma pack (push, 1) + +#define XN_MAX_VERSION_MODIFIER_LENGTH 16 +typedef struct XnDetailedVersion +{ + uint8_t m_nMajor; + uint8_t m_nMinor; + uint16_t m_nMaintenance; + uint32_t m_nBuild; + char m_strModifier[XN_MAX_VERSION_MODIFIER_LENGTH]; +} XnDetailedVersion; + +typedef struct XnBootStatus +{ + XnFileZone zone; + XnBootErrorCode errorCode; +} XnBootStatus; + +typedef struct XnFwStreamInfo +{ + XnFwStreamType type; + char creationInfo[80]; +} XnFwStreamInfo; + +typedef struct XnFwStreamVideoMode +{ + uint32_t m_nXRes; + uint32_t m_nYRes; + uint32_t m_nFPS; + XnFwPixelFormat m_nPixelFormat; + XnFwCompressionType m_nCompression; +} XnFwStreamVideoMode; + +typedef struct XnCommandGetFwStreamList +{ + uint32_t count; // in: number of allocated elements in streams array. out: number of written elements in the array + XnFwStreamInfo* streams; +} XnCommandGetFwStreamList; + +typedef struct XnCommandCreateStream +{ + XnFwStreamType type; + const char* creationInfo; + uint32_t id; // out +} XnCommandCreateStream; + +typedef struct XnCommandDestroyStream +{ + uint32_t id; +} XnCommandDestroyStream; + +typedef struct XnCommandStartStream +{ + uint32_t id; +} XnCommandStartStream; + +typedef struct XnCommandStopStream +{ + uint32_t id; +} XnCommandStopStream; + +typedef struct XnCommandGetFwStreamVideoModeList +{ + int streamId; + uint32_t count; // in: number of allocated elements in videoModes array. out: number of written elements in the array + XnFwStreamVideoMode* videoModes; +} XnCommandGetFwStreamVideoModeList; + +typedef struct XnCommandSetFwStreamVideoMode +{ + int streamId; + XnFwStreamVideoMode videoMode; +} XnCommandSetFwStreamVideoMode; + +typedef struct XnCommandGetFwStreamVideoMode +{ + int streamId; + XnFwStreamVideoMode videoMode; // out +} XnCommandGetFwStreamVideoMode; + +#pragma pack (pop) + +#endif //__XN_PRIME_CLIENT_PROPS_H__ diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h new file mode 100644 index 000000000..1517bddb3 --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h @@ -0,0 +1,229 @@ +/***************************************************************************** +* * +* 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 _PRIME_SENSE_H_ +#define _PRIME_SENSE_H_ + +#include + +/** +* Additional properties for PrimeSense devices +* +* @remarks +* properties structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* 00 - common stream properties +* 10 - depth stream properties +* E0 - device commands +* F0 - device properties +*/ +enum +{ + // Stream Properties + PS_PROPERTY_DUMP_DATA = 0x1d270001, // boolean + + // Device Properties + PS_PROPERTY_USB_INTERFACE = 0x1d27F001, // values from XnUsbInterfaceType +}; + +/** +* Additional commands for PrimeSense devices +* +* @remarks +* Commands structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* E0 - device commands +*/ +enum +{ + // Device Commands - use via invoke() + PS_COMMAND_AHB_READ = 0x1d27E001, // XnCommandAHB + PS_COMMAND_AHB_WRITE = 0x1d27E002, // XnCommandAHB + PS_COMMAND_I2C_READ = 0x1d27E003, // XnCommandI2C + PS_COMMAND_I2C_WRITE = 0x1d27E004, // XnCommandI2C + PS_COMMAND_SOFT_RESET = 0x1d27E005, // no arguments + PS_COMMAND_POWER_RESET = 0x1d27E006, // no arguments + PS_COMMAND_BEGIN_FIRMWARE_UPDATE = 0x1d27E007, // no arguments + PS_COMMAND_END_FIRMWARE_UPDATE = 0x1d27E008, // no arguments + PS_COMMAND_UPLOAD_FILE = 0x1d27E009, // XnCommandUploadFile + PS_COMMAND_DOWNLOAD_FILE = 0x1d27E00A, // XnCommandDownloadFile + PS_COMMAND_GET_FILE_LIST = 0x1d27E00B, // an array of XnFileEntry + PS_COMMAND_FORMAT_ZONE = 0x1d27E00C, // XnCommandFormatZone + PS_COMMAND_DUMP_ENDPOINT = 0x1d27E00D, // XnCommandDumpEndpoint + PS_COMMAND_GET_I2C_DEVICE_LIST = 0x1d27E00E, // XnCommandGetI2CDevices + PS_COMMAND_GET_BIST_LIST = 0x1d27E00F, // XnCommandGetBistList + PS_COMMAND_EXECUTE_BIST = 0x1d27E010, // XnCommandExecuteBist + PS_COMMAND_USB_TEST = 0x1d27E011, // XnCommandUsbTest + PS_COMMAND_GET_LOG_MASK_LIST = 0x1d27E012, // XnCommandGetLogMaskList + PS_COMMAND_SET_LOG_MASK_STATE = 0x1d27E013, // XnCommandSetLogMaskState + PS_COMMAND_START_LOG = 0x1d27E014, // no arguments + PS_COMMAND_STOP_LOG = 0x1d27E015, // no arguments +}; + +typedef enum XnUsbInterfaceType +{ + PS_USB_INTERFACE_DONT_CARE = 0, + PS_USB_INTERFACE_ISO_ENDPOINTS = 1, + PS_USB_INTERFACE_BULK_ENDPOINTS = 2, +} XnUsbInterfaceType; + +#pragma pack (push, 1) + +// Data Types +typedef struct XnFwFileVersion +{ + uint8_t major; + uint8_t minor; + uint8_t maintenance; + uint8_t build; +} XnFwFileVersion; + +typedef enum XnFwFileFlags +{ + XN_FILE_FLAG_BAD_CRC = 0x0001, +} XnFwFileFlags; + +typedef struct XnFwFileEntry +{ + char name[32]; + XnFwFileVersion version; + uint32_t address; + uint32_t size; + uint16_t crc; + uint16_t zone; + XnFwFileFlags flags; // bitmap +} XnFwFileEntry; + +typedef struct XnI2CDeviceInfo +{ + uint32_t id; + char name[32]; +} XnI2CDeviceInfo; + +typedef struct XnBistInfo +{ + uint32_t id; + char name[32]; +} XnBistInfo; + +typedef struct XnFwLogMask +{ + uint32_t id; + char name[32]; +} XnFwLogMask; + +typedef struct XnUsbTestEndpointResult +{ + double averageBytesPerSecond; + uint32_t lostPackets; +} XnUsbTestEndpointResult; + +// Commands + +typedef struct XnCommandAHB +{ + uint32_t address; // Address of this register + uint32_t offsetInBits; // Offset of the field in bits within address + uint32_t widthInBits; // Width of the field in bits + uint32_t value; // For read requests, this is where the actual value will be filled. For write requests, the value to write. +} XnCommandAHB; + +typedef struct XnCommandI2C +{ + uint32_t deviceID; // Device to communicate with + uint32_t addressSize; // Size of the address, in bytes (1-4) + uint32_t address; // Address + uint32_t valueSize; // Size of the value, in bytes (1-4) + uint32_t mask; // For write request - a mask to be applied to the value. For read requests - ignored. + uint32_t value; // For write request - the value to be written. For read requests - the place where the actual value is written to +} XnCommandI2C; + +typedef struct XnCommandUploadFile +{ + const char* filePath; + uint32_t uploadToFactory; +} XnCommandUploadFile; + +typedef struct XnCommandDownloadFile +{ + uint16_t zone; + const char* firmwareFileName; + const char* targetPath; +} XnCommandDownloadFile; + +typedef struct XnCommandGetFileList +{ + uint32_t count; // in: number of allocated elements in files array. out: number of written elements in the array + XnFwFileEntry* files; +} XnCommandGetFileList; + +typedef struct XnCommandFormatZone +{ + uint8_t zone; +} XnCommandFormatZone; + +typedef struct XnCommandDumpEndpoint +{ + uint8_t endpoint; + bool enabled; +} XnCommandDumpEndpoint; + +typedef struct XnCommandGetI2CDeviceList +{ + uint32_t count; // in: number of allocated elements in devices array. out: number of written elements in the array + XnI2CDeviceInfo* devices; +} XnCommandGetI2CDeviceList; + +typedef struct XnCommandGetBistList +{ + uint32_t count; // in: number of allocated elements in tests array. out: number of written elements in the array + XnBistInfo* tests; +} XnCommandGetBistList; + +typedef struct XnCommandExecuteBist +{ + uint32_t id; + uint32_t errorCode; + uint32_t extraDataSize; // in: number of allocated bytes in extraData. out: number of written bytes in extraData + uint8_t* extraData; +} XnCommandExecuteBist; + +typedef struct XnCommandUsbTest +{ + uint32_t seconds; + uint32_t endpointCount; // in: number of allocated bytes in endpoints array. out: number of written bytes in array + XnUsbTestEndpointResult* endpoints; +} XnCommandUsbTest; + +typedef struct XnCommandGetLogMaskList +{ + uint32_t count; // in: number of allocated elements in masks array. out: number of written elements in the array + XnFwLogMask* masks; +} XnCommandGetLogMaskList; + +typedef struct XnCommandSetLogMaskState +{ + uint32_t mask; + bool enabled; +} XnCommandSetLogMaskState; + +#pragma pack (pop) + +#endif //_PRIME_SENSE_H_ \ No newline at end of file diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h new file mode 100644 index 000000000..23bd81dbb --- /dev/null +++ b/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h @@ -0,0 +1,139 @@ +/***************************************************************************** +* * +* 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 _ONI_PLATFORM_WIN32_H_ +#define _ONI_PLATFORM_WIN32_H_ + +//--------------------------------------------------------------------------- +// Prerequisites +//--------------------------------------------------------------------------- +#ifndef WINVER // Allow use of features specific to Windows XP or later + #define WINVER 0x0501 +#endif +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later + #define _WIN32_WINNT 0x0501 +#endif +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later + #define _WIN32_WINDOWS 0x0410 +#endif +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later + #define _WIN32_IE 0x0600 +#endif +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Undeprecate CRT functions +#ifndef _CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h... +typedef signed char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef __int64 int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#define ONI_PLATFORM ONI_PLATFORM_WIN32 +#define ONI_PLATFORM_STRING "Win32" + +//--------------------------------------------------------------------------- +// Platform Capabilities +//--------------------------------------------------------------------------- +#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN + +#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 + +//--------------------------------------------------------------------------- +// Memory +//--------------------------------------------------------------------------- +/** The default memory alignment. */ +#define ONI_DEFAULT_MEM_ALIGN 16 + +/** The thread static declarator (using TLS). */ +#define ONI_THREAD_STATIC __declspec(thread) + +//--------------------------------------------------------------------------- +// Files +//--------------------------------------------------------------------------- +/** The maximum allowed file path size (in bytes). */ +#define ONI_FILE_MAX_PATH MAX_PATH + +//--------------------------------------------------------------------------- +// Call backs +//--------------------------------------------------------------------------- +/** The std call type. */ +#define ONI_STDCALL __stdcall + +/** The call back calling convention. */ +#define ONI_CALLBACK_TYPE ONI_STDCALL + +/** The C and C++ calling convension. */ +#define ONI_C_DECL __cdecl + +//--------------------------------------------------------------------------- +// Macros +//--------------------------------------------------------------------------- +/** Returns the date and time at compile time. */ +#define ONI_TIMESTAMP __DATE__ " " __TIME__ + +/** Converts n into a pre-processor string. */ +#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) +#define ONI_STRINGIFY_HELPER(n) #n + +//--------------------------------------------------------------------------- +// API Export/Import Macros +//--------------------------------------------------------------------------- +/** Indicates an exported shared library function. */ +#define ONI_API_EXPORT __declspec(dllexport) + +/** Indicates an imported shared library function. */ +#define ONI_API_IMPORT __declspec(dllimport) + +/** Indicates a deprecated function */ +#if _MSC_VER < 1400 // Before VS2005 there was no support for declspec deprecated... + #define ONI_API_DEPRECATED(msg) +#else + #define ONI_API_DEPRECATED(msg) __declspec(deprecated(msg)) +#endif + +#endif //_ONI_PLATFORM_WIN32_H_ diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp new file mode 100644 index 000000000..6ac7444d5 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -0,0 +1,84 @@ +#include +#include "ColorStream.hpp" + +using namespace FreenectDriver; + + +ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) +{ + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30); + setVideoMode(video_mode); + pDevice->startVideo(); +} + +// Add video modes here as you implement them +ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() +{ + FreenectVideoModeMap modes; + // pixelFormat, resolutionX, resolutionY, fps freenect_video_format, freenect_resolution + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30)] = std::pair(FREENECT_VIDEO_RGB, FREENECT_RESOLUTION_MEDIUM); + + + return modes; + + /* working format possiblities + FREENECT_VIDEO_RGB + FREENECT_VIDEO_YUV_RGB + FREENECT_VIDEO_YUV_RAW + */ +} + +OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) +{ + FreenectVideoModeMap supported_video_modes = getSupportedVideoModes(); + FreenectVideoModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); + if (matched_mode_iter == supported_video_modes.end()) + return ONI_STATUS_NOT_SUPPORTED; + + freenect_video_format format = matched_mode_iter->second.first; + freenect_resolution resolution = matched_mode_iter->second.second; + + try { device->setVideoFormat(format, resolution); } + catch (std::runtime_error e) + { + LogError("Format " + to_string(format) + " and resolution " + to_string(resolution) + " combination not supported by libfreenect"); + return ONI_STATUS_NOT_SUPPORTED; + } + video_mode = requested_mode; + return ONI_STATUS_OK; +} + +void ColorStream::populateFrame(void* data, OniFrame* frame) const +{ + frame->sensorType = sensor_type; + frame->stride = video_mode.resolutionX * 3; + frame->cropOriginX = 0; + frame->cropOriginY = 0; + frame->croppingEnabled = false; + + // copy stream buffer from freenect + switch (video_mode.pixelFormat) + { + default: + LogError("Pixel format " + to_string(video_mode.pixelFormat) + " not supported by populateFrame()"); + return; + + case ONI_PIXEL_FORMAT_RGB888: + uint8_t* source = static_cast(data); + uint8_t* target = static_cast(frame->data); + std::copy(source, source + frame->dataSize, target); + return; + } +} + +/* color video modes reference + +FREENECT_VIDEO_RGB = 0, //< Decompressed RGB mode (demosaicing done by libfreenect) +FREENECT_VIDEO_BAYER = 1, //< Bayer compressed mode (raw information from camera) +FREENECT_VIDEO_YUV_RGB = 5, //< YUV RGB mode +FREENECT_VIDEO_YUV_RAW = 6, //< YUV Raw mode + +ONI_PIXEL_FORMAT_RGB888 = 200, +ONI_PIXEL_FORMAT_YUV422 = 201, +ONI_PIXEL_FORMAT_JPEG = 204, +*/ diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp new file mode 100644 index 000000000..daf38becf --- /dev/null +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -0,0 +1,156 @@ +#pragma once + +#include // for transform() +#include // for M_PI +#include "libfreenect.hpp" +#include "Driver/OniDriverAPI.h" +#include "VideoStream.hpp" + + +namespace FreenectDriver +{ + class ColorStream : public VideoStream + { + public: + // from NUI library & converted to radians + static const float DIAGONAL_FOV = 73.9 * (M_PI / 180); + static const float HORIZONTAL_FOV = 62 * (M_PI / 180); + static const float VERTICAL_FOV = 48.6 * (M_PI / 180); + + private: + typedef std::map< OniVideoMode, std::pair > FreenectVideoModeMap; + static const OniSensorType sensor_type = ONI_SENSOR_COLOR; + + static FreenectVideoModeMap getSupportedVideoModes(); + OniStatus setVideoMode(OniVideoMode requested_mode); + void populateFrame(void* data, OniFrame* frame) const; + + bool auto_white_balance; + bool auto_exposure; + + public: + ColorStream(Freenect::FreenectDevice* pDevice); + //~ColorStream() { } + + static OniSensorInfo getSensorInfo() + { + FreenectVideoModeMap supported_modes = getSupportedVideoModes(); + OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; + std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); + OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; + return sensors; + } + + // from StreamBase + OniBool isPropertySupported(int propertyId) + { + switch(propertyId) + { + default: + return VideoStream::isPropertySupported(propertyId); + + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: + case ONI_STREAM_PROPERTY_VERTICAL_FOV: + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: + return true; + } + } + + OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { + default: + return VideoStream::getProperty(propertyId, data, pDataSize); + + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) + { + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_HORIZONTAL_FOV"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = HORIZONTAL_FOV; + return ONI_STATUS_OK; + } + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) + { + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VERTICAL_FOV"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = VERTICAL_FOV; + return ONI_STATUS_OK; + } + + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + { + if (*pDataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = auto_white_balance; + return ONI_STATUS_OK; + } + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + { + if (*pDataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_EXPOSURE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = auto_exposure; + return ONI_STATUS_OK; + } + } + } + + OniStatus setProperty(int propertyId, const void* data, int dataSize) + { + switch (propertyId) + { + default: + return VideoStream::setProperty(propertyId, data, dataSize); + + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + { + if (dataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE"); + return ONI_STATUS_ERROR; + } + auto_white_balance = *(static_cast(data)); + int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_white_balance); + return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + { + if (dataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_EXPOSURE"); + return ONI_STATUS_ERROR; + } + auto_exposure = *(static_cast(data)); + int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_exposure); + return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } + case ONI_STREAM_PROPERTY_MIRRORING: // OniBool + { + if (dataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING"); + return ONI_STATUS_ERROR; + } + mirroring = *(static_cast(data)); + int ret = device->setFlag(FREENECT_MIRROR_VIDEO, mirroring); + return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } + } + } + }; +} diff --git a/OpenNI2-FreenectDriver/src/D2S.h b/OpenNI2-FreenectDriver/src/D2S.h new file mode 100644 index 000000000..636d7bfa4 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/D2S.h @@ -0,0 +1,1003 @@ +const unsigned short D2S[] = { +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 3, 7, 10, 13, 17, +20, 23, 27, 30, 33, 36, 40, 43, 46, 49, +52, 55, 59, 62, 65, 68, 71, 74, 77, 80, +83, 86, 88, 91, 94, 97, 100, 103, 106, 108, +111, 114, 117, 119, 122, 125, 128, 130, 133, 136, +138, 141, 143, 146, 149, 151, 154, 156, 159, 161, +164, 166, 169, 171, 174, 176, 178, 181, 183, 186, +188, 190, 193, 195, 197, 200, 202, 204, 206, 209, +211, 213, 215, 218, 220, 222, 224, 226, 229, 231, +233, 235, 237, 239, 241, 243, 245, 247, 249, 252, +254, 256, 258, 260, 262, 264, 266, 267, 269, 271, +273, 275, 277, 279, 281, 283, 285, 287, 288, 290, +292, 294, 296, 298, 299, 301, 303, 305, 307, 308, +310, 312, 314, 315, 317, 319, 321, 322, 324, 326, +327, 329, 331, 332, 334, 336, 337, 339, 341, 342, +344, 345, 347, 349, 350, 352, 353, 355, 357, 358, +360, 361, 363, 364, 366, 367, 369, 370, 372, 373, +375, 376, 378, 379, 381, 382, 383, 385, 386, 388, +389, 391, 392, 393, 395, 396, 398, 399, 400, 402, +403, 404, 406, 407, 409, 410, 411, 413, 414, 415, +416, 418, 419, 420, 422, 423, 424, 426, 427, 428, +429, 431, 432, 433, 434, 436, 437, 438, 439, 441, +442, 443, 444, 445, 447, 448, 449, 450, 451, 452, +454, 455, 456, 457, 458, 459, 461, 462, 463, 464, +465, 466, 467, 468, 470, 471, 472, 473, 474, 475, +476, 477, 478, 479, 480, 482, 483, 484, 485, 486, +487, 488, 489, 490, 491, 492, 493, 494, 495, 496, +497, 498, 499, 500, 501, 502, 503, 504, 505, 506, +507, 508, 509, 510, 511, 512, 513, 514, 515, 516, +517, 518, 519, 520, 521, 521, 522, 523, 524, 525, +526, 527, 528, 529, 530, 531, 532, 532, 533, 534, +535, 536, 537, 538, 539, 540, 540, 541, 542, 543, +544, 545, 546, 546, 547, 548, 549, 550, 551, 551, +552, 553, 554, 555, 556, 556, 557, 558, 559, 560, +561, 561, 562, 563, 564, 565, 565, 566, 567, 568, +568, 569, 570, 571, 572, 572, 573, 574, 575, 575, +576, 577, 578, 578, 579, 580, 581, 581, 582, 583, +584, 584, 585, 586, 587, 587, 588, 589, 590, 590, +591, 592, 592, 593, 594, 594, 595, 596, 597, 597, +598, 599, 599, 600, 601, 601, 602, 603, 604, 604, +605, 606, 606, 607, 608, 608, 609, 610, 610, 611, +612, 612, 613, 614, 614, 615, 615, 616, 617, 617, +618, 619, 619, 620, 621, 621, 622, 622, 623, 624, +624, 625, 626, 626, 627, 627, 628, 629, 629, 630, +631, 631, 632, 632, 633, 634, 634, 635, 635, 636, +636, 637, 638, 638, 639, 639, 640, 641, 641, 642, +642, 643, 643, 644, 645, 645, 646, 646, 647, 647, +648, 649, 649, 650, 650, 651, 651, 652, 652, 653, +654, 654, 655, 655, 656, 656, 657, 657, 658, 658, +659, 659, 660, 661, 661, 662, 662, 663, 663, 664, +664, 665, 665, 666, 666, 667, 667, 668, 668, 669, +669, 670, 670, 671, 671, 672, 672, 673, 673, 674, +674, 675, 675, 676, 676, 677, 677, 678, 678, 679, +679, 680, 680, 681, 681, 682, 682, 683, 683, 684, +684, 685, 685, 685, 686, 686, 687, 687, 688, 688, +689, 689, 690, 690, 691, 691, 691, 692, 692, 693, +693, 694, 694, 695, 695, 696, 696, 696, 697, 697, +698, 698, 699, 699, 699, 700, 700, 701, 701, 702, +702, 703, 703, 703, 704, 704, 705, 705, 706, 706, +706, 707, 707, 708, 708, 708, 709, 709, 710, 710, +711, 711, 711, 712, 712, 713, 713, 713, 714, 714, +715, 715, 715, 716, 716, 717, 717, 717, 718, 718, +719, 719, 719, 720, 720, 721, 721, 721, 722, 722, +723, 723, 723, 724, 724, 724, 725, 725, 726, 726, +726, 727, 727, 727, 728, 728, 729, 729, 729, 730, +730, 730, 731, 731, 732, 732, 732, 733, 733, 733, +734, 734, 734, 735, 735, 736, 736, 736, 737, 737, +737, 738, 738, 738, 739, 739, 739, 740, 740, 741, +741, 741, 742, 742, 742, 743, 743, 743, 744, 744, +744, 745, 745, 745, 746, 746, 746, 747, 747, 747, +748, 748, 748, 749, 749, 749, 750, 750, 750, 751, +751, 751, 752, 752, 752, 753, 753, 753, 754, 754, +754, 755, 755, 755, 756, 756, 756, 756, 757, 757, +757, 758, 758, 758, 759, 759, 759, 760, 760, 760, +761, 761, 761, 761, 762, 762, 762, 763, 763, 763, +764, 764, 764, 765, 765, 765, 765, 766, 766, 766, +767, 767, 767, 768, 768, 768, 768, 769, 769, 769, +770, 770, 770, 770, 771, 771, 771, 772, 772, 772, +773, 773, 773, 773, 774, 774, 774, 775, 775, 775, +775, 776, 776, 776, 776, 777, 777, 777, 778, 778, +778, 778, 779, 779, 779, 780, 780, 780, 780, 781, +781, 781, 781, 782, 782, 782, 783, 783, 783, 783, +784, 784, 784, 784, 785, 785, 785, 785, 786, 786, +786, 787, 787, 787, 787, 788, 788, 788, 788, 789, +789, 789, 789, 790, 790, 790, 790, 791, 791, 791, +791, 792, 792, 792, 792, 793, 793, 793, 793, 794, +794, 794, 794, 795, 795, 795, 795, 796, 796, 796, +796, 797, 797, 797, 797, 798, 798, 798, 798, 799, +799, 799, 799, 800, 800, 800, 800, 801, 801, 801, +801, 801, 802, 802, 802, 802, 803, 803, 803, 803, +804, 804, 804, 804, 805, 805, 805, 805, 805, 806, +806, 806, 806, 807, 807, 807, 807, 808, 808, 808, +808, 808, 809, 809, 809, 809, 810, 810, 810, 810, +810, 811, 811, 811, 811, 812, 812, 812, 812, 812, +813, 813, 813, 813, 813, 814, 814, 814, 814, 815, +815, 815, 815, 815, 816, 816, 816, 816, 817, 817, +817, 817, 817, 818, 818, 818, 818, 818, 819, 819, +819, 819, 819, 820, 820, 820, 820, 820, 821, 821, +821, 821, 822, 822, 822, 822, 822, 823, 823, 823, +823, 823, 824, 824, 824, 824, 824, 825, 825, 825, +825, 825, 826, 826, 826, 826, 826, 827, 827, 827, +827, 827, 828, 828, 828, 828, 828, 828, 829, 829, +829, 829, 829, 830, 830, 830, 830, 830, 831, 831, +831, 831, 831, 832, 832, 832, 832, 832, 832, 833, +833, 833, 833, 833, 834, 834, 834, 834, 834, 835, +835, 835, 835, 835, 835, 836, 836, 836, 836, 836, +837, 837, 837, 837, 837, 837, 838, 838, 838, 838, +838, 839, 839, 839, 839, 839, 839, 840, 840, 840, +840, 840, 841, 841, 841, 841, 841, 841, 842, 842, +842, 842, 842, 842, 843, 843, 843, 843, 843, 843, +844, 844, 844, 844, 844, 845, 845, 845, 845, 845, +845, 846, 846, 846, 846, 846, 846, 847, 847, 847, +847, 847, 847, 848, 848, 848, 848, 848, 848, 849, +849, 849, 849, 849, 849, 850, 850, 850, 850, 850, +850, 850, 851, 851, 851, 851, 851, 851, 852, 852, +852, 852, 852, 852, 853, 853, 853, 853, 853, 853, +854, 854, 854, 854, 854, 854, 854, 855, 855, 855, +855, 855, 855, 856, 856, 856, 856, 856, 856, 857, +857, 857, 857, 857, 857, 857, 858, 858, 858, 858, +858, 858, 858, 859, 859, 859, 859, 859, 859, 860, +860, 860, 860, 860, 860, 860, 861, 861, 861, 861, +861, 861, 861, 862, 862, 862, 862, 862, 862, 863, +863, 863, 863, 863, 863, 863, 864, 864, 864, 864, +864, 864, 864, 865, 865, 865, 865, 865, 865, 865, +866, 866, 866, 866, 866, 866, 866, 867, 867, 867, +867, 867, 867, 867, 868, 868, 868, 868, 868, 868, +868, 868, 869, 869, 869, 869, 869, 869, 869, 870, +870, 870, 870, 870, 870, 870, 871, 871, 871, 871, +871, 871, 871, 871, 872, 872, 872, 872, 872, 872, +872, 873, 873, 873, 873, 873, 873, 873, 873, 874, +874, 874, 874, 874, 874, 874, 875, 875, 875, 875, +875, 875, 875, 875, 876, 876, 876, 876, 876, 876, +876, 876, 877, 877, 877, 877, 877, 877, 877, 878, +878, 878, 878, 878, 878, 878, 878, 879, 879, 879, +879, 879, 879, 879, 879, 880, 880, 880, 880, 880, +880, 880, 880, 881, 881, 881, 881, 881, 881, 881, +881, 882, 882, 882, 882, 882, 882, 882, 882, 882, +883, 883, 883, 883, 883, 883, 883, 883, 884, 884, +884, 884, 884, 884, 884, 884, 885, 885, 885, 885, +885, 885, 885, 885, 885, 886, 886, 886, 886, 886, +886, 886, 886, 887, 887, 887, 887, 887, 887, 887, +887, 887, 888, 888, 888, 888, 888, 888, 888, 888, +888, 889, 889, 889, 889, 889, 889, 889, 889, 890, +890, 890, 890, 890, 890, 890, 890, 890, 891, 891, +891, 891, 891, 891, 891, 891, 891, 892, 892, 892, +892, 892, 892, 892, 892, 892, 893, 893, 893, 893, +893, 893, 893, 893, 893, 893, 894, 894, 894, 894, +894, 894, 894, 894, 894, 895, 895, 895, 895, 895, +895, 895, 895, 895, 896, 896, 896, 896, 896, 896, +896, 896, 896, 896, 897, 897, 897, 897, 897, 897, +897, 897, 897, 898, 898, 898, 898, 898, 898, 898, +898, 898, 898, 899, 899, 899, 899, 899, 899, 899, +899, 899, 899, 900, 900, 900, 900, 900, 900, 900, +900, 900, 900, 901, 901, 901, 901, 901, 901, 901, +901, 901, 901, 902, 902, 902, 902, 902, 902, 902, +902, 902, 902, 903, 903, 903, 903, 903, 903, 903, +903, 903, 903, 904, 904, 904, 904, 904, 904, 904, +904, 904, 904, 905, 905, 905, 905, 905, 905, 905, +905, 905, 905, 905, 906, 906, 906, 906, 906, 906, +906, 906, 906, 906, 907, 907, 907, 907, 907, 907, +907, 907, 907, 907, 907, 908, 908, 908, 908, 908, +908, 908, 908, 908, 908, 908, 909, 909, 909, 909, +909, 909, 909, 909, 909, 909, 910, 910, 910, 910, +910, 910, 910, 910, 910, 910, 910, 911, 911, 911, +911, 911, 911, 911, 911, 911, 911, 911, 911, 912, +912, 912, 912, 912, 912, 912, 912, 912, 912, 912, +913, 913, 913, 913, 913, 913, 913, 913, 913, 913, +913, 914, 914, 914, 914, 914, 914, 914, 914, 914, +914, 914, 914, 915, 915, 915, 915, 915, 915, 915, +915, 915, 915, 915, 915, 916, 916, 916, 916, 916, +916, 916, 916, 916, 916, 916, 917, 917, 917, 917, +917, 917, 917, 917, 917, 917, 917, 917, 918, 918, +918, 918, 918, 918, 918, 918, 918, 918, 918, 918, +919, 919, 919, 919, 919, 919, 919, 919, 919, 919, +919, 919, 919, 920, 920, 920, 920, 920, 920, 920, +920, 920, 920, 920, 920, 921, 921, 921, 921, 921, +921, 921, 921, 921, 921, 921, 921, 921, 922, 922, +922, 922, 922, 922, 922, 922, 922, 922, 922, 922, +923, 923, 923, 923, 923, 923, 923, 923, 923, 923, +923, 923, 923, 924, 924, 924, 924, 924, 924, 924, +924, 924, 924, 924, 924, 924, 925, 925, 925, 925, +925, 925, 925, 925, 925, 925, 925, 925, 925, 926, +926, 926, 926, 926, 926, 926, 926, 926, 926, 926, +926, 926, 926, 927, 927, 927, 927, 927, 927, 927, +927, 927, 927, 927, 927, 927, 928, 928, 928, 928, +928, 928, 928, 928, 928, 928, 928, 928, 928, 928, +929, 929, 929, 929, 929, 929, 929, 929, 929, 929, +929, 929, 929, 929, 930, 930, 930, 930, 930, 930, +930, 930, 930, 930, 930, 930, 930, 930, 931, 931, +931, 931, 931, 931, 931, 931, 931, 931, 931, 931, +931, 931, 932, 932, 932, 932, 932, 932, 932, 932, +932, 932, 932, 932, 932, 932, 933, 933, 933, 933, +933, 933, 933, 933, 933, 933, 933, 933, 933, 933, +933, 934, 934, 934, 934, 934, 934, 934, 934, 934, +934, 934, 934, 934, 934, 934, 935, 935, 935, 935, +935, 935, 935, 935, 935, 935, 935, 935, 935, 935, +935, 936, 936, 936, 936, 936, 936, 936, 936, 936, +936, 936, 936, 936, 936, 936, 937, 937, 937, 937, +937, 937, 937, 937, 937, 937, 937, 937, 937, 937, +937, 938, 938, 938, 938, 938, 938, 938, 938, 938, +938, 938, 938, 938, 938, 938, 938, 939, 939, 939, +939, 939, 939, 939, 939, 939, 939, 939, 939, 939, +939, 939, 939, 940, 940, 940, 940, 940, 940, 940, +940, 940, 940, 940, 940, 940, 940, 940, 940, 941, +941, 941, 941, 941, 941, 941, 941, 941, 941, 941, +941, 941, 941, 941, 941, 942, 942, 942, 942, 942, +942, 942, 942, 942, 942, 942, 942, 942, 942, 942, +942, 943, 943, 943, 943, 943, 943, 943, 943, 943, +943, 943, 943, 943, 943, 943, 943, 943, 944, 944, +944, 944, 944, 944, 944, 944, 944, 944, 944, 944, +944, 944, 944, 944, 944, 945, 945, 945, 945, 945, +945, 945, 945, 945, 945, 945, 945, 945, 945, 945, +945, 945, 946, 946, 946, 946, 946, 946, 946, 946, +946, 946, 946, 946, 946, 946, 946, 946, 946, 946, +947, 947, 947, 947, 947, 947, 947, 947, 947, 947, +947, 947, 947, 947, 947, 947, 947, 948, 948, 948, +948, 948, 948, 948, 948, 948, 948, 948, 948, 948, +948, 948, 948, 948, 948, 949, 949, 949, 949, 949, +949, 949, 949, 949, 949, 949, 949, 949, 949, 949, +949, 949, 949, 950, 950, 950, 950, 950, 950, 950, +950, 950, 950, 950, 950, 950, 950, 950, 950, 950, +950, 950, 951, 951, 951, 951, 951, 951, 951, 951, +951, 951, 951, 951, 951, 951, 951, 951, 951, 951, +951, 952, 952, 952, 952, 952, 952, 952, 952, 952, +952, 952, 952, 952, 952, 952, 952, 952, 952, 952, +953, 953, 953, 953, 953, 953, 953, 953, 953, 953, +953, 953, 953, 953, 953, 953, 953, 953, 953, 954, +954, 954, 954, 954, 954, 954, 954, 954, 954, 954, +954, 954, 954, 954, 954, 954, 954, 954, 955, 955, +955, 955, 955, 955, 955, 955, 955, 955, 955, 955, +955, 955, 955, 955, 955, 955, 955, 955, 956, 956, +956, 956, 956, 956, 956, 956, 956, 956, 956, 956, +956, 956, 956, 956, 956, 956, 956, 956, 956, 957, +957, 957, 957, 957, 957, 957, 957, 957, 957, 957, +957, 957, 957, 957, 957, 957, 957, 957, 957, 958, +958, 958, 958, 958, 958, 958, 958, 958, 958, 958, +958, 958, 958, 958, 958, 958, 958, 958, 958, 958, +959, 959, 959, 959, 959, 959, 959, 959, 959, 959, +959, 959, 959, 959, 959, 959, 959, 959, 959, 959, +959, 960, 960, 960, 960, 960, 960, 960, 960, 960, +960, 960, 960, 960, 960, 960, 960, 960, 960, 960, +960, 960, 960, 961, 961, 961, 961, 961, 961, 961, +961, 961, 961, 961, 961, 961, 961, 961, 961, 961, +961, 961, 961, 961, 962, 962, 962, 962, 962, 962, +962, 962, 962, 962, 962, 962, 962, 962, 962, 962, +962, 962, 962, 962, 962, 962, 962, 963, 963, 963, +963, 963, 963, 963, 963, 963, 963, 963, 963, 963, +963, 963, 963, 963, 963, 963, 963, 963, 963, 964, +964, 964, 964, 964, 964, 964, 964, 964, 964, 964, +964, 964, 964, 964, 964, 964, 964, 964, 964, 964, +964, 964, 965, 965, 965, 965, 965, 965, 965, 965, +965, 965, 965, 965, 965, 965, 965, 965, 965, 965, +965, 965, 965, 965, 965, 966, 966, 966, 966, 966, +966, 966, 966, 966, 966, 966, 966, 966, 966, 966, +966, 966, 966, 966, 966, 966, 966, 966, 966, 967, +967, 967, 967, 967, 967, 967, 967, 967, 967, 967, +967, 967, 967, 967, 967, 967, 967, 967, 967, 967, +967, 967, 967, 968, 968, 968, 968, 968, 968, 968, +968, 968, 968, 968, 968, 968, 968, 968, 968, 968, +968, 968, 968, 968, 968, 968, 968, 968, 969, 969, +969, 969, 969, 969, 969, 969, 969, 969, 969, 969, +969, 969, 969, 969, 969, 969, 969, 969, 969, 969, +969, 969, 969, 970, 970, 970, 970, 970, 970, 970, +970, 970, 970, 970, 970, 970, 970, 970, 970, 970, +970, 970, 970, 970, 970, 970, 970, 970, 971, 971, +971, 971, 971, 971, 971, 971, 971, 971, 971, 971, +971, 971, 971, 971, 971, 971, 971, 971, 971, 971, +971, 971, 971, 971, 972, 972, 972, 972, 972, 972, +972, 972, 972, 972, 972, 972, 972, 972, 972, 972, +972, 972, 972, 972, 972, 972, 972, 972, 972, 972, +973, 973, 973, 973, 973, 973, 973, 973, 973, 973, +973, 973, 973, 973, 973, 973, 973, 973, 973, 973, +973, 973, 973, 973, 973, 973, 973, 974, 974, 974, +974, 974, 974, 974, 974, 974, 974, 974, 974, 974, +974, 974, 974, 974, 974, 974, 974, 974, 974, 974, +974, 974, 974, 974, 975, 975, 975, 975, 975, 975, +975, 975, 975, 975, 975, 975, 975, 975, 975, 975, +975, 975, 975, 975, 975, 975, 975, 975, 975, 975, +975, 975, 976, 976, 976, 976, 976, 976, 976, 976, +976, 976, 976, 976, 976, 976, 976, 976, 976, 976, +976, 976, 976, 976, 976, 976, 976, 976, 976, 976, +977, 977, 977, 977, 977, 977, 977, 977, 977, 977, +977, 977, 977, 977, 977, 977, 977, 977, 977, 977, +977, 977, 977, 977, 977, 977, 977, 977, 977, 978, +978, 978, 978, 978, 978, 978, 978, 978, 978, 978, +978, 978, 978, 978, 978, 978, 978, 978, 978, 978, +978, 978, 978, 978, 978, 978, 978, 978, 979, 979, +979, 979, 979, 979, 979, 979, 979, 979, 979, 979, +979, 979, 979, 979, 979, 979, 979, 979, 979, 979, +979, 979, 979, 979, 979, 979, 979, 979, 980, 980, +980, 980, 980, 980, 980, 980, 980, 980, 980, 980, +980, 980, 980, 980, 980, 980, 980, 980, 980, 980, +980, 980, 980, 980, 980, 980, 980, 980, 981, 981, +981, 981, 981, 981, 981, 981, 981, 981, 981, 981, +981, 981, 981, 981, 981, 981, 981, 981, 981, 981, +981, 981, 981, 981, 981, 981, 981, 981, 981, 982, +982, 982, 982, 982, 982, 982, 982, 982, 982, 982, +982, 982, 982, 982, 982, 982, 982, 982, 982, 982, +982, 982, 982, 982, 982, 982, 982, 982, 982, 982, +983, 983, 983, 983, 983, 983, 983, 983, 983, 983, +983, 983, 983, 983, 983, 983, 983, 983, 983, 983, +983, 983, 983, 983, 983, 983, 983, 983, 983, 983, +983, 983, 983, 984, 984, 984, 984, 984, 984, 984, +984, 984, 984, 984, 984, 984, 984, 984, 984, 984, +984, 984, 984, 984, 984, 984, 984, 984, 984, 984, +984, 984, 984, 984, 984, 985, 985, 985, 985, 985, +985, 985, 985, 985, 985, 985, 985, 985, 985, 985, +985, 985, 985, 985, 985, 985, 985, 985, 985, 985, +985, 985, 985, 985, 985, 985, 985, 985, 985, 986, +986, 986, 986, 986, 986, 986, 986, 986, 986, 986, +986, 986, 986, 986, 986, 986, 986, 986, 986, 986, +986, 986, 986, 986, 986, 986, 986, 986, 986, 986, +986, 986, 986, 987, 987, 987, 987, 987, 987, 987, +987, 987, 987, 987, 987, 987, 987, 987, 987, 987, +987, 987, 987, 987, 987, 987, 987, 987, 987, 987, +987, 987, 987, 987, 987, 987, 987, 987, 988, 988, +988, 988, 988, 988, 988, 988, 988, 988, 988, 988, +988, 988, 988, 988, 988, 988, 988, 988, 988, 988, +988, 988, 988, 988, 988, 988, 988, 988, 988, 988, +988, 988, 988, 989, 989, 989, 989, 989, 989, 989, +989, 989, 989, 989, 989, 989, 989, 989, 989, 989, +989, 989, 989, 989, 989, 989, 989, 989, 989, 989, +989, 989, 989, 989, 989, 989, 989, 989, 989, 990, +990, 990, 990, 990, 990, 990, 990, 990, 990, 990, +990, 990, 990, 990, 990, 990, 990, 990, 990, 990, +990, 990, 990, 990, 990, 990, 990, 990, 990, 990, +990, 990, 990, 990, 990, 990, 991, 991, 991, 991, +991, 991, 991, 991, 991, 991, 991, 991, 991, 991, +991, 991, 991, 991, 991, 991, 991, 991, 991, 991, +991, 991, 991, 991, 991, 991, 991, 991, 991, 991, +991, 991, 991, 991, 992, 992, 992, 992, 992, 992, +992, 992, 992, 992, 992, 992, 992, 992, 992, 992, +992, 992, 992, 992, 992, 992, 992, 992, 992, 992, +992, 992, 992, 992, 992, 992, 992, 992, 992, 992, +992, 992, 992, 993, 993, 993, 993, 993, 993, 993, +993, 993, 993, 993, 993, 993, 993, 993, 993, 993, +993, 993, 993, 993, 993, 993, 993, 993, 993, 993, +993, 993, 993, 993, 993, 993, 993, 993, 993, 993, +993, 993, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 994, 994, 994, 994, 994, 994, 994, 994, +994, 994, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 995, 995, 995, 995, 995, 995, +995, 995, 995, 995, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 996, 996, 996, 996, +996, 996, 996, 996, 996, 996, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 997, +997, 997, 997, 997, 997, 997, 997, 997, 997, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 998, 998, 998, 998, 998, 998, 998, +998, 998, 998, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 999, 999, +999, 999, 999, 999, 999, 999, 999, 999, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, +1000, 1000, 1000, 1000, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, +1001, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, +1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, +1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, +1005, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, +1006, 1006, 1006, 1006, 1006, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, +1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, +1008, 1008, 1008, 1008, 1008, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, +1009, 1009, 1009, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, +1010, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, +1011, 1011, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, +1012, 1012, 1012, 1012, 1012, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, +1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, +1014, 1014, 1014, 1014, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, +1015, 1015, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, +1016, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, +1017, 1017, 1017, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, +1018, 1018, 1018, 1018, 1018, 1018, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, +1019, 1019, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, +1021, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, +1022, 1022, 1022, 1022, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, +1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, +1026, 1026, 1026, 1026, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, +1027, 1027, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, +1028, 1028, 1028, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, +1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, +1030, 1030, 1030, 1030, 1030, 1030, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, +1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, +1032, 1032, 1032, 1032, 1032, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, +1033, 1033, 1033, 1033, 1033, 1033, 1033, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, +1034, 1034, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, +1035, 1035, 1035, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, +1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, +1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, +1039, 1039, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, +1040, 1040, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, +1042, 1042, 1042, 1042, 1042, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, +1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, +1044, 1044, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, +1045, 1045, 1045, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, +1046, 1046, 1046, 1046, 1046, 1046, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, +1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, +1048, 1048, 1048, 1048, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, +1049, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, +1050, 1050, 1050, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, +1052}; + diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-FreenectDriver/src/DepthStream.cpp new file mode 100644 index 000000000..7159003db --- /dev/null +++ b/OpenNI2-FreenectDriver/src/DepthStream.cpp @@ -0,0 +1,146 @@ +#include +#include "DepthStream.hpp" + +using namespace FreenectDriver; + + +DepthStream::DepthStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) +{ + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); + image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; + setVideoMode(video_mode); + pDevice->startDepth(); +} + +// Add video modes here as you implement them +// Note: if image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR, +// setVideoFormat() will try FREENECT_DEPTH_REGISTERED first then fall back on what is set here. +DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() +{ + FreenectDepthModeMap modes; + // pixelFormat, resolutionX, resolutionY, fps + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = std::pair(FREENECT_DEPTH_MM, FREENECT_RESOLUTION_MEDIUM); + + + return modes; +} + +OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) +{ + FreenectDepthModeMap supported_video_modes = getSupportedVideoModes(); + FreenectDepthModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); + if (matched_mode_iter == supported_video_modes.end()) + return ONI_STATUS_NOT_SUPPORTED; + + freenect_depth_format format = matched_mode_iter->second.first; + freenect_resolution resolution = matched_mode_iter->second.second; + if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) // try forcing registration mode + format = FREENECT_DEPTH_REGISTERED; + + try { device->setDepthFormat(format, resolution); } + catch (std::runtime_error e) + { + LogError("Format " + to_string(format) + " and resolution " + to_string(resolution) + " combination not supported by libfreenect"); + if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) + { + LogError("Could not enable image registration format; falling back to format defined in getSupportedVideoModes()"); + image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; + return setVideoMode(requested_mode); + } + return ONI_STATUS_NOT_SUPPORTED; + } + video_mode = requested_mode; + return ONI_STATUS_OK; +} + +void DepthStream::populateFrame(void* data, OniFrame* frame) const +{ + frame->sensorType = sensor_type; + frame->stride = video_mode.resolutionX * sizeof(uint16_t); + + if (cropping.enabled) + { + frame->height = cropping.height; + frame->width = cropping.width; + frame->cropOriginX = cropping.originX; + frame->cropOriginY = cropping.originY; + frame->croppingEnabled = true; + } + else + { + frame->cropOriginX = 0; + frame->cropOriginY = 0; + frame->croppingEnabled = false; + } + + + // copy stream buffer from freenect + + uint16_t* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; + uint16_t* target = static_cast(frame->data); + const unsigned int skipWidth = video_mode.resolutionX - frame->width; + + if (mirroring) + { + target += frame->width; + + for (int y = 0; y < frame->height; y++) + { + for (int x = 0; x < frame->width; x++) + { + *target-- = *source++; + } + + source += skipWidth; + target += 2 * frame->width; + } + } + else + { + for (int y = 0; y < frame->height; y++) + { + for (int x = 0; x < frame->width; x++) + { + *target++ = *source++; + } + + source += skipWidth; + } + } + + /* + uint16_t* data_ptr = static_cast(data); + uint16_t* frame_data = static_cast(frame->data); + if (mirroring) + { + for (unsigned int i = 0; i < frame->dataSize / 2; i++) + { + // find corresponding mirrored pixel + unsigned int row = i / video_mode.resolutionX; + unsigned int col = video_mode.resolutionX - (i % video_mode.resolutionX); + unsigned int target = (row * video_mode.resolutionX) + col; + // copy it to this pixel + frame_data[i] = data_ptr[target]; + } + } + else + std::copy(data_ptr, data_ptr+frame->dataSize / 2, frame_data); + */ +} + + +/* depth video modes reference + +FREENECT_DEPTH_11BIT = 0, //< 11 bit depth information in one uint16_t/pixel +FREENECT_DEPTH_10BIT = 1, //< 10 bit depth information in one uint16_t/pixel +FREENECT_DEPTH_11BIT_PACKED = 2, //< 11 bit packed depth information +FREENECT_DEPTH_10BIT_PACKED = 3, //< 10 bit packed depth information +FREENECT_DEPTH_REGISTERED = 4, //< processed depth data in mm, aligned to 640x480 RGB +FREENECT_DEPTH_MM = 5, //< depth to each pixel in mm, but left unaligned to RGB image +FREENECT_DEPTH_DUMMY = 2147483647, //< Dummy value to force enum to be 32 bits wide + +ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, +ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, +ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, +ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, +*/ diff --git a/OpenNI2-FreenectDriver/src/DepthStream.hpp b/OpenNI2-FreenectDriver/src/DepthStream.hpp new file mode 100644 index 000000000..303449ecd --- /dev/null +++ b/OpenNI2-FreenectDriver/src/DepthStream.hpp @@ -0,0 +1,210 @@ +#pragma once + +#include // for transform() +#include // for M_PI +#include // for memcpy +#include "libfreenect.hpp" +#include "Driver/OniDriverAPI.h" +#include "PS1080.h" +#include "VideoStream.hpp" +#include "S2D.h" +#include "D2S.h" + + +namespace FreenectDriver +{ + class DepthStream : public VideoStream + { + public: + // from NUI library and converted to radians + static const float DIAGONAL_FOV = 70 * (M_PI / 180); + static const float HORIZONTAL_FOV = 58.5 * (M_PI / 180); + static const float VERTICAL_FOV = 45.6 * (M_PI / 180); + // from DepthKinectStream.cpp + static const int MAX_VALUE = 10000; + static const unsigned long long GAIN_VAL = 42; + static const unsigned long long CONST_SHIFT_VAL = 200; + static const unsigned long long MAX_SHIFT_VAL = 2047; + static const unsigned long long PARAM_COEFF_VAL = 4; + static const unsigned long long SHIFT_SCALE_VAL = 10; + static const unsigned long long ZERO_PLANE_DISTANCE_VAL = 120; + static const double ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; + static const double EMITTER_DCMOS_DISTANCE_VAL = 7.5; + + private: + typedef std::map< OniVideoMode, std::pair > FreenectDepthModeMap; + static const OniSensorType sensor_type = ONI_SENSOR_DEPTH; + OniImageRegistrationMode image_registration_mode; + + static FreenectDepthModeMap getSupportedVideoModes(); + OniStatus setVideoMode(OniVideoMode requested_mode); + void populateFrame(void* data, OniFrame* frame) const; + + public: + DepthStream(Freenect::FreenectDevice* pDevice); + //~DepthStream() { } + + static OniSensorInfo getSensorInfo() + { + FreenectDepthModeMap supported_modes = getSupportedVideoModes(); + OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; + std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); + OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; + return sensors; + } + + OniImageRegistrationMode getImageRegistrationMode() const { return image_registration_mode; } + OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) + { + if (!isImageRegistrationModeSupported(mode)) + return ONI_STATUS_NOT_SUPPORTED; + image_registration_mode = mode; + return setVideoMode(video_mode); + } + + // from StreamBase + OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF || mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR); } + + OniBool isPropertySupported(int propertyId) + { + switch(propertyId) + { + default: + return VideoStream::isPropertySupported(propertyId); + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: + case ONI_STREAM_PROPERTY_VERTICAL_FOV: + case ONI_STREAM_PROPERTY_MAX_VALUE: + case XN_STREAM_PROPERTY_GAIN: + case XN_STREAM_PROPERTY_CONST_SHIFT: + case XN_STREAM_PROPERTY_MAX_SHIFT: + case XN_STREAM_PROPERTY_PARAM_COEFF: + case XN_STREAM_PROPERTY_SHIFT_SCALE: + case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: + case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: + case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: + case XN_STREAM_PROPERTY_S2D_TABLE: + case XN_STREAM_PROPERTY_D2S_TABLE: + return true; + } + } + + OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { + default: + return VideoStream::getProperty(propertyId, data, pDataSize); + + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_HORIZONTAL_FOV"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = HORIZONTAL_FOV; + return ONI_STATUS_OK; + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VERTICAL_FOV"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = VERTICAL_FOV; + return ONI_STATUS_OK; + case ONI_STREAM_PROPERTY_MAX_VALUE: // int + if (*pDataSize != sizeof(int)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MAX_VALUE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = MAX_VALUE; + return ONI_STATUS_OK; + + case XN_STREAM_PROPERTY_PIXEL_REGISTRATION: // XnPixelRegistration (get only) + case XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED: // unsigned long long + case XN_STREAM_PROPERTY_HOLE_FILTER: // unsigned long long + case XN_STREAM_PROPERTY_REGISTRATION_TYPE: // XnProcessingType + case XN_STREAM_PROPERTY_AGC_BIN: // XnDepthAGCBin* + case XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR: // unsigned long long + case XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE: // double + case XN_STREAM_PROPERTY_CLOSE_RANGE: // unsigned long long + return ONI_STATUS_NOT_SUPPORTED; + + case XN_STREAM_PROPERTY_GAIN: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_GAIN"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = GAIN_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_CONST_SHIFT: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_CONST_SHIFT"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = CONST_SHIFT_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_MAX_SHIFT: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_MAX_SHIFT"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = MAX_SHIFT_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_PARAM_COEFF: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_PARAM_COEFF"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = PARAM_COEFF_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_SHIFT_SCALE: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_SHIFT_SCALE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = SHIFT_SCALE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = ZERO_PLANE_DISTANCE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: // double + if (*pDataSize != sizeof(double)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = ZERO_PLANE_PIXEL_SIZE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: // double + if (*pDataSize != sizeof(double)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = EMITTER_DCMOS_DISTANCE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_S2D_TABLE: // OniDepthPixel[] + *pDataSize = sizeof(S2D); + //std::copy(S2D, S2D+1, static_cast(data)); + memcpy(data, S2D, *pDataSize); + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_D2S_TABLE: // unsigned short[] + *pDataSize = sizeof(D2S); + //std::copy(D2S, D2S+1, static_cast(data)); + memcpy(data, D2S, *pDataSize); + return ONI_STATUS_OK; + } + } + }; +} diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp new file mode 100644 index 000000000..6a52ff58d --- /dev/null +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -0,0 +1,351 @@ +/** +* FreenectDriver +* Copyright 2013 Benn Snyder +* +* 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. +*/ +#include +#include +#include "Driver/OniDriverAPI.h" +#include "freenect_internal.h" +#include "libfreenect.hpp" +#include "DepthStream.hpp" +#include "ColorStream.hpp" + + +namespace FreenectDriver +{ + class Device : public oni::driver::DeviceBase, public Freenect::FreenectDevice + { + private: + ColorStream* color; + DepthStream* depth; + + // for Freenect::FreenectDevice + void DepthCallback(void* data, uint32_t timestamp) { + depth->buildFrame(data, timestamp); + } + void VideoCallback(void* data, uint32_t timestamp) { + color->buildFrame(data, timestamp); + } + + public: + Device(freenect_context* fn_ctx, int index) : Freenect::FreenectDevice(fn_ctx, index), + color(NULL), + depth(NULL) { } + ~Device() + { + destroyStream(color); + destroyStream(depth); + } + + // for DeviceBase + + OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return depth->isImageRegistrationModeSupported(mode); } + + OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) + { + *numSensors = 2; + OniSensorInfo * sensors = new OniSensorInfo[*numSensors]; + sensors[0] = depth->getSensorInfo(); + sensors[1] = color->getSensorInfo(); + *pSensors = sensors; + return ONI_STATUS_OK; + } + + oni::driver::StreamBase* createStream(OniSensorType sensorType) + { + switch (sensorType) + { + default: + LogError("Cannot create a stream of type " + to_string(sensorType)); + return NULL; + case ONI_SENSOR_COLOR: + if (! color) + color = new ColorStream(this); + return color; + case ONI_SENSOR_DEPTH: + if (! depth) + depth = new DepthStream(this); + return depth; + // todo: IR + } + } + + void destroyStream(oni::driver::StreamBase* pStream) + { + if (pStream == NULL) + return; + + if (pStream == color) + { + Freenect::FreenectDevice::stopVideo(); + delete color; + color = NULL; + } + if (pStream == depth) + { + Freenect::FreenectDevice::stopDepth(); + delete depth; + depth = NULL; + } + } + + // todo: fill out properties + OniBool isPropertySupported(int propertyId) + { + if (propertyId == ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION) + return true; + return false; + } + + OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { + default: + case ONI_DEVICE_PROPERTY_FIRMWARE_VERSION: // string + case ONI_DEVICE_PROPERTY_DRIVER_VERSION: // OniVersion + case ONI_DEVICE_PROPERTY_HARDWARE_VERSION: // int + case ONI_DEVICE_PROPERTY_SERIAL_NUMBER: // string + case ONI_DEVICE_PROPERTY_ERROR_STATE: // ? + // files + case ONI_DEVICE_PROPERTY_PLAYBACK_SPEED: // float + case ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED: // OniBool + // xn + case XN_MODULE_PROPERTY_USB_INTERFACE: // XnSensorUsbInterface + case XN_MODULE_PROPERTY_MIRROR: // bool + case XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP: // unsigned long long + case XN_MODULE_PROPERTY_LEAN_INIT: // unsigned long long + case XN_MODULE_PROPERTY_SERIAL_NUMBER: // unsigned long long + case XN_MODULE_PROPERTY_VERSION: // XnVersions + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: // OniImageRegistrationMode + if (*pDataSize != sizeof(OniImageRegistrationMode)) + { + LogError("Unexpected size for ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = depth->getImageRegistrationMode(); + return ONI_STATUS_OK; + } + } + + OniStatus setProperty(int propertyId, const void* data, int dataSize) + { + switch (propertyId) + { + default: + case ONI_DEVICE_PROPERTY_FIRMWARE_VERSION: // By implementation + case ONI_DEVICE_PROPERTY_DRIVER_VERSION: // OniVersion + case ONI_DEVICE_PROPERTY_HARDWARE_VERSION: // int + case ONI_DEVICE_PROPERTY_SERIAL_NUMBER: // string + case ONI_DEVICE_PROPERTY_ERROR_STATE: // ? + // files + case ONI_DEVICE_PROPERTY_PLAYBACK_SPEED: // float + case ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED: // OniBool + // xn + case XN_MODULE_PROPERTY_USB_INTERFACE: // XnSensorUsbInterface + case XN_MODULE_PROPERTY_MIRROR: // bool + case XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP: // unsigned long long + case XN_MODULE_PROPERTY_LEAN_INIT: // unsigned long long + case XN_MODULE_PROPERTY_SERIAL_NUMBER: // unsigned long long + case XN_MODULE_PROPERTY_VERSION: // XnVersions + // xn commands + case XN_MODULE_PROPERTY_FIRMWARE_PARAM: // XnInnerParam + case XN_MODULE_PROPERTY_RESET: // unsigned long long + case XN_MODULE_PROPERTY_IMAGE_CONTROL: // XnControlProcessingData + case XN_MODULE_PROPERTY_DEPTH_CONTROL: // XnControlProcessingData + case XN_MODULE_PROPERTY_AHB: // XnAHBData + case XN_MODULE_PROPERTY_LED_STATE: // XnLedState + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: // OniImageRegistrationMode + if (dataSize != sizeof(OniImageRegistrationMode)) + { + LogError("Unexpected size for ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION"); + return ONI_STATUS_ERROR; + } + return depth->setImageRegistrationMode(*(static_cast(data))); + } + } + + OniBool isCommandSupported(int commandId) + { + switch (commandId) + { + default: + case ONI_DEVICE_COMMAND_SEEK: + return false; + } + } + + OniStatus invoke(int commandId, void* data, int dataSize) + { + switch (commandId) + { + default: + case ONI_DEVICE_COMMAND_SEEK: // OniSeek + return ONI_STATUS_NOT_SUPPORTED; + } + } + + + /* todo: for DeviceBase + virtual OniStatus tryManualTrigger() {return ONI_STATUS_OK;} + */ + }; + + + class Driver : public oni::driver::DriverBase, private Freenect::Freenect + { + private: + typedef std::map OniDeviceMap; + OniDeviceMap devices; + + static std::string devid_to_uri(int id) { + return "freenect://" + to_string(id); + } + + static int uri_to_devid(const std::string uri) { + int id; + std::istringstream is(uri); + is.seekg(strlen("freenect://")); + is >> id; + return id; + } + + public: + Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) + { + WriteMessage("Using libfreenect v" + to_string(PROJECT_VER)); + + freenect_set_log_level(m_ctx, FREENECT_LOG_DEBUG); + freenect_select_subdevices(m_ctx, FREENECT_DEVICE_CAMERA); // OpenNI2 doesn't use MOTOR or AUDIO + DriverServices = &getServices(); + } + ~Driver() { shutdown(); } + + // for DriverBase + + OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) + { + DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); + for (int i = 0; i < Freenect::deviceCount(); i++) + { + std::string uri = devid_to_uri(i); + + WriteMessage("Found device " + uri); + + OniDeviceInfo info; + strncpy(info.uri, uri.c_str(), ONI_MAX_STR); + strncpy(info.vendor, "Microsoft", ONI_MAX_STR); + strncpy(info.name, "Kinect", ONI_MAX_STR); + devices[info] = NULL; + deviceConnected(&info); + deviceStateChanged(&info, 0); + + freenect_device* dev; + if (freenect_open_device(m_ctx, &dev, i) == 0) + { + info.usbVendorId = dev->usb_cam.VID; + info.usbProductId = dev->usb_cam.PID; + freenect_close_device(dev); + } + else + { + WriteMessage("Unable to open device to query VID/PID"); + } + } + return ONI_STATUS_OK; + } + + oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode = NULL) + { + for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) + { + if (strcmp(iter->first.uri, uri) == 0) // found + { + if (iter->second) // already open + { + return iter->second; + } + else + { + WriteMessage("Opening device " + std::string(uri)); + int id = uri_to_devid(iter->first.uri); + Device* device = &createDevice(id); + iter->second = device; + return device; + } + } + } + + LogError("Could not find device " + std::string(uri)); + return NULL; + } + + void deviceClose(oni::driver::DeviceBase* pDevice) + { + for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) + { + if (iter->second == pDevice) + { + WriteMessage("Closing device " + std::string(iter->first.uri)); + int id = uri_to_devid(iter->first.uri); + devices.erase(iter); + deleteDevice(id); + return; + } + } + + LogError("Could not close unrecognized device"); + } + + OniStatus tryDevice(const char* uri) + { + oni::driver::DeviceBase* device = deviceOpen(uri); + if (! device) + return ONI_STATUS_ERROR; + deviceClose(device); + return ONI_STATUS_OK; + } + + void shutdown() + { + for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) + { + WriteMessage("Closing device " + std::string(iter->first.uri)); + int id = uri_to_devid(iter->first.uri); + deleteDevice(id); + } + + devices.clear(); + } + + + /* todo: for DriverBase + virtual void* enableFrameSync(oni::driver::StreamBase** pStreams, int streamCount); + virtual void disableFrameSync(void* frameSyncGroup); + */ + }; +} + + +// macros defined in XnLib (not included) - workaround +#define XN_NEW(type, arg...) new type(arg) +#define XN_DELETE(p) delete(p) +ONI_EXPORT_DRIVER(FreenectDriver::Driver); +#undef XN_NEW +#undef XN_DELETE diff --git a/OpenNI2-FreenectDriver/src/S2D.h b/OpenNI2-FreenectDriver/src/S2D.h new file mode 100644 index 000000000..ab90f3a17 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/S2D.h @@ -0,0 +1,207 @@ +const uint16_t S2D[] = { +0, 315, 315, 315, 316, 316, 316, 316, 317, 317, +317, 318, 318, 318, 319, 319, 319, 319, 320, 320, +320, 321, 321, 321, 322, 322, 322, 322, 323, 323, +323, 324, 324, 324, 325, 325, 325, 326, 326, 326, +326, 327, 327, 327, 328, 328, 328, 329, 329, 329, +330, 330, 330, 331, 331, 331, 332, 332, 332, 332, +333, 333, 333, 334, 334, 334, 335, 335, 335, 336, +336, 336, 337, 337, 337, 338, 338, 338, 339, 339, +339, 340, 340, 340, 341, 341, 341, 342, 342, 343, +343, 343, 344, 344, 344, 345, 345, 345, 346, 346, +346, 347, 347, 347, 348, 348, 348, 349, 349, 350, +350, 350, 351, 351, 351, 352, 352, 352, 353, 353, +354, 354, 354, 355, 355, 355, 356, 356, 356, 357, +357, 358, 358, 358, 359, 359, 359, 360, 360, 361, +361, 361, 362, 362, 363, 363, 363, 364, 364, 364, +365, 365, 366, 366, 366, 367, 367, 368, 368, 368, +369, 369, 370, 370, 370, 371, 371, 372, 372, 372, +373, 373, 374, 374, 374, 375, 375, 376, 376, 377, +377, 377, 378, 378, 379, 379, 379, 380, 380, 381, +381, 382, 382, 382, 383, 383, 384, 384, 385, 385, +385, 386, 386, 387, 387, 388, 388, 389, 389, 389, +390, 390, 391, 391, 392, 392, 393, 393, 393, 394, +394, 395, 395, 396, 396, 397, 397, 398, 398, 398, +399, 399, 400, 400, 401, 401, 402, 402, 403, 403, +404, 404, 405, 405, 406, 406, 407, 407, 408, 408, +409, 409, 409, 410, 410, 411, 411, 412, 412, 413, +413, 414, 414, 415, 415, 416, 416, 417, 418, 418, +419, 419, 420, 420, 421, 421, 422, 422, 423, 423, +424, 424, 425, 425, 426, 426, 427, 427, 428, 429, +429, 430, 430, 431, 431, 432, 432, 433, 433, 434, +435, 435, 436, 436, 437, 437, 438, 438, 439, 440, +440, 441, 441, 442, 442, 443, 444, 444, 445, 445, +446, 446, 447, 448, 448, 449, 449, 450, 451, 451, +452, 452, 453, 454, 454, 455, 455, 456, 457, 457, +458, 458, 459, 460, 460, 461, 462, 462, 463, 463, +464, 465, 465, 466, 467, 467, 468, 468, 469, 470, +470, 471, 472, 472, 473, 474, 474, 475, 476, 476, +477, 478, 478, 479, 480, 480, 481, 482, 482, 483, +484, 484, 485, 486, 487, 487, 488, 489, 489, 490, +491, 491, 492, 493, 494, 494, 495, 496, 496, 497, +498, 499, 499, 500, 501, 502, 502, 503, 504, 504, +505, 506, 507, 507, 508, 509, 510, 511, 511, 512, +513, 514, 514, 515, 516, 517, 517, 518, 519, 520, +521, 521, 522, 523, 524, 525, 525, 526, 527, 528, +529, 529, 530, 531, 532, 533, 534, 534, 535, 536, +537, 538, 539, 540, 540, 541, 542, 543, 544, 545, +546, 546, 547, 548, 549, 550, 551, 552, 553, 554, +554, 555, 556, 557, 558, 559, 560, 561, 562, 563, +564, 565, 565, 566, 567, 568, 569, 570, 571, 572, +573, 574, 575, 576, 577, 578, 579, 580, 581, 582, +583, 584, 585, 586, 587, 588, 589, 590, 591, 592, +593, 594, 595, 596, 597, 598, 599, 600, 601, 602, +603, 604, 606, 607, 608, 609, 610, 611, 612, 613, +614, 615, 616, 618, 619, 620, 621, 622, 623, 624, +625, 627, 628, 629, 630, 631, 632, 634, 635, 636, +637, 638, 640, 641, 642, 643, 644, 646, 647, 648, +649, 650, 652, 653, 654, 655, 657, 658, 659, 661, +662, 663, 664, 666, 667, 668, 670, 671, 672, 674, +675, 676, 678, 679, 680, 682, 683, 684, 686, 687, +688, 690, 691, 693, 694, 696, 697, 698, 700, 701, +703, 704, 706, 707, 708, 710, 711, 713, 714, 716, +717, 719, 720, 722, 723, 725, 727, 728, 730, 731, +733, 734, 736, 738, 739, 741, 742, 744, 746, 747, +749, 750, 752, 754, 755, 757, 759, 761, 762, 764, +766, 767, 769, 771, 773, 774, 776, 778, 780, 781, +783, 785, 787, 789, 790, 792, 794, 796, 798, 800, +802, 803, 805, 807, 809, 811, 813, 815, 817, 819, +821, 823, 825, 827, 829, 831, 833, 835, 837, 839, +841, 843, 845, 847, 849, 851, 854, 856, 858, 860, +862, 864, 867, 869, 871, 873, 875, 878, 880, 882, +885, 887, 889, 891, 894, 896, 898, 901, 903, 906, +908, 910, 913, 915, 918, 920, 923, 925, 928, 930, +933, 935, 938, 940, 943, 946, 948, 951, 954, 956, +959, 962, 964, 967, 970, 973, 975, 978, 981, 984, +987, 989, 992, 995, 998, 1001, 1004, 1007, 1010, 1013, +1016, 1019, 1022, 1025, 1028, 1031, 1034, 1038, 1041, 1044, +1047, 1050, 1054, 1057, 1060, 1063, 1067, 1070, 1073, 1077, +1080, 1084, 1087, 1090, 1094, 1097, 1101, 1105, 1108, 1112, +1115, 1119, 1123, 1126, 1130, 1134, 1138, 1141, 1145, 1149, +1153, 1157, 1161, 1165, 1169, 1173, 1177, 1181, 1185, 1189, +1193, 1197, 1202, 1206, 1210, 1214, 1219, 1223, 1227, 1232, +1236, 1241, 1245, 1250, 1255, 1259, 1264, 1268, 1273, 1278, +1283, 1288, 1292, 1297, 1302, 1307, 1312, 1317, 1322, 1328, +1333, 1338, 1343, 1349, 1354, 1359, 1365, 1370, 1376, 1381, +1387, 1392, 1398, 1404, 1410, 1415, 1421, 1427, 1433, 1439, +1445, 1452, 1458, 1464, 1470, 1477, 1483, 1489, 1496, 1503, +1509, 1516, 1523, 1529, 1536, 1543, 1550, 1557, 1564, 1572, +1579, 1586, 1594, 1601, 1609, 1616, 1624, 1632, 1639, 1647, +1655, 1663, 1671, 1680, 1688, 1696, 1705, 1713, 1722, 1731, +1739, 1748, 1757, 1766, 1776, 1785, 1794, 1804, 1813, 1823, +1833, 1843, 1853, 1863, 1873, 1883, 1894, 1904, 1915, 1926, +1936, 1947, 1959, 1970, 1981, 1993, 2005, 2016, 2028, 2040, +2053, 2065, 2078, 2090, 2103, 2116, 2129, 2143, 2156, 2170, +2184, 2198, 2212, 2226, 2241, 2256, 2271, 2286, 2301, 2317, +2333, 2349, 2365, 2381, 2398, 2415, 2432, 2450, 2467, 2485, +2503, 2522, 2541, 2560, 2579, 2598, 2618, 2639, 2659, 2680, +2701, 2723, 2744, 2767, 2789, 2812, 2835, 2859, 2883, 2908, +2933, 2958, 2984, 3010, 3037, 3064, 3092, 3120, 3149, 3178, +3208, 3238, 3269, 3300, 3333, 3365, 3399, 3433, 3468, 3503, +3539, 3576, 3614, 3653, 3692, 3732, 3774, 3816, 3859, 3903, +3948, 3994, 4041, 4089, 4139, 4190, 4241, 4295, 4349, 4405, +4463, 4522, 4582, 4645, 4708, 4774, 4842, 4911, 4983, 5056, +5132, 5210, 5291, 5374, 5460, 5548, 5640, 5734, 5832, 5933, +6038, 6146, 6259, 6375, 6497, 6622, 6753, 6889, 7030, 7178, +7332, 7492, 7660, 7835, 8019, 8212, 8413, 8626, 8849, 9084, +9331, 9593, 9870, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0}; + diff --git a/OpenNI2-FreenectDriver/src/Utility.hpp b/OpenNI2-FreenectDriver/src/Utility.hpp new file mode 100644 index 000000000..531be112d --- /dev/null +++ b/OpenNI2-FreenectDriver/src/Utility.hpp @@ -0,0 +1,74 @@ +// This file contains symbols that may be used by any class or don't really go anywhere else. +#pragma once + +#include +#include "Driver/OniDriverAPI.h" + + +// Oni helpers + +static OniVideoMode makeOniVideoMode(OniPixelFormat pixel_format, int resolution_x, int resolution_y, int frames_per_second) +{ + OniVideoMode mode; + mode.pixelFormat = pixel_format; + mode.resolutionX = resolution_x; + mode.resolutionY = resolution_y; + mode.fps = frames_per_second; + return mode; +} +static bool operator==(const OniVideoMode& left, const OniVideoMode& right) +{ + return (left.pixelFormat == right.pixelFormat && left.resolutionX == right.resolutionX + && left.resolutionY == right.resolutionY && left.fps == right.fps); +} +static bool operator<(const OniVideoMode& left, const OniVideoMode& right) +{ + return (left.resolutionX * left.resolutionY < right.resolutionX * right.resolutionY); +} + +static bool operator<(const OniDeviceInfo& left, const OniDeviceInfo& right) +{ + return (strcmp(left.uri, right.uri) < 0); +} + + +/// Extracts `first` from `pair`, for transforming a map into its keys. +struct ExtractKey +{ + template typename T::first_type + operator()(T pair) const + { + return pair.first; + } +}; + + +// holding out on C++11 +template +static std::string to_string(const T& n) +{ + std::ostringstream oss; + oss << n; + return oss.str(); +} + + +// global logging +namespace FreenectDriver +{ + static void WriteMessage(std::string info) + { + std::cout << "OpenNI2-FreenectDriver: " << info << std::endl; + } + + // DriverServices is set in DeviceDriver.cpp so all files can call errorLoggerAppend() + static oni::driver::DriverServices* DriverServices; + static void LogError(std::string error) + { + // errorLoggerAppend() doesn't seem to go anywhere, so WriteMessage also + WriteMessage("(ERROR) " + error); + + if (DriverServices != NULL) + DriverServices->errorLoggerAppend(std::string("OpenNI2-FreenectDriver: " + error).c_str()); + } +} diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp new file mode 100644 index 000000000..0823e7e7f --- /dev/null +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -0,0 +1,202 @@ +#pragma once + +#include "libfreenect.hpp" +#include "PS1080.h" +#include "Utility.hpp" + + +namespace FreenectDriver +{ + class VideoStream : public oni::driver::StreamBase + { + private: + unsigned int frame_id; // number each frame + + virtual OniStatus setVideoMode(OniVideoMode requested_mode) = 0; + virtual void populateFrame(void* data, OniFrame* frame) const = 0; + + protected: + static const OniSensorType sensor_type; + Freenect::FreenectDevice* device; + bool running; // buildFrame() does something iff true + OniVideoMode video_mode; + OniCropping cropping; + bool mirroring; + + public: + VideoStream(Freenect::FreenectDevice* device) : + frame_id(1), + device(device), + mirroring(false) + { + // joy of structs + memset(&cropping, 0, sizeof(cropping)); + memset(&video_mode, 0, sizeof(video_mode)); + } + //~VideoStream() { stop(); } + + void buildFrame(void* data, uint32_t timestamp) + { + if (!running) + return; + + OniFrame* frame = getServices().acquireFrame(); + frame->frameIndex = frame_id++; + frame->timestamp = timestamp; + frame->videoMode = video_mode; + frame->width = video_mode.resolutionX; + frame->height = video_mode.resolutionY; + + populateFrame(data, frame); + raiseNewFrame(frame); + getServices().releaseFrame(frame); + } + + // from StreamBase + + OniStatus start() + { + running = true; + return ONI_STATUS_OK; + } + void stop() { running = false; } + + // only add to property handlers if the property is generic to all children + // otherwise, implement in child and call these in default case + OniBool isPropertySupported(int propertyId) + { + switch(propertyId) + { + case ONI_STREAM_PROPERTY_VIDEO_MODE: + case ONI_STREAM_PROPERTY_CROPPING: + case ONI_STREAM_PROPERTY_MIRRORING: + return true; + default: + return false; + } + } + + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { + default: + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_MAX_VALUE: // int + case ONI_STREAM_PROPERTY_MIN_VALUE: // int + case ONI_STREAM_PROPERTY_STRIDE: // int + case ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES: // int + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + // xn + case XN_STREAM_PROPERTY_INPUT_FORMAT: // unsigned long long + case XN_STREAM_PROPERTY_CROPPING_MODE: // XnCroppingMode + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_STREAM_PROPERTY_VIDEO_MODE: // OniVideoMode* + if (*pDataSize != sizeof(OniVideoMode)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VIDEO_MODE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = video_mode; + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_CROPPING: // OniCropping* + if (*pDataSize != sizeof(OniCropping)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_CROPPING"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = cropping; + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_MIRRORING: // OniBool + if (*pDataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = mirroring; + return ONI_STATUS_OK; + } + } + virtual OniStatus setProperty(int propertyId, const void* data, int dataSize) + { + switch (propertyId) + { + default: + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float: radians + case ONI_STREAM_PROPERTY_MAX_VALUE: // int + case ONI_STREAM_PROPERTY_MIN_VALUE: // int + case ONI_STREAM_PROPERTY_STRIDE: // int + case ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES: // int + // camera + case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool + case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool + // xn + case XN_STREAM_PROPERTY_INPUT_FORMAT: // unsigned long long + case XN_STREAM_PROPERTY_CROPPING_MODE: // XnCroppingMode + return ONI_STATUS_NOT_SUPPORTED; + + case ONI_STREAM_PROPERTY_VIDEO_MODE: // OniVideoMode* + if (dataSize != sizeof(OniVideoMode)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VIDEO_MODE"); + return ONI_STATUS_ERROR; + } + if (ONI_STATUS_OK != setVideoMode(*(static_cast(data)))) + return ONI_STATUS_NOT_SUPPORTED; + raisePropertyChanged(propertyId, data, dataSize); + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_CROPPING: // OniCropping* + if (dataSize != sizeof(OniCropping)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_CROPPING"); + return ONI_STATUS_ERROR; + } + cropping = *(static_cast(data)); + raisePropertyChanged(propertyId, data, dataSize); + return ONI_STATUS_OK; + + case ONI_STREAM_PROPERTY_MIRRORING: // OniBool + if (dataSize != sizeof(OniBool)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING"); + return ONI_STATUS_ERROR; + } + mirroring = *(static_cast(data)); + raisePropertyChanged(propertyId, data, dataSize); + return ONI_STATUS_OK; + } + } + + + /* todo : from StreamBase + virtual OniStatus convertDepthToColorCoordinates(StreamBase* colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) { return ONI_STATUS_NOT_SUPPORTED; } + */ + }; +} + + +/* image video modes reference + +FREENECT_VIDEO_RGB = 0, //< Decompressed RGB mode (demosaicing done by libfreenect) +FREENECT_VIDEO_BAYER = 1, //< Bayer compressed mode (raw information from camera) +FREENECT_VIDEO_IR_8BIT = 2, //< 8-bit IR mode +FREENECT_VIDEO_IR_10BIT = 3, //< 10-bit IR mode +FREENECT_VIDEO_IR_10BIT_PACKED = 4, //< 10-bit packed IR mode +FREENECT_VIDEO_YUV_RGB = 5, //< YUV RGB mode +FREENECT_VIDEO_YUV_RAW = 6, //< YUV Raw mode +FREENECT_VIDEO_DUMMY = 2147483647, //< Dummy value to force enum to be 32 bits wide + +ONI_PIXEL_FORMAT_RGB888 = 200, +ONI_PIXEL_FORMAT_YUV422 = 201, +ONI_PIXEL_FORMAT_GRAY8 = 202, +ONI_PIXEL_FORMAT_GRAY16 = 203, +ONI_PIXEL_FORMAT_JPEG = 204, +*/ From 9cbe0a7e457af83e7567c233a158b77f9cda5bbc Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sun, 10 May 2015 12:52:28 +0900 Subject: [PATCH 02/20] openni2: Works with /opt/OpenNI2/Tools/NiViewer. --- OpenNI2-FreenectDriver/CMakeLists.txt | 14 ++-- OpenNI2-FreenectDriver/src/ColorStream.cpp | 20 ++++-- OpenNI2-FreenectDriver/src/ColorStream.hpp | 10 ++- OpenNI2-FreenectDriver/src/DepthStream.cpp | 12 ++-- OpenNI2-FreenectDriver/src/DepthStream.hpp | 6 +- OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 77 ++++++++++++++++----- OpenNI2-FreenectDriver/src/VideoStream.hpp | 10 +-- 7 files changed, 104 insertions(+), 45 deletions(-) diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-FreenectDriver/CMakeLists.txt index 30f70dcee..475136d57 100644 --- a/OpenNI2-FreenectDriver/CMakeLists.txt +++ b/OpenNI2-FreenectDriver/CMakeLists.txt @@ -4,23 +4,25 @@ file(GLOB HEADERS src/*.hpp src/*.h) file(GLOB SOURCES src/*.cpp) -add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES}) +add_library(Freenect2Driver SHARED ${HEADERS} ${SOURCES}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver) -set_target_properties(FreenectDriver PROPERTIES +set_target_properties(Freenect2Driver PROPERTIES VERSION ${PROJECT_VER} SOVERSION ${PROJECT_APIVER} - OUTPUT_NAME FreenectDriver) + OUTPUT_NAME Freenect2Driver) add_definitions(-DPROJECT_VER="${PROJECT_VER}") -include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) +include_directories(/opt/OpenNI2/Include) +include_directories(${PROJECT_SOURCE_DIR}/../include) +include_directories(${PROJECT_SOURCE_DIR}/../examples/protonect/include) include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) -target_link_libraries(FreenectDriver freenectstatic ${MATH_LIB}) +target_link_libraries(Freenect2Driver freenect2 ${MATH_LIB}) -install (TARGETS FreenectDriver +install (TARGETS Freenect2Driver DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/OpenNI2-FreenectDriver") diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-FreenectDriver/src/ColorStream.cpp index 6ac7444d5..df4f98a84 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.cpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.cpp @@ -4,11 +4,11 @@ using namespace FreenectDriver; -ColorStream::ColorStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) +ColorStream::ColorStream(libfreenect2::Freenect2Device* pDevice) : VideoStream(pDevice) { - video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30); + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30); setVideoMode(video_mode); - pDevice->startVideo(); + pDevice->start(); } // Add video modes here as you implement them @@ -16,7 +16,7 @@ ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() { FreenectVideoModeMap modes; // pixelFormat, resolutionX, resolutionY, fps freenect_video_format, freenect_resolution - modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 640, 480, 30)] = std::pair(FREENECT_VIDEO_RGB, FREENECT_RESOLUTION_MEDIUM); + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30)] = std::pair(FREENECT2_VIDEO_RGB, FREENECT2_RESOLUTION_1920x1080); return modes; @@ -35,15 +35,17 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) if (matched_mode_iter == supported_video_modes.end()) return ONI_STATUS_NOT_SUPPORTED; - freenect_video_format format = matched_mode_iter->second.first; - freenect_resolution resolution = matched_mode_iter->second.second; + freenect2_video_format format = matched_mode_iter->second.first; + freenect2_resolution resolution = matched_mode_iter->second.second; +#if 0 try { device->setVideoFormat(format, resolution); } catch (std::runtime_error e) { LogError("Format " + to_string(format) + " and resolution " + to_string(resolution) + " combination not supported by libfreenect"); return ONI_STATUS_NOT_SUPPORTED; } +#endif // 0 video_mode = requested_mode; return ONI_STATUS_OK; } @@ -66,7 +68,11 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const case ONI_PIXEL_FORMAT_RGB888: uint8_t* source = static_cast(data); uint8_t* target = static_cast(frame->data); - std::copy(source, source + frame->dataSize, target); + for (uint8_t* p = source; p < source + frame->dataSize; p+=3) { + *target++ = p[2]; + *target++ = p[1]; + *target++ = p[0]; + } return; } } diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-FreenectDriver/src/ColorStream.hpp index daf38becf..604be5e32 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.hpp +++ b/OpenNI2-FreenectDriver/src/ColorStream.hpp @@ -2,7 +2,9 @@ #include // for transform() #include // for M_PI -#include "libfreenect.hpp" +#include +#include "libfreenect2.h" +#include "libfreenect2/libfreenect2.hpp" #include "Driver/OniDriverAPI.h" #include "VideoStream.hpp" @@ -18,7 +20,7 @@ namespace FreenectDriver static const float VERTICAL_FOV = 48.6 * (M_PI / 180); private: - typedef std::map< OniVideoMode, std::pair > FreenectVideoModeMap; + typedef std::map< OniVideoMode, std::pair > FreenectVideoModeMap; static const OniSensorType sensor_type = ONI_SENSOR_COLOR; static FreenectVideoModeMap getSupportedVideoModes(); @@ -29,7 +31,7 @@ namespace FreenectDriver bool auto_exposure; public: - ColorStream(Freenect::FreenectDevice* pDevice); + ColorStream(libfreenect2::Freenect2Device* pDevice); //~ColorStream() { } static OniSensorInfo getSensorInfo() @@ -116,6 +118,7 @@ namespace FreenectDriver default: return VideoStream::setProperty(propertyId, data, dataSize); +#if 0 // camera case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool { @@ -150,6 +153,7 @@ namespace FreenectDriver int ret = device->setFlag(FREENECT_MIRROR_VIDEO, mirroring); return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; } +#endif } } }; diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-FreenectDriver/src/DepthStream.cpp index 7159003db..7aadc98cc 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.cpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.cpp @@ -4,12 +4,12 @@ using namespace FreenectDriver; -DepthStream::DepthStream(Freenect::FreenectDevice* pDevice) : VideoStream(pDevice) +DepthStream::DepthStream(libfreenect2::Freenect2Device* pDevice) : VideoStream(pDevice) { - video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30); image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; setVideoMode(video_mode); - pDevice->startDepth(); + pDevice->start(); } // Add video modes here as you implement them @@ -19,7 +19,7 @@ DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() { FreenectDepthModeMap modes; // pixelFormat, resolutionX, resolutionY, fps - modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = std::pair(FREENECT_DEPTH_MM, FREENECT_RESOLUTION_MEDIUM); + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30)] = std::pair(FREENECT2_DEPTH_MM, FREENECT2_RESOLUTION_512x424); return modes; @@ -32,6 +32,7 @@ OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) if (matched_mode_iter == supported_video_modes.end()) return ONI_STATUS_NOT_SUPPORTED; +#if 0 freenect_depth_format format = matched_mode_iter->second.first; freenect_resolution resolution = matched_mode_iter->second.second; if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) // try forcing registration mode @@ -49,6 +50,7 @@ OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) } return ONI_STATUS_NOT_SUPPORTED; } +#endif // 0 video_mode = requested_mode; return ONI_STATUS_OK; } @@ -76,7 +78,7 @@ void DepthStream::populateFrame(void* data, OniFrame* frame) const // copy stream buffer from freenect - uint16_t* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; + float* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; uint16_t* target = static_cast(frame->data); const unsigned int skipWidth = video_mode.resolutionX - frame->width; diff --git a/OpenNI2-FreenectDriver/src/DepthStream.hpp b/OpenNI2-FreenectDriver/src/DepthStream.hpp index 303449ecd..ef76ca644 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.hpp +++ b/OpenNI2-FreenectDriver/src/DepthStream.hpp @@ -3,7 +3,7 @@ #include // for transform() #include // for M_PI #include // for memcpy -#include "libfreenect.hpp" +#include "libfreenect2/libfreenect2.hpp" #include "Driver/OniDriverAPI.h" #include "PS1080.h" #include "VideoStream.hpp" @@ -32,7 +32,7 @@ namespace FreenectDriver static const double EMITTER_DCMOS_DISTANCE_VAL = 7.5; private: - typedef std::map< OniVideoMode, std::pair > FreenectDepthModeMap; + typedef std::map< OniVideoMode, std::pair > FreenectDepthModeMap; static const OniSensorType sensor_type = ONI_SENSOR_DEPTH; OniImageRegistrationMode image_registration_mode; @@ -41,7 +41,7 @@ namespace FreenectDriver void populateFrame(void* data, OniFrame* frame) const; public: - DepthStream(Freenect::FreenectDevice* pDevice); + DepthStream(libfreenect2::Freenect2Device* pDevice); //~DepthStream() { } static OniSensorInfo getSensorInfo() diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index 6a52ff58d..e54d26162 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -17,30 +17,38 @@ #include #include #include "Driver/OniDriverAPI.h" -#include "freenect_internal.h" -#include "libfreenect.hpp" +#include "libfreenect2/libfreenect2.hpp" +#include #include "DepthStream.hpp" #include "ColorStream.hpp" namespace FreenectDriver { - class Device : public oni::driver::DeviceBase, public Freenect::FreenectDevice + class Device : public oni::driver::DeviceBase, public libfreenect2::FrameListener { private: + libfreenect2::Freenect2Device *dev; ColorStream* color; DepthStream* depth; // for Freenect::FreenectDevice - void DepthCallback(void* data, uint32_t timestamp) { - depth->buildFrame(data, timestamp); - } - void VideoCallback(void* data, uint32_t timestamp) { - color->buildFrame(data, timestamp); + bool onNewFrame(libfreenect2::Frame::Type type, libfreenect2::Frame *frame) { + if (type == libfreenect2::Frame::Color) { + if (color) + color->buildFrame(frame->data, 0); // timestamp); + } else + if (type == libfreenect2::Frame::Ir) { + } else + if (type == libfreenect2::Frame::Depth) { + if (depth) + depth->buildFrame(frame->data, 0); // timestamp); + } } public: - Device(freenect_context* fn_ctx, int index) : Freenect::FreenectDevice(fn_ctx, index), + Device(freenect2_context* fn_ctx, int index) : //libfreenect2::Freenect2Device(fn_ctx, index), + dev(NULL), color(NULL), depth(NULL) { } ~Device() @@ -49,6 +57,16 @@ namespace FreenectDriver destroyStream(depth); } + // for Freenect2Device + void setFreenect2Device(libfreenect2::Freenect2Device *dev) { + this->dev = dev; + dev->setColorFrameListener(this); + dev->setIrAndDepthFrameListener(this); + } + void start() { dev->start(); } + void stop() { dev->stop(); } + void close() { dev->close(); } + // for DeviceBase OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return depth->isImageRegistrationModeSupported(mode); } @@ -72,13 +90,15 @@ namespace FreenectDriver return NULL; case ONI_SENSOR_COLOR: if (! color) - color = new ColorStream(this); + color = new ColorStream(dev); return color; case ONI_SENSOR_DEPTH: if (! depth) - depth = new DepthStream(this); + depth = new DepthStream(dev); return depth; // todo: IR + case ONI_SENSOR_IR: + std::cout << "## FreenectDriver::Device::createStream(IR): TODO" << std::endl; } } @@ -87,6 +107,18 @@ namespace FreenectDriver if (pStream == NULL) return; +#if 1 + // destroy them all :-) + dev->stop(); + if (color != NULL) { + delete color; + color = NULL; + } + if (depth != NULL) { + delete depth; + depth = NULL; + } +#else // 0 if (pStream == color) { Freenect::FreenectDevice::stopVideo(); @@ -99,6 +131,7 @@ namespace FreenectDriver delete depth; depth = NULL; } +#endif // 0 } // todo: fill out properties @@ -208,7 +241,7 @@ namespace FreenectDriver }; - class Driver : public oni::driver::DriverBase, private Freenect::Freenect + class Driver : public oni::driver::DriverBase, private libfreenect2::Freenect2 { private: typedef std::map OniDeviceMap; @@ -229,10 +262,13 @@ namespace FreenectDriver public: Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) { - WriteMessage("Using libfreenect v" + to_string(PROJECT_VER)); + //WriteMessage("Using libfreenect v" + to_string(PROJECT_VER)); + WriteMessage("Using libfreenect2"); +#if 0 freenect_set_log_level(m_ctx, FREENECT_LOG_DEBUG); freenect_select_subdevices(m_ctx, FREENECT_DEVICE_CAMERA); // OpenNI2 doesn't use MOTOR or AUDIO +#endif // 0 DriverServices = &getServices(); } ~Driver() { shutdown(); } @@ -242,7 +278,7 @@ namespace FreenectDriver OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); - for (int i = 0; i < Freenect::deviceCount(); i++) + for (int i = 0; i < Freenect2::enumerateDevices(); i++) { std::string uri = devid_to_uri(i); @@ -256,6 +292,7 @@ namespace FreenectDriver deviceConnected(&info); deviceStateChanged(&info, 0); +#if 0 freenect_device* dev; if (freenect_open_device(m_ctx, &dev, i) == 0) { @@ -267,6 +304,7 @@ namespace FreenectDriver { WriteMessage("Unable to open device to query VID/PID"); } +#endif // 0 } return ONI_STATUS_OK; } @@ -285,7 +323,8 @@ namespace FreenectDriver { WriteMessage("Opening device " + std::string(uri)); int id = uri_to_devid(iter->first.uri); - Device* device = &createDevice(id); + Device* device = new Device(NULL, id); + device->setFreenect2Device(openDevice(id)); // XXX, detault pipeline // const PacketPipeline *factory); iter->second = device; return device; } @@ -305,7 +344,9 @@ namespace FreenectDriver WriteMessage("Closing device " + std::string(iter->first.uri)); int id = uri_to_devid(iter->first.uri); devices.erase(iter); - deleteDevice(id); + Device* device = (Device*)iter->second; + device->stop(); + device->close(); return; } } @@ -328,7 +369,9 @@ namespace FreenectDriver { WriteMessage("Closing device " + std::string(iter->first.uri)); int id = uri_to_devid(iter->first.uri); - deleteDevice(id); + Device* device = (Device*)iter->second; + device->stop(); + device->close(); } devices.clear(); diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-FreenectDriver/src/VideoStream.hpp index 0823e7e7f..6c431cc6e 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-FreenectDriver/src/VideoStream.hpp @@ -1,10 +1,12 @@ #pragma once -#include "libfreenect.hpp" +#include +#include +#include "libfreenect2.h" +#include "libfreenect2/libfreenect2.hpp" #include "PS1080.h" #include "Utility.hpp" - namespace FreenectDriver { class VideoStream : public oni::driver::StreamBase @@ -17,14 +19,14 @@ namespace FreenectDriver protected: static const OniSensorType sensor_type; - Freenect::FreenectDevice* device; + libfreenect2::Freenect2Device* device; bool running; // buildFrame() does something iff true OniVideoMode video_mode; OniCropping cropping; bool mirroring; public: - VideoStream(Freenect::FreenectDevice* device) : + VideoStream(libfreenect2::Freenect2Device* device) : frame_id(1), device(device), mirroring(false) From 4f1e7df94ef187b2843b041a5b4183632ee23b84 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 16 May 2015 07:57:04 +0900 Subject: [PATCH 03/20] openni2: Add ItStream class --- OpenNI2-FreenectDriver/src/DeviceDriver.cpp | 34 ++-- OpenNI2-FreenectDriver/src/IrStream.cpp | 93 ++++++++++ OpenNI2-FreenectDriver/src/IrStream.hpp | 195 ++++++++++++++++++++ 3 files changed, 305 insertions(+), 17 deletions(-) create mode 100644 OpenNI2-FreenectDriver/src/IrStream.cpp create mode 100644 OpenNI2-FreenectDriver/src/IrStream.hpp diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp index e54d26162..9acfab0dd 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-FreenectDriver/src/DeviceDriver.cpp @@ -21,6 +21,7 @@ #include #include "DepthStream.hpp" #include "ColorStream.hpp" +#include "IrStream.hpp" namespace FreenectDriver @@ -31,6 +32,7 @@ namespace FreenectDriver libfreenect2::Freenect2Device *dev; ColorStream* color; DepthStream* depth; + IrStream* ir; // for Freenect::FreenectDevice bool onNewFrame(libfreenect2::Frame::Type type, libfreenect2::Frame *frame) { @@ -39,6 +41,8 @@ namespace FreenectDriver color->buildFrame(frame->data, 0); // timestamp); } else if (type == libfreenect2::Frame::Ir) { + if (ir) + ir->buildFrame(frame->data, 0); // timestamp); } else if (type == libfreenect2::Frame::Depth) { if (depth) @@ -50,10 +54,12 @@ namespace FreenectDriver Device(freenect2_context* fn_ctx, int index) : //libfreenect2::Freenect2Device(fn_ctx, index), dev(NULL), color(NULL), + ir(NULL), depth(NULL) { } ~Device() { destroyStream(color); + destroyStream(ir); destroyStream(depth); } @@ -73,10 +79,11 @@ namespace FreenectDriver OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) { - *numSensors = 2; + *numSensors = 3; OniSensorInfo * sensors = new OniSensorInfo[*numSensors]; sensors[0] = depth->getSensorInfo(); sensors[1] = color->getSensorInfo(); + sensors[2] = ir->getSensorInfo(); *pSensors = sensors; return ONI_STATUS_OK; } @@ -96,9 +103,10 @@ namespace FreenectDriver if (! depth) depth = new DepthStream(dev); return depth; - // todo: IR case ONI_SENSOR_IR: - std::cout << "## FreenectDriver::Device::createStream(IR): TODO" << std::endl; + if (! ir) + ir = new IrStream(dev); + return ir; } } @@ -107,31 +115,23 @@ namespace FreenectDriver if (pStream == NULL) return; -#if 1 - // destroy them all :-) + // stop them all dev->stop(); - if (color != NULL) { - delete color; - color = NULL; - } - if (depth != NULL) { - delete depth; - depth = NULL; - } -#else // 0 if (pStream == color) { - Freenect::FreenectDevice::stopVideo(); delete color; color = NULL; } if (pStream == depth) { - Freenect::FreenectDevice::stopDepth(); delete depth; depth = NULL; } -#endif // 0 + if (pStream == ir) + { + delete ir; + ir = NULL; + } } // todo: fill out properties diff --git a/OpenNI2-FreenectDriver/src/IrStream.cpp b/OpenNI2-FreenectDriver/src/IrStream.cpp new file mode 100644 index 000000000..da30a4add --- /dev/null +++ b/OpenNI2-FreenectDriver/src/IrStream.cpp @@ -0,0 +1,93 @@ +#include +#include "IrStream.hpp" + +using namespace FreenectDriver; + + +IrStream::IrStream(libfreenect2::Freenect2Device* pDevice) : VideoStream(pDevice) +{ + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30); + image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; + setVideoMode(video_mode); + pDevice->start(); +} + +// Add video modes here as you implement them +// Note: if image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR, +// setVideoFormat() will try FREENECT_DEPTH_REGISTERED first then fall back on what is set here. +IrStream::FreenectIrModeMap IrStream::getSupportedVideoModes() +{ + FreenectIrModeMap modes; + // pixelFormat, resolutionX, resolutionY, fps + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30)] = std::pair(FREENECT2_IR_RAW, FREENECT2_RESOLUTION_512x424); + + + return modes; +} + +OniStatus IrStream::setVideoMode(OniVideoMode requested_mode) +{ + FreenectIrModeMap supported_video_modes = getSupportedVideoModes(); + FreenectIrModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); + if (matched_mode_iter == supported_video_modes.end()) + return ONI_STATUS_NOT_SUPPORTED; + + video_mode = requested_mode; + return ONI_STATUS_OK; +} + +void IrStream::populateFrame(void* data, OniFrame* frame) const +{ + frame->sensorType = sensor_type; + frame->stride = video_mode.resolutionX * sizeof(uint16_t); + + if (cropping.enabled) + { + frame->height = cropping.height; + frame->width = cropping.width; + frame->cropOriginX = cropping.originX; + frame->cropOriginY = cropping.originY; + frame->croppingEnabled = true; + } + else + { + frame->cropOriginX = 0; + frame->cropOriginY = 0; + frame->croppingEnabled = false; + } + + + // copy stream buffer from freenect + + float* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; + uint16_t* target = static_cast(frame->data); + const unsigned int skipWidth = video_mode.resolutionX - frame->width; + + if (mirroring) + { + target += frame->width; + + for (int y = 0; y < frame->height; y++) + { + for (int x = 0; x < frame->width; x++) + { + *target-- = *source++; + } + + source += skipWidth; + target += 2 * frame->width; + } + } + else + { + for (int y = 0; y < frame->height; y++) + { + for (int x = 0; x < frame->width; x++) + { + *target++ = *source++; + } + + source += skipWidth; + } + } +} diff --git a/OpenNI2-FreenectDriver/src/IrStream.hpp b/OpenNI2-FreenectDriver/src/IrStream.hpp new file mode 100644 index 000000000..08a5c00f0 --- /dev/null +++ b/OpenNI2-FreenectDriver/src/IrStream.hpp @@ -0,0 +1,195 @@ +#pragma once + +#include // for transform() +#include // for M_PI +#include // for memcpy +#include "libfreenect2/libfreenect2.hpp" +#include "Driver/OniDriverAPI.h" +#include "PS1080.h" +#include "VideoStream.hpp" + +namespace FreenectDriver +{ + class IrStream : public VideoStream + { + public: + // from NUI library and converted to radians + static const float DIAGONAL_FOV = 70 * (M_PI / 180); + static const float HORIZONTAL_FOV = 58.5 * (M_PI / 180); + static const float VERTICAL_FOV = 45.6 * (M_PI / 180); + // from DepthKinectStream.cpp + static const int MAX_VALUE = 10000; + static const unsigned long long GAIN_VAL = 42; + static const unsigned long long CONST_SHIFT_VAL = 200; + static const unsigned long long MAX_SHIFT_VAL = 2047; + static const unsigned long long PARAM_COEFF_VAL = 4; + static const unsigned long long SHIFT_SCALE_VAL = 10; + static const unsigned long long ZERO_PLANE_DISTANCE_VAL = 120; + static const double ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; + static const double EMITTER_DCMOS_DISTANCE_VAL = 7.5; + + private: + typedef std::map< OniVideoMode, std::pair > FreenectIrModeMap; + static const OniSensorType sensor_type = ONI_SENSOR_IR; + OniImageRegistrationMode image_registration_mode; + + static FreenectIrModeMap getSupportedVideoModes(); + OniStatus setVideoMode(OniVideoMode requested_mode); + void populateFrame(void* data, OniFrame* frame) const; + + public: + IrStream(libfreenect2::Freenect2Device* pDevice); + //~IrStream() { } + + static OniSensorInfo getSensorInfo() + { + FreenectIrModeMap supported_modes = getSupportedVideoModes(); + OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; + std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); + OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; + return sensors; + } + + OniImageRegistrationMode getImageRegistrationMode() const { return image_registration_mode; } + OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) + { + if (!isImageRegistrationModeSupported(mode)) + return ONI_STATUS_NOT_SUPPORTED; + image_registration_mode = mode; + return setVideoMode(video_mode); + } + + // from StreamBase + OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF || mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR); } + + OniBool isPropertySupported(int propertyId) + { + switch(propertyId) + { + default: + return VideoStream::isPropertySupported(propertyId); + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: + case ONI_STREAM_PROPERTY_VERTICAL_FOV: + case ONI_STREAM_PROPERTY_MAX_VALUE: + case XN_STREAM_PROPERTY_GAIN: + case XN_STREAM_PROPERTY_CONST_SHIFT: + case XN_STREAM_PROPERTY_MAX_SHIFT: + case XN_STREAM_PROPERTY_PARAM_COEFF: + case XN_STREAM_PROPERTY_SHIFT_SCALE: + case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: + case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: + case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: + return true; + } + } + + OniStatus getProperty(int propertyId, void* data, int* pDataSize) + { + switch (propertyId) + { + default: + return VideoStream::getProperty(propertyId, data, pDataSize); + + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_HORIZONTAL_FOV"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = HORIZONTAL_FOV; + return ONI_STATUS_OK; + case ONI_STREAM_PROPERTY_VERTICAL_FOV: // float (radians) + if (*pDataSize != sizeof(float)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_VERTICAL_FOV"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = VERTICAL_FOV; + return ONI_STATUS_OK; + case ONI_STREAM_PROPERTY_MAX_VALUE: // int + if (*pDataSize != sizeof(int)) + { + LogError("Unexpected size for ONI_STREAM_PROPERTY_MAX_VALUE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = MAX_VALUE; + return ONI_STATUS_OK; + + case XN_STREAM_PROPERTY_PIXEL_REGISTRATION: // XnPixelRegistration (get only) + case XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED: // unsigned long long + case XN_STREAM_PROPERTY_HOLE_FILTER: // unsigned long long + case XN_STREAM_PROPERTY_REGISTRATION_TYPE: // XnProcessingType + case XN_STREAM_PROPERTY_AGC_BIN: // XnDepthAGCBin* + case XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR: // unsigned long long + case XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE: // double + case XN_STREAM_PROPERTY_CLOSE_RANGE: // unsigned long long + return ONI_STATUS_NOT_SUPPORTED; + + case XN_STREAM_PROPERTY_GAIN: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_GAIN"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = GAIN_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_CONST_SHIFT: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_CONST_SHIFT"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = CONST_SHIFT_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_MAX_SHIFT: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_MAX_SHIFT"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = MAX_SHIFT_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_PARAM_COEFF: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_PARAM_COEFF"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = PARAM_COEFF_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_SHIFT_SCALE: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_SHIFT_SCALE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = SHIFT_SCALE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: // unsigned long long + if (*pDataSize != sizeof(unsigned long long)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = ZERO_PLANE_DISTANCE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: // double + if (*pDataSize != sizeof(double)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = ZERO_PLANE_PIXEL_SIZE_VAL; + return ONI_STATUS_OK; + case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: // double + if (*pDataSize != sizeof(double)) + { + LogError("Unexpected size for XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE"); + return ONI_STATUS_ERROR; + } + *(static_cast(data)) = EMITTER_DCMOS_DISTANCE_VAL; + return ONI_STATUS_OK; + } + } + }; +} From 7236306194e9fd66e4dd6a3f0c7a8a4c4269390c Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sun, 24 May 2015 13:51:46 +0900 Subject: [PATCH 04/20] openni2: Change name and directory, FreenectDriver -> Freenect2Driver --- .../CMakeLists.txt | 12 ++++++------ .../README.md | 0 .../Include/Android-Arm/OniPlatformAndroid-Arm.h | 0 .../Include/Driver/OniDriverAPI.h | 0 .../Include/Driver/OniDriverTypes.h | 0 .../Include/Linux-Arm/OniPlatformLinux-Arm.h | 0 .../Include/Linux-x86/OniPlatformLinux-x86.h | 0 .../Include/MacOSX/OniPlatformMacOSX.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h | 0 .../Include/OniCProperties.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h | 0 .../Include/OniProperties.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h | 0 .../Include/Win32/OniPlatformWin32.h | 0 .../src/ColorStream.cpp | 4 ++-- .../src/ColorStream.hpp | 4 ++-- .../src/D2S.h | 0 .../src/DepthStream.cpp | 4 ++-- .../src/DepthStream.hpp | 4 ++-- .../src/DeviceDriver.cpp | 8 ++++++-- .../src/IrStream.cpp | 4 ++-- .../src/IrStream.hpp | 4 ++-- .../src/S2D.h | 0 .../src/Utility.hpp | 6 +++--- .../src/VideoStream.hpp | 5 +++-- 32 files changed, 30 insertions(+), 25 deletions(-) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/CMakeLists.txt (81%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/README.md (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/ColorStream.cpp (94%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/ColorStream.hpp (97%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/D2S.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/DepthStream.cpp (96%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/DepthStream.hpp (98%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/DeviceDriver.cpp (98%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/IrStream.cpp (93%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/IrStream.hpp (98%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/S2D.h (100%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/Utility.hpp (93%) rename {OpenNI2-FreenectDriver => OpenNI2-Freenect2Driver}/src/VideoStream.hpp (97%) diff --git a/OpenNI2-FreenectDriver/CMakeLists.txt b/OpenNI2-Freenect2Driver/CMakeLists.txt similarity index 81% rename from OpenNI2-FreenectDriver/CMakeLists.txt rename to OpenNI2-Freenect2Driver/CMakeLists.txt index 475136d57..99ff4fe23 100644 --- a/OpenNI2-FreenectDriver/CMakeLists.txt +++ b/OpenNI2-Freenect2Driver/CMakeLists.txt @@ -1,6 +1,6 @@ -###################################################################################### -# OpenNI2-FreenectDriver -###################################################################################### +############################################################################## +# OpenNI2-Freenect2Driver +############################################################################## file(GLOB HEADERS src/*.hpp src/*.h) file(GLOB SOURCES src/*.cpp) @@ -8,7 +8,7 @@ add_library(Freenect2Driver SHARED ${HEADERS} ${SOURCES}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") -set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-FreenectDriver) +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-Freenect2Driver) set_target_properties(Freenect2Driver PROPERTIES VERSION ${PROJECT_VER} SOVERSION ${PROJECT_APIVER} @@ -16,7 +16,7 @@ set_target_properties(Freenect2Driver PROPERTIES add_definitions(-DPROJECT_VER="${PROJECT_VER}") -include_directories(/opt/OpenNI2/Include) +include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) include_directories(${PROJECT_SOURCE_DIR}/../include) include_directories(${PROJECT_SOURCE_DIR}/../examples/protonect/include) include_directories(${PROJECT_SOURCE_DIR}/src) @@ -25,4 +25,4 @@ include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) target_link_libraries(Freenect2Driver freenect2 ${MATH_LIB}) install (TARGETS Freenect2Driver - DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/OpenNI2-FreenectDriver") + DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/OpenNI2-Freenect2Driver") diff --git a/OpenNI2-FreenectDriver/README.md b/OpenNI2-Freenect2Driver/README.md similarity index 100% rename from OpenNI2-FreenectDriver/README.md rename to OpenNI2-Freenect2Driver/README.md diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h diff --git a/OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h b/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h similarity index 100% rename from OpenNI2-FreenectDriver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h rename to OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h diff --git a/OpenNI2-FreenectDriver/src/ColorStream.cpp b/OpenNI2-Freenect2Driver/src/ColorStream.cpp similarity index 94% rename from OpenNI2-FreenectDriver/src/ColorStream.cpp rename to OpenNI2-Freenect2Driver/src/ColorStream.cpp index df4f98a84..12b462b60 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.cpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -1,10 +1,10 @@ #include #include "ColorStream.hpp" -using namespace FreenectDriver; +using namespace Freenect2Driver; -ColorStream::ColorStream(libfreenect2::Freenect2Device* pDevice) : VideoStream(pDevice) +ColorStream::ColorStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30); setVideoMode(video_mode); diff --git a/OpenNI2-FreenectDriver/src/ColorStream.hpp b/OpenNI2-Freenect2Driver/src/ColorStream.hpp similarity index 97% rename from OpenNI2-FreenectDriver/src/ColorStream.hpp rename to OpenNI2-Freenect2Driver/src/ColorStream.hpp index 604be5e32..e5d4d79b4 100644 --- a/OpenNI2-FreenectDriver/src/ColorStream.hpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -9,7 +9,7 @@ #include "VideoStream.hpp" -namespace FreenectDriver +namespace Freenect2Driver { class ColorStream : public VideoStream { @@ -31,7 +31,7 @@ namespace FreenectDriver bool auto_exposure; public: - ColorStream(libfreenect2::Freenect2Device* pDevice); + ColorStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); //~ColorStream() { } static OniSensorInfo getSensorInfo() diff --git a/OpenNI2-FreenectDriver/src/D2S.h b/OpenNI2-Freenect2Driver/src/D2S.h similarity index 100% rename from OpenNI2-FreenectDriver/src/D2S.h rename to OpenNI2-Freenect2Driver/src/D2S.h diff --git a/OpenNI2-FreenectDriver/src/DepthStream.cpp b/OpenNI2-Freenect2Driver/src/DepthStream.cpp similarity index 96% rename from OpenNI2-FreenectDriver/src/DepthStream.cpp rename to OpenNI2-Freenect2Driver/src/DepthStream.cpp index 7aadc98cc..d538f3105 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.cpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -1,10 +1,10 @@ #include #include "DepthStream.hpp" -using namespace FreenectDriver; +using namespace Freenect2Driver; -DepthStream::DepthStream(libfreenect2::Freenect2Device* pDevice) : VideoStream(pDevice) +DepthStream::DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30); image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; diff --git a/OpenNI2-FreenectDriver/src/DepthStream.hpp b/OpenNI2-Freenect2Driver/src/DepthStream.hpp similarity index 98% rename from OpenNI2-FreenectDriver/src/DepthStream.hpp rename to OpenNI2-Freenect2Driver/src/DepthStream.hpp index ef76ca644..59c51d83d 100644 --- a/OpenNI2-FreenectDriver/src/DepthStream.hpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -11,7 +11,7 @@ #include "D2S.h" -namespace FreenectDriver +namespace Freenect2Driver { class DepthStream : public VideoStream { @@ -41,7 +41,7 @@ namespace FreenectDriver void populateFrame(void* data, OniFrame* frame) const; public: - DepthStream(libfreenect2::Freenect2Device* pDevice); + DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); //~DepthStream() { } static OniSensorInfo getSensorInfo() diff --git a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp similarity index 98% rename from OpenNI2-FreenectDriver/src/DeviceDriver.cpp rename to OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index 9acfab0dd..2b9c0f885 100644 --- a/OpenNI2-FreenectDriver/src/DeviceDriver.cpp +++ b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -14,6 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/** +* OpenNI2 Freenect2 Driver +* Copyright 2015 hanyazou@gmail.com +*/ #include #include #include "Driver/OniDriverAPI.h" @@ -24,7 +28,7 @@ #include "IrStream.hpp" -namespace FreenectDriver +namespace Freenect2Driver { class Device : public oni::driver::DeviceBase, public libfreenect2::FrameListener { @@ -389,6 +393,6 @@ namespace FreenectDriver // macros defined in XnLib (not included) - workaround #define XN_NEW(type, arg...) new type(arg) #define XN_DELETE(p) delete(p) -ONI_EXPORT_DRIVER(FreenectDriver::Driver); +ONI_EXPORT_DRIVER(Freenect2Driver::Driver); #undef XN_NEW #undef XN_DELETE diff --git a/OpenNI2-FreenectDriver/src/IrStream.cpp b/OpenNI2-Freenect2Driver/src/IrStream.cpp similarity index 93% rename from OpenNI2-FreenectDriver/src/IrStream.cpp rename to OpenNI2-Freenect2Driver/src/IrStream.cpp index da30a4add..f35f70a32 100644 --- a/OpenNI2-FreenectDriver/src/IrStream.cpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -1,10 +1,10 @@ #include #include "IrStream.hpp" -using namespace FreenectDriver; +using namespace Freenect2Driver; -IrStream::IrStream(libfreenect2::Freenect2Device* pDevice) : VideoStream(pDevice) +IrStream::IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30); image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; diff --git a/OpenNI2-FreenectDriver/src/IrStream.hpp b/OpenNI2-Freenect2Driver/src/IrStream.hpp similarity index 98% rename from OpenNI2-FreenectDriver/src/IrStream.hpp rename to OpenNI2-Freenect2Driver/src/IrStream.hpp index 08a5c00f0..2f9f3defd 100644 --- a/OpenNI2-FreenectDriver/src/IrStream.hpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -8,7 +8,7 @@ #include "PS1080.h" #include "VideoStream.hpp" -namespace FreenectDriver +namespace Freenect2Driver { class IrStream : public VideoStream { @@ -38,7 +38,7 @@ namespace FreenectDriver void populateFrame(void* data, OniFrame* frame) const; public: - IrStream(libfreenect2::Freenect2Device* pDevice); + IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); //~IrStream() { } static OniSensorInfo getSensorInfo() diff --git a/OpenNI2-FreenectDriver/src/S2D.h b/OpenNI2-Freenect2Driver/src/S2D.h similarity index 100% rename from OpenNI2-FreenectDriver/src/S2D.h rename to OpenNI2-Freenect2Driver/src/S2D.h diff --git a/OpenNI2-FreenectDriver/src/Utility.hpp b/OpenNI2-Freenect2Driver/src/Utility.hpp similarity index 93% rename from OpenNI2-FreenectDriver/src/Utility.hpp rename to OpenNI2-Freenect2Driver/src/Utility.hpp index 531be112d..f9d5e39ac 100644 --- a/OpenNI2-FreenectDriver/src/Utility.hpp +++ b/OpenNI2-Freenect2Driver/src/Utility.hpp @@ -54,11 +54,11 @@ static std::string to_string(const T& n) // global logging -namespace FreenectDriver +namespace Freenect2Driver { static void WriteMessage(std::string info) { - std::cout << "OpenNI2-FreenectDriver: " << info << std::endl; + std::cout << "OpenNI2-Freenect2Driver: " << info << std::endl; } // DriverServices is set in DeviceDriver.cpp so all files can call errorLoggerAppend() @@ -69,6 +69,6 @@ namespace FreenectDriver WriteMessage("(ERROR) " + error); if (DriverServices != NULL) - DriverServices->errorLoggerAppend(std::string("OpenNI2-FreenectDriver: " + error).c_str()); + DriverServices->errorLoggerAppend(std::string("OpenNI2-Freenect2Driver: " + error).c_str()); } } diff --git a/OpenNI2-FreenectDriver/src/VideoStream.hpp b/OpenNI2-Freenect2Driver/src/VideoStream.hpp similarity index 97% rename from OpenNI2-FreenectDriver/src/VideoStream.hpp rename to OpenNI2-Freenect2Driver/src/VideoStream.hpp index 6c431cc6e..d6eecc4d6 100644 --- a/OpenNI2-FreenectDriver/src/VideoStream.hpp +++ b/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -7,7 +7,7 @@ #include "PS1080.h" #include "Utility.hpp" -namespace FreenectDriver +namespace Freenect2Driver { class VideoStream : public oni::driver::StreamBase { @@ -24,9 +24,10 @@ namespace FreenectDriver OniVideoMode video_mode; OniCropping cropping; bool mirroring; + Freenect2Driver::Registration* reg; public: - VideoStream(libfreenect2::Freenect2Device* device) : + VideoStream(libfreenect2::Freenect2Device* device, Freenect2Driver::Registration* reg) : frame_id(1), device(device), mirroring(false) From f6e4a73fb488f3eeb62b148160a18b844a4e81a9 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sun, 31 May 2015 22:12:21 +0900 Subject: [PATCH 05/20] openni2: Change depth video mode from 512x424 to 640x480 to work with the NiTE --- OpenNI2-Freenect2Driver/src/ColorStream.cpp | 19 +-- OpenNI2-Freenect2Driver/src/ColorStream.hpp | 12 +- OpenNI2-Freenect2Driver/src/DepthStream.cpp | 82 ++---------- OpenNI2-Freenect2Driver/src/DepthStream.hpp | 2 +- OpenNI2-Freenect2Driver/src/DeviceDriver.cpp | 132 +++++++++++++++---- OpenNI2-Freenect2Driver/src/IrStream.cpp | 57 +------- OpenNI2-Freenect2Driver/src/IrStream.hpp | 2 +- OpenNI2-Freenect2Driver/src/VideoStream.hpp | 70 ++++++++-- 8 files changed, 201 insertions(+), 175 deletions(-) diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/OpenNI2-Freenect2Driver/src/ColorStream.cpp index 12b462b60..46964768f 100644 --- a/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -16,9 +16,9 @@ ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() { FreenectVideoModeMap modes; // pixelFormat, resolutionX, resolutionY, fps freenect_video_format, freenect_resolution + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 512, 424, 30)] = std::pair(FREENECT2_VIDEO_RGB, FREENECT2_RESOLUTION_1920x1080); modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30)] = std::pair(FREENECT2_VIDEO_RGB, FREENECT2_RESOLUTION_1920x1080); - return modes; /* working format possiblities @@ -50,13 +50,10 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) return ONI_STATUS_OK; } -void ColorStream::populateFrame(void* data, OniFrame* frame) const +void ColorStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const { - frame->sensorType = sensor_type; - frame->stride = video_mode.resolutionX * 3; - frame->cropOriginX = 0; - frame->cropOriginY = 0; - frame->croppingEnabled = false; + dstFrame->sensorType = sensor_type; + dstFrame->stride = dstFrame->width * 3; // copy stream buffer from freenect switch (video_mode.pixelFormat) @@ -66,13 +63,7 @@ void ColorStream::populateFrame(void* data, OniFrame* frame) const return; case ONI_PIXEL_FORMAT_RGB888: - uint8_t* source = static_cast(data); - uint8_t* target = static_cast(frame->data); - for (uint8_t* p = source; p < source + frame->dataSize; p+=3) { - *target++ = p[2]; - *target++ = p[1]; - *target++ = p[0]; - } + reg->colorFrameRGB888(srcFrame, dstFrame); return; } } diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/OpenNI2-Freenect2Driver/src/ColorStream.hpp index e5d4d79b4..95a4d6bbf 100644 --- a/OpenNI2-Freenect2Driver/src/ColorStream.hpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -25,7 +25,7 @@ namespace Freenect2Driver static FreenectVideoModeMap getSupportedVideoModes(); OniStatus setVideoMode(OniVideoMode requested_mode); - void populateFrame(void* data, OniFrame* frame) const; + void populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const; bool auto_white_balance; bool auto_exposure; @@ -43,6 +43,16 @@ namespace Freenect2Driver return sensors; } + OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) + { + if (mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { + // XXX, switch color resolution to 512x424 for registrarion here + OniVideoMode video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 512, 424, 30); + setProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, &video_mode, sizeof(video_mode)); + } + return ONI_STATUS_OK; + } + // from StreamBase OniBool isPropertySupported(int propertyId) { diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/OpenNI2-Freenect2Driver/src/DepthStream.cpp index d538f3105..709f813d2 100644 --- a/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -6,7 +6,8 @@ using namespace Freenect2Driver; DepthStream::DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { - video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30); + //video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30); + video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; setVideoMode(video_mode); pDevice->start(); @@ -19,9 +20,9 @@ DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() { FreenectDepthModeMap modes; // pixelFormat, resolutionX, resolutionY, fps + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = std::pair(FREENECT2_DEPTH_MM, FREENECT2_RESOLUTION_512x424); modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30)] = std::pair(FREENECT2_DEPTH_MM, FREENECT2_RESOLUTION_512x424); - return modes; } @@ -55,79 +56,18 @@ OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) return ONI_STATUS_OK; } -void DepthStream::populateFrame(void* data, OniFrame* frame) const +void DepthStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const { - frame->sensorType = sensor_type; - frame->stride = video_mode.resolutionX * sizeof(uint16_t); - - if (cropping.enabled) - { - frame->height = cropping.height; - frame->width = cropping.width; - frame->cropOriginX = cropping.originX; - frame->cropOriginY = cropping.originY; - frame->croppingEnabled = true; - } - else - { - frame->cropOriginX = 0; - frame->cropOriginY = 0; - frame->croppingEnabled = false; - } + dstFrame->sensorType = sensor_type; + dstFrame->stride = dstFrame->width * sizeof(uint16_t); + // XXX, save depth map for registration + reg->depthFrame(srcFrame); // copy stream buffer from freenect - - float* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; - uint16_t* target = static_cast(frame->data); - const unsigned int skipWidth = video_mode.resolutionX - frame->width; - - if (mirroring) - { - target += frame->width; - - for (int y = 0; y < frame->height; y++) - { - for (int x = 0; x < frame->width; x++) - { - *target-- = *source++; - } - - source += skipWidth; - target += 2 * frame->width; - } - } - else - { - for (int y = 0; y < frame->height; y++) - { - for (int x = 0; x < frame->width; x++) - { - *target++ = *source++; - } - - source += skipWidth; - } - } - - /* - uint16_t* data_ptr = static_cast(data); - uint16_t* frame_data = static_cast(frame->data); - if (mirroring) - { - for (unsigned int i = 0; i < frame->dataSize / 2; i++) - { - // find corresponding mirrored pixel - unsigned int row = i / video_mode.resolutionX; - unsigned int col = video_mode.resolutionX - (i % video_mode.resolutionX); - unsigned int target = (row * video_mode.resolutionX) + col; - // copy it to this pixel - frame_data[i] = data_ptr[target]; - } - } - else - std::copy(data_ptr, data_ptr+frame->dataSize / 2, frame_data); - */ + copyFrame(static_cast((void*)srcFrame->data), srcX, srcY, srcFrame->width, + static_cast(dstFrame->data), dstX, dstY, dstFrame->width, + width, height, mirroring); } diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/OpenNI2-Freenect2Driver/src/DepthStream.hpp index 59c51d83d..ef7b8d98a 100644 --- a/OpenNI2-Freenect2Driver/src/DepthStream.hpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -38,7 +38,7 @@ namespace Freenect2Driver static FreenectDepthModeMap getSupportedVideoModes(); OniStatus setVideoMode(OniVideoMode requested_mode); - void populateFrame(void* data, OniFrame* frame) const; + void populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const; public: DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); diff --git a/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index 2b9c0f885..85f1826a3 100644 --- a/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -20,6 +20,8 @@ */ #include #include +#include +#include #include "Driver/OniDriverAPI.h" #include "libfreenect2/libfreenect2.hpp" #include @@ -30,6 +32,8 @@ namespace Freenect2Driver { + typedef std::map ConfigStrings; + class Device : public oni::driver::DeviceBase, public libfreenect2::FrameListener { private: @@ -37,20 +41,44 @@ namespace Freenect2Driver ColorStream* color; DepthStream* depth; IrStream* ir; + Registration *reg; + ConfigStrings config; + + struct timeval ts_epoc; + long getTimestamp() { + struct timeval ts; + gettimeofday(&ts, NULL); + return (ts.tv_sec - ts_epoc.tv_sec) * 1000 + ts.tv_usec / 1000; // XXX, ignoring nsec of the epoc. + } // for Freenect::FreenectDevice bool onNewFrame(libfreenect2::Frame::Type type, libfreenect2::Frame *frame) { if (type == libfreenect2::Frame::Color) { if (color) - color->buildFrame(frame->data, 0); // timestamp); + color->buildFrame(frame, getTimestamp()); } else if (type == libfreenect2::Frame::Ir) { if (ir) - ir->buildFrame(frame->data, 0); // timestamp); + ir->buildFrame(frame, getTimestamp()); } else if (type == libfreenect2::Frame::Depth) { if (depth) - depth->buildFrame(frame->data, 0); // timestamp); + depth->buildFrame(frame, getTimestamp()); + } + } + + OniStatus setStreamProperties(VideoStream* stream, std::string pfx) + { + pfx += '-'; + OniStatus res = ONI_STATUS_OK, tmp_res; + if (config.find(pfx + "size") != config.end()) { + WriteMessage("setStreamProperty: " + pfx + "size: " + config[pfx + "size"]); + std::string size(config[pfx + "size"]); + int i = size.find("x"); + OniVideoMode video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, std::stoi(size.substr(0, i)), std::stoi(size.substr(i + 1)), 30); + tmp_res = stream->setProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, (void*)&video_mode, sizeof(video_mode)); + if (tmp_res != ONI_STATUS_OK) + res = tmp_res; } } @@ -73,6 +101,9 @@ namespace Freenect2Driver dev->setColorFrameListener(this); dev->setIrAndDepthFrameListener(this); } + void setConfigStrings(ConfigStrings& config) { + this->config = config; + } void start() { dev->start(); } void stop() { dev->stop(); } void close() { dev->close(); } @@ -100,16 +131,22 @@ namespace Freenect2Driver LogError("Cannot create a stream of type " + to_string(sensorType)); return NULL; case ONI_SENSOR_COLOR: - if (! color) - color = new ColorStream(dev); + if (! color) { + color = new ColorStream(dev, reg); + setStreamProperties(color, "color"); + } return color; case ONI_SENSOR_DEPTH: - if (! depth) - depth = new DepthStream(dev); + if (! depth) { + depth = new DepthStream(dev, reg); + setStreamProperties(depth, "depth"); + } return depth; case ONI_SENSOR_IR: - if (! ir) - ir = new IrStream(dev); + if (! ir) { + ir = new IrStream(dev, reg); + setStreamProperties(ir, "ir"); + } return ir; } } @@ -214,7 +251,9 @@ namespace Freenect2Driver LogError("Unexpected size for ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION"); return ONI_STATUS_ERROR; } - return depth->setImageRegistrationMode(*(static_cast(data))); + OniImageRegistrationMode mode = *(static_cast(data)); + color->setImageRegistrationMode(mode); + return depth->setImageRegistrationMode(mode); } } @@ -250,21 +289,38 @@ namespace Freenect2Driver private: typedef std::map OniDeviceMap; OniDeviceMap devices; + std::string uriScheme; + ConfigStrings config; - static std::string devid_to_uri(int id) { - return "freenect://" + to_string(id); + std::string devid_to_uri(int id) { + return uriScheme + "://" + to_string(id); } - static int uri_to_devid(const std::string uri) { + int uri_to_devid(const std::string uri) { int id; std::istringstream is(uri); - is.seekg(strlen("freenect://")); + is.seekg((uriScheme + "://").length()); is >> id; return id; } + void register_uri(std::string uri) { + OniDeviceInfo info; + strncpy(info.uri, uri.c_str(), ONI_MAX_STR); + strncpy(info.vendor, "Microsoft", ONI_MAX_STR); + //strncpy(info.name, "Kinect 2", ONI_MAX_STR); // XXX, NiTE does not accept new name + strncpy(info.name, "Kinect", ONI_MAX_STR); + if (devices.find(info) == devices.end()) { + WriteMessage("Driver: register new uri: " + uri); + devices[info] = NULL; + deviceConnected(&info); + deviceStateChanged(&info, 0); + } + } + public: - Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) + Driver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices), + uriScheme("freenect2") { //WriteMessage("Using libfreenect v" + to_string(PROJECT_VER)); WriteMessage("Using libfreenect2"); @@ -285,16 +341,17 @@ namespace Freenect2Driver for (int i = 0; i < Freenect2::enumerateDevices(); i++) { std::string uri = devid_to_uri(i); + std::array modes = { + "", + "?depth-size=640x480", + "?depth-size=512x424", + }; WriteMessage("Found device " + uri); - - OniDeviceInfo info; - strncpy(info.uri, uri.c_str(), ONI_MAX_STR); - strncpy(info.vendor, "Microsoft", ONI_MAX_STR); - strncpy(info.name, "Kinect", ONI_MAX_STR); - devices[info] = NULL; - deviceConnected(&info); - deviceStateChanged(&info, 0); + + for (int i = 0; i < modes.size(); i++) { + register_uri(uri + modes[i]); + } #if 0 freenect_device* dev; @@ -313,11 +370,34 @@ namespace Freenect2Driver return ONI_STATUS_OK; } - oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode = NULL) + oni::driver::DeviceBase* deviceOpen(const char* c_uri, const char* c_mode = NULL) { + std::string uri(c_uri); + std::string mode(c_mode ? c_mode : ""); + if (uri.find("?") != -1) { + mode += "&"; + mode += uri.substr(uri.find("?") + 1); + uri = uri.substr(0, uri.find("?")); + } + std::stringstream ss(mode); + std::string buf; + while(std::getline(ss, buf, '&')) { + if (buf.find("=") != -1) { + config[buf.substr(0, buf.find("="))] = buf.substr(buf.find("=")+1); + } else { + if (0 < buf.length()) + config[buf] = ""; + } + } + WriteMessage("deiveOpen: " + uri); + for (std::map::iterator it = config.begin(); it != config.end(); it++) { + WriteMessage(" " + it->first + " = " + it->second); + } + for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) { - if (strcmp(iter->first.uri, uri) == 0) // found + std::string iter_uri(iter->first.uri); + if (iter_uri.substr(0, iter_uri.find("?")) == uri) // found { if (iter->second) // already open { @@ -329,6 +409,7 @@ namespace Freenect2Driver int id = uri_to_devid(iter->first.uri); Device* device = new Device(NULL, id); device->setFreenect2Device(openDevice(id)); // XXX, detault pipeline // const PacketPipeline *factory); + device->setConfigStrings(config); iter->second = device; return device; } @@ -364,6 +445,7 @@ namespace Freenect2Driver if (! device) return ONI_STATUS_ERROR; deviceClose(device); + register_uri(std::string(uri)); // XXX, register new uri here. return ONI_STATUS_OK; } diff --git a/OpenNI2-Freenect2Driver/src/IrStream.cpp b/OpenNI2-Freenect2Driver/src/IrStream.cpp index f35f70a32..903877f9d 100644 --- a/OpenNI2-Freenect2Driver/src/IrStream.cpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -36,58 +36,13 @@ OniStatus IrStream::setVideoMode(OniVideoMode requested_mode) return ONI_STATUS_OK; } -void IrStream::populateFrame(void* data, OniFrame* frame) const +void IrStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const { - frame->sensorType = sensor_type; - frame->stride = video_mode.resolutionX * sizeof(uint16_t); - - if (cropping.enabled) - { - frame->height = cropping.height; - frame->width = cropping.width; - frame->cropOriginX = cropping.originX; - frame->cropOriginY = cropping.originY; - frame->croppingEnabled = true; - } - else - { - frame->cropOriginX = 0; - frame->cropOriginY = 0; - frame->croppingEnabled = false; - } - + dstFrame->sensorType = sensor_type; + dstFrame->stride = dstFrame->width * sizeof(uint16_t); // copy stream buffer from freenect - - float* source = static_cast(data) + frame->cropOriginX + frame->cropOriginY * video_mode.resolutionX; - uint16_t* target = static_cast(frame->data); - const unsigned int skipWidth = video_mode.resolutionX - frame->width; - - if (mirroring) - { - target += frame->width; - - for (int y = 0; y < frame->height; y++) - { - for (int x = 0; x < frame->width; x++) - { - *target-- = *source++; - } - - source += skipWidth; - target += 2 * frame->width; - } - } - else - { - for (int y = 0; y < frame->height; y++) - { - for (int x = 0; x < frame->width; x++) - { - *target++ = *source++; - } - - source += skipWidth; - } - } + copyFrame(static_cast((void*)srcFrame->data), srcX, srcY, srcFrame->width, + static_cast(dstFrame->data), dstX, dstY, dstFrame->width, + width, height, mirroring); } diff --git a/OpenNI2-Freenect2Driver/src/IrStream.hpp b/OpenNI2-Freenect2Driver/src/IrStream.hpp index 2f9f3defd..9686380d4 100644 --- a/OpenNI2-Freenect2Driver/src/IrStream.hpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -35,7 +35,7 @@ namespace Freenect2Driver static FreenectIrModeMap getSupportedVideoModes(); OniStatus setVideoMode(OniVideoMode requested_mode); - void populateFrame(void* data, OniFrame* frame) const; + void populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const; public: IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); diff --git a/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/OpenNI2-Freenect2Driver/src/VideoStream.hpp index d6eecc4d6..780ffc27a 100644 --- a/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -15,7 +15,7 @@ namespace Freenect2Driver unsigned int frame_id; // number each frame virtual OniStatus setVideoMode(OniVideoMode requested_mode) = 0; - virtual void populateFrame(void* data, OniFrame* frame) const = 0; + virtual void populateFrame(libfreenect2::Frame* lf2Frame, int srcX, int srcY, OniFrame* oniFrame, int tgtX, int tgtY, int width, int height) const = 0; protected: static const OniSensorType sensor_type; @@ -25,11 +25,37 @@ namespace Freenect2Driver OniCropping cropping; bool mirroring; Freenect2Driver::Registration* reg; + bool callPropertyChangedCallback; + + static void copyFrame(float* srcPix, int srcX, int srcY, int srcStride, uint16_t* dstPix, int dstX, int dstY, int dstStride, int width, int height, bool mirroring) + { + srcPix += srcX + srcY * srcStride; + dstPix += dstX + dstY * dstStride; + + for (int y = 0; y < height; y++) { + uint16_t* dst = dstPix + y * dstStride; + float* src = srcPix + y * srcStride; + if (mirroring) { + dst += width; + for (int x = 0; x < width; x++) + *dst-- = *src++; + } else { + for (int x = 0; x < width; x++) + *dst++ = *src++; + } + } + } + void raisePropertyChanged(int propertyId, const void* data, int dataSize) { + if (callPropertyChangedCallback) + StreamBase::raisePropertyChanged(propertyId, data, dataSize); + } public: VideoStream(libfreenect2::Freenect2Device* device, Freenect2Driver::Registration* reg) : frame_id(1), device(device), + reg(reg), + callPropertyChangedCallback(false), mirroring(false) { // joy of structs @@ -38,21 +64,43 @@ namespace Freenect2Driver } //~VideoStream() { stop(); } - void buildFrame(void* data, uint32_t timestamp) + void setPropertyChangedCallback(oni::driver::PropertyChangedCallback handler, void* pCookie) { + callPropertyChangedCallback = true; + StreamBase::setPropertyChangedCallback(handler, pCookie); + } + + void buildFrame(libfreenect2::Frame* lf2Frame, uint32_t timestamp) { if (!running) return; - OniFrame* frame = getServices().acquireFrame(); - frame->frameIndex = frame_id++; - frame->timestamp = timestamp; - frame->videoMode = video_mode; - frame->width = video_mode.resolutionX; - frame->height = video_mode.resolutionY; + OniFrame* oniFrame = getServices().acquireFrame(); + oniFrame->frameIndex = frame_id++; + oniFrame->timestamp = timestamp; + oniFrame->videoMode = video_mode; + oniFrame->width = video_mode.resolutionX; + oniFrame->height = video_mode.resolutionY; + + if (cropping.enabled) + { + oniFrame->height = cropping.height; + oniFrame->width = cropping.width; + oniFrame->cropOriginX = cropping.originX; + oniFrame->cropOriginY = cropping.originY; + oniFrame->croppingEnabled = true; + } + else + { + oniFrame->cropOriginX = 0; + oniFrame->cropOriginY = 0; + oniFrame->croppingEnabled = false; + } + int width = std::min(oniFrame->width, (int)lf2Frame->width); + int height = std::min(oniFrame->height, (int)lf2Frame->height); - populateFrame(data, frame); - raiseNewFrame(frame); - getServices().releaseFrame(frame); + populateFrame(lf2Frame, oniFrame->cropOriginX, oniFrame->cropOriginY, oniFrame, 0, 0, width, height); + raiseNewFrame(oniFrame); + getServices().releaseFrame(oniFrame); } // from StreamBase From 7e7493b7392a7aeac26cb240071fc6a4d8639de1 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 6 Jun 2015 10:04:20 +0900 Subject: [PATCH 06/20] openni2: Eliminate compile warnings in OpenNI2-Freenect2Driver --- OpenNI2-Freenect2Driver/src/ColorStream.cpp | 4 ++++ OpenNI2-Freenect2Driver/src/ColorStream.hpp | 6 +++--- OpenNI2-Freenect2Driver/src/DepthStream.cpp | 14 ++++++++++++++ OpenNI2-Freenect2Driver/src/DepthStream.hpp | 10 +++++----- OpenNI2-Freenect2Driver/src/DeviceDriver.cpp | 10 +++++++--- OpenNI2-Freenect2Driver/src/IrStream.cpp | 14 ++++++++++++++ OpenNI2-Freenect2Driver/src/IrStream.hpp | 10 +++++----- OpenNI2-Freenect2Driver/src/VideoStream.hpp | 6 ++++-- 8 files changed, 56 insertions(+), 18 deletions(-) diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/OpenNI2-Freenect2Driver/src/ColorStream.cpp index 46964768f..b49510ebe 100644 --- a/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -3,6 +3,10 @@ using namespace Freenect2Driver; +// from NUI library & converted to radians +const float ColorStream::DIAGONAL_FOV = 73.9 * (M_PI / 180); +const float ColorStream::HORIZONTAL_FOV = 62 * (M_PI / 180); +const float ColorStream::VERTICAL_FOV = 48.6 * (M_PI / 180); ColorStream::ColorStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/OpenNI2-Freenect2Driver/src/ColorStream.hpp index 95a4d6bbf..fceede6a2 100644 --- a/OpenNI2-Freenect2Driver/src/ColorStream.hpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -15,9 +15,9 @@ namespace Freenect2Driver { public: // from NUI library & converted to radians - static const float DIAGONAL_FOV = 73.9 * (M_PI / 180); - static const float HORIZONTAL_FOV = 62 * (M_PI / 180); - static const float VERTICAL_FOV = 48.6 * (M_PI / 180); + static const float DIAGONAL_FOV; + static const float HORIZONTAL_FOV; + static const float VERTICAL_FOV; private: typedef std::map< OniVideoMode, std::pair > FreenectVideoModeMap; diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/OpenNI2-Freenect2Driver/src/DepthStream.cpp index 709f813d2..cea592aef 100644 --- a/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -3,6 +3,20 @@ using namespace Freenect2Driver; +// from NUI library and converted to radians +const float DepthStream::DIAGONAL_FOV = 70 * (M_PI / 180); +const float DepthStream::HORIZONTAL_FOV = 58.5 * (M_PI / 180); +const float DepthStream::VERTICAL_FOV = 45.6 * (M_PI / 180); +// from DepthKinectStream.cpp +const int DepthStream::MAX_VALUE; +const unsigned long long DepthStream::GAIN_VAL; +const unsigned long long DepthStream::CONST_SHIFT_VAL; +const unsigned long long DepthStream::MAX_SHIFT_VAL; +const unsigned long long DepthStream::PARAM_COEFF_VAL; +const unsigned long long DepthStream::SHIFT_SCALE_VAL; +const unsigned long long DepthStream::ZERO_PLANE_DISTANCE_VAL; +const double DepthStream::ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; +const double DepthStream::EMITTER_DCMOS_DISTANCE_VAL = 7.5; DepthStream::DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/OpenNI2-Freenect2Driver/src/DepthStream.hpp index ef7b8d98a..6ed966315 100644 --- a/OpenNI2-Freenect2Driver/src/DepthStream.hpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -17,9 +17,9 @@ namespace Freenect2Driver { public: // from NUI library and converted to radians - static const float DIAGONAL_FOV = 70 * (M_PI / 180); - static const float HORIZONTAL_FOV = 58.5 * (M_PI / 180); - static const float VERTICAL_FOV = 45.6 * (M_PI / 180); + static const float DIAGONAL_FOV; + static const float HORIZONTAL_FOV; + static const float VERTICAL_FOV; // from DepthKinectStream.cpp static const int MAX_VALUE = 10000; static const unsigned long long GAIN_VAL = 42; @@ -28,8 +28,8 @@ namespace Freenect2Driver static const unsigned long long PARAM_COEFF_VAL = 4; static const unsigned long long SHIFT_SCALE_VAL = 10; static const unsigned long long ZERO_PLANE_DISTANCE_VAL = 120; - static const double ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; - static const double EMITTER_DCMOS_DISTANCE_VAL = 7.5; + static const double ZERO_PLANE_PIXEL_SIZE_VAL; + static const double EMITTER_DCMOS_DISTANCE_VAL; private: typedef std::map< OniVideoMode, std::pair > FreenectDepthModeMap; diff --git a/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index 85f1826a3..9cb8d6b31 100644 --- a/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -55,16 +55,18 @@ namespace Freenect2Driver bool onNewFrame(libfreenect2::Frame::Type type, libfreenect2::Frame *frame) { if (type == libfreenect2::Frame::Color) { if (color) - color->buildFrame(frame, getTimestamp()); + return color->buildFrame(frame, getTimestamp()); } else if (type == libfreenect2::Frame::Ir) { if (ir) - ir->buildFrame(frame, getTimestamp()); + return ir->buildFrame(frame, getTimestamp()); } else if (type == libfreenect2::Frame::Depth) { if (depth) - depth->buildFrame(frame, getTimestamp()); + return depth->buildFrame(frame, getTimestamp()); } + + return false; } OniStatus setStreamProperties(VideoStream* stream, std::string pfx) @@ -80,6 +82,8 @@ namespace Freenect2Driver if (tmp_res != ONI_STATUS_OK) res = tmp_res; } + + return res; } public: diff --git a/OpenNI2-Freenect2Driver/src/IrStream.cpp b/OpenNI2-Freenect2Driver/src/IrStream.cpp index 903877f9d..06df16e15 100644 --- a/OpenNI2-Freenect2Driver/src/IrStream.cpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -3,6 +3,20 @@ using namespace Freenect2Driver; +// from NUI library and converted to radians +const float IrStream::DIAGONAL_FOV = 70 * (M_PI / 180); +const float IrStream::HORIZONTAL_FOV = 58.5 * (M_PI / 180); +const float IrStream::VERTICAL_FOV = 45.6 * (M_PI / 180); +// from DepthKinectStream.cpp +const int IrStream::MAX_VALUE; +const unsigned long long IrStream::GAIN_VAL; +const unsigned long long IrStream::CONST_SHIFT_VAL; +const unsigned long long IrStream::MAX_SHIFT_VAL; +const unsigned long long IrStream::PARAM_COEFF_VAL; +const unsigned long long IrStream::SHIFT_SCALE_VAL; +const unsigned long long IrStream::ZERO_PLANE_DISTANCE_VAL; +const double IrStream::ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; +const double IrStream::EMITTER_DCMOS_DISTANCE_VAL = 7.5; IrStream::IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { diff --git a/OpenNI2-Freenect2Driver/src/IrStream.hpp b/OpenNI2-Freenect2Driver/src/IrStream.hpp index 9686380d4..fe46f64f2 100644 --- a/OpenNI2-Freenect2Driver/src/IrStream.hpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -14,9 +14,9 @@ namespace Freenect2Driver { public: // from NUI library and converted to radians - static const float DIAGONAL_FOV = 70 * (M_PI / 180); - static const float HORIZONTAL_FOV = 58.5 * (M_PI / 180); - static const float VERTICAL_FOV = 45.6 * (M_PI / 180); + static const float DIAGONAL_FOV; + static const float HORIZONTAL_FOV; + static const float VERTICAL_FOV; // from DepthKinectStream.cpp static const int MAX_VALUE = 10000; static const unsigned long long GAIN_VAL = 42; @@ -25,8 +25,8 @@ namespace Freenect2Driver static const unsigned long long PARAM_COEFF_VAL = 4; static const unsigned long long SHIFT_SCALE_VAL = 10; static const unsigned long long ZERO_PLANE_DISTANCE_VAL = 120; - static const double ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; - static const double EMITTER_DCMOS_DISTANCE_VAL = 7.5; + static const double ZERO_PLANE_PIXEL_SIZE_VAL; + static const double EMITTER_DCMOS_DISTANCE_VAL; private: typedef std::map< OniVideoMode, std::pair > FreenectIrModeMap; diff --git a/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/OpenNI2-Freenect2Driver/src/VideoStream.hpp index 780ffc27a..df363a9cd 100644 --- a/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -69,10 +69,10 @@ namespace Freenect2Driver StreamBase::setPropertyChangedCallback(handler, pCookie); } - void buildFrame(libfreenect2::Frame* lf2Frame, uint32_t timestamp) + bool buildFrame(libfreenect2::Frame* lf2Frame, uint32_t timestamp) { if (!running) - return; + return false; OniFrame* oniFrame = getServices().acquireFrame(); oniFrame->frameIndex = frame_id++; @@ -101,6 +101,8 @@ namespace Freenect2Driver populateFrame(lf2Frame, oniFrame->cropOriginX, oniFrame->cropOriginY, oniFrame, 0, 0, width, height); raiseNewFrame(oniFrame); getServices().releaseFrame(oniFrame); + + return false; } // from StreamBase From cd4a96d045a8ea54a8987e68fe9f07f0b87ef4ed Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 23 May 2015 22:17:17 +0900 Subject: [PATCH 07/20] openni2: Add registration --- OpenNI2-Freenect2Driver/src/ColorStream.cpp | 39 ++++++++- OpenNI2-Freenect2Driver/src/ColorStream.hpp | 2 + OpenNI2-Freenect2Driver/src/DepthStream.cpp | 6 +- OpenNI2-Freenect2Driver/src/DepthStream.hpp | 1 + OpenNI2-Freenect2Driver/src/DeviceDriver.cpp | 83 +++++++++++++++----- OpenNI2-Freenect2Driver/src/IrStream.cpp | 3 - OpenNI2-Freenect2Driver/src/IrStream.hpp | 12 --- OpenNI2-Freenect2Driver/src/Registration.cpp | 43 ++++++++++ OpenNI2-Freenect2Driver/src/Registration.hpp | 20 +++++ OpenNI2-Freenect2Driver/src/VideoStream.hpp | 1 + 10 files changed, 172 insertions(+), 38 deletions(-) create mode 100644 OpenNI2-Freenect2Driver/src/Registration.cpp create mode 100644 OpenNI2-Freenect2Driver/src/Registration.hpp diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/OpenNI2-Freenect2Driver/src/ColorStream.cpp index b49510ebe..55bb1efab 100644 --- a/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -67,11 +67,48 @@ void ColorStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int src return; case ONI_PIXEL_FORMAT_RGB888: - reg->colorFrameRGB888(srcFrame, dstFrame); + if (reg->isEnabled()) { + libfreenect2::Frame registered(512, 424, 3); + + reg->colorFrameRGB888(srcFrame, ®istered); + + copyFrame(static_cast(registered.data), srcX, srcY, registered.width * registered.bytes_per_pixel, + static_cast(dstFrame->data), dstX, dstY, dstFrame->stride, + width, height, mirroring); + } else { + copyFrame(static_cast(srcFrame->data), srcX, srcY, srcFrame->width * srcFrame->bytes_per_pixel, + static_cast(dstFrame->data), dstX, dstY, dstFrame->stride, + width, height, mirroring); + } return; } } +void ColorStream::copyFrame(uint8_t* srcPix, int srcX, int srcY, int srcStride, uint8_t* dstPix, int dstX, int dstY, int dstStride, int width, int height, bool mirroring) +{ + srcPix += srcX + srcY * srcStride; + dstPix += dstX + dstY * dstStride; + + for (int y = 0; y < height; y++) { + uint8_t* dst = dstPix + y * dstStride; + uint8_t* src = srcPix + y * srcStride; + if (mirroring) { + dst += dstStride - 1; + for (int x = 0; x < dstStride; ++x) + *dst-- = *src++; + } else { + for (int x = 0; x < dstStride-2; x += 3) + { + *dst++ = src[2]; + *dst++ = src[1]; + *dst++ = src[0]; + src += 3; + } + } + } +} + + /* color video modes reference FREENECT_VIDEO_RGB = 0, //< Decompressed RGB mode (demosaicing done by libfreenect) diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/OpenNI2-Freenect2Driver/src/ColorStream.hpp index fceede6a2..28be880aa 100644 --- a/OpenNI2-Freenect2Driver/src/ColorStream.hpp +++ b/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -27,6 +27,8 @@ namespace Freenect2Driver OniStatus setVideoMode(OniVideoMode requested_mode); void populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const; + static void copyFrame(uint8_t* srcPix, int srcX, int srcY, int srcStride, uint8_t* dstPix, int dstX, int dstY, int dstStride, int width, int height, bool mirroring); + bool auto_white_balance; bool auto_exposure; diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/OpenNI2-Freenect2Driver/src/DepthStream.cpp index cea592aef..9609f631c 100644 --- a/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -76,7 +76,11 @@ void DepthStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int src dstFrame->stride = dstFrame->width * sizeof(uint16_t); // XXX, save depth map for registration - reg->depthFrame(srcFrame); + if (reg->isEnabled()) + reg->depthFrame(srcFrame); + + if (srcFrame->width < dstFrame->width || srcFrame->height < dstFrame->height) + memset(dstFrame->data, 0x00, dstFrame->width * dstFrame->height * 2); // copy stream buffer from freenect copyFrame(static_cast((void*)srcFrame->data), srcX, srcY, srcFrame->width, diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/OpenNI2-Freenect2Driver/src/DepthStream.hpp index 6ed966315..0b410aa17 100644 --- a/OpenNI2-Freenect2Driver/src/DepthStream.hpp +++ b/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -59,6 +59,7 @@ namespace Freenect2Driver if (!isImageRegistrationModeSupported(mode)) return ONI_STATUS_NOT_SUPPORTED; image_registration_mode = mode; + reg->setEnable(image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR); return setVideoMode(video_mode); } diff --git a/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index 9cb8d6b31..ef258b9bc 100644 --- a/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -25,6 +25,8 @@ #include "Driver/OniDriverAPI.h" #include "libfreenect2/libfreenect2.hpp" #include +#include +#include #include "DepthStream.hpp" #include "ColorStream.hpp" #include "IrStream.hpp" @@ -34,7 +36,7 @@ namespace Freenect2Driver { typedef std::map ConfigStrings; - class Device : public oni::driver::DeviceBase, public libfreenect2::FrameListener + class Device : public oni::driver::DeviceBase { private: libfreenect2::Freenect2Device *dev; @@ -43,6 +45,9 @@ namespace Freenect2Driver IrStream* ir; Registration *reg; ConfigStrings config; + bool device_stop; + libfreenect2::SyncMultiFrameListener listener; + libfreenect2::thread* thread; struct timeval ts_epoc; long getTimestamp() { @@ -51,22 +56,31 @@ namespace Freenect2Driver return (ts.tv_sec - ts_epoc.tv_sec) * 1000 + ts.tv_usec / 1000; // XXX, ignoring nsec of the epoc. } - // for Freenect::FreenectDevice - bool onNewFrame(libfreenect2::Frame::Type type, libfreenect2::Frame *frame) { - if (type == libfreenect2::Frame::Color) { - if (color) - return color->buildFrame(frame, getTimestamp()); - } else - if (type == libfreenect2::Frame::Ir) { - if (ir) - return ir->buildFrame(frame, getTimestamp()); - } else - if (type == libfreenect2::Frame::Depth) { - if (depth) - return depth->buildFrame(frame, getTimestamp()); + static void static_run(void* cookie) + { + static_cast(cookie)->run(); } - return false; + void run() + { + libfreenect2::FrameMap frames; + while(!device_stop) + { + listener.waitForNewFrame(frames); + + libfreenect2::Frame *irFrame = frames[libfreenect2::Frame::Ir]; + libfreenect2::Frame *depthFrame = frames[libfreenect2::Frame::Depth]; + libfreenect2::Frame *colorFrame = frames[libfreenect2::Frame::Color]; + const long timeStamp = getTimestamp(); + if (depth) + depth->buildFrame(depthFrame, timeStamp); + if (ir) + ir->buildFrame(irFrame, timeStamp); + if (color) + color->buildFrame(colorFrame, timeStamp); + + listener.release(frames); + } } OniStatus setStreamProperties(VideoStream* stream, std::string pfx) @@ -89,28 +103,55 @@ namespace Freenect2Driver public: Device(freenect2_context* fn_ctx, int index) : //libfreenect2::Freenect2Device(fn_ctx, index), dev(NULL), + reg(NULL), color(NULL), ir(NULL), - depth(NULL) { } + depth(NULL), + device_stop(false), + listener(libfreenect2::Frame::Depth | libfreenect2::Frame::Ir | libfreenect2::Frame::Color), + thread(NULL) + { + gettimeofday(&ts_epoc, NULL); + thread = new libfreenect2::thread(&Device::static_run, this); + } ~Device() { + close(); destroyStream(color); destroyStream(ir); destroyStream(depth); + if (reg) { + delete reg; + reg = NULL; + } } // for Freenect2Device void setFreenect2Device(libfreenect2::Freenect2Device *dev) { this->dev = dev; - dev->setColorFrameListener(this); - dev->setIrAndDepthFrameListener(this); + dev->setColorFrameListener(&listener); + dev->setIrAndDepthFrameListener(&listener); + reg = new Registration(dev); } void setConfigStrings(ConfigStrings& config) { this->config = config; } - void start() { dev->start(); } - void stop() { dev->stop(); } - void close() { dev->close(); } + void start() { + //TODO: start thread executing the run() method + //device_stop = false; + //thread = new libfreenect2::thread(&Device::static_run, this); + dev->start(); + } + void stop() { + device_stop = true; + thread->join(); + + dev->stop(); + } + void close() { + stop(); + dev->close(); + } // for DeviceBase diff --git a/OpenNI2-Freenect2Driver/src/IrStream.cpp b/OpenNI2-Freenect2Driver/src/IrStream.cpp index 06df16e15..300008b23 100644 --- a/OpenNI2-Freenect2Driver/src/IrStream.cpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -21,14 +21,11 @@ const double IrStream::EMITTER_DCMOS_DISTANCE_VAL = 7.5; IrStream::IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30); - image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; setVideoMode(video_mode); pDevice->start(); } // Add video modes here as you implement them -// Note: if image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR, -// setVideoFormat() will try FREENECT_DEPTH_REGISTERED first then fall back on what is set here. IrStream::FreenectIrModeMap IrStream::getSupportedVideoModes() { FreenectIrModeMap modes; diff --git a/OpenNI2-Freenect2Driver/src/IrStream.hpp b/OpenNI2-Freenect2Driver/src/IrStream.hpp index fe46f64f2..67cd315bb 100644 --- a/OpenNI2-Freenect2Driver/src/IrStream.hpp +++ b/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -31,7 +31,6 @@ namespace Freenect2Driver private: typedef std::map< OniVideoMode, std::pair > FreenectIrModeMap; static const OniSensorType sensor_type = ONI_SENSOR_IR; - OniImageRegistrationMode image_registration_mode; static FreenectIrModeMap getSupportedVideoModes(); OniStatus setVideoMode(OniVideoMode requested_mode); @@ -50,18 +49,7 @@ namespace Freenect2Driver return sensors; } - OniImageRegistrationMode getImageRegistrationMode() const { return image_registration_mode; } - OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) - { - if (!isImageRegistrationModeSupported(mode)) - return ONI_STATUS_NOT_SUPPORTED; - image_registration_mode = mode; - return setVideoMode(video_mode); - } - // from StreamBase - OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF || mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR); } - OniBool isPropertySupported(int propertyId) { switch(propertyId) diff --git a/OpenNI2-Freenect2Driver/src/Registration.cpp b/OpenNI2-Freenect2Driver/src/Registration.cpp new file mode 100644 index 000000000..4ef46bcf7 --- /dev/null +++ b/OpenNI2-Freenect2Driver/src/Registration.cpp @@ -0,0 +1,43 @@ +#include +#include "Driver/OniDriverAPI.h" +#include "Registration.hpp" + +using namespace Freenect2Driver; + +Registration::Registration(libfreenect2::Freenect2Device* dev) : + dev(dev), + reg(NULL), + enabled(false) +{ + } + +Registration::~Registration() { + delete reg; +} + +void Registration::depthFrame(libfreenect2::Frame* frame) { + lastDepthFrame = frame; + } + +void Registration::colorFrameRGB888(libfreenect2::Frame* colorFrame, libfreenect2::Frame* registeredFrame) +{ + if (!reg) { + libfreenect2::Freenect2Device::ColorCameraParams colCamParams = dev->getColorCameraParams(); + libfreenect2::Freenect2Device::IrCameraParams irCamParams = dev->getIrCameraParams(); + { + libfreenect2::Freenect2Device::ColorCameraParams cp = colCamParams; + std::cout << "fx=" << cp.fx << ",fy=" << cp.fy << + ",cx=" << cp.cx << ",cy=" << cp.cy << std::endl; + libfreenect2::Freenect2Device::IrCameraParams ip = irCamParams; + std::cout << "fx=" << ip.fx << ",fy=" << ip.fy << + ",ix=" << ip.cx << ",iy=" << ip.cy << + ",k1=" << ip.k1 << ",k2=" << ip.k2 << ",k3=" << ip.k3 << + ",p1=" << ip.p1 << ",p2=" << ip.p2 << std::endl; + } + reg = new libfreenect2::Registration(irCamParams, colCamParams); + } + + libfreenect2::Frame undistorted(lastDepthFrame->width, lastDepthFrame->height, lastDepthFrame->bytes_per_pixel); + + reg->apply(colorFrame, lastDepthFrame, &undistorted, registeredFrame); + } diff --git a/OpenNI2-Freenect2Driver/src/Registration.hpp b/OpenNI2-Freenect2Driver/src/Registration.hpp new file mode 100644 index 000000000..69e2affe1 --- /dev/null +++ b/OpenNI2-Freenect2Driver/src/Registration.hpp @@ -0,0 +1,20 @@ +#include + +namespace Freenect2Driver { + class Registration { + private: + libfreenect2::Freenect2Device* dev; + libfreenect2::Registration* reg; + libfreenect2::Frame* lastDepthFrame; + bool enabled; + + public: + Registration(libfreenect2::Freenect2Device* dev); + ~Registration(); + + void depthFrame(libfreenect2::Frame* frame); + void colorFrameRGB888(libfreenect2::Frame* srcFrame, libfreenect2::Frame* dstFrame); + void setEnable(bool enable = true) { enabled = enable; } + bool isEnabled() { return enabled; } + }; +} diff --git a/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/OpenNI2-Freenect2Driver/src/VideoStream.hpp index df363a9cd..59eca5f48 100644 --- a/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -6,6 +6,7 @@ #include "libfreenect2/libfreenect2.hpp" #include "PS1080.h" #include "Utility.hpp" +#include "Registration.hpp" namespace Freenect2Driver { From 653451aeede48698a962ffc76000e830a124fd3f Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sun, 14 Jun 2015 06:49:14 +0900 Subject: [PATCH 08/20] openni2: Move OpenNI2-Freenect2Driver into drivers/ sub directory --- .../OpenNI2-Freenect2Driver}/CMakeLists.txt | 0 .../OpenNI2-Freenect2Driver}/README.md | 0 .../Include/Android-Arm/OniPlatformAndroid-Arm.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h | 0 .../Include/Linux-Arm/OniPlatformLinux-Arm.h | 0 .../Include/Linux-x86/OniPlatformLinux-x86.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h | 0 .../extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h | 0 .../OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h | 0 .../OpenNI2-Freenect2Driver}/src/ColorStream.cpp | 0 .../OpenNI2-Freenect2Driver}/src/ColorStream.hpp | 0 .../OpenNI2-Freenect2Driver}/src/D2S.h | 0 .../OpenNI2-Freenect2Driver}/src/DepthStream.cpp | 0 .../OpenNI2-Freenect2Driver}/src/DepthStream.hpp | 0 .../OpenNI2-Freenect2Driver}/src/DeviceDriver.cpp | 0 .../OpenNI2-Freenect2Driver}/src/IrStream.cpp | 0 .../OpenNI2-Freenect2Driver}/src/IrStream.hpp | 0 .../OpenNI2-Freenect2Driver}/src/Registration.cpp | 0 .../OpenNI2-Freenect2Driver}/src/Registration.hpp | 0 .../OpenNI2-Freenect2Driver}/src/S2D.h | 0 .../OpenNI2-Freenect2Driver}/src/Utility.hpp | 0 .../OpenNI2-Freenect2Driver}/src/VideoStream.hpp | 0 34 files changed, 0 insertions(+), 0 deletions(-) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/CMakeLists.txt (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/README.md (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/ColorStream.cpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/ColorStream.hpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/D2S.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/DepthStream.cpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/DepthStream.hpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/DeviceDriver.cpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/IrStream.cpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/IrStream.hpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/Registration.cpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/Registration.hpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/S2D.h (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/Utility.hpp (100%) rename {OpenNI2-Freenect2Driver => drivers/OpenNI2-Freenect2Driver}/src/VideoStream.hpp (100%) diff --git a/OpenNI2-Freenect2Driver/CMakeLists.txt b/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt similarity index 100% rename from OpenNI2-Freenect2Driver/CMakeLists.txt rename to drivers/OpenNI2-Freenect2Driver/CMakeLists.txt diff --git a/OpenNI2-Freenect2Driver/README.md b/drivers/OpenNI2-Freenect2Driver/README.md similarity index 100% rename from OpenNI2-Freenect2Driver/README.md rename to drivers/OpenNI2-Freenect2Driver/README.md diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h diff --git a/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h similarity index 100% rename from OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h rename to drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/ColorStream.cpp rename to drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp diff --git a/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/ColorStream.hpp rename to drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp diff --git a/OpenNI2-Freenect2Driver/src/D2S.h b/drivers/OpenNI2-Freenect2Driver/src/D2S.h similarity index 100% rename from OpenNI2-Freenect2Driver/src/D2S.h rename to drivers/OpenNI2-Freenect2Driver/src/D2S.h diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/DepthStream.cpp rename to drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp diff --git a/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/DepthStream.hpp rename to drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp diff --git a/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/DeviceDriver.cpp rename to drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp diff --git a/OpenNI2-Freenect2Driver/src/IrStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/IrStream.cpp rename to drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp diff --git a/OpenNI2-Freenect2Driver/src/IrStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/IrStream.hpp rename to drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp diff --git a/OpenNI2-Freenect2Driver/src/Registration.cpp b/drivers/OpenNI2-Freenect2Driver/src/Registration.cpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/Registration.cpp rename to drivers/OpenNI2-Freenect2Driver/src/Registration.cpp diff --git a/OpenNI2-Freenect2Driver/src/Registration.hpp b/drivers/OpenNI2-Freenect2Driver/src/Registration.hpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/Registration.hpp rename to drivers/OpenNI2-Freenect2Driver/src/Registration.hpp diff --git a/OpenNI2-Freenect2Driver/src/S2D.h b/drivers/OpenNI2-Freenect2Driver/src/S2D.h similarity index 100% rename from OpenNI2-Freenect2Driver/src/S2D.h rename to drivers/OpenNI2-Freenect2Driver/src/S2D.h diff --git a/OpenNI2-Freenect2Driver/src/Utility.hpp b/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/Utility.hpp rename to drivers/OpenNI2-Freenect2Driver/src/Utility.hpp diff --git a/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp similarity index 100% rename from OpenNI2-Freenect2Driver/src/VideoStream.hpp rename to drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp From 7c0d3cfd5694098d484d8256ce818e6415d20a75 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 23 May 2015 17:05:46 +0900 Subject: [PATCH 09/20] openni2: Add timestamp on the frames --- .../src/DepthStream.cpp | 2 +- .../src/DeviceDriver.cpp | 62 ++++++++++++------- .../src/VideoStream.hpp | 4 +- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp index 9609f631c..cec74530a 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -22,8 +22,8 @@ DepthStream::DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver { //video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30); video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); - image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; setVideoMode(video_mode); + setImageRegistrationMode(ONI_IMAGE_REGISTRATION_OFF); pDevice->start(); } diff --git a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index ef258b9bc..b29a6b16e 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "Driver/OniDriverAPI.h" #include "libfreenect2/libfreenect2.hpp" #include @@ -49,38 +48,56 @@ namespace Freenect2Driver libfreenect2::SyncMultiFrameListener listener; libfreenect2::thread* thread; - struct timeval ts_epoc; - long getTimestamp() { - struct timeval ts; - gettimeofday(&ts, NULL); - return (ts.tv_sec - ts_epoc.tv_sec) * 1000 + ts.tv_usec / 1000; // XXX, ignoring nsec of the epoc. - } - static void static_run(void* cookie) { static_cast(cookie)->run(); - } + } + + VideoStream* getStream(libfreenect2::Frame::Type type) + { + if (type == libfreenect2::Frame::Depth) + return depth; + if (type == libfreenect2::Frame::Ir) + return ir; + if (type == libfreenect2::Frame::Color) + return color; + return NULL; + } void run() { libfreenect2::FrameMap frames; + uint32_t seqNum = 0; + libfreenect2::Frame::Type seqType; + + struct streams { + const char* name; + libfreenect2::Frame::Type type; + } streams[] = { + { "Ir", libfreenect2::Frame::Ir }, + { "Depth", libfreenect2::Frame::Depth }, + { "Color", libfreenect2::Frame::Color } + }; while(!device_stop) { listener.waitForNewFrame(frames); - libfreenect2::Frame *irFrame = frames[libfreenect2::Frame::Ir]; - libfreenect2::Frame *depthFrame = frames[libfreenect2::Frame::Depth]; - libfreenect2::Frame *colorFrame = frames[libfreenect2::Frame::Color]; - const long timeStamp = getTimestamp(); - if (depth) - depth->buildFrame(depthFrame, timeStamp); - if (ir) - ir->buildFrame(irFrame, timeStamp); - if (color) - color->buildFrame(colorFrame, timeStamp); + for (int i = 0; i < sizeof(streams)/sizeof(*streams); i++) { + struct streams& s = streams[i]; + VideoStream* stream = getStream(s.type); + libfreenect2::Frame *frame = frames[s.type]; + if (stream) { + if (seqNum == 0) + seqType = s.type; + if (s.type == seqType) + seqNum++; + frame->timestamp = seqNum * 33369; + stream->buildFrame(frame); + } + } listener.release(frames); - } + } } OniStatus setStreamProperties(VideoStream* stream, std::string pfx) @@ -111,7 +128,6 @@ namespace Freenect2Driver listener(libfreenect2::Frame::Depth | libfreenect2::Frame::Ir | libfreenect2::Frame::Color), thread(NULL) { - gettimeofday(&ts_epoc, NULL); thread = new libfreenect2::thread(&Device::static_run, this); } ~Device() @@ -473,10 +489,12 @@ namespace Freenect2Driver { WriteMessage("Closing device " + std::string(iter->first.uri)); int id = uri_to_devid(iter->first.uri); - devices.erase(iter); + Device* device = (Device*)iter->second; device->stop(); device->close(); + + devices.erase(iter); return; } } diff --git a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp index 59eca5f48..4b9e11dfc 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -70,14 +70,14 @@ namespace Freenect2Driver StreamBase::setPropertyChangedCallback(handler, pCookie); } - bool buildFrame(libfreenect2::Frame* lf2Frame, uint32_t timestamp) + bool buildFrame(libfreenect2::Frame* lf2Frame) { if (!running) return false; OniFrame* oniFrame = getServices().acquireFrame(); oniFrame->frameIndex = frame_id++; - oniFrame->timestamp = timestamp; + oniFrame->timestamp = lf2Frame->timestamp; oniFrame->videoMode = video_mode; oniFrame->width = video_mode.resolutionX; oniFrame->height = video_mode.resolutionY; From f6bb18cb19e92915fb411dd3faf9534308ade793 Mon Sep 17 00:00:00 2001 From: HenningJ Date: Mon, 15 Jun 2015 17:27:00 +0200 Subject: [PATCH 10/20] openni2: Change copying of color images to reflect the change from BGR to BGRX color format --- .../OpenNI2-Freenect2Driver/src/ColorStream.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp index 55bb1efab..eeda2b82f 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -68,7 +68,7 @@ void ColorStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int src case ONI_PIXEL_FORMAT_RGB888: if (reg->isEnabled()) { - libfreenect2::Frame registered(512, 424, 3); + libfreenect2::Frame registered(512, 424, 4); reg->colorFrameRGB888(srcFrame, ®istered); @@ -94,15 +94,24 @@ void ColorStream::copyFrame(uint8_t* srcPix, int srcX, int srcY, int srcStride, uint8_t* src = srcPix + y * srcStride; if (mirroring) { dst += dstStride - 1; - for (int x = 0; x < dstStride; ++x) - *dst-- = *src++; + for (int x = 0; x < srcStride; ++x) + { + if (x % 4 != 3) + { + *dst-- = *src++; + } + else + { + ++src; + } + } } else { for (int x = 0; x < dstStride-2; x += 3) { *dst++ = src[2]; *dst++ = src[1]; *dst++ = src[0]; - src += 3; + src += 4; } } } From 048755dcc9e056bdbfa92b869d47250807cea4cc Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 20 Jun 2015 12:35:11 +0900 Subject: [PATCH 11/20] openni2: Delete unused lines --- .../src/ColorStream.cpp | 27 ----- .../src/ColorStream.hpp | 39 +------ .../src/DepthStream.cpp | 36 ------ .../src/DeviceDriver.cpp | 18 --- .../OpenNI2-Freenect2Driver/src/IrStream.cpp | 11 -- .../OpenNI2-Freenect2Driver/src/IrStream.hpp | 103 ------------------ .../src/VideoStream.hpp | 19 ---- 7 files changed, 1 insertion(+), 252 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp index eeda2b82f..90d259f2a 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -24,12 +24,6 @@ ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30)] = std::pair(FREENECT2_VIDEO_RGB, FREENECT2_RESOLUTION_1920x1080); return modes; - - /* working format possiblities - FREENECT_VIDEO_RGB - FREENECT_VIDEO_YUV_RGB - FREENECT_VIDEO_YUV_RAW - */ } OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) @@ -42,14 +36,6 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) freenect2_video_format format = matched_mode_iter->second.first; freenect2_resolution resolution = matched_mode_iter->second.second; -#if 0 - try { device->setVideoFormat(format, resolution); } - catch (std::runtime_error e) - { - LogError("Format " + to_string(format) + " and resolution " + to_string(resolution) + " combination not supported by libfreenect"); - return ONI_STATUS_NOT_SUPPORTED; - } -#endif // 0 video_mode = requested_mode; return ONI_STATUS_OK; } @@ -116,16 +102,3 @@ void ColorStream::copyFrame(uint8_t* srcPix, int srcX, int srcY, int srcStride, } } } - - -/* color video modes reference - -FREENECT_VIDEO_RGB = 0, //< Decompressed RGB mode (demosaicing done by libfreenect) -FREENECT_VIDEO_BAYER = 1, //< Bayer compressed mode (raw information from camera) -FREENECT_VIDEO_YUV_RGB = 5, //< YUV RGB mode -FREENECT_VIDEO_YUV_RAW = 6, //< YUV Raw mode - -ONI_PIXEL_FORMAT_RGB888 = 200, -ONI_PIXEL_FORMAT_YUV422 = 201, -ONI_PIXEL_FORMAT_JPEG = 204, -*/ diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp index 28be880aa..27475daa1 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -128,44 +128,7 @@ namespace Freenect2Driver switch (propertyId) { default: - return VideoStream::setProperty(propertyId, data, dataSize); - -#if 0 - // camera - case ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE: // OniBool - { - if (dataSize != sizeof(OniBool)) - { - LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE"); - return ONI_STATUS_ERROR; - } - auto_white_balance = *(static_cast(data)); - int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_white_balance); - return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; - } - case ONI_STREAM_PROPERTY_AUTO_EXPOSURE: // OniBool - { - if (dataSize != sizeof(OniBool)) - { - LogError("Unexpected size for ONI_STREAM_PROPERTY_AUTO_EXPOSURE"); - return ONI_STATUS_ERROR; - } - auto_exposure = *(static_cast(data)); - int ret = device->setFlag(FREENECT_AUTO_WHITE_BALANCE, auto_exposure); - return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; - } - case ONI_STREAM_PROPERTY_MIRRORING: // OniBool - { - if (dataSize != sizeof(OniBool)) - { - LogError("Unexpected size for ONI_STREAM_PROPERTY_MIRRORING"); - return ONI_STATUS_ERROR; - } - mirroring = *(static_cast(data)); - int ret = device->setFlag(FREENECT_MIRROR_VIDEO, mirroring); - return (ret == 0) ? ONI_STATUS_OK : ONI_STATUS_ERROR; - } -#endif + return VideoStream::setProperty(propertyId, data, dataSize); } } }; diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp index cec74530a..b95bb3bf0 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -47,25 +47,6 @@ OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) if (matched_mode_iter == supported_video_modes.end()) return ONI_STATUS_NOT_SUPPORTED; -#if 0 - freenect_depth_format format = matched_mode_iter->second.first; - freenect_resolution resolution = matched_mode_iter->second.second; - if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) // try forcing registration mode - format = FREENECT_DEPTH_REGISTERED; - - try { device->setDepthFormat(format, resolution); } - catch (std::runtime_error e) - { - LogError("Format " + to_string(format) + " and resolution " + to_string(resolution) + " combination not supported by libfreenect"); - if (image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) - { - LogError("Could not enable image registration format; falling back to format defined in getSupportedVideoModes()"); - image_registration_mode = ONI_IMAGE_REGISTRATION_OFF; - return setVideoMode(requested_mode); - } - return ONI_STATUS_NOT_SUPPORTED; - } -#endif // 0 video_mode = requested_mode; return ONI_STATUS_OK; } @@ -87,20 +68,3 @@ void DepthStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int src static_cast(dstFrame->data), dstX, dstY, dstFrame->width, width, height, mirroring); } - - -/* depth video modes reference - -FREENECT_DEPTH_11BIT = 0, //< 11 bit depth information in one uint16_t/pixel -FREENECT_DEPTH_10BIT = 1, //< 10 bit depth information in one uint16_t/pixel -FREENECT_DEPTH_11BIT_PACKED = 2, //< 11 bit packed depth information -FREENECT_DEPTH_10BIT_PACKED = 3, //< 10 bit packed depth information -FREENECT_DEPTH_REGISTERED = 4, //< processed depth data in mm, aligned to 640x480 RGB -FREENECT_DEPTH_MM = 5, //< depth to each pixel in mm, but left unaligned to RGB image -FREENECT_DEPTH_DUMMY = 2147483647, //< Dummy value to force enum to be 32 bits wide - -ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, -ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, -ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, -ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, -*/ diff --git a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index b29a6b16e..347c8d029 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -386,10 +386,6 @@ namespace Freenect2Driver //WriteMessage("Using libfreenect v" + to_string(PROJECT_VER)); WriteMessage("Using libfreenect2"); -#if 0 - freenect_set_log_level(m_ctx, FREENECT_LOG_DEBUG); - freenect_select_subdevices(m_ctx, FREENECT_DEVICE_CAMERA); // OpenNI2 doesn't use MOTOR or AUDIO -#endif // 0 DriverServices = &getServices(); } ~Driver() { shutdown(); } @@ -413,20 +409,6 @@ namespace Freenect2Driver for (int i = 0; i < modes.size(); i++) { register_uri(uri + modes[i]); } - -#if 0 - freenect_device* dev; - if (freenect_open_device(m_ctx, &dev, i) == 0) - { - info.usbVendorId = dev->usb_cam.VID; - info.usbProductId = dev->usb_cam.PID; - freenect_close_device(dev); - } - else - { - WriteMessage("Unable to open device to query VID/PID"); - } -#endif // 0 } return ONI_STATUS_OK; } diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp index 300008b23..328e31aa1 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -4,19 +4,8 @@ using namespace Freenect2Driver; // from NUI library and converted to radians -const float IrStream::DIAGONAL_FOV = 70 * (M_PI / 180); const float IrStream::HORIZONTAL_FOV = 58.5 * (M_PI / 180); const float IrStream::VERTICAL_FOV = 45.6 * (M_PI / 180); -// from DepthKinectStream.cpp -const int IrStream::MAX_VALUE; -const unsigned long long IrStream::GAIN_VAL; -const unsigned long long IrStream::CONST_SHIFT_VAL; -const unsigned long long IrStream::MAX_SHIFT_VAL; -const unsigned long long IrStream::PARAM_COEFF_VAL; -const unsigned long long IrStream::SHIFT_SCALE_VAL; -const unsigned long long IrStream::ZERO_PLANE_DISTANCE_VAL; -const double IrStream::ZERO_PLANE_PIXEL_SIZE_VAL = 0.10520000010728836; -const double IrStream::EMITTER_DCMOS_DISTANCE_VAL = 7.5; IrStream::IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg) : VideoStream(pDevice, reg) { diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp index 67cd315bb..f0393754a 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -14,19 +14,8 @@ namespace Freenect2Driver { public: // from NUI library and converted to radians - static const float DIAGONAL_FOV; static const float HORIZONTAL_FOV; static const float VERTICAL_FOV; - // from DepthKinectStream.cpp - static const int MAX_VALUE = 10000; - static const unsigned long long GAIN_VAL = 42; - static const unsigned long long CONST_SHIFT_VAL = 200; - static const unsigned long long MAX_SHIFT_VAL = 2047; - static const unsigned long long PARAM_COEFF_VAL = 4; - static const unsigned long long SHIFT_SCALE_VAL = 10; - static const unsigned long long ZERO_PLANE_DISTANCE_VAL = 120; - static const double ZERO_PLANE_PIXEL_SIZE_VAL; - static const double EMITTER_DCMOS_DISTANCE_VAL; private: typedef std::map< OniVideoMode, std::pair > FreenectIrModeMap; @@ -58,15 +47,6 @@ namespace Freenect2Driver return VideoStream::isPropertySupported(propertyId); case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: case ONI_STREAM_PROPERTY_VERTICAL_FOV: - case ONI_STREAM_PROPERTY_MAX_VALUE: - case XN_STREAM_PROPERTY_GAIN: - case XN_STREAM_PROPERTY_CONST_SHIFT: - case XN_STREAM_PROPERTY_MAX_SHIFT: - case XN_STREAM_PROPERTY_PARAM_COEFF: - case XN_STREAM_PROPERTY_SHIFT_SCALE: - case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: - case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: - case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: return true; } } @@ -94,89 +74,6 @@ namespace Freenect2Driver } *(static_cast(data)) = VERTICAL_FOV; return ONI_STATUS_OK; - case ONI_STREAM_PROPERTY_MAX_VALUE: // int - if (*pDataSize != sizeof(int)) - { - LogError("Unexpected size for ONI_STREAM_PROPERTY_MAX_VALUE"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = MAX_VALUE; - return ONI_STATUS_OK; - - case XN_STREAM_PROPERTY_PIXEL_REGISTRATION: // XnPixelRegistration (get only) - case XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED: // unsigned long long - case XN_STREAM_PROPERTY_HOLE_FILTER: // unsigned long long - case XN_STREAM_PROPERTY_REGISTRATION_TYPE: // XnProcessingType - case XN_STREAM_PROPERTY_AGC_BIN: // XnDepthAGCBin* - case XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR: // unsigned long long - case XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE: // double - case XN_STREAM_PROPERTY_CLOSE_RANGE: // unsigned long long - return ONI_STATUS_NOT_SUPPORTED; - - case XN_STREAM_PROPERTY_GAIN: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_GAIN"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = GAIN_VAL; - return ONI_STATUS_OK; - case XN_STREAM_PROPERTY_CONST_SHIFT: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_CONST_SHIFT"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = CONST_SHIFT_VAL; - return ONI_STATUS_OK; - case XN_STREAM_PROPERTY_MAX_SHIFT: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_MAX_SHIFT"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = MAX_SHIFT_VAL; - return ONI_STATUS_OK; - case XN_STREAM_PROPERTY_PARAM_COEFF: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_PARAM_COEFF"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = PARAM_COEFF_VAL; - return ONI_STATUS_OK; - case XN_STREAM_PROPERTY_SHIFT_SCALE: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_SHIFT_SCALE"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = SHIFT_SCALE_VAL; - return ONI_STATUS_OK; - case XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE: // unsigned long long - if (*pDataSize != sizeof(unsigned long long)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = ZERO_PLANE_DISTANCE_VAL; - return ONI_STATUS_OK; - case XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE: // double - if (*pDataSize != sizeof(double)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = ZERO_PLANE_PIXEL_SIZE_VAL; - return ONI_STATUS_OK; - case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: // double - if (*pDataSize != sizeof(double)) - { - LogError("Unexpected size for XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE"); - return ONI_STATUS_ERROR; - } - *(static_cast(data)) = EMITTER_DCMOS_DISTANCE_VAL; - return ONI_STATUS_OK; } } }; diff --git a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp index 4b9e11dfc..299c0b861 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -235,22 +235,3 @@ namespace Freenect2Driver */ }; } - - -/* image video modes reference - -FREENECT_VIDEO_RGB = 0, //< Decompressed RGB mode (demosaicing done by libfreenect) -FREENECT_VIDEO_BAYER = 1, //< Bayer compressed mode (raw information from camera) -FREENECT_VIDEO_IR_8BIT = 2, //< 8-bit IR mode -FREENECT_VIDEO_IR_10BIT = 3, //< 10-bit IR mode -FREENECT_VIDEO_IR_10BIT_PACKED = 4, //< 10-bit packed IR mode -FREENECT_VIDEO_YUV_RGB = 5, //< YUV RGB mode -FREENECT_VIDEO_YUV_RAW = 6, //< YUV Raw mode -FREENECT_VIDEO_DUMMY = 2147483647, //< Dummy value to force enum to be 32 bits wide - -ONI_PIXEL_FORMAT_RGB888 = 200, -ONI_PIXEL_FORMAT_YUV422 = 201, -ONI_PIXEL_FORMAT_GRAY8 = 202, -ONI_PIXEL_FORMAT_GRAY16 = 203, -ONI_PIXEL_FORMAT_JPEG = 204, -*/ From d4e47d3f7e7c2e9376cf521fde92f7459db8dae0 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 2 Jan 2016 14:11:33 +0900 Subject: [PATCH 12/20] openni2: Fix compile errors after last merge --- CMakeLists.txt | 6 ++ .../OpenNI2-Freenect2Driver/CMakeLists.txt | 88 +++++++++++++------ .../src/ColorStream.cpp | 9 +- .../src/ColorStream.hpp | 7 +- .../src/DepthStream.cpp | 4 +- .../src/DepthStream.hpp | 6 +- .../src/DeviceDriver.cpp | 8 +- .../OpenNI2-Freenect2Driver/src/IrStream.cpp | 3 +- .../OpenNI2-Freenect2Driver/src/IrStream.hpp | 6 +- .../src/VideoStream.hpp | 3 +- 10 files changed, 86 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 729d778b2..8c943acd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ SET(DEPENDS_DIR "${MY_DIR}/depends" CACHE STRING "dependency directory must be s OPTION(BUILD_SHARED_LIBS "Build shared (ON) or static (OFF) libraries" ON) OPTION(BUILD_EXAMPLES "Build examples" ON) +OPTION(BUILD_OPENNI2_DRIVER "Build OpenNI2 driver" OFF) OPTION(ENABLE_CXX11 "Enable C++11 support" OFF) OPTION(ENABLE_OPENCL "Enable OpenCL support" ON) OPTION(ENABLE_OPENGL "Enable OpenGL support" ON) @@ -268,3 +269,8 @@ IF(BUILD_EXAMPLES) MESSAGE(STATUS "Configurating examples") ADD_SUBDIRECTORY(${MY_DIR}/examples) ENDIF() + +IF(BUILD_OPENNI2_DRIVER) + MESSAGE(STATUS "Configuring OpenNI2 driver") + ADD_SUBDIRECTORY(${MY_DIR}/drivers/OpenNI2-Freenect2Driver) +ENDIF() diff --git a/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt b/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt index 99ff4fe23..c11af429f 100644 --- a/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt +++ b/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt @@ -1,28 +1,60 @@ -############################################################################## -# OpenNI2-Freenect2Driver -############################################################################## - -file(GLOB HEADERS src/*.hpp src/*.h) -file(GLOB SOURCES src/*.cpp) -add_library(Freenect2Driver SHARED ${HEADERS} ${SOURCES}) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") - -set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib/OpenNI2-Freenect2Driver) -set_target_properties(Freenect2Driver PROPERTIES - VERSION ${PROJECT_VER} - SOVERSION ${PROJECT_APIVER} - OUTPUT_NAME Freenect2Driver) - -add_definitions(-DPROJECT_VER="${PROJECT_VER}") - -include_directories(extern/OpenNI-Linux-x64-2.2.0.33/Include) -include_directories(${PROJECT_SOURCE_DIR}/../include) -include_directories(${PROJECT_SOURCE_DIR}/../examples/protonect/include) -include_directories(${PROJECT_SOURCE_DIR}/src) -include_directories(${PROJECT_SOURCE_DIR}/wrappers/cpp) - -target_link_libraries(Freenect2Driver freenect2 ${MATH_LIB}) - -install (TARGETS Freenect2Driver - DESTINATION "${PROJECT_LIBRARY_INSTALL_DIR}/OpenNI2-Freenect2Driver") +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.1) + +if(WIN32 AND NOT MINGW) + if(NOT DEFINED CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX "d") + endif() +endif() + +IF(NOT DEFINED CMAKE_BUILD_TYPE) + # No effect for multi-configuration generators (e.g. for Visual Studio) + SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose: RelWithDebInfo Release Debug MinSizeRel None") +ENDIF() + +PROJECT(openni2_freenect2driver) + +SET(MY_DIR ${openni2_freenect2driver_SOURCE_DIR}) +SET(freenect2_ROOT_DIR ${MY_DIR}/../..) + +FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found +SET(OPENNI2_INCLUDE $ENV{OPENNI2_INCLUDE}) +SET(OPENNI2_LINRARY $ENV{OPENNI2_REDIST}) + +IF(TARGET freenect2) + MESSAGE(STATUS "Using in-tree freenect2 target") + SET(freenect2_LIBRARIES freenect2) + SET(freenect2_DLLS ${LIBFREENECT2_DLLS}) +ELSE() + FIND_PACKAGE(freenect2 REQUIRED) + # Out-of-tree build will have to have DLLs manually copied. +ENDIF() + +INCLUDE_DIRECTORIES( + ${freenect2_INCLUDE_DIR} + ${OPENNI2_INCLUDE} +) + +SET(OpenNI2-Freenect2Driver_src + src/ColorStream.cpp + src/DepthStream.cpp + src/IrStream.cpp + src/DeviceDriver.cpp + src/Registration.cpp + ${freenect2_ROOT_DIR}/${LIBFREENECT2_THREADING_SOURCE} +) + +SET(OpenNI2-Freenect2Driver_LIBRARIES + ${freenect2_LIBRARIES} +) + +SET(OpenNI2-Freenect2Driver_DLLS + ${freenect2_DLLS} +) + +ADD_LIBRARY(OpenNI2-Freenect2Driver ${OpenNI2-Freenect2Driver_src}) + +TARGET_LINK_LIBRARIES(OpenNI2-Freenect2Driver + ${OpenNI2-Freenect2Driver_LIBRARIES} +) + +INSTALL(TARGETS OpenNI2-Freenect2Driver DESTINATION "${OPENNI2_LINRARY}/OpenNI2/Drivers") diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp index 90d259f2a..ebfa2e563 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -19,9 +19,9 @@ ColorStream::ColorStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() { FreenectVideoModeMap modes; - // pixelFormat, resolutionX, resolutionY, fps freenect_video_format, freenect_resolution - modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 512, 424, 30)] = std::pair(FREENECT2_VIDEO_RGB, FREENECT2_RESOLUTION_1920x1080); - modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30)] = std::pair(FREENECT2_VIDEO_RGB, FREENECT2_RESOLUTION_1920x1080); + // pixelFormat, resolutionX, resolutionY, fps + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 512, 424, 30)] = 0; + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30)] = 1; return modes; } @@ -33,9 +33,6 @@ OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) if (matched_mode_iter == supported_video_modes.end()) return ONI_STATUS_NOT_SUPPORTED; - freenect2_video_format format = matched_mode_iter->second.first; - freenect2_resolution resolution = matched_mode_iter->second.second; - video_mode = requested_mode; return ONI_STATUS_OK; } diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp index 27475daa1..be8200527 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -3,9 +3,8 @@ #include // for transform() #include // for M_PI #include -#include "libfreenect2.h" -#include "libfreenect2/libfreenect2.hpp" -#include "Driver/OniDriverAPI.h" +#include +#include #include "VideoStream.hpp" @@ -20,7 +19,7 @@ namespace Freenect2Driver static const float VERTICAL_FOV; private: - typedef std::map< OniVideoMode, std::pair > FreenectVideoModeMap; + typedef std::map< OniVideoMode, int > FreenectVideoModeMap; static const OniSensorType sensor_type = ONI_SENSOR_COLOR; static FreenectVideoModeMap getSupportedVideoModes(); diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp index b95bb3bf0..6b7246843 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -34,8 +34,8 @@ DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() { FreenectDepthModeMap modes; // pixelFormat, resolutionX, resolutionY, fps - modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = std::pair(FREENECT2_DEPTH_MM, FREENECT2_RESOLUTION_512x424); - modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30)] = std::pair(FREENECT2_DEPTH_MM, FREENECT2_RESOLUTION_512x424); + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = 0; + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30)] = 1; return modes; } diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp index 0b410aa17..0cff6501c 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -3,8 +3,8 @@ #include // for transform() #include // for M_PI #include // for memcpy -#include "libfreenect2/libfreenect2.hpp" -#include "Driver/OniDriverAPI.h" +#include +#include #include "PS1080.h" #include "VideoStream.hpp" #include "S2D.h" @@ -32,7 +32,7 @@ namespace Freenect2Driver static const double EMITTER_DCMOS_DISTANCE_VAL; private: - typedef std::map< OniVideoMode, std::pair > FreenectDepthModeMap; + typedef std::map FreenectDepthModeMap; static const OniSensorType sensor_type = ONI_SENSOR_DEPTH; OniImageRegistrationMode image_registration_mode; diff --git a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index 347c8d029..8f7e4ebf6 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -21,8 +21,8 @@ #include #include #include -#include "Driver/OniDriverAPI.h" -#include "libfreenect2/libfreenect2.hpp" +#include +#include #include #include #include @@ -118,7 +118,7 @@ namespace Freenect2Driver } public: - Device(freenect2_context* fn_ctx, int index) : //libfreenect2::Freenect2Device(fn_ctx, index), + Device(int index) : //libfreenect2::Freenect2Device(fn_ctx, index), dev(NULL), reg(NULL), color(NULL), @@ -450,7 +450,7 @@ namespace Freenect2Driver { WriteMessage("Opening device " + std::string(uri)); int id = uri_to_devid(iter->first.uri); - Device* device = new Device(NULL, id); + Device* device = new Device(id); device->setFreenect2Device(openDevice(id)); // XXX, detault pipeline // const PacketPipeline *factory); device->setConfigStrings(config); iter->second = device; diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp index 328e31aa1..2bed4a397 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -19,8 +19,7 @@ IrStream::FreenectIrModeMap IrStream::getSupportedVideoModes() { FreenectIrModeMap modes; // pixelFormat, resolutionX, resolutionY, fps - modes[makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30)] = std::pair(FREENECT2_IR_RAW, FREENECT2_RESOLUTION_512x424); - + modes[makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30)] = 0; return modes; } diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp index f0393754a..a02af197b 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -3,8 +3,8 @@ #include // for transform() #include // for M_PI #include // for memcpy -#include "libfreenect2/libfreenect2.hpp" -#include "Driver/OniDriverAPI.h" +#include +#include #include "PS1080.h" #include "VideoStream.hpp" @@ -18,7 +18,7 @@ namespace Freenect2Driver static const float VERTICAL_FOV; private: - typedef std::map< OniVideoMode, std::pair > FreenectIrModeMap; + typedef std::map< OniVideoMode, int> FreenectIrModeMap; static const OniSensorType sensor_type = ONI_SENSOR_IR; static FreenectIrModeMap getSupportedVideoModes(); diff --git a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp index 299c0b861..5123385bb 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -2,8 +2,7 @@ #include #include -#include "libfreenect2.h" -#include "libfreenect2/libfreenect2.hpp" +#include #include "PS1080.h" #include "Utility.hpp" #include "Registration.hpp" From f6b2e9b1bbfd7e1ab1c160b211076e740eddd0d6 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 4 Jul 2015 08:55:08 +0900 Subject: [PATCH 13/20] openni2: Have a member of libfreenect2::Freenect2 in the OpenNI2 driver --- drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index 8f7e4ebf6..1bbcc36df 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -345,13 +345,14 @@ namespace Freenect2Driver }; - class Driver : public oni::driver::DriverBase, private libfreenect2::Freenect2 + class Driver : public oni::driver::DriverBase { private: typedef std::map OniDeviceMap; OniDeviceMap devices; std::string uriScheme; ConfigStrings config; + libfreenect2::Freenect2 freenect2; std::string devid_to_uri(int id) { return uriScheme + "://" + to_string(id); @@ -395,7 +396,7 @@ namespace Freenect2Driver OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); - for (int i = 0; i < Freenect2::enumerateDevices(); i++) + for (int i = 0; i < freenect2.enumerateDevices(); i++) { std::string uri = devid_to_uri(i); std::array modes = { @@ -451,7 +452,7 @@ namespace Freenect2Driver WriteMessage("Opening device " + std::string(uri)); int id = uri_to_devid(iter->first.uri); Device* device = new Device(id); - device->setFreenect2Device(openDevice(id)); // XXX, detault pipeline // const PacketPipeline *factory); + device->setFreenect2Device(freenect2.openDevice(id)); // XXX, detault pipeline // const PacketPipeline *factory); device->setConfigStrings(config); iter->second = device; return device; From 6f76a8ce2822dccaf4fd6a9ca2075f63fc80df09 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 4 Jul 2015 23:23:59 +0900 Subject: [PATCH 14/20] openni2: Use OpenNI2 logging functions/classes --- .../OpenNI2-Freenect2Driver/src/Utility.hpp | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp b/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp index f9d5e39ac..21e04da32 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp @@ -56,19 +56,22 @@ static std::string to_string(const T& n) // global logging namespace Freenect2Driver { - static void WriteMessage(std::string info) - { - std::cout << "OpenNI2-Freenect2Driver: " << info << std::endl; - } - // DriverServices is set in DeviceDriver.cpp so all files can call errorLoggerAppend() static oni::driver::DriverServices* DriverServices; - static void LogError(std::string error) - { - // errorLoggerAppend() doesn't seem to go anywhere, so WriteMessage also - WriteMessage("(ERROR) " + error); - - if (DriverServices != NULL) - DriverServices->errorLoggerAppend(std::string("OpenNI2-Freenect2Driver: " + error).c_str()); - } + + // from XnLog.h + typedef enum XnLogSeverity { + XN_LOG_VERBOSE = 0, + XN_LOG_INFO = 1, + XN_LOG_WARNING = 2, + XN_LOG_ERROR = 3, + XN_LOG_SEVERITY_NONE = 10, + } XnLogSeverity; } +#define FN2DRV_LOG_MASK "Freenect2Driver" +#define WriteVerbose(str) do { if (DriverServices != NULL) DriverServices->log(XN_LOG_VERBOSE, __FILE__, __LINE__, FN2DRV_LOG_MASK, std::string(str).c_str()); } while(0) +#define WriteInfo(str) do { if (DriverServices != NULL) DriverServices->log(XN_LOG_INFO, __FILE__, __LINE__, FN2DRV_LOG_MASK, std::string(str).c_str()); } while(0) +#define WriteWarning(str) do { if (DriverServices != NULL) DriverServices->log(XN_LOG_WARNING, __FILE__, __LINE__, FN2DRV_LOG_MASK, std::string(str).c_str()); } while(0) +#define WriteError(str) do { if (DriverServices != NULL) DriverServices->log(XN_LOG_ERROR, __FILE__, __LINE__, FN2DRV_LOG_MASK, std::string(str).c_str()); } while(0) +#define WriteMessage(str) WriteInfo(str) +#define LogError(str) WriteError(str) From 17b888e5bad55ef2f864928618bcabb641d2a0e0 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 4 Jul 2015 23:43:47 +0900 Subject: [PATCH 15/20] openni2: Add OpenKinect Project's license headers --- .../src/ColorStream.cpp | 26 ++++++++++++ .../src/ColorStream.hpp | 26 ++++++++++++ drivers/OpenNI2-Freenect2Driver/src/D2S.h | 26 ++++++++++++ .../src/DepthStream.cpp | 26 ++++++++++++ .../src/DepthStream.hpp | 26 ++++++++++++ .../src/DeviceDriver.cpp | 42 ++++++++++++------- .../OpenNI2-Freenect2Driver/src/IrStream.cpp | 26 ++++++++++++ .../OpenNI2-Freenect2Driver/src/IrStream.hpp | 26 ++++++++++++ .../src/Registration.cpp | 26 ++++++++++++ .../src/Registration.hpp | 26 ++++++++++++ drivers/OpenNI2-Freenect2Driver/src/S2D.h | 26 ++++++++++++ .../OpenNI2-Freenect2Driver/src/Utility.hpp | 26 ++++++++++++ .../src/VideoStream.hpp | 26 ++++++++++++ 13 files changed, 338 insertions(+), 16 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp index ebfa2e563..0c56b03d2 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #include #include "ColorStream.hpp" diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp index be8200527..d10966f63 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #pragma once #include // for transform() diff --git a/drivers/OpenNI2-Freenect2Driver/src/D2S.h b/drivers/OpenNI2-Freenect2Driver/src/D2S.h index 636d7bfa4..8ca91cc8f 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/D2S.h +++ b/drivers/OpenNI2-Freenect2Driver/src/D2S.h @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + const unsigned short D2S[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp index 6b7246843..c21e3d02b 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #include #include "DepthStream.hpp" diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp index 0cff6501c..8a1b3fba6 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #pragma once #include // for transform() diff --git a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index 1bbcc36df..f388fa13b 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -1,23 +1,33 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ /** * FreenectDriver * Copyright 2013 Benn Snyder -* -* 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. -*/ -/** -* OpenNI2 Freenect2 Driver -* Copyright 2015 hanyazou@gmail.com */ + #include #include #include diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp index 2bed4a397..74f5ff0c8 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #include #include "IrStream.hpp" diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp index a02af197b..4bb51bcf0 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #pragma once #include // for transform() diff --git a/drivers/OpenNI2-Freenect2Driver/src/Registration.cpp b/drivers/OpenNI2-Freenect2Driver/src/Registration.cpp index 4ef46bcf7..c3d6fac9c 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/Registration.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/Registration.cpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #include #include "Driver/OniDriverAPI.h" #include "Registration.hpp" diff --git a/drivers/OpenNI2-Freenect2Driver/src/Registration.hpp b/drivers/OpenNI2-Freenect2Driver/src/Registration.hpp index 69e2affe1..8aa4a5356 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/Registration.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/Registration.hpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #include namespace Freenect2Driver { diff --git a/drivers/OpenNI2-Freenect2Driver/src/S2D.h b/drivers/OpenNI2-Freenect2Driver/src/S2D.h index ab90f3a17..3c421b99b 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/S2D.h +++ b/drivers/OpenNI2-Freenect2Driver/src/S2D.h @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + const uint16_t S2D[] = { 0, 315, 315, 315, 316, 316, 316, 316, 317, 317, 317, 318, 318, 318, 319, 319, 319, 319, 320, 320, diff --git a/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp b/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp index 21e04da32..443d8cbe7 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/Utility.hpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + // This file contains symbols that may be used by any class or don't really go anywhere else. #pragma once diff --git a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp index 5123385bb..f556b4016 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -1,3 +1,29 @@ +/* + * This file is part of the OpenKinect Project. http://www.openkinect.org + * + * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file + * for details. + * + * This code is licensed to you under the terms of the Apache License, version + * 2.0, or, at your option, the terms of the GNU General Public License, + * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, + * or the following URLs: + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * If you redistribute this file in source form, modified or unmodified, you + * may: + * 1) Leave this header intact and distribute it under the same terms, + * accompanying it with the APACHE20 and GPL20 files, or + * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or + * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file + * In all cases you must keep the copyright notice intact and include a copy + * of the CONTRIB file. + * + * Binary distributions must follow the binary distribution requirements of + * either License. + */ + #pragma once #include From 11c122c4ed0f1c5f90169f50f112d38cbefc0893 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 2 Jan 2016 06:42:13 +0900 Subject: [PATCH 16/20] openni2: Delete OpenNI2 header files --- .../Android-Arm/OniPlatformAndroid-Arm.h | 43 - .../Include/Driver/OniDriverAPI.h | 378 --- .../Include/Driver/OniDriverTypes.h | 54 - .../Include/Linux-Arm/OniPlatformLinux-Arm.h | 36 - .../Include/Linux-x86/OniPlatformLinux-x86.h | 102 - .../Include/MacOSX/OniPlatformMacOSX.h | 42 - .../Include/OniCAPI.h | 259 -- .../Include/OniCEnums.h | 84 - .../Include/OniCProperties.h | 68 - .../Include/OniCTypes.h | 193 -- .../Include/OniEnums.h | 86 - .../Include/OniPlatform.h | 72 - .../Include/OniProperties.h | 73 - .../Include/OniVersion.h | 43 - .../Include/OpenNI.h | 2750 ----------------- .../Include/PS1080.h | 632 ---- .../Include/PSLink.h | 199 -- .../Include/PrimeSense.h | 229 -- .../Include/Win32/OniPlatformWin32.h | 139 - 19 files changed, 5482 deletions(-) delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h deleted file mode 100644 index 0aae276b5..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Android-Arm/OniPlatformAndroid-Arm.h +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_PLATFORM_ANDROID_ARM_H_ -#define _ONI_PLATFORM_ANDROID_ARM_H_ - -// Start with Linux-x86, and override what's different -#include "../Linux-x86/OniPlatformLinux-x86.h" - -//--------------------------------------------------------------------------- -// Platform Basic Definition -//--------------------------------------------------------------------------- -#undef ONI_PLATFORM -#undef ONI_PLATFORM_STRING - -#define ONI_PLATFORM ONI_PLATFORM_ANDROID_ARM -#define ONI_PLATFORM_STRING "Android-Arm" - -#ifdef HAVE_ANDROID_OS - #define ONI_PLATFORM_ANDROID_OS - - #undef ONI_PLATFORM_STRING - #define ONI_PLATFORM_STRING "AndroidOS-Arm" -#endif - -#endif //_ONI_PLATFORM_LINUX_ARM_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h deleted file mode 100644 index c41e1f660..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverAPI.h +++ /dev/null @@ -1,378 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_DRIVER_API_H_ -#define _ONI_DRIVER_API_H_ - -#include "OniPlatform.h" -#include "OniCTypes.h" -#include "OniCProperties.h" -#include "OniDriverTypes.h" -#include - -namespace oni { namespace driver { - -class DeviceBase; -class StreamBase; - -typedef void (ONI_CALLBACK_TYPE* DeviceConnectedCallback)(const OniDeviceInfo*, void* pCookie); -typedef void (ONI_CALLBACK_TYPE* DeviceDisconnectedCallback)(const OniDeviceInfo*, void* pCookie); -typedef void (ONI_CALLBACK_TYPE* DeviceStateChangedCallback)(const OniDeviceInfo* deviceId, int errorState, void* pCookie); -typedef void (ONI_CALLBACK_TYPE* NewFrameCallback)(StreamBase* streamId, OniFrame*, void* pCookie); -typedef void (ONI_CALLBACK_TYPE* PropertyChangedCallback)(void* sender, int propertyId, const void* data, int dataSize, void* pCookie); - -class StreamServices : public OniStreamServices -{ -public: - int getDefaultRequiredFrameSize() - { - return OniStreamServices::getDefaultRequiredFrameSize(streamServices); - } - - OniFrame* acquireFrame() - { - return OniStreamServices::acquireFrame(streamServices); - } - - void addFrameRef(OniFrame* pFrame) - { - OniStreamServices::addFrameRef(streamServices, pFrame); - } - - void releaseFrame(OniFrame* pFrame) - { - OniStreamServices::releaseFrame(streamServices, pFrame); - } -}; - -class StreamBase -{ -public: - StreamBase() : m_newFrameCallback(NULL), m_propertyChangedCallback(NULL) {} - virtual ~StreamBase() {} - - virtual void setServices(StreamServices* pStreamServices) { m_pServices = pStreamServices; } - - virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} - virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} - virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} - virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} - virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} - - virtual int getRequiredFrameSize() { return getServices().getDefaultRequiredFrameSize(); } - - virtual OniStatus start() = 0; - virtual void stop() = 0; - - virtual void setNewFrameCallback(NewFrameCallback handler, void* pCookie) { m_newFrameCallback = handler; m_newFrameCallbackCookie = pCookie; } - virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } - - virtual void notifyAllProperties() { return; } - - virtual OniStatus convertDepthToColorCoordinates(StreamBase* /*colorStream*/, int /*depthX*/, int /*depthY*/, OniDepthPixel /*depthZ*/, int* /*pColorX*/, int* /*pColorY*/) { return ONI_STATUS_NOT_SUPPORTED; } - -protected: - void raiseNewFrame(OniFrame* pFrame) { (*m_newFrameCallback)(this, pFrame, m_newFrameCallbackCookie); } - void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } - - StreamServices& getServices() { return *m_pServices; } - -private: - StreamServices* m_pServices; - NewFrameCallback m_newFrameCallback; - void* m_newFrameCallbackCookie; - PropertyChangedCallback m_propertyChangedCallback; - void* m_propertyChangedCookie; -}; - -class DeviceBase -{ -public: - DeviceBase() {} - virtual ~DeviceBase() {} - - virtual OniStatus getSensorInfoList(OniSensorInfo** pSensorInfos, int* numSensors) = 0; - - virtual StreamBase* createStream(OniSensorType) = 0; - virtual void destroyStream(StreamBase* pStream) = 0; - - virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} - virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} - virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} - virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} - virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} - virtual OniStatus tryManualTrigger() {return ONI_STATUS_OK;} - - virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } - virtual void notifyAllProperties() { return; } - - virtual OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF); } - -protected: - void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } - -private: - PropertyChangedCallback m_propertyChangedCallback; - void* m_propertyChangedCookie; -}; - -class DriverServices -{ -public: - DriverServices(OniDriverServices* pDriverServices) : m_pDriverServices(pDriverServices) {} - - void errorLoggerAppend(const char* format, ...) - { - va_list args; - va_start(args, format); - m_pDriverServices->errorLoggerAppend(m_pDriverServices->driverServices, format, args); - va_end(args); - } - - void errorLoggerClear() - { - m_pDriverServices->errorLoggerClear(m_pDriverServices->driverServices); - } - - void log(int severity, const char* file, int line, const char* mask, const char* message) - { - m_pDriverServices->log(m_pDriverServices->driverServices, severity, file, line, mask, message); - } - -private: - OniDriverServices* m_pDriverServices; -}; - -class DriverBase -{ -public: - DriverBase(OniDriverServices* pDriverServices) : m_services(pDriverServices) - {} - - virtual ~DriverBase() {} - - virtual OniStatus initialize(DeviceConnectedCallback connectedCallback, DeviceDisconnectedCallback disconnectedCallback, DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) - { - m_deviceConnectedEvent = connectedCallback; - m_deviceDisconnectedEvent = disconnectedCallback; - m_deviceStateChangedEvent = deviceStateChangedCallback; - m_pCookie = pCookie; - return ONI_STATUS_OK; - } - - virtual DeviceBase* deviceOpen(const char* uri, const char* mode) = 0; - virtual void deviceClose(DeviceBase* pDevice) = 0; - - virtual void shutdown() = 0; - - virtual OniStatus tryDevice(const char* /*uri*/) { return ONI_STATUS_ERROR;} - - virtual void* enableFrameSync(StreamBase** /*pStreams*/, int /*streamCount*/) { return NULL; } - virtual void disableFrameSync(void* /*frameSyncGroup*/) {} - -protected: - void deviceConnected(const OniDeviceInfo* pInfo) { (m_deviceConnectedEvent)(pInfo, m_pCookie); } - void deviceDisconnected(const OniDeviceInfo* pInfo) { (m_deviceDisconnectedEvent)(pInfo, m_pCookie); } - void deviceStateChanged(const OniDeviceInfo* pInfo, int errorState) { (m_deviceStateChangedEvent)(pInfo, errorState, m_pCookie); } - - DriverServices& getServices() { return m_services; } - -private: - DeviceConnectedCallback m_deviceConnectedEvent; - DeviceDisconnectedCallback m_deviceDisconnectedEvent; - DeviceStateChangedCallback m_deviceStateChangedEvent; - void* m_pCookie; - - DriverServices m_services; -}; - -}} // oni::driver - -#define ONI_EXPORT_DRIVER(DriverClass) \ - \ -oni::driver::DriverBase* g_pDriver = NULL; \ - \ -/* As Driver */ \ -ONI_C_API_EXPORT void oniDriverCreate(OniDriverServices* driverServices) { \ - g_pDriver = XN_NEW(DriverClass, driverServices); \ -} \ -ONI_C_API_EXPORT void oniDriverDestroy() \ -{ \ - g_pDriver->shutdown(); \ - XN_DELETE(g_pDriver); g_pDriver = NULL; \ -} \ -ONI_C_API_EXPORT OniStatus oniDriverInitialize(oni::driver::DeviceConnectedCallback deviceConnectedCallback, \ - oni::driver::DeviceDisconnectedCallback deviceDisconnectedCallback, \ - oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, \ - void* pCookie) \ -{ \ - return g_pDriver->initialize(deviceConnectedCallback, deviceDisconnectedCallback, deviceStateChangedCallback, pCookie); \ -} \ - \ -ONI_C_API_EXPORT OniStatus oniDriverTryDevice(const char* uri) \ -{ \ - return g_pDriver->tryDevice(uri); \ -} \ - \ -/* As Device */ \ -ONI_C_API_EXPORT oni::driver::DeviceBase* oniDriverDeviceOpen(const char* uri, const char* mode) \ -{ \ - return g_pDriver->deviceOpen(uri, mode); \ -} \ -ONI_C_API_EXPORT void oniDriverDeviceClose(oni::driver::DeviceBase* pDevice) \ -{ \ - g_pDriver->deviceClose(pDevice); \ -} \ - \ -ONI_C_API_EXPORT OniStatus oniDriverDeviceGetSensorInfoList(oni::driver::DeviceBase* pDevice, OniSensorInfo** pSensorInfos, \ - int* numSensors) \ -{ \ - return pDevice->getSensorInfoList(pSensorInfos, numSensors); \ -} \ - \ -ONI_C_API_EXPORT oni::driver::StreamBase* oniDriverDeviceCreateStream(oni::driver::DeviceBase* pDevice, \ - OniSensorType sensorType) \ -{ \ - return pDevice->createStream(sensorType); \ -} \ - \ -ONI_C_API_EXPORT void oniDriverDeviceDestroyStream(oni::driver::DeviceBase* pDevice, oni::driver::StreamBase* pStream) \ -{ \ - return pDevice->destroyStream(pStream); \ -} \ - \ -ONI_C_API_EXPORT OniStatus oniDriverDeviceSetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ - const void* data, int dataSize) \ -{ \ - return pDevice->setProperty(propertyId, data, dataSize); \ -} \ -ONI_C_API_EXPORT OniStatus oniDriverDeviceGetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ - void* data, int* pDataSize) \ -{ \ - return pDevice->getProperty(propertyId, data, pDataSize); \ -} \ -ONI_C_API_EXPORT OniBool oniDriverDeviceIsPropertySupported(oni::driver::DeviceBase* pDevice, int propertyId) \ -{ \ - return pDevice->isPropertySupported(propertyId); \ -} \ -ONI_C_API_EXPORT void oniDriverDeviceSetPropertyChangedCallback(oni::driver::DeviceBase* pDevice, \ - oni::driver::PropertyChangedCallback handler, void* pCookie) \ -{ \ - pDevice->setPropertyChangedCallback(handler, pCookie); \ -} \ -ONI_C_API_EXPORT void oniDriverDeviceNotifyAllProperties(oni::driver::DeviceBase* pDevice) \ -{ \ - pDevice->notifyAllProperties(); \ -} \ -ONI_C_API_EXPORT OniStatus oniDriverDeviceInvoke(oni::driver::DeviceBase* pDevice, int commandId, \ - void* data, int dataSize) \ -{ \ - return pDevice->invoke(commandId, data, dataSize); \ -} \ -ONI_C_API_EXPORT OniBool oniDriverDeviceIsCommandSupported(oni::driver::DeviceBase* pDevice, int commandId) \ -{ \ - return pDevice->isCommandSupported(commandId); \ -} \ -ONI_C_API_EXPORT OniStatus oniDriverDeviceTryManualTrigger(oni::driver::DeviceBase* pDevice) \ -{ \ - return pDevice->tryManualTrigger(); \ -} \ -ONI_C_API_EXPORT OniBool oniDriverDeviceIsImageRegistrationModeSupported(oni::driver::DeviceBase* pDevice, \ - OniImageRegistrationMode mode) \ -{ \ - return pDevice->isImageRegistrationModeSupported(mode); \ -} \ - \ -/* As Stream */ \ -ONI_C_API_EXPORT void oniDriverStreamSetServices(oni::driver::StreamBase* pStream, OniStreamServices* pServices) \ -{ \ - pStream->setServices((oni::driver::StreamServices*)pServices); \ -} \ - \ -ONI_C_API_EXPORT OniStatus oniDriverStreamSetProperty(oni::driver::StreamBase* pStream, int propertyId, \ - const void* data, int dataSize) \ -{ \ - return pStream->setProperty(propertyId, data, dataSize); \ -} \ -ONI_C_API_EXPORT OniStatus oniDriverStreamGetProperty(oni::driver::StreamBase* pStream, int propertyId, void* data, \ - int* pDataSize) \ -{ \ - return pStream->getProperty(propertyId, data, pDataSize); \ -} \ -ONI_C_API_EXPORT OniBool oniDriverStreamIsPropertySupported(oni::driver::StreamBase* pStream, int propertyId) \ -{ \ - return pStream->isPropertySupported(propertyId); \ -} \ -ONI_C_API_EXPORT void oniDriverStreamSetPropertyChangedCallback(oni::driver::StreamBase* pStream, \ - oni::driver::PropertyChangedCallback handler, void* pCookie) \ -{ \ - pStream->setPropertyChangedCallback(handler, pCookie); \ -} \ -ONI_C_API_EXPORT void oniDriverStreamNotifyAllProperties(oni::driver::StreamBase* pStream) \ -{ \ - pStream->notifyAllProperties(); \ -} \ -ONI_C_API_EXPORT OniStatus oniDriverStreamInvoke(oni::driver::StreamBase* pStream, int commandId, \ - void* data, int dataSize) \ -{ \ - return pStream->invoke(commandId, data, dataSize); \ -} \ -ONI_C_API_EXPORT OniBool oniDriverStreamIsCommandSupported(oni::driver::StreamBase* pStream, int commandId) \ -{ \ - return pStream->isCommandSupported(commandId); \ -} \ - \ -ONI_C_API_EXPORT OniStatus oniDriverStreamStart(oni::driver::StreamBase* pStream) \ -{ \ - return pStream->start(); \ -} \ -ONI_C_API_EXPORT void oniDriverStreamStop(oni::driver::StreamBase* pStream) \ -{ \ - pStream->stop(); \ -} \ - \ -ONI_C_API_EXPORT int oniDriverStreamGetRequiredFrameSize(oni::driver::StreamBase* pStream) \ -{ \ - return pStream->getRequiredFrameSize(); \ -} \ - \ -ONI_C_API_EXPORT void oniDriverStreamSetNewFrameCallback(oni::driver::StreamBase* pStream, \ - oni::driver::NewFrameCallback handler, void* pCookie) \ -{ \ - pStream->setNewFrameCallback(handler, pCookie); \ -} \ - \ -ONI_C_API_EXPORT OniStatus oniDriverStreamConvertDepthToColorCoordinates(oni::driver::StreamBase* pDepthStream, \ - oni::driver::StreamBase* pColorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) \ -{ \ - return pDepthStream->convertDepthToColorCoordinates(pColorStream, depthX, depthY, depthZ, pColorX, pColorY); \ -} \ - \ -ONI_C_API_EXPORT void* oniDriverEnableFrameSync(oni::driver::StreamBase** pStreams, int streamCount) \ -{ \ - return g_pDriver->enableFrameSync(pStreams, streamCount); \ -} \ - \ -ONI_C_API_EXPORT void oniDriverDisableFrameSync(void* frameSyncGroup) \ -{ \ - return g_pDriver->disableFrameSync(frameSyncGroup); \ -} \ - -#endif // _ONI_DRIVER_API_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h deleted file mode 100644 index fe8cd44c9..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Driver/OniDriverTypes.h +++ /dev/null @@ -1,54 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_DRIVER_TYPES_H_ -#define _ONI_DRIVER_TYPES_H_ - -#include -#include - -#define ONI_STREAM_PROPERTY_PRIVATE_BASE XN_MAX_UINT16 - -typedef struct -{ - int dataSize; - void* data; -} OniGeneralBuffer; - -/////// DriverServices -struct OniDriverServices -{ - void* driverServices; - void (ONI_CALLBACK_TYPE* errorLoggerAppend)(void* driverServices, const char* format, va_list args); - void (ONI_CALLBACK_TYPE* errorLoggerClear)(void* driverServices); - void (ONI_CALLBACK_TYPE* log)(void* driverServices, int severity, const char* file, int line, const char* mask, const char* message); -}; - -struct OniStreamServices -{ - void* streamServices; - int (ONI_CALLBACK_TYPE* getDefaultRequiredFrameSize)(void* streamServices); - OniFrame* (ONI_CALLBACK_TYPE* acquireFrame)(void* streamServices); // returns a frame with size corresponding to getRequiredFrameSize() - void (ONI_CALLBACK_TYPE* addFrameRef)(void* streamServices, OniFrame* pframe); - void (ONI_CALLBACK_TYPE* releaseFrame)(void* streamServices, OniFrame* pframe); -}; - - -#endif // _ONI_DRIVER_TYPES_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h deleted file mode 100644 index fb96323bd..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-Arm/OniPlatformLinux-Arm.h +++ /dev/null @@ -1,36 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_PLATFORM_LINUX_ARM_H_ -#define _ONI_PLATFORM_LINUX_ARM_H_ - -// Start with Linux-x86, and override what's different -#include "../Linux-x86/OniPlatformLinux-x86.h" - -//--------------------------------------------------------------------------- -// Platform Basic Definition -//--------------------------------------------------------------------------- -#undef ONI_PLATFORM -#undef ONI_PLATFORM_STRING -#define ONI_PLATFORM ONI_PLATFORM_LINUX_ARM -#define ONI_PLATFORM_STRING "Linux-Arm" - -#endif //_ONI_PLATFORM_LINUX_ARM_H_ - diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h deleted file mode 100644 index e5980f356..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Linux-x86/OniPlatformLinux-x86.h +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_PLATFORM_LINUX_X86_H_ -#define _ONI_PLATFORM_LINUX_X86_H_ - -//--------------------------------------------------------------------------- -// Prerequisites -//--------------------------------------------------------------------------- - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------------- -// Platform Basic Definition -//--------------------------------------------------------------------------- -#define ONI_PLATFORM ONI_PLATFORM_LINUX_X86 -#define ONI_PLATFORM_STRING "Linux-x86" - -//--------------------------------------------------------------------------- -// Platform Capabilities -//--------------------------------------------------------------------------- -#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN - -#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 - -//--------------------------------------------------------------------------- -// Memory -//--------------------------------------------------------------------------- -/** The default memory alignment. */ -#define ONI_DEFAULT_MEM_ALIGN 16 - -/** The thread static declarator (using TLS). */ -#define ONI_THREAD_STATIC __thread - -//--------------------------------------------------------------------------- -// Files -//--------------------------------------------------------------------------- -/** The maximum allowed file path size (in bytes). */ -#define ONI_FILE_MAX_PATH 256 - -//--------------------------------------------------------------------------- -// Call back -//--------------------------------------------------------------------------- -/** The std call type. */ -#define ONI_STDCALL __stdcall - -/** The call back calling convention. */ -#define ONI_CALLBACK_TYPE - -/** The C and C++ calling convension. */ -#define ONI_C_DECL - -//--------------------------------------------------------------------------- -// Macros -//--------------------------------------------------------------------------- -/** Returns the date and time at compile time. */ -#define ONI_TIMESTAMP __DATE__ " " __TIME__ - -/** Converts n into a pre-processor string. */ -#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) -#define ONI_STRINGIFY_HELPER(n) #n - -//--------------------------------------------------------------------------- -// API Export/Import Macros -//--------------------------------------------------------------------------- -/** Indicates an exported shared library function. */ -#define ONI_API_EXPORT __attribute__ ((visibility("default"))) - -/** Indicates an imported shared library function. */ -#define ONI_API_IMPORT - -/** Indicates a deprecated function */ -#define ONI_API_DEPRECATED(msg) __attribute__((warning("This function is deprecated: " msg))) - -#endif //_ONI_PLATFORM_LINUX_X86_H_ - diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h deleted file mode 100644 index 251256ebb..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/MacOSX/OniPlatformMacOSX.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** -* * -* PrimeSense PSCommon Library * -* Copyright (C) 2012 PrimeSense Ltd. * -* * -* This file is part of PSCommon. * -* * -* 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 _ONI_PLATFORM_MACOSX_H_ -#define _ONI_PLATFORM_MACOSX_H_ - -// Start with Linux-x86, and override what's different -#include "../Linux-x86/OniPlatformLinux-x86.h" - -#include - -#undef ONI_PLATFORM -#undef ONI_PLATFORM_STRING -#define ONI_PLATFORM ONI_PLATFORM_MACOSX -#define ONI_PLATFORM_STRING "MacOSX" - -#define ONI_PLATFORM_HAS_NO_TIMED_OPS -#define ONI_PLATFORM_HAS_NO_CLOCK_GETTIME -#define ONI_PLATFORM_HAS_NO_SCHED_PARAM -#define ONI_PLATFORM_HAS_BUILTIN_SEMUN - -#undef ONI_THREAD_STATIC -#define ONI_THREAD_STATIC - -#endif //_ONI_PLATFORM_MACOSX_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h deleted file mode 100644 index aea426d49..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCAPI.h +++ /dev/null @@ -1,259 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_C_API_H_ -#define _ONI_C_API_H_ - -#include "OniPlatform.h" -#include "OniCTypes.h" -#include "OniCProperties.h" -#include "OniVersion.h" - -/******************************************** General APIs */ - -/** Initialize OpenNI2. Use ONI_API_VERSION as the version. */ -ONI_C_API OniStatus oniInitialize(int apiVersion); -/** Shutdown OpenNI2 */ -ONI_C_API void oniShutdown(); - -/** - * Get the list of currently connected device. - * Each device is represented by its OniDeviceInfo. - * pDevices will be allocated inside. - */ -ONI_C_API OniStatus oniGetDeviceList(OniDeviceInfo** pDevices, int* pNumDevices); -/** Release previously allocated device list */ -ONI_C_API OniStatus oniReleaseDeviceList(OniDeviceInfo* pDevices); - -ONI_C_API OniStatus oniRegisterDeviceCallbacks(OniDeviceCallbacks* pCallbacks, void* pCookie, OniCallbackHandle* pHandle); -ONI_C_API void oniUnregisterDeviceCallbacks(OniCallbackHandle handle); - -/** Wait for any of the streams to have a new frame */ -ONI_C_API OniStatus oniWaitForAnyStream(OniStreamHandle* pStreams, int numStreams, int* pStreamIndex, int timeout); - -/** Get the current version of OpenNI2 */ -ONI_C_API OniVersion oniGetVersion(); - -/** Translate from format to number of bytes per pixel. Will return 0 for formats in which the number of bytes per pixel isn't fixed. */ -ONI_C_API int oniFormatBytesPerPixel(OniPixelFormat format); - -/** Get internal error */ -ONI_C_API const char* oniGetExtendedError(); - -/******************************************** Device APIs */ - -/** Open a device. Uri can be taken from the matching OniDeviceInfo. */ -ONI_C_API OniStatus oniDeviceOpen(const char* uri, OniDeviceHandle* pDevice); -/** Close a device */ -ONI_C_API OniStatus oniDeviceClose(OniDeviceHandle device); - -/** Get the possible configurations available for a specific source, or NULL if the source does not exist. */ -ONI_C_API const OniSensorInfo* oniDeviceGetSensorInfo(OniDeviceHandle device, OniSensorType sensorType); - -/** Get the OniDeviceInfo of a certain device. */ -ONI_C_API OniStatus oniDeviceGetInfo(OniDeviceHandle device, OniDeviceInfo* pInfo); - -/** Create a new stream in the device. The stream will originate from the source. */ -ONI_C_API OniStatus oniDeviceCreateStream(OniDeviceHandle device, OniSensorType sensorType, OniStreamHandle* pStream); - -ONI_C_API OniStatus oniDeviceEnableDepthColorSync(OniDeviceHandle device); -ONI_C_API void oniDeviceDisableDepthColorSync(OniDeviceHandle device); -ONI_C_API OniBool oniDeviceGetDepthColorSyncEnabled(OniDeviceHandle device); - -/** Set property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ -ONI_C_API OniStatus oniDeviceSetProperty(OniDeviceHandle device, int propertyId, const void* data, int dataSize); -/** Get property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ -ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, void* data, int* pDataSize); -/** Check if the property is supported by the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ -ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId); -/** Invoke an internal functionality of the device. */ -ONI_C_API OniStatus oniDeviceInvoke(OniDeviceHandle device, int commandId, void* data, int dataSize); -/** Check if a command is supported, for invoke */ -ONI_C_API OniBool oniDeviceIsCommandSupported(OniDeviceHandle device, int commandId); - -ONI_C_API OniBool oniDeviceIsImageRegistrationModeSupported(OniDeviceHandle device, OniImageRegistrationMode mode); - -/** @internal */ -ONI_C_API OniStatus oniDeviceOpenEx(const char* uri, const char* mode, OniDeviceHandle* pDevice); - -/******************************************** Stream APIs */ - -/** Destroy an existing stream */ -ONI_C_API void oniStreamDestroy(OniStreamHandle stream); - -/** Get the OniSensorInfo of the certain stream. */ -ONI_C_API const OniSensorInfo* oniStreamGetSensorInfo(OniStreamHandle stream); - -/** Start generating data from the stream. */ -ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream); -/** Stop generating data from the stream. */ -ONI_C_API void oniStreamStop(OniStreamHandle stream); - -/** Get the next frame from the stream. This function is blocking until there is a new frame from the stream. For timeout, use oniWaitForStreams() first */ -ONI_C_API OniStatus oniStreamReadFrame(OniStreamHandle stream, OniFrame** pFrame); - -/** Register a callback to when the stream has a new frame. */ -ONI_C_API OniStatus oniStreamRegisterNewFrameCallback(OniStreamHandle stream, OniNewFrameCallback handler, void* pCookie, OniCallbackHandle* pHandle); -/** Unregister a previously registered callback to when the stream has a new frame. */ -ONI_C_API void oniStreamUnregisterNewFrameCallback(OniStreamHandle stream, OniCallbackHandle handle); - -/** Set property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ -ONI_C_API OniStatus oniStreamSetProperty(OniStreamHandle stream, int propertyId, const void* data, int dataSize); -/** Get property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ -ONI_C_API OniStatus oniStreamGetProperty(OniStreamHandle stream, int propertyId, void* data, int* pDataSize); -/** Check if the property is supported the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ -ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId); -/** Invoke an internal functionality of the stream. */ -ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void* data, int dataSize); -/** Check if a command is supported, for invoke */ -ONI_C_API OniBool oniStreamIsCommandSupported(OniStreamHandle stream, int commandId); -/** Sets the stream buffer allocation functions. Note that this function may only be called while stream is not started. */ -ONI_C_API OniStatus oniStreamSetFrameBuffersAllocator(OniStreamHandle stream, OniFrameAllocBufferCallback alloc, OniFrameFreeBufferCallback free, void* pCookie); - -//// -/** Mark another user of the frame. */ -ONI_C_API void oniFrameAddRef(OniFrame* pFrame); -/** Mark that the frame is no longer needed. */ -ONI_C_API void oniFrameRelease(OniFrame* pFrame); - -// ONI_C_API OniStatus oniConvertRealWorldToProjective(OniStreamHandle stream, OniFloatPoint3D* pRealWorldPoint, OniFloatPoint3D* pProjectivePoint); -// ONI_C_API OniStatus oniConvertProjectiveToRealWorld(OniStreamHandle stream, OniFloatPoint3D* pProjectivePoint, OniFloatPoint3D* pRealWorldPoint); - -/** - * Creates a recorder that records to a file. - * @param [in] fileName The name of the file that will contain the recording. - * @param [out] pRecorder Points to the handle to the newly created recorder. - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniCreateRecorder(const char* fileName, OniRecorderHandle* pRecorder); - -/** - * Attaches a stream to a recorder. The amount of attached streams is virtually - * infinite. You cannot attach a stream after you have started a recording, if - * you do: an error will be returned by oniRecorderAttachStream. - * @param [in] recorder The handle to the recorder. - * @param [in] stream The handle to the stream. - * @param [in] allowLossyCompression Allows/denies lossy compression - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniRecorderAttachStream( - OniRecorderHandle recorder, - OniStreamHandle stream, - OniBool allowLossyCompression); - -/** - * Starts recording. There must be at least one stream attached to the recorder, - * if not: oniRecorderStart will return an error. - * @param[in] recorder The handle to the recorder. - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniRecorderStart(OniRecorderHandle recorder); - -/** - * Stops recording. You can resume recording via oniRecorderStart. - * @param[in] recorder The handle to the recorder. - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API void oniRecorderStop(OniRecorderHandle recorder); - -/** - * Stops recording if needed, and destroys a recorder. - * @param [in,out] recorder The handle to the recorder, the handle will be - * invalidated (nullified) when the function returns. - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniRecorderDestroy(OniRecorderHandle* pRecorder); - -ONI_C_API OniStatus oniCoordinateConverterDepthToWorld(OniStreamHandle depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ); - -ONI_C_API OniStatus oniCoordinateConverterWorldToDepth(OniStreamHandle depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ); - -ONI_C_API OniStatus oniCoordinateConverterDepthToColor(OniStreamHandle depthStream, OniStreamHandle colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY); - -/******************************************** Log APIs */ - -/** - * Change the log output folder - - * @param const char * strOutputFolder [in] path to the desirebale folder - * - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniSetLogOutputFolder(const char* strOutputFolder); - -/** - * Get the current log file name - - * @param char * strFileName [out] hold the returned file name - * @param int nBufferSize [in] size of strFileName - * - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniGetLogFileName(char* strFileName, int nBufferSize); - -/** - * Set the Minimum severity for log produce - - * @param const char * strMask [in] Name of the logger - * - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniSetLogMinSeverity(int nMinSeverity); - -/** - * Configures if log entries will be printed to console. - - * @param OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. - * - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniSetLogConsoleOutput(OniBool bConsoleOutput); - -/** - * Configures if log entries will be printed to a log file. - - * @param OniBool bFileOutput [in] TRUE to print log entries to the file, FALSE otherwise. - * - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput); - -#if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM -/** - * Configures if log entries will be printed to the Android log. - - * @param OniBool bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. - * - * @retval ONI_STATUS_OK Upon successful completion. - * @retval ONI_STATUS_ERROR Upon any kind of failure. - */ -ONI_C_API OniStatus oniSetLogAndroidOutput(OniBool bAndroidOutput); -#endif -#endif // _ONI_C_API_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h deleted file mode 100644 index d7f513b8c..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCEnums.h +++ /dev/null @@ -1,84 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_C_ENUMS_H_ -#define _ONI_C_ENUMS_H_ - -/** Possible failure values */ -typedef enum -{ - ONI_STATUS_OK = 0, - ONI_STATUS_ERROR = 1, - ONI_STATUS_NOT_IMPLEMENTED = 2, - ONI_STATUS_NOT_SUPPORTED = 3, - ONI_STATUS_BAD_PARAMETER = 4, - ONI_STATUS_OUT_OF_FLOW = 5, - ONI_STATUS_NO_DEVICE = 6, - ONI_STATUS_TIME_OUT = 102, -} OniStatus; - -/** The source of the stream */ -typedef enum -{ - ONI_SENSOR_IR = 1, - ONI_SENSOR_COLOR = 2, - ONI_SENSOR_DEPTH = 3, - -} OniSensorType; - -/** All available formats of the output of a stream */ -typedef enum -{ - // Depth - ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, - ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, - ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, - ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, - - // Color - ONI_PIXEL_FORMAT_RGB888 = 200, - ONI_PIXEL_FORMAT_YUV422 = 201, - ONI_PIXEL_FORMAT_GRAY8 = 202, - ONI_PIXEL_FORMAT_GRAY16 = 203, - ONI_PIXEL_FORMAT_JPEG = 204, - ONI_PIXEL_FORMAT_YUYV = 205, -} OniPixelFormat; - -typedef enum -{ - ONI_DEVICE_STATE_OK = 0, - ONI_DEVICE_STATE_ERROR = 1, - ONI_DEVICE_STATE_NOT_READY = 2, - ONI_DEVICE_STATE_EOF = 3 -} OniDeviceState; - -typedef enum -{ - ONI_IMAGE_REGISTRATION_OFF = 0, - ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, -} OniImageRegistrationMode; - -enum -{ - ONI_TIMEOUT_NONE = 0, - ONI_TIMEOUT_FOREVER = -1, -}; - -#endif // _ONI_C_ENUMS_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h deleted file mode 100644 index da13d58e4..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCProperties.h +++ /dev/null @@ -1,68 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_C_PROPERTIES_H_ -#define _ONI_C_PROPERTIES_H_ - -// Device properties -enum -{ - ONI_DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // By implementation - ONI_DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion - ONI_DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int - ONI_DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string - ONI_DEVICE_PROPERTY_ERROR_STATE = 4, // ?? - ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode - - // Files - ONI_DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float - ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool -}; - -// Stream properties -enum -{ - ONI_STREAM_PROPERTY_CROPPING = 0, // OniCropping* - ONI_STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians - ONI_STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians - ONI_STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* - - ONI_STREAM_PROPERTY_MAX_VALUE = 4, // int - ONI_STREAM_PROPERTY_MIN_VALUE = 5, // int - - ONI_STREAM_PROPERTY_STRIDE = 6, // int - ONI_STREAM_PROPERTY_MIRRORING = 7, // OniBool - - ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int - - // Camera - ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool - ONI_STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool - ONI_STREAM_PROPERTY_EXPOSURE = 102, // int - ONI_STREAM_PROPERTY_GAIN = 103, // int -}; - -// Device commands (for Invoke) -enum -{ - ONI_DEVICE_COMMAND_SEEK = 1, // OniSeek -}; - -#endif // _ONI_C_PROPERTIES_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h deleted file mode 100644 index 122469495..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniCTypes.h +++ /dev/null @@ -1,193 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_TYPES_H_ -#define _ONI_TYPES_H_ - -#include "OniPlatform.h" -#include "OniCEnums.h" - -/** Basic types **/ -typedef int OniBool; - -#ifndef TRUE -#define TRUE 1 -#endif //TRUE -#ifndef FALSE -#define FALSE 0 -#endif //FALSE - -#define ONI_MAX_STR 256 -#define ONI_MAX_SENSORS 10 - -struct OniCallbackHandleImpl; -typedef struct OniCallbackHandleImpl* OniCallbackHandle; - -/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ -typedef struct -{ - /** Major version number, incremented for major API restructuring. */ - int major; - /** Minor version number, incremented when significant new features added. */ - int minor; - /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ - int maintenance; - /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ - int build; -} OniVersion; - -typedef int OniHardwareVersion; - -/** Description of the output: format and resolution */ -typedef struct -{ - OniPixelFormat pixelFormat; - int resolutionX; - int resolutionY; - int fps; -} OniVideoMode; - -/** List of supported video modes by a specific source */ -typedef struct -{ - OniSensorType sensorType; - int numSupportedVideoModes; - OniVideoMode *pSupportedVideoModes; -} OniSensorInfo; - -/** Basic description of a device */ -typedef struct -{ - char uri[ONI_MAX_STR]; - char vendor[ONI_MAX_STR]; - char name[ONI_MAX_STR]; - uint16_t usbVendorId; - uint16_t usbProductId; -} OniDeviceInfo; - -struct _OniDevice; -typedef _OniDevice* OniDeviceHandle; - -struct _OniStream; -typedef _OniStream* OniStreamHandle; - -struct _OniRecorder; -typedef _OniRecorder* OniRecorderHandle; - -/** All information of the current frame */ -typedef struct -{ - int dataSize; - void* data; - - OniSensorType sensorType; - uint64_t timestamp; - int frameIndex; - - int width; - int height; - - OniVideoMode videoMode; - OniBool croppingEnabled; - int cropOriginX; - int cropOriginY; - - int stride; -} OniFrame; - -typedef void (ONI_CALLBACK_TYPE* OniNewFrameCallback)(OniStreamHandle stream, void* pCookie); -typedef void (ONI_CALLBACK_TYPE* OniGeneralCallback)(void* pCookie); -typedef void (ONI_CALLBACK_TYPE* OniDeviceInfoCallback)(const OniDeviceInfo* pInfo, void* pCookie); -typedef void (ONI_CALLBACK_TYPE* OniDeviceStateCallback)(const OniDeviceInfo* pInfo, OniDeviceState deviceState, void* pCookie); - -typedef void* (ONI_CALLBACK_TYPE* OniFrameAllocBufferCallback)(int size, void* pCookie); -typedef void (ONI_CALLBACK_TYPE* OniFrameFreeBufferCallback)(void* data, void* pCookie); - -typedef struct -{ - OniDeviceInfoCallback deviceConnected; - OniDeviceInfoCallback deviceDisconnected; - OniDeviceStateCallback deviceStateChanged; -} OniDeviceCallbacks; - -typedef struct -{ - int enabled; - int originX; - int originY; - int width; - int height; -} OniCropping; - -// Pixel types -/** -Pixel type used to store depth images. -*/ -typedef uint16_t OniDepthPixel; - -/** -Pixel type used to store 16-bit grayscale images -*/ -typedef uint16_t OniGrayscale16Pixel; - -/** -Pixel type used to store 8-bit grayscale/bayer images -*/ -typedef uint8_t OniGrayscale8Pixel; - -#pragma pack (push, 1) - -/** Holds the value of a single color image pixel in 24-bit RGB format. */ -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; -} OniRGB888Pixel; - -/** - Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). - The first pixel has the values y1, u, v. - The second pixel has the values y2, u, v. -*/ -typedef struct -{ - /** First chrominance value for two pixels, stored as blue luminance difference signal. */ - uint8_t u; - /** Overall luminance value of first pixel. */ - uint8_t y1; - /** Second chrominance value for two pixels, stored as red luminance difference signal. */ - uint8_t v; - /** Overall luminance value of second pixel. */ - uint8_t y2; -} OniYUV422DoublePixel; - -#pragma pack (pop) - -typedef struct -{ - int frameIndex; - OniStreamHandle stream; -} OniSeek; - -#endif // _ONI_TYPES_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h deleted file mode 100644 index 018f22271..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniEnums.h +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_ENUMS_H_ -#define _ONI_ENUMS_H_ - -namespace openni -{ - -/** Possible failure values */ -typedef enum -{ - STATUS_OK = 0, - STATUS_ERROR = 1, - STATUS_NOT_IMPLEMENTED = 2, - STATUS_NOT_SUPPORTED = 3, - STATUS_BAD_PARAMETER = 4, - STATUS_OUT_OF_FLOW = 5, - STATUS_NO_DEVICE = 6, - STATUS_TIME_OUT = 102, -} Status; - -/** The source of the stream */ -typedef enum -{ - SENSOR_IR = 1, - SENSOR_COLOR = 2, - SENSOR_DEPTH = 3, - -} SensorType; - -/** All available formats of the output of a stream */ -typedef enum -{ - // Depth - PIXEL_FORMAT_DEPTH_1_MM = 100, - PIXEL_FORMAT_DEPTH_100_UM = 101, - PIXEL_FORMAT_SHIFT_9_2 = 102, - PIXEL_FORMAT_SHIFT_9_3 = 103, - - // Color - PIXEL_FORMAT_RGB888 = 200, - PIXEL_FORMAT_YUV422 = 201, - PIXEL_FORMAT_GRAY8 = 202, - PIXEL_FORMAT_GRAY16 = 203, - PIXEL_FORMAT_JPEG = 204, - PIXEL_FORMAT_YUYV = 205, -} PixelFormat; - -typedef enum -{ - DEVICE_STATE_OK = 0, - DEVICE_STATE_ERROR = 1, - DEVICE_STATE_NOT_READY = 2, - DEVICE_STATE_EOF = 3 -} DeviceState; - -typedef enum -{ - IMAGE_REGISTRATION_OFF = 0, - IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, -} ImageRegistrationMode; - -static const int TIMEOUT_NONE = 0; -static const int TIMEOUT_FOREVER = -1; - -} // namespace openni - -#endif // _ONI_ENUMS_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h deleted file mode 100644 index 65f6904dc..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniPlatform.h +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_PLATFORM_H_ -#define _ONI_PLATFORM_H_ - -// Supported platforms -#define ONI_PLATFORM_WIN32 1 -#define ONI_PLATFORM_LINUX_X86 2 -#define ONI_PLATFORM_LINUX_ARM 3 -#define ONI_PLATFORM_MACOSX 4 -#define ONI_PLATFORM_ANDROID_ARM 5 - -#if (defined _WIN32) -# ifndef RC_INVOKED -# if _MSC_VER < 1300 -# error OpenNI Platform Abstraction Layer - Win32 - Microsoft Visual Studio version below 2003 (7.0) are not supported! -# endif -# endif -# include "Win32/OniPlatformWin32.h" -#elif defined (ANDROID) && defined (__arm__) -# include "Android-Arm/OniPlatformAndroid-Arm.h" -#elif (__linux__ && (__i386__ || __x86_64__)) -# include "Linux-x86/OniPlatformLinux-x86.h" -#elif (__linux__ && __arm__) -# include "Linux-Arm/OniPlatformLinux-Arm.h" -#elif _ARC -# include "ARC/OniPlaformARC.h" -#elif (__APPLE__) -# include "MacOSX/OniPlatformMacOSX.h" -#else -# error Xiron Platform Abstraction Layer - Unsupported Platform! -#endif - -#ifdef __cplusplus -# define ONI_C extern "C" -# define ONI_C_API_EXPORT ONI_C ONI_API_EXPORT -# define ONI_C_API_IMPORT ONI_C ONI_API_IMPORT -# define ONI_CPP_API_EXPORT ONI_API_EXPORT -# define ONI_CPP_API_IMPORT ONI_API_IMPORT -#else // __cplusplus -# define ONI_C_API_EXPORT ONI_API_EXPORT -# define ONI_C_API_IMPORT ONI_API_IMPORT -#endif // __cplusplus - -#ifdef OPENNI2_EXPORT -# define ONI_C_API ONI_C_API_EXPORT -# define ONI_CPP_API ONI_CPP_API_EXPORT -#else // OPENNI2_EXPORT -# define ONI_C_API ONI_C_API_IMPORT -# define ONI_CPP_API ONI_CPP_API_IMPORT -#endif // OPENNI2_EXPORT - - -#endif // _ONI_PLATFORM_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h deleted file mode 100644 index 19b0805a9..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniProperties.h +++ /dev/null @@ -1,73 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_PROPERTIES_H_ -#define _ONI_PROPERTIES_H_ - -namespace openni -{ - -// Device properties -enum -{ - DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // string - DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion - DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int - DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string - DEVICE_PROPERTY_ERROR_STATE = 4, // ?? - DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode - - // Files - DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float - DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool -}; - -// Stream properties -enum -{ - STREAM_PROPERTY_CROPPING = 0, // OniCropping* - STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians - STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians - STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* - - STREAM_PROPERTY_MAX_VALUE = 4, // int - STREAM_PROPERTY_MIN_VALUE = 5, // int - - STREAM_PROPERTY_STRIDE = 6, // int - STREAM_PROPERTY_MIRRORING = 7, // OniBool - - STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int - - // Camera - STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool - STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool - STREAM_PROPERTY_EXPOSURE = 102, // int - STREAM_PROPERTY_GAIN = 103, // int - -}; - -// Device commands (for Invoke) -enum -{ - DEVICE_COMMAND_SEEK = 1, // OniSeek -}; - -} // namespace openni -#endif // _ONI_PROPERTIES_H_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h deleted file mode 100644 index 7aa13ed58..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OniVersion.h +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** -* * -* 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. * -* * -*****************************************************************************/ -#include "OniPlatform.h" - -#define ONI_VERSION_MAJOR 2 -#define ONI_VERSION_MINOR 2 -#define ONI_VERSION_MAINTENANCE 0 -#define ONI_VERSION_BUILD 33 - -/** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */ -#define ONI_BRIEF_VERSION_STRING \ - ONI_STRINGIFY(ONI_VERSION_MAJOR) "." \ - ONI_STRINGIFY(ONI_VERSION_MINOR) "." \ - ONI_STRINGIFY(ONI_VERSION_MAINTENANCE) \ - " (Build " ONI_STRINGIFY(ONI_VERSION_BUILD) ")" - -/** OpenNI version (in numeric format): (OpenNI major version * 100000000 + OpenNI minor version * 1000000 + OpenNI maintenance version * 10000 + OpenNI build version). */ -#define ONI_VERSION (ONI_VERSION_MAJOR*100000000 + ONI_VERSION_MINOR*1000000 + ONI_VERSION_MAINTENANCE*10000 + ONI_VERSION_BUILD) -#define ONI_CREATE_API_VERSION(major, minor) ((major)*1000 + (minor)) -#define ONI_API_VERSION ONI_CREATE_API_VERSION(ONI_VERSION_MAJOR, ONI_VERSION_MINOR) - -/** OpenNI version (in string format): "Major.Minor.Maintenance.Build-Platform (MMM DD YYYY HH:MM:SS)". */ -#define ONI_VERSION_STRING \ - ONI_BRIEF_VERSION_STRING "-" \ - ONI_PLATFORM_STRING " (" ONI_TIMESTAMP ")" diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h deleted file mode 100644 index 52324b4eb..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/OpenNI.h +++ /dev/null @@ -1,2750 +0,0 @@ -/***************************************************************************** -* * -* 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" - -/** -openni is the namespace of the entire C++ API of OpenNI -*/ -namespace openni -{ - -/** Pixel type used to store depth images. */ -typedef uint16_t DepthPixel; - -/** Pixel type used to store IR images. */ -typedef uint16_t Grayscale16Pixel; - -// structs -/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ -typedef struct -{ - /** Major version number, incremented for major API restructuring. */ - int major; - /** Minor version number, incremented when significant new features added. */ - int minor; - /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ - int maintenance; - /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ - int build; -} Version; - -/** Holds the value of a single color image pixel in 24-bit RGB format. */ -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; - -/** - Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). - The first pixel has the values y1, u, v. - The second pixel has the values y2, u, v. -*/ -typedef struct -{ - /** First chrominance value for two pixels, stored as blue luminance difference signal. */ - uint8_t u; - /** Overall luminance value of first pixel. */ - uint8_t y1; - /** Second chrominance value for two pixels, stored as red luminance difference signal. */ - uint8_t v; - /** Overall luminance value of second pixel. */ - uint8_t y2; -} YUV422DoublePixel; - -/** This special URI can be passed to @ref Device::open() when the application has no concern for a specific device. */ -#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 - -/** -Provides a simple array class used throughout the API. Wraps a primitive array -of objects, holding the elements and their count. -*/ -template -class Array -{ -public: - /** - Default constructor. Creates an empty Array and sets the element count to zero. - */ - Array() : m_data(NULL), m_count(0), m_owner(false) {} - - /** - Constructor. Creates new Array from an existing primitive array of known size. - - @tparam [in] T Object type this Array will contain. - @param [in] data Pointer to a primitive array of objects of type T. - @param [in] count Number of elements in the primitive array pointed to by data. - */ - Array(const T* data, int count) : m_owner(false) { _setData(data, count); } - - /** - Destructor. Destroys the Array object. - */ - ~Array() - { - clear(); - } - - /** - Getter function for the Array size. - @returns Current number of elements in the Array. - */ - int getSize() const { return m_count; } - - /** - Implements the array indexing operator for the Array class. - */ - const T& operator[](int index) const {return m_data[index];} - - /** - @internal - Setter function for data. Causes this array to wrap an existing primitive array - of specified type. The optional data ownership flag controls whether the primitive - array this Array wraps will be destroyed when this Array is deconstructed. - @param [in] T Type of objects array will contain. - @param [in] data Pointer to first object in list. - @param [in] count Number of objects in list. - @param [in] isOwner Optional flag to indicate data ownership - */ - 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&); - Array& operator=(const Array&); - - 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; - -/** -Encapsulates a group of settings for a @ref VideoStream. Settings stored include -frame rate, resolution, and pixel format. - -This class is used as an input for changing the settings of a @ref VideoStream, -as well as an output for reporting the current settings of that class. It is also used -by @ref SensorInfo to report available video modes of a stream. - -Recommended practice is to use @ref SensorInfo::getSupportedVideoModes() -to obtain a list of valid video modes, and then to use items from that list to pass -new settings to @ref VideoStream. This is much less likely to produce an -invalid video mode than instantiating and manually changing objects of this -class. -*/ -class VideoMode : private OniVideoMode -{ -public: - /** - Default constructor, creates an empty VideoMode object. Application programs should, in most - cases, use the copy constructor to copy an existing valid video mode. This is much less - error prone that creating and attempting to configure a new VideoMode from scratch. - */ - VideoMode() - {} - - /** - Copy constructor, creates a new VideoMode identical to an existing VideoMode. - - @param [in] other Existing VideoMode to copy. - */ - VideoMode(const VideoMode& other) - { - *this = other; - } - - /** - Assignment operator. Sets the pixel format, frame rate, and resolution of this - VideoMode to equal that of a different VideoMode. - - @param [in] other Existing VideoMode to copy settings from. - */ - VideoMode& operator=(const VideoMode& other) - { - setPixelFormat(other.getPixelFormat()); - setResolution(other.getResolutionX(), other.getResolutionY()); - setFps(other.getFps()); - - return *this; - } - - /** - Getter function for the pixel format of this VideoMode. - @returns Current pixel format setting of this VideoMode. - */ - PixelFormat getPixelFormat() const { return (PixelFormat)pixelFormat; } - - /** - Getter function for the X resolution of this VideoMode. - @returns Current horizontal resolution of this VideoMode, in pixels. - */ - int getResolutionX() const { return resolutionX; } - - /** - Getter function for the Y resolution of this VideoMode. - @returns Current vertical resolution of this VideoMode, in pixels. - */ - int getResolutionY() const {return resolutionY;} - - /** - Getter function for the frame rate of this VideoMode. - @returns Current frame rate, measured in frames per second. - */ - int getFps() const { return fps; } - - /** - Setter function for the pixel format of this VideoMode. Application use of this - function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() - to obtain a list of valid video modes. - @param [in] format Desired new pixel format for this VideoMode. - */ - void setPixelFormat(PixelFormat format) { this->pixelFormat = (OniPixelFormat)format; } - - /** - Setter function for the resolution of this VideoMode. Application use of this - function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() to - obtain a list of valid video modes. - @param [in] resolutionX Desired new horizontal resolution in pixels. - @param [in] resolutionY Desired new vertical resolution in pixels. - */ - void setResolution(int resolutionX, int resolutionY) - { - this->resolutionX = resolutionX; - this->resolutionY = resolutionY; - } - - /** - Setter function for the frame rate. Application use of this function is not recommended. - Instead, use @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid - video modes. - @param [in] fps Desired new frame rate, measured in frames per second. - */ - void setFps(int fps) { this->fps = fps; } - - friend class SensorInfo; - friend class VideoStream; - friend class VideoFrameRef; -}; - -/** -The SensorInfo class encapsulates all info related to a specific sensor in a specific -device. -A @ref Device object holds a SensorInfo object for each sensor it contains. -A @ref VideoStream object holds one SensorInfo object, describing the sensor used to produce that stream. - -A given SensorInfo object will contain the type of the sensor (Depth, IR or Color), and -a list of all video modes that the sensor can support. Each available video mode will have a single -VideoMode object that can be queried to get the details of that mode. - -SensorInfo objects should be the only source of VideoMode objects for the vast majority of -application programs. - -Application programs will never directly instantiate objects of type SensorInfo. In fact, no -public constructors are provided. SensorInfo objects should be obtained either from a Device or @ref VideoStream, -and in turn be used to provide available video modes for that sensor. -*/ -class SensorInfo -{ -public: - /** - Provides the sensor type of the sensor this object is associated with. - @returns Type of the sensor. - */ - SensorType getSensorType() const { return (SensorType)m_pInfo->sensorType; } - - /** - Provides a list of video modes that this sensor can support. This function is the - recommended method to be used by applications to obtain @ref VideoMode objects. - - @returns Reference to an array of @ref VideoMode objects, one for each supported - video mode. - */ - const Array& 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(pInfo->pSupportedVideoModes), pInfo->numSupportedVideoModes); - } - } - - const OniSensorInfo* m_pInfo; - Array m_videoModes; - - friend class VideoStream; - friend class Device; -}; - -/** -The DeviceInfo class encapsulates info related to a specific device. - -Applications will generally obtain objects of this type via calls to @ref OpenNI::enumerateDevices() or -@ref openni::Device::getDeviceInfo(), and then use the various accessor functions to obtain specific -information on that device. - -There should be no reason for application code to instantiate this object directly. -*/ -class DeviceInfo : private OniDeviceInfo -{ -public: - /** - Returns the device URI. URI can be used by @ref Device::open to open a specific device. - The URI string format is determined by the driver. - */ - const char* getUri() const { return uri; } - /** Returns a the vendor name for this device. */ - const char* getVendor() const { return vendor; } - /** Returns the device name for this device. */ - const char* getName() const { return name; } - /** Returns the USB VID code for this device. */ - uint16_t getUsbVendorId() const { return usbVendorId; } - /** Returns the USB PID code for this device. */ - uint16_t getUsbProductId() const { return usbProductId; } - - friend class Device; - friend class OpenNI; -}; - -/** -The @ref VideoFrameRef class encapsulates a single video frame - the output of a @ref VideoStream at a specific time. -The data contained will be a single frame of color, IR, or depth video, along with associated meta data. - -An object of type @ref VideoFrameRef does not actually hold the data of the frame, but only a reference to it. The -reference can be released by destroying the @ref VideoFrameRef object, or by calling the @ref release() method. The -actual data of the frame is freed when the last reference to it is released. - -The usual way to obtain @ref VideoFrameRef objects is by a call to @ref VideoStream.:readFrame(). - -All data references by a @ref VideoFrameRef is stored as a primitive array of pixels. Each pixel will be -of a type according to the configured pixel format (see @ref VideoMode). -*/ -class VideoFrameRef -{ -public: - /** - Default constructor. Creates a new empty @ref VideoFrameRef object. - This object will be invalid until initialized by a call to @ref VideoStream::readFrame(). - */ - VideoFrameRef() - { - m_pFrame = NULL; - } - - /** - Destroy this object and release the reference to the frame. - */ - ~VideoFrameRef() - { - release(); - } - - /** - Copy constructor. Creates a new @ref VideoFrameRef object. The newly created - object will reference the same frame current object references. - @param [in] other Another @ref VideoFrameRef object. - */ - VideoFrameRef(const VideoFrameRef& other) : m_pFrame(NULL) - { - _setFrame(other.m_pFrame); - } - - /** - Make this @ref VideoFrameRef object reference the same frame that the @c other frame references. - If this object referenced another frame before calling this method, the previous frame will be released. - @param [in] other Another @ref VideoFrameRef object. - */ - VideoFrameRef& operator=(const VideoFrameRef& other) - { - _setFrame(other.m_pFrame); - return *this; - } - - /** - Getter function for the size of the data contained by this object. Useful primarily - when allocating buffers. - @returns Current size of data pointed to by this object, measured in bytes. - */ - inline int getDataSize() const - { - return m_pFrame->dataSize; - } - - /** - Getter function for the array of data pointed to by this object. - @returns Pointer to the actual frame data array. Type of data - pointed to can be determined according to the pixel format (can be obtained by calling @ref getVideoMode()). - */ - inline const void* getData() const - { - return m_pFrame->data; - } - - /** - Getter function for the sensor type used to produce this frame. Used to determine whether - this is an IR, Color or Depth frame. See the @ref SensorType enumeration for all possible return - values from this function. - @returns The type of sensor used to produce this frame. - */ - inline SensorType getSensorType() const - { - return (SensorType)m_pFrame->sensorType; - } - - /** - Returns a reference to the @ref VideoMode object assigned to this frame. This object describes - the video mode the sensor was configured to when the frame was produced and can be used - to determine the pixel format and resolution of the data. It will also provide the frame rate - that the sensor was running at when it recorded this frame. - @returns Reference to the @ref VideoMode assigned to this frame. - */ - inline const VideoMode& getVideoMode() const - { - return static_cast(m_pFrame->videoMode); - } - - /** - Provides a timestamp for the frame. The 'zero' point for this stamp - is implementation specific, but all streams from the same device are guaranteed to use the same zero. - This value can therefore be used to compute time deltas between frames from the same device, - regardless of whether they are from the same stream. - @returns Timestamp of frame, measured in microseconds from an arbitrary zero - */ - inline uint64_t getTimestamp() const - { - return m_pFrame->timestamp; - } - - /** - Frames are provided sequential frame ID numbers by the sensor that produced them. If frame - synchronization has been enabled for a device via @ref Device::setDepthColorSyncEnabled(), then frame - numbers for corresponding frames of depth and color are guaranteed to match. - - If frame synchronization is not enabled, then there is no guarantee of matching frame indexes between - @ref VideoStream "VideoStreams". In the latter case, applications should use timestamps instead of frame indexes to - align frames in time. - @returns Index number for this frame. - */ - inline int getFrameIndex() const - { - return m_pFrame->frameIndex; - } - - /** - Gives the current width of this frame, measured in pixels. If cropping is enabled, this will be - the width of the cropping window. If cropping is not enabled, then this will simply be equal to - the X resolution of the @ref VideoMode used to produce this frame. - @returns Width of this frame in pixels. - */ - inline int getWidth() const - { - return m_pFrame->width; - } - - /** - Gives the current height of this frame, measured in pixels. If cropping is enabled, this will - be the length of the cropping window. If cropping is not enabled, then this will simply be equal - to the Y resolution of the @ref VideoMode used to produce this frame. - */ - inline int getHeight() const - { - return m_pFrame->height; - } - - /** - Indicates whether cropping was enabled when the frame was produced. - @return true if cropping is enabled, false otherwise - */ - inline bool getCroppingEnabled() const - { - return m_pFrame->croppingEnabled == TRUE; - } - - /** - Indicates the X coordinate of the upper left corner of the crop window. - @return Distance of crop origin from left side of image, in pixels. - */ - inline int getCropOriginX() const - { - return m_pFrame->cropOriginX; - } - - /** - Indicates the Y coordinate of the upper left corner of the crop window. - @return Distance of crop origin from top of image, in pixels. - */ - inline int getCropOriginY() const - { - return m_pFrame->cropOriginY; - } - - /** - Gives the length of one row of pixels, measured in bytes. Primarily useful - for indexing the array which contains the data. - @returns Stride of the array which contains the image for this frame, in bytes - */ - inline int getStrideInBytes() const - { - return m_pFrame->stride; - } - - /** - Check if this object references an actual frame. - */ - inline bool isValid() const - { - return m_pFrame != NULL; - } - - /** - Release the reference to the frame. Once this method is called, the object becomes invalid, and no method - should be called other than the assignment operator, or passing this object to a @ref VideoStream::readFrame() call. - */ - void release() - { - if (m_pFrame != NULL) - { - oniFrameRelease(m_pFrame); - m_pFrame = NULL; - } - } - - /** @internal */ - void _setFrame(OniFrame* pFrame) - { - setReference(pFrame); - if (pFrame != NULL) - { - oniFrameAddRef(pFrame); - } - } - - /** @internal */ - 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!!? -}; - -/** -The @ref VideoStream object encapsulates a single video stream from a device. Once created, it is used to start data flow -from the device, and to read individual frames of data. This is the central class used to obtain data in OpenNI. It -provides the ability to manually read data in a polling loop, as well as providing events and a Listener class that can be -used to implement event-driven data acquisition. - -Aside from the video data frames themselves, the class offers a number of functions used for obtaining information about a -@ref VideoStream. Field of view, available video modes, and minimum and maximum valid pixel values can all be obtained. - -In addition to obtaining data, the @ref VideoStream object is used to set all configuration properties that apply to a specific -stream (rather than to an entire device). In particular, it is used to control cropping, mirroring, and video modes. - -A pointer to a valid, initialized device that provides the desired stream type is required to create a stream. - -Several video streams can be created to stream data from the same sensor. This is useful if several components of an application -need to read frames separately. - -While some device might allow different streams -from the same sensor to have different configurations, most devices will have a single configuration for the sensor, -shared by all streams. -*/ -class VideoStream -{ -public: - /** - The @ref VideoStream::NewFrameListener class is provided to allow the implementation of event driven frame reading. To use - it, create a class that inherits from it and implement override the onNewFrame() method. Then, register - your created class with an active @ref VideoStream using the @ref VideoStream::addNewFrameListener() function. Once this is done, the - event handler function you implemented will be called whenever a new frame becomes available. You may call - @ref VideoStream::readFrame() from within the event handler. - */ - class NewFrameListener - { - public: - /** - Default constructor. - */ - NewFrameListener() : m_callbackHandle(NULL) - { - } - - virtual ~NewFrameListener() - { - } - - /** - Derived classes should implement this function to handle new frames. - */ - 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); - } - }; - - /** - Default constructor. Creates a new, non-valid @ref VideoStream object. The object created will be invalid until its create() function - is called with a valid Device. - */ - VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true) - {} - - /** - Handle constructor. Creates a VideoStream object based on the given initialized handle. - This object will not destroy the underlying handle when @ref destroy() or destructor is called - */ - explicit VideoStream(OniStreamHandle handle) : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(false) - { - _setHandle(handle); - } - - /** - Destructor. The destructor calls the destroy() function, but it is considered a best practice for applications to - call destroy() manually on any @ref VideoStream that they run create() on. - */ - ~VideoStream() - { - destroy(); - } - - /** - Checks to see if this object has been properly initialized and currently points to a valid stream. - @returns true if this object has been previously initialized, false otherwise. - */ - bool isValid() const - { - return m_stream != NULL; - } - - /** - Creates a stream of frames from a specific sensor type of a specific device. You must supply a reference to a - Device that supplies the sensor type requested. You can use @ref Device::hasSensor() to check whether a - given sensor is available on your target device before calling create(). - - @param [in] device A reference to the @ref Device you want to create the stream on. - @param [in] sensorType The type of sensor the stream should produce data from. - @returns Status code indicating success or failure for this operation. - */ - inline Status create(const Device& device, SensorType sensorType); - - /** - Destroy this stream. This function is currently called automatically by the destructor, but it is - considered a best practice for applications to manually call this function on any @ref VideoStream that they - call create() for. - */ - inline void destroy(); - - /** - Provides the @ref SensorInfo object associated with the sensor that is producing this @ref VideoStream. Note that - this function will return NULL if the stream has not yet been initialized with the create() function. - - @ref SensorInfo is useful primarily as a means of learning which video modes are valid for this VideoStream. - - @returns Reference to the SensorInfo object associated with the sensor providing this stream. - */ - const SensorInfo& getSensorInfo() const - { - return m_sensorInfo; - } - - /** - Starts data generation from this video stream. - */ - Status start() - { - if (!isValid()) - { - return STATUS_ERROR; - } - - return (Status)oniStreamStart(m_stream); - } - - /** - Stops data generation from this video stream. - */ - void stop() - { - if (!isValid()) - { - return; - } - - oniStreamStop(m_stream); - } - - /** - Read the next frame from this video stream, delivered as a @ref VideoFrameRef. This is the primary - method for manually obtaining frames of video data. - If no new frame is available, the call will block until one is available. - To avoid blocking, use @ref VideoStream::Listener to implement an event driven architecture. Another - alternative is to use @ref OpenNI::waitForAnyStream() to wait for new frames from several streams. - - @param [out] pFrame Pointer to a @ref VideoFrameRef object to hold the reference to the new frame. - @returns Status code to indicated success or failure of this function. - */ - Status readFrame(VideoFrameRef* pFrame) - { - if (!isValid()) - { - return STATUS_ERROR; - } - - OniFrame* pOniFrame; - Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame); - - pFrame->setReference(pOniFrame); - return rc; - } - - /** - Adds a new Listener to receive this VideoStream onNewFrame event. See @ref VideoStream::NewFrameListener for - more information on implementing an event driven frame reading architecture. An instance of a listener can be added to only one source. - - @param [in] pListener Pointer to a @ref VideoStream::NewFrameListener object (or a derivative) that will respond to this event. - @returns Status code indicating success or failure of the operation. - */ - Status addNewFrameListener(NewFrameListener* pListener) - { - if (!isValid()) - { - return STATUS_ERROR; - } - - return (Status)oniStreamRegisterNewFrameCallback(m_stream, pListener->callback, pListener, &pListener->m_callbackHandle); - } - - /** - Removes a Listener from this video stream list. The listener removed will no longer receive new frame events from this stream. - @param [in] pListener Pointer to the listener object to be removed. - */ - void removeNewFrameListener(NewFrameListener* pListener) - { - if (!isValid()) - { - return; - } - - oniStreamUnregisterNewFrameCallback(m_stream, pListener->m_callbackHandle); - pListener->m_callbackHandle = NULL; - } - - /** - Sets the frame buffers allocator for this video stream. - @param [in] pAllocator Pointer to the frame buffers allocator object. Pass NULL to return to default frame allocator. - @returns ONI_STATUS_OUT_OF_FLOW The frame buffers allocator cannot be set while stream is streaming. - */ - 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); - } - } - - /** - @internal - Get an internal handle. This handle can be used via the C API. - */ - OniStreamHandle _getHandle() const - { - return m_stream; - } - - /** - Gets an object through which several camera settings can be configured. - @returns NULL if the stream doesn't support camera settings. - */ - CameraSettings* getCameraSettings() {return m_pCameraSettings;} - - /** - General function for obtaining the value of stream specific properties. - There are convenience functions available for all commonly used properties, so it is not - expected that applications will make direct use of the getProperty function very often. - - @param [in] propertyId The numerical ID of the property to be queried. - @param [out] data Place to store the value of the property. - @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. - @returns Status code indicating success or failure of this operation. - */ - Status getProperty(int propertyId, void* data, int* dataSize) const - { - if (!isValid()) - { - return STATUS_ERROR; - } - - return (Status)oniStreamGetProperty(m_stream, propertyId, data, dataSize); - } - - /** - General function for setting the value of stream specific properties. - There are convenience functions available for all commonly used properties, so it is not - expected that applications will make direct use of the setProperty function very often. - - @param [in] propertyId The numerical ID of the property to be set. - @param [in] data Place to store the data to be written to the property. - @param [in] dataSize Size of the data to be written to the property. - @returns Status code indicating success or failure of this operation. - */ - Status setProperty(int propertyId, const void* data, int dataSize) - { - if (!isValid()) - { - return STATUS_ERROR; - } - - return (Status)oniStreamSetProperty(m_stream, propertyId, data, dataSize); - } - - /** - Get the current video mode information for this video stream. - This includes its resolution, fps and stream format. - - @returns Current video mode information for this video stream. - */ - VideoMode getVideoMode() const - { - VideoMode videoMode; - getProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(&videoMode)); - return videoMode; - } - - /** - Changes the current video mode of this stream. Recommended practice is to use @ref Device::getSensorInfo(), and - then @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid video mode settings for this stream. Then, - pass a valid @ref VideoMode to @ref setVideoMode to ensure correct operation. - - @param [in] videoMode Desired new video mode for this stream. - returns Status code indicating success or failure of this operation. - */ - Status setVideoMode(const VideoMode& videoMode) - { - return setProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(videoMode)); - } - - /** - Provides the maximum possible value for pixels obtained by this stream. This is most useful for - getting the maximum possible value of depth streams. - @returns Maximum possible pixel value. - */ - int getMaxPixelValue() const - { - int maxValue; - Status rc = getProperty(STREAM_PROPERTY_MAX_VALUE, &maxValue); - if (rc != STATUS_OK) - { - return 0; - } - return maxValue; - } - - /** - Provides the smallest possible value for pixels obtains by this VideoStream. This is most useful - for getting the minimum possible value that will be reported by a depth stream. - @returns Minimum possible pixel value that can come from this stream. - */ - int getMinPixelValue() const - { - int minValue; - Status rc = getProperty(STREAM_PROPERTY_MIN_VALUE, &minValue); - if (rc != STATUS_OK) - { - return 0; - } - return minValue; - } - - /** - Checks whether this stream supports cropping. - @returns true if the stream supports cropping, false if it does not. - */ - bool isCroppingSupported() const - { - return isPropertySupported(STREAM_PROPERTY_CROPPING); - } - - /** - Obtains the current cropping settings for this stream. - @param [out] pOriginX X coordinate of the upper left corner of the cropping window - @param [out] pOriginY Y coordinate of the upper left corner of the cropping window - @param [out] pWidth Horizontal width of the cropping window, in pixels - @param [out] pHeight Vertical width of the cropping window, in pixels - returns true if cropping is currently enabled, false if it is not. - */ - bool getCropping(int* pOriginX, int* pOriginY, int* pWidth, int* pHeight) const - { - OniCropping cropping; - bool enabled = false; - - Status rc = getProperty(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; - } - - /** - Changes the cropping settings for this stream. You can use the @ref isCroppingSupported() - function to make sure cropping is supported before calling this function. - @param [in] originX New X coordinate of the upper left corner of the cropping window. - @param [in] originY New Y coordinate of the upper left corner of the cropping window. - @param [in] width New horizontal width for the cropping window, in pixels. - @param [in] height New vertical height for the cropping window, in pixels. - @returns Status code indicating success or failure of this operation. - */ - 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(STREAM_PROPERTY_CROPPING, cropping); - } - - /** - Disables cropping. - @returns Status code indicating success or failure of this operation. - */ - Status resetCropping() - { - OniCropping cropping; - cropping.enabled = false; - return setProperty(STREAM_PROPERTY_CROPPING, cropping); - } - - /** - Check whether mirroring is currently turned on for this stream. - @returns true if mirroring is currently enabled, false otherwise. - */ - bool getMirroringEnabled() const - { - OniBool enabled; - Status rc = getProperty(STREAM_PROPERTY_MIRRORING, &enabled); - if (rc != STATUS_OK) - { - return false; - } - return enabled == TRUE; - } - - /** - Enable or disable mirroring for this stream. - @param [in] isEnabled true to enable mirroring, false to disable it. - @returns Status code indicating the success or failure of this operation. - */ - Status setMirroringEnabled(bool isEnabled) - { - return setProperty(STREAM_PROPERTY_MIRRORING, isEnabled ? TRUE : FALSE); - } - - /** - Gets the horizontal field of view of frames received from this stream. - @returns Horizontal field of view, in radians. - */ - float getHorizontalFieldOfView() const - { - float horizontal = 0; - getProperty(STREAM_PROPERTY_HORIZONTAL_FOV, &horizontal); - return horizontal; - } - - /** - Gets the vertical field of view of frames received from this stream. - @returns Vertical field of view, in radians. - */ - float getVerticalFieldOfView() const - { - float vertical = 0; - getProperty(STREAM_PROPERTY_VERTICAL_FOV, &vertical); - return vertical; - } - - /** - Function for setting a value of a stream property using an arbitrary input type. - There are convenience functions available for all commonly used properties, so it is not - expected that applications will make direct use of this function very often. - @tparam [in] T Data type of the value to be passed to the property. - @param [in] propertyId The numerical ID of the property to be set. - @param [in] value Data to be sent to the property. - @returns Status code indicating success or failure of this operation. - */ - template - Status setProperty(int propertyId, const T& value) - { - return setProperty(propertyId, &value, sizeof(T)); - } - - /** - Function for getting the value from a property using an arbitrary output type. - There are convenience functions available for all commonly used properties, so it is not - expected that applications will make direct use of this function very often. - @tparam [in] T Data type of the value to be read. - @param [in] propertyId The numerical ID of the property to be read. - @param [in, out] value Pointer to a place to store the value read from the property. - @returns Status code indicating success or failure of this operation. - */ - template - Status getProperty(int propertyId, T* value) const - { - int size = sizeof(T); - return getProperty(propertyId, value, &size); - } - - /** - Checks if a specific property is supported by the video stream. - @param [in] propertyId Property to be checked. - @returns true if the property is supported, false otherwise. - */ - bool isPropertySupported(int propertyId) const - { - if (!isValid()) - { - return false; - } - - return oniStreamIsPropertySupported(m_stream, propertyId) == TRUE; - } - - /** - Invokes a command that takes an arbitrary data type as its input. It is not expected that - application code will need this function frequently, as all commonly used properties have - higher level functions provided. - @param [in] commandId Numerical code of the property to be invoked. - @param [in] data Data to be passed to the property. - @param [in] dataSize size of the buffer passed in @c data. - @returns Status code indicating success or failure of this operation. - */ - Status invoke(int commandId, void* data, int dataSize) - { - if (!isValid()) - { - return STATUS_ERROR; - } - - return (Status)oniStreamInvoke(m_stream, commandId, data, dataSize); - } - - /** - Invokes a command that takes an arbitrary data type as its input. It is not expected that - application code will need this function frequently, as all commonly used properties have - higher level functions provided. - @tparam [in] T Type of data to be passed to the property. - @param [in] commandId Numerical code of the property to be invoked. - @param [in] value Data to be passed to the property. - @returns Status code indicating success or failure of this operation. - */ - template - Status invoke(int commandId, T& value) - { - return invoke(commandId, &value, sizeof(T)); - } - - /** - Checks if a specific command is supported by the video stream. - @param [in] commandId Command to be checked. - @returns true if the command is supported, false otherwise. - */ - 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; -}; - -/** -The Device object abstracts a specific device; either a single hardware device, or a file -device holding a recording from a hardware device. It offers the ability to connect to -the device, and obtain information about its configuration and the data streams it can offer. - -It provides the means to query and change all configuration parameters that apply to the -device as a whole. This includes enabling depth/color image registration and frame -synchronization. - -Devices are used when creating and initializing @ref VideoStream "VideoStreams" -- you will need a valid pointer to -a Device in order to use the VideoStream.create() function. This, along with configuration, is -the primary use of this class for application developers. - -Before devices can be created, @ref OpenNI::initialize() must have been run to make the device drivers -on the system available to the API. -*/ -class Device -{ -public: - /** - Default constructor. Creates a new empty Device object. This object will be invalid until it is initialized by - calling its open() function. - */ - Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true) - { - clearSensors(); - } - - /** - Handle constructor. Creates a Device object based on the given initialized handle. - This object will not destroy the underlying handle when @ref close() or destructor is called - */ - explicit Device(OniDeviceHandle handle) : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(false) - { - _setHandle(handle); - } - - /** - The destructor calls the @ref close() function, but it is considered a best practice for applications to - call @ref close() manually on any @ref Device that they run @ref open() on. - */ - ~Device() - { - if (m_device != NULL) - { - close(); - } - } - - /** - Opens a device. This can either open a device chosen arbitrarily from all devices - on the system, or open a specific device selected by passing this function the device URI. - - To open any device, simply pass the constant@ref ANY_DEVICE to this function. If multiple - devices are connected to the system, then one of them will be opened. This procedure is most - useful when it is known that exactly one device is (or can be) connected to the system. In that case, - requesting a list of all devices and iterating through it would be a waste of effort. - - If multiple devices are (or may be) connected to a system, then a URI will be required to select - a specific device to open. There are two ways to obtain a URI: from a DeviceConnected event, or - by calling @ref OpenNI::enumerateDevices(). - - In the case of a DeviceConnected event, the @ref OpenNI::Listener will be provided with a DeviceInfo object - as an argument to its @ref OpenNI::Listener::onDeviceConnected "onDeviceConnected()" function. - The DeviceInfo.getUri() function can then be used to obtain the URI. - - If the application is not using event handlers, then it can also call the static function - @ref OpenNI::enumerateDevices(). This will return an array of @ref DeviceInfo objects, one for each device - currently available to the system. The application can then iterate through this list and - select the desired device. The URI is again obtained via the @ref DeviceInfo::getUri() function. - - Standard codes of type Status are returned indicating whether opening was successful. - - @param [in] uri String containing the URI of the device to be opened, or @ref ANY_DEVICE. - @returns Status code with the outcome of the open operation. - - @remark For opening a recording file, pass the file path as a uri. - */ - inline Status open(const char* uri); - - /** - Closes the device. This properly closes any files or shuts down hardware, as appropriate. This - function is currently called by the destructor if not called manually by application code, but it - is considered a best practice to manually close any device that was opened. - */ - inline void close(); - - /** - Provides information about this device in the form of a DeviceInfo object. This object can - be used to access the URI of the device, as well as various USB descriptor strings that might - be useful to an application. - - Note that valid device info will not be available if this device has not yet been opened. If you are - trying to obtain a URI to open a device, use OpenNI::enumerateDevices() instead. - @returns DeviceInfo object for this Device - */ - const DeviceInfo& getDeviceInfo() const - { - return m_deviceInfo; - } - - /** - This function checks to see if one of the specific sensor types defined in @ref SensorType is - available on this device. This allows an application to, for example, query for the presence - of a depth sensor, or color sensor. - @param [in] sensorType of sensor to query for - @returns true if the Device supports the sensor queried, false otherwise. - */ - 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; - } - - /** - Get the @ref SensorInfo for a specific sensor type on this device. The @ref SensorInfo - is useful primarily for determining which video modes are supported by the sensor. - @param [in] sensorType of sensor to get information about. - @returns SensorInfo object corresponding to the sensor type specified, or NULL if such a sensor - is not available from this device. - */ - 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]; - } - - /** - @internal - Get an internal handle. This handle can be used via the C API. - */ - OniDeviceHandle _getHandle() const - { - return m_device; - } - - /** - Gets an object through which playback of a file device can be controlled. - @returns NULL if this device is not a file device. - */ - PlaybackControl* getPlaybackControl() {return m_pPlaybackControl;} - - /** - Get the value of a general property of the device. - There are convenience functions for all the commonly used properties, such as - image registration and frame synchronization. It is expected for this reason - that this function will rarely be directly used by applications. - - @param [in] propertyId Numerical ID of the property you would like to check. - @param [out] data Place to store the value of the property. - @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. - @returns Status code indicating results of this operation. - */ - Status getProperty(int propertyId, void* data, int* dataSize) const - { - return (Status)oniDeviceGetProperty(m_device, propertyId, data, dataSize); - } - - /** - Sets the value of a general property of the device. - There are convenience functions for all the commonly used properties, such as - image registration and frame synchronization. It is expected for this reason - that this function will rarely be directly used by applications. - - @param [in] propertyId The numerical ID of the property to be set. - @param [in] data Place to store the data to be written to the property. - @param [in] dataSize Size of the data to be written to the property. - @returns Status code indicating results of this operation. - */ - Status setProperty(int propertyId, const void* data, int dataSize) - { - return (Status)oniDeviceSetProperty(m_device, propertyId, data, dataSize); - } - - /** - Checks to see if this device can support registration of color video and depth video. - Image registration is used to properly superimpose two images from cameras located at different - points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about - registration. - @returns true if image registration is supported by this device, false otherwise. - */ - bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const - { - return (oniDeviceIsImageRegistrationModeSupported(m_device, (OniImageRegistrationMode)mode) == TRUE); - } - - /** - Gets the current image registration mode of this device. - Image registration is used to properly superimpose two images from cameras located at different - points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about - registration. - @returns Current image registration mode. See @ref ImageRegistrationMode for possible return values. - */ - ImageRegistrationMode getImageRegistrationMode() const - { - ImageRegistrationMode mode; - Status rc = getProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, &mode); - if (rc != STATUS_OK) - { - return IMAGE_REGISTRATION_OFF; - } - return mode; - } - - /** - Sets the image registration on this device. - Image registration is used to properly superimpose two images from cameras located at different - points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about - registration. - - See @ref ImageRegistrationMode for a list of valid settings to pass to this function. - - It is a good practice to first check if the mode is supported by calling @ref isImageRegistrationModeSupported(). - - @param [in] mode Desired new value for the image registration mode. - @returns Status code for the operation. - */ - Status setImageRegistrationMode(ImageRegistrationMode mode) - { - return setProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, mode); - } - - /** - Checks whether this Device object is currently connected to an actual file or hardware device. - @returns true if the Device is connected, false otherwise. - */ - bool isValid() const - { - return m_device != NULL; - } - - /** - Checks whether this device is a file device (i.e. a recording). - @returns true if this is a file device, false otherwise. - */ - bool isFile() const - { - return isPropertySupported(DEVICE_PROPERTY_PLAYBACK_SPEED) && - isPropertySupported(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED) && - isCommandSupported(DEVICE_COMMAND_SEEK); - } - - /** - Used to turn the depth/color frame synchronization feature on and off. When frame synchronization - is enabled, the device will deliver depth and image frames that are separated in time - by some maximum value. When disabled, the phase difference between depth and image frame - generation cannot be guaranteed. - @param [in] isEnabled Set to TRUE to enable synchronization, FALSE to disable it - @returns Status code indicating success or failure of this operation - */ - 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; - } - - /** - Sets a property that takes an arbitrary data type as its input. It is not expected that - application code will need this function frequently, as all commonly used properties have - higher level functions provided. - - @tparam T Type of data to be passed to the property. - @param [in] propertyId The numerical ID of the property to be set. - @param [in] value Place to store the data to be written to the property. - @returns Status code indicating success or failure of this operation. - */ - template - Status setProperty(int propertyId, const T& value) - { - return setProperty(propertyId, &value, sizeof(T)); - } - - /** - Checks a property that provides an arbitrary data type as its output. It is not expected that - application code will need this function frequently, as all commonly used properties have - higher level functions provided. - @tparam [in] T Data type of the value to be read. - @param [in] propertyId The numerical ID of the property to be read. - @param [in, out] value Pointer to a place to store the value read from the property. - @returns Status code indicating success or failure of this operation. - */ - template - Status getProperty(int propertyId, T* value) const - { - int size = sizeof(T); - return getProperty(propertyId, value, &size); - } - - /** - Checks if a specific property is supported by the device. - @param [in] propertyId Property to be checked. - @returns true if the property is supported, false otherwise. - */ - bool isPropertySupported(int propertyId) const - { - return oniDeviceIsPropertySupported(m_device, propertyId) == TRUE; - } - - /** - Invokes a command that takes an arbitrary data type as its input. It is not expected that - application code will need this function frequently, as all commonly used properties have - higher level functions provided. - @param [in] commandId Numerical code of the property to be invoked. - @param [in] data Data to be passed to the property. - @param [in] dataSize size of the buffer passed in @c data. - @returns Status code indicating success or failure of this operation. - */ - Status invoke(int commandId, void* data, int dataSize) - { - return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize); - } - - /** - Invokes a command that takes an arbitrary data type as its input. It is not expected that - application code will need this function frequently, as all commonly used properties have - higher level functions provided. - @tparam [in] T Type of data to be passed to the property. - @param [in] propertyId Numerical code of the property to be invoked. - @param [in] value Data to be passed to the property. - @returns Status code indicating success or failure of this operation. - */ - template - Status invoke(int propertyId, T& value) - { - return invoke(propertyId, &value, sizeof(T)); - } - - /** - Checks if a specific command is supported by the device. - @param [in] commandId Command to be checked. - @returns true if the command is supported, false otherwise. - */ - bool isCommandSupported(int commandId) const - { - return oniDeviceIsCommandSupported(m_device, commandId) == TRUE; - } - - /** @internal **/ - 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; -}; - -/** - * The PlaybackControl class provides access to a series of specific to playing back - * a recording from a file device. - * - * When playing a stream back from a recording instead of playing from a live device, - * it is possible to vary playback speed, change the current time location (ie - * fast forward / rewind / seek), specify whether the playback should be repeated at the end - * of the recording, and query the total size of the recording. - * - * Since none of these functions make sense in the context of a physical device, they are - * split out into a seperate playback control class. To use, simply create your file device, - * create a PlaybackControl, and then attach the PlaybackControl to the file device. - */ -class PlaybackControl -{ -public: - - /** - * Deconstructor. Destroys a PlaybackControl class. The deconstructor presently detaches - * from its recording automatically, but it is considered a best practice for applications to - * manually detach from any stream that was attached to. - */ - ~PlaybackControl() - { - detach(); - } - - /** - * Getter function for the current playback speed of this device. - * - * This value is expressed as a multiple of the speed the original - * recording was taken at. For example, if the original recording was at 30fps, and - * playback speed is set to 0.5, then the recording will play at 15fps. If playback speed - * is set to 2.0, then the recording would playback at 60fps. - * - * In addition, there are two "special" values. A playback speed of 0.0 indicates that the - * playback should occur as fast as the system is capable of returning frames. This is - * most useful when testing algorithms on large datasets, as it enables playback to be - * done at a much higher rate than would otherwise be possible. - * - * A value of -1 indicates that speed is "manual". In this mode, new frames will only - * become available when an application manually reads them. If used in a polling loop, - * this setting also enables systems to read and process frames limited only by - * available processing speeds. - * - * @returns Current playback speed of the device, measured as ratio of recording speed. - */ - float getSpeed() const - { - if (!isValid()) - { - return 0.0f; - } - float speed; - Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, &speed); - if (rc != STATUS_OK) - { - return 1.0f; - } - return speed; - } - /** - * Setter function for the playback speed of the device. For a full explaination of - * what this value means @see PlaybackControl::getSpeed(). - * - * @param [in] speed Desired new value of playback speed, as ratio of original recording. - * @returns Status code indicating success or failure of this operation. - */ - Status setSpeed(float speed) - { - if (!isValid()) - { - return STATUS_NO_DEVICE; - } - return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, speed); - } - - /** - * Gets the current repeat setting of the file device. - * - * @returns true if repeat is enabled, false if not enabled. - */ - bool getRepeatEnabled() const - { - if (!isValid()) - { - return false; - } - - OniBool repeat; - Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, &repeat); - if (rc != STATUS_OK) - { - return false; - } - - return repeat == TRUE; - } - - /** - * Changes the current repeat mode of the device. If repeat mode is turned on, then the recording will - * begin playback again at the beginning after the last frame is read. If turned off, no more frames - * will become available after last frame is read. - * - * @param [in] repeat New value for repeat -- true to enable, false to disable - * @returns Status code indicating success or failure of this operations. - */ - Status setRepeatEnabled(bool repeat) - { - if (!isValid()) - { - return STATUS_NO_DEVICE; - } - - return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, repeat ? TRUE : FALSE); - } - - /** - * Seeks within a VideoStream to a given FrameID. Note that when this function is called on one - * stream, all other streams will also be changed to the corresponding place in the recording. The FrameIDs - * of different streams may not match, since FrameIDs may differ for streams that are not synchronized, but - * the recording will set all streams to the same moment in time. - * - * @param [in] stream Stream for which the frameIndex value is valid. - * @param [in] frameIndex Frame index to move playback to - * @returns Status code indicating success or failure of this operation - */ - 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); - } - - /** - * Provides the a count of frames that this recording contains for a given stream. This is useful - * both to determine the length of the recording, and to ensure that a valid Frame Index is set when using - * the @ref PlaybackControl::seek() function. - * - * @param [in] stream The video stream to count frames for - * @returns Number of frames in provided @ref VideoStream, or 0 if the stream is not part of the recording - */ - int getNumberOfFrames(const VideoStream& stream) const - { - int numOfFrames = -1; - Status rc = stream.getProperty(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 - Status getProperty(int propertyId, T* value) const - { - if (!isValid()) return STATUS_NOT_SUPPORTED; - - return m_pStream->getProperty(propertyId, value); - } - template - Status setProperty(int propertyId, const T& value) - { - if (!isValid()) return STATUS_NOT_SUPPORTED; - - return m_pStream->setProperty(propertyId, value); - } - - friend class VideoStream; - CameraSettings(VideoStream* pStream) - { - m_pStream = pStream; - } - - VideoStream* m_pStream; -}; - - -/** - * The OpenNI class is a static entry point to the library. It is used by every OpenNI 2.0 - * application to initialize the SDK and drivers to enable creation of valid device objects. - * - * It also defines a listener class and events that enable for event driven notification of - * device connection, device disconnection, and device configuration changes. - * - * In addition, it gives access to SDK version information and provides a function that allows - * you to wait for data to become available on any one of a list of streams (as opposed to - * waiting for data on one specific stream with functions provided by the VideoStream class) - * -*/ -class OpenNI -{ -public: - - /** - * The OpenNI::DeviceConnectedListener class provides a means of registering for, and responding to - * when a device is connected. - * - * onDeviceConnected is called whenever a new device is connected to the system (ie this event - * would be triggered when a new sensor is manually plugged into the host system running the - * application) - * - * To use this class, you should write a new class that inherits from it, and override the - * onDeviceConnected method. Once you instantiate your class, use the - * OpenNI::addDeviceConnectedListener() function to add your listener object to OpenNI's list of listeners. Your - * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceConnectedListener() - * function is also provided, if you want to have your class stop listening to these events for any - * reason. - */ - class DeviceConnectedListener - { - public: - DeviceConnectedListener() - { - m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback; - m_deviceConnectedCallbacks.deviceDisconnected = NULL; - m_deviceConnectedCallbacks.deviceStateChanged = NULL; - m_deviceConnectedCallbacksHandle = NULL; - } - - virtual ~DeviceConnectedListener() - { - } - - /** - * Callback function for the onDeviceConnected event. This function will be - * called whenever this event occurs. When this happens, a pointer to the @ref DeviceInfo - * object for the newly connected device will be supplied. Note that once a - * device is removed, if it was opened by a @ref Device object, that object can no longer be - * used to access the device, even if it was reconnected. Once a device was reconnected, - * @ref Device::open() should be called again in order to use this device. - * - * If you wish to open the new device as it is connected, simply query the provided DeviceInfo - * object to obtain the URI of the device, and pass this URI to the Device.Open() function. - */ - 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(pInfo)); - } - - friend class OpenNI; - OniDeviceCallbacks m_deviceConnectedCallbacks; - OniCallbackHandle m_deviceConnectedCallbacksHandle; - - }; - /** - * The OpenNI::DeviceDisconnectedListener class provides a means of registering for, and responding to - * when a device is disconnected. - * - * onDeviceDisconnected is called when a device is removed from the system. Note that once a - * device is removed, if it was opened by a @ref Device object, that object can no longer be - * used to access the device, even if it was reconnected. Once a device was reconnected, - * @ref Device::open() should be called again in order to use this device. - * - * To use this class, you should write a new class that inherits from it, and override the - * onDeviceDisconnected method. Once you instantiate your class, use the - * OpenNI::addDeviceDisconnectedListener() function to add your listener object to OpenNI's list of listeners. Your - * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceDisconnectedListener() - * function is also provided, if you want to have your class stop listening to these events for any - * reason. - */ - class DeviceDisconnectedListener - { - public: - DeviceDisconnectedListener() - { - m_deviceDisconnectedCallbacks.deviceConnected = NULL; - m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback; - m_deviceDisconnectedCallbacks.deviceStateChanged = NULL; - m_deviceDisconnectedCallbacksHandle = NULL; - } - - virtual ~DeviceDisconnectedListener() - { - } - - /** - * Callback function for the onDeviceDisconnected event. This function will be - * called whenever this event occurs. When this happens, a pointer to the DeviceInfo - * object for the newly disconnected device will be supplied. Note that once a - * device is removed, if it was opened by a @ref Device object, that object can no longer be - * used to access the device, even if it was reconnected. Once a device was reconnected, - * @ref Device::open() should be called again in order to use this device. - */ - 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(pInfo)); - } - - friend class OpenNI; - OniDeviceCallbacks m_deviceDisconnectedCallbacks; - OniCallbackHandle m_deviceDisconnectedCallbacksHandle; - }; - /** - * The OpenNI::DeviceStateChangedListener class provides a means of registering for, and responding to - * when a device's state is changed. - * - * onDeviceStateChanged is triggered whenever the state of a connected device is changed. - * - * To use this class, you should write a new class that inherits from it, and override the - * onDeviceStateChanged method. Once you instantiate your class, use the - * OpenNI::addDeviceStateChangedListener() function to add your listener object to OpenNI's list of listeners. Your - * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceStateChangedListener() - * function is also provided, if you want to have your class stop listening to these events for any - * reason. - */ - class DeviceStateChangedListener - { - public: - DeviceStateChangedListener() - { - m_deviceStateChangedCallbacks.deviceConnected = NULL; - m_deviceStateChangedCallbacks.deviceDisconnected = NULL; - m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback; - m_deviceStateChangedCallbacksHandle = NULL; - } - - virtual ~DeviceStateChangedListener() - { - } - - /** - * Callback function for the onDeviceStateChanged event. This function will be - * called whenever this event occurs. When this happens, a pointer to a DeviceInfo - * object for the affected device will be supplied, as well as the new DeviceState - * value of that device. - */ - 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(pInfo), DeviceState(state)); - } - - friend class OpenNI; - OniDeviceCallbacks m_deviceStateChangedCallbacks; - OniCallbackHandle m_deviceStateChangedCallbacksHandle; - }; - - /** - Initialize the library. - This will load all available drivers, and see which devices are available - It is forbidden to call any other method in OpenNI before calling @ref initialize(). - */ - static Status initialize() - { - return (Status)oniInitialize(ONI_API_VERSION); // provide version of API, to make sure proper struct sizes are used - } - - /** - Stop using the library. Unload all drivers, close all streams and devices. - Once @ref shutdown was called, no other calls to OpenNI is allowed. - */ - static void shutdown() - { - oniShutdown(); - } - - /** - * Returns the version of OpenNI - */ - 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; - } - - /** - * Retrieves the calling thread's last extended error information. The last extended error information is maintained - * on a per-thread basis. Multiple threads do not overwrite each other's last extended error information. - * - * The extended error information is cleared on every call to an OpenNI method, so you should call this method - * immediately after a call to an OpenNI method which have failed. - */ - static const char* getExtendedError() - { - return oniGetExtendedError(); - } - - /** - Fills up an array of @ref DeviceInfo objects with devices that are available. - @param [in,out] deviceInfoList An array to be filled with devices. - */ - static void enumerateDevices(Array* deviceInfoList) - { - OniDeviceInfo* m_pDeviceInfos; - int m_deviceInfoCount; - oniGetDeviceList(&m_pDeviceInfos, &m_deviceInfoCount); - deviceInfoList->_setData((DeviceInfo*)m_pDeviceInfos, m_deviceInfoCount, true); - oniReleaseDeviceList(m_pDeviceInfos); - } - - /** - Wait for a new frame from any of the streams provided. The function blocks until any of the streams - has a new frame available, or the timeout has passed. - @param [in] pStreams An array of streams to wait for. - @param [in] streamCount The number of streams in @c pStreams - @param [out] pReadyStreamIndex The index of the first stream that has new frame available. - @param [in] timeout [Optional] A timeout before returning if no stream has new data. Default value is @ref TIMEOUT_FOREVER. - */ - 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; - } - - /** - * Add a listener to the list of objects that receive the event when a device is connected. See the - * @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. - * - * @param pListener Pointer to the Listener to be added to the list - * @returns Status code indicating success or failure of this operation. - */ - static Status addDeviceConnectedListener(DeviceConnectedListener* pListener) - { - if (pListener->m_deviceConnectedCallbacksHandle != NULL) - { - return STATUS_ERROR; - } - return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceConnectedCallbacks, pListener, &pListener->m_deviceConnectedCallbacksHandle); - } - /** - * Add a listener to the list of objects that receive the event when a device is disconnected. See the - * @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. - * - * @param pListener Pointer to the Listener to be added to the list - * @returns Status code indicating success or failure of this operation. - */ - static Status addDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) - { - if (pListener->m_deviceDisconnectedCallbacksHandle != NULL) - { - return STATUS_ERROR; - } - return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceDisconnectedCallbacks, pListener, &pListener->m_deviceDisconnectedCallbacksHandle); - } - /** - * Add a listener to the list of objects that receive the event when a device's state changes. See the - * @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. - * - * @param pListener Pointer to the Listener to be added to the list - * @returns Status code indicating success or failure of this operation. - */ - static Status addDeviceStateChangedListener(DeviceStateChangedListener* pListener) - { - if (pListener->m_deviceStateChangedCallbacksHandle != NULL) - { - return STATUS_ERROR; - } - return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceStateChangedCallbacks, pListener, &pListener->m_deviceStateChangedCallbacksHandle); - } - /** - * Remove a listener from the list of objects that receive the event when a device is connected. See - * the @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. - * - * @param pListener Pointer to the Listener to be removed from the list - * @returns Status code indicating the success or failure of this operation. - */ - static void removeDeviceConnectedListener(DeviceConnectedListener* pListener) - { - oniUnregisterDeviceCallbacks(pListener->m_deviceConnectedCallbacksHandle); - pListener->m_deviceConnectedCallbacksHandle = NULL; - } - /** - * Remove a listener from the list of objects that receive the event when a device is disconnected. See - * the @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. - * - * @param pListener Pointer to the Listener to be removed from the list - * @returns Status code indicating the success or failure of this operation. - */ - static void removeDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) - { - oniUnregisterDeviceCallbacks(pListener->m_deviceDisconnectedCallbacksHandle); - pListener->m_deviceDisconnectedCallbacksHandle = NULL; - } - /** - * Remove a listener from the list of objects that receive the event when a device's state changes. See - * the @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. - * - * @param pListener Pointer to the Listener to be removed from the list - * @returns Status code indicating the success or failure of this operation. - */ - static void removeDeviceStateChangedListener(DeviceStateChangedListener* pListener) - { - oniUnregisterDeviceCallbacks(pListener->m_deviceStateChangedCallbacksHandle); - pListener->m_deviceStateChangedCallbacksHandle = NULL; - } - - /** - * Change the log output folder - - * @param const char * strLogOutputFolder [in] log required folder - * - * @retval STATUS_OK Upon successful completion. - * @retval STATUS_ERROR Upon any kind of failure. - */ - static Status setLogOutputFolder(const char *strLogOutputFolder) - { - return (Status)oniSetLogOutputFolder(strLogOutputFolder); - } - - /** - * Get current log file name - - * @param char * strFileName [out] returned file name buffer - * @param int nBufferSize [in] Buffer size - * - * @retval STATUS_OK Upon successful completion. - * @retval STATUS_ERROR Upon any kind of failure. - */ - static Status getLogFileName(char *strFileName, int nBufferSize) - { - return (Status)oniGetLogFileName(strFileName, nBufferSize); - } - - /** - * Set minimum severity for log produce - - * @param const char * strMask [in] Logger name - * @param int nMinSeverity [in] Logger severity - * - * @retval STATUS_OK Upon successful completion. - * @retval STATUS_ERROR Upon any kind of failure. - */ - static Status setLogMinSeverity(int nMinSeverity) - { - return(Status) oniSetLogMinSeverity(nMinSeverity); - } - - /** - * Configures if log entries will be printed to console. - - * @param const OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. - * - * @retval STATUS_OK Upon successful completion. - * @retval STATUS_ERROR Upon any kind of failure. - */ - static Status setLogConsoleOutput(bool bConsoleOutput) - { - return (Status)oniSetLogConsoleOutput(bConsoleOutput); - } - - /** - * Configures if log entries will be printed to file. - - * @param const OniBool bConsoleOutput [in] TRUE to print log entries to file, FALSE otherwise. - * - * @retval STATUS_OK Upon successful completion. - * @retval STATUS_ERROR Upon any kind of failure. - */ - static Status setLogFileOutput(bool bFileOutput) - { - return (Status)oniSetLogFileOutput(bFileOutput); - } - - #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM - /** - * Configures if log entries will be printed to the Android log. - - * @param OniBool bAndroidOutput bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. - * - * @retval STATUS_OK Upon successful completion. - * @retval STATUS_ERROR Upon any kind of failure. - */ - - static Status setLogAndroidOutput(bool bAndroidOutput) - { - return (Status)oniSetLogAndroidOutput(bAndroidOutput); - } - #endif - -private: - OpenNI() - { - } -}; - -/** -The CoordinateConverter class converts points between the different coordinate systems. - -Depth and World coordinate systems - -OpenNI applications commonly use two different coordinate systems to represent depth. These two systems are referred to as Depth -and World representation. - -Depth coordinates are the native data representation. In this system, the frame is a map (two dimensional array), and each pixel is -assigned a depth value. This depth value represents the distance between the camera plane and whatever object is in the given -pixel. The X and Y coordinates are simply the location in the map, where the origin is the top-left corner of the field of view. - -World coordinates superimpose a more familiar 3D Cartesian coordinate system on the world, with the camera lens at the origin. -In this system, every point is specified by 3 points -- x, y and z. The x axis of this system is along a line that passes -through the infrared projector and CMOS imager of the camera. The y axis is parallel to the front face of the camera, and -perpendicular to the x axis (it will also be perpendicular to the ground if the camera is upright and level). The z axis -runs into the scene, perpendicular to both the x and y axis. From the perspective of the camera, an object moving from -left to right is moving along the increasing x axis. An object moving up is moving along the increasing y axis, and an object -moving away from the camera is moving along the increasing z axis. - -Mathematically, the Depth coordinate system is the projection of the scene on the CMOS. If the sensor's angular field of view and -resolution are known, then an angular size can be calculated for each pixel. This is how the conversion algorithms work. The -dependence of this calculation on FoV and resolution is the reason that a @ref VideoStream pointer must be provided to these -functions. The @ref VideoStream pointer is used to determine parameters for the specific points to be converted. - -Since Depth coordinates are a projective, the apparent size of objects in depth coordinates (measured in pixels) -will increase as an object moves closer to the sensor. The size of objects in the World coordinate system is independent of -distance from the sensor. - -Note that converting from Depth to World coordinates is relatively expensive computationally. It is generally not practical to convert -the entire raw depth map to World coordinates. A better approach is to have your computer vision algorithm work in Depth -coordinates for as long as possible, and only converting a few specific points to World coordinates right before output. - -Note that when converting from Depth to World or vice versa, the Z value remains the same. -*/ -class CoordinateConverter -{ -public: - /** - Converts a single point from the World coordinate system to the Depth coordinate system. - @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates - @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates - @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates - @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates - @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0 at far left of image - @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0 at top of image - @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in the @ref PixelFormat of depthStream - */ - 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; - } - - /** - Converts a single point from the World coordinate system to a floating point representation of the Depth coordinate system - @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates - @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates - @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates - @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates - @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0.0 at far left of the image - @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0.0 at the top of the image - @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in millimeters with 0.0 at the camera lens - */ - 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); - } - - /** - Converts a single point from the Depth coordinate system to the World coordinate system. - @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates - @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0 at the far left of the image - @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0 at the top of the image - @param [in] depthZ the Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream - @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates - @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates - @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates - */ - 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); - } - - /** - Converts a single point from a floating point representation of the Depth coordinate system to the World coordinate system. - @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates - @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0.0 at the far left of the image - @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0.0 at the top of the image - @param [in] depthZ Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream - @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates - @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates - @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates - */ - 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); - } - - /** - For a given depth point, provides the coordinates of the corresponding color value. Useful for superimposing the depth and color images. - This operation is the same as turning on registration, but is performed on a single pixel rather than the whole image. - @param [in] depthStream Reference to a openni::VideoStream that produced the depth value - @param [in] colorStream Reference to a openni::VideoStream that we want to find the appropriate color pixel in - @param [in] depthX X value of the depth point, given in Depth coordinates and measured in pixels - @param [in] depthY Y value of the depth point, given in Depth coordinates and measured in pixels - @param [in] depthZ Z(depth) value of the depth point, given in the @ref PixelFormat of depthStream - @param [out] pColorX The X coordinate of the color pixel that overlaps the given depth pixel, measured in pixels - @param [out] pColorY The Y coordinate of the color pixel that overlaps the given depth pixel, measured in pixels - */ - 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); - } -}; - -/** - * The Recorder class is used to record streams to an ONI file. - * - * After a recorder is instantiated, it must be initialized with a specific filename where - * the recording will be stored. The recorder is then attached to one or more streams. Once - * this is complete, the recorder can be told to start recording. The recorder will store - * every frame from every stream to the specified file. Later, this file can be used to - * initialize a file Device, and used to play back the same data that was recorded. - * - * Opening a file device is done by passing its path as the uri to the @ref Device::open() method. - * - * @see PlaybackControl for options available to play a reorded file. - * - */ -class Recorder -{ -public: - /** - * Creates a recorder. The recorder is not valid, i.e. @ref isValid() returns - * false. You must initialize the recorder before use with @ref create(). - */ - Recorder() : m_recorder(NULL) - { - } - - /** - * Destroys a recorder. This will also stop recording. - */ - ~Recorder() - { - destroy(); - } - - /** - * Initializes a recorder. You can initialize the recorder only once. Attempts - * to intialize more than once will result in an error code being returned. - * - * Initialization assigns the recorder to an output file that will be used for - * recording. Before use, the @ref attach() function must also be used to assign input - * data to the Recorder. - * - * @param [in] fileName The name of a file which will contain the recording. - * @returns Status code which indicates success or failure of the operation. - */ - Status create(const char* fileName) - { - if (!isValid()) - { - return (Status)oniCreateRecorder(fileName, &m_recorder); - } - return STATUS_ERROR; - } - - /** - * Verifies if the recorder is valid, i.e. if one can record with this recorder. A - * recorder object is not valid until the @ref create() method is called. - * - * @returns true if the recorder has been intialized, false otherwise. - */ - bool isValid() const - { - return NULL != getHandle(); - } - - /** - * Attaches a stream to the recorder. Note, this won't start recording, you - * should explicitly start it using @ref start() method. As soon as the recording - * process has been started, no more streams can be attached to the recorder. - * - * @param [in] stream The stream to be recorded. - * @param [in] allowLossyCompression [Optional] If this value is true, the recorder might use - * a lossy compression, which means that when the recording will be played-back, there might - * be small differences from the original frame. Default value is false. - */ - Status attach(VideoStream& stream, bool allowLossyCompression = false) - { - if (!isValid() || !stream.isValid()) - { - return STATUS_ERROR; - } - return (Status)oniRecorderAttachStream( - m_recorder, - stream._getHandle(), - allowLossyCompression); - } - - /** - * Starts recording. - * Once this method is called, the recorder will take all subsequent frames from the attached streams - * and store them in the file. - * You may not attach additional streams once recording was started. - */ - Status start() - { - if (!isValid()) - { - return STATUS_ERROR; - } - return (Status)oniRecorderStart(m_recorder); - } - - /** - * Stops recording. You may use @ref start() to resume the recording. - */ - void stop() - { - if (isValid()) - { - oniRecorderStop(m_recorder); - } - } - - /** - Destroys the recorder object. - */ - void destroy() - { - if (isValid()) - { - oniRecorderDestroy(&m_recorder); - } - } - -private: - Recorder(const Recorder&); - Recorder& operator=(const Recorder&); - - /** - * Returns a handle of this 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_ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h deleted file mode 100644 index 561f7664a..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PS1080.h +++ /dev/null @@ -1,632 +0,0 @@ -/***************************************************************************** -* * -* 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 _PS1080_H_ -#define _PS1080_H_ - -#include - -/** The maximum permitted Xiron device name string length. */ -#define XN_DEVICE_MAX_STRING_LENGTH 200 - -/* - * private properties of PS1080 devices. - * - * @remarks - * properties structure is 0x1080XXYY where XX is range and YY is code. - * range values: - * F0 - device properties - * E0 - device commands - * 00 - common stream properties - * 10 - depth stream properties - * 20 - color stream properties - */ -enum -{ - /*******************************************************************/ - /* Device properties */ - /*******************************************************************/ - - /** unsigned long long (XnSensorUsbInterface) */ - XN_MODULE_PROPERTY_USB_INTERFACE = 0x1080F001, // "UsbInterface" - /** Boolean */ - XN_MODULE_PROPERTY_MIRROR = 0x1080F002, // "Mirror" - /** unsigned long long, get only */ - XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP = 0x1080F004, // "ResetSensorOnStartup" - /** unsigned long long, get only */ - XN_MODULE_PROPERTY_LEAN_INIT = 0x1080F005, // "LeanInit" - /** char[XN_DEVICE_MAX_STRING_LENGTH], get only */ - XN_MODULE_PROPERTY_SERIAL_NUMBER = 0x1080F006, // "ID" - /** XnVersions, get only */ - XN_MODULE_PROPERTY_VERSION = 0x1080F007, // "Version" - /** Boolean */ - XN_MODULE_PROPERTY_FIRMWARE_FRAME_SYNC = 0x1080F008, - /** Boolean */ - XN_MODULE_PROPERTY_HOST_TIMESTAMPS = 0x1080FF77, // "HostTimestamps" - /** Boolean */ - XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN = 0x1080FF78, // "CloseStreamsOnShutdown" - /** Integer */ - XN_MODULE_PROPERTY_FIRMWARE_LOG_INTERVAL = 0x1080FF7F, // "FirmwareLogInterval" - /** Boolean */ - XN_MODULE_PROPERTY_PRINT_FIRMWARE_LOG = 0x1080FF80, // "FirmwareLogPrint" - /** Integer */ - XN_MODULE_PROPERTY_FIRMWARE_LOG_FILTER = 0x1080FF81, // "FirmwareLogFilter" - /** String, get only */ - XN_MODULE_PROPERTY_FIRMWARE_LOG = 0x1080FF82, // "FirmwareLog" - /** Integer */ - XN_MODULE_PROPERTY_FIRMWARE_CPU_INTERVAL = 0x1080FF83, // "FirmwareCPUInterval" - /** String, get only */ - XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME = 0x1080FF7A, // "PhysicalDeviceName" - /** String, get only */ - XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA = 0x1080FF7B, // "VendorSpecificData" - /** String, get only */ - XN_MODULE_PROPERTY_SENSOR_PLATFORM_STRING = 0x1080FF7C, // "SensorPlatformString" - - /*******************************************************************/ - /* Device commands (activated via SetProperty/GetProperty) */ - /*******************************************************************/ - - /** XnInnerParam */ - XN_MODULE_PROPERTY_FIRMWARE_PARAM = 0x1080E001, // "FirmwareParam" - /** unsigned long long, set only */ - XN_MODULE_PROPERTY_RESET = 0x1080E002, // "Reset" - /** XnControlProcessingData */ - XN_MODULE_PROPERTY_IMAGE_CONTROL = 0x1080E003, // "ImageControl" - /** XnControlProcessingData */ - XN_MODULE_PROPERTY_DEPTH_CONTROL = 0x1080E004, // "DepthControl" - /** XnAHBData */ - XN_MODULE_PROPERTY_AHB = 0x1080E005, // "AHB" - /** XnLedState */ - XN_MODULE_PROPERTY_LED_STATE = 0x1080E006, // "LedState" - /** Boolean */ - XN_MODULE_PROPERTY_EMITTER_STATE = 0x1080E007, // "EmitterState" - - /** XnCmosBlankingUnits */ - XN_MODULE_PROPERTY_CMOS_BLANKING_UNITS = 0x1080FF74, // "CmosBlankingUnits" - /** XnCmosBlankingTime */ - XN_MODULE_PROPERTY_CMOS_BLANKING_TIME = 0x1080FF75, // "CmosBlankingTime" - /** XnFlashFileList, get only */ - XN_MODULE_PROPERTY_FILE_LIST = 0x1080FF84, // "FileList" - /** XnParamFlashData, get only */ - XN_MODULE_PROPERTY_FLASH_CHUNK = 0x1080FF85, // "FlashChunk" - XN_MODULE_PROPERTY_FILE = 0x1080FF86, // "FlashFile" - /** Integer */ - XN_MODULE_PROPERTY_DELETE_FILE = 0x1080FF87, // "DeleteFile" - XN_MODULE_PROPERTY_FILE_ATTRIBUTES = 0x1080FF88, // "FileAttributes" - XN_MODULE_PROPERTY_TEC_SET_POINT = 0x1080FF89, // "TecSetPoint" - /** get only */ - XN_MODULE_PROPERTY_TEC_STATUS = 0x1080FF8A, // "TecStatus" - /** get only */ - XN_MODULE_PROPERTY_TEC_FAST_CONVERGENCE_STATUS = 0x1080FF8B, // "TecFastConvergenceStatus" - XN_MODULE_PROPERTY_EMITTER_SET_POINT = 0x1080FF8C, // "EmitterSetPoint" - /** get only */ - XN_MODULE_PROPERTY_EMITTER_STATUS = 0x1080FF8D, // "EmitterStatus" - XN_MODULE_PROPERTY_I2C = 0x1080FF8E, // "I2C" - /** Integer, set only */ - XN_MODULE_PROPERTY_BIST = 0x1080FF8F, // "BIST" - /** XnProjectorFaultData, set only */ - XN_MODULE_PROPERTY_PROJECTOR_FAULT = 0x1080FF90, // "ProjectorFault" - /** Boolean, set only */ - XN_MODULE_PROPERTY_APC_ENABLED = 0x1080FF91, // "APCEnabled" - /** Boolean */ - XN_MODULE_PROPERTY_FIRMWARE_TEC_DEBUG_PRINT = 0x1080FF92, // "TecDebugPrint" - - /*******************************************************************/ - /* Common stream properties */ - /*******************************************************************/ - - /** unsigned long long */ - XN_STREAM_PROPERTY_INPUT_FORMAT = 0x10800001, // "InputFormat" - /** unsigned long long (XnCroppingMode) */ - XN_STREAM_PROPERTY_CROPPING_MODE = 0x10800002, // "CroppingMode" - - /*******************************************************************/ - /* Depth stream properties */ - /*******************************************************************/ - - /** unsigned long long */ - XN_STREAM_PROPERTY_CLOSE_RANGE = 0x1080F003, // "CloseRange" - /** XnPixelRegistration - get only */ - XN_STREAM_PROPERTY_PIXEL_REGISTRATION = 0x10801001, // "PixelRegistration" - /** unsigned long long */ - XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED = 0x10801002, // "WhiteBalancedEnabled" - /** unsigned long long */ - XN_STREAM_PROPERTY_GAIN = 0x10801003, // "Gain" - /** unsigned long long */ - XN_STREAM_PROPERTY_HOLE_FILTER = 0x10801004, // "HoleFilter" - /** unsigned long long (XnProcessingType) */ - XN_STREAM_PROPERTY_REGISTRATION_TYPE = 0x10801005, // "RegistrationType" - /** XnDepthAGCBin* */ - XN_STREAM_PROPERTY_AGC_BIN = 0x10801006, // "AGCBin" - /** unsigned long long, get only */ - XN_STREAM_PROPERTY_CONST_SHIFT = 0x10801007, // "ConstShift" - /** unsigned long long, get only */ - XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR = 0x10801008, // "PixelSizeFactor" - /** unsigned long long, get only */ - XN_STREAM_PROPERTY_MAX_SHIFT = 0x10801009, // "MaxShift" - /** unsigned long long, get only */ - XN_STREAM_PROPERTY_PARAM_COEFF = 0x1080100A, // "ParamCoeff" - /** unsigned long long, get only */ - XN_STREAM_PROPERTY_SHIFT_SCALE = 0x1080100B, // "ShiftScale" - /** unsigned long long, get only */ - XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE = 0x1080100C, // "ZPD" - /** double, get only */ - XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE = 0x1080100D, // "ZPPS" - /** double, get only */ - XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE = 0x1080100E, // "LDDIS" - /** double, get only */ - XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE = 0x1080100F, // "DCRCDIS" - /** OniDepthPixel[], get only */ - XN_STREAM_PROPERTY_S2D_TABLE = 0x10801010, // "S2D" - /** unsigned short[], get only */ - XN_STREAM_PROPERTY_D2S_TABLE = 0x10801011, // "D2S" - /** get only */ - XN_STREAM_PROPERTY_DEPTH_SENSOR_CALIBRATION_INFO = 0x10801012, - /** Boolean */ - XN_STREAM_PROPERTY_GMC_MODE = 0x1080FF44, // "GmcMode" - /** Boolean */ - XN_STREAM_PROPERTY_GMC_DEBUG = 0x1080FF45, // "GmcDebug" - /** Boolean */ - XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION = 0x1080FF46, // "WavelengthCorrection" - /** Boolean */ - XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION_DEBUG = 0x1080FF47, // "WavelengthCorrectionDebug" - - /*******************************************************************/ - /* Color stream properties */ - /*******************************************************************/ - /** Integer */ - XN_STREAM_PROPERTY_FLICKER = 0x10802001, // "Flicker" -}; - -typedef enum -{ - XN_SENSOR_FW_VER_UNKNOWN = 0, - XN_SENSOR_FW_VER_0_17 = 1, - XN_SENSOR_FW_VER_1_1 = 2, - XN_SENSOR_FW_VER_1_2 = 3, - XN_SENSOR_FW_VER_3_0 = 4, - XN_SENSOR_FW_VER_4_0 = 5, - XN_SENSOR_FW_VER_5_0 = 6, - XN_SENSOR_FW_VER_5_1 = 7, - XN_SENSOR_FW_VER_5_2 = 8, - XN_SENSOR_FW_VER_5_3 = 9, - XN_SENSOR_FW_VER_5_4 = 10, - XN_SENSOR_FW_VER_5_5 = 11, - XN_SENSOR_FW_VER_5_6 = 12, - XN_SENSOR_FW_VER_5_7 = 13, - XN_SENSOR_FW_VER_5_8 = 14, -} XnFWVer; - -typedef enum { - XN_SENSOR_VER_UNKNOWN = 0, - XN_SENSOR_VER_2_0 = 1, - XN_SENSOR_VER_3_0 = 2, - XN_SENSOR_VER_4_0 = 3, - XN_SENSOR_VER_5_0 = 4 -} XnSensorVer; - -typedef enum { - XN_SENSOR_HW_VER_UNKNOWN = 0, - XN_SENSOR_HW_VER_FPDB_10 = 1, - XN_SENSOR_HW_VER_CDB_10 = 2, - XN_SENSOR_HW_VER_RD_3 = 3, - XN_SENSOR_HW_VER_RD_5 = 4, - XN_SENSOR_HW_VER_RD1081 = 5, - XN_SENSOR_HW_VER_RD1082 = 6, - XN_SENSOR_HW_VER_RD109 = 7 -} XnHWVer; - -typedef enum { - XN_SENSOR_CHIP_VER_UNKNOWN = 0, - XN_SENSOR_CHIP_VER_PS1000 = 1, - XN_SENSOR_CHIP_VER_PS1080 = 2, - XN_SENSOR_CHIP_VER_PS1080A6 = 3 -} XnChipVer; - -typedef enum -{ - XN_CMOS_TYPE_IMAGE = 0, - XN_CMOS_TYPE_DEPTH = 1, - - XN_CMOS_COUNT -} XnCMOSType; - -typedef enum -{ - XN_IO_IMAGE_FORMAT_BAYER = 0, - XN_IO_IMAGE_FORMAT_YUV422 = 1, - XN_IO_IMAGE_FORMAT_JPEG = 2, - XN_IO_IMAGE_FORMAT_JPEG_420 = 3, - XN_IO_IMAGE_FORMAT_JPEG_MONO = 4, - XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 = 5, - XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER = 6, - XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUYV = 7, -} XnIOImageFormats; - -typedef enum -{ - XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT = 0, - XN_IO_DEPTH_FORMAT_COMPRESSED_PS = 1, - XN_IO_DEPTH_FORMAT_UNCOMPRESSED_10_BIT = 2, - XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT = 3, - XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT = 4, -} XnIODepthFormats; - -typedef enum -{ - XN_RESET_TYPE_POWER = 0, - XN_RESET_TYPE_SOFT = 1, - XN_RESET_TYPE_SOFT_FIRST = 2, -} XnParamResetType; - -typedef enum XnSensorUsbInterface -{ - XN_SENSOR_USB_INTERFACE_DEFAULT = 0, - XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS = 1, - XN_SENSOR_USB_INTERFACE_BULK_ENDPOINTS = 2, - XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS_LOW_DEPTH = 3, -} XnSensorUsbInterface; - -typedef enum XnProcessingType -{ - XN_PROCESSING_DONT_CARE = 0, - XN_PROCESSING_HARDWARE = 1, - XN_PROCESSING_SOFTWARE = 2, -} XnProcessingType; - -typedef enum XnCroppingMode -{ - XN_CROPPING_MODE_NORMAL = 1, - XN_CROPPING_MODE_INCREASED_FPS = 2, - XN_CROPPING_MODE_SOFTWARE_ONLY = 3, -} XnCroppingMode; - -enum -{ - XN_ERROR_STATE_OK = 0, - XN_ERROR_STATE_DEVICE_PROJECTOR_FAULT = 1, - XN_ERROR_STATE_DEVICE_OVERHEAT = 2, -}; - -typedef enum XnFirmwareCroppingMode -{ - XN_FIRMWARE_CROPPING_MODE_DISABLED = 0, - XN_FIRMWARE_CROPPING_MODE_NORMAL = 1, - XN_FIRMWARE_CROPPING_MODE_INCREASED_FPS = 2, -} XnFirmwareCroppingMode; - -typedef enum -{ - XnLogFilterDebug = 0x0001, - XnLogFilterInfo = 0x0002, - XnLogFilterError = 0x0004, - XnLogFilterProtocol = 0x0008, - XnLogFilterAssert = 0x0010, - XnLogFilterConfig = 0x0020, - XnLogFilterFrameSync = 0x0040, - XnLogFilterAGC = 0x0080, - XnLogFilterTelems = 0x0100, - - XnLogFilterAll = 0xFFFF -} XnLogFilter; - -typedef enum -{ - XnFileAttributeReadOnly = 0x8000 -} XnFilePossibleAttributes; - -typedef enum -{ - XnFlashFileTypeFileTable = 0x00, - XnFlashFileTypeScratchFile = 0x01, - XnFlashFileTypeBootSector = 0x02, - XnFlashFileTypeBootManager = 0x03, - XnFlashFileTypeCodeDownloader = 0x04, - XnFlashFileTypeMonitor = 0x05, - XnFlashFileTypeApplication = 0x06, - XnFlashFileTypeFixedParams = 0x07, - XnFlashFileTypeDescriptors = 0x08, - XnFlashFileTypeDefaultParams = 0x09, - XnFlashFileTypeImageCmos = 0x0A, - XnFlashFileTypeDepthCmos = 0x0B, - XnFlashFileTypeAlgorithmParams = 0x0C, - XnFlashFileTypeReferenceQVGA = 0x0D, - XnFlashFileTypeReferenceVGA = 0x0E, - XnFlashFileTypeMaintenance = 0x0F, - XnFlashFileTypeDebugParams = 0x10, - XnFlashFileTypePrimeProcessor = 0x11, - XnFlashFileTypeGainControl = 0x12, - XnFlashFileTypeRegistartionParams = 0x13, - XnFlashFileTypeIDParams = 0x14, - XnFlashFileTypeSensorTECParams = 0x15, - XnFlashFileTypeSensorAPCParams = 0x16, - XnFlashFileTypeSensorProjectorFaultParams = 0x17, - XnFlashFileTypeProductionFile = 0x18, - XnFlashFileTypeUpgradeInProgress = 0x19, - XnFlashFileTypeWavelengthCorrection = 0x1A, - XnFlashFileTypeGMCReferenceOffset = 0x1B, - XnFlashFileTypeSensorNESAParams = 0x1C, - XnFlashFileTypeSensorFault = 0x1D, - XnFlashFileTypeVendorData = 0x1E, -} XnFlashFileType; - -typedef enum XnBistType -{ - //Auto tests - XN_BIST_IMAGE_CMOS = 1 << 0, - XN_BIST_IR_CMOS = 1 << 1, - XN_BIST_POTENTIOMETER = 1 << 2, - XN_BIST_FLASH = 1 << 3, - XN_BIST_FULL_FLASH = 1 << 4, - XN_BIST_PROJECTOR_TEST_MASK = 1 << 5, - XN_BIST_TEC_TEST_MASK = 1 << 6, - - // Manual tests - XN_BIST_NESA_TEST_MASK = 1 << 7, - XN_BIST_NESA_UNLIMITED_TEST_MASK = 1 << 8, - - // Mask of all the auto tests - XN_BIST_ALL = (0xFFFFFFFF & ~XN_BIST_NESA_TEST_MASK & ~XN_BIST_NESA_UNLIMITED_TEST_MASK), - -} XnBistType; - -typedef enum XnBistError -{ - XN_BIST_RAM_TEST_FAILURE = 1 << 0, - XN_BIST_IR_CMOS_CONTROL_BUS_FAILURE = 1 << 1, - XN_BIST_IR_CMOS_DATA_BUS_FAILURE = 1 << 2, - XN_BIST_IR_CMOS_BAD_VERSION = 1 << 3, - XN_BIST_IR_CMOS_RESET_FAILUE = 1 << 4, - XN_BIST_IR_CMOS_TRIGGER_FAILURE = 1 << 5, - XN_BIST_IR_CMOS_STROBE_FAILURE = 1 << 6, - XN_BIST_COLOR_CMOS_CONTROL_BUS_FAILURE = 1 << 7, - XN_BIST_COLOR_CMOS_DATA_BUS_FAILURE = 1 << 8, - XN_BIST_COLOR_CMOS_BAD_VERSION = 1 << 9, - XN_BIST_COLOR_CMOS_RESET_FAILUE = 1 << 10, - XN_BIST_FLASH_WRITE_LINE_FAILURE = 1 << 11, - XN_BIST_FLASH_TEST_FAILURE = 1 << 12, - XN_BIST_POTENTIOMETER_CONTROL_BUS_FAILURE = 1 << 13, - XN_BIST_POTENTIOMETER_FAILURE = 1 << 14, - XN_BIST_AUDIO_TEST_FAILURE = 1 << 15, - XN_BIST_PROJECTOR_TEST_LD_FAIL = 1 << 16, - XN_BIST_PROJECTOR_TEST_LD_FAILSAFE_TRIG_FAIL = 1 << 17, - XN_BIST_PROJECTOR_TEST_FAILSAFE_HIGH_FAIL = 1 << 18, - XN_BIST_PROJECTOR_TEST_FAILSAFE_LOW_FAIL = 1 << 19, - XN_TEC_TEST_HEATER_CROSSED = 1 << 20, - XN_TEC_TEST_HEATER_DISCONNETED = 1 << 21, - XN_TEC_TEST_TEC_CROSSED = 1 << 22, - XN_TEC_TEST_TEC_FAULT = 1 << 23, -} XnBistError; - -typedef enum XnDepthCMOSType -{ - XN_DEPTH_CMOS_NONE = 0, - XN_DEPTH_CMOS_MT9M001 = 1, - XN_DEPTH_CMOS_AR130 = 2, -} XnDepthCMOSType; - -typedef enum XnImageCMOSType -{ - XN_IMAGE_CMOS_NONE = 0, - XN_IMAGE_CMOS_MT9M112 = 1, - XN_IMAGE_CMOS_MT9D131 = 2, - XN_IMAGE_CMOS_MT9M114 = 3, -} XnImageCMOSType; - -#define XN_IO_MAX_I2C_BUFFER_SIZE 10 -#define XN_MAX_LOG_SIZE (6*1024) - -#pragma pack (push, 1) - -typedef struct XnSDKVersion -{ - unsigned char nMajor; - unsigned char nMinor; - unsigned char nMaintenance; - unsigned short nBuild; -} XnSDKVersion; - -typedef struct { - unsigned char nMajor; - unsigned char nMinor; - unsigned short nBuild; - unsigned int nChip; - unsigned short nFPGA; - unsigned short nSystemVersion; - - XnSDKVersion SDK; - - XnHWVer HWVer; - XnFWVer FWVer; - XnSensorVer SensorVer; - XnChipVer ChipVer; -} XnVersions; - -typedef struct -{ - unsigned short nParam; - unsigned short nValue; -} XnInnerParamData; - -typedef struct XnDepthAGCBin -{ - unsigned short nBin; - unsigned short nMin; - unsigned short nMax; -} XnDepthAGCBin; - -typedef struct XnControlProcessingData -{ - unsigned short nRegister; - unsigned short nValue; -} XnControlProcessingData; - -typedef struct XnAHBData -{ - unsigned int nRegister; - unsigned int nValue; - unsigned int nMask; -} XnAHBData; - -typedef struct XnPixelRegistration -{ - unsigned int nDepthX; - unsigned int nDepthY; - uint16_t nDepthValue; - unsigned int nImageXRes; - unsigned int nImageYRes; - unsigned int nImageX; // out - unsigned int nImageY; // out -} XnPixelRegistration; - -typedef struct XnLedState -{ - uint16_t nLedID; - uint16_t nState; -} XnLedState; - -typedef struct XnCmosBlankingTime -{ - XnCMOSType nCmosID; - float nTimeInMilliseconds; - uint16_t nNumberOfFrames; -} XnCmosBlankingTime; - -typedef struct XnCmosBlankingUnits -{ - XnCMOSType nCmosID; - uint16_t nUnits; - uint16_t nNumberOfFrames; -} XnCmosBlankingUnits; - -typedef struct XnI2CWriteData -{ - uint16_t nBus; - uint16_t nSlaveAddress; - uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; - uint16_t nWriteSize; -} XnI2CWriteData; - -typedef struct XnI2CReadData -{ - uint16_t nBus; - uint16_t nSlaveAddress; - uint16_t cpReadBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; - uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; - uint16_t nReadSize; - uint16_t nWriteSize; -} XnI2CReadData; - -typedef struct XnTecData -{ - uint16_t m_SetPointVoltage; - uint16_t m_CompensationVoltage; - uint16_t m_TecDutyCycle; //duty cycle on heater/cooler - uint16_t m_HeatMode; //TRUE - heat, FALSE - cool - int32_t m_ProportionalError; - int32_t m_IntegralError; - int32_t m_DerivativeError; - uint16_t m_ScanMode; //0 - crude, 1 - precise -} XnTecData; - -typedef struct XnTecFastConvergenceData -{ - int16_t m_SetPointTemperature; // set point temperature in celsius, - // scaled by factor of 100 (extra precision) - int16_t m_MeasuredTemperature; // measured temperature in celsius, - // scaled by factor of 100 (extra precision) - int32_t m_ProportionalError; // proportional error in system clocks - int32_t m_IntegralError; // integral error in system clocks - int32_t m_DerivativeError; // derivative error in system clocks - uint16_t m_ScanMode; // 0 - initial, 1 - crude, 2 - precise - uint16_t m_HeatMode; // 0 - idle, 1 - heat, 2 - cool - uint16_t m_TecDutyCycle; // duty cycle on heater/cooler in percents - uint16_t m_TemperatureRange; // 0 - cool, 1 - room, 2 - warm -} XnTecFastConvergenceData; - -typedef struct XnEmitterData -{ - uint16_t m_State; //idle, calibrating - uint16_t m_SetPointVoltage; //this is what should be written to the XML - uint16_t m_SetPointClocks; //target cross duty cycle - uint16_t m_PD_Reading; //current cross duty cycle in system clocks(high time) - uint16_t m_EmitterSet; //duty cycle on emitter set in system clocks (high time). - uint16_t m_EmitterSettingLogic; //TRUE = positive logic, FALSE = negative logic - uint16_t m_LightMeasureLogic; //TRUE - positive logic, FALSE - negative logic - uint16_t m_IsAPCEnabled; - uint16_t m_EmitterSetStepSize; // in MilliVolts - uint16_t m_ApcTolerance; // in system clocks (only valid up till v5.2) - uint16_t m_SubClocking; //in system clocks (only valid from v5.3) - uint16_t m_Precision; // (only valid from v5.3) -} XnEmitterData; - -typedef struct -{ - uint16_t nId; - uint16_t nAttribs; -} XnFileAttributes; - -typedef struct -{ - uint32_t nOffset; - const char* strFileName; - uint16_t nAttributes; -} XnParamFileData; - -typedef struct -{ - uint32_t nOffset; - uint32_t nSize; - unsigned char* pData; -} XnParamFlashData; - -typedef struct { - uint16_t nId; - uint16_t nType; - uint32_t nVersion; - uint32_t nOffset; - uint32_t nSize; - uint16_t nCrc; - uint16_t nAttributes; - uint16_t nReserve; -} XnFlashFile; - -typedef struct -{ - XnFlashFile* pFiles; - uint16_t nFiles; -} XnFlashFileList; - -typedef struct XnProjectorFaultData -{ - uint16_t nMinThreshold; - uint16_t nMaxThreshold; - int32_t bProjectorFaultEvent; -} XnProjectorFaultData; - -typedef struct XnBist -{ - uint32_t nTestsMask; - uint32_t nFailures; -} XnBist; - -#pragma pack (pop) - -#endif //_PS1080_H_ \ No newline at end of file diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h deleted file mode 100644 index dd4d8992a..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PSLink.h +++ /dev/null @@ -1,199 +0,0 @@ -#ifndef __XN_PRIME_CLIENT_PROPS_H__ -#define __XN_PRIME_CLIENT_PROPS_H__ - -#include - -enum -{ - /**** Device properties ****/ - - /* XnDetailedVersion, get only */ - LINK_PROP_FW_VERSION = 0x12000001, // "FWVersion" - /* Int, get only */ - LINK_PROP_VERSIONS_INFO_COUNT = 0x12000002, // "VersionsInfoCount" - /* General - array - XnComponentVersion * count elements, get only */ - LINK_PROP_VERSIONS_INFO = 0x12000003, // "VersionsInfo" - /* Int - 0 means off, 1 means on. */ - LINK_PROP_EMITTER_ACTIVE = 0x12000008, // "EmitterActive" - /* String. Set only */ - LINK_PROP_PRESET_FILE = 0x1200000a, // "PresetFile" - /* Get only */ - LINK_PROP_BOOT_STATUS = 0x1200000b, - - /**** Device commands ****/ - /* XnCommandGetFwStreams */ - LINK_COMMAND_GET_FW_STREAM_LIST = 0x1200F001, - /* XnCommandCreateStream */ - LINK_COMMAND_CREATE_FW_STREAM = 0x1200F002, - /* XnCommandDestroyStream */ - LINK_COMMAND_DESTROY_FW_STREAM = 0x1200F003, - /* XnCommandStartStream */ - LINK_COMMAND_START_FW_STREAM = 0x1200F004, - /* XnCommandStopStream */ - LINK_COMMAND_STOP_FW_STREAM = 0x1200F005, - /* XnCommandGetFwStreamVideoModeList */ - LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE_LIST = 0x1200F006, - /* XnCommandSetFwStreamVideoMode */ - LINK_COMMAND_SET_FW_STREAM_VIDEO_MODE = 0x1200F007, - /* XnCommandGetFwStreamVideoMode */ - LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE = 0x1200F008, - - /**** Stream properties ****/ - /* Int. 1 - Shifts 9.3, 2 - Grayscale16, 3 - YUV422, 4 - Bayer8 */ - LINK_PROP_PIXEL_FORMAT = 0x12001001, // "PixelFormat" - /* Int. 0 - None, 1 - 8z, 2 - 16z, 3 - 24z, 4 - 6-bit, 5 - 10-bit, 6 - 11-bit, 7 - 12-bit */ - LINK_PROP_COMPRESSION = 0x12001002, // "Compression" - - /**** Depth Stream properties ****/ - /* Real, get only */ - LINK_PROP_DEPTH_SCALE = 0x1200000b, // "DepthScale" - /* Int, get only */ - LINK_PROP_MAX_SHIFT = 0x12002001, // "MaxShift" - /* Int, get only */ - LINK_PROP_ZERO_PLANE_DISTANCE = 0x12002002, // "ZPD" - /* Int, get only */ - LINK_PROP_CONST_SHIFT = 0x12002003, // "ConstShift" - /* Int, get only */ - LINK_PROP_PARAM_COEFF = 0x12002004, // "ParamCoeff" - /* Int, get only */ - LINK_PROP_SHIFT_SCALE = 0x12002005, // "ShiftScale" - /* Real, get only */ - LINK_PROP_ZERO_PLANE_PIXEL_SIZE = 0x12002006, // "ZPPS" - /* Real, get only */ - LINK_PROP_ZERO_PLANE_OUTPUT_PIXEL_SIZE = 0x12002007, // "ZPOPS" - /* Real, get only */ - LINK_PROP_EMITTER_DEPTH_CMOS_DISTANCE = 0x12002008, // "LDDIS" - /* General - array - MaxShift * XnDepthPixel elements, get only */ - LINK_PROP_SHIFT_TO_DEPTH_TABLE = 0x12002009, // "S2D" - /* General - array - MaxDepth * uint16_t elements, get only */ - LINK_PROP_DEPTH_TO_SHIFT_TABLE = 0x1200200a, // "D2S" -}; - -typedef enum XnFileZone -{ - XN_ZONE_FACTORY = 0x0000, - XN_ZONE_UPDATE = 0x0001, -} XnFileZone; - -typedef enum XnBootErrorCode -{ - XN_BOOT_OK = 0x0000, - XN_BOOT_BAD_CRC = 0x0001, - XN_BOOT_UPLOAD_IN_PROGRESS = 0x0002, - XN_BOOT_FW_LOAD_FAILED = 0x0003, -} XnBootErrorCode; - -typedef enum XnFwStreamType -{ - XN_FW_STREAM_TYPE_COLOR = 0x0001, - XN_FW_STREAM_TYPE_IR = 0x0002, - XN_FW_STREAM_TYPE_SHIFTS = 0x0003, - XN_FW_STREAM_TYPE_AUDIO = 0x0004, - XN_FW_STREAM_TYPE_DY = 0x0005, - XN_FW_STREAM_TYPE_LOG = 0x0008, -} XnFwStreamType; - -typedef enum XnFwPixelFormat -{ - XN_FW_PIXEL_FORMAT_NONE = 0x0000, - XN_FW_PIXEL_FORMAT_SHIFTS_9_3 = 0x0001, - XN_FW_PIXEL_FORMAT_GRAYSCALE16 = 0x0002, - XN_FW_PIXEL_FORMAT_YUV422 = 0x0003, - XN_FW_PIXEL_FORMAT_BAYER8 = 0x0004, -} XnFwPixelFormat; - -typedef enum XnFwCompressionType -{ - XN_FW_COMPRESSION_NONE = 0x0000, - XN_FW_COMPRESSION_8Z = 0x0001, - XN_FW_COMPRESSION_16Z = 0x0002, - XN_FW_COMPRESSION_24Z = 0x0003, - XN_FW_COMPRESSION_6_BIT_PACKED = 0x0004, - XN_FW_COMPRESSION_10_BIT_PACKED = 0x0005, - XN_FW_COMPRESSION_11_BIT_PACKED = 0x0006, - XN_FW_COMPRESSION_12_BIT_PACKED = 0x0007, -} XnFwCompressionType; - -#pragma pack (push, 1) - -#define XN_MAX_VERSION_MODIFIER_LENGTH 16 -typedef struct XnDetailedVersion -{ - uint8_t m_nMajor; - uint8_t m_nMinor; - uint16_t m_nMaintenance; - uint32_t m_nBuild; - char m_strModifier[XN_MAX_VERSION_MODIFIER_LENGTH]; -} XnDetailedVersion; - -typedef struct XnBootStatus -{ - XnFileZone zone; - XnBootErrorCode errorCode; -} XnBootStatus; - -typedef struct XnFwStreamInfo -{ - XnFwStreamType type; - char creationInfo[80]; -} XnFwStreamInfo; - -typedef struct XnFwStreamVideoMode -{ - uint32_t m_nXRes; - uint32_t m_nYRes; - uint32_t m_nFPS; - XnFwPixelFormat m_nPixelFormat; - XnFwCompressionType m_nCompression; -} XnFwStreamVideoMode; - -typedef struct XnCommandGetFwStreamList -{ - uint32_t count; // in: number of allocated elements in streams array. out: number of written elements in the array - XnFwStreamInfo* streams; -} XnCommandGetFwStreamList; - -typedef struct XnCommandCreateStream -{ - XnFwStreamType type; - const char* creationInfo; - uint32_t id; // out -} XnCommandCreateStream; - -typedef struct XnCommandDestroyStream -{ - uint32_t id; -} XnCommandDestroyStream; - -typedef struct XnCommandStartStream -{ - uint32_t id; -} XnCommandStartStream; - -typedef struct XnCommandStopStream -{ - uint32_t id; -} XnCommandStopStream; - -typedef struct XnCommandGetFwStreamVideoModeList -{ - int streamId; - uint32_t count; // in: number of allocated elements in videoModes array. out: number of written elements in the array - XnFwStreamVideoMode* videoModes; -} XnCommandGetFwStreamVideoModeList; - -typedef struct XnCommandSetFwStreamVideoMode -{ - int streamId; - XnFwStreamVideoMode videoMode; -} XnCommandSetFwStreamVideoMode; - -typedef struct XnCommandGetFwStreamVideoMode -{ - int streamId; - XnFwStreamVideoMode videoMode; // out -} XnCommandGetFwStreamVideoMode; - -#pragma pack (pop) - -#endif //__XN_PRIME_CLIENT_PROPS_H__ diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h deleted file mode 100644 index 1517bddb3..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/PrimeSense.h +++ /dev/null @@ -1,229 +0,0 @@ -/***************************************************************************** -* * -* 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 _PRIME_SENSE_H_ -#define _PRIME_SENSE_H_ - -#include - -/** -* Additional properties for PrimeSense devices -* -* @remarks -* properties structure is 0x1D27XXYY where XX is range and YY is code. -* range values: -* 00 - common stream properties -* 10 - depth stream properties -* E0 - device commands -* F0 - device properties -*/ -enum -{ - // Stream Properties - PS_PROPERTY_DUMP_DATA = 0x1d270001, // boolean - - // Device Properties - PS_PROPERTY_USB_INTERFACE = 0x1d27F001, // values from XnUsbInterfaceType -}; - -/** -* Additional commands for PrimeSense devices -* -* @remarks -* Commands structure is 0x1D27XXYY where XX is range and YY is code. -* range values: -* E0 - device commands -*/ -enum -{ - // Device Commands - use via invoke() - PS_COMMAND_AHB_READ = 0x1d27E001, // XnCommandAHB - PS_COMMAND_AHB_WRITE = 0x1d27E002, // XnCommandAHB - PS_COMMAND_I2C_READ = 0x1d27E003, // XnCommandI2C - PS_COMMAND_I2C_WRITE = 0x1d27E004, // XnCommandI2C - PS_COMMAND_SOFT_RESET = 0x1d27E005, // no arguments - PS_COMMAND_POWER_RESET = 0x1d27E006, // no arguments - PS_COMMAND_BEGIN_FIRMWARE_UPDATE = 0x1d27E007, // no arguments - PS_COMMAND_END_FIRMWARE_UPDATE = 0x1d27E008, // no arguments - PS_COMMAND_UPLOAD_FILE = 0x1d27E009, // XnCommandUploadFile - PS_COMMAND_DOWNLOAD_FILE = 0x1d27E00A, // XnCommandDownloadFile - PS_COMMAND_GET_FILE_LIST = 0x1d27E00B, // an array of XnFileEntry - PS_COMMAND_FORMAT_ZONE = 0x1d27E00C, // XnCommandFormatZone - PS_COMMAND_DUMP_ENDPOINT = 0x1d27E00D, // XnCommandDumpEndpoint - PS_COMMAND_GET_I2C_DEVICE_LIST = 0x1d27E00E, // XnCommandGetI2CDevices - PS_COMMAND_GET_BIST_LIST = 0x1d27E00F, // XnCommandGetBistList - PS_COMMAND_EXECUTE_BIST = 0x1d27E010, // XnCommandExecuteBist - PS_COMMAND_USB_TEST = 0x1d27E011, // XnCommandUsbTest - PS_COMMAND_GET_LOG_MASK_LIST = 0x1d27E012, // XnCommandGetLogMaskList - PS_COMMAND_SET_LOG_MASK_STATE = 0x1d27E013, // XnCommandSetLogMaskState - PS_COMMAND_START_LOG = 0x1d27E014, // no arguments - PS_COMMAND_STOP_LOG = 0x1d27E015, // no arguments -}; - -typedef enum XnUsbInterfaceType -{ - PS_USB_INTERFACE_DONT_CARE = 0, - PS_USB_INTERFACE_ISO_ENDPOINTS = 1, - PS_USB_INTERFACE_BULK_ENDPOINTS = 2, -} XnUsbInterfaceType; - -#pragma pack (push, 1) - -// Data Types -typedef struct XnFwFileVersion -{ - uint8_t major; - uint8_t minor; - uint8_t maintenance; - uint8_t build; -} XnFwFileVersion; - -typedef enum XnFwFileFlags -{ - XN_FILE_FLAG_BAD_CRC = 0x0001, -} XnFwFileFlags; - -typedef struct XnFwFileEntry -{ - char name[32]; - XnFwFileVersion version; - uint32_t address; - uint32_t size; - uint16_t crc; - uint16_t zone; - XnFwFileFlags flags; // bitmap -} XnFwFileEntry; - -typedef struct XnI2CDeviceInfo -{ - uint32_t id; - char name[32]; -} XnI2CDeviceInfo; - -typedef struct XnBistInfo -{ - uint32_t id; - char name[32]; -} XnBistInfo; - -typedef struct XnFwLogMask -{ - uint32_t id; - char name[32]; -} XnFwLogMask; - -typedef struct XnUsbTestEndpointResult -{ - double averageBytesPerSecond; - uint32_t lostPackets; -} XnUsbTestEndpointResult; - -// Commands - -typedef struct XnCommandAHB -{ - uint32_t address; // Address of this register - uint32_t offsetInBits; // Offset of the field in bits within address - uint32_t widthInBits; // Width of the field in bits - uint32_t value; // For read requests, this is where the actual value will be filled. For write requests, the value to write. -} XnCommandAHB; - -typedef struct XnCommandI2C -{ - uint32_t deviceID; // Device to communicate with - uint32_t addressSize; // Size of the address, in bytes (1-4) - uint32_t address; // Address - uint32_t valueSize; // Size of the value, in bytes (1-4) - uint32_t mask; // For write request - a mask to be applied to the value. For read requests - ignored. - uint32_t value; // For write request - the value to be written. For read requests - the place where the actual value is written to -} XnCommandI2C; - -typedef struct XnCommandUploadFile -{ - const char* filePath; - uint32_t uploadToFactory; -} XnCommandUploadFile; - -typedef struct XnCommandDownloadFile -{ - uint16_t zone; - const char* firmwareFileName; - const char* targetPath; -} XnCommandDownloadFile; - -typedef struct XnCommandGetFileList -{ - uint32_t count; // in: number of allocated elements in files array. out: number of written elements in the array - XnFwFileEntry* files; -} XnCommandGetFileList; - -typedef struct XnCommandFormatZone -{ - uint8_t zone; -} XnCommandFormatZone; - -typedef struct XnCommandDumpEndpoint -{ - uint8_t endpoint; - bool enabled; -} XnCommandDumpEndpoint; - -typedef struct XnCommandGetI2CDeviceList -{ - uint32_t count; // in: number of allocated elements in devices array. out: number of written elements in the array - XnI2CDeviceInfo* devices; -} XnCommandGetI2CDeviceList; - -typedef struct XnCommandGetBistList -{ - uint32_t count; // in: number of allocated elements in tests array. out: number of written elements in the array - XnBistInfo* tests; -} XnCommandGetBistList; - -typedef struct XnCommandExecuteBist -{ - uint32_t id; - uint32_t errorCode; - uint32_t extraDataSize; // in: number of allocated bytes in extraData. out: number of written bytes in extraData - uint8_t* extraData; -} XnCommandExecuteBist; - -typedef struct XnCommandUsbTest -{ - uint32_t seconds; - uint32_t endpointCount; // in: number of allocated bytes in endpoints array. out: number of written bytes in array - XnUsbTestEndpointResult* endpoints; -} XnCommandUsbTest; - -typedef struct XnCommandGetLogMaskList -{ - uint32_t count; // in: number of allocated elements in masks array. out: number of written elements in the array - XnFwLogMask* masks; -} XnCommandGetLogMaskList; - -typedef struct XnCommandSetLogMaskState -{ - uint32_t mask; - bool enabled; -} XnCommandSetLogMaskState; - -#pragma pack (pop) - -#endif //_PRIME_SENSE_H_ \ No newline at end of file diff --git a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h b/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h deleted file mode 100644 index 23bd81dbb..000000000 --- a/drivers/OpenNI2-Freenect2Driver/extern/OpenNI-Linux-x64-2.2.0.33/Include/Win32/OniPlatformWin32.h +++ /dev/null @@ -1,139 +0,0 @@ -/***************************************************************************** -* * -* 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 _ONI_PLATFORM_WIN32_H_ -#define _ONI_PLATFORM_WIN32_H_ - -//--------------------------------------------------------------------------- -// Prerequisites -//--------------------------------------------------------------------------- -#ifndef WINVER // Allow use of features specific to Windows XP or later - #define WINVER 0x0501 -#endif -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later - #define _WIN32_WINNT 0x0501 -#endif -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later - #define _WIN32_WINDOWS 0x0410 -#endif -#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later - #define _WIN32_IE 0x0600 -#endif -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -// Undeprecate CRT functions -#ifndef _CRT_SECURE_NO_DEPRECATE - #define _CRT_SECURE_NO_DEPRECATE 1 -#endif - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h... -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef __int64 int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; -#else -#include -#endif - -//--------------------------------------------------------------------------- -// Platform Basic Definition -//--------------------------------------------------------------------------- -#define ONI_PLATFORM ONI_PLATFORM_WIN32 -#define ONI_PLATFORM_STRING "Win32" - -//--------------------------------------------------------------------------- -// Platform Capabilities -//--------------------------------------------------------------------------- -#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN - -#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 - -//--------------------------------------------------------------------------- -// Memory -//--------------------------------------------------------------------------- -/** The default memory alignment. */ -#define ONI_DEFAULT_MEM_ALIGN 16 - -/** The thread static declarator (using TLS). */ -#define ONI_THREAD_STATIC __declspec(thread) - -//--------------------------------------------------------------------------- -// Files -//--------------------------------------------------------------------------- -/** The maximum allowed file path size (in bytes). */ -#define ONI_FILE_MAX_PATH MAX_PATH - -//--------------------------------------------------------------------------- -// Call backs -//--------------------------------------------------------------------------- -/** The std call type. */ -#define ONI_STDCALL __stdcall - -/** The call back calling convention. */ -#define ONI_CALLBACK_TYPE ONI_STDCALL - -/** The C and C++ calling convension. */ -#define ONI_C_DECL __cdecl - -//--------------------------------------------------------------------------- -// Macros -//--------------------------------------------------------------------------- -/** Returns the date and time at compile time. */ -#define ONI_TIMESTAMP __DATE__ " " __TIME__ - -/** Converts n into a pre-processor string. */ -#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) -#define ONI_STRINGIFY_HELPER(n) #n - -//--------------------------------------------------------------------------- -// API Export/Import Macros -//--------------------------------------------------------------------------- -/** Indicates an exported shared library function. */ -#define ONI_API_EXPORT __declspec(dllexport) - -/** Indicates an imported shared library function. */ -#define ONI_API_IMPORT __declspec(dllimport) - -/** Indicates a deprecated function */ -#if _MSC_VER < 1400 // Before VS2005 there was no support for declspec deprecated... - #define ONI_API_DEPRECATED(msg) -#else - #define ONI_API_DEPRECATED(msg) __declspec(deprecated(msg)) -#endif - -#endif //_ONI_PLATFORM_WIN32_H_ From 5992be312932b8470abd5763e1dd2f600f4e07b6 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 2 Jan 2016 06:43:54 +0900 Subject: [PATCH 17/20] openni2: Refactor setVideoMode() and getSensorInfo() in VideoStream class --- .../src/ColorStream.cpp | 16 +--- .../src/ColorStream.hpp | 15 +-- .../src/DepthStream.cpp | 18 +--- .../src/DepthStream.hpp | 16 +--- .../src/DeviceDriver.cpp | 93 ++++++++++--------- .../OpenNI2-Freenect2Driver/src/IrStream.cpp | 18 +--- .../OpenNI2-Freenect2Driver/src/IrStream.hpp | 16 +--- .../src/VideoStream.hpp | 29 +++++- 8 files changed, 88 insertions(+), 133 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp index 0c56b03d2..43e196f99 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.cpp @@ -38,11 +38,10 @@ ColorStream::ColorStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver { video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_RGB888, 1920, 1080, 30); setVideoMode(video_mode); - pDevice->start(); } // Add video modes here as you implement them -ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() +ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() const { FreenectVideoModeMap modes; // pixelFormat, resolutionX, resolutionY, fps @@ -52,20 +51,9 @@ ColorStream::FreenectVideoModeMap ColorStream::getSupportedVideoModes() return modes; } -OniStatus ColorStream::setVideoMode(OniVideoMode requested_mode) -{ - FreenectVideoModeMap supported_video_modes = getSupportedVideoModes(); - FreenectVideoModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); - if (matched_mode_iter == supported_video_modes.end()) - return ONI_STATUS_NOT_SUPPORTED; - - video_mode = requested_mode; - return ONI_STATUS_OK; -} - void ColorStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const { - dstFrame->sensorType = sensor_type; + dstFrame->sensorType = getSensorType(); dstFrame->stride = dstFrame->width * 3; // copy stream buffer from freenect diff --git a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp index d10966f63..ae0bfacbb 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/ColorStream.hpp @@ -46,10 +46,8 @@ namespace Freenect2Driver private: typedef std::map< OniVideoMode, int > FreenectVideoModeMap; - static const OniSensorType sensor_type = ONI_SENSOR_COLOR; - - static FreenectVideoModeMap getSupportedVideoModes(); - OniStatus setVideoMode(OniVideoMode requested_mode); + OniSensorType getSensorType() const { return ONI_SENSOR_COLOR; } + VideoModeMap getSupportedVideoModes() const; void populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const; static void copyFrame(uint8_t* srcPix, int srcX, int srcY, int srcStride, uint8_t* dstPix, int dstX, int dstY, int dstStride, int width, int height, bool mirroring); @@ -61,15 +59,6 @@ namespace Freenect2Driver ColorStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); //~ColorStream() { } - static OniSensorInfo getSensorInfo() - { - FreenectVideoModeMap supported_modes = getSupportedVideoModes(); - OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; - std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); - OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; - return sensors; - } - OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) { if (mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp index c21e3d02b..f96a5d0d6 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.cpp @@ -50,15 +50,14 @@ DepthStream::DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30); setVideoMode(video_mode); setImageRegistrationMode(ONI_IMAGE_REGISTRATION_OFF); - pDevice->start(); } // Add video modes here as you implement them // Note: if image_registration_mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR, // setVideoFormat() will try FREENECT_DEPTH_REGISTERED first then fall back on what is set here. -DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() +DepthStream::VideoModeMap DepthStream::getSupportedVideoModes() const { - FreenectDepthModeMap modes; + VideoModeMap modes; // pixelFormat, resolutionX, resolutionY, fps modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 640, 480, 30)] = 0; modes[makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, 512, 424, 30)] = 1; @@ -66,20 +65,9 @@ DepthStream::FreenectDepthModeMap DepthStream::getSupportedVideoModes() return modes; } -OniStatus DepthStream::setVideoMode(OniVideoMode requested_mode) -{ - FreenectDepthModeMap supported_video_modes = getSupportedVideoModes(); - FreenectDepthModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); - if (matched_mode_iter == supported_video_modes.end()) - return ONI_STATUS_NOT_SUPPORTED; - - video_mode = requested_mode; - return ONI_STATUS_OK; -} - void DepthStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const { - dstFrame->sensorType = sensor_type; + dstFrame->sensorType = getSensorType(); dstFrame->stride = dstFrame->width * sizeof(uint16_t); // XXX, save depth map for registration diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp index 8a1b3fba6..6a194d161 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -58,27 +58,15 @@ namespace Freenect2Driver static const double EMITTER_DCMOS_DISTANCE_VAL; private: - typedef std::map FreenectDepthModeMap; - static const OniSensorType sensor_type = ONI_SENSOR_DEPTH; + OniSensorType getSensorType() const { return ONI_SENSOR_DEPTH; } OniImageRegistrationMode image_registration_mode; - - static FreenectDepthModeMap getSupportedVideoModes(); - OniStatus setVideoMode(OniVideoMode requested_mode); + VideoModeMap getSupportedVideoModes() const; void populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const; public: DepthStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); //~DepthStream() { } - static OniSensorInfo getSensorInfo() - { - FreenectDepthModeMap supported_modes = getSupportedVideoModes(); - OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; - std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); - OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; - return sensors; - } - OniImageRegistrationMode getImageRegistrationMode() const { return image_registration_mode; } OniStatus setImageRegistrationMode(OniImageRegistrationMode mode) { diff --git a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index f388fa13b..c0266156f 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -142,10 +142,10 @@ namespace Freenect2Driver } ~Device() { - close(); destroyStream(color); destroyStream(ir); destroyStream(depth); + close(); if (reg) { delete reg; reg = NULL; @@ -166,17 +166,48 @@ namespace Freenect2Driver //TODO: start thread executing the run() method //device_stop = false; //thread = new libfreenect2::thread(&Device::static_run, this); - dev->start(); + if (! color) { + color = new ColorStream(dev, reg); + setStreamProperties(color, "color"); + } + if (! depth) { + depth = new DepthStream(dev, reg); + setStreamProperties(depth, "depth"); + } + if (! ir) { + ir = new IrStream(dev, reg); + setStreamProperties(ir, "ir"); + } + dev->start(); } void stop() { - device_stop = true; - thread->join(); - - dev->stop(); + if (!device_stop) { + device_stop = true; + thread->join(); + dev->stop(); + } + if (color != NULL) + { + delete color; + color = NULL; + } + if (depth != NULL) + { + delete depth; + depth = NULL; + } + if (ir != NULL) + { + delete ir; + ir = NULL; + } } void close() { - stop(); - dev->close(); + if (this->dev) { + stop(); + dev->close(); + } + this->dev = NULL; } // for DeviceBase @@ -202,48 +233,25 @@ namespace Freenect2Driver LogError("Cannot create a stream of type " + to_string(sensorType)); return NULL; case ONI_SENSOR_COLOR: - if (! color) { - color = new ColorStream(dev, reg); - setStreamProperties(color, "color"); - } + WriteMessage("Device: createStream(color)"); return color; case ONI_SENSOR_DEPTH: - if (! depth) { - depth = new DepthStream(dev, reg); - setStreamProperties(depth, "depth"); - } + WriteMessage("Device: createStream(depth)"); return depth; case ONI_SENSOR_IR: - if (! ir) { - ir = new IrStream(dev, reg); - setStreamProperties(ir, "ir"); - } + WriteMessage("Device: createStream(ir)"); return ir; } } void destroyStream(oni::driver::StreamBase* pStream) { - if (pStream == NULL) - return; - - // stop them all - dev->stop(); if (pStream == color) - { - delete color; - color = NULL; - } + WriteMessage("Device: destroyStream(color)"); if (pStream == depth) - { - delete depth; - depth = NULL; - } + WriteMessage("Device: destroyStream(depth)"); if (pStream == ir) - { - delete ir; - ir = NULL; - } + WriteMessage("Device: destroyStream(ir)"); } // todo: fill out properties @@ -464,6 +472,7 @@ namespace Freenect2Driver Device* device = new Device(id); device->setFreenect2Device(freenect2.openDevice(id)); // XXX, detault pipeline // const PacketPipeline *factory); device->setConfigStrings(config); + device->start(); iter->second = device; return device; } @@ -509,14 +518,10 @@ namespace Freenect2Driver { for (OniDeviceMap::iterator iter = devices.begin(); iter != devices.end(); iter++) { - WriteMessage("Closing device " + std::string(iter->first.uri)); - int id = uri_to_devid(iter->first.uri); - Device* device = (Device*)iter->second; - device->stop(); - device->close(); + if (iter->second) { + deviceClose(iter->second); + } } - - devices.clear(); } diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp index 74f5ff0c8..2427c3d1d 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.cpp @@ -37,33 +37,21 @@ IrStream::IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Regi { video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30); setVideoMode(video_mode); - pDevice->start(); } // Add video modes here as you implement them -IrStream::FreenectIrModeMap IrStream::getSupportedVideoModes() +IrStream::VideoModeMap IrStream::getSupportedVideoModes() const { - FreenectIrModeMap modes; + VideoModeMap modes; // pixelFormat, resolutionX, resolutionY, fps modes[makeOniVideoMode(ONI_PIXEL_FORMAT_GRAY16, 512, 424, 30)] = 0; return modes; } -OniStatus IrStream::setVideoMode(OniVideoMode requested_mode) -{ - FreenectIrModeMap supported_video_modes = getSupportedVideoModes(); - FreenectIrModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); - if (matched_mode_iter == supported_video_modes.end()) - return ONI_STATUS_NOT_SUPPORTED; - - video_mode = requested_mode; - return ONI_STATUS_OK; -} - void IrStream::populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const { - dstFrame->sensorType = sensor_type; + dstFrame->sensorType = getSensorType(); dstFrame->stride = dstFrame->width * sizeof(uint16_t); // copy stream buffer from freenect diff --git a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp index 4bb51bcf0..cdd5b3b0c 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/IrStream.hpp @@ -44,26 +44,14 @@ namespace Freenect2Driver static const float VERTICAL_FOV; private: - typedef std::map< OniVideoMode, int> FreenectIrModeMap; - static const OniSensorType sensor_type = ONI_SENSOR_IR; - - static FreenectIrModeMap getSupportedVideoModes(); - OniStatus setVideoMode(OniVideoMode requested_mode); + OniSensorType getSensorType() const { return ONI_SENSOR_IR; } + VideoModeMap getSupportedVideoModes() const; void populateFrame(libfreenect2::Frame* srcFrame, int srcX, int srcY, OniFrame* dstFrame, int dstX, int dstY, int width, int height) const; public: IrStream(libfreenect2::Freenect2Device* pDevice, Freenect2Driver::Registration *reg); //~IrStream() { } - static OniSensorInfo getSensorInfo() - { - FreenectIrModeMap supported_modes = getSupportedVideoModes(); - OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; - std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); - OniSensorInfo sensors = { sensor_type, static_cast(supported_modes.size()), modes }; - return sensors; - } - // from StreamBase OniBool isPropertySupported(int propertyId) { diff --git a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp index f556b4016..baff4c1a8 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/VideoStream.hpp @@ -39,12 +39,10 @@ namespace Freenect2Driver { private: unsigned int frame_id; // number each frame - - virtual OniStatus setVideoMode(OniVideoMode requested_mode) = 0; virtual void populateFrame(libfreenect2::Frame* lf2Frame, int srcX, int srcY, OniFrame* oniFrame, int tgtX, int tgtY, int width, int height) const = 0; protected: - static const OniSensorType sensor_type; + virtual OniSensorType getSensorType() const = 0; libfreenect2::Freenect2Device* device; bool running; // buildFrame() does something iff true OniVideoMode video_mode; @@ -52,6 +50,19 @@ namespace Freenect2Driver bool mirroring; Freenect2Driver::Registration* reg; bool callPropertyChangedCallback; + typedef std::map< OniVideoMode, int > VideoModeMap; + virtual VideoModeMap getSupportedVideoModes() const = 0; + + OniStatus setVideoMode(OniVideoMode requested_mode) + { + VideoModeMap supported_video_modes = getSupportedVideoModes(); + VideoModeMap::const_iterator matched_mode_iter = supported_video_modes.find(requested_mode); + if (matched_mode_iter == supported_video_modes.end()) + return ONI_STATUS_NOT_SUPPORTED; + + video_mode = requested_mode; + return ONI_STATUS_OK; + } static void copyFrame(float* srcPix, int srcX, int srcY, int srcStride, uint16_t* dstPix, int dstX, int dstY, int dstStride, int width, int height, bool mirroring) { @@ -82,7 +93,8 @@ namespace Freenect2Driver device(device), reg(reg), callPropertyChangedCallback(false), - mirroring(false) + mirroring(false), + running(false) { // joy of structs memset(&cropping, 0, sizeof(cropping)); @@ -90,6 +102,15 @@ namespace Freenect2Driver } //~VideoStream() { stop(); } + OniSensorInfo getSensorInfo() + { + VideoModeMap supported_modes = getSupportedVideoModes(); + OniVideoMode* modes = new OniVideoMode[supported_modes.size()]; + std::transform(supported_modes.begin(), supported_modes.end(), modes, ExtractKey()); + OniSensorInfo sensors = { getSensorType(), static_cast(supported_modes.size()), modes }; + return sensors; + } + void setPropertyChangedCallback(oni::driver::PropertyChangedCallback handler, void* pCookie) { callPropertyChangedCallback = true; StreamBase::setPropertyChangedCallback(handler, pCookie); From 6d37bae11c3c1a7be0eee58aba0000da51a6e927 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 2 Jan 2016 13:55:24 +0900 Subject: [PATCH 18/20] openni2: Remove D2S.h adn S2D.h --- drivers/OpenNI2-Freenect2Driver/src/D2S.h | 1029 ----------------- .../src/DepthStream.hpp | 22 +- drivers/OpenNI2-Freenect2Driver/src/S2D.h | 233 ---- 3 files changed, 14 insertions(+), 1270 deletions(-) delete mode 100644 drivers/OpenNI2-Freenect2Driver/src/D2S.h delete mode 100644 drivers/OpenNI2-Freenect2Driver/src/S2D.h diff --git a/drivers/OpenNI2-Freenect2Driver/src/D2S.h b/drivers/OpenNI2-Freenect2Driver/src/D2S.h deleted file mode 100644 index 8ca91cc8f..000000000 --- a/drivers/OpenNI2-Freenect2Driver/src/D2S.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* - * This file is part of the OpenKinect Project. http://www.openkinect.org - * - * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file - * for details. - * - * This code is licensed to you under the terms of the Apache License, version - * 2.0, or, at your option, the terms of the GNU General Public License, - * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, - * or the following URLs: - * http://www.apache.org/licenses/LICENSE-2.0 - * http://www.gnu.org/licenses/gpl-2.0.txt - * - * If you redistribute this file in source form, modified or unmodified, you - * may: - * 1) Leave this header intact and distribute it under the same terms, - * accompanying it with the APACHE20 and GPL20 files, or - * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or - * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file - * In all cases you must keep the copyright notice intact and include a copy - * of the CONTRIB file. - * - * Binary distributions must follow the binary distribution requirements of - * either License. - */ - -const unsigned short D2S[] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 3, 7, 10, 13, 17, -20, 23, 27, 30, 33, 36, 40, 43, 46, 49, -52, 55, 59, 62, 65, 68, 71, 74, 77, 80, -83, 86, 88, 91, 94, 97, 100, 103, 106, 108, -111, 114, 117, 119, 122, 125, 128, 130, 133, 136, -138, 141, 143, 146, 149, 151, 154, 156, 159, 161, -164, 166, 169, 171, 174, 176, 178, 181, 183, 186, -188, 190, 193, 195, 197, 200, 202, 204, 206, 209, -211, 213, 215, 218, 220, 222, 224, 226, 229, 231, -233, 235, 237, 239, 241, 243, 245, 247, 249, 252, -254, 256, 258, 260, 262, 264, 266, 267, 269, 271, -273, 275, 277, 279, 281, 283, 285, 287, 288, 290, -292, 294, 296, 298, 299, 301, 303, 305, 307, 308, -310, 312, 314, 315, 317, 319, 321, 322, 324, 326, -327, 329, 331, 332, 334, 336, 337, 339, 341, 342, -344, 345, 347, 349, 350, 352, 353, 355, 357, 358, -360, 361, 363, 364, 366, 367, 369, 370, 372, 373, -375, 376, 378, 379, 381, 382, 383, 385, 386, 388, -389, 391, 392, 393, 395, 396, 398, 399, 400, 402, -403, 404, 406, 407, 409, 410, 411, 413, 414, 415, -416, 418, 419, 420, 422, 423, 424, 426, 427, 428, -429, 431, 432, 433, 434, 436, 437, 438, 439, 441, -442, 443, 444, 445, 447, 448, 449, 450, 451, 452, -454, 455, 456, 457, 458, 459, 461, 462, 463, 464, -465, 466, 467, 468, 470, 471, 472, 473, 474, 475, -476, 477, 478, 479, 480, 482, 483, 484, 485, 486, -487, 488, 489, 490, 491, 492, 493, 494, 495, 496, -497, 498, 499, 500, 501, 502, 503, 504, 505, 506, -507, 508, 509, 510, 511, 512, 513, 514, 515, 516, -517, 518, 519, 520, 521, 521, 522, 523, 524, 525, -526, 527, 528, 529, 530, 531, 532, 532, 533, 534, -535, 536, 537, 538, 539, 540, 540, 541, 542, 543, -544, 545, 546, 546, 547, 548, 549, 550, 551, 551, -552, 553, 554, 555, 556, 556, 557, 558, 559, 560, -561, 561, 562, 563, 564, 565, 565, 566, 567, 568, -568, 569, 570, 571, 572, 572, 573, 574, 575, 575, -576, 577, 578, 578, 579, 580, 581, 581, 582, 583, -584, 584, 585, 586, 587, 587, 588, 589, 590, 590, -591, 592, 592, 593, 594, 594, 595, 596, 597, 597, -598, 599, 599, 600, 601, 601, 602, 603, 604, 604, -605, 606, 606, 607, 608, 608, 609, 610, 610, 611, -612, 612, 613, 614, 614, 615, 615, 616, 617, 617, -618, 619, 619, 620, 621, 621, 622, 622, 623, 624, -624, 625, 626, 626, 627, 627, 628, 629, 629, 630, -631, 631, 632, 632, 633, 634, 634, 635, 635, 636, -636, 637, 638, 638, 639, 639, 640, 641, 641, 642, -642, 643, 643, 644, 645, 645, 646, 646, 647, 647, -648, 649, 649, 650, 650, 651, 651, 652, 652, 653, -654, 654, 655, 655, 656, 656, 657, 657, 658, 658, -659, 659, 660, 661, 661, 662, 662, 663, 663, 664, -664, 665, 665, 666, 666, 667, 667, 668, 668, 669, -669, 670, 670, 671, 671, 672, 672, 673, 673, 674, -674, 675, 675, 676, 676, 677, 677, 678, 678, 679, -679, 680, 680, 681, 681, 682, 682, 683, 683, 684, -684, 685, 685, 685, 686, 686, 687, 687, 688, 688, -689, 689, 690, 690, 691, 691, 691, 692, 692, 693, -693, 694, 694, 695, 695, 696, 696, 696, 697, 697, -698, 698, 699, 699, 699, 700, 700, 701, 701, 702, -702, 703, 703, 703, 704, 704, 705, 705, 706, 706, -706, 707, 707, 708, 708, 708, 709, 709, 710, 710, -711, 711, 711, 712, 712, 713, 713, 713, 714, 714, -715, 715, 715, 716, 716, 717, 717, 717, 718, 718, -719, 719, 719, 720, 720, 721, 721, 721, 722, 722, -723, 723, 723, 724, 724, 724, 725, 725, 726, 726, -726, 727, 727, 727, 728, 728, 729, 729, 729, 730, -730, 730, 731, 731, 732, 732, 732, 733, 733, 733, -734, 734, 734, 735, 735, 736, 736, 736, 737, 737, -737, 738, 738, 738, 739, 739, 739, 740, 740, 741, -741, 741, 742, 742, 742, 743, 743, 743, 744, 744, -744, 745, 745, 745, 746, 746, 746, 747, 747, 747, -748, 748, 748, 749, 749, 749, 750, 750, 750, 751, -751, 751, 752, 752, 752, 753, 753, 753, 754, 754, -754, 755, 755, 755, 756, 756, 756, 756, 757, 757, -757, 758, 758, 758, 759, 759, 759, 760, 760, 760, -761, 761, 761, 761, 762, 762, 762, 763, 763, 763, -764, 764, 764, 765, 765, 765, 765, 766, 766, 766, -767, 767, 767, 768, 768, 768, 768, 769, 769, 769, -770, 770, 770, 770, 771, 771, 771, 772, 772, 772, -773, 773, 773, 773, 774, 774, 774, 775, 775, 775, -775, 776, 776, 776, 776, 777, 777, 777, 778, 778, -778, 778, 779, 779, 779, 780, 780, 780, 780, 781, -781, 781, 781, 782, 782, 782, 783, 783, 783, 783, -784, 784, 784, 784, 785, 785, 785, 785, 786, 786, -786, 787, 787, 787, 787, 788, 788, 788, 788, 789, -789, 789, 789, 790, 790, 790, 790, 791, 791, 791, -791, 792, 792, 792, 792, 793, 793, 793, 793, 794, -794, 794, 794, 795, 795, 795, 795, 796, 796, 796, -796, 797, 797, 797, 797, 798, 798, 798, 798, 799, -799, 799, 799, 800, 800, 800, 800, 801, 801, 801, -801, 801, 802, 802, 802, 802, 803, 803, 803, 803, -804, 804, 804, 804, 805, 805, 805, 805, 805, 806, -806, 806, 806, 807, 807, 807, 807, 808, 808, 808, -808, 808, 809, 809, 809, 809, 810, 810, 810, 810, -810, 811, 811, 811, 811, 812, 812, 812, 812, 812, -813, 813, 813, 813, 813, 814, 814, 814, 814, 815, -815, 815, 815, 815, 816, 816, 816, 816, 817, 817, -817, 817, 817, 818, 818, 818, 818, 818, 819, 819, -819, 819, 819, 820, 820, 820, 820, 820, 821, 821, -821, 821, 822, 822, 822, 822, 822, 823, 823, 823, -823, 823, 824, 824, 824, 824, 824, 825, 825, 825, -825, 825, 826, 826, 826, 826, 826, 827, 827, 827, -827, 827, 828, 828, 828, 828, 828, 828, 829, 829, -829, 829, 829, 830, 830, 830, 830, 830, 831, 831, -831, 831, 831, 832, 832, 832, 832, 832, 832, 833, -833, 833, 833, 833, 834, 834, 834, 834, 834, 835, -835, 835, 835, 835, 835, 836, 836, 836, 836, 836, -837, 837, 837, 837, 837, 837, 838, 838, 838, 838, -838, 839, 839, 839, 839, 839, 839, 840, 840, 840, -840, 840, 841, 841, 841, 841, 841, 841, 842, 842, -842, 842, 842, 842, 843, 843, 843, 843, 843, 843, -844, 844, 844, 844, 844, 845, 845, 845, 845, 845, -845, 846, 846, 846, 846, 846, 846, 847, 847, 847, -847, 847, 847, 848, 848, 848, 848, 848, 848, 849, -849, 849, 849, 849, 849, 850, 850, 850, 850, 850, -850, 850, 851, 851, 851, 851, 851, 851, 852, 852, -852, 852, 852, 852, 853, 853, 853, 853, 853, 853, -854, 854, 854, 854, 854, 854, 854, 855, 855, 855, -855, 855, 855, 856, 856, 856, 856, 856, 856, 857, -857, 857, 857, 857, 857, 857, 858, 858, 858, 858, -858, 858, 858, 859, 859, 859, 859, 859, 859, 860, -860, 860, 860, 860, 860, 860, 861, 861, 861, 861, -861, 861, 861, 862, 862, 862, 862, 862, 862, 863, -863, 863, 863, 863, 863, 863, 864, 864, 864, 864, -864, 864, 864, 865, 865, 865, 865, 865, 865, 865, -866, 866, 866, 866, 866, 866, 866, 867, 867, 867, -867, 867, 867, 867, 868, 868, 868, 868, 868, 868, -868, 868, 869, 869, 869, 869, 869, 869, 869, 870, -870, 870, 870, 870, 870, 870, 871, 871, 871, 871, -871, 871, 871, 871, 872, 872, 872, 872, 872, 872, -872, 873, 873, 873, 873, 873, 873, 873, 873, 874, -874, 874, 874, 874, 874, 874, 875, 875, 875, 875, -875, 875, 875, 875, 876, 876, 876, 876, 876, 876, -876, 876, 877, 877, 877, 877, 877, 877, 877, 878, -878, 878, 878, 878, 878, 878, 878, 879, 879, 879, -879, 879, 879, 879, 879, 880, 880, 880, 880, 880, -880, 880, 880, 881, 881, 881, 881, 881, 881, 881, -881, 882, 882, 882, 882, 882, 882, 882, 882, 882, -883, 883, 883, 883, 883, 883, 883, 883, 884, 884, -884, 884, 884, 884, 884, 884, 885, 885, 885, 885, -885, 885, 885, 885, 885, 886, 886, 886, 886, 886, -886, 886, 886, 887, 887, 887, 887, 887, 887, 887, -887, 887, 888, 888, 888, 888, 888, 888, 888, 888, -888, 889, 889, 889, 889, 889, 889, 889, 889, 890, -890, 890, 890, 890, 890, 890, 890, 890, 891, 891, -891, 891, 891, 891, 891, 891, 891, 892, 892, 892, -892, 892, 892, 892, 892, 892, 893, 893, 893, 893, -893, 893, 893, 893, 893, 893, 894, 894, 894, 894, -894, 894, 894, 894, 894, 895, 895, 895, 895, 895, -895, 895, 895, 895, 896, 896, 896, 896, 896, 896, -896, 896, 896, 896, 897, 897, 897, 897, 897, 897, -897, 897, 897, 898, 898, 898, 898, 898, 898, 898, -898, 898, 898, 899, 899, 899, 899, 899, 899, 899, -899, 899, 899, 900, 900, 900, 900, 900, 900, 900, -900, 900, 900, 901, 901, 901, 901, 901, 901, 901, -901, 901, 901, 902, 902, 902, 902, 902, 902, 902, -902, 902, 902, 903, 903, 903, 903, 903, 903, 903, -903, 903, 903, 904, 904, 904, 904, 904, 904, 904, -904, 904, 904, 905, 905, 905, 905, 905, 905, 905, -905, 905, 905, 905, 906, 906, 906, 906, 906, 906, -906, 906, 906, 906, 907, 907, 907, 907, 907, 907, -907, 907, 907, 907, 907, 908, 908, 908, 908, 908, -908, 908, 908, 908, 908, 908, 909, 909, 909, 909, -909, 909, 909, 909, 909, 909, 910, 910, 910, 910, -910, 910, 910, 910, 910, 910, 910, 911, 911, 911, -911, 911, 911, 911, 911, 911, 911, 911, 911, 912, -912, 912, 912, 912, 912, 912, 912, 912, 912, 912, -913, 913, 913, 913, 913, 913, 913, 913, 913, 913, -913, 914, 914, 914, 914, 914, 914, 914, 914, 914, -914, 914, 914, 915, 915, 915, 915, 915, 915, 915, -915, 915, 915, 915, 915, 916, 916, 916, 916, 916, -916, 916, 916, 916, 916, 916, 917, 917, 917, 917, -917, 917, 917, 917, 917, 917, 917, 917, 918, 918, -918, 918, 918, 918, 918, 918, 918, 918, 918, 918, -919, 919, 919, 919, 919, 919, 919, 919, 919, 919, -919, 919, 919, 920, 920, 920, 920, 920, 920, 920, -920, 920, 920, 920, 920, 921, 921, 921, 921, 921, -921, 921, 921, 921, 921, 921, 921, 921, 922, 922, -922, 922, 922, 922, 922, 922, 922, 922, 922, 922, -923, 923, 923, 923, 923, 923, 923, 923, 923, 923, -923, 923, 923, 924, 924, 924, 924, 924, 924, 924, -924, 924, 924, 924, 924, 924, 925, 925, 925, 925, -925, 925, 925, 925, 925, 925, 925, 925, 925, 926, -926, 926, 926, 926, 926, 926, 926, 926, 926, 926, -926, 926, 926, 927, 927, 927, 927, 927, 927, 927, -927, 927, 927, 927, 927, 927, 928, 928, 928, 928, -928, 928, 928, 928, 928, 928, 928, 928, 928, 928, -929, 929, 929, 929, 929, 929, 929, 929, 929, 929, -929, 929, 929, 929, 930, 930, 930, 930, 930, 930, -930, 930, 930, 930, 930, 930, 930, 930, 931, 931, -931, 931, 931, 931, 931, 931, 931, 931, 931, 931, -931, 931, 932, 932, 932, 932, 932, 932, 932, 932, -932, 932, 932, 932, 932, 932, 933, 933, 933, 933, -933, 933, 933, 933, 933, 933, 933, 933, 933, 933, -933, 934, 934, 934, 934, 934, 934, 934, 934, 934, -934, 934, 934, 934, 934, 934, 935, 935, 935, 935, -935, 935, 935, 935, 935, 935, 935, 935, 935, 935, -935, 936, 936, 936, 936, 936, 936, 936, 936, 936, -936, 936, 936, 936, 936, 936, 937, 937, 937, 937, -937, 937, 937, 937, 937, 937, 937, 937, 937, 937, -937, 938, 938, 938, 938, 938, 938, 938, 938, 938, -938, 938, 938, 938, 938, 938, 938, 939, 939, 939, -939, 939, 939, 939, 939, 939, 939, 939, 939, 939, -939, 939, 939, 940, 940, 940, 940, 940, 940, 940, -940, 940, 940, 940, 940, 940, 940, 940, 940, 941, -941, 941, 941, 941, 941, 941, 941, 941, 941, 941, -941, 941, 941, 941, 941, 942, 942, 942, 942, 942, -942, 942, 942, 942, 942, 942, 942, 942, 942, 942, -942, 943, 943, 943, 943, 943, 943, 943, 943, 943, -943, 943, 943, 943, 943, 943, 943, 943, 944, 944, -944, 944, 944, 944, 944, 944, 944, 944, 944, 944, -944, 944, 944, 944, 944, 945, 945, 945, 945, 945, -945, 945, 945, 945, 945, 945, 945, 945, 945, 945, -945, 945, 946, 946, 946, 946, 946, 946, 946, 946, -946, 946, 946, 946, 946, 946, 946, 946, 946, 946, -947, 947, 947, 947, 947, 947, 947, 947, 947, 947, -947, 947, 947, 947, 947, 947, 947, 948, 948, 948, -948, 948, 948, 948, 948, 948, 948, 948, 948, 948, -948, 948, 948, 948, 948, 949, 949, 949, 949, 949, -949, 949, 949, 949, 949, 949, 949, 949, 949, 949, -949, 949, 949, 950, 950, 950, 950, 950, 950, 950, -950, 950, 950, 950, 950, 950, 950, 950, 950, 950, -950, 950, 951, 951, 951, 951, 951, 951, 951, 951, -951, 951, 951, 951, 951, 951, 951, 951, 951, 951, -951, 952, 952, 952, 952, 952, 952, 952, 952, 952, -952, 952, 952, 952, 952, 952, 952, 952, 952, 952, -953, 953, 953, 953, 953, 953, 953, 953, 953, 953, -953, 953, 953, 953, 953, 953, 953, 953, 953, 954, -954, 954, 954, 954, 954, 954, 954, 954, 954, 954, -954, 954, 954, 954, 954, 954, 954, 954, 955, 955, -955, 955, 955, 955, 955, 955, 955, 955, 955, 955, -955, 955, 955, 955, 955, 955, 955, 955, 956, 956, -956, 956, 956, 956, 956, 956, 956, 956, 956, 956, -956, 956, 956, 956, 956, 956, 956, 956, 956, 957, -957, 957, 957, 957, 957, 957, 957, 957, 957, 957, -957, 957, 957, 957, 957, 957, 957, 957, 957, 958, -958, 958, 958, 958, 958, 958, 958, 958, 958, 958, -958, 958, 958, 958, 958, 958, 958, 958, 958, 958, -959, 959, 959, 959, 959, 959, 959, 959, 959, 959, -959, 959, 959, 959, 959, 959, 959, 959, 959, 959, -959, 960, 960, 960, 960, 960, 960, 960, 960, 960, -960, 960, 960, 960, 960, 960, 960, 960, 960, 960, -960, 960, 960, 961, 961, 961, 961, 961, 961, 961, -961, 961, 961, 961, 961, 961, 961, 961, 961, 961, -961, 961, 961, 961, 962, 962, 962, 962, 962, 962, -962, 962, 962, 962, 962, 962, 962, 962, 962, 962, -962, 962, 962, 962, 962, 962, 962, 963, 963, 963, -963, 963, 963, 963, 963, 963, 963, 963, 963, 963, -963, 963, 963, 963, 963, 963, 963, 963, 963, 964, -964, 964, 964, 964, 964, 964, 964, 964, 964, 964, -964, 964, 964, 964, 964, 964, 964, 964, 964, 964, -964, 964, 965, 965, 965, 965, 965, 965, 965, 965, -965, 965, 965, 965, 965, 965, 965, 965, 965, 965, -965, 965, 965, 965, 965, 966, 966, 966, 966, 966, -966, 966, 966, 966, 966, 966, 966, 966, 966, 966, -966, 966, 966, 966, 966, 966, 966, 966, 966, 967, -967, 967, 967, 967, 967, 967, 967, 967, 967, 967, -967, 967, 967, 967, 967, 967, 967, 967, 967, 967, -967, 967, 967, 968, 968, 968, 968, 968, 968, 968, -968, 968, 968, 968, 968, 968, 968, 968, 968, 968, -968, 968, 968, 968, 968, 968, 968, 968, 969, 969, -969, 969, 969, 969, 969, 969, 969, 969, 969, 969, -969, 969, 969, 969, 969, 969, 969, 969, 969, 969, -969, 969, 969, 970, 970, 970, 970, 970, 970, 970, -970, 970, 970, 970, 970, 970, 970, 970, 970, 970, -970, 970, 970, 970, 970, 970, 970, 970, 971, 971, -971, 971, 971, 971, 971, 971, 971, 971, 971, 971, -971, 971, 971, 971, 971, 971, 971, 971, 971, 971, -971, 971, 971, 971, 972, 972, 972, 972, 972, 972, -972, 972, 972, 972, 972, 972, 972, 972, 972, 972, -972, 972, 972, 972, 972, 972, 972, 972, 972, 972, -973, 973, 973, 973, 973, 973, 973, 973, 973, 973, -973, 973, 973, 973, 973, 973, 973, 973, 973, 973, -973, 973, 973, 973, 973, 973, 973, 974, 974, 974, -974, 974, 974, 974, 974, 974, 974, 974, 974, 974, -974, 974, 974, 974, 974, 974, 974, 974, 974, 974, -974, 974, 974, 974, 975, 975, 975, 975, 975, 975, -975, 975, 975, 975, 975, 975, 975, 975, 975, 975, -975, 975, 975, 975, 975, 975, 975, 975, 975, 975, -975, 975, 976, 976, 976, 976, 976, 976, 976, 976, -976, 976, 976, 976, 976, 976, 976, 976, 976, 976, -976, 976, 976, 976, 976, 976, 976, 976, 976, 976, -977, 977, 977, 977, 977, 977, 977, 977, 977, 977, -977, 977, 977, 977, 977, 977, 977, 977, 977, 977, -977, 977, 977, 977, 977, 977, 977, 977, 977, 978, -978, 978, 978, 978, 978, 978, 978, 978, 978, 978, -978, 978, 978, 978, 978, 978, 978, 978, 978, 978, -978, 978, 978, 978, 978, 978, 978, 978, 979, 979, -979, 979, 979, 979, 979, 979, 979, 979, 979, 979, -979, 979, 979, 979, 979, 979, 979, 979, 979, 979, -979, 979, 979, 979, 979, 979, 979, 979, 980, 980, -980, 980, 980, 980, 980, 980, 980, 980, 980, 980, -980, 980, 980, 980, 980, 980, 980, 980, 980, 980, -980, 980, 980, 980, 980, 980, 980, 980, 981, 981, -981, 981, 981, 981, 981, 981, 981, 981, 981, 981, -981, 981, 981, 981, 981, 981, 981, 981, 981, 981, -981, 981, 981, 981, 981, 981, 981, 981, 981, 982, -982, 982, 982, 982, 982, 982, 982, 982, 982, 982, -982, 982, 982, 982, 982, 982, 982, 982, 982, 982, -982, 982, 982, 982, 982, 982, 982, 982, 982, 982, -983, 983, 983, 983, 983, 983, 983, 983, 983, 983, -983, 983, 983, 983, 983, 983, 983, 983, 983, 983, -983, 983, 983, 983, 983, 983, 983, 983, 983, 983, -983, 983, 983, 984, 984, 984, 984, 984, 984, 984, -984, 984, 984, 984, 984, 984, 984, 984, 984, 984, -984, 984, 984, 984, 984, 984, 984, 984, 984, 984, -984, 984, 984, 984, 984, 985, 985, 985, 985, 985, -985, 985, 985, 985, 985, 985, 985, 985, 985, 985, -985, 985, 985, 985, 985, 985, 985, 985, 985, 985, -985, 985, 985, 985, 985, 985, 985, 985, 985, 986, -986, 986, 986, 986, 986, 986, 986, 986, 986, 986, -986, 986, 986, 986, 986, 986, 986, 986, 986, 986, -986, 986, 986, 986, 986, 986, 986, 986, 986, 986, -986, 986, 986, 987, 987, 987, 987, 987, 987, 987, -987, 987, 987, 987, 987, 987, 987, 987, 987, 987, -987, 987, 987, 987, 987, 987, 987, 987, 987, 987, -987, 987, 987, 987, 987, 987, 987, 987, 988, 988, -988, 988, 988, 988, 988, 988, 988, 988, 988, 988, -988, 988, 988, 988, 988, 988, 988, 988, 988, 988, -988, 988, 988, 988, 988, 988, 988, 988, 988, 988, -988, 988, 988, 989, 989, 989, 989, 989, 989, 989, -989, 989, 989, 989, 989, 989, 989, 989, 989, 989, -989, 989, 989, 989, 989, 989, 989, 989, 989, 989, -989, 989, 989, 989, 989, 989, 989, 989, 989, 990, -990, 990, 990, 990, 990, 990, 990, 990, 990, 990, -990, 990, 990, 990, 990, 990, 990, 990, 990, 990, -990, 990, 990, 990, 990, 990, 990, 990, 990, 990, -990, 990, 990, 990, 990, 990, 991, 991, 991, 991, -991, 991, 991, 991, 991, 991, 991, 991, 991, 991, -991, 991, 991, 991, 991, 991, 991, 991, 991, 991, -991, 991, 991, 991, 991, 991, 991, 991, 991, 991, -991, 991, 991, 991, 992, 992, 992, 992, 992, 992, -992, 992, 992, 992, 992, 992, 992, 992, 992, 992, -992, 992, 992, 992, 992, 992, 992, 992, 992, 992, -992, 992, 992, 992, 992, 992, 992, 992, 992, 992, -992, 992, 992, 993, 993, 993, 993, 993, 993, 993, -993, 993, 993, 993, 993, 993, 993, 993, 993, 993, -993, 993, 993, 993, 993, 993, 993, 993, 993, 993, -993, 993, 993, 993, 993, 993, 993, 993, 993, 993, -993, 993, 994, 994, 994, 994, 994, 994, 994, 994, -994, 994, 994, 994, 994, 994, 994, 994, 994, 994, -994, 994, 994, 994, 994, 994, 994, 994, 994, 994, -994, 994, 994, 994, 994, 994, 994, 994, 994, 994, -994, 994, 995, 995, 995, 995, 995, 995, 995, 995, -995, 995, 995, 995, 995, 995, 995, 995, 995, 995, -995, 995, 995, 995, 995, 995, 995, 995, 995, 995, -995, 995, 995, 995, 995, 995, 995, 995, 995, 995, -995, 995, 995, 995, 996, 996, 996, 996, 996, 996, -996, 996, 996, 996, 996, 996, 996, 996, 996, 996, -996, 996, 996, 996, 996, 996, 996, 996, 996, 996, -996, 996, 996, 996, 996, 996, 996, 996, 996, 996, -996, 996, 996, 996, 996, 996, 997, 997, 997, 997, -997, 997, 997, 997, 997, 997, 997, 997, 997, 997, -997, 997, 997, 997, 997, 997, 997, 997, 997, 997, -997, 997, 997, 997, 997, 997, 997, 997, 997, 997, -997, 997, 997, 997, 997, 997, 997, 997, 997, 998, -998, 998, 998, 998, 998, 998, 998, 998, 998, 998, -998, 998, 998, 998, 998, 998, 998, 998, 998, 998, -998, 998, 998, 998, 998, 998, 998, 998, 998, 998, -998, 998, 998, 998, 998, 998, 998, 998, 998, 998, -998, 998, 998, 999, 999, 999, 999, 999, 999, 999, -999, 999, 999, 999, 999, 999, 999, 999, 999, 999, -999, 999, 999, 999, 999, 999, 999, 999, 999, 999, -999, 999, 999, 999, 999, 999, 999, 999, 999, 999, -999, 999, 999, 999, 999, 999, 999, 999, 1000, 1000, -1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1000, 1000, 1000, 1000, 1001, 1001, 1001, 1001, 1001, 1001, -1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, -1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, -1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, -1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, -1001, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, -1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, -1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, -1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, -1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1003, -1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, -1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, -1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, -1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, -1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1004, -1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, -1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, -1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, -1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, -1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, -1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, -1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, -1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, -1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, -1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, -1005, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, -1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, -1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, -1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, -1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006, -1006, 1006, 1006, 1006, 1006, 1007, 1007, 1007, 1007, 1007, -1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, -1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, -1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, -1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, -1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1008, -1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, -1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, -1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, -1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, -1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, -1008, 1008, 1008, 1008, 1008, 1009, 1009, 1009, 1009, 1009, -1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, -1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, -1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, -1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, -1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, -1009, 1009, 1009, 1010, 1010, 1010, 1010, 1010, 1010, 1010, -1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, -1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, -1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, -1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, -1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, -1010, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, -1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, -1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, -1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, -1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, -1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, -1011, 1011, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, -1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, -1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, -1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, -1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, -1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, -1012, 1012, 1012, 1012, 1012, 1013, 1013, 1013, 1013, 1013, -1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, -1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, -1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, -1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, -1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, -1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1014, 1014, -1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, -1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, -1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, -1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, -1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, -1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, -1014, 1014, 1014, 1014, 1015, 1015, 1015, 1015, 1015, 1015, -1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, -1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, -1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, -1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, -1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, -1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, -1015, 1015, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, -1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, -1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, -1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, -1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, -1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, -1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, -1016, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -1017, 1017, 1017, 1018, 1018, 1018, 1018, 1018, 1018, 1018, -1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, -1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, -1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, -1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, -1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, -1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, 1018, -1018, 1018, 1018, 1018, 1018, 1018, 1019, 1019, 1019, 1019, -1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, -1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, -1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, -1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, -1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, -1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, -1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019, -1019, 1019, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, -1021, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, -1022, 1022, 1022, 1022, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, -1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, -1026, 1026, 1026, 1026, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, -1027, 1027, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, -1028, 1028, 1028, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, -1029, 1029, 1029, 1029, 1029, 1029, 1029, 1029, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, -1030, 1030, 1030, 1030, 1030, 1030, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, -1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1031, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, -1032, 1032, 1032, 1032, 1032, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, -1033, 1033, 1033, 1033, 1033, 1033, 1033, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034, -1034, 1034, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, -1035, 1035, 1035, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, -1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, -1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1039, -1039, 1039, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, 1040, -1040, 1040, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, -1042, 1042, 1042, 1042, 1042, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, -1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, -1044, 1044, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, -1045, 1045, 1045, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -1046, 1046, 1046, 1046, 1046, 1046, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, -1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, -1048, 1048, 1048, 1048, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, 1049, -1049, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, -1050, 1050, 1050, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, 1051, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, -1052}; - diff --git a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp index 6a194d161..5d6b0f39e 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DepthStream.hpp @@ -33,8 +33,6 @@ #include #include "PS1080.h" #include "VideoStream.hpp" -#include "S2D.h" -#include "D2S.h" namespace Freenect2Driver @@ -210,14 +208,22 @@ namespace Freenect2Driver *(static_cast(data)) = EMITTER_DCMOS_DISTANCE_VAL; return ONI_STATUS_OK; case XN_STREAM_PROPERTY_S2D_TABLE: // OniDepthPixel[] - *pDataSize = sizeof(S2D); - //std::copy(S2D, S2D+1, static_cast(data)); - memcpy(data, S2D, *pDataSize); + { + uint16_t *s2d = (uint16_t *)data; + *pDataSize = sizeof(*s2d) * 2048; + memset(data, 0, *pDataSize); + for (int i = 1; i <= 1052; i++) + s2d[i] = 342205.0/(1086.671 - i); + } return ONI_STATUS_OK; case XN_STREAM_PROPERTY_D2S_TABLE: // unsigned short[] - *pDataSize = sizeof(D2S); - //std::copy(D2S, D2S+1, static_cast(data)); - memcpy(data, D2S, *pDataSize); + { + uint16_t *d2s = (uint16_t *)data; + *pDataSize = sizeof(*d2s) * 10001; + memset(data, 0, *pDataSize); + for (int i = 315; i <= 10000; i++) + d2s[i] = 1086.671 - 342205.0/(i + 1); + } return ONI_STATUS_OK; } } diff --git a/drivers/OpenNI2-Freenect2Driver/src/S2D.h b/drivers/OpenNI2-Freenect2Driver/src/S2D.h deleted file mode 100644 index 3c421b99b..000000000 --- a/drivers/OpenNI2-Freenect2Driver/src/S2D.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * This file is part of the OpenKinect Project. http://www.openkinect.org - * - * Copyright (c) 2015 individual OpenKinect contributors. See the CONTRIB file - * for details. - * - * This code is licensed to you under the terms of the Apache License, version - * 2.0, or, at your option, the terms of the GNU General Public License, - * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, - * or the following URLs: - * http://www.apache.org/licenses/LICENSE-2.0 - * http://www.gnu.org/licenses/gpl-2.0.txt - * - * If you redistribute this file in source form, modified or unmodified, you - * may: - * 1) Leave this header intact and distribute it under the same terms, - * accompanying it with the APACHE20 and GPL20 files, or - * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or - * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file - * In all cases you must keep the copyright notice intact and include a copy - * of the CONTRIB file. - * - * Binary distributions must follow the binary distribution requirements of - * either License. - */ - -const uint16_t S2D[] = { -0, 315, 315, 315, 316, 316, 316, 316, 317, 317, -317, 318, 318, 318, 319, 319, 319, 319, 320, 320, -320, 321, 321, 321, 322, 322, 322, 322, 323, 323, -323, 324, 324, 324, 325, 325, 325, 326, 326, 326, -326, 327, 327, 327, 328, 328, 328, 329, 329, 329, -330, 330, 330, 331, 331, 331, 332, 332, 332, 332, -333, 333, 333, 334, 334, 334, 335, 335, 335, 336, -336, 336, 337, 337, 337, 338, 338, 338, 339, 339, -339, 340, 340, 340, 341, 341, 341, 342, 342, 343, -343, 343, 344, 344, 344, 345, 345, 345, 346, 346, -346, 347, 347, 347, 348, 348, 348, 349, 349, 350, -350, 350, 351, 351, 351, 352, 352, 352, 353, 353, -354, 354, 354, 355, 355, 355, 356, 356, 356, 357, -357, 358, 358, 358, 359, 359, 359, 360, 360, 361, -361, 361, 362, 362, 363, 363, 363, 364, 364, 364, -365, 365, 366, 366, 366, 367, 367, 368, 368, 368, -369, 369, 370, 370, 370, 371, 371, 372, 372, 372, -373, 373, 374, 374, 374, 375, 375, 376, 376, 377, -377, 377, 378, 378, 379, 379, 379, 380, 380, 381, -381, 382, 382, 382, 383, 383, 384, 384, 385, 385, -385, 386, 386, 387, 387, 388, 388, 389, 389, 389, -390, 390, 391, 391, 392, 392, 393, 393, 393, 394, -394, 395, 395, 396, 396, 397, 397, 398, 398, 398, -399, 399, 400, 400, 401, 401, 402, 402, 403, 403, -404, 404, 405, 405, 406, 406, 407, 407, 408, 408, -409, 409, 409, 410, 410, 411, 411, 412, 412, 413, -413, 414, 414, 415, 415, 416, 416, 417, 418, 418, -419, 419, 420, 420, 421, 421, 422, 422, 423, 423, -424, 424, 425, 425, 426, 426, 427, 427, 428, 429, -429, 430, 430, 431, 431, 432, 432, 433, 433, 434, -435, 435, 436, 436, 437, 437, 438, 438, 439, 440, -440, 441, 441, 442, 442, 443, 444, 444, 445, 445, -446, 446, 447, 448, 448, 449, 449, 450, 451, 451, -452, 452, 453, 454, 454, 455, 455, 456, 457, 457, -458, 458, 459, 460, 460, 461, 462, 462, 463, 463, -464, 465, 465, 466, 467, 467, 468, 468, 469, 470, -470, 471, 472, 472, 473, 474, 474, 475, 476, 476, -477, 478, 478, 479, 480, 480, 481, 482, 482, 483, -484, 484, 485, 486, 487, 487, 488, 489, 489, 490, -491, 491, 492, 493, 494, 494, 495, 496, 496, 497, -498, 499, 499, 500, 501, 502, 502, 503, 504, 504, -505, 506, 507, 507, 508, 509, 510, 511, 511, 512, -513, 514, 514, 515, 516, 517, 517, 518, 519, 520, -521, 521, 522, 523, 524, 525, 525, 526, 527, 528, -529, 529, 530, 531, 532, 533, 534, 534, 535, 536, -537, 538, 539, 540, 540, 541, 542, 543, 544, 545, -546, 546, 547, 548, 549, 550, 551, 552, 553, 554, -554, 555, 556, 557, 558, 559, 560, 561, 562, 563, -564, 565, 565, 566, 567, 568, 569, 570, 571, 572, -573, 574, 575, 576, 577, 578, 579, 580, 581, 582, -583, 584, 585, 586, 587, 588, 589, 590, 591, 592, -593, 594, 595, 596, 597, 598, 599, 600, 601, 602, -603, 604, 606, 607, 608, 609, 610, 611, 612, 613, -614, 615, 616, 618, 619, 620, 621, 622, 623, 624, -625, 627, 628, 629, 630, 631, 632, 634, 635, 636, -637, 638, 640, 641, 642, 643, 644, 646, 647, 648, -649, 650, 652, 653, 654, 655, 657, 658, 659, 661, -662, 663, 664, 666, 667, 668, 670, 671, 672, 674, -675, 676, 678, 679, 680, 682, 683, 684, 686, 687, -688, 690, 691, 693, 694, 696, 697, 698, 700, 701, -703, 704, 706, 707, 708, 710, 711, 713, 714, 716, -717, 719, 720, 722, 723, 725, 727, 728, 730, 731, -733, 734, 736, 738, 739, 741, 742, 744, 746, 747, -749, 750, 752, 754, 755, 757, 759, 761, 762, 764, -766, 767, 769, 771, 773, 774, 776, 778, 780, 781, -783, 785, 787, 789, 790, 792, 794, 796, 798, 800, -802, 803, 805, 807, 809, 811, 813, 815, 817, 819, -821, 823, 825, 827, 829, 831, 833, 835, 837, 839, -841, 843, 845, 847, 849, 851, 854, 856, 858, 860, -862, 864, 867, 869, 871, 873, 875, 878, 880, 882, -885, 887, 889, 891, 894, 896, 898, 901, 903, 906, -908, 910, 913, 915, 918, 920, 923, 925, 928, 930, -933, 935, 938, 940, 943, 946, 948, 951, 954, 956, -959, 962, 964, 967, 970, 973, 975, 978, 981, 984, -987, 989, 992, 995, 998, 1001, 1004, 1007, 1010, 1013, -1016, 1019, 1022, 1025, 1028, 1031, 1034, 1038, 1041, 1044, -1047, 1050, 1054, 1057, 1060, 1063, 1067, 1070, 1073, 1077, -1080, 1084, 1087, 1090, 1094, 1097, 1101, 1105, 1108, 1112, -1115, 1119, 1123, 1126, 1130, 1134, 1138, 1141, 1145, 1149, -1153, 1157, 1161, 1165, 1169, 1173, 1177, 1181, 1185, 1189, -1193, 1197, 1202, 1206, 1210, 1214, 1219, 1223, 1227, 1232, -1236, 1241, 1245, 1250, 1255, 1259, 1264, 1268, 1273, 1278, -1283, 1288, 1292, 1297, 1302, 1307, 1312, 1317, 1322, 1328, -1333, 1338, 1343, 1349, 1354, 1359, 1365, 1370, 1376, 1381, -1387, 1392, 1398, 1404, 1410, 1415, 1421, 1427, 1433, 1439, -1445, 1452, 1458, 1464, 1470, 1477, 1483, 1489, 1496, 1503, -1509, 1516, 1523, 1529, 1536, 1543, 1550, 1557, 1564, 1572, -1579, 1586, 1594, 1601, 1609, 1616, 1624, 1632, 1639, 1647, -1655, 1663, 1671, 1680, 1688, 1696, 1705, 1713, 1722, 1731, -1739, 1748, 1757, 1766, 1776, 1785, 1794, 1804, 1813, 1823, -1833, 1843, 1853, 1863, 1873, 1883, 1894, 1904, 1915, 1926, -1936, 1947, 1959, 1970, 1981, 1993, 2005, 2016, 2028, 2040, -2053, 2065, 2078, 2090, 2103, 2116, 2129, 2143, 2156, 2170, -2184, 2198, 2212, 2226, 2241, 2256, 2271, 2286, 2301, 2317, -2333, 2349, 2365, 2381, 2398, 2415, 2432, 2450, 2467, 2485, -2503, 2522, 2541, 2560, 2579, 2598, 2618, 2639, 2659, 2680, -2701, 2723, 2744, 2767, 2789, 2812, 2835, 2859, 2883, 2908, -2933, 2958, 2984, 3010, 3037, 3064, 3092, 3120, 3149, 3178, -3208, 3238, 3269, 3300, 3333, 3365, 3399, 3433, 3468, 3503, -3539, 3576, 3614, 3653, 3692, 3732, 3774, 3816, 3859, 3903, -3948, 3994, 4041, 4089, 4139, 4190, 4241, 4295, 4349, 4405, -4463, 4522, 4582, 4645, 4708, 4774, 4842, 4911, 4983, 5056, -5132, 5210, 5291, 5374, 5460, 5548, 5640, 5734, 5832, 5933, -6038, 6146, 6259, 6375, 6497, 6622, 6753, 6889, 7030, 7178, -7332, 7492, 7660, 7835, 8019, 8212, 8413, 8626, 8849, 9084, -9331, 9593, 9870, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0}; - From d67cac82873763b30be5ebb7a92f55ed471aa6f4 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Sat, 2 Jan 2016 17:46:26 +0900 Subject: [PATCH 19/20] openni2: Update README.md --- drivers/OpenNI2-Freenect2Driver/README.md | 65 +++++++---------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/drivers/OpenNI2-Freenect2Driver/README.md b/drivers/OpenNI2-Freenect2Driver/README.md index c5ae5c15e..6556c2526 100644 --- a/drivers/OpenNI2-Freenect2Driver/README.md +++ b/drivers/OpenNI2-Freenect2Driver/README.md @@ -1,59 +1,30 @@ -OpenNI2-FreenectDriver +OpenNI2-Freenect2Driver ====================== -OpenNI2-FreenectDriver is a bridge to libfreenect implemented as an OpenNI2 driver. -It allows OpenNI2 to use Kinect hardware on Linux and OSX. -OpenNI2-FreenectDriver is distributed under the [Apache 2](https://github.com/OpenKinect/libfreenect/blob/master/APACHE20) license. +OpenNI2-Freenect2Driver is a bridge to libfreenect2 implemented as an OpenNI2 driver. +It allows OpenNI2 to use Kinect for Windows v2 (K4W2) devices on Mac OS X. (and on Linux?) +OpenNI2-Freenect2Driver is derived from OpenNI2-FreenectDriver (https://github.com/OpenKinect/libfreenect/tree/master/OpenNI2-FreenectDriver). Install ------- -1. Download and unpack [OpenNI](http://structure.io/openni) 2.2.0.33 or higher. -2. Go to the top libfreenect directory and build it with the OpenNI2 driver. +Please refer libfreenect2 install documentation at first. This description assumes that you are familiar with the libfreenect2 build instruction. - mkdir build - cd build - cmake .. -DBUILD_OPENNI2_DRIVER=ON - make +1. You need [OpenNI](http://structure.io/openni) 2.2.0.33 or higher installed on your system and set the environment variables properly. You can use homebrew to install OpenNI if you use Mac OS X. And you will need to make sure target systems have libusb and all other dependencies also. -3. Copy the driver to your OpenNI2 driver repository. You must first change `Repository` to match your project layout. + $ brew tap homebrew/science + $ brew install openni2 - Repository="/example/path/to/Samples/Bin/OpenNI2/Drivers/" - cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} - - # you could instead make a symlink to avoid copying after every build - # ln -s lib/OpenNI2-FreenectDriver/libFreenectDriver.{so,dylib} ${Repository} + $ export OPENNI2_REDIST=/usr/local/lib/ni2 + $ export OPENNI2_INCLUDE=/usr/local/include/ni2 -OpenNI2-FreenectDriver is built with a static libfreenect, so you do not need to include libfreenect when deploying. -However, you will need to make sure target systems have libusb and all other dependencies listed in `ldd libFreenectDriver.so`. +2. Go to the top libfreenect2 directory and build it. The build option which enables to build this driver is OFF by default. You must specify -DBUILD_OPENNI2_DRIVER=ON in cmake argument. And you may specify additional -DENABLE_OPENGL=NO in cmake argument to use OpenNI2's NiViewer. -__________________________________________________ + $ cd /some/where/libfreenect2 + $ mkdir build + $ cd build + $ cmake -DBUILD_OPENNI2_DRIVER=ON .. + $ make -Structure ---------- -This driver is modeled on TestDevice.cpp and Drivers/Kinect/. -In the FreenectDriver namespace, it ties together the C++ interfaces of OpenNI2 and libfreenect using multiple inheritance. +3. 'make install' copies the driver to your OpenNI2 driver repository (${OPENNI2_REDIST}/OpenNI2/Drivers) -Driver inherits publically from oni::driver::DriverBase and privately from Freenect::Freenect. -libfreenect.hpp allows protected access to the Freenect context, so that FreenectDriver can call the Freenect's C API. -As a DriverBase, FreenectDriver manages devices and sets up device state callbacks. - -Device inherits publically from oni::driver::DeviceBase and Freenect::FreenectDevice. -Because of this, it can be built by Freenect::Freenect::createDevice() and it can define Device's depth and video callbacks. -Those callbacks trigger acquireFrame() in FreenectStream. - -VideoStream is a virtual base class inheriting from oni::driver::StreamBase. -It does generic frame setup in buildFrame() and then calls pure virtual populateFrame() to let derived classes finish the frame. -It also provides the base skeleton for setting and getting properties, which cascades down the inheritance tree. - -DepthStream and ColorStream are nearly identical in definition and implementation, both inheriting from VideoStream. -They differ mostly in the formats they use to process data and the video modes they support. -These two classes offer a system to store and report supported video modes. -To implement a new mode, simply add it to getSupportedVideoModes() and modify populateFrame() as necessary. - -__________________________________________________ - -Todo ----- -* support more FREENECT_RESOLUTION_\*, FREENECT_VIDEO_\*, and FREENECT_DEPTH_\* -* provide more OniVideoMode and OniStreamProperty -* implement remaining derived functions + $ make install From 38696aeeed937b977832b57c382b826196aea541 Mon Sep 17 00:00:00 2001 From: Zou Hanya Date: Mon, 4 Jan 2016 01:15:38 +0900 Subject: [PATCH 20/20] openni2: Add a cross-platform FindOpenNI2.cmake for Linux --- cmake_modules/FindOpenNI2.cmake | 53 +++++++++++++++++++ .../OpenNI2-Freenect2Driver/CMakeLists.txt | 7 ++- .../src/DeviceDriver.cpp | 14 ++--- 3 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 cmake_modules/FindOpenNI2.cmake diff --git a/cmake_modules/FindOpenNI2.cmake b/cmake_modules/FindOpenNI2.cmake new file mode 100644 index 000000000..4fb747779 --- /dev/null +++ b/cmake_modules/FindOpenNI2.cmake @@ -0,0 +1,53 @@ +# - Find OpenNI2 +# +# OpenNI2_FOUND: true if OpenNI2 was found +# OpenNI2_INCLUDE_DIRS: the directory that contains the include file +# OpenNI2_INSTALL_DIR: the directory that contains the librariy file + +IF(PKG_CONFIG_FOUND) + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + SET(MODULE "libopenni2") + IF(OpenNI2_FIND_REQUIRED) + SET(OpenNI2_REQUIRED "REQUIRED") + ENDIF() + PKG_CHECK_MODULES(OpenNI2 ${OpenNI2_REQUIRED} ${MODULE}) + FIND_PATH(OpenNI2_INSTALL_DIR + NAMES ${OpenNI2_LIBRARIES} + HINTS ${OpenNI2_LIBRARY_DIRS} + ) + SET(OpenNI2_INSTALL_DIR ${OpenNI2_LIBRARY}) + + RETURN() + ENDIF() +ENDIF() + +FIND_PATH(OpenNI2_INCLUDE_DIRS + NAMES Driver/OniDriverAPI.h + PATHS + "/opt/include" + "/opt/local/include" + "/usr/include" + "/usr/local/include" + ENV OPENNI2_INCLUDE + PATH_SUFFIXES + "ni2" + "openni2" +) + +FIND_PATH(OpenNI2_INSTALL_DIR + NAMES + libOniFile.so + libOniFile.dylib + PATHS + "/opt/lib" + "/opt/local/lib" + "/usr/lib" + "/usr/local/lib" + ENV OPENNI2_REDIST + PATH_SUFFIXES + ni2/OpenNI2/Drivers + OpenNI2/Drivers/lib +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenNI2 DEFAULT_MSG OpenNI2_INSTALL_DIR OpenNI2_INCLUDE_DIRS) diff --git a/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt b/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt index c11af429f..b53d97ebc 100644 --- a/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt +++ b/drivers/OpenNI2-Freenect2Driver/CMakeLists.txt @@ -17,8 +17,7 @@ SET(MY_DIR ${openni2_freenect2driver_SOURCE_DIR}) SET(freenect2_ROOT_DIR ${MY_DIR}/../..) FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found -SET(OPENNI2_INCLUDE $ENV{OPENNI2_INCLUDE}) -SET(OPENNI2_LINRARY $ENV{OPENNI2_REDIST}) +FIND_PACKAGE(OpenNI2 REQUIRED) IF(TARGET freenect2) MESSAGE(STATUS "Using in-tree freenect2 target") @@ -31,7 +30,7 @@ ENDIF() INCLUDE_DIRECTORIES( ${freenect2_INCLUDE_DIR} - ${OPENNI2_INCLUDE} + ${OpenNI2_INCLUDE_DIRS} ) SET(OpenNI2-Freenect2Driver_src @@ -57,4 +56,4 @@ TARGET_LINK_LIBRARIES(OpenNI2-Freenect2Driver ${OpenNI2-Freenect2Driver_LIBRARIES} ) -INSTALL(TARGETS OpenNI2-Freenect2Driver DESTINATION "${OPENNI2_LINRARY}/OpenNI2/Drivers") +INSTALL(TARGETS OpenNI2-Freenect2Driver DESTINATION "${OpenNI2_INSTALL_DIR}") diff --git a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp index c0266156f..c5b92c071 100644 --- a/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp +++ b/drivers/OpenNI2-Freenect2Driver/src/DeviceDriver.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -118,7 +118,7 @@ namespace Freenect2Driver WriteMessage("setStreamProperty: " + pfx + "size: " + config[pfx + "size"]); std::string size(config[pfx + "size"]); int i = size.find("x"); - OniVideoMode video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, std::stoi(size.substr(0, i)), std::stoi(size.substr(i + 1)), 30); + OniVideoMode video_mode = makeOniVideoMode(ONI_PIXEL_FORMAT_DEPTH_1_MM, atoi(size.substr(0, i).c_str()), atoi(size.substr(i + 1).c_str()), 30); tmp_res = stream->setProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, (void*)&video_mode, sizeof(video_mode)); if (tmp_res != ONI_STATUS_OK) res = tmp_res; @@ -417,11 +417,11 @@ namespace Freenect2Driver for (int i = 0; i < freenect2.enumerateDevices(); i++) { std::string uri = devid_to_uri(i); - std::array modes = { - "", - "?depth-size=640x480", - "?depth-size=512x424", - }; + std::vector modes; + + modes.push_back(""); + modes.push_back("?depth-size=640x480"); + modes.push_back("?depth-size=512x424"); WriteMessage("Found device " + uri);