diff --git a/.gitignore b/.gitignore index 045f4ae5..f22459a7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,16 +7,18 @@ Bin *.pyc *.py~ *.bz2 -source/Documentation/html Redist/Output* Redist/Install/obj* Redist/build.* Redist/Install/Fragments/RedistFragments.wxs Redist/*-src *.bak -Source/Documentation/xml Temp +Build Redist/Final Redist/compile.log Redist/OpenNI-* Source/Documentation/html +Source/Documentation/java +Source/Documentation/xml +OpenNI.xcodeproj diff --git a/Android.mk b/Android.mk index 4e3e26b3..7d04a253 100644 --- a/Android.mk +++ b/Android.mk @@ -14,26 +14,5 @@ # limitations under the License. -# Check if we're building from OS or NDK -ifdef TARGET_BUILD_VARIANT - OPENNI2_ANDROID_OS_BUILD := true -else - OPENNI2_ANDROID_NDK_BUILD := true -endif - -# Setup OpenNI2 local variables -OPENNI2_CFLAGS := -O3 -ftree-vectorize -ffast-math -funroll-loops -fPIC -fvisibility=hidden - -ifeq ($(ARCH_ARM_HAVE_ARMV7A),true) - OPENNI2_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mtune=cortex-a9 -mfpu=vfp -endif - -ifeq ($(ARCH_ARM_HAVE_NEON),true) - OPENNI2_CFLAGS += -mfpu=neon -DHAVE_NEON=1 -flax-vector-conversions -endif - # Recurse through all subdirs include $(call all-subdir-makefiles) - -# Cleanup the local variables -OPENNI2_CFLAGS := diff --git a/CHANGES.txt b/CHANGES.txt index 697e6908..bea3fd56 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,7 +1,94 @@ Change Log: ----------- -OpenNI 2.2.0: +OpenNI 2.3: + - Android support added + - OpenNIHelper class to handle device permissions + - OpenNIView class to allow drawing of VideoFrameRef objects + - SimpleRead and SimpleViewer sample applications + - NiViewer application + - Fix pure-C APIs + - Allow providing driver list from config file + - Auto-recording feature (see OpenNI.ini) + - Bug Fix: depth/world conversion was wrong when depth is in 100 um format + - Adding logs for endpoints bandwidth and FPS + - Better handling of cases where device does not report its FOV + - Remove GLH from samples + - NiViewer: + - IR emitter on/off is added for both PS1080 and Kinect. + - Near mode on/off is added for Kinect (was already there for PS1080) + - IR now also uses an histogram + - draw textures according to aspect ratio + - Cleanup help screen + - Java APIs + - Add log APIs + - Implemented hashCode() and equals() for VideoMode + - Bug Fix: VideoFrameRef.getData() returned ByteBuffer with big endianity, whereas data was with little endianity + - Bug Fix: bad JNI calls in oniGetDeviceList, oniStreamGetSensorInfo and oniDeviceGetSensorInfo. + - Fix callbacks JNI calls + - Bug Fix: memory leak in waitForAnyStream() + - Java SimpleViewer + - Allow passing file name in command prompt + - Add support for IR streams + - Carmine: + - Add support for FW 5.9 + - PS1080Console bug: "startread" did not work properly + - Added support for the fast zoom crop (640x480 regular -> 640x480 zoomed) - 'z' in NiViewer + - Add a property that allows reading from endpoints without creating streams + - Bug Fix: Disconnect event was fired twice + - Implement MAX_PIXEL_VALUE for IR stream + - Bug Fix: Single pixel translation is wrong when image res is 1280x1024 + - Windows: print USB banndwidth to log + - Kinect: + - Add mirror support + - Rewrite image registration for better performance + - Support of additional properties (exposed via KinectProperties.h): + - 3D sensing properties: Near Mode, IR Emitter On/Off + - Non-3D sensing properties: Camera Elevation, Accelerometer, Audio Array ID + - Capri: + - Bug Fix: Depth stops working if switching to QQVGA and then back to VGA + - i2c device list now also states the master and slave IDs + - Fixed a weird log during shutdown + - Add projector commands: projector on/off, pulse on/off + - Add commands for setting CMOS gain + - Add commands for reading temperature sensors + - Add commands for toggling ACC, periodic-BIST and VDD + - Print test name when running BIST + - Default resolution is now QQVGA on ARM machines + - Bug Fix: Setting Mirror from INI file didn't work + - Handle some protocol error codes that weren't handled + - Bug Fix: error strings were missing from log + - Implement MAX_PIXEL_VALUE for IR stream + - Bug Fix: no even frame indexes from Capri devices. + - Properties are now saved in recordings + - PSLinkConsole: allow running a single command and exit + - PresetsAHB property now supports comments in files + - Add ReadDebugData command + - Support 100um mode + - Can turn on firmware log from INI file + - Bug Fix: log stream might lose the first packet + - PSLinkConsole Bug Fix: FormatZone command did not work. + - Capri: don't set USB interface if not doing reset (console mode) + - Bug: Couldn't set video mode to IR stream + - OniFile: + - Allow calling setVideoMode() as long as it's the same mode (needed by some applications) + - Properties are now saved in recordings + - allow playback of recordings that don't have the cropping property (just assume it's disabled) + - Bug Fix: potential crash when playback restarts + - Fix a potential deadlock if calling stop() immediately after a repeat occurred + - potential crash when closing recorder + - Can control playback speed and repeat options from INI file + - Build: + - Support gold linker in compilation + - Add Linux prerequisites to release notes + - Add release notes and change log to installation + - Refactor TestDevice so it can actually be used for testing + - ReleaseVersion script now also creates a full Android package + +OpenNI 2.2.1: + - PS1080: Added a property for reading from all endpoints, regardless of streams + +OpenNI 2.2: - Added getDepthColorSyncEnabled() API - Added log settings API - Add a typedef: OniGrayscale8Pixel @@ -50,7 +137,7 @@ OpenNI 2.2.0: - Support WIX 3.6 and up - ReleaseVersion script won't fail if output file exists (overwrite it) -OpenNI 2.1.0: +OpenNI 2.1: - API change: each event now has its own addListener()/removeListener() methods. A listener object can now be added only once. - Support for Mac OSX - Support for Linux on Arm @@ -80,7 +167,7 @@ OpenNI 2.1.0: - Bug Fix: ReleaseVersion script did not work on 32-bit machines - Linux Bug Fix: log timestamps did not start from 0. -OpenNI 2.0.0: +OpenNI 2: - Brand new API (see documentation) - Algorithms API were removed, and are now part of middleware libraries (such as NiTE) - New deployment model - private copy to each application (see documentation) diff --git a/Config/OpenNI.ini b/Config/OpenNI.ini index 3375b84d..d6fc79d1 100644 --- a/Config/OpenNI.ini +++ b/Config/OpenNI.ini @@ -1,14 +1,17 @@ [Log] ; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None -Verbosity=3 -LogToConsole=0 -LogToFile=0 +;Verbosity=0 +;LogToConsole=1 +;LogToFile=1 +;LogToAndroidLog=1 [Device] -;Override="" +;Override= +;RecordTo= [Drivers] -; Location of the drivers specified by a relative path based on OpenNI's shared library or an absolute path. -; Path separator "/" can be used to be portable for any platforms. -; Default - OpenNI2/Drivers +; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. ;Repository=OpenNI2/Drivers + +; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. +;List= diff --git a/Config/OpenNI2/Drivers/OniFile.ini b/Config/OpenNI2/Drivers/OniFile.ini new file mode 100644 index 00000000..487c3191 --- /dev/null +++ b/Config/OpenNI2/Drivers/OniFile.ini @@ -0,0 +1,7 @@ +;---------------- Player Configuration ------------------- +[Player] +; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 +;Speed=1.0 + +; Repeat. 1 - on (default), 0 - off +;Repeat=1 \ No newline at end of file diff --git a/Config/OpenNI2/Drivers/PSLink.ini b/Config/OpenNI2/Drivers/PSLink.ini index 705a7bfb..577629b7 100644 --- a/Config/OpenNI2/Drivers/PSLink.ini +++ b/Config/OpenNI2/Drivers/PSLink.ini @@ -4,6 +4,9 @@ ; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines) ;UsbInterface=2 +; Enable firmware logs. 0 - Off (default), 1 - On +;FirmwareLog=1 + [Depth] ; Allows dumping all frames to files. 0 - Off (default), 1 - On ;DumpData=1 diff --git a/Include/Android-Arm/OniPlatformAndroid-Arm.h b/Include/Android-Arm/OniPlatformAndroid-Arm.h index 1a3bca12..3d139ab4 100644 --- a/Include/Android-Arm/OniPlatformAndroid-Arm.h +++ b/Include/Android-Arm/OniPlatformAndroid-Arm.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_PLATFORM_ANDROID_ARM_H_ -#define _ONI_PLATFORM_ANDROID_ARM_H_ +#ifndef ONIPLATFORMANDROID_ARM_H +#define ONIPLATFORMANDROID_ARM_H // Start with Linux-x86, and override what's different #include "../Linux-x86/OniPlatformLinux-x86.h" @@ -40,4 +40,4 @@ #define ONI_PLATFORM_STRING "AndroidOS-Arm" #endif -#endif //_ONI_PLATFORM_LINUX_ARM_H_ +#endif // ONIPLATFORMANDROID_ARM_H diff --git a/Include/Driver/OniDriverAPI.h b/Include/Driver/OniDriverAPI.h index c41e1f66..bba018a5 100644 --- a/Include/Driver/OniDriverAPI.h +++ b/Include/Driver/OniDriverAPI.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_DRIVER_API_H_ -#define _ONI_DRIVER_API_H_ +#ifndef ONIDRIVERAPI_H +#define ONIDRIVERAPI_H #include "OniPlatform.h" #include "OniCTypes.h" @@ -375,4 +375,4 @@ ONI_C_API_EXPORT void oniDriverDisableFrameSync(void* frameSyncGroup) return g_pDriver->disableFrameSync(frameSyncGroup); \ } \ -#endif // _ONI_DRIVER_API_H_ +#endif // ONIDRIVERAPI_H diff --git a/Include/Driver/OniDriverTypes.h b/Include/Driver/OniDriverTypes.h index fe8cd44c..e8a9402b 100644 --- a/Include/Driver/OniDriverTypes.h +++ b/Include/Driver/OniDriverTypes.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_DRIVER_TYPES_H_ -#define _ONI_DRIVER_TYPES_H_ +#ifndef ONIDRIVERTYPES_H +#define ONIDRIVERTYPES_H #include #include @@ -51,4 +51,4 @@ struct OniStreamServices }; -#endif // _ONI_DRIVER_TYPES_H_ +#endif // ONIDRIVERTYPES_H diff --git a/Include/KinectProperties.h b/Include/KinectProperties.h new file mode 100644 index 00000000..0999cb9b --- /dev/null +++ b/Include/KinectProperties.h @@ -0,0 +1,104 @@ +/***************************************************************************** +* * +* 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 KINECTPROPERTIES_H +#define KINECTPROPERTIES_H + +#include + +/* + * private properties of Microsoft Kinect devices. + * + * @remarks + * properties structure is 0x045eXXYY (045e = Microsoft's USB vendor ID) + * where XX is range and YY is code. + * range values: + * 00 - common stream properties + * 10 - depth stream properties + * 20 - color stream properties + * E0 - device commands + * F0 - device properties + */ +enum +{ + KINECT_PROPERTY_BASE = 0x045e0000, + + /*******************************************************************/ + /* Common stream properties (00-) */ + /*******************************************************************/ + + /*******************************************************************/ + /* Depth stream properties (10-) */ + /*******************************************************************/ + + /** OniBool, set and get. + * Maps to Near Mode in Kinect SDK. + * Also maps to XN_STREAM_PROPERTY_CLOSE_RANGE in PS1080.h. + */ + KINECT_DEPTH_PROPERTY_CLOSE_RANGE = KINECT_PROPERTY_BASE + 0x1001, + + /*******************************************************************/ + /* Color stream properties (20-) */ + /*******************************************************************/ + + /*******************************************************************/ + /* Device commands (E0-) */ + /*******************************************************************/ + + /*******************************************************************/ + /* Device properties (F0-) */ + /*******************************************************************/ + + /* 3D sensing properties (F0-) */ + + /** OniBool, set and get. + * Maps to !NuiGetForceInfraredEmitterOff in Kinect SDK. + * Also maps to XN_MODULE_PROPERTY_EMITTER_STATE. + */ + KINECT_DEVICE_PROPERTY_EMITTER_STATE = KINECT_PROPERTY_BASE + 0xF001, + + /* Non- 3D sensing bonus properties (F8) */ + + /** long, set and get. + * Maps to NuiCameraElevationGetAngle and NuiCameraElevationSetAngle in Kinect SDK. + */ + KINECT_DEVICE_PROPERTY_CAMERA_ELEVATION = KINECT_PROPERTY_BASE + 0xF801, + + /** KinectVector3f, get only. + * Maps to NuiAccelerometerGetCurrentReading. + */ + KINECT_DEVICE_PROPERTY_ACCELEROMETER = KINECT_PROPERTY_BASE + 0xF802, + + /** String, get only. + * Maps to NuiAudioArrayId. + * Useful to find the mic array on the sensor when developing audio-enabled applications. + */ + KINECT_DEVICE_PROPERTY_AUDIO_ARRAY_ID = KINECT_PROPERTY_BASE + 0xF803, + +}; + +typedef struct +{ + float x; + float y; + float z; +} KinectVector3f; + +#endif // KINECTPROPERTIES_H diff --git a/Include/Linux-Arm/OniPlatformLinux-Arm.h b/Include/Linux-Arm/OniPlatformLinux-Arm.h index fb96323b..be1f4da1 100644 --- a/Include/Linux-Arm/OniPlatformLinux-Arm.h +++ b/Include/Linux-Arm/OniPlatformLinux-Arm.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_PLATFORM_LINUX_ARM_H_ -#define _ONI_PLATFORM_LINUX_ARM_H_ +#ifndef ONIPLATFORMLINUX_ARM_H +#define ONIPLATFORMLINUX_ARM_H // Start with Linux-x86, and override what's different #include "../Linux-x86/OniPlatformLinux-x86.h" @@ -32,5 +32,5 @@ #define ONI_PLATFORM ONI_PLATFORM_LINUX_ARM #define ONI_PLATFORM_STRING "Linux-Arm" -#endif //_ONI_PLATFORM_LINUX_ARM_H_ +#endif // ONIPLATFORMLINUX_ARM_H diff --git a/Include/Linux-x86/OniPlatformLinux-x86.h b/Include/Linux-x86/OniPlatformLinux-x86.h index e5980f35..0e75f1c0 100644 --- a/Include/Linux-x86/OniPlatformLinux-x86.h +++ b/Include/Linux-x86/OniPlatformLinux-x86.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_PLATFORM_LINUX_X86_H_ -#define _ONI_PLATFORM_LINUX_X86_H_ +#ifndef ONIPLATFORMLINUX_X86_H +#define ONIPLATFORMLINUX_X86_H //--------------------------------------------------------------------------- // Prerequisites @@ -98,5 +98,5 @@ /** Indicates a deprecated function */ #define ONI_API_DEPRECATED(msg) __attribute__((warning("This function is deprecated: " msg))) -#endif //_ONI_PLATFORM_LINUX_X86_H_ +#endif // ONIPLATFORMLINUX_X86_H diff --git a/Include/MacOSX/OniPlatformMacOSX.h b/Include/MacOSX/OniPlatformMacOSX.h index 251256eb..4de813ae 100644 --- a/Include/MacOSX/OniPlatformMacOSX.h +++ b/Include/MacOSX/OniPlatformMacOSX.h @@ -1,9 +1,9 @@ /***************************************************************************** * * -* PrimeSense PSCommon Library * +* OpenNI 2.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * -* This file is part of PSCommon. * +* 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. * @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_PLATFORM_MACOSX_H_ -#define _ONI_PLATFORM_MACOSX_H_ +#ifndef ONIPLATFORMMACOSX_H +#define ONIPLATFORMMACOSX_H // Start with Linux-x86, and override what's different #include "../Linux-x86/OniPlatformLinux-x86.h" @@ -31,6 +31,21 @@ #define ONI_PLATFORM ONI_PLATFORM_MACOSX #define ONI_PLATFORM_STRING "MacOSX" +#include "TargetConditionals.h" +#if (TARGET_IPHONE_SIMULATOR == 1) || (TARGET_OS_IPHONE == 1) + #define ONI_PLATFORM_IOS + + #undef ONI_PLATFORM_STRING + #define ONI_PLATFORM_STRING "iOS" +#elif TARGET_OS_MAC + #ifdef XN_XCODE_BUILD + #define ONI_PLATFORM_MACOSX_XCODE + + #undef ONI_PLATFORM_STRING + #define ONI_PLATFORM_STRING "MacOSX-Xcode" + #endif +#endif + #define ONI_PLATFORM_HAS_NO_TIMED_OPS #define ONI_PLATFORM_HAS_NO_CLOCK_GETTIME #define ONI_PLATFORM_HAS_NO_SCHED_PARAM @@ -39,4 +54,4 @@ #undef ONI_THREAD_STATIC #define ONI_THREAD_STATIC -#endif //_ONI_PLATFORM_MACOSX_H_ +#endif // ONIPLATFORMMACOSX_H diff --git a/Include/OniCAPI.h b/Include/OniCAPI.h index aea426d4..7fad7601 100644 --- a/Include/OniCAPI.h +++ b/Include/OniCAPI.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_C_API_H_ -#define _ONI_C_API_H_ +#ifndef ONICAPI_H +#define ONICAPI_H #include "OniPlatform.h" #include "OniCTypes.h" @@ -256,4 +256,4 @@ ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput); */ ONI_C_API OniStatus oniSetLogAndroidOutput(OniBool bAndroidOutput); #endif -#endif // _ONI_C_API_H_ +#endif // ONICAPI_H diff --git a/Include/OniCEnums.h b/Include/OniCEnums.h index d7f513b8..c11fa52e 100644 --- a/Include/OniCEnums.h +++ b/Include/OniCEnums.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_C_ENUMS_H_ -#define _ONI_C_ENUMS_H_ +#ifndef ONICENUMS_H +#define ONICENUMS_H /** Possible failure values */ typedef enum @@ -81,4 +81,4 @@ enum ONI_TIMEOUT_FOREVER = -1, }; -#endif // _ONI_C_ENUMS_H_ +#endif // ONICENUMS_H diff --git a/Include/OniCProperties.h b/Include/OniCProperties.h index da13d58e..b321a18c 100644 --- a/Include/OniCProperties.h +++ b/Include/OniCProperties.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_C_PROPERTIES_H_ -#define _ONI_C_PROPERTIES_H_ +#ifndef ONICPROPERTIES_H +#define ONICPROPERTIES_H // Device properties enum @@ -65,4 +65,4 @@ enum ONI_DEVICE_COMMAND_SEEK = 1, // OniSeek }; -#endif // _ONI_C_PROPERTIES_H_ +#endif // ONICPROPERTIES_H diff --git a/Include/OniCTypes.h b/Include/OniCTypes.h index 12246949..83a952e2 100644 --- a/Include/OniCTypes.h +++ b/Include/OniCTypes.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_TYPES_H_ -#define _ONI_TYPES_H_ +#ifndef ONICTYPES_H +#define ONICTYPES_H #include "OniPlatform.h" #include "OniCEnums.h" @@ -83,13 +83,13 @@ typedef struct } OniDeviceInfo; struct _OniDevice; -typedef _OniDevice* OniDeviceHandle; +typedef struct _OniDevice* OniDeviceHandle; struct _OniStream; -typedef _OniStream* OniStreamHandle; +typedef struct _OniStream* OniStreamHandle; struct _OniRecorder; -typedef _OniRecorder* OniRecorderHandle; +typedef struct _OniRecorder* OniRecorderHandle; /** All information of the current frame */ typedef struct @@ -141,6 +141,7 @@ typedef struct Pixel type used to store depth images. */ typedef uint16_t OniDepthPixel; +typedef uint16_t OniIRPixel; /** Pixel type used to store 16-bit grayscale images @@ -182,6 +183,23 @@ typedef struct uint8_t y2; } OniYUV422DoublePixel; +/** + 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 +{ + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of second pixel. */ + uint8_t y2; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; +} OniYUYVDoublePixel; + #pragma pack (pop) typedef struct @@ -190,4 +208,4 @@ typedef struct OniStreamHandle stream; } OniSeek; -#endif // _ONI_TYPES_H_ +#endif // ONICTYPES_H diff --git a/Include/OniEnums.h b/Include/OniEnums.h index 018f2227..d6cb45bb 100644 --- a/Include/OniEnums.h +++ b/Include/OniEnums.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_ENUMS_H_ -#define _ONI_ENUMS_H_ +#ifndef ONIENUMS_H +#define ONIENUMS_H namespace openni { @@ -83,4 +83,4 @@ static const int TIMEOUT_FOREVER = -1; } // namespace openni -#endif // _ONI_ENUMS_H_ +#endif // ONIENUMS_H diff --git a/Include/OniPlatform.h b/Include/OniPlatform.h index 602b4ba5..23841889 100644 --- a/Include/OniPlatform.h +++ b/Include/OniPlatform.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_PLATFORM_H_ -#define _ONI_PLATFORM_H_ +#ifndef ONIPLATFORM_H +#define ONIPLATFORM_H // Supported platforms #define ONI_PLATFORM_WIN32 1 @@ -69,4 +69,4 @@ #endif // OPENNI2_EXPORT -#endif // _ONI_PLATFORM_H_ +#endif // ONIPLATFORM_H diff --git a/Include/OniProperties.h b/Include/OniProperties.h index 19b0805a..07439337 100644 --- a/Include/OniProperties.h +++ b/Include/OniProperties.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_PROPERTIES_H_ -#define _ONI_PROPERTIES_H_ +#ifndef ONIPROPERTIES_H +#define ONIPROPERTIES_H namespace openni { @@ -70,4 +70,4 @@ enum }; } // namespace openni -#endif // _ONI_PROPERTIES_H_ +#endif // ONIPROPERTIES_H diff --git a/Source/Drivers/PS1080/Formats/XnNiCodec.h b/Include/OniTest.h similarity index 55% rename from Source/Drivers/PS1080/Formats/XnNiCodec.h rename to Include/OniTest.h index 68e65108..93ef767e 100644 --- a/Source/Drivers/PS1080/Formats/XnNiCodec.h +++ b/Include/OniTest.h @@ -18,38 +18,23 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_XN_CODEC_H__ -#define __XN_XN_CODEC_H__ +#ifndef ONITEST_H +#define ONITEST_H -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnCodec.h" +#define TEST_DEVICE_NAME "Test" // use with device.open() to create a test device -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -//class XN_FORMATS_CPP_API XnNiCodec : public XnCodec -//{ -//public: -// XnNiCodec(xn::Codec& codec) : m_codec(codec) {} -// virtual ~XnNiCodec() {} -// -// virtual XnCompressionFormats GetCompressionFormat() const { return XnCodec::GetCompressionFormatFromCodecID(m_codec.GetCodecID()); } -// -// virtual XnStatus Compress(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) -// { -// return m_codec.EncodeData(pData, nDataSize, pCompressedData, *pnCompressedDataSize, pnCompressedDataSize); -// } -// -// virtual XnStatus Decompress(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) -// { -// return m_codec.DecodeData(pCompressedData, nCompressedDataSize, pData, *pnDataSize, pnDataSize); -// } -// -//private: -// xn::Codec m_codec; -//}; -// +/** +* Additional commands for Test device streams +*/ +enum +{ + TEST_COMMAND_ISSUE_FRAME = 0xFFFF0001, // TestCommandIssueFrame +}; -#endif // __XN_XN_CODEC_H__ \ No newline at end of file +typedef struct TestCommandIssueFrame +{ + uint64_t timestamp; + void* data; +} TestCommandIssueFrame; + +#endif // ONITEST_H diff --git a/Include/OniVersion.h b/Include/OniVersion.h index 7aa13ed5..1783fb0a 100644 --- a/Include/OniVersion.h +++ b/Include/OniVersion.h @@ -18,12 +18,15 @@ * limitations under the License. * * * *****************************************************************************/ +#ifndef ONIVERSION_H +#define ONIVERSION_H + #include "OniPlatform.h" #define ONI_VERSION_MAJOR 2 -#define ONI_VERSION_MINOR 2 +#define ONI_VERSION_MINOR 3 #define ONI_VERSION_MAINTENANCE 0 -#define ONI_VERSION_BUILD 33 +#define ONI_VERSION_BUILD 15 /** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */ #define ONI_BRIEF_VERSION_STRING \ @@ -41,3 +44,5 @@ #define ONI_VERSION_STRING \ ONI_BRIEF_VERSION_STRING "-" \ ONI_PLATFORM_STRING " (" ONI_TIMESTAMP ")" + +#endif // ONIVERSION_H diff --git a/Include/OpenNI.h b/Include/OpenNI.h index 52324b4e..ffcd51d7 100644 --- a/Include/OpenNI.h +++ b/Include/OpenNI.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _OPENNI_H_ -#define _OPENNI_H_ +#ifndef OPENNI_H +#define OPENNI_H #include "OniPlatform.h" #include "OniProperties.h" @@ -82,15 +82,32 @@ typedef struct uint8_t y2; } YUV422DoublePixel; +/** + 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 +{ + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of second pixel. */ + uint8_t y2; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; +} YUYVDoublePixel; + /** 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 +class _NullString +{ +public: + _NullString() {} + operator const char*() const { return NULL; } +}; + +static const _NullString ANY_DEVICE; /** Provides a simple array class used throughout the API. Wraps a primitive array @@ -1707,7 +1724,7 @@ class PlaybackControl return speed; } /** - * Setter function for the playback speed of the device. For a full explaination of + * Setter function for the playback speed of the device. For a full explanation of * what this value means @see PlaybackControl::getSpeed(). * * @param [in] speed Desired new value of playback speed, as ratio of original recording. @@ -2295,7 +2312,6 @@ class OpenNI /** * 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. @@ -2744,7 +2760,6 @@ void Device::close() } } - } -#endif // _OPEN_NI_HPP_ +#endif // OPENNI_H diff --git a/Include/PS1080.h b/Include/PS1080.h index 561f7664..17c145e4 100644 --- a/Include/PS1080.h +++ b/Include/PS1080.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _PS1080_H_ -#define _PS1080_H_ +#ifndef PS1080_H +#define PS1080_H #include @@ -127,6 +127,9 @@ enum XN_MODULE_PROPERTY_APC_ENABLED = 0x1080FF91, // "APCEnabled" /** Boolean */ XN_MODULE_PROPERTY_FIRMWARE_TEC_DEBUG_PRINT = 0x1080FF92, // "TecDebugPrint" + /** Boolean, set only */ + XN_MODULE_PROPERTY_READ_ALL_ENDPOINTS = 0x1080FF93, + /*******************************************************************/ /* Common stream properties */ @@ -143,6 +146,8 @@ enum /** unsigned long long */ XN_STREAM_PROPERTY_CLOSE_RANGE = 0x1080F003, // "CloseRange" + /** unsigned long long */ + XN_STREAM_PROPERTY_FAST_ZOOM_CROP = 0x1080F009, // "FastZoomCrop" /** XnPixelRegistration - get only */ XN_STREAM_PROPERTY_PIXEL_REGISTRATION = 0x10801001, // "PixelRegistration" /** unsigned long long */ @@ -212,6 +217,7 @@ typedef enum XN_SENSOR_FW_VER_5_6 = 12, XN_SENSOR_FW_VER_5_7 = 13, XN_SENSOR_FW_VER_5_8 = 14, + XN_SENSOR_FW_VER_5_9 = 15, } XnFWVer; typedef enum { @@ -629,4 +635,4 @@ typedef struct XnBist #pragma pack (pop) -#endif //_PS1080_H_ \ No newline at end of file +#endif // PS1080_H diff --git a/Include/PSLink.h b/Include/PSLink.h index dd4d8992..3949329b 100644 --- a/Include/PSLink.h +++ b/Include/PSLink.h @@ -1,5 +1,25 @@ -#ifndef __XN_PRIME_CLIENT_PROPS_H__ -#define __XN_PRIME_CLIENT_PROPS_H__ +/***************************************************************************** +* * +* 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 PSLINK_H +#define PSLINK_H #include @@ -14,11 +34,20 @@ enum /* 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" + LINK_PROP_PROJECTOR_ACTIVE = 0x12000008, // "ProjectorActive" /* String. Set only */ LINK_PROP_PRESET_FILE = 0x1200000a, // "PresetFile" /* Get only */ LINK_PROP_BOOT_STATUS = 0x1200000b, + /* Int - system specific units */ + LINK_PROP_PROJECTOR_POWER = 0x1200000c, + /* SetAccActive*/ + LINK_PROP_ACC_ENABLED = 0x1200000d, + /* SetAccActive*/ + LINK_PROP_VDD_ENABLED = 0x1200000e, + /* SetAccActive*/ + LINK_PROP_PERIODIC_BIST_ENABLED = 0x1200000f, + /**** Device commands ****/ /* XnCommandGetFwStreams */ @@ -37,6 +66,10 @@ enum LINK_COMMAND_SET_FW_STREAM_VIDEO_MODE = 0x1200F007, /* XnCommandGetFwStreamVideoMode */ LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE = 0x1200F008, + /* XnCommandSetProjectorPulse */ + LINK_COMMAND_SET_PROJECTOR_PULSE = 0x1200F009, + /* No args */ + LINK_COMMAND_DISABLE_PROJECTOR_PULSE = 0x1200F00a, /**** Stream properties ****/ /* Int. 1 - Shifts 9.3, 2 - Grayscale16, 3 - YUV422, 4 - Bayer8 */ @@ -194,6 +227,13 @@ typedef struct XnCommandGetFwStreamVideoMode XnFwStreamVideoMode videoMode; // out } XnCommandGetFwStreamVideoMode; +typedef struct XnCommandSetProjectorPulse +{ + float delay; //start delay - delay time before start pulse + float width; //DC - duty cycle - the percentage of the pulse out of total cycle + float cycle; +} XnCommandSetProjectorPulse; + #pragma pack (pop) -#endif //__XN_PRIME_CLIENT_PROPS_H__ +#endif // PSLINK_H diff --git a/Include/PrimeSense.h b/Include/PrimeSense.h index 1517bddb..172b73d6 100644 --- a/Include/PrimeSense.h +++ b/Include/PrimeSense.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _PRIME_SENSE_H_ -#define _PRIME_SENSE_H_ +#ifndef PRIMESENSE_H +#define PRIMESENSE_H #include @@ -38,9 +38,10 @@ enum { // Stream Properties PS_PROPERTY_DUMP_DATA = 0x1d270001, // boolean + PS_PROPERTY_GAIN = 0x1d270002, // int - system specific // Device Properties - PS_PROPERTY_USB_INTERFACE = 0x1d27F001, // values from XnUsbInterfaceType + PS_PROPERTY_USB_INTERFACE = 0x1d27F001, // values from XnUsbInterfaceType }; /** @@ -74,7 +75,10 @@ enum 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 + PS_COMMAND_STOP_LOG = 0x1d27E015, // no arguments + PS_COMMAND_READ_TEMPERATURE = 0x1d27E016, // no arguments + PS_COMMAND_GET_TEMP_LIST = 0x1d27E017,// PrintTempList + PS_COMMAND_READ_DEBUG_DATA = 0x1d27E018, //ReadDebugDaata }; typedef enum XnUsbInterfaceType @@ -113,7 +117,9 @@ typedef struct XnFwFileEntry typedef struct XnI2CDeviceInfo { - uint32_t id; + uint8_t masterId; + uint8_t slaveId; + uint32_t id; char name[32]; } XnI2CDeviceInfo; @@ -123,6 +129,12 @@ typedef struct XnBistInfo char name[32]; } XnBistInfo; +typedef struct XnTempInfo +{ + uint32_t id; + char name[16]; +} XnTempInfo; + typedef struct XnFwLogMask { uint32_t id; @@ -197,6 +209,12 @@ typedef struct XnCommandGetBistList XnBistInfo* tests; } XnCommandGetBistList; +typedef struct XnCommandGetTempList +{ + uint32_t count; // in: number of allocated elements in tests array. out: number of written elements in the array + XnTempInfo* pTempInfos; +} XnCommandGetTempList; + typedef struct XnCommandExecuteBist { uint32_t id; @@ -205,6 +223,12 @@ typedef struct XnCommandExecuteBist uint8_t* extraData; } XnCommandExecuteBist; +typedef struct XnCommandTemperatureResponse +{ + uint32_t id; + float temperature; +} XnCommandTemperatureResponse; + typedef struct XnCommandUsbTest { uint32_t seconds; @@ -224,6 +248,13 @@ typedef struct XnCommandSetLogMaskState bool enabled; } XnCommandSetLogMaskState; +typedef struct XnCommandDebugData +{ + uint16_t dataID; // Values come from XnLinkInternalPropID + uint16_t dataSize; // in: size of allocated buffer in data, out: actual bytes written to data + uint8_t* data; +} XnCommandDebugData; + #pragma pack (pop) -#endif //_PRIME_SENSE_H_ \ No newline at end of file +#endif // PRIMESENSE_H diff --git a/Include/Win32/OniPlatformWin32.h b/Include/Win32/OniPlatformWin32.h index 23bd81db..dfb89536 100644 --- a/Include/Win32/OniPlatformWin32.h +++ b/Include/Win32/OniPlatformWin32.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_PLATFORM_WIN32_H_ -#define _ONI_PLATFORM_WIN32_H_ +#ifndef ONIPLATFORMWIN32_H +#define ONIPLATFORMWIN32_H //--------------------------------------------------------------------------- // Prerequisites @@ -136,4 +136,4 @@ typedef unsigned __int64 uint64_t; #define ONI_API_DEPRECATED(msg) __declspec(deprecated(msg)) #endif -#endif //_ONI_PLATFORM_WIN32_H_ +#endif // ONIPLATFORMWIN32_H diff --git a/Makefile b/Makefile index a436a84f..e42a1c18 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,22 @@ -############################################################################# -# OpenNI makefile. +# OpenNI 2 Makefile # -# default configuration is Release. for a debug version use: +# Default configuration is Release. for a debug version use: # make CFG=Debug # -# default compiler is g++. for another one use: +# Default compiler is g++. for another one use: # make CXX= # -# By default, CLR projects will only be build if mono is installed. -# To force CLR projects use: -# make FORCE_BUILD_CLR=1 -# -############################################################################# +# Java-dependent build rules are disabled by default. To enable them, use: +# make HAS_JAVA=1 + +#------------------------------------------------------------------------------- include ThirdParty/PSCommon/BuildSystem/CommonDefs.mak +#------------------------------------------------------------------------------- + +# HAS_JAVA=0 # Uncomment this to force the value. + MAJOR_VERSION = $(shell grep "define ONI_VERSION_MAJOR" Include/OniVersion.h | cut -f 2) MINOR_VERSION = $(shell grep "define ONI_VERSION_MINOR" Include/OniVersion.h | cut -f 2) MAINT_VERSION = $(shell grep "define ONI_VERSION_MAINT" Include/OniVersion.h | cut -f 2) @@ -24,81 +26,95 @@ ifeq ("$(OSTYPE)","Darwin") else OS_NAME = Linux endif -PRODUCT_STRING = OpenNI-$(OS_NAME)-$(PLATFORM)-$(shell cd Packaging && python -c "import UpdateVersion; print UpdateVersion.getVersionName()" && cd ..) + +PRODUCT_STRING = OpenNI-$(OS_NAME)-$(PLATFORM)-$(shell cd Packaging && python2 -c "import UpdateVersion; print UpdateVersion.getVersionName()" && cd ..) + FINAL_DIR = Packaging/Final -OPENNI = Source/Core -XNLIB = ThirdParty/PSCommon/XnLib/Source +CORE = Source/Core +XNLIB = ThirdParty/PSCommon/XnLib/Source DEPTH_UTILS = Source/DepthUtils -# list all drivers -ALL_DRIVERS = \ +#------------------------------------------------------------------------------- +# C++ + +CXX_MAIN_SUBDIRS = \ + $(CORE) \ + ThirdParty/PSCommon/XnLib/Source \ + Source/DepthUtils \ Source/Drivers/DummyDevice \ Source/Drivers/PS1080 \ Source/Drivers/PSLink \ - Source/Drivers/OniFile - -# list all wrappers -ALL_WRAPPERS = \ - Wrappers/java/OpenNI.jni \ - Wrappers/java/OpenNI.java - -# list all tools -ALL_TOOLS = \ + Source/Drivers/OniFile \ Source/Drivers/PS1080/PS1080Console \ Source/Drivers/PSLink/PSLinkConsole - -# list all core projects -ALL_CORE_PROJS = \ - $(XNLIB) \ - $(OPENNI) \ - $(DEPTH_UTILS) \ - $(ALL_DRIVERS) \ - $(ALL_WRAPPERS) \ - $(ALL_TOOLS) - -# list all samples -CORE_SAMPLES = \ + +CXX_SAMPLES_SUBDIRS = \ Samples/SimpleRead \ Samples/EventBasedRead \ Samples/MultipleStreamRead \ Samples/MWClosestPoint \ Samples/MWClosestPointApp -# list all java samples -JAVA_SAMPLES = \ +#------------------------------------------------------------------------------- +# Java + +JAVA_MAIN_SUBDIRS = \ + Wrappers/java \ + Wrappers/java/jni + +JAVA_SAMPLES_SUBDIRS = \ Samples/SimpleViewer.java +#------------------------------------------------------------------------------- +# GLUT + ifeq "$(GLUT_SUPPORTED)" "1" - ALL_TOOLS += \ + CXX_MAIN_SUBDIRS += \ Source/Tools/NiViewer - CORE_SAMPLES += \ + CXX_SAMPLES_SUBDIRS += \ Samples/SimpleViewer \ Samples/MultiDepthViewer \ Samples/ClosestPointViewer -else - ifeq "$(GLES_SUPPORTED)" "1" - CORE_SAMPLES += - endif endif -ALL_SAMPLES = \ - $(CORE_SAMPLES) \ - $(JAVA_SAMPLES) +#------------------------------------------------------------------------------- +# Target groups + +ALL_CXX_SUBDIRS = \ + $(CXX_MAIN_SUBDIRS) \ + $(CXX_SAMPLES_SUBDIRS) \ + +ALL_JAVA_SUBDIRS = \ + $(JAVA_MAIN_SUBDIRS) \ + $(JAVA_SAMPLES_SUBDIRS) + +ALL_MAIN_SUBDIRS = \ + $(CXX_MAIN_SUBDIRS) \ + $(JAVA_MAIN_SUBDIRS) + +ALL_SAMPLES_SUBDIRS = \ + $(CXX_SAMPLES_SUBDIRS) \ + $(JAVA_SAMPLES_SUBDIRS) -# list all projects that are build -ALL_BUILD_PROJS = \ - $(ALL_CORE_PROJS) \ - $(ALL_SAMPLES) +ALL_SUBDIRS = \ + $(ALL_MAIN_SUBDIRS) \ + $(ALL_SAMPLES_SUBDIRS) -ALL_PROJS = \ - $(ALL_BUILD_PROJS) +# Add an unconditional shorthand for java targets +java: $(ALL_JAVA_SUBDIRS) -ALL_PROJS_CLEAN = $(foreach proj,$(ALL_PROJS),$(proj)-clean) +.PHONY: java -# define a function which creates a target for each proj -define CREATE_PROJ_TARGET +#------------------------------------------------------------------------------- +# Recursive make machinery + +# Compute the list of cleaning targets. +CLEAN_SUBDIRS = $(foreach target,$(ALL_SUBDIRS),$(target)-clean) + +# Define a function for creating per-subdirectory target rules. +define CREATE_SUBDIR $1: $$(MAKE) -C $1 @@ -106,55 +122,89 @@ $1-clean: $$(MAKE) -C $1 clean endef -################ TARGETS ################## +# Create all per-subdirectory targets. +$(foreach target,$(ALL_SUBDIRS),$(eval $(call CREATE_SUBDIR,$(target)))) -.PHONY: all $(ALL_PROJS) $(ALL_PROJS_CLEAN) install uninstall clean release +# Declare all per-subdirectory rules as phony, so that they're always built. +# See: http://www.gnu.org/software/make/manual/make.html#Recursion +.PHONY: \ + $(ALL_SUBDIRS) \ + $(CLEAN_SUBDIRS) -# make all makefiles -all: $(ALL_PROJS) +# Set 'all' as the default target, since it is not the first target defined in this Makefile. +.DEFAULT_GOAL = all -core: $(ALL_CORE_PROJS) +#------------------------------------------------------------------------------- +# Additional rules -samples: $(ALL_SAMPLES) +$(FINAL_DIR): + mkdir -p $(FINAL_DIR) -# create projects targets -$(foreach proj,$(ALL_PROJS),$(eval $(call CREATE_PROJ_TARGET,$(proj)))) +#------------------------------------------------------------------------------- +# Target dependencies -# additional dependencies -$(OPENNI): $(XNLIB) -Wrappers/java/OpenNI.jni: $(OPENNI) $(XNLIB) +$(CORE): $(XNLIB) -Source/Drivers/DummyDevice: $(OPENNI) $(XNLIB) -Source/Drivers/RawDevice: $(OPENNI) $(XNLIB) -Source/Drivers/PS1080: $(OPENNI) $(XNLIB) $(DEPTH_UTILS) -Source/Drivers/PS1080/PS1080Console: $(OPENNI) $(XNLIB) -Source/Drivers/PSLink: $(OPENNI) $(XNLIB) -Source/Drivers/PSLink/PSLinkConsole: $(OPENNI) $(XNLIB) -Source/Drivers/OniFile: $(OPENNI) $(XNLIB) +Wrappers/java: Wrappers/java/jni +Wrappers/java/jni: $(CORE) -Source/Tools/NiViewer: $(OPENNI) $(XNLIB) +Source/Drivers/DummyDevice: $(CORE) +Source/Drivers/RawDevice: $(CORE) +Source/Drivers/PS1080: $(CORE) $(DEPTH_UTILS) +Source/Drivers/PS1080/PS1080Console: $(CORE) +Source/Drivers/PSLink: $(CORE) +Source/Drivers/PSLink/PSLinkConsole: $(CORE) +Source/Drivers/OniFile: $(CORE) -Samples/SimpleRead: $(OPENNI) -Samples/EventBasedRead: $(OPENNI) -Samples/MultipleStreamRead: $(OPENNI) -Samples/MWClosestPoint: $(OPENNI) -Samples/MWClosestPointApp: $(OPENNI) Samples/MWClosestPoint +Source/Tools/NiViewer: $(CORE) -Samples/SimpleViewer: $(OPENNI) -Samples/MultiDepthViewer: $(OPENNI) -Samples/ClosestPointViewer: $(OPENNI) Samples/MWClosestPoint -Samples/SimpleViewer.java: Wrappers/java/OpenNI.java +Samples/SimpleRead: $(CORE) +Samples/EventBasedRead: $(CORE) +Samples/MultipleStreamRead: $(CORE) +Samples/MWClosestPoint: $(CORE) +Samples/SimpleViewer: $(CORE) +Samples/MultiDepthViewer: $(CORE) -$(FINAL_DIR): - mkdir -p $(FINAL_DIR) +Samples/MWClosestPointApp: $(CORE) Samples/MWClosestPoint +Samples/ClosestPointViewer: $(CORE) Samples/MWClosestPoint + +Samples/SimpleViewer.java: Wrappers/java + +#------------------------------------------------------------------------------- +# Top-level targets + +MAIN_SUBDIRS = \ + $(CXX_MAIN_SUBDIRS) + +SAMPLES_SUBDIRS = \ + $(CXX_SAMPLES_SUBDIRS) + +# Add java targets to the default build, depending on the HAS_JAVA variable. +ifeq ($(HAS_JAVA), 1) + MAIN_SUBDIRS += $(JAVA_MAIN_SUBDIRS) + SAMPLES_SUBDIRS += $(JAVA_SAMPLES_SUBDIRS) +endif + +all: main samples + +main: $(MAIN_SUBDIRS) + +samples: $(SAMPLES_SUBDIRS) doc: Source/Documentation/Runme.py rm -f Source/Documentation/html/*.md5 - + release: | all doc $(FINAL_DIR) Packaging/Harvest.py Packaging/$(PRODUCT_STRING) $(PLATFORM) cd Packaging; tar -cjf Final/$(PRODUCT_STRING).tar.bz2 $(PRODUCT_STRING) -# clean is cleaning all projects -clean: $(ALL_PROJS_CLEAN) +clean: $(CLEAN_SUBDIRS) + +.PHONY: \ + all \ + doc \ + main \ + samples \ + release \ + clean diff --git a/NOTICE b/NOTICE index b8aa8b11..676126fd 100644 --- a/NOTICE +++ b/NOTICE @@ -1,15 +1,509 @@ -OpenNI 2.0 +OpenNI 2.X + Copyright (c) 2012 PrimeSense Ltd. This product is licensed under the Apache License, Version 2.0 (the "License"); -You should have received a copy of the Apache License -along with OpenNI. If not, see: - http://www.apache.org/licenses/LICENSE-2.0 +You should have received a copy of the Apache License along with OpenNI 2.X. +If not, see: + 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. + +The following open source components are included in OpenNI 2.X: + +1. LibJPEG, 6b of 27-Mar-1998 + +Source code can be downloaded from: http://libjpeg.sourceforge.net/ + +This software is based in part on the work of the Independent JPEG Group. +OpenNI 2.X source code also contains the source code of libjpeg, as well as +its license terms. An online copy can be found at: + +https://github.com/OpenNI/OpenNI2/blob/master/ThirdParty/LibJPEG/README + +This license can be found at: +https://github.com/aseprite/aseprite/blob/master/docs/licenses/libjpeg-LICENSE. +txt + +We've made some minor modifications to the source code. + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and +you, its user, assume the entire risk as to its quality and accuracy. +This software is copyright (C) 1991-1998, Thomas G. Lane. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then +this README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept NO +LIABILITY for damages of any kind. +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. +Permission is NOT granted for the use of any IJG author's name or company +name in advertising or publicity relating to this software or products +derived from it. This software may be referred to only as "the Independent +JPEG Group's software". +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. +ansi2knr.c is included in this distribution by permission of L. Peter +Deutsch, sole proprietor of its copyright holder, Aladdin Enterprises of +Menlo Park, CA. ansi2knr.c is NOT covered by the above copyright and +conditions, but instead by the usual distribution terms of the Free Software +Foundation; principally, that you must include source code if you +redistribute it. (See the file +ansi2knr.c for full details.) However, since ansi2knr.c is not needed as +part of any program generated from the IJG code, this does not limit you more +than the foregoing paragraphs do. +The Unix configuration script "configure" was produced with GNU Autoconf. It +is copyright by the Free Software Foundation but is freely distributable. The +same holds for its supporting scripts (config.guess, config.sub, ltconfig, +ltmain.sh). Another support script, install-sh, is copyright by M.I.T. but +is also freely distributable. +It appears that the arithmetic coding option of the JPEG spec is covered by +patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot +legally be used without obtaining one or more licenses. For this reason, +support for arithmetic coding has been removed from the free JPEG software. +(Since arithmetic coding provides only a marginal gain over the unpatented +Huffman mode, it is unlikely that very many implementations will support +it.) So far as we are aware, there are no patent restrictions on the +remaining code. +The IJG distribution formerly included code to read and write GIF files. To +avoid entanglement with the Unisys LZW patent, GIF reading support has been +removed altogether, and the GIF writer has been simplified to produce +"uncompressed GIFs". This technique does not use the LZW algorithm; the +resulting GIF files are larger than usual, but are readable by all standard +GIF decoders. +We are required to state that "The Graphics Interchange Format(c) is the +Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark +property of CompuServe Incorporated." + +2. LibUSB, 1.0.9, under GNU Lesser General Public License, v 2.1 (or any +later version) + +OpenNI 2.X uses a modified version of libusb, which was modified by +PrimeSense on 2012. + +The modified source code is distributed along with OpenNI 2.X source code and +can be found in the following path: +ThirdParty/PSCommon/XnLib/ThirdParty/libusb-1.0.9-Android + + +Copyright (C) 2007-2008 Daniel Drake +Copyright (c) 2001 Johannes Erdfelt + +This library is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free +Software Foundation; either version 2.1 of the License, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Full text of the license is available below. + +3. GLUT 3.7.x + +Some of the samples arrive with GLUT binaries and headers for Windows. Those +are under the following copyright: + +This license can be found at: +http://user.xmission.com/~nate/glut/README-win32.txt + +The OpenGL Utility Toolkit (GLUT) distribution contains source code published +in a book titled "Programming OpenGL for the X Window System" (ISBN: +0-201-48359-9) published by Addison-Wesley. The programs and associated +files contained in the distribution were developed by Mark J. Kilgard and are +Copyright 1994, 1995, 1996 by Mark J. Kilgard (unless otherwise noted). The +programs are not in the public domain, but they are freely distributable +without licensing fees. These programs are provided without guarantee or +warrantee expressed or implied. + +THIS SOURCE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OR +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +OpenGL (R) is a registered trademark of Silicon Graphics, Inc. + +***************************************************************************** +GNU LESSER GENERAL PUBLIC LICENSE +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc.51 Franklin Street, +Fifth Floor, Boston, MA 02110-1301 USA. Everyone is permitted to copy and +distribute verbatim copies of this license document, but changing it is not +allowed. +[This is the first released version of the Lesser GPL. It also counts as the +successor of the GNU Library Public License, version 2, hence the version +number 2.1.] +Preamble +The licenses for most software are designed to take away your freedom to +share and change it. By contrast, the GNU General Public Licenses are +intended to guarantee your freedom to share and change free software--to make +sure the software is free for all its users. +This license, the Lesser General Public License, applies to some specially +designated software packages--typically libraries--of the Free Software +Foundation and other authors who decide to use it. You can use it too, but +we suggest you first think carefully about whether this license or the +ordinary General Public License is the better strategy to use in any +particular case, based on the explanations below. +When we speak of free software, we are referring to freedom of use, not +price. Our General Public Licenses are designed to make sure that you have +the freedom to distribute copies of free software (and charge for this +service if you wish); that you receive source code or can get it if you want +it; that you can change the software and use pieces of it in new free +programs; and that you are informed that you can do these things. +To protect your rights, we need to make restrictions that forbid distributors +to deny you these rights or to ask you to surrender these rights. These +restrictions translate to certain responsibilities for you if you distribute +copies of the library or if you modify it. +For example, if you distribute copies of the library, whether gratis or for a +fee, you must give the recipients all the rights that we gave you. You must +make sure that they, too, receive or can get the source code. If you link +other code with the library, you must provide complete object files to the +recipients, so that they can relink them with the library after making +changes to the library and recompiling it. And you must show them these +terms so they know their rights. +We protect your rights with a two-step method: (1) we copyright the library, +and (2) we offer you this license, which gives you legal permission to copy, +distribute and/or modify the library. +To protect each distributor, we want to make it very clear that there is no +warranty for the free library. Also, if the library is modified by someone +else and passed on, the recipients should know that what they have is not the +original version, so that the original author's reputation will not be +affected by problems that might be introduced by others. +Finally, software patents pose a constant threat to the existence of any free +program. We wish to make sure that a company cannot effectively restrict the +users of a free program by obtaining a restrictive license from a patent +holder. Therefore, we insist that any patent license obtained for a version +of the library must be consistent with the full freedom of use specified in +this license. +Most GNU software, including some libraries, is covered by the ordinary GNU +General Public License. This license, the GNU Lesser General Public License, +applies to certain designated libraries, and is quite different from the +ordinary General Public License. We use this license for certain libraries +in order to permit linking those libraries into non-free programs. +When a program is linked with a library, whether statically or using a shared +library, the combination of the two is legally speaking a combined work, a +derivative of the original library. The ordinary General Public License +therefore permits such linking only if the entire combination fits its +criteria of freedom. The Lesser General Public License permits more lax +criteria for linking other code with the library. +We call this license the "Lesser" General Public License because it does Less +to protect the user's freedom than the ordinary General Public License. It +also provides other free software developers Less of an advantage over +competing non-free programs. These disadvantages are the reason we use the +ordinary General Public License for many libraries. However, the Lesser +license provides advantages in certain special circumstances. +For example, on rare occasions, there may be a special need to encourage the +widest possible use of a certain library, so that it becomes a de-facto +standard. To achieve this, non-free programs must be allowed to use the +library. A more frequent case is that a free library does the same job as +widely used non-free libraries. In this case, there is little to gain by +limiting the free library to free software only, so we use the Lesser General +Public License. +In other cases, permission to use a particular library in non-free programs +enables a greater number of people to use a large body of free software. For +example, permission to use the GNU C Library in non-free programs enables +many more people to use the whole GNU operating system, as well as its +variant, the GNU/Linux operating system. +Although the Lesser General Public License is Less protective of the users' +freedom, it does ensure that the user of a program that is linked with the +Library has the freedom and the wherewithal to run that program using a +modified version of the Library. +The precise terms and conditions for copying, distribution and modification +follow. Pay close attention to the difference between a "work based on the +library" and a "work that uses the library". The former contains code +derived from the library, whereas the latter must be combined with the +library in order to run. +GNU LESSER GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License Agreement applies to any software library or other program +which contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Lesser General +Public License (also called "this License"). +Each licensee is addressed as "you". +A "library" means a collection of software functions and/or data prepared so +as to be conveniently linked with application programs (which use some of +those functions and data) to form executables. +The "Library", below, refers to any such software library or work which has +been distributed under these terms. A "work based on the Library" means +either the Library or any derivative work under copyright law: that is to +say, a work containing the Library or a portion of it, either verbatim or +with modifications and/or translated straightforwardly into another +language. (Hereinafter, translation is included without limitation in the +term "modification".) +"Source code" for a work means the preferred form of the work for making +modifications to it. For a library, complete source code means all the +source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and +installation of the library. +Activities other than copying, distribution and modification are not covered +by this License; they are outside its scope. The act of running a program +using the Library is not restricted, and output from such a program is +covered only if its contents constitute a work based on the Library +(independent of the use of the Library in a tool for writing it). Whether +that is true depends on what the Library does and what the program that uses +the Library does. +1. You may copy and distribute verbatim copies of the Library's complete +source code as you receive it, in any medium, provided that you conspicuously +and appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +License and to the absence of any warranty; and distribute a copy of this +License along with the Library. +You may charge a fee for the physical act of transferring a copy, and you may +at your option offer warranty protection in exchange for a fee. +2. You may modify your copy or copies of the Library or any portion of it, +thus forming a work based on the Library, and copy and distribute such +modifications or work under the terms of Section 1 above, provided that you +also meet all of these conditions: +a) The modified work must itself be a software library. +b) You must cause the files modified to carry prominent notices stating that +you changed the files and the date of any change. +c) You must cause the whole of the work to be licensed at no charge to all +third parties under the terms of this License. +d) If a facility in the modified Library refers to a function or a table of +data to be supplied by an application program that uses the facility, other +than as an argument passed when the facility is invoked, then you must make a +good faith effort to ensure that,in the event an application does not supply +such function or table, the facility still operates, and performs whatever +part of its purpose remains meaningful. +(For example, a function in a library to compute square roots has a purpose +that is entirely well-defined independent of the application. Therefore, +Subsection 2d requires that any application-supplied function or table used +by this function must be optional: if the application does not supply it, the +square root function must still compute square roots.) +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Library, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Library, the distribution of the whole must be +on the terms of this License, whose permissions for other licensees extend to +the entire whole, and thus to each and every part regardless of who wrote it. +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise the +right to control the distribution of derivative or collective works based on +the Library. +In addition, mere aggregation of another work not based on the Library with +the Library (or with a work based on the Library) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. +3. You may opt to apply the terms of the ordinary GNU General Public License +instead of this License to a given copy of the Library. To do this, you must +alter all the notices that refer to this License, so that they refer to the +ordinary GNU General Public License, version 2, instead of to this License. +(If a newer version than version 2 of the ordinary GNU General Public License +has appeared, then you can specify that version instead if you wish.) Do not +make any other change in these notices. +Once this change is made in a given copy, it is irreversible for that copy, +so the ordinary GNU General Public License applies to all subsequent copies +and derivative works made from that copy. +This option is useful when you wish to copy part of the code of the Library +into a program that is not a library. +4. You may copy and distribute the Library (or a portion or derivative of it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you accompany it with the complete +corresponding machine-readable source code, which must be distributed under +the terms of Sections 1 and 2 above on a medium customarily used for software +interchange. +If distribution of object code is made by offering access to copy from a +designated place, then offering equivalent access to copy the source code +from the same place satisfies the requirement to distribute the source code, +even though third parties are not compelled to copy the source along with the +object code. +5. A program that contains no derivative of any portion of the Library, but +is designed to work with the Library by being compiled or linked with it, is +called a "work that uses the Library". Such a work, in isolation, is not a +derivative work of the Library, and therefore falls outside the scope of this +License. +However, linking a "work that uses the Library" with the Library creates an +executable that is a derivative of the Library (because it contains portions +of the Library), rather than a "work that uses the library". The executable +is therefore covered by this License. Section 6 states terms for distribution +of such executables. +When a "work that uses the Library" uses material from a header file that is +part of the Library, the object code for the work may be a derivative work of +the Library even though the source code is not. Whether this is true is +especially significant if the work can be linked without the Library, or if +the work is itself a library. The threshold for this to be true is not +precisely defined by law. +If such an object file uses only numerical parameters, data structure layouts +and accessors, and small macros and small inline functions (ten lines or less +in length), then the use of the object file is unrestricted, regardless of +whether it is legally a derivative work. (Executables containing this object +code plus portions of the Library will still fall under Section 6.) +Otherwise, if the work is a derivative of the Library, you may distribute the +object code for the work under the terms of Section 6. Any executables +containing that work also fall under Section 6, whether or not they are +linked directly with the Library itself. +6. As an exception to the Sections above, you may also combine or link a +"work that uses the Library" with the Library to produce a work containing +portions of the Library, and distribute that work under terms of your choice, +provided that the terms permit modification of the work for the customer's +own use and reverse engineering for debugging such modifications. +You must give prominent notice with each copy of the work that the Library is +used in it and that the Library and its use are covered by this License. You +must supply a copy of this License. If the work during execution displays +copyright notices, you must include the copyright notice for the Library +among them, as well as a reference directing the user to the copy of this +License. Also, you must do one of these things: +a) Accompany the work with the complete corresponding machine-readable source +code for the Library including whatever changes were used in the work (which +must be distributed under Sections 1 and 2 above); and, if the work is an +executable linked with the Library, with the complete machine-readable "work +that uses the Library", as object code and/or source code, so that the user +can modify the Library and then relink to produce a modified executable +containing the modified Library. (It is understood that the user who changes +the contents of definitions files in the Library will not necessarily be able +to recompile the application to use the modified definitions.) +b) Use a suitable shared library mechanism for linking with the Library. A +suitable mechanism is one that (1) uses at run time a copy of the library +already present on the user's computer system, rather than copying library +functions into the executable, and (2) will operate properly with a modified +version of the library, if the user installs one, as long as the modified +version is interface-compatible with the version that the work was made with. +c) Accompany the work with a written offer, valid for at least three years, +to give the same user the materials specified in Subsection 6a, above, for a +charge no more than the cost of performing this distribution. +d) If distribution of the work is made by offering access to copy from a +designated place, offer equivalent access to copy the above specified +materials from the same place. +e) Verify that the user has already received a copy of these materials or +that you have already sent this user a copy. +For an executable, the required form of the "work that uses the Library" must +include any data and utility programs needed for reproducing the executable +from it. However, as a special exception, the materials to be distributed +need not include anything that is normally distributed (in either source or +binary form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component itself +accompanies the executable. +It may happen that this requirement contradicts the license restrictions of +other proprietary libraries that do not normally accompany the operating +system. Such a contradiction means you cannot use both them and the Library +together in an executable that you distribute. +7. You may place library facilities that are a work based on the Library +side-by-side in a single library together with other library facilities not +covered by this License, and distribute such a combined library, provided +that the separate distribution of the work based on the Library and of the +other library facilities is otherwise permitted, and provided that you do +these two things: +a) Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities. This must be +distributed under the terms of the Sections above. +b) Give prominent notice with the combined library of the fact that part of +it is a work based on the Library, and explaining where to find the +accompanying uncombined form of the same work. +8. You may not copy, modify, sublicense, link with, or distribute the Library +except as expressly provided under this License. Any attempt otherwise to +copy, modify, sublicense, link with, or distribute the Library is void, and +will automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this License will +not have their licenses terminated so long as such parties remain in full +compliance. +9. You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute the +Library or its derivative works. These actions are prohibited by law if you +do not accept this License. Therefore, by modifying or distributing the +Library (or any work based on the Library), you indicate your acceptance of +this License to do so, and all its terms and conditions for copying, +distributing or modifying the Library or works based on it. +10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the original +licensor to copy, distribute, link with or modify the Library subject to +these terms and conditions. You may not impose any further restrictions on +the recipients' exercise of the rights granted herein. You are not +responsible for enforcing compliance by third parties with this License. +11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not excuse +you from the conditions of this License. If you cannot distribute so as to +satisfy simultaneously your obligations under this License and any other +pertinent obligations, then as a consequence you may not distribute the +Library at all. For example, if a patent license would not permit +royalty-free redistribution of the Library by all those who receive copies +directly or indirectly through you, then the only way you could satisfy both +it and this License would be to refrain entirely from distribution of the +Library. +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, and +the section as a whole is intended to apply in other circumstances. +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system which is implemented by public license +practices. Many people have made generous contributions to the wide range of +software distributed through that system in reliance on consistent +application of that system; it is up to the author/donor to decide if he or +she is willing to distribute software through any other system and a licensee +cannot impose that choice. +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. +12. If the distribution and/or use of the Library is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Library under this License may add an +explicit geographical distribution limitation excluding those countries, so +that distribution is permitted only in or among countries not thus excluded. +In such case, this License incorporates the limitation as if written in the +body of this License. +13. The Free Software Foundation may publish revised and/or new versions of +the Lesser General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and "any later +version", you have the option of following the terms and conditions either of +that version or of any later version published by the Free Software +Foundation. If the Library does not specify a license version number, you +may choose any version ever published by the Free Software Foundation. +14. If you wish to incorporate parts of the Library into other free programs +whose distribution conditions are incompatible with these, write to the +author to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes make +exceptions for this. Our decision will be guided by the two goals of +preserving the free status of all derivatives of our free software and of +promoting the sharing and reuse of software generally. +NO WARRANTY +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS and OTHER PARTIES PROVIDE THE LIBRARY +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF +THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE +COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY and REDISTRIBUTE +THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE +OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR +DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR +A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH +HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS -This software is based in part on the work of the Independent JPEG Group. -Your use of the library may involve use of the Microsoft Kinect for Windows Software Development Kit, -which is currently subject to the following license: - http://www.microsoft.com/en-us/kinectforwindows/develop/sdk-eula.aspx diff --git a/OpenNI.sln b/OpenNI.sln index 9af176a6..b63b27f6 100644 --- a/OpenNI.sln +++ b/OpenNI.sln @@ -1,5 +1,7 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleRead", "Samples\SimpleRead\SimpleRead.vcxproj", "{BDA3BF24-550A-4BF9-83E5-7B56134EDD40}" ProjectSection(ProjectDependencies) = postProject {72D595BB-8C52-449B-91DB-0E9F6AEAF53A} = {72D595BB-8C52-449B-91DB-0E9F6AEAF53A} @@ -104,7 +106,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PSLinkConsole", "Source\Dri EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wrappers", "Wrappers", "{9FCEE1ED-B0D9-46D7-A014-98FBDD0EF6A9}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenNI.jni", "Wrappers\java\OpenNI.jni\OpenNI.jni.vcxproj", "{1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenNI.jni", "Wrappers\java\jni\OpenNI.jni.vcxproj", "{1723CBBA-8EE7-439A-93FB-2E94B4DB2E63}" ProjectSection(ProjectDependencies) = postProject {72D595BB-8C52-449B-91DB-0E9F6AEAF53A} = {72D595BB-8C52-449B-91DB-0E9F6AEAF53A} EndProjectSection @@ -120,6 +122,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PSLink", "Source\Drivers\PS {72D595BB-8C52-449B-91DB-0E9F6AEAF5BB} = {72D595BB-8C52-449B-91DB-0E9F6AEAF5BB} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Kinect2", "Source\Drivers\Kinect2\Kinect2.vcxproj", "{950CCD82-B435-4C10-8852-DDD8AAD14119}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -300,28 +304,37 @@ Global {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Release|x64.Build.0 = Release|x64 {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Release|x86.ActiveCfg = Release|Win32 {5B74F010-8B79-46B5-B906-C2B56CDB3386}.Release|x86.Build.0 = Release|Win32 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Debug|x64.ActiveCfg = Debug|x64 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Debug|x64.Build.0 = Debug|x64 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Debug|x86.ActiveCfg = Debug|Win32 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Debug|x86.Build.0 = Debug|Win32 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Release|x64.ActiveCfg = Release|x64 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Release|x64.Build.0 = Release|x64 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Release|x86.ActiveCfg = Release|Win32 + {950CCD82-B435-4C10-8852-DDD8AAD14119}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {BDA3BF24-550A-4BF9-83E5-7B56134EDD40} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} + {B7DE6235-086E-42C6-B5AC-2DC795388ED9} = {238D091D-1A85-4A61-9DCD-483768C51804} {BDA3BF24-550A-4BF9-83E5-7B56134EED40} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} + {BDA3BF24-550A-4BF9-83E5-0056134EED40} = {20285393-1DB1-4300-8AD3-30AEAE3C5DA6} {BDA3BF24-550A-FFF9-83E5-7B56134EEE40} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} + {9F6652AF-35F2-452E-A2D3-08D05F5C075E} = {238D091D-1A85-4A61-9DCD-483768C51804} + {31F0F25B-A84A-48AC-9716-5DF9137F3855} = {238D091D-1A85-4A61-9DCD-483768C51804} + {15ECC029-90DE-4D1D-B00A-4A8E647D8C24} = {238D091D-1A85-4A61-9DCD-483768C51804} {4B01E59D-CC85-4B2E-B3A2-00F75856CB23} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} {A0DB36C9-CE6C-4F61-933C-E53A630D3C7E} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} {BDA3BF24-550A-4BF9-83E5-0006134EED40} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} {BDA3BF24-5555-4BF9-83E5-7B56134EDD40} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} {920D08AC-452C-4326-BC6E-86FE65848587} = {EA8ECD36-D9CB-4860-97A7-2D85E7111E6B} - {B7DE6235-086E-42C6-B5AC-2DC795388ED9} = {238D091D-1A85-4A61-9DCD-483768C51804} - {9F6652AF-35F2-452E-A2D3-08D05F5C075E} = {238D091D-1A85-4A61-9DCD-483768C51804} - {31F0F25B-A84A-48AC-9716-5DF9137F3855} = {238D091D-1A85-4A61-9DCD-483768C51804} - {15ECC029-90DE-4D1D-B00A-4A8E647D8C24} = {238D091D-1A85-4A61-9DCD-483768C51804} {E636BACA-795F-41CF-BC52-14C727BF014E} = {238D091D-1A85-4A61-9DCD-483768C51804} - {5B74F010-8B79-46B5-B906-C2B56CDB3386} = {238D091D-1A85-4A61-9DCD-483768C51804} - {BDA3BF24-550A-4BF9-83E5-0056134EED40} = {20285393-1DB1-4300-8AD3-30AEAE3C5DA6} {D39A4248-3985-41DE-AFD5-AEC58D29291F} = {20285393-1DB1-4300-8AD3-30AEAE3C5DA6} - {D5709FB9-909D-415F-8F86-2F25BEF6CE23} = {20285393-1DB1-4300-8AD3-30AEAE3C5DA6} {1723CBBA-8EE7-439A-93FB-2E94B4DB2E63} = {9FCEE1ED-B0D9-46D7-A014-98FBDD0EF6A9} + {D5709FB9-909D-415F-8F86-2F25BEF6CE23} = {20285393-1DB1-4300-8AD3-30AEAE3C5DA6} + {5B74F010-8B79-46B5-B906-C2B56CDB3386} = {238D091D-1A85-4A61-9DCD-483768C51804} + {950CCD82-B435-4C10-8852-DDD8AAD14119} = {238D091D-1A85-4A61-9DCD-483768C51804} EndGlobalSection EndGlobal diff --git a/Packaging/Harvest.py b/Packaging/Harvest.py index 4ce9ed26..df627cfd 100755 --- a/Packaging/Harvest.py +++ b/Packaging/Harvest.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 #/**************************************************************************** #* * @@ -21,6 +21,7 @@ #* * #****************************************************************************/ import os +import glob import re import sys import shutil @@ -29,42 +30,45 @@ import xml.dom.minidom class Harvest: - def __init__(self, rootDir, outDir, arch): + def __init__(self, rootDir, outDir, arch, osName): self.rootDir = rootDir self.outDir = outDir self.arch = arch - self.osName = platform.system() - self.binDir = os.path.join(rootDir, 'Bin', arch + '-Release') + self.osName = osName self.platformSuffix = '' self.glutSuffix = '32' - + self.binDir = os.path.join(rootDir, 'Bin', arch + '-Release') + + # override some defaults if self.osName == 'Windows': if arch == 'x86': self.binDir = os.path.join(rootDir, 'Bin', 'Win32-Release') elif arch == 'x64': self.platformSuffix = '64' self.glutSuffix = '64' + elif self.osName == 'Android': + self.binDir = os.path.join(rootDir, 'Wrappers', 'java', 'libs', 'armeabi-v7a') def copySharedObject(self, sourceDir, name, targetDir): if self.osName == 'Windows': shutil.copy(os.path.join(sourceDir, name + '.dll'), targetDir) shutil.copy(os.path.join(sourceDir, name + '.pdb'), targetDir) - elif self.osName == 'Linux': + elif self.osName == 'Linux' or self.osName == 'Android': shutil.copy(os.path.join(sourceDir, 'lib' + name + '.so'), targetDir) elif self.osName == 'Darwin': shutil.copy(os.path.join(sourceDir, 'lib' + name + '.dylib'), targetDir) else: raise 'Unsupported platform!' - + def copyExecutable(self, sourceDir, name, targetDir): if self.osName == 'Windows': shutil.copy(os.path.join(sourceDir, name + '.exe'), targetDir) shutil.copy(os.path.join(sourceDir, name + '.pdb'), targetDir) else: shutil.copy(os.path.join(sourceDir, name), targetDir) - + def regxReplace(self, findStr, repStr, filePath): - "replaces all findStr by repStr in file filePath using regualr expression" + "replaces all findStr by repStr in file filePath using regular expression" findStrRegx = re.compile(findStr) tempName = filePath+'~~~' fileMode = os.stat(filePath).st_mode @@ -77,58 +81,84 @@ def regxReplace(self, findStr, repStr, filePath): input.close() os.remove(filePath) os.rename(tempName, filePath) - + def copyRedistFiles(self, targetDir): os.makedirs(targetDir) # start with OpenNI itself self.copySharedObject(self.binDir, 'OpenNI2', targetDir) self.copySharedObject(self.binDir, 'OpenNI2.jni', targetDir) - shutil.copy(os.path.join(self.binDir, 'org.openni.jar'), targetDir) - shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI.ini'), targetDir) + + if self.osName != 'Android': + shutil.copy(os.path.join(self.binDir, 'org.openni.jar'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI.ini'), targetDir) + # and now all drivers - binDriversDir = os.path.join(self.binDir, 'OpenNI2', 'Drivers') - targetDriversDir = os.path.join(targetDir, 'OpenNI2', 'Drivers') - os.makedirs(targetDriversDir) + if self.osName != 'Android': + binDriversDir = os.path.join(self.binDir, 'OpenNI2', 'Drivers') + targetDriversDir = os.path.join(targetDir, 'OpenNI2', 'Drivers') + os.makedirs(targetDriversDir) + else: + binDriversDir = self.binDir + targetDriversDir = targetDir + self.copySharedObject(binDriversDir, 'usb', targetDriversDir) + self.copySharedObject(binDriversDir, 'OniFile', targetDriversDir) self.copySharedObject(binDriversDir, 'PS1080', targetDriversDir) self.copySharedObject(binDriversDir, 'PSLink', targetDriversDir) - shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PS1080.ini'), targetDriversDir) - shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PSLink.ini'), targetDriversDir) + + if self.osName != 'Android': + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PS1080.ini'), targetDriversDir) + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PSLink.ini'), targetDriversDir) + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'OniFile.ini'), targetDriversDir) + if self.osName == 'Windows': self.copySharedObject(binDriversDir, 'Kinect', targetDriversDir) - - def copySample(self, samplesDir, name, isLibrary = False, isGL = False, isJava = False): + + def copySample(self, samplesDir, targetBinDir, name, isLibrary = False, isGL = False, isJava = False, sourceSamplesDir = None): if self.arch == 'Arm' and isGL: return - + + if sourceSamplesDir is None: + sourceSamplesDir = os.path.join(self.rootDir, 'Samples') + sampleTargetDir = os.path.join(samplesDir, name) - sampleSourceDir = os.path.join(self.rootDir, 'Samples', name) + sampleSourceDir = os.path.join(sourceSamplesDir, name) + + if self.osName == 'Android': + # remove the .Android in the end + sampleTargetDir = os.path.splitext(sampleTargetDir)[0] # copy sources - for root, dirs, files in os.walk(sampleSourceDir): - # take dir name without 'root' and append to target - dst = os.path.join(samplesDir, name, os.path.relpath(root, sampleSourceDir)) - #print dst - for file in files: - if (isJava and file.endswith('.java')) or (not isJava and (file.endswith('.h') or file.endswith('.cpp'))): - if not os.path.exists(dst): - os.makedirs(dst) - shutil.copy(os.path.join(root, file), dst) - + if self.osName == 'Android': + shutil.copytree(os.path.join(sampleSourceDir, 'src'), os.path.join(sampleTargetDir, 'src')) + shutil.copytree(os.path.join(sampleSourceDir, 'res'), os.path.join(sampleTargetDir, 'res')) + if os.path.exists(os.path.join(sampleSourceDir, 'jni')): + shutil.copytree(os.path.join(sampleSourceDir, 'jni'), os.path.join(sampleTargetDir, 'jni')) + if os.path.exists(os.path.join(sampleSourceDir, 'assets')): + shutil.copytree(os.path.join(sampleSourceDir, 'assets'), os.path.join(sampleTargetDir, 'assets')) + else: + for root, dirs, files in os.walk(sampleSourceDir): + # take dir name without 'root' and append to target + dst = os.path.join(sampleTargetDir, os.path.relpath(root, sampleSourceDir)) + for file in files: + if (isJava and file.endswith('.java')) or (not isJava and (file.endswith('.h') or file.endswith('.cpp'))): + if not os.path.exists(dst): + os.makedirs(dst) + shutil.copy(os.path.join(root, file), dst) + # copy common header - if not isJava and not isLibrary: + if not isJava and not isLibrary and self.osName != 'Android': shutil.copy(os.path.join(self.rootDir, 'Samples', 'Common', 'OniSampleUtilities.h'), sampleTargetDir) - + # copy GL headers if self.osName == 'Windows' and isGL: shutil.copytree(os.path.join(self.rootDir, 'ThirdParty', 'GL', 'GL'), os.path.join(sampleTargetDir, 'GL')) - shutil.copytree(os.path.join(self.rootDir, 'ThirdParty', 'GL', 'glh'), os.path.join(sampleTargetDir, 'glh')) # and lib shutil.copy(os.path.join(self.rootDir, 'ThirdParty', 'GL', 'glut32.lib'), sampleTargetDir) shutil.copy(os.path.join(self.rootDir, 'ThirdParty', 'GL', 'glut64.lib'), sampleTargetDir) shutil.copy(os.path.join(self.rootDir, 'ThirdParty', 'GL', 'glut32.dll'), sampleTargetDir) shutil.copy(os.path.join(self.rootDir, 'ThirdParty', 'GL', 'glut64.dll'), sampleTargetDir) - + # and project file / makefile if self.osName == 'Windows': if isJava: @@ -151,27 +181,27 @@ def copySample(self, samplesDir, name, isLibrary = False, isGL = False, isJava = buildFile.write(')\n') buildFile.write(buildScript) buildFile.close() - + else: shutil.copy(os.path.join(sampleSourceDir, name + '.vcxproj'), sampleTargetDir) projFile = os.path.join(sampleTargetDir, name + '.vcxproj') #ET.register_namespace('', 'http://schemas.microsoft.com/developer/msbuild/2003') doc = xml.dom.minidom.parse(projFile) - + # remove OutDir and IntDir (make them default) for propertyGroup in doc.getElementsByTagName("PropertyGroup"): if len(propertyGroup.getElementsByTagName("OutDir")) > 0: propertyGroup.parentNode.removeChild(propertyGroup) - + for group in doc.getElementsByTagName("ItemDefinitionGroup"): condAttr = group.getAttribute('Condition') if condAttr.find('x64') != -1: postfix = '64' glPostfix = '64' - else: + else: postfix = '' glPostfix = '32' - + incDirs = group.getElementsByTagName('ClCompile')[0].getElementsByTagName('AdditionalIncludeDirectories')[0] val = incDirs.firstChild.data @@ -181,7 +211,7 @@ def copySample(self, samplesDir, name, isLibrary = False, isGL = False, isJava = val = re.sub('..\\\\Common', r'.', val) # fix OpenNI include dir val = re.sub('..\\\\..\\\\Include', '$(OPENNI2_INCLUDE' + postfix + ')', val) - + incDirs.firstChild.data = val # fix additional library directories @@ -189,22 +219,22 @@ def copySample(self, samplesDir, name, isLibrary = False, isGL = False, isJava = val = libDirs.firstChild.data val = re.sub('\$\(OutDir\)', '$(OutDir);$(OPENNI2_LIB' + postfix + ')', val) libDirs.firstChild.data = val - + # add post-build event to copy OpenNI redist post = doc.createElement('PostBuildEvent') cmd = 'xcopy /D /S /F /Y "$(OPENNI2_REDIST' + postfix + ')\*" "$(OutDir)"\n' if isGL: cmd += 'xcopy /D /F /Y "$(ProjectDir)\\glut' + glPostfix + '.dll" "$(OutDir)"\n' - + cmdNode = doc.createElement('Command') cmdNode.appendChild(doc.createTextNode(cmd)) post.appendChild(cmdNode) group.appendChild(post) - + proj = open(projFile, 'w') proj.write(doc.toxml()) proj.close() - + elif self.osName == 'Linux' or self.osName == 'Darwin': shutil.copy(os.path.join(sampleSourceDir, 'Makefile'), sampleTargetDir) shutil.copy(os.path.join(rootDir, 'ThirdParty', 'PSCommon', 'BuildSystem', 'CommonDefs.mak'), sampleTargetDir) @@ -216,13 +246,13 @@ def copySample(self, samplesDir, name, isLibrary = False, isGL = False, isJava = shutil.copy(os.path.join(rootDir, 'ThirdParty', 'PSCommon', 'BuildSystem', 'CommonJavaMakefile'), sampleTargetDir) else: shutil.copy(os.path.join(rootDir, 'ThirdParty', 'PSCommon', 'BuildSystem', 'CommonCppMakefile'), sampleTargetDir) - + # fix common makefiles path self.regxReplace('../../ThirdParty/PSCommon/BuildSystem/', '', os.path.join(sampleTargetDir, 'Makefile')) - + # fix BIN dir self.regxReplace('BIN_DIR = ../../Bin', 'BIN_DIR = Bin', os.path.join(sampleTargetDir, 'Makefile')) - + # fix include dirs and copy openni_redist add = r''' ifndef OPENNI2_INCLUDE @@ -238,106 +268,213 @@ def copySample(self, samplesDir, name, isLibrary = False, isGL = False, isJava = .PHONY: copy-redist copy-redist: cp -R $(OPENNI2_REDIST)/* $(OUT_DIR) - + $(OUTPUT_FILE): copy-redist -''' +''' self.regxReplace(r'include (Common.*Makefile)', add, os.path.join(sampleTargetDir, 'Makefile')) + elif self.osName == 'Android': + shutil.copy(os.path.join(sampleSourceDir, '.classpath'), sampleTargetDir) + shutil.copy(os.path.join(sampleSourceDir, '.project'), sampleTargetDir) + shutil.copy(os.path.join(sampleSourceDir, 'AndroidManifest.xml'), sampleTargetDir) + shutil.copy(os.path.join(sampleSourceDir, 'build.xml'), sampleTargetDir) + shutil.copy(os.path.join(sampleSourceDir, 'proguard-project.txt'), sampleTargetDir) + shutil.copy(os.path.join(sampleSourceDir, 'project.properties'), sampleTargetDir) + # fix dependency + self.regxReplace('../../../Wrappers/java', '../../OpenNIAndroidLibrary', os.path.join(sampleTargetDir, 'project.properties')) + self.regxReplace('../../Wrappers/java', '../../OpenNIAndroidLibrary', os.path.join(sampleTargetDir, 'project.properties')) # and executable - if isJava: + if self.osName == 'Android': + apkName = glob.glob(os.path.join(sampleSourceDir, 'bin', '*-release.apk'))[0] + realName = os.path.split(sampleTargetDir)[1] + shutil.copy(apkName, os.path.join(targetBinDir, realName + '.apk')) + elif isJava: splitName = os.path.splitext(name) # copy jar - shutil.copy(os.path.join(self.binDir, 'org.openni.Samples.' + splitName[0] + '.jar'), os.path.join(samplesDir, 'Bin')) + shutil.copy(os.path.join(self.binDir, 'org.openni.Samples.' + splitName[0] + '.jar'), targetBinDir) # and script if not isLibrary: if self.osName == 'Windows': - shutil.copy(os.path.join(self.binDir, 'org.openni.Samples.' + splitName[0] + '.bat'), os.path.join(samplesDir, 'Bin')) + shutil.copy(os.path.join(self.binDir, 'org.openni.Samples.' + splitName[0] + '.bat'), targetBinDir) else: - shutil.copy(os.path.join(self.binDir, 'org.openni.Samples.' + splitName[0]), os.path.join(samplesDir, 'Bin')) + shutil.copy(os.path.join(self.binDir, 'org.openni.Samples.' + splitName[0]), targetBinDir) elif isLibrary: - self.copySharedObject(self.binDir, name, os.path.join(samplesDir, 'Bin')) + self.copySharedObject(self.binDir, name, targetBinDir) if self.osName == 'Windows': - shutil.copy(os.path.join(self.binDir, name + '.lib'), os.path.join(samplesDir, 'Bin')) + shutil.copy(os.path.join(self.binDir, name + '.lib'), targetBinDir) else: # regular executable - self.copyExecutable(self.binDir, name, os.path.join(samplesDir, 'Bin')) - + self.copyExecutable(self.binDir, name, targetBinDir) + def copyTool(self, toolsDir, name, isGL = False): if self.arch == 'Arm' and isGL: return - + self.copyExecutable(self.binDir, name, toolsDir) def copyDocumentation(self, docDir): + os.makedirs(docDir) if self.osName == 'Windows': - os.makedirs(docDir) - shutil.copy(os.path.join(self.rootDir, 'Source', 'Documentation', 'html', 'OpenNI.chm'), docDir) + shutil.copy(os.path.join(self.rootDir, 'Source', 'Documentation', 'cpp', 'OpenNI.chm'), docDir) else: - shutil.copytree(os.path.join(self.rootDir, 'Source', 'Documentation', 'html'), docDir) - - shutil.copytree(os.path.join(self.rootDir, 'Source', 'Documentation', 'java'), os.path.join(docDir, 'java')) - + shutil.copytree(os.path.join(self.rootDir, 'Source', 'Documentation', 'cpp'), os.path.join(docDir, 'cpp')) + + if self.osName == 'Android': + shutil.copytree(os.path.join(self.rootDir, 'Wrappers', 'java', 'doc', 'gen'), os.path.join(docDir, 'java')) + else: + shutil.copytree(os.path.join(self.rootDir, 'Source', 'Documentation', 'java'), os.path.join(docDir, 'java')) + def copyGLUT(self, targetDir): if self.osName == 'Windows': - shutil.copy(os.path.join(rootDir, 'ThirdParty', 'GL', 'glut' + self.glutSuffix + '.dll'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'ThirdParty', 'GL', 'glut' + self.glutSuffix + '.dll'), targetDir) + + def copyAndroidLib(self, targetDir): + os.makedirs(targetDir) + shutil.copytree(os.path.join(self.rootDir, 'Wrappers', 'java', 'src'), os.path.join(targetDir, 'src')) + shutil.copytree(os.path.join(self.rootDir, 'Wrappers', 'java', 'res'), os.path.join(targetDir, 'res')) + shutil.copytree(os.path.join(self.rootDir, 'Wrappers', 'java', 'libs'), os.path.join(targetDir, 'libs')) + os.makedirs(os.path.join(targetDir, 'bin')) + shutil.copy(os.path.join(self.rootDir, 'Wrappers', 'java', 'bin', 'classes.jar'), os.path.join(targetDir, 'bin', 'org.openni.jar')) + shutil.copy(os.path.join(self.rootDir, 'Wrappers', 'java', '.classpath'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Wrappers', 'java', '.project'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Wrappers', 'java', 'AndroidManifest.xml'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Wrappers', 'java', 'build.xml'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Wrappers', 'java', 'proguard-project.txt'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Wrappers', 'java', 'project.properties'), targetDir) + # remove redundant file + os.remove(os.path.join(targetDir, 'res', '.gitignore')) + + def copyAssets(self, targetDir): + os.makedirs(targetDir) + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI.ini'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PS1080.ini'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'PSLink.ini'), targetDir) + shutil.copy(os.path.join(self.rootDir, 'Config', 'OpenNI2', 'Drivers', 'OniFile.ini'), targetDir) + + def createNativeMakefile(self, nativeDir, redistDir): + nativeAndroidMk = open(os.path.join(nativeDir, 'Android.mk'), 'w') + nativeAndroidMk.write('LOCAL_PATH := $(call my-dir)\n') + + libs = [] + for root, dirs, files in os.walk(redistDir): + for file in files: + if file.startswith('lib') and file.endswith('.so') and file != 'libOpenNI2.so': + moduleName = file[3:len(file)-3] + nativeAndroidMk.write('include $(CLEAR_VARS)\n') + libs.append(moduleName) + nativeAndroidMk.write('LOCAL_MODULE := ' + moduleName + '\n') + nativeAndroidMk.write('LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/' + file + '\n') + nativeAndroidMk.write('include $(PREBUILT_SHARED_LIBRARY)\n') + nativeAndroidMk.write('\n') + # and now OpenNI itself + nativeAndroidMk.write('include $(CLEAR_VARS)\n') + nativeAndroidMk.write('LOCAL_MODULE := OpenNI2\n') + nativeAndroidMk.write('LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libOpenNI2.so\n') + nativeAndroidMk.write('LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include\n') + nativeAndroidMk.write('LOCAL_SHARED_LIBRARIES := ' + ' '.join(libs) + '\n') + nativeAndroidMk.write('include $(PREBUILT_SHARED_LIBRARY)\n') + nativeAndroidMk.write('\n') + def run(self): if os.path.exists(self.outDir): shutil.rmtree(self.outDir) os.makedirs(self.outDir) - + # Redist - self.copyRedistFiles(os.path.join(self.outDir, 'Redist')) - + if self.osName == 'Android': + nativeDir = os.path.join(self.outDir, 'Native', 'OpenNI2') + redistDir = os.path.join(nativeDir, 'armeabi-v7a') + else: + redistDir = os.path.join(self.outDir, 'Redist') + self.copyRedistFiles(redistDir) + # Samples samplesDir = os.path.join(self.outDir, 'Samples') - self.copyRedistFiles(os.path.join(samplesDir, 'Bin')) - self.copyGLUT(os.path.join(samplesDir, 'Bin')) - self.copySample(samplesDir, 'SimpleRead') - self.copySample(samplesDir, 'SimpleViewer', isGL = True) - self.copySample(samplesDir, 'SimpleViewer.java', isJava = True) - self.copySample(samplesDir, 'EventBasedRead') - self.copySample(samplesDir, 'MultiDepthViewer', isGL = True) - self.copySample(samplesDir, 'MultipleStreamRead') - self.copySample(samplesDir, 'MWClosestPoint', isLibrary = True) - self.copySample(samplesDir, 'MWClosestPointApp') - self.copySample(samplesDir, 'ClosestPointViewer', isGL = True) - + if self.osName != 'Android': + samplesBinDir = os.path.join(samplesDir, 'Bin') + self.copyRedistFiles(samplesBinDir) + self.copyGLUT(samplesBinDir) + self.copySample(samplesDir, samplesBinDir, 'SimpleRead') + self.copySample(samplesDir, samplesBinDir, 'SimpleViewer', isGL = True) + self.copySample(samplesDir, samplesBinDir, 'SimpleViewer.java', isJava = True) + self.copySample(samplesDir, samplesBinDir, 'EventBasedRead') + self.copySample(samplesDir, samplesBinDir, 'MultiDepthViewer', isGL = True) + self.copySample(samplesDir, samplesBinDir, 'MultipleStreamRead') + self.copySample(samplesDir, samplesBinDir, 'MWClosestPoint', isLibrary = True) + self.copySample(samplesDir, samplesBinDir, 'MWClosestPointApp') + self.copySample(samplesDir, samplesBinDir, 'ClosestPointViewer', isGL = True) + else: + samplesBinDir = os.path.join(samplesDir, 'Prebuilt') + os.makedirs(samplesBinDir) + self.copySample(samplesDir, samplesBinDir, 'SimpleRead.Android') + self.copySample(samplesDir, samplesBinDir, 'SimpleViewer.Android') + # Tools toolsDir = os.path.join(self.outDir, 'Tools') - self.copyRedistFiles(toolsDir) - self.copyGLUT(toolsDir) - self.copyTool(toolsDir, 'NiViewer', isGL = True) - self.copyTool(toolsDir, 'PS1080Console') - self.copyTool(toolsDir, 'PSLinkConsole') - + if self.osName != 'Android': + self.copyRedistFiles(toolsDir) + self.copyGLUT(toolsDir) + self.copyTool(toolsDir, 'NiViewer', isGL = True) + self.copyTool(toolsDir, 'PS1080Console') + self.copyTool(toolsDir, 'PSLinkConsole') + else: + toolsSourceDir = os.path.join(self.rootDir, 'Source', 'Tools') + toolsBinDir = os.path.join(toolsDir, 'Prebuilt') + os.makedirs(toolsBinDir) + self.copySample(toolsDir, toolsBinDir, 'NiViewer.Android', sourceSamplesDir = toolsSourceDir) + # Documentation docDir = os.path.join(self.outDir, 'Documentation') self.copyDocumentation(docDir) - + # Include - shutil.copytree(os.path.join(rootDir, 'Include'), os.path.join(self.outDir, 'Include')) - + if self.osName == 'Android': + incDir = os.path.join(nativeDir, 'include') + else: + incDir = os.path.join(self.outDir, 'Include') + shutil.copytree(os.path.join(self.rootDir, 'Include'), incDir) + + # Android stuff + if self.osName == 'Android': + # Android native makefile + self.createNativeMakefile(nativeDir, redistDir) + + # Android lib + self.copyAndroidLib(os.path.join(self.outDir, 'OpenNIAndroidLibrary')) + self.copyAssets(os.path.join(self.outDir, 'Assets', 'openni')) + + + # Release notes and change log + shutil.copy(os.path.join(self.rootDir, 'ReleaseNotes.txt'), self.outDir) + shutil.copy(os.path.join(self.rootDir, 'CHANGES.txt'), self.outDir) + # Licenses - shutil.copy(os.path.join(rootDir, 'NOTICE'), self.outDir) - shutil.copy(os.path.join(rootDir, 'LICENSE'), self.outDir) - + shutil.copy(os.path.join(self.rootDir, 'NOTICE'), self.outDir) + shutil.copy(os.path.join(self.rootDir, 'LICENSE'), self.outDir) + if self.osName == 'Windows': # Driver - shutil.copytree(os.path.join(rootDir, 'ThirdParty', 'PSCommon', 'XnLib', 'Driver', 'Win32', 'Bin'), os.path.join(self.outDir, 'Driver')) - + shutil.copytree(os.path.join(self.rootDir, 'ThirdParty', 'PSCommon', 'XnLib', 'Driver', 'Win32', 'Bin'), os.path.join(self.outDir, 'Driver')) + # Library libDir = os.path.join(self.outDir, 'Lib') os.makedirs(libDir) shutil.copy(os.path.join(self.binDir, 'OpenNI2.lib'), libDir) - else: + elif self.osName != 'Android': # install script shutil.copy(os.path.join(self.rootDir, 'Packaging', 'Linux', 'install.sh'), self.outDir) shutil.copy(os.path.join(self.rootDir, 'Packaging', 'Linux', 'primesense-usb.rules'), self.outDir) -if len(sys.argv) < 3: - print 'Usage: ' + sys.argv[0] + ' ' - exit(1) - -rootDir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) -harvest = Harvest(rootDir, sys.argv[1], sys.argv[2]) -harvest.run() +if __name__ == '__main__': + if len(sys.argv) < 3: + print 'Usage: ' + sys.argv[0] + ' ' + exit(1) + + rootDir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) + arch = sys.argv[2] + osName = platform.system() + if sys.argv[2] == 'Android': + arch = 'Arm' + osName = 'Android' + harvest = Harvest(rootDir, sys.argv[1], arch, osName) + harvest.run() diff --git a/Packaging/Install/Includes/Variables.wxi b/Packaging/Install/Includes/Variables.wxi index 06d01741..5449d5bb 100644 --- a/Packaging/Install/Includes/Variables.wxi +++ b/Packaging/Install/Includes/Variables.wxi @@ -5,13 +5,13 @@ It's not enough to just include newer files. --> - + - + - + - \ No newline at end of file + diff --git a/Packaging/Linux/install.sh b/Packaging/Linux/install.sh index 2243c9d6..fa452099 100755 --- a/Packaging/Linux/install.sh +++ b/Packaging/Linux/install.sh @@ -1,26 +1,25 @@ #!/bin/sh -#/*************************************************************************** -#* * -#* OpenNI 2.0 * -#* Copyright (C) 2012 PrimeSense Ltd. * -#* * -#* This file is part of OpenNI2 installation. * -#* * -#* OpenNI is free software: you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License as published* -#* by the Free Software Foundation, either version 3 of the License, or * -#* (at your option) any later version. * -#* * -#* OpenNI is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Lesser General Public License for more details. * -#* * -#* You should have received a copy of the GNU Lesser General Public License* -#* along with OpenNI. If not, see . * -#* * -#***************************************************************************/ +#/**************************************************************************** +#* * +#* 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. * +#* * +#****************************************************************************/ # # Check if user is root/running with sudo diff --git a/Packaging/ReleaseVersion.py b/Packaging/ReleaseVersion.py index e2fdf5fb..8339da5f 100755 --- a/Packaging/ReleaseVersion.py +++ b/Packaging/ReleaseVersion.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 #/**************************************************************************** #* * @@ -30,11 +30,12 @@ import stat import UpdateVersion +from Harvest import Harvest if len(sys.argv) < 2 or sys.argv[1] in ('-h','--help'): - print "usage: " + sys.argv[0] + " [UpdateVersion]" + print "usage: " + sys.argv[0] + " [UpdateVersion]" sys.exit(1) - + plat = sys.argv[1] origDir = os.getcwd() @@ -47,6 +48,17 @@ UpdateVersion.VERSION_BUILD += 1 UpdateVersion.update() +def check_call(cmd, outputFile = None): + if platform.system() == 'Windows': + useShell=True + else: + useShell=False + + rc = subprocess.call(cmd, shell=useShell, stdout=outputFile, stderr=outputFile) + if rc != 0: + print 'Failed to execute command: ' + str(cmd) + sys.exit(9) + def get_reg_values(reg_key, value_list): # open the reg key try: @@ -74,7 +86,7 @@ def get_reg_values(reg_key, value_list): def calc_jobs_number(): cores = 1 - + try: if isinstance(self, OSMac): txt = gop('sysctl -n hw.physicalcpu') @@ -84,54 +96,72 @@ def calc_jobs_number(): cores = int(txt) except: pass - + return str(cores * 2) +def build_android_project(path, outputFile, target = 'release'): + if not 'NDK_HOME' in os.environ: + print 'Please define NDK_HOME!' + sys.exit(2) + + if not 'ANDROID_HOME' in os.environ: + print 'Please define ANDROID_HOME!' + sys.exit(2) + + sdkDir = os.environ['ANDROID_HOME'] + check_call([os.path.join(sdkDir, 'tools', 'android'), 'update', 'project', '-p', path], outputFile) + check_call(['ant', '-f', os.path.join(path, 'build.xml'), target], outputFile) + +def build_android(): + logFile = open('build.android.log', 'w') + + libraries = ['Wrappers/java'] + samples = ['Samples/SimpleRead.Android', 'Samples/SimpleViewer.Android'] + tools = ['Source/Tools/NiViewer.Android'] + + # build all projects + android_projects = libraries + samples + tools + # clean all + print 'Cleaning...' + for proj in android_projects: + logFile.write('**** Cleaning ' + proj + "...****\n") + build_android_project(os.path.join('..', proj), outputFile=logFile, target='clean') + # and build all + for proj in android_projects: + logFile.write('**** Building ' + proj + "...****\n") + print 'Building ' + proj + '...', + build_android_project(os.path.join('..', proj), outputFile=logFile) + print 'OK' + + # build documentation + print 'Creating C++ documentation...', + check_call([os.path.join('..', 'Source', 'Documentation', 'Runme.py')], outputFile=logFile) + print 'OK' + + print 'Creating java documentation...', + build_android_project('../Wrappers/java', outputFile=logFile, target='javadoc') + print 'OK' + # Create installer strVersion = UpdateVersion.getVersionName() print "Creating installer for OpenNI " + strVersion + " " + plat finalDir = "Final" if not os.path.isdir(finalDir): os.mkdir(finalDir) - -if plat == 'android': - if not 'NDK_ROOT' in os.environ: - print 'Please define NDK_ROOT!' - sys.exit(2) - - ndkDir = os.environ['NDK_ROOT'] - buildDir = 'AndroidBuild' - if os.path.isdir(buildDir): - shutil.rmtree(buildDir) - - outputDir = 'OpenNI-android-' + strVersion - if os.path.isdir(outputDir): - shutil.rmtree(outputDir) - - os.makedirs(buildDir + '/jni') - os.symlink('../../../', buildDir + '/jni/OpenNI2') - shutil.copy('../Android.mk', buildDir + '/jni') - shutil.copy('../Application.mk', buildDir + '/jni') - rc = subprocess.call([ ndkDir + '/ndk-build', '-C', buildDir, '-j8' ]) - if rc != 0: - print 'Build failed!' - sys.exit(3) - - finalFile = finalDir + '/' + outputDir + '.tar' - - shutil.move(buildDir + '/libs/armeabi-v7a', outputDir) - - # add config files - shutil.copy('../Config/OpenNI.ini', outputDir) - shutil.copy('../Config/OpenNI2/Drivers/PS1080.ini', outputDir) +if plat == 'Android': + build_android() + outputDir = 'OpenNI-Android-' + strVersion + harvest = Harvest('..', outputDir, 'Arm', 'Android') + harvest.run() + finalFile = finalDir + '/' + outputDir + ".tar" print('Creating archive ' + finalFile) subprocess.check_call(['tar', '-cf', finalFile, outputDir]) elif platform.system() == 'Windows': import win32con,pywintypes,win32api,platform - + (bits,linkage) = platform.architecture() matchObject = re.search('64',bits) is_64_bit_machine = matchObject is not None @@ -140,7 +170,7 @@ def calc_jobs_number(): MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0") else: MSVC_KEY = (win32con.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\10.0") - + MSVC_VALUES = [("InstallDir", win32con.REG_SZ)] VS_INST_DIR = get_reg_values(MSVC_KEY, MSVC_VALUES)[0] PROJECT_SLN = "..\OpenNI.sln" @@ -152,34 +182,34 @@ def calc_jobs_number(): # everything OK, can remove build log os.remove(bulidLog) - + outFile = 'OpenNI-Windows-' + plat + '-' + strVersion + '.msi' finalFile = os.path.join(finalDir, outFile) if os.path.exists(finalFile): os.remove(finalFile) shutil.move('Install/bin/' + plat + '/en-us/' + outFile, finalDir) - + elif platform.system() == 'Linux' or platform.system() == 'Darwin': devNull = open('/dev/null', 'w') subprocess.check_call(['make', '-C', '../', '-j' + calc_jobs_number(), 'PLATFORM=' + plat, 'clean'], stdout=devNull, stderr=devNull) devNull.close() - + buildLog = open(origDir + '/build.release.' + plat + '.log', 'w') subprocess.check_call(['make', '-C', '../', '-j' + calc_jobs_number(), 'PLATFORM=' + plat, 'release'], stdout=buildLog, stderr=buildLog) buildLog.close() - + # everything OK, can remove build log os.remove(origDir + '/build.release.' + plat + '.log') - + else: print "Unknown OS" sys.exit(2) - + # also copy Release Notes and CHANGES documents shutil.copy('../ReleaseNotes.txt', finalDir) shutil.copy('../CHANGES.txt', finalDir) - + print "Installer can be found under: " + finalDir print "Done" diff --git a/Packaging/UpdateVersion.py b/Packaging/UpdateVersion.py index 87358c4c..33be0974 100755 --- a/Packaging/UpdateVersion.py +++ b/Packaging/UpdateVersion.py @@ -1,3 +1,5 @@ +#!/usr/bin/python2.7 + #/**************************************************************************** #* * #* OpenNI 2.x Alpha * @@ -26,9 +28,9 @@ from datetime import date VERSION_MAJOR = 2 -VERSION_MINOR = 2 +VERSION_MINOR = 3 VERSION_MAINTENANCE = 0 -VERSION_BUILD = 33 +VERSION_BUILD = 15 def getVersionString(): return str(VERSION_MAJOR) + "." + str(VERSION_MINOR) + "." + str(VERSION_MAINTENANCE) + "." + str(VERSION_BUILD) @@ -66,6 +68,9 @@ def update(): update_wix_project("Install/Install.wixproj") update_doxygen("../Source/Documentation/Doxyfile") update_release_notes("../ReleaseNotes.txt") + update_android_projects("../Wrappers/java") + update_android_projects("../Source/Tools") + update_android_projects("../Samples") print ("\n*** Done ***") @@ -132,7 +137,17 @@ def update_release_notes (filePath): output.write(s) output.close() os.remove(filePath) - os.rename(tempName,filePath) + os.rename(tempName,filePath) + +def update_android_projects(path): + versionCode = VERSION_BUILD + VERSION_MAINTENANCE * 10000 + VERSION_MINOR * 1000000 + VERSION_MAJOR * 100000000 + for root, dirs, files in os.walk(path): + for file in files: + if file == 'AndroidManifest.xml' and not root.endswith('bin'): + print(( "Updating android project: " + root)) + fileName = os.path.join(root, file) + regx_replace(r'android:versionCode=\"(.*)\"', 'android:versionCode="' + str(versionCode) + '"', fileName) + regx_replace(r'android:versionName=\"(.*)\"', 'android:versionName="' + getVersionName() + '"', fileName) if __name__ == '__main__': if len(sys.argv) == 5: @@ -140,5 +155,5 @@ def update_release_notes (filePath): VERSION_MINOR = int(sys.argv[2]) VERSION_MAINTENANCE = int(sys.argv[3]) VERSION_BUILD = int(sys.argv[4]) - + update() diff --git a/README b/README index c91e93f2..de8e7bd9 100644 --- a/README +++ b/README @@ -1,10 +1,17 @@ OpenNI ------ -Website: www.openni.org +Website: http://structure.io/openni -Buliding Prerequisites +Building Prerequisites ====================== + +OS X +---- +- Libusb 1.0 + First, install Homebrew: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" + brew install libusb --universal + Windows ------- - Microsoft Visual Studio 2010 @@ -46,12 +53,7 @@ Linux - JDK 6.0 From: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html Or via apt: - Ubuntu 10.x: - sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" - sudo apt-get update - sudo apt-get install sun-java6-jdk - Ubuntu 12.x: - sudo apt-get install openjdk-6-jdk + sudo apt-get install openjdk-6-jdk - FreeGLUT3 From: http://freeglut.sourceforge.net/index.php#download Or via apt: @@ -67,28 +69,49 @@ Linux Android ------- -- Android NDK r8d +- Android NDK From: http://developer.android.com/tools/sdk/ndk/index.html#Downloads + You must also define an environment variable called "NDK_HOME" that points to the NDK installation directory. +- Android SDK + From: http://developer.android.com/sdk/index.html#download + You must also define an environment variable called "ANDROID_HOME" that points to the SDK installation directory. + Currently requires installing SDK for API level 14 and 18 (via Android SDK Manager) +- Ant + On Ubuntu machine: sudo apt-get install ant + For Windows, from: https://code.google.com/p/winant +- JDK 6.0 + For Windows: + From: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html + You must also define an environment variable called "JAVA_HOME" that points to the JDK installation directory. + For example: set JAVA_HOME=c:\Program Files (x86)\Java\jdk1.6.0_32 + For Ubuntu: + From: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u32-downloads-1594644.html + Or via apt: + sudo apt-get install openjdk-6-jdk Building ======== Building on Windows: Open the solution OpenNI.sln -Building on Linux: +Building on Linux / OS X: Run: $ make - + Cross-Compiling for ARM on Linux: The following environment variables should be defined: - ARM_CXX= - ARM_STAGING= Then, run: $ PLATFORM=Arm make + +Building for Android: + - Create a workspace in eclipse + - Import all projects under root directory -Creating OpenNI2 package: - - Go into the directory 'Packaging' - - Run ReleaseVersion.py [x86|x64|arm|android] - NOTE: for android, NDK_ROOT must be defined, pointing to the NDK installation dir. - - Installer will be placed in the 'Final' directory +Creating OpenNI2 Package +======================== +- Go into the directory 'Packaging' +- Run ReleaseVersion.py [x86|x64|Arm|Android] +- Installer will be placed in the 'Final' directory diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index c95a96ed..8f6bd1ce 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,5 +1,5 @@ -OpenNI 2.2.0 Build 33 -November 12 2013 +OpenNI 2.3.0 Build 15 +November 10 2013 Minimum Requirements: --------------------- @@ -20,6 +20,26 @@ Minimum Requirements: - GCC 4.x - Some of the sample applications require a graphics card equivalent to: ATI RADEON x1300 or NVIDIA GeForce 7300. +Prerequisets: +------------- +- Windows: + - Microsoft Kinect SDK v1.6 (for using with Kinect devices) + From: http://go.microsoft.com/fwlink/?LinkID=262831 + +- Linux: + - LibUSB 1.0.x + From: http://sourceforge.net/projects/libusb/files/libusb-1.0/ + Or via apt: + sudo apt-get install libusb-1.0-0 + - LibUDEV + sudo apt-get install libudev0 + - FreeGLUT3 + From: http://freeglut.sourceforge.net/index.php#download + You only need the run-time version to run the OpenGL samples: + sudo apt-get install freeglut3 + If you also want to compile the OpenGL samples, you'll need to install the development version: + sudo apt-get install freeglut3-dev + Notes: ------ - On Android, only native support (and samples) is currently provided. Please note that as bionic (Android linker) does not diff --git a/Samples/ClosestPointViewer/ClosestPointViewer.vcxproj b/Samples/ClosestPointViewer/ClosestPointViewer.vcxproj index fe63dbfc..9dee031b 100644 --- a/Samples/ClosestPointViewer/ClosestPointViewer.vcxproj +++ b/Samples/ClosestPointViewer/ClosestPointViewer.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ Application true MultiByte + v120 Application true MultiByte + v120 Application false true MultiByte + v120 Application false true MultiByte + v120 @@ -142,6 +146,7 @@ glut32.lib;OpenNI2.lib;MWClosestPoint.lib $(OutDir);..\..\ThirdParty\GL true + false ..\..\Include diff --git a/Samples/ClosestPointViewer/Viewer.h b/Samples/ClosestPointViewer/Viewer.h index 1208950f..805c6f39 100644 --- a/Samples/ClosestPointViewer/Viewer.h +++ b/Samples/ClosestPointViewer/Viewer.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_SAMPLE_VIEWER_H_ -#define _ONI_SAMPLE_VIEWER_H_ +#ifndef VIEWER_H +#define VIEWER_H #include "MWClosestPoint/MWClosestPoint.h" #include @@ -98,4 +98,4 @@ class SampleViewer }; -#endif // _ONI_SAMPLE_VIEWER_H_ +#endif // VIEWER_H diff --git a/Samples/Common/OniSampleUtilities.h b/Samples/Common/OniSampleUtilities.h index a036d9f9..824f8fd7 100644 --- a/Samples/Common/OniSampleUtilities.h +++ b/Samples/Common/OniSampleUtilities.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_SAMPLE_UTILITIES_H_ -#define _ONI_SAMPLE_UTILITIES_H_ +#ifndef ONISAMPLEUTILITIES_H +#define ONISAMPLEUTILITIES_H #include #include @@ -116,4 +116,4 @@ void calculateHistogram(float* pHistogram, int histogramSize, const openni::Vide -#endif // _ONI_SAMPLE_UTILITIES_H_ +#endif // ONISAMPLEUTILITIES_H diff --git a/Samples/EventBasedRead/EventBasedRead.vcxproj b/Samples/EventBasedRead/EventBasedRead.vcxproj index f67db7a3..8ba58ff9 100644 --- a/Samples/EventBasedRead/EventBasedRead.vcxproj +++ b/Samples/EventBasedRead/EventBasedRead.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ Application true MultiByte + v120 Application true MultiByte + v120 Application false true MultiByte + v120 Application false true MultiByte + v120 diff --git a/Samples/MWClosestPoint/MWClosestPoint.h b/Samples/MWClosestPoint/MWClosestPoint.h index e51def12..a4a92068 100644 --- a/Samples/MWClosestPoint/MWClosestPoint.h +++ b/Samples/MWClosestPoint/MWClosestPoint.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _MW_CLOSEST_POINT_H_ -#define _MW_CLOSEST_POINT_H_ +#ifndef MWCLOSESTPOINT_H +#define MWCLOSESTPOINT_H #include @@ -79,4 +79,4 @@ class MW_CP_API ClosestPoint -#endif // _MW_CLOSEST_POINT_H_ +#endif // MWCLOSESTPOINT_H diff --git a/Samples/MWClosestPoint/MWClosestPoint.vcxproj b/Samples/MWClosestPoint/MWClosestPoint.vcxproj index 74cafe76..520e6766 100644 --- a/Samples/MWClosestPoint/MWClosestPoint.vcxproj +++ b/Samples/MWClosestPoint/MWClosestPoint.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ DynamicLibrary true MultiByte + v120 DynamicLibrary true MultiByte + v120 DynamicLibrary false true MultiByte + v120 DynamicLibrary false true MultiByte + v120 diff --git a/Samples/MWClosestPointApp/MWClosestPointApp.vcxproj b/Samples/MWClosestPointApp/MWClosestPointApp.vcxproj index 063ec377..00b15831 100644 --- a/Samples/MWClosestPointApp/MWClosestPointApp.vcxproj +++ b/Samples/MWClosestPointApp/MWClosestPointApp.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ Application true MultiByte + v120 Application true MultiByte + v120 Application false true MultiByte + v120 Application false true MultiByte + v120 diff --git a/Samples/MultiDepthViewer/MultiDepthViewer.vcxproj b/Samples/MultiDepthViewer/MultiDepthViewer.vcxproj index d021c0d0..ab077457 100644 --- a/Samples/MultiDepthViewer/MultiDepthViewer.vcxproj +++ b/Samples/MultiDepthViewer/MultiDepthViewer.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ Application true MultiByte + v120 Application true MultiByte + v120 Application false true MultiByte + v120 Application false true MultiByte + v120 @@ -136,6 +140,7 @@ glut32.lib;OpenNI2.lib $(OutDir);..\..\ThirdParty\GL true + false diff --git a/Samples/MultiDepthViewer/Viewer.h b/Samples/MultiDepthViewer/Viewer.h index 60001208..1e32c933 100644 --- a/Samples/MultiDepthViewer/Viewer.h +++ b/Samples/MultiDepthViewer/Viewer.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_SAMPLE_VIEWER_H_ -#define _ONI_SAMPLE_VIEWER_H_ +#ifndef VIEWER_H +#define VIEWER_H #include @@ -79,4 +79,4 @@ class SampleViewer }; -#endif // _ONI_SAMPLE_VIEWER_H_ \ No newline at end of file +#endif // VIEWER_H diff --git a/Samples/MultipleStreamRead/MultipleStreamRead.vcxproj b/Samples/MultipleStreamRead/MultipleStreamRead.vcxproj index 15887ec6..762df131 100644 --- a/Samples/MultipleStreamRead/MultipleStreamRead.vcxproj +++ b/Samples/MultipleStreamRead/MultipleStreamRead.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ Application true MultiByte + v120 Application true MultiByte + v120 Application false true MultiByte + v120 Application false true MultiByte + v120 diff --git a/Samples/SimpleRead.Android/.classpath b/Samples/SimpleRead.Android/.classpath new file mode 100644 index 00000000..62aff606 --- /dev/null +++ b/Samples/SimpleRead.Android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Samples/SimpleRead.Android/.project b/Samples/SimpleRead.Android/.project new file mode 100644 index 00000000..ce1c2ffd --- /dev/null +++ b/Samples/SimpleRead.Android/.project @@ -0,0 +1,33 @@ + + + SimpleRead + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/Samples/SimpleRead.Android/AndroidManifest.xml b/Samples/SimpleRead.Android/AndroidManifest.xml new file mode 100644 index 00000000..b888b476 --- /dev/null +++ b/Samples/SimpleRead.Android/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/Samples/SimpleRead.Android/build.xml b/Samples/SimpleRead.Android/build.xml new file mode 100644 index 00000000..f239e59d --- /dev/null +++ b/Samples/SimpleRead.Android/build.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/SimpleRead.Android/ic_launcher-web.png b/Samples/SimpleRead.Android/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/Samples/SimpleRead.Android/ic_launcher-web.png differ diff --git a/Samples/SimpleRead.Android/proguard-project.txt b/Samples/SimpleRead.Android/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/Samples/SimpleRead.Android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/Samples/SimpleRead.Android/project.properties b/Samples/SimpleRead.Android/project.properties new file mode 100644 index 00000000..752a7c01 --- /dev/null +++ b/Samples/SimpleRead.Android/project.properties @@ -0,0 +1,15 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-14 +android.library.reference.1=../../Wrappers/java diff --git a/Samples/SimpleRead.Android/res/drawable-hdpi/ic_launcher.png b/Samples/SimpleRead.Android/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/Samples/SimpleRead.Android/res/drawable-hdpi/ic_launcher.png differ diff --git a/Samples/SimpleRead.Android/res/drawable-mdpi/ic_launcher.png b/Samples/SimpleRead.Android/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/Samples/SimpleRead.Android/res/drawable-mdpi/ic_launcher.png differ diff --git a/Samples/SimpleRead.Android/res/drawable-xhdpi/ic_launcher.png b/Samples/SimpleRead.Android/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/Samples/SimpleRead.Android/res/drawable-xhdpi/ic_launcher.png differ diff --git a/Samples/SimpleRead.Android/res/drawable-xxhdpi/ic_launcher.png b/Samples/SimpleRead.Android/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/Samples/SimpleRead.Android/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/Samples/SimpleRead.Android/res/layout/activity_simple_read.xml b/Samples/SimpleRead.Android/res/layout/activity_simple_read.xml new file mode 100644 index 00000000..222e8907 --- /dev/null +++ b/Samples/SimpleRead.Android/res/layout/activity_simple_read.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/Samples/SimpleRead.Android/res/values-sw600dp/dimens.xml b/Samples/SimpleRead.Android/res/values-sw600dp/dimens.xml new file mode 100644 index 00000000..44f01db7 --- /dev/null +++ b/Samples/SimpleRead.Android/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/Samples/SimpleRead.Android/res/values-sw720dp-land/dimens.xml b/Samples/SimpleRead.Android/res/values-sw720dp-land/dimens.xml new file mode 100644 index 00000000..61e3fa8f --- /dev/null +++ b/Samples/SimpleRead.Android/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ + + + + 128dp + + diff --git a/Samples/SimpleRead.Android/res/values-v11/styles.xml b/Samples/SimpleRead.Android/res/values-v11/styles.xml new file mode 100644 index 00000000..3c02242a --- /dev/null +++ b/Samples/SimpleRead.Android/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/Samples/SimpleRead.Android/res/values/dimens.xml b/Samples/SimpleRead.Android/res/values/dimens.xml new file mode 100644 index 00000000..55c1e590 --- /dev/null +++ b/Samples/SimpleRead.Android/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/Samples/SimpleRead.Android/res/values/strings.xml b/Samples/SimpleRead.Android/res/values/strings.xml new file mode 100644 index 00000000..b1d06e4f --- /dev/null +++ b/Samples/SimpleRead.Android/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + SimpleRead + Waiting for frames… + + diff --git a/Samples/SimpleRead.Android/res/values/styles.xml b/Samples/SimpleRead.Android/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/Samples/SimpleRead.Android/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/Samples/SimpleRead.Android/src/org/openni/android/samples/simpleread/SimpleReadActivity.java b/Samples/SimpleRead.Android/src/org/openni/android/samples/simpleread/SimpleReadActivity.java new file mode 100644 index 00000000..e399aacc --- /dev/null +++ b/Samples/SimpleRead.Android/src/org/openni/android/samples/simpleread/SimpleReadActivity.java @@ -0,0 +1,206 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ +package org.openni.android.samples.simpleread; + +import java.util.List; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.os.Bundle; +import android.util.Log; +import android.widget.TextView; + +import org.openni.Device; +import org.openni.DeviceInfo; +import org.openni.OpenNI; +import org.openni.SensorType; +import org.openni.VideoFrameRef; +import org.openni.VideoStream; +import org.openni.android.OpenNIHelper; + +public class SimpleReadActivity + extends Activity + implements OpenNIHelper.DeviceOpenListener { + + private static final String TAG = "SimplerRead"; + private OpenNIHelper mOpenNIHelper; + private boolean mDeviceOpenPending = false; + private Thread mMainLoopThread; + private boolean mShouldRun = true; + private Device mDevice; + private VideoStream mStream; + private TextView mStatusLine; + + @Override + protected void onCreate(Bundle savedInstanceState) { + mOpenNIHelper = new OpenNIHelper(this); + OpenNI.setLogAndroidOutput(true); + OpenNI.setLogMinSeverity(0); + OpenNI.initialize(); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_simple_read); + mStatusLine = (TextView) findViewById(R.id.status_line); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + + mOpenNIHelper.shutdown(); + OpenNI.shutdown(); + } + + @Override + protected void onResume() { + Log.d(TAG, "onResume"); + + super.onResume(); + + // onResume() is called after the USB permission dialog is closed, in which case, we don't want + // to request device permissions again + if (mDeviceOpenPending) { + return; + } + + // Request opening the first OpenNI-compliant device found + String uri; + + List devices = OpenNI.enumerateDevices(); + if (devices.isEmpty()) { + showAlertAndExit("No OpenNI-compliant device found."); + return; + } + + uri = devices.get(0).getUri(); + + mDeviceOpenPending = true; + mOpenNIHelper.requestDeviceOpen(uri, this); + } + + private void showAlertAndExit(String message) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(message); + builder.setNeutralButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + builder.show(); + } + + @Override + public void onDeviceOpened(Device aDevice) { + Log.d(TAG, "Permission granted for device " + aDevice.getDeviceInfo().getUri()); + + mDeviceOpenPending = false; + + try { + mDevice = aDevice; + mStream = VideoStream.create(mDevice, SensorType.DEPTH); + mStream.start(); + } catch (RuntimeException e) { + showAlertAndExit("Failed to open stream: " + e.getMessage()); + return; + } + + mShouldRun = true; + mMainLoopThread = new Thread() { + @Override + public void run() { + while (mShouldRun) { + VideoFrameRef frame = null; + + try { + frame = mStream.readFrame(); + // get the middle pixel + int index = frame.getVideoMode().getResolutionY() / 2 * frame.getVideoMode().getResolutionX() + frame.getVideoMode().getResolutionX() / 2; + short depthValue = frame.getData().getShort(index * 2); + updateLabel(String.format("Frame Index: %,d | Timestamp: %.6f seconds | Middle depth value: %,d mm", frame.getFrameIndex(), frame.getTimestamp() / 1e6, depthValue)); + } catch (Exception e) { + Log.e(TAG, "Failed reading frame: " + e); + } + } + }; + }; + + mMainLoopThread.setName("SimpleRead MainLoop Thread"); + mMainLoopThread.start(); + } + + private void stop() { + mShouldRun = false; + + while (mMainLoopThread != null) { + try { + mMainLoopThread.join(); + mMainLoopThread = null; + break; + } catch (InterruptedException e) { + } + } + + if (mStream != null) { + mStream.stop(); + } + + mStatusLine.setText(R.string.waiting_for_frames); + } + + private void updateLabel(final String message) { + runOnUiThread(new Runnable() { + public void run() { + mStatusLine.setText(message); + } + }); + } + + @Override + public void onDeviceOpenFailed(String uri) { + Log.e(TAG, "Failed to open device " + uri); + mDeviceOpenPending = false; + showAlertAndExit("Failed to open device"); + } + + @Override + protected void onPause() { + Log.d(TAG, "onPause"); + + super.onPause(); + + // onPause() is called just before the USB permission dialog is opened, in which case, we don't + // want to shutdown OpenNI + if (mDeviceOpenPending) + return; + + stop(); + + if (mStream != null) { + mStream.destroy(); + mStream = null; + } + + if (mDevice != null) { + mDevice.close(); + mDevice = null; + } + } +} diff --git a/Samples/SimpleRead/SimpleRead.vcxproj b/Samples/SimpleRead/SimpleRead.vcxproj index de3942f1..d93c0018 100644 --- a/Samples/SimpleRead/SimpleRead.vcxproj +++ b/Samples/SimpleRead/SimpleRead.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ Application true MultiByte + v120 Application true MultiByte + v120 Application false true MultiByte + v120 Application false true MultiByte + v120 diff --git a/Samples/SimpleViewer.Android/.classpath b/Samples/SimpleViewer.Android/.classpath new file mode 100644 index 00000000..7bc01d9a --- /dev/null +++ b/Samples/SimpleViewer.Android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Samples/SimpleViewer.Android/.project b/Samples/SimpleViewer.Android/.project new file mode 100644 index 00000000..501e0561 --- /dev/null +++ b/Samples/SimpleViewer.Android/.project @@ -0,0 +1,33 @@ + + + SimpleViewer + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/Samples/SimpleViewer.Android/AndroidManifest.xml b/Samples/SimpleViewer.Android/AndroidManifest.xml new file mode 100644 index 00000000..bb204490 --- /dev/null +++ b/Samples/SimpleViewer.Android/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + diff --git a/Samples/SimpleViewer.Android/build.xml b/Samples/SimpleViewer.Android/build.xml new file mode 100644 index 00000000..acfd02f8 --- /dev/null +++ b/Samples/SimpleViewer.Android/build.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/SimpleViewer.Android/ic_launcher-web.png b/Samples/SimpleViewer.Android/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/Samples/SimpleViewer.Android/ic_launcher-web.png differ diff --git a/Samples/SimpleViewer.Android/proguard-project.txt b/Samples/SimpleViewer.Android/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/Samples/SimpleViewer.Android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/Samples/SimpleViewer.Android/project.properties b/Samples/SimpleViewer.Android/project.properties new file mode 100644 index 00000000..752a7c01 --- /dev/null +++ b/Samples/SimpleViewer.Android/project.properties @@ -0,0 +1,15 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-14 +android.library.reference.1=../../Wrappers/java diff --git a/Samples/SimpleViewer.Android/res/drawable-hdpi/ic_launcher.png b/Samples/SimpleViewer.Android/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/Samples/SimpleViewer.Android/res/drawable-hdpi/ic_launcher.png differ diff --git a/Samples/SimpleViewer.Android/res/drawable-mdpi/ic_launcher.png b/Samples/SimpleViewer.Android/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/Samples/SimpleViewer.Android/res/drawable-mdpi/ic_launcher.png differ diff --git a/Samples/SimpleViewer.Android/res/drawable-xhdpi/ic_launcher.png b/Samples/SimpleViewer.Android/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/Samples/SimpleViewer.Android/res/drawable-xhdpi/ic_launcher.png differ diff --git a/Samples/SimpleViewer.Android/res/drawable-xxhdpi/ic_launcher.png b/Samples/SimpleViewer.Android/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/Samples/SimpleViewer.Android/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/Samples/SimpleViewer.Android/res/layout/activity_simple_viewer.xml b/Samples/SimpleViewer.Android/res/layout/activity_simple_viewer.xml new file mode 100644 index 00000000..1ce13606 --- /dev/null +++ b/Samples/SimpleViewer.Android/res/layout/activity_simple_viewer.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/Samples/SimpleViewer.Android/res/values-sw600dp/dimens.xml b/Samples/SimpleViewer.Android/res/values-sw600dp/dimens.xml new file mode 100644 index 00000000..44f01db7 --- /dev/null +++ b/Samples/SimpleViewer.Android/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/Samples/SimpleViewer.Android/res/values-sw720dp-land/dimens.xml b/Samples/SimpleViewer.Android/res/values-sw720dp-land/dimens.xml new file mode 100644 index 00000000..61e3fa8f --- /dev/null +++ b/Samples/SimpleViewer.Android/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ + + + + 128dp + + diff --git a/Samples/SimpleViewer.Android/res/values-v11/styles.xml b/Samples/SimpleViewer.Android/res/values-v11/styles.xml new file mode 100644 index 00000000..3c02242a --- /dev/null +++ b/Samples/SimpleViewer.Android/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/Samples/SimpleViewer.Android/res/values/dimens.xml b/Samples/SimpleViewer.Android/res/values/dimens.xml new file mode 100644 index 00000000..55c1e590 --- /dev/null +++ b/Samples/SimpleViewer.Android/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/Samples/SimpleViewer.Android/res/values/strings.xml b/Samples/SimpleViewer.Android/res/values/strings.xml new file mode 100644 index 00000000..8499e30c --- /dev/null +++ b/Samples/SimpleViewer.Android/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + SimpleViewer + Waiting for frames… + + diff --git a/Samples/SimpleViewer.Android/res/values/styles.xml b/Samples/SimpleViewer.Android/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/Samples/SimpleViewer.Android/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/Samples/SimpleViewer.Android/src/org/openni/android/samples/simpleviewer/SimpleViewerActivity.java b/Samples/SimpleViewer.Android/src/org/openni/android/samples/simpleviewer/SimpleViewerActivity.java new file mode 100644 index 00000000..7d9ac6c8 --- /dev/null +++ b/Samples/SimpleViewer.Android/src/org/openni/android/samples/simpleviewer/SimpleViewerActivity.java @@ -0,0 +1,244 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ +package org.openni.android.samples.simpleviewer; + +import java.util.List; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.graphics.Color; +import android.os.Bundle; +import android.util.Log; +import android.view.MotionEvent; +import android.widget.TextView; + +import org.openni.Device; +import org.openni.DeviceInfo; +import org.openni.OpenNI; +import org.openni.SensorType; +import org.openni.VideoFrameRef; +import org.openni.VideoStream; +import org.openni.android.OpenNIHelper; +import org.openni.android.OpenNIView; + +public class SimpleViewerActivity + extends Activity + implements OpenNIHelper.DeviceOpenListener { + + private static final String TAG = "SimplerViewer"; + private OpenNIHelper mOpenNIHelper; + private boolean mDeviceOpenPending = false; + private Thread mMainLoopThread; + private boolean mShouldRun = true; + private Device mDevice; + private VideoStream mStream; + private VideoStream mSecondStream; + private OpenNIView mFrameView; + private TextView mStatusLine; + private int mViewStream = 0; + + @Override + protected void onCreate(Bundle savedInstanceState) { + mOpenNIHelper = new OpenNIHelper(this); + OpenNI.setLogAndroidOutput(true); + OpenNI.setLogMinSeverity(0); + OpenNI.initialize(); + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_simple_viewer); + mFrameView = (OpenNIView) findViewById(R.id.frameView); + mStatusLine = (TextView) findViewById(R.id.status_line); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + + mOpenNIHelper.shutdown(); + OpenNI.shutdown(); + } + + @Override + protected void onResume() { + Log.d(TAG, "onResume"); + + super.onResume(); + + // onResume() is called after the USB permission dialog is closed, in which case, we don't want + // to request device permissions again + if (mDeviceOpenPending) { + return; + } + + // Request opening the first OpenNI-compliant device found + String uri; + + List devices = OpenNI.enumerateDevices(); + if (devices.isEmpty()) { + showAlertAndExit("No OpenNI-compliant device found."); + return; + } + + uri = devices.get(0).getUri(); + + mDeviceOpenPending = true; + mOpenNIHelper.requestDeviceOpen(uri, this); + } + + private void showAlertAndExit(String message) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(message); + builder.setNeutralButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + builder.show(); + } + + @Override + public void onDeviceOpened(Device aDevice) { + Log.d(TAG, "Permission granted for device " + aDevice.getDeviceInfo().getUri()); + + mDeviceOpenPending = false; + + try { + mDevice = aDevice; + mStream = VideoStream.create(mDevice, SensorType.DEPTH); + mStream.start(); + + if (mDevice.hasSensor(SensorType.COLOR)) { + mSecondStream = VideoStream.create(mDevice, SensorType.COLOR); + mSecondStream.start(); + } else if (mDevice.hasSensor(SensorType.IR)) { + mSecondStream = VideoStream.create(mDevice, SensorType.IR); + mSecondStream.start(); + } + } catch (RuntimeException e) { + showAlertAndExit("Failed to open stream: " + e.getMessage()); + return; + } + + mShouldRun = true; + mMainLoopThread = new Thread() { + @Override + public void run() { + while (mShouldRun) { + VideoStream[] streams = { mStream, mSecondStream }; + int[] colors = { Color.YELLOW, Color.WHITE }; + VideoFrameRef frame = null; + + try { + frame = streams[mViewStream].readFrame(); + // Request rendering of the current OpenNI frame + mFrameView.setBaseColor(colors[mViewStream]); + mFrameView.update(frame); + updateLabel(String.format("Frame Index: %,d | Timestamp: %.6f seconds", frame.getFrameIndex(), frame.getTimestamp() / 1e6)); + } catch (Exception e) { + Log.e(TAG, "Failed reading frame: " + e); + } + } + }; + }; + + mMainLoopThread.setName("SimpleViewer MainLoop Thread"); + mMainLoopThread.start(); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (event.getAction() != MotionEvent.ACTION_DOWN) + return false; + + mViewStream = (mViewStream + 1) % 2; + mFrameView.clear(); + mStatusLine.setText(R.string.waiting_for_frames); + return true; + } + + + private void stop() { + mShouldRun = false; + + while (mMainLoopThread != null) { + try { + mMainLoopThread.join(); + mMainLoopThread = null; + break; + } catch (InterruptedException e) { + } + } + + if (mStream != null) { + mStream.stop(); + } + + if (mSecondStream != null) { + mSecondStream.stop(); + } + + mStatusLine.setText(R.string.waiting_for_frames); + } + + private void updateLabel(final String message) { + runOnUiThread(new Runnable() { + public void run() { + mStatusLine.setText(message); + } + }); + } + + @Override + public void onDeviceOpenFailed(String uri) { + Log.e(TAG, "Failed to open device " + uri); + mDeviceOpenPending = false; + showAlertAndExit("Failed to open device"); + } + + @Override + protected void onPause() { + Log.d(TAG, "onPause"); + + super.onPause(); + + // onPause() is called just before the USB permission dialog is opened, in which case, we don't + // want to shutdown OpenNI + if (mDeviceOpenPending) + return; + + stop(); + + if (mStream != null) { + mStream.destroy(); + mStream = null; + } + + if (mSecondStream != null) { + mSecondStream.destroy(); + mSecondStream = null; + } + + if (mDevice != null) { + mDevice.close(); + mDevice = null; + } + } +} diff --git a/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewer.java b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewer.java index 3e674d1b..71d39595 100644 --- a/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewer.java +++ b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewer.java @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ package org.openni.Samples.SimpleViewer; import java.awt.*; @@ -13,6 +33,7 @@ public class SimpleViewer extends Component float mHistogram[]; int[] mImagePixels; + int mMaxGray16Value = 0; VideoStream mVideoStream; VideoFrameRef mLastFrame; BufferedImage mBufferedImage; @@ -80,7 +101,6 @@ public synchronized void onFrameReady(VideoStream stream) { case SHIFT_9_2: case SHIFT_9_3: calcHist(frameData); - frameData.rewind(); int pos = 0; while(frameData.remaining() > 0) { int depth = (int)frameData.getShort() & 0xFFFF; @@ -99,6 +119,24 @@ public synchronized void onFrameReady(VideoStream stream) { pos++; } break; + case GRAY8: + pos = 0; + while (frameData.remaining() > 0) { + int pixel = (int)frameData.get() & 0xFF; + mImagePixels[pos] = 0xFF000000 | (pixel << 16) | (pixel << 8) | pixel; + pos++; + } + break; + case GRAY16: + calcMaxGray16Value(frameData); + pos = 0; + while (frameData.remaining() > 0) { + int pixel = (int)frameData.getShort() & 0xFFFF; + pixel = (int)(pixel * 255.0 / mMaxGray16Value); + mImagePixels[pos] = 0xFF000000 | (pixel << 16) | (pixel << 8) | pixel; + pos++; + } + break; default: // don't know how to draw mLastFrame.release(); @@ -136,5 +174,16 @@ private void calcHist(ByteBuffer depthBuffer) { mHistogram[i] = (int) (256 * (1.0f - (mHistogram[i] / (float) points))); } } + depthBuffer.rewind(); + } + + private void calcMaxGray16Value(ByteBuffer gray16Buffer) { + while (gray16Buffer.remaining() > 0) { + int pixel = (int)gray16Buffer.getShort() & 0xFFFF; + if (pixel > mMaxGray16Value) { + mMaxGray16Value = pixel; + } + } + gray16Buffer.rewind(); } } diff --git a/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewerApplication.java b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewerApplication.java index 2f52385f..032e5352 100755 --- a/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewerApplication.java +++ b/Samples/SimpleViewer.java/src/org/openni/Samples/SimpleViewer/SimpleViewerApplication.java @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ package org.openni.Samples.SimpleViewer; import org.openni.*; @@ -76,6 +96,11 @@ public void windowClosing(WindowEvent e) { mComboBoxStreams.addItem("Depth"); } + if (device.getSensorInfo(SensorType.IR) != null) { + mDeviceSensors.add(SensorType.IR); + mComboBoxStreams.addItem("IR"); + } + mComboBoxStreams.addItemListener(this); mComboBoxVideoModes.addItemListener(this); mViewer.setSize(800,600); @@ -128,6 +153,8 @@ void selectedStreamChanged() { case SHIFT_9_2: case SHIFT_9_3: case RGB888: + case GRAY8: + case GRAY16: mSupportedModes.add(mode); break; } @@ -154,6 +181,8 @@ private String pixelFormatToName(PixelFormat format) { case SHIFT_9_2: return "9.2"; case SHIFT_9_3: return "9.3"; case RGB888: return "RGB"; + case GRAY8: return "Gray8"; + case GRAY16: return "Gray16"; default: return "UNKNOWN"; } } @@ -188,14 +217,21 @@ void run() { public static void main(String s[]) { // initialize OpenNI OpenNI.initialize(); + + String uri; - List devicesInfo = OpenNI.enumerateDevices(); - if (devicesInfo.isEmpty()) { - JOptionPane.showMessageDialog(null, "No device is connected", "Error", JOptionPane.ERROR_MESSAGE); - return; + if (s.length > 0) { + uri = s[0]; + } else { + List devicesInfo = OpenNI.enumerateDevices(); + if (devicesInfo.isEmpty()) { + JOptionPane.showMessageDialog(null, "No device is connected", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + uri = devicesInfo.get(0).getUri(); } - Device device = Device.open(devicesInfo.get(0).getUri()); + Device device = Device.open(uri); final SimpleViewerApplication app = new SimpleViewerApplication(device); app.run(); diff --git a/Samples/SimpleViewer/SimpleViewer.vcxproj b/Samples/SimpleViewer/SimpleViewer.vcxproj index d693a1d2..22c594db 100644 --- a/Samples/SimpleViewer/SimpleViewer.vcxproj +++ b/Samples/SimpleViewer/SimpleViewer.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ Application true MultiByte + v120 Application true MultiByte + v120 Application false true MultiByte + v120 Application false true MultiByte + v120 @@ -136,6 +140,7 @@ glut32.lib;OpenNI2.lib $(OutDir);..\..\ThirdParty\GL true + false diff --git a/Samples/SimpleViewer/Viewer.h b/Samples/SimpleViewer/Viewer.h index b7db859d..8b3921d0 100644 --- a/Samples/SimpleViewer/Viewer.h +++ b/Samples/SimpleViewer/Viewer.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_SAMPLE_VIEWER_H_ -#define _ONI_SAMPLE_VIEWER_H_ +#ifndef VIEWER_H +#define VIEWER_H #include @@ -78,4 +78,4 @@ class SampleViewer }; -#endif // _ONI_SAMPLE_VIEWER_H_ +#endif // VIEWER_H diff --git a/Source/Core/Android.mk b/Source/Core/Android.mk index e212b010..9f2edb7f 100644 --- a/Source/Core/Android.mk +++ b/Source/Core/Android.mk @@ -17,34 +17,26 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +include $(LOCAL_PATH)/../../ThirdParty/PSCommon/BuildSystem/CommonAndroid.mk + # Sources MY_SRC_FILES := \ $(LOCAL_PATH)/*.cpp \ $(LOCAL_PATH)/../Drivers/OniFile/Formats/XnCodec.cpp \ $(LOCAL_PATH)/../Drivers/OniFile/Formats/XnStreamCompression.cpp -ifdef OPENNI2_ANDROID_NDK_BUILD - MY_SRC_FILES += $(LOCAL_PATH)/../../ThirdParty/LibJPEG/*.c \ -endif - MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) # C/CPP Flags -LOCAL_CFLAGS += $(OPENNI2_CFLAGS) -DOPENNI2_EXPORT +LOCAL_CFLAGS += -DOPENNI2_EXPORT # Includes LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/../../Include \ - $(LOCAL_PATH)/../../ThirdParty/PSCommon/XnLib/Include \ - $(LOCAL_PATH)/../Drivers/OniFile/Formats + $(LOCAL_PATH)/../Drivers/OniFile/Formats \ + $(LOCAL_PATH)/../Drivers/OniFile -ifdef OPENNI2_ANDROID_NDK_BUILD - LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ThirdParty/LibJPEG -else - LOCAL_C_INCLUDES += external/jpeg -endif - LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../Include # LD Flags @@ -52,16 +44,16 @@ LOCAL_LDFLAGS := -Wl,--export-dynamic # Dependencies LOCAL_STATIC_LIBRARIES := XnLib -LOCAL_SHARED_LIBRARIES := liblog libdl -ifdef OPENNI2_ANDROID_OS_BUILD +ifdef PS_OS_BUILD LOCAL_SHARED_LIBRARIES += libjpeg LOCAL_REQUIRED_MODULES = libPS1080 libOniFile -else - LOCAL_LDLIBS += -llog endif # Output LOCAL_MODULE := libOpenNI2 include $(BUILD_SHARED_LIBRARY) + +#include XnLib +include $(LOCAL_PATH)/../../ThirdParty/PSCommon/XnLib/Source/Android.mk diff --git a/Source/Core/Makefile b/Source/Core/Makefile index a3bb73f9..9a510b3b 100644 --- a/Source/Core/Makefile +++ b/Source/Core/Makefile @@ -6,6 +6,7 @@ INC_DIRS = \ ../../Include \ ../../ThirdParty/PSCommon/XnLib/Include \ ../Drivers/OniFile/Formats \ + ../Drivers/OniFile \ ../../ThirdParty/LibJPEG SRC_FILES = \ @@ -15,9 +16,15 @@ SRC_FILES = \ ../../ThirdParty/LibJPEG/*.c \ ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib - LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib + LDFLAGS += \ + -framework CoreFoundation \ + -framework IOKit endif LIB_NAME = OpenNI2 diff --git a/Source/Core/OniCommon.h b/Source/Core/OniCommon.h index 4908457d..2f0d97a9 100644 --- a/Source/Core/OniCommon.h +++ b/Source/Core/OniCommon.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_COMMON_H_ -#define _ONI_COMMON_H_ +#ifndef ONICOMMON_H +#define ONICOMMON_H #define ONI_NAMESPACE_IMPLEMENTATION_BEGIN namespace oni { namespace implementation { #define ONI_NAMESPACE_IMPLEMENTATION_END }} @@ -29,4 +29,4 @@ struct _OniFrameSync; typedef _OniFrameSync* OniFrameSyncHandle; -#endif // _ONI_COMMON_H_ \ No newline at end of file +#endif // ONICOMMON_H diff --git a/Source/Core/OniContext.cpp b/Source/Core/OniContext.cpp index 153c7c6e..a777cbc0 100644 --- a/Source/Core/OniContext.cpp +++ b/Source/Core/OniContext.cpp @@ -19,6 +19,7 @@ * * *****************************************************************************/ #include "OniContext.h" +#include "OniFileRecorder.h" #include "OniStreamFrameHolder.h" #include #include @@ -32,9 +33,10 @@ ONI_NAMESPACE_IMPLEMENTATION_BEGIN OniBool Context::s_valid = FALSE; -Context::Context() : m_errorLogger(xnl::ErrorLogger::GetInstance()), m_initializationCounter(0) +Context::Context() : m_errorLogger(xnl::ErrorLogger::GetInstance()), m_autoRecording(false), m_autoRecordingStarted(false), m_initializationCounter(0), m_lastFPSPrint(0) { - xnOSMemSet(m_overrideDevice, 0, XN_FILE_MAX_PATH); + m_overrideDevice[0] = '\0'; + m_driverRepo[0] = '\0'; } Context::~Context() @@ -42,14 +44,8 @@ Context::~Context() s_valid = FALSE; } -// Dummy function used only for taking its address for the sake of xnOSGetModulePathForProcAddress. -static void dummyFunctionToTakeAddress() {} - OniStatus Context::initialize() { - XnBool repositoryOverridden = FALSE; - XnChar repositoryFromINI[XN_FILE_MAX_PATH] = {0}; - m_initializationCounter++; if (m_initializationCounter > 1) { @@ -57,194 +53,264 @@ OniStatus Context::initialize() return ONI_STATUS_OK; } - XnStatus rc; - - XnChar strModulePath[XN_FILE_MAX_PATH]; - rc = xnOSGetModulePathForProcAddress(reinterpret_cast(&dummyFunctionToTakeAddress), strModulePath); + XnStatus rc = resolvePathToOpenNI(); if (rc != XN_STATUS_OK) { - m_errorLogger.Append("Couldn't get the OpenNI shared library module's path: %s", xnGetStatusString(rc)); return OniStatusFromXnStatus(rc); } - - XnChar strBaseDir[XN_FILE_MAX_PATH]; - rc = xnOSGetDirName(strModulePath, strBaseDir, XN_FILE_MAX_PATH); + + rc = configure(); if (rc != XN_STATUS_OK) { - // Very unlikely to happen, but just in case. - m_errorLogger.Append("Couldn't get the OpenNI shared library module's directory: %s", xnGetStatusString(rc)); return OniStatusFromXnStatus(rc); } s_valid = TRUE; - // Read configuration file + rc = loadLibraries(); + if (rc == XN_STATUS_OK) + { + m_errorLogger.Clear(); + } - XnChar strOniConfigurationFile[XN_FILE_MAX_PATH]; - XnBool configurationFileExists = FALSE; + return OniStatusFromXnStatus(rc); +} - // Search the module directory for OpenNI.ini. - xnOSStrCopy(strOniConfigurationFile, strBaseDir, XN_FILE_MAX_PATH); - rc = xnOSAppendFilePath(strOniConfigurationFile, ONI_CONFIGURATION_FILE, XN_FILE_MAX_PATH); - if (rc == XN_STATUS_OK) +// Dummy function used only for taking its address for the sake of xnOSGetModulePathForProcAddress. +static void dummyFunctionToTakeAddress() {} + +XnStatus Context::resolvePathToOpenNI() +{ + XnStatus rc = XN_STATUS_OK; + + XnChar strModulePath[XN_FILE_MAX_PATH]; + rc = xnOSGetModulePathForProcAddress(reinterpret_cast(&dummyFunctionToTakeAddress), strModulePath); + if (rc != XN_STATUS_OK) { - xnOSDoesFileExist(strOniConfigurationFile, &configurationFileExists); + m_errorLogger.Append("Couldn't get the OpenNI shared library module's path: %s", xnGetStatusString(rc)); + return rc; } -#ifdef ONI_PLATFORM_ANDROID_OS - xnLogSetMaskMinSeverity(XN_LOG_MASK_ALL, (XnLogSeverity)0); - xnLogSetAndroidOutput(TRUE); -#endif - - if (configurationFileExists) + rc = xnOSGetDirName(strModulePath, m_pathToOpenNI, sizeof(m_pathToOpenNI)); + if (rc != XN_STATUS_OK) { - // First, we should process the log related configuration as early as possible. + // Very unlikely to happen, but just in case. + m_errorLogger.Append("Couldn't get the OpenNI shared library module's directory: %s", xnGetStatusString(rc)); + return rc; + } - XnInt32 nValue; - XnChar strLogPath[XN_FILE_MAX_PATH] = {0}; + return XN_STATUS_OK; +} - //Test if log redirection is needed - rc = xnOSReadStringFromINI(strOniConfigurationFile, "Log", "LogPath", strLogPath, XN_FILE_MAX_PATH); - if (rc == XN_STATUS_OK) - { - rc = xnLogSetOutputFolder(strLogPath); - if (rc != XN_STATUS_OK) - { - xnLogWarning(XN_MASK_ONI_CONTEXT, "Failed to set log output folder: %s", xnGetStatusString(rc)); - } - else - { - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Log directory redirected to: %s", strLogPath); - } - } +XnStatus Context::resolveConfigurationFile(char* strOniConfigurationFile) +{ + XnStatus rc = XN_STATUS_OK; + XnBool bExists; - rc = xnOSReadIntFromINI(strOniConfigurationFile, "Log", "Verbosity", &nValue); - if (rc == XN_STATUS_OK) - { - xnLogSetMaskMinSeverity(XN_LOG_MASK_ALL, (XnLogSeverity)nValue); - } +#if XN_PLATFORM == XN_PLATFORM_ANDROID_ARM + // support for applications + xnOSGetApplicationFilesDir(strOniConfigurationFile, XN_FILE_MAX_PATH); + rc = xnOSAppendFilePath(strOniConfigurationFile, ONI_CONFIGURATION_FILE, XN_FILE_MAX_PATH); + XN_IS_STATUS_OK(rc); - rc = xnOSReadIntFromINI(strOniConfigurationFile, "Log", "LogToConsole", &nValue); - if (rc == XN_STATUS_OK) - { - xnLogSetConsoleOutput(nValue == 1); - } - - rc = xnOSReadIntFromINI(strOniConfigurationFile, "Log", "LogToFile", &nValue); - if (rc == XN_STATUS_OK) - { - xnLogSetFileOutput(nValue == 1); - } + xnOSDoesFileExist(strOniConfigurationFile, &bExists); - // Then, process the other device configurations. + if (!bExists) + { + // support for native use - search in current dir + rc = xnOSStrCopy(strOniConfigurationFile, ONI_CONFIGURATION_FILE, XN_FILE_MAX_PATH); + XN_IS_STATUS_OK(rc); + } - rc = xnOSReadStringFromINI(strOniConfigurationFile, "Device", "Override", m_overrideDevice, XN_FILE_MAX_PATH); - if (rc != XN_STATUS_OK) - { - xnLogVerbose(XN_MASK_ONI_CONTEXT, "No override device in configuration file"); - } +#else + xnOSStrCopy(strOniConfigurationFile, m_pathToOpenNI, XN_FILE_MAX_PATH); + rc = xnOSAppendFilePath(strOniConfigurationFile, ONI_CONFIGURATION_FILE, XN_FILE_MAX_PATH); + XN_IS_STATUS_OK(rc); +#endif - rc = xnOSReadStringFromINI(strOniConfigurationFile, "Drivers", "Repository", repositoryFromINI, XN_FILE_MAX_PATH); - if (rc == XN_STATUS_OK) - { - repositoryOverridden = TRUE; - } + xnOSDoesFileExist(strOniConfigurationFile, &bExists); + if (!bExists) + { + strOniConfigurationFile[0] = '\0'; + } + return XN_STATUS_OK; +} - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Configuration has been read from '%s'", strOniConfigurationFile); +XnStatus Context::configure() +{ + XnStatus nRetVal = XN_STATUS_OK; + + XnChar strOniConfigurationFile[XN_FILE_MAX_PATH]; + XnStatus rc = resolveConfigurationFile(strOniConfigurationFile); + if (rc != XN_STATUS_OK) + { + return OniStatusFromXnStatus(rc); } - else + +#ifdef ONI_PLATFORM_ANDROID_OS + xnLogSetMaskMinSeverity(XN_LOG_MASK_ALL, (XnLogSeverity)0); + xnLogSetAndroidOutput(TRUE); +#endif + + // First, we should process the log related configuration as early as possible. + rc = xnLogInitFromINIFile(strOniConfigurationFile, "Log"); + if (XN_STATUS_OK != rc) { - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Couldn't find configuration file '%s'", strOniConfigurationFile); + return ONI_STATUS_ERROR; } + // Now that log was configured, we can start issues some log entries xnLogVerbose(XN_MASK_ONI_CONTEXT, "OpenNI %s", ONI_VERSION_STRING); + if (strOniConfigurationFile[0] != '\0') + { + xnLogVerbose(XN_MASK_ONI_CONTEXT, "Configuration file found at '%s'", strOniConfigurationFile); + } - // Resolve the drive path based on the module's directory. - XnChar strDriverPath[XN_FILE_MAX_PATH]; - xnOSStrCopy(strDriverPath, strBaseDir, XN_FILE_MAX_PATH); + // Then, process the other device configurations. + rc = xnOSReadStringFromINI(strOniConfigurationFile, "Device", "Override", m_overrideDevice, sizeof(m_overrideDevice)); + if (rc == XN_STATUS_OK) + { + xnLogWarning(XN_MASK_ONI_CONTEXT, "Device will be overridden with '%s'", m_overrideDevice); + } - if (repositoryOverridden) + XnChar autoRecordingName[XN_FILE_MAX_PATH]; + rc = xnOSReadStringFromINI(strOniConfigurationFile, "Device", "RecordTo", autoRecordingName, XN_FILE_MAX_PATH); + if (rc == XN_STATUS_OK) { - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Extending the driver path by '%s', as configured in file '%s'", repositoryFromINI, strOniConfigurationFile); - rc = xnOSAppendFilePath(strDriverPath, repositoryFromINI, XN_FILE_MAX_PATH); + OniStatus oniRc = recorderOpen(autoRecordingName, &m_autoRecorder); + if (oniRc == ONI_STATUS_OK) + { + m_autoRecording = true; + } } - else + + XnChar strRepo[XN_FILE_MAX_PATH]; + strRepo[0] = '\0'; + +#if XN_PLATFORM != XN_PLATFORM_ANDROID_ARM + xnOSStrCopy(strRepo, ONI_DEFAULT_DRIVERS_REPOSITORY, sizeof(strRepo)); +#endif + + // check if repo was overridden + XnChar strTemp[XN_INI_MAX_LEN]; + rc = xnOSReadStringFromINI(strOniConfigurationFile, "Drivers", "Repository", strTemp, sizeof(strTemp)); + if (rc == XN_STATUS_OK) { - rc = xnOSAppendFilePath(strDriverPath, ONI_DEFAULT_DRIVERS_REPOSITORY, XN_FILE_MAX_PATH); + xnOSStrCopy(strRepo, strTemp, sizeof(strRepo)); } + rc = xnOSStrCopy(m_driverRepo, m_pathToOpenNI, sizeof(m_driverRepo)); + XN_IS_STATUS_OK(nRetVal); + rc = xnOSAppendFilePath(m_driverRepo, strRepo, sizeof(m_driverRepo)); if (rc != XN_STATUS_OK) { + xnLogError(XN_MASK_ONI_CONTEXT, "Driver path is too long!"); m_errorLogger.Append("The driver path gets too long"); - return OniStatusFromXnStatus(rc); + return rc; } - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Using '%s' as driver path", strDriverPath); - rc = loadLibraries(strDriverPath); +#if XN_PLATFORM == XN_PLATFORM_ANDROID_ARM + m_driversList.AddLast("libOniFile.so"); + m_driversList.AddLast("libPS1080.so"); + m_driversList.AddLast("libPSLink.so"); + m_driversList.AddLast("libSD.so"); +#endif + // check if driver list is overridden + XnChar strDriversList[2048]; + rc = xnOSReadStringFromINI(strOniConfigurationFile, "Drivers", "List", strDriversList, sizeof(strDriversList)); if (rc == XN_STATUS_OK) { - m_errorLogger.Clear(); + m_driversList.Clear(); + + // parse list + xnl::FileName driver; + int driverLen = 0; + + for (XnChar* c = strDriversList; ; ++c) + { + if (*c == ',' || *c == '\0') + { + driver[driverLen++] = '\0'; + rc = m_driversList.AddLast(driver); + XN_IS_STATUS_OK(rc); + driverLen = 0; + + if (*c == '\0') + break; + } + else + { + driver[driverLen++] = *c; + } + } } - return OniStatusFromXnStatus(rc); + return (XN_STATUS_OK); } -XnStatus Context::loadLibraries(const char* directoryName) + +XnStatus Context::loadLibraries() { XnStatus nRetVal; - // Get a file list of Xiron devices + xnLogVerbose(XN_MASK_ONI_CONTEXT, "Using '%s' as driver path", m_driverRepo); + + if (m_driversList.IsEmpty()) + { + // search repo for drivers + XnInt32 nFileCount = 0; + XnChar cpSearchString[XN_FILE_MAX_PATH] = ""; + + xnLogVerbose(XN_MASK_ONI_CONTEXT, "Looking for drivers at '%s'", m_driverRepo); - XnInt32 nFileCount = 0; - typedef XnChar FileName[XN_FILE_MAX_PATH]; - FileName* acsFileList = NULL; + // Build the search pattern string + XN_VALIDATE_STR_APPEND(cpSearchString, m_driverRepo, XN_FILE_MAX_PATH, nRetVal); + XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_DIR_SEP, XN_FILE_MAX_PATH, nRetVal); + XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_PREFIX, XN_FILE_MAX_PATH, nRetVal); + XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_ALL_WILDCARD, XN_FILE_MAX_PATH, nRetVal); + XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_POSTFIX, XN_FILE_MAX_PATH, nRetVal); -#if (ONI_PLATFORM != ONI_PLATFORM_ANDROID_ARM) - XnChar cpSearchString[XN_FILE_MAX_PATH] = ""; + nRetVal = xnOSCountFiles(cpSearchString, &nFileCount); + if (nRetVal != XN_STATUS_OK || nFileCount == 0) + { + xnLogError(XN_MASK_ONI_CONTEXT, "Found no drivers matching '%s'", cpSearchString); + m_errorLogger.Append("Found no files matching '%s'", cpSearchString); + return XN_STATUS_NO_MODULES_FOUND; + } - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Looking for drivers in drivers repository '%s'", directoryName); + nRetVal = m_driversList.SetSize(nFileCount); + XN_IS_STATUS_OK(nRetVal); - // Build the search pattern string - XN_VALIDATE_STR_APPEND(cpSearchString, directoryName, XN_FILE_MAX_PATH, nRetVal); - XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_DIR_SEP, XN_FILE_MAX_PATH, nRetVal); - XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_PREFIX, XN_FILE_MAX_PATH, nRetVal); - XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_ALL_WILDCARD, XN_FILE_MAX_PATH, nRetVal); - XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_POSTFIX, XN_FILE_MAX_PATH, nRetVal); + typedef XnChar MyFileName[XN_FILE_MAX_PATH]; + MyFileName* acsFileList = XN_NEW_ARR(MyFileName, nFileCount); - nRetVal = xnOSCountFiles(cpSearchString, &nFileCount); - if (nRetVal != XN_STATUS_OK || nFileCount == 0) - { - xnLogError(XN_MASK_ONI_CONTEXT, "Found no drivers matching '%s'", cpSearchString); - m_errorLogger.Append("Found no files matching '%s'", cpSearchString); - return XN_STATUS_NO_MODULES_FOUND; - } + nRetVal = xnOSGetFileList(cpSearchString, NULL, acsFileList, nFileCount, &nFileCount); + XN_IS_STATUS_OK(nRetVal); - acsFileList = XN_NEW_ARR(FileName, nFileCount); - nRetVal = xnOSGetFileList(cpSearchString, NULL, acsFileList, nFileCount, &nFileCount); -#else - // Android - nFileCount = 3; - acsFileList = XN_NEW_ARR(FileName, nFileCount); - strcpy(acsFileList[0], "libPS1080.so"); - strcpy(acsFileList[1], "libOniFile.so"); - strcpy(acsFileList[2], "libPSLink.so"); -#endif + for (int i = 0; i < nFileCount; ++i) + { + m_driversList[i] = acsFileList[i]; + } + + XN_DELETE_ARR(acsFileList); + } // Save directory XnChar workingDir[XN_FILE_MAX_PATH]; xnOSGetCurrentDir(workingDir, XN_FILE_MAX_PATH); // Change directory - xnOSSetCurrentDir(directoryName); + xnOSSetCurrentDir(m_driverRepo); - for (int i = 0; i < nFileCount; ++i) + for (XnUInt32 i = 0; i < m_driversList.GetSize(); ++i) { - DeviceDriver* pDeviceDriver = XN_NEW(DeviceDriver, acsFileList[i], m_frameManager, m_errorLogger); + xnLogVerbose(XN_MASK_ONI_CONTEXT, "Loading device driver '%s'...", m_driversList[i].getData()); + DeviceDriver* pDeviceDriver = XN_NEW(DeviceDriver, m_driversList[i].getData(), m_frameManager, m_errorLogger); if (pDeviceDriver == NULL || !pDeviceDriver->isValid()) { - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Couldn't use file '%s' as a device driver", acsFileList[i]); - m_errorLogger.Append("Couldn't understand file '%s' as a device driver", acsFileList[i]); + xnLogWarning(XN_MASK_ONI_CONTEXT, "Couldn't use file '%s' as a device driver", m_driversList[i].getData()); + m_errorLogger.Append("Couldn't understand file '%s' as a device driver", m_driversList[i].getData()); XN_DELETE(pDeviceDriver); continue; } @@ -254,8 +320,8 @@ XnStatus Context::loadLibraries(const char* directoryName) pDeviceDriver->registerDeviceStateChangedCallback(deviceDriver_DeviceStateChanged, this, dummy); if (!pDeviceDriver->initialize()) { - xnLogVerbose(XN_MASK_ONI_CONTEXT, "Couldn't use file '%s' as a device driver", acsFileList[i]); - m_errorLogger.Append("Couldn't initialize device driver from file '%s'", acsFileList[i]); + xnLogVerbose(XN_MASK_ONI_CONTEXT, "Couldn't use file '%s' as a device driver", m_driversList[i].getData()); + m_errorLogger.Append("Couldn't initialize device driver from file '%s'", m_driversList[i].getData()); XN_DELETE(pDeviceDriver); continue; } @@ -270,20 +336,19 @@ XnStatus Context::loadLibraries(const char* directoryName) if (m_deviceDrivers.Size() == 0) { xnLogError(XN_MASK_ONI_CONTEXT, "Found no valid drivers"); - m_errorLogger.Append("Found no valid drivers in '%s'", directoryName); + m_errorLogger.Append("Found no valid drivers"); return XN_STATUS_NO_MODULES_FOUND; } - XN_DELETE_ARR(acsFileList); - return XN_STATUS_OK; } + void Context::shutdown() { --m_initializationCounter; if (m_initializationCounter > 0) { - xnLogInfo(XN_MASK_ONI_CONTEXT, "Shutdown: still need %d more shutdown calls (to match initializations)", m_initializationCounter); + xnLogVerbose(XN_MASK_ONI_CONTEXT, "Shutdown: still need %d more shutdown calls (to match initializations)", m_initializationCounter); return; } if (!s_valid) @@ -327,6 +392,12 @@ void Context::shutdown() m_cs.Unlock(); + m_overrideDevice[0] = '\0'; + m_driverRepo[0] = '\0'; + m_pathToOpenNI[0] = '\0'; + m_driversList.Clear(); + + xnLogVerbose(XN_MASK_ONI_CONTEXT, "Shutdown: successful."); xnLogClose(); } @@ -543,6 +614,13 @@ OniStatus Context::createStream(OniDeviceHandle device, OniSensorType sensorType m_streams.AddLast(pMyStream); m_cs.Unlock(); + if (m_autoRecording) + { + m_streamsToAutoRecord.Lock(); + m_streamsToAutoRecord.AddLast(*pStream); + m_streamsToAutoRecord.Unlock(); + } + return ONI_STATUS_OK; } @@ -555,6 +633,13 @@ OniStatus Context::streamDestroy(OniStreamHandle stream) return ONI_STATUS_OK; } + if (m_autoRecording) + { + m_streamsToAutoRecord.Lock(); + m_streamsToAutoRecord.Remove(stream); + m_streamsToAutoRecord.Unlock(); + } + VideoStream* pStream = stream->pStream; rc = streamDestroy(pStream); if (rc == ONI_STATUS_OK) @@ -651,6 +736,19 @@ void Context::frameAddRef(OniFrame* pFrame) OniStatus Context::waitForStreams(OniStreamHandle* pStreams, int streamCount, int* pStreamIndex, int timeout) { + if (m_autoRecording && !m_autoRecordingStarted) + { + m_streamsToAutoRecord.Lock(); + for (xnl::List::ConstIterator iter = m_streamsToAutoRecord.Begin(); iter != m_streamsToAutoRecord.End(); ++iter) + { + m_autoRecorder->pRecorder->attachStream(*(*iter)->pStream, true); + } + m_streamsToAutoRecord.Unlock(); + + m_autoRecorder->pRecorder->start(); + m_autoRecordingStarted = true; + } + static const int MAX_WAITED_STREAMS = 50; Device* deviceList[MAX_WAITED_STREAMS]; VideoStream* streamsList[MAX_WAITED_STREAMS]; @@ -934,7 +1032,9 @@ OniStatus Context::recorderOpen(const char* fileName, OniRecorderHandle* pRecord return ONI_STATUS_ERROR; } // Create the recorder itself. - if (NULL == ((*pRecorder)->pRecorder = XN_NEW(Recorder, m_frameManager, m_errorLogger, *pRecorder))) + (*pRecorder)->pRecorder = XN_NEW(FileRecorder, m_frameManager, m_errorLogger, *pRecorder); + + if (NULL == (*pRecorder)->pRecorder) { XN_DELETE(*pRecorder); return ONI_STATUS_ERROR; @@ -1027,11 +1127,40 @@ void Context::addToLogger(const XnChar* cpFormat, ...) void Context::onNewFrame() { + XnUInt64 nNow; + xnOSGetHighResTimeStamp(&nNow); + nNow /= 1000000; + m_cs.Lock(); for (xnl::Hash::Iterator it = m_waitingThreads.Begin(); it != m_waitingThreads.End(); ++it) { xnOSSetEvent(it->Value()); } + + if (nNow != m_lastFPSPrint) + { + XnChar fpsInfo[2048] = ""; + XnUInt32 written = 0; + XnUInt32 writtenNow = 0; + xnOSStrFormat(fpsInfo + written, sizeof(fpsInfo) - written, &writtenNow, "[FPS] "); + written += writtenNow; + + for (xnl::List::Iterator it = m_streams.Begin(); it != m_streams.End(); ++it) + { + VideoStream* pStream = *it; + if (written > sizeof(fpsInfo)) + { + break; + } + + xnOSStrFormat(fpsInfo + written, sizeof(fpsInfo) - written, &writtenNow, "%s: %.2f ", + pStream->getSensorName(), pStream->calcCurrentFPS()); + written += writtenNow; + } + + xnLogVerbose(XN_MASK_ONI_CONTEXT, "%s", fpsInfo); + m_lastFPSPrint = nNow; + } m_cs.Unlock(); } diff --git a/Source/Core/OniContext.h b/Source/Core/OniContext.h index d9ee2afb..10b13e5b 100644 --- a/Source/Core/OniContext.h +++ b/Source/Core/OniContext.h @@ -18,6 +18,9 @@ * limitations under the License. * * * *****************************************************************************/ +#ifndef ONICONTEXT_H +#define ONICONTEXT_H + #include "OniStream.h" #include "OniDevice.h" #include "OniSyncedStreamsFrameHolder.h" @@ -25,12 +28,14 @@ #include "OniRecorder.h" #include "OniFrameManager.h" -#include "XnList.h" -#include "XnHash.h" -#include "XnEvent.h" #include "OniDriverHandler.h" #include "OniCommon.h" +#include +#include +#include +#include + struct _OniDevice { oni::implementation::Device* pDevice; @@ -112,7 +117,10 @@ class Context Context(const Context& other); Context& operator=(const Context&other); - XnStatus loadLibraries(const char* directoryName); + XnStatus resolvePathToOpenNI(); + XnStatus configure(); + XnStatus resolveConfigurationFile(char* strConfigurationFile); + XnStatus loadLibraries(); void onNewFrame(); XN_EVENT_HANDLE getThreadEvent(); static void XN_CALLBACK_TYPE newFrameCallback(void* pCookie); @@ -130,13 +138,24 @@ class Context xnl::List m_streams; xnl::List m_recorders; + xnl::Lockable > m_streamsToAutoRecord; + XnBool m_autoRecording; + XnBool m_autoRecordingStarted; + OniRecorderHandle m_autoRecorder; + xnl::Hash m_waitingThreads; xnl::CriticalSection m_cs; + char m_pathToOpenNI[XN_FILE_MAX_PATH]; char m_overrideDevice[XN_FILE_MAX_PATH]; + char m_driverRepo[XN_FILE_MAX_PATH]; + xnl::Array m_driversList; int m_initializationCounter; + XnUInt64 m_lastFPSPrint; }; ONI_NAMESPACE_IMPLEMENTATION_END + +#endif // ONICONTEXT_H diff --git a/Source/Core/OniDataRecords.h b/Source/Core/OniDataRecords.h index 0c018294..17a23f0a 100644 --- a/Source/Core/OniDataRecords.h +++ b/Source/Core/OniDataRecords.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_IMPL_DATA_RECORDS_H_ -#define _ONI_IMPL_DATA_RECORDS_H_ 1 +#ifndef ONIDATARECORDS_H +#define ONIDATARECORDS_H 1 #include "XnOS.h" #include "XnList.h" @@ -244,4 +244,4 @@ class RecordAssembler #endif ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_IMPL_DATA_RECORDS_H_ +#endif // ONIDATARECORDS_H diff --git a/Source/Core/OniDebug.h b/Source/Core/OniDebug.h index 9df2dd7e..b5fa1b30 100644 --- a/Source/Core/OniDebug.h +++ b/Source/Core/OniDebug.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_DEBUG_H_ -#define _ONI_DEBUG_H_ +#ifndef ONIDEBUG_H +#define ONIDEBUG_H namespace oni { @@ -167,4 +167,4 @@ class Debug -#endif \ No newline at end of file +#endif // ONIDEBUG_H diff --git a/Source/Core/OniDevice.cpp b/Source/Core/OniDevice.cpp index 24511f0b..ac9f4498 100644 --- a/Source/Core/OniDevice.cpp +++ b/Source/Core/OniDevice.cpp @@ -77,6 +77,13 @@ OniStatus Device::close() if (m_openCount == 0) { + while(m_streams.Begin() != m_streams.End()) + { + VideoStream* pStream = *m_streams.Begin(); + pStream->stop(); + m_streams.Remove(pStream); + } + for (int i = 0; i < MAX_SENSORS_PER_DEVICE; ++i) { if (m_sensors[i] != NULL) diff --git a/Source/Core/OniDevice.h b/Source/Core/OniDevice.h index e76294c6..6419f743 100644 --- a/Source/Core/OniDevice.h +++ b/Source/Core/OniDevice.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_IMPL_DEVICE_H_ -#define _ONI_IMPL_DEVICE_H_ +#ifndef ONIDEVICE_H +#define ONIDEVICE_H #include "OniDriverHandler.h" #include "OniFrameManager.h" @@ -104,4 +104,4 @@ class Device ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_IMP_DEVICE_H_ +#endif // ONIDEVICE_H diff --git a/Source/Core/OniDeviceDriver.h b/Source/Core/OniDeviceDriver.h index 7423e263..6c532b57 100644 --- a/Source/Core/OniDeviceDriver.h +++ b/Source/Core/OniDeviceDriver.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_IMPL_DEVICE_DRIVER_H_ -#define _ONI_IMPL_DEVICE_DRIVER_H_ +#ifndef ONIDEVICEDRIVER_H +#define ONIDEVICEDRIVER_H #include "OniDriverHandler.h" #include "OniFrameManager.h" @@ -83,4 +83,4 @@ class DeviceDriver ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_IMPL_DEVICE_DRIVER_H_ \ No newline at end of file +#endif // ONIDEVICEDRIVER_H diff --git a/Source/Core/OniDriverHandler.h b/Source/Core/OniDriverHandler.h index be23d449..fd96f0d1 100644 --- a/Source/Core/OniDriverHandler.h +++ b/Source/Core/OniDriverHandler.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _LIBRARY_HANDLER_H_ -#define _LIBRARY_HANDLER_H_ +#ifndef ONIDRIVERHANDLER_H +#define ONIDRIVERHANDLER_H #include "OniCAPI.h" #include "OniCTypes.h" @@ -258,4 +258,4 @@ class DriverHandler ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _LIBRARY_HANDLER_H_ +#endif // ONIDRIVERHANDLER_H diff --git a/Source/Core/OniDriverServices.h b/Source/Core/OniDriverServices.h index 6710df78..8a65e18e 100644 --- a/Source/Core/OniDriverServices.h +++ b/Source/Core/OniDriverServices.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_DRIVER_SERVICES_H_ -#define _ONI_DRIVER_SERVICES_H_ +#ifndef ONIDRIVERSERVICES_H +#define ONIDRIVERSERVICES_H #include "XnErrorLogger.h" @@ -40,4 +40,4 @@ class DriverServices ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_DRIVER_SERVICES_H_ \ No newline at end of file +#endif // ONIDRIVERSERVICES_H diff --git a/Source/Core/OniFileRecorder.cpp b/Source/Core/OniFileRecorder.cpp new file mode 100644 index 00000000..55d16810 --- /dev/null +++ b/Source/Core/OniFileRecorder.cpp @@ -0,0 +1,1106 @@ +/***************************************************************************** +* * +* 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 "OniFileRecorder.h" + +#include "XnLockGuard.h" + +#include "OniContext.h" +#include "OniProperties.h" +#include "PS1080.h" +#include "PSLink.h" +#include "FileProperties.h" + +ONI_NAMESPACE_IMPLEMENTATION_BEGIN + +// NOTE: XnLib does not define UINT*_C like macros for some reason... +#define XN_UINT64_C(x) ((x) + (XN_MAX_UINT64 - XN_MAX_UINT64)) +#define XN_UINT32_C(x) ((x) + (XN_MAX_UINT32 - XN_MAX_UINT32)) + +namespace { + +enum PropertyType +{ + PROPERTY_TYPE_GENERAL, + PROPERTY_TYPE_INTEGER, + PROPERTY_TYPE_REAL +}; + +const struct PropertyTable { + XnUInt32 propertyId; + const char* propertyName; + PropertyType propertyType; +} propertyTable[] = { + // PS1080 Properties + { XN_STREAM_PROPERTY_INPUT_FORMAT, "InputFormat" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_CROPPING_MODE, "CroppingMode" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED, "WhiteBalancedEnabled", PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_GAIN, "Gain" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_HOLE_FILTER, "HoleFilter" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_REGISTRATION_TYPE, "RegistrationType" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_AGC_BIN, "AGCBin" , PROPERTY_TYPE_GENERAL }, + { XN_STREAM_PROPERTY_CONST_SHIFT, "ConstShift" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR, "PixelSizeFactor" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_MAX_SHIFT, "MaxShift" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_PARAM_COEFF, "ParamCoeff" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_SHIFT_SCALE, "ShiftScale" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_S2D_TABLE, "S2D" , PROPERTY_TYPE_GENERAL }, + { XN_STREAM_PROPERTY_D2S_TABLE, "D2S" , PROPERTY_TYPE_GENERAL }, + { XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, "ZPD" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE, "ZPPS" , PROPERTY_TYPE_REAL }, + { XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE, "LDDIS" , PROPERTY_TYPE_REAL }, + { XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE, "DCRCDIS" , PROPERTY_TYPE_REAL }, + { XN_STREAM_PROPERTY_CLOSE_RANGE, "CloseRange" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_FAST_ZOOM_CROP, "FastZoomCrop" , PROPERTY_TYPE_INTEGER }, + { XN_STREAM_PROPERTY_PIXEL_REGISTRATION, "PixelRegistration" , PROPERTY_TYPE_GENERAL }, + // PSLink Properties + { LINK_PROP_MAX_SHIFT, "MaxShift", PROPERTY_TYPE_INTEGER}, + { LINK_PROP_ZERO_PLANE_DISTANCE, "ZPD", PROPERTY_TYPE_INTEGER}, + { LINK_PROP_CONST_SHIFT, "ConstShift", PROPERTY_TYPE_INTEGER}, + { LINK_PROP_PARAM_COEFF, "ParamCoeff", PROPERTY_TYPE_INTEGER}, + { LINK_PROP_SHIFT_SCALE, "ShiftScale", PROPERTY_TYPE_INTEGER}, + { LINK_PROP_ZERO_PLANE_PIXEL_SIZE, "ZPPS", PROPERTY_TYPE_REAL}, + { LINK_PROP_EMITTER_DEPTH_CMOS_DISTANCE, "LDDIS", PROPERTY_TYPE_REAL}, + { LINK_PROP_SHIFT_TO_DEPTH_TABLE, "S2D", PROPERTY_TYPE_GENERAL}, + { LINK_PROP_DEPTH_TO_SHIFT_TABLE, "D2S", PROPERTY_TYPE_GENERAL}, + // File Properties + { ONI_FILE_PROPERTY_ORIGINAL_DEVICE, "oniOriginalDevice", PROPERTY_TYPE_GENERAL} +}; + +const XnSizeT propertyTableItemsCount = sizeof(propertyTable) / sizeof(propertyTable[0]); + +} // namespace + +/** + * Is used by Recorder to make it possible to undo failed records. + * + * The usage pattern is: + * + * void Recorder::YourMethod() { + * // Create an undo point. + * Memento undoPoint(this); + * + * // Emit records here. If anything goes wrong - just return from this + * // method. + * + * // If anything went okay, release the undo point, so that nothing will + * // be undone. + * undoPoint.Release(); + * } + * + */ +class FileRecorder::Memento +{ +public: + /** + * Creates a Memento for the current state of the given Recorder. + */ + Memento(FileRecorder* pRecorder) + : m_pRecorder(pRecorder), m_offset(XN_UINT64_C(0)) + { + Reuse(); + } + + /** + * Destroys the Memento and reverts the Recorder back to the remembered state. + * + * @note The undo action will not be done if you have released the Memento. + */ + ~Memento() + { + if (m_needRollback) + { + Undo(); + } + } + + /** + * Releases the Memento. A released memento will not undo. + */ + void Release() + { + m_needRollback = false; + } + + /** + * ReUses the Memento. it will function like a brand-new one. + */ + void Reuse() + { + m_needRollback = true; + + XnStatus status = xnOSTellFile64(m_pRecorder->m_file, &m_offset); + if (status != XN_STATUS_OK) + { + m_pRecorder = NULL; + } + } + + /** + * Explicitly undo emits. Reverts the Recorder back to the remembered state. + */ + void Undo() + { + if (m_pRecorder != NULL) + { + xnOSSeekFile64(m_pRecorder->m_file, XN_OS_SEEK_SET, m_offset); + } + } + + /** + * An easy way to get the current position of the file. (and save for later use) + */ + XnUInt64 GetPosition() + { + return m_offset; + } + + /** + * An easey way to get the current position of the file. (for later use) + */ + void SetPosition(XnUInt64 pos) + { + if (m_pRecorder != NULL) + { + xnOSSeekFile64(m_pRecorder->m_file, XN_OS_SEEK_SET, pos); + } + } + +private: + FileRecorder* m_pRecorder; + XnUInt64 m_offset; + XnBool m_needRollback; +}; + +FileRecorder::FileRecorder(FrameManager& frameManager, xnl::ErrorLogger& errorLogger, OniRecorderHandle handle) : + Recorder(handle), + m_frameManager(frameManager), + m_errorLogger(errorLogger), + m_maxId(0), + m_configurationId(0), + m_propertyPriority(ms_priorityNormal), + m_file(XN_INVALID_FILE_HANDLE) +{ +} + +FileRecorder::~FileRecorder() +{ + stop(); + detachAllStreams(); + send(Message::MESSAGE_TERMINATE); + xnOSWaitForThreadExit(m_thread, XN_WAIT_INFINITE); + xnOSCloseThread(&m_thread); + if (NULL != m_handle) + { + m_handle->pRecorder = NULL; + } +} + +OniStatus FileRecorder::initialize(const char* fileName) +{ + m_fileName = fileName; + + // Probe if we can actually open the file. + XN_FILE_HANDLE fileHandle = XN_INVALID_FILE_HANDLE; + XnStatus status = xnOSOpenFile( + /* file name = */ fileName, + /* open flags = */ XN_OS_FILE_WRITE | XN_OS_FILE_TRUNCATE, + /* out handle = */ &fileHandle); + if (XN_STATUS_OK != status) + { + return ONI_STATUS_ERROR; + } + xnOSCloseFile(&fileHandle); + + m_assembler.initialize(); + + status = xnOSCreateThread(threadMain, this, &m_thread); + if (XN_STATUS_OK != status) + { + return ONI_STATUS_ERROR; + } + + send(Message::MESSAGE_INITIALIZE); + return ONI_STATUS_OK; +} + +OniStatus FileRecorder::attachStream(VideoStream& stream, OniBool allowLossyCompression) +{ + OniStatus rc = Recorder::attachStream(stream, allowLossyCompression); + if (rc == ONI_STATUS_OK) + { + VideoStream* pStream = &stream; + xnl::LockGuard guard(m_streams); + m_streams[pStream].nodeId = ++m_maxId; + m_streams[pStream].pCodec = NULL; + m_streams[pStream].frameId = 0; + m_streams[pStream].allowLossyCompression = allowLossyCompression; + m_streams[pStream].frameId = 0; + m_streams[pStream].lastOutputTimestamp = 0; + m_streams[pStream].lastInputTimestamp = 0; + m_streams[pStream].lastNewDataRecordPosition = 0; + m_streams[pStream].dataIndex.Clear(); + send(Message::MESSAGE_ATTACH, pStream); + } + + return rc; +} + +OniStatus FileRecorder::detachStream(VideoStream& stream) +{ + OniStatus rc = Recorder::detachStream(stream); + if (rc == ONI_STATUS_OK) + { + xnl::LockGuard guard(m_streams); + VideoStream* pStream = &stream; + send(Message::MESSAGE_DETACH, pStream); + } + + return rc; +} + +OniStatus FileRecorder::start() +{ + Recorder::start(); + send(Message::MESSAGE_START); + return ONI_STATUS_OK; +} + +OniStatus FileRecorder::record(VideoStream& stream, OniFrame& aFrame) +{ + if (!m_started) + { + return ONI_STATUS_ERROR; + } + xnl::LockGuard< AttachedStreams > guard(m_streams); + VideoStream* pStream = &stream; + if (m_streams.Find(pStream) == m_streams.End()) + { + return ONI_STATUS_BAD_PARAMETER; + } + OniFrame* pFrame = &aFrame; + m_frameManager.addRef(pFrame); + send(Message::MESSAGE_RECORD, pStream, pFrame); + return ONI_STATUS_OK; +} + +OniStatus FileRecorder::recordStreamProperty( + VideoStream& stream, + int propertyId, + const void* pData, + int dataSize) +{ + xnl::LockGuard< AttachedStreams > guard(m_streams); + VideoStream* pStream = &stream; + if (m_streams.Find(pStream) == m_streams.End()) + { + return ONI_STATUS_BAD_PARAMETER; + } + // The original pData will not be valid after this function ends. + // Free this pointer when soon after handling the PropertyMessage! + void *newPtr = xnOSMalloc(dataSize); + xnOSMemCopy(newPtr, pData, dataSize); + send(Message::MESSAGE_RECORDPROPERTY, pStream, newPtr, propertyId, dataSize, m_propertyPriority); + return ONI_STATUS_OK; +} + +XN_THREAD_PROC FileRecorder::threadMain(XN_THREAD_PARAM pThreadParam) +{ + FileRecorder* pSelf = reinterpret_cast(pThreadParam); + if (NULL != pSelf) + { + pSelf->m_running = TRUE; + while (pSelf->m_running) + { + pSelf->messagePump(); + } + } + XN_THREAD_PROC_RETURN(XN_STATUS_OK); +} + +void FileRecorder::messagePump() +{ + XnStatus nRetVal = XN_STATUS_OK; + Message msg = { Message::MESSAGE_NO_OPERATION, 0, NULL, {NULL}, 0, 0 }; + + { + xnl::LockGuard guard(m_queue); + nRetVal = m_queue.Pop(msg); + } + + if (XN_STATUS_OK == nRetVal) + { + switch (msg.type) + { + case Message::MESSAGE_INITIALIZE: + { + onInitialize(); + } + break; + case Message::MESSAGE_TERMINATE: + { + onTerminate(); + m_running = FALSE; + } + break; + case Message::MESSAGE_ATTACH: + { + xnl::LockGuard streamsGuard(m_streams); + AttachedStreams::Iterator i = m_streams.Find(msg.pStream); + if (i != m_streams.End()) + { + onAttach(i->Value().nodeId, msg.pStream); + } + } + break; + case Message::MESSAGE_DETACH: + { + xnl::LockGuard streamsGuard(m_streams); + AttachedStreams::Iterator i = m_streams.Find(msg.pStream); + if (i != m_streams.End()) + { + onDetach(i->Value().nodeId); + XN_DELETE(m_streams[msg.pStream].pCodec); + m_streams.Remove(msg.pStream); + } + } + break; + case Message::MESSAGE_START: + { + xnl::LockGuard streamsGuard(m_streams); + for (AttachedStreams::Iterator + i = m_streams.Begin(), + e = m_streams.End(); + i != e; ++i) + { + onStart(i->Value().nodeId); + } + m_started = true; + } + break; + case Message::MESSAGE_RECORD: + { + xnl::LockGuard streamsGuard(m_streams); + AttachedStreams::Iterator i = m_streams.Find(msg.pStream); + if (i != m_streams.End()) + { + XnCodecBase* pCodec = m_streams[msg.pStream].pCodec; + XnUInt32 frameId = ++m_frameIds[msg.pStream]; + ++m_streams[msg.pStream].frameId; + XnUInt64 timestamp = 0; + if (frameId > 1) + { + timestamp = m_streams[msg.pStream].lastOutputTimestamp + (msg.pFrame->timestamp - m_streams[msg.pStream].lastInputTimestamp); + } + m_streams[msg.pStream].lastInputTimestamp = msg.pFrame->timestamp; + m_streams[msg.pStream].lastOutputTimestamp = timestamp; + onRecord(i->Value().nodeId, pCodec, msg.pFrame, frameId, timestamp); + m_frameManager.release(msg.pFrame); + } + } + break; + case Message::MESSAGE_RECORDPROPERTY: + { + xnl::LockGuard streamsGuard(m_streams); + AttachedStreams::Iterator i = m_streams.Find(msg.pStream); + if (i != m_streams.End()) + { + onRecordProperty( + i->Value().nodeId, + msg.propertyId, + msg.pData, + msg.dataSize); + } + // free the temporary buffer allocated earlier + xnOSFree((void*)msg.pData); + } + break; + default: + ; + } + } +} + +void FileRecorder::send( + Message::Type type, + VideoStream* pStream, + const void* pData, + XnUInt32 propertyId, + XnSizeT dataSize, + int priority) +{ + Message msg = + { + type, + pStream != NULL ? m_streams[pStream].nodeId : 0, + pStream, + {pData}, + propertyId, + dataSize + }; + xnl::LockGuard guard(m_queue); + m_queue.Push(msg, priority); +} + +void FileRecorder::onInitialize() +{ + XnStatus status = xnOSOpenFile( + /* file name = */ m_fileName.Data(), + /* open flags = */ XN_OS_FILE_WRITE | XN_OS_FILE_TRUNCATE, + /* out handle = */ &m_file); + + if (XN_STATUS_OK == status) + { + FileHeaderData fileHeader = + { + /* identity = */ { 'N', 'I', '1', '0' }, + /* version = */ { 1, 0, 1, 0 }, + /* maxTimeStamp = */ XN_MAX_UINT64, + /* maxNodeId = */ m_maxId, + }; + m_fileHeader = fileHeader; + xnOSWriteFile(m_file, &m_fileHeader, sizeof(m_fileHeader)); + } +} + +// A handy macro, that makes code more readable. +// Usage: +// +// void Recorder::YourMethod() { +// Memento undoPoint(this); +// EMIT(RECORD_END()) /* #1 */ +// EMIT(RECORD_END()) /* #2 */ +// undoPoint.Release(); +// } +// +// This will safely emit RECORD_END into the file, if either of (#1 or #2) +// expressions fail, the undoPoint will revert the file to the state, prior +// to YourMethod execution. +// +#define EMIT(expr) \ + if (ONI_STATUS_OK == (m_assembler.emit_##expr)) \ + { \ + if (ONI_STATUS_OK != m_assembler.serialize(m_file)) \ + { \ + return; \ + } \ + } \ + else \ + { \ + return; \ + } + +#define FIND_ATTACHED_STREAM_INFO(nodeId) \ + AttachedStreamInfo *pInfo = NULL; \ + xnl::LockGuard guard(m_streams); \ + for (AttachedStreams::Iterator \ + i = m_streams.Begin(), e = m_streams.End(); \ + i != e; \ + ++i) \ + { \ + if(i->Value().nodeId == nodeId) \ + { \ + pInfo = &(i->Value()); \ + break; \ + } \ + } + +XnUInt64 FileRecorder::getLastPropertyRecordPos(XnUInt32 nodeId, const char *propName, XnUInt64 newRecordPos) +{ + XnUInt64 pos = 0; + FIND_ATTACHED_STREAM_INFO(nodeId) + if (!pInfo) return 0; + + if (pInfo->lastPropertyRecordPosition.Find(propName) != pInfo->lastPropertyRecordPosition.End()) + { + pos = pInfo->lastPropertyRecordPosition[propName]; + } + pInfo->lastPropertyRecordPosition[propName] = newRecordPos; + return pos; +} + +void FileRecorder::onTerminate() +{ + // Truncate the file to it's last offset, so that undone records + // will not be serialized. + XnUInt64 truncationOffset = XN_UINT64_C(0); + if (XN_STATUS_OK == xnOSTellFile64(m_file, &truncationOffset)) + { + xnOSTruncateFile64(m_file, truncationOffset); + } + + Memento undoPoint(this); + EMIT(RECORD_END()) + undoPoint.Release(); + + // The file header needs being patched, because its maxNodeId field has become + // irrelevant by now. + m_fileHeader.maxNodeId = m_maxId; + xnOSSeekFile64(m_file, XN_OS_SEEK_SET, XN_UINT64_C(0)); + xnOSWriteFile(m_file, &m_fileHeader, sizeof(m_fileHeader)); + + xnOSCloseFile(&m_file); + m_file = XN_INVALID_FILE_HANDLE; +} + +typedef enum XnPixelFormat +{ + XN_PIXEL_FORMAT_RGB24 = 1, + XN_PIXEL_FORMAT_YUV422 = 2, + XN_PIXEL_FORMAT_GRAYSCALE_8_BIT = 3, + XN_PIXEL_FORMAT_GRAYSCALE_16_BIT = 4, + XN_PIXEL_FORMAT_MJPEG = 5, +} XnPixelFormat; + +typedef struct XnSupportedPixelFormats +{ + XnBool m_bRGB24 : 1; + XnBool m_bYUV422 : 1; + XnBool m_bGrayscale8Bit : 1; + XnBool m_bGrayscale16Bit : 1; + XnBool m_bMJPEG : 1; + XnUInt m_nPadding : 3; + XnUInt m_nReserved : 24; +} XnSupportedPixelFormats; + +XnPixelFormat toXnPixelFormat(OniPixelFormat oniFormat) +{ + switch(oniFormat) + { + // Depth + case ONI_PIXEL_FORMAT_DEPTH_1_MM: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; + case ONI_PIXEL_FORMAT_DEPTH_100_UM: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; + case ONI_PIXEL_FORMAT_SHIFT_9_2: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; + case ONI_PIXEL_FORMAT_SHIFT_9_3: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; + + // Color + case ONI_PIXEL_FORMAT_RGB888: return XN_PIXEL_FORMAT_RGB24; + case ONI_PIXEL_FORMAT_YUV422: return XN_PIXEL_FORMAT_YUV422; + case ONI_PIXEL_FORMAT_GRAY8: return XN_PIXEL_FORMAT_GRAYSCALE_8_BIT; + case ONI_PIXEL_FORMAT_GRAY16: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; + case ONI_PIXEL_FORMAT_JPEG: return XN_PIXEL_FORMAT_MJPEG; + + default: + //not supported by OpenNI 1.x + return XnPixelFormat(0); + } +} + +void fillXnSupportedPixelFormats(XnSupportedPixelFormats &xnSPF, OniPixelFormat oniFormat) +{ + xnOSMemSet(&xnSPF, 0, sizeof(xnSPF)); + switch(toXnPixelFormat(oniFormat)) + { + case XN_PIXEL_FORMAT_RGB24: xnSPF.m_bRGB24 = 1; break; + case XN_PIXEL_FORMAT_YUV422: xnSPF.m_bYUV422 = 1; break; + case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: xnSPF.m_bGrayscale8Bit = 1; break; + case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT: xnSPF.m_bGrayscale16Bit = 1; break; + case XN_PIXEL_FORMAT_MJPEG: xnSPF.m_bMJPEG = 1; break; + } +} + +void FileRecorder::onAttach(XnUInt32 nodeId, VideoStream* pStream) +{ + if (nodeId == 0 || pStream == NULL) + { + return; + } + const OniSensorInfo* pSensorInfo = pStream->getSensorInfo(); + if (pSensorInfo == NULL) + { + return; + } + + // Assume we'll be using uncompressed codec. + XnUInt32 codecId = ONI_CODEC_UNCOMPRESSED; + + // Applicable for depth streams only. + int maxDepth = XN_MAX_UINT16; + + OniVideoMode curVideoMode; + int size = sizeof(OniVideoMode); + pStream->getProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, &curVideoMode, &size); + + // Guess codec type from video mode format. + switch (curVideoMode.pixelFormat) + { + case ONI_PIXEL_FORMAT_DEPTH_100_UM: + case ONI_PIXEL_FORMAT_DEPTH_1_MM: + { + size = int(sizeof(maxDepth)); + + pStream->getProperty( + ONI_STREAM_PROPERTY_MAX_VALUE, &maxDepth, &size); + + m_streams[pStream].pCodec = XN_NEW( + Xn16zEmbTablesCodec, static_cast(maxDepth)); + + codecId = ONI_CODEC_16Z_EMB_TABLES; + } + break; + case ONI_PIXEL_FORMAT_RGB888: + { + if (m_streams[pStream].allowLossyCompression) + { + m_streams[pStream].pCodec = XN_NEW( + XnJpegCodec, + /* bRGB = */ TRUE, + curVideoMode.resolutionX, + curVideoMode.resolutionY); + + codecId = ONI_CODEC_JPEG; + } + else + { + m_streams[pStream].pCodec = XN_NEW(XnUncompressedCodec); + } + } + break; + default: + m_streams[pStream].pCodec = XN_NEW(XnUncompressedCodec); + break; + } + + // If anything went wrong - fall back to uncompressed format. + if (XN_STATUS_OK != m_streams[pStream].pCodec->Init()) + { + XN_DELETE(m_streams[pStream].pCodec); + m_streams[pStream].pCodec = NULL; + codecId = ONI_CODEC_UNCOMPRESSED; + } + + Memento undoPoint(this); + // save the position of this record so we can override it upon detaching + m_streams[pStream].nodeAddedRecordPosition = undoPoint.GetPosition(); + + EMIT(RECORD_NODE_ADDED( + m_streams[pStream].nodeType = AsNodeType(pSensorInfo->sensorType), + nodeId, + m_streams[pStream].codecId = codecId, + /* numberOfFrames = */ XN_MAX_UINT32, + /* minTimeStamp = */ XN_UINT64_C(0), + /* maxTimeStamp = */ XN_MAX_UINT64, + /* seekTablePosition = */ XN_UINT64_C(0) + )) + undoPoint.Reuse(); + + EMIT(RECORD_GENERAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "oniOriginalDevice", undoPoint.GetPosition()), + "oniOriginalDevice", + pStream->getDevice().getInfo()->name, + sizeof(pStream->getDevice().getInfo()->name) + )); + undoPoint.Reuse(); + + // required data size (for cases where data is larger than video mode) + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "oniRequiredFrameSize", undoPoint.GetPosition()), + "oniRequiredFrameSize", + pStream->getRequiredFrameSize() + )); + undoPoint.Reuse(); + + // isGenerating (needed for OpenNI 1.x playback) + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnIsGenerating", undoPoint.GetPosition()), + "xnIsGenerating", + TRUE + )); + undoPoint.Reuse(); + + // xnDeviceMaxDepth + if (curVideoMode.pixelFormat == ONI_PIXEL_FORMAT_DEPTH_1_MM || + curVideoMode.pixelFormat == ONI_PIXEL_FORMAT_DEPTH_100_UM) + { + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnDeviceMaxDepth", undoPoint.GetPosition()), + "xnDeviceMaxDepth", + maxDepth + )) + } + undoPoint.Reuse(); + + // xnSupportedMapOutputModesCount + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnSupportedMapOutputModesCount", undoPoint.GetPosition()), + "xnSupportedMapOutputModesCount", + pSensorInfo->numSupportedVideoModes + )) + undoPoint.Reuse(); + + // xnSupportedMapOutputModes + VideoModeData* pVideoModes = XN_NEW_ARR( + VideoModeData, pSensorInfo->numSupportedVideoModes); + for (int i = 0; i < pSensorInfo->numSupportedVideoModes; ++i) + { + const OniVideoMode& videoMode = pSensorInfo->pSupportedVideoModes[i]; + pVideoModes[i].width = videoMode.resolutionX; + pVideoModes[i].height = videoMode.resolutionY; + pVideoModes[i].fps = videoMode.fps; + } + + EMIT(RECORD_GENERAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnSupportedMapOutputModes", undoPoint.GetPosition()), + "xnSupportedMapOutputModes", + pVideoModes, + sizeof(*pVideoModes) * pSensorInfo->numSupportedVideoModes + )) + undoPoint.Reuse(); + + // xnMapOutputMode + VideoModeData curVMD; + curVMD.width = curVideoMode.resolutionX; + curVMD.height = curVideoMode.resolutionY; + curVMD.fps = curVideoMode.fps; + EMIT(RECORD_GENERAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnMapOutputMode", undoPoint.GetPosition()), + "xnMapOutputMode", + &curVMD, + sizeof(curVMD) + )) + undoPoint.Reuse(); + + XnPixelFormat pixelFormat = toXnPixelFormat(curVideoMode.pixelFormat); + if (pixelFormat != 0) + { + // xnSupportedPixelFormats + XnSupportedPixelFormats supportedPixelFormats; + fillXnSupportedPixelFormats(supportedPixelFormats, curVideoMode.pixelFormat); + EMIT(RECORD_GENERAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnSupportedPixelFormats", undoPoint.GetPosition()), + "xnSupportedPixelFormats", + &supportedPixelFormats, + sizeof(supportedPixelFormats) + )) + undoPoint.Reuse(); + + // xnPixelFormat + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnPixelFormat", undoPoint.GetPosition()), + "xnPixelFormat", + pixelFormat + )) + undoPoint.Reuse(); + } + + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "oniPixelFormat", undoPoint.GetPosition()), + "oniPixelFormat", + curVideoMode.pixelFormat + )) + undoPoint.Reuse(); + + XN_DELETE_ARR(pVideoModes); + + size = sizeof(XnFloat); + float vdummy, hdummy; + if ( pStream->getProperty(ONI_STREAM_PROPERTY_HORIZONTAL_FOV, &hdummy, &size) == ONI_STATUS_OK && + pStream->getProperty(ONI_STREAM_PROPERTY_VERTICAL_FOV, &vdummy, &size) == ONI_STATUS_OK ) + { + // xnFOV + struct XnFieldOfView + { + /** Horizontal Field Of View, in radians. */ + XnDouble fHFOV; + /** Vertical Field Of View, in radians. */ + XnDouble fVFOV; + } fov = {hdummy, vdummy}; + + EMIT(RECORD_GENERAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnFOV", undoPoint.GetPosition()), + "xnFOV", + &fov, + sizeof(fov) + )) + undoPoint.Reuse(); + } + + // xnCropping + struct XnCropping + { + /** TRUE if cropping is turned on, FALSE otherwise. */ + XnBool bEnabled; + /** Offset in the X-axis, in pixels. */ + XnUInt16 nXOffset; + /** Offset in the Y-axis, in pixels. */ + XnUInt16 nYOffset; + /** Number of pixels in the X-axis. */ + XnUInt16 nXSize; + /** Number of pixels in the Y-axis. */ + XnUInt16 nYSize; + } xncropping = {0}; + OniCropping cropping; + size = sizeof(OniCropping); + if (pStream->getProperty(ONI_STREAM_PROPERTY_CROPPING, &cropping, &size) == ONI_STATUS_OK) + { + // we support cropping capability + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "Cropping", undoPoint.GetPosition()), + "Cropping", + TRUE + )); + + undoPoint.Reuse(); + + xncropping.bEnabled = cropping.enabled; + xncropping.nXOffset = (XnUInt16)cropping.originX; + xncropping.nYOffset = (XnUInt16)cropping.originY; + xncropping.nXSize = (XnUInt16)cropping.width; + xncropping.nYSize = (XnUInt16)cropping.height; + + EMIT(RECORD_GENERAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnCropping", undoPoint.GetPosition()), + "xnCropping", + &xncropping, + sizeof(xncropping) + )) + + undoPoint.Reuse(); + } + + OniBool bMirror = FALSE; + size = sizeof(bMirror); + if (pStream->getProperty(ONI_STREAM_PROPERTY_MIRRORING, &bMirror, &size) == ONI_STATUS_OK) + { + // we support mirroring capability + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "Mirror", undoPoint.GetPosition()), + "Mirror", + TRUE + )); + + undoPoint.Reuse(); + + // and now tell the mirror state + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, "xnMirror", undoPoint.GetPosition()), + "xnMirror", + bMirror + )) + + undoPoint.Reuse(); + } + + m_propertyPriority = ms_priorityHigh; + pStream->notifyAllProperties(); + m_propertyPriority = ms_priorityNormal; + undoPoint.Release(); +} + +void FileRecorder::onDetach(XnUInt32 nodeId) +{ + if (nodeId == 0) + { + return; + } + + FIND_ATTACHED_STREAM_INFO(nodeId) + if (!pInfo) return; + + Memento undoPoint(this); + EMIT(RECORD_NODE_REMOVED( + nodeId, + pInfo->nodeAddedRecordPosition + )) + undoPoint.Release(); + + undoPoint.Reuse(); + XnUInt64 nSeekTablePos = undoPoint.GetPosition(); + // write the seek table + EMIT(RECORD_SEEK_TABLE( + nodeId, + pInfo->frameId, + pInfo->dataIndex + )) + + undoPoint.Release(); + + undoPoint.Reuse(); + // Seek to position of node added record + undoPoint.SetPosition(pInfo->nodeAddedRecordPosition); + + // re-write this record, this time with seek data + EMIT(RECORD_NODE_ADDED( + pInfo->nodeType, + nodeId, + pInfo->codecId, + /* numberOfFrames = */ pInfo->frameId, + /* minTimeStamp = */ XN_UINT64_C(0), + /* maxTimeStamp = */ pInfo->lastOutputTimestamp, + /* seekTablePosition = */ nSeekTablePos + )) + undoPoint.Undo(); +} + +void FileRecorder::onStart(XnUInt32 nodeId) +{ + if (0 == nodeId) + { + return; + } + Memento undoPoint(this); + EMIT(RECORD_NODE_STATE_READY( + nodeId + )) + + EMIT(RECORD_NODE_DATA_BEGIN( + nodeId, + /* framesCount = */ XN_MAX_UINT32, + /* maxTimeStamp = */ XN_MAX_UINT64 + )) + undoPoint.Release(); +} + +void FileRecorder::onRecord(XnUInt32 nodeId, XnCodecBase* pCodec, const OniFrame* pFrame, XnUInt32 frameId, XnUInt64 timestamp) +{ + if (0 == nodeId || NULL == pFrame) + { + return; + } + + FIND_ATTACHED_STREAM_INFO(nodeId) + if (!pInfo) return; + + Memento undoPoint(this); + + if (NULL != pCodec) + { + XnUInt32 bufferSize_bytes32 = pFrame->dataSize * 2 + pCodec->GetOverheadSize(); + XnUInt8* buffer = XN_NEW_ARR(XnUInt8, bufferSize_bytes32); + + XnStatus status = pCodec->Compress(reinterpret_cast(pFrame->data), + pFrame->dataSize, buffer, &bufferSize_bytes32); + XnSizeT bufferSize_bytes = bufferSize_bytes32; + if (XN_STATUS_OK == status) + { + EMIT(RECORD_NEW_DATA( + nodeId, + pInfo->lastNewDataRecordPosition, + timestamp, + frameId, + buffer, + bufferSize_bytes)) + } + XN_DELETE_ARR(buffer); + } + else + { + EMIT(RECORD_NEW_DATA( + nodeId, + pInfo->lastNewDataRecordPosition, + pFrame->timestamp, + pFrame->frameIndex, + pFrame->data, + pFrame->dataSize + )) + } + undoPoint.Release(); + // save this record's position as the last one + pInfo->lastNewDataRecordPosition = undoPoint.GetPosition(); + + // write to seek table + DataIndexEntry dataIndexEntry; + dataIndexEntry.nTimestamp = timestamp; + dataIndexEntry.nConfigurationID = m_configurationId; + dataIndexEntry.nSeekPos = undoPoint.GetPosition(); + + pInfo->dataIndex.AddLast(dataIndexEntry); +} + +void FileRecorder::onRecordProperty( + XnUInt32 nodeId, + XnUInt32 propertyId, + const void* pData, + XnSizeT dataSize) +{ + if (0 == nodeId || NULL == pData || 0 == dataSize) + { + return; + } + Memento undoPoint(this); + for (XnSizeT i = 0; i < propertyTableItemsCount; ++i) + { + if (propertyTable[i].propertyId == propertyId) + { + switch (propertyTable[i].propertyType) + { + case PROPERTY_TYPE_INTEGER: + { + uint64_t value = *(uint64_t*)pData; + if (dataSize == sizeof(int)) + { + value = (uint64_t)*(int*)pData; + } + EMIT(RECORD_INT_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, propertyTable[i].propertyName, undoPoint.GetPosition()), + propertyTable[i].propertyName, + value)) + } + break; + case PROPERTY_TYPE_REAL: + { + double value = *(double*)pData; + if (dataSize == sizeof(float)) + { + value = (double)*(float*)pData; + } + EMIT(RECORD_REAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, propertyTable[i].propertyName, undoPoint.GetPosition()), + propertyTable[i].propertyName, + value)) + } + break; + case PROPERTY_TYPE_GENERAL: + default: + { + EMIT(RECORD_GENERAL_PROPERTY( + nodeId, + getLastPropertyRecordPos(nodeId, propertyTable[i].propertyName, undoPoint.GetPosition()), + propertyTable[i].propertyName, + pData, + dataSize)) + } + } + } + } + undoPoint.Release(); + + // update the global configurationId + ++m_configurationId; +} + +ONI_NAMESPACE_IMPLEMENTATION_END diff --git a/Source/Core/OniFileRecorder.h b/Source/Core/OniFileRecorder.h new file mode 100644 index 00000000..9a9bb0ba --- /dev/null +++ b/Source/Core/OniFileRecorder.h @@ -0,0 +1,189 @@ +/***************************************************************************** +* * +* 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 ONIFILERECORDER_H +#define ONIFILERECORDER_H 1 + +#include "XnString.h" +#include "XnPriorityQueue.h" + +// These come from OniFile/Formats +#include "Xn16zEmbTablesCodec.h" +#include "XnJpegCodec.h" +#include "XnUncompressedCodec.h" + +#include "OniRecorder.h" +#include "OniDataRecords.h" + +ONI_NAMESPACE_IMPLEMENTATION_BEGIN + +class FileRecorder : public Recorder +{ +public: + FileRecorder(FrameManager& frameManager, xnl::ErrorLogger& errorLogger, OniRecorderHandle handle = NULL); + ~FileRecorder(); + + OniStatus initialize(const char* fileName); + + OniStatus attachStream(VideoStream& stream, OniBool allowLossyCompression); + OniStatus detachStream(VideoStream& stream); + + virtual OniStatus start(); + + virtual OniStatus record(VideoStream& stream, OniFrame& aFrame); + + virtual OniStatus recordStreamProperty( + VideoStream& stream, + int propertyId, + const void* pData, + int dataSize); + +private: + XN_DISABLE_COPY_AND_ASSIGN(FileRecorder) + + // Messages are sent to Recorder's message loop and executed asynchronously. + // Please note: not all the fields are valid for every message. For example, + // Message::MESSAGE_DETACH relies only upon the nodeId field of the message, other + // fields are invalid and irrelevant for that message. + struct Message + { + enum Type + { + MESSAGE_NO_OPERATION, ///< Does not use any of Message fields. Does nothing. + MESSAGE_INITIALIZE, ///< Does not use any of Message fields. + MESSAGE_TERMINATE, ///< Does not use any of Message fields. + MESSAGE_ATTACH, ///< Uses: nodeId, pStream + MESSAGE_DETACH, ///< Uses: nodeId + MESSAGE_START, ///< Does not use any of Message fields. + MESSAGE_RECORD, ///< Uses: nodeId, pFrame + MESSAGE_RECORDPROPERTY, + } + type; + + XnUInt32 nodeId; + VideoStream* pStream; + union { + const void* pData; + OniFrame* pFrame; + }; + XnUInt32 propertyId; + XnSizeT dataSize; + + }; + + // Used for undo functionality. + class Memento; + friend class Memento; + + // The main function of Recorder's thread. + static XN_THREAD_PROC threadMain(XN_THREAD_PARAM pThreadParam); + + // Obtains the next message from the queue of messages and executes an + // action associated with that message. + void messagePump(); + + // Sends a message to the threadMain. + void send( + Message::Type type, + VideoStream* pStream = NULL, + const void* pData = NULL, + XnUInt32 propertyId = 0u, + XnSizeT dataSize = 0u, + int priority = ms_priorityNormal); + + // Message handlers: + void onInitialize(); + void onTerminate(); + void onAttach(XnUInt32 nodeId, VideoStream* pStream); + void onDetach(XnUInt32 nodeId); + void onStart (XnUInt32 nodeId); + void onRecord(XnUInt32 nodeId, XnCodecBase* pCodec, const OniFrame* pFrame, XnUInt32 frameId, XnUInt64 timestamp); + void onRecordProperty( + XnUInt32 nodeId, + XnUInt32 propertyId, + const void* pData, + XnSizeT dataSize); + + FrameManager& m_frameManager; + + // Error logger. + xnl::ErrorLogger& m_errorLogger; + + // Stores utility information about a stream. Currently the structure is + // pretty simple, but it might evolve in future. + struct AttachedStreamInfo + { + XnUInt32 nodeId; + XnUInt32 frameId; + XnCodecBase* pCodec; + OniBool allowLossyCompression; + XnUInt64 lastInputTimestamp; + XnUInt64 lastOutputTimestamp; + + // needed for overriding the NODE_ADDED record when detaching the stream + XnUInt64 nodeAddedRecordPosition; + XnUInt32 nodeType; + XnUInt32 codecId; + + // needed for keeping track of undoRecordPos field + XnUInt64 lastNewDataRecordPosition; + xnl::Hash + lastPropertyRecordPosition; + + // needed for generating the SeekTable in the end + DataIndexEntryList dataIndex; + }; + + // A map of stream -> stream information. + typedef xnl::Lockable< xnl::Hash > AttachedStreams; + AttachedStreams m_streams; + + // A helper function for the properties' undoRecordPos + XnUInt64 getLastPropertyRecordPos(XnUInt32 nodeId, const char *propName, XnUInt64 newRecordPos); + + // The maximum ID of a stream. This number grows with the every next stream + // attached to this Recorder and never decreases. + XnUInt32 m_maxId; + + // increased any time when a property changes in ANY attached stream, + // to avoid the player seeking with the tables when a configuration has changed. + XnUInt32 m_configurationId; + + // A message queue, used by threadMain and Send(). + typedef xnl::Lockable > MessageQueue; + MessageQueue m_queue; + int m_propertyPriority; + static const int ms_priorityLow = 2; + static const int ms_priorityNormal = 1; + static const int ms_priorityHigh = 0; + + // The Recorder uses RecordAssembler to assemble records correctly and to + // serialize them to a file. + RecordAssembler m_assembler; + + XN_THREAD_HANDLE m_thread; + FileHeaderData m_fileHeader; //< Will be patched during termination. + xnl::String m_fileName; + XN_FILE_HANDLE m_file; +}; + +ONI_NAMESPACE_IMPLEMENTATION_END + +#endif // ONIFILERECORDER_H diff --git a/Source/Core/OniFrameHolder.h b/Source/Core/OniFrameHolder.h index 738d3e79..99e649d5 100644 --- a/Source/Core/OniFrameHolder.h +++ b/Source/Core/OniFrameHolder.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_IMPL_FRAME_HOLDER_H_ -#define _ONI_IMPL_FRAME_HOLDER_H_ +#ifndef ONIFRAMEHOLDER_H +#define ONIFRAMEHOLDER_H #include "OniCommon.h" #include "OniFrameManager.h" @@ -83,4 +83,4 @@ class FrameHolder ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_IMPL_FRAME_HOLDER_H_ +#endif // ONIFRAMEHOLDER_H diff --git a/Source/Core/OniFrameManager.cpp b/Source/Core/OniFrameManager.cpp index 0d450aa7..2f7e0708 100644 --- a/Source/Core/OniFrameManager.cpp +++ b/Source/Core/OniFrameManager.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "OniFrameManager.h" #include diff --git a/Source/Core/OniFrameManager.h b/Source/Core/OniFrameManager.h index c1a42c23..4eb0187d 100644 --- a/Source/Core/OniFrameManager.h +++ b/Source/Core/OniFrameManager.h @@ -1,5 +1,25 @@ -#ifndef _ONI_FRAME_MANAGER_H_ -#define _ONI_FRAME_MANAGER_H_ +/***************************************************************************** +* * +* 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 ONIFRAMEMANAGER_H +#define ONIFRAMEMANAGER_H #include #include "OniCommon.h" @@ -37,4 +57,4 @@ class FrameManager ONI_NAMESPACE_IMPLEMENTATION_END -#endif //_ONI_FRAME_MANAGER_H_ \ No newline at end of file +#endif // ONIFRAMEMANAGER_H diff --git a/Source/Core/OniInternal.h b/Source/Core/OniInternal.h index 045489d9..e96b3371 100644 --- a/Source/Core/OniInternal.h +++ b/Source/Core/OniInternal.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_INTERNAL_H_ -#define _ONI_INTERNAL_H_ +#ifndef ONIINTERNAL_H +#define ONIINTERNAL_H #include "OniPlatform.h" @@ -37,4 +37,4 @@ ONI_C_API void oniWriteLogEntry(const char* mask, int severity, const char* mess // #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM // ONI_C_API OniStatus oniSetLogAndroidOutput(OniBool bAndroidOutput); //#endif -#endif //_ONI_INTERNAL_H_ \ No newline at end of file +#endif // ONIINTERNAL_H diff --git a/Source/Core/OniRecorder.cpp b/Source/Core/OniRecorder.cpp index 1a70a7fa..682145f3 100644 --- a/Source/Core/OniRecorder.cpp +++ b/Source/Core/OniRecorder.cpp @@ -22,1091 +22,75 @@ #include "XnLockGuard.h" -// These come from OniFile/Formats: -#include "Xn16zEmbTablesCodec.h" -#include "XnJpegCodec.h" -#include "XnUncompressedCodec.h" - -#include "OniContext.h" -#include "OniProperties.h" -#include "PS1080.h" - ONI_NAMESPACE_IMPLEMENTATION_BEGIN -// NOTE: XnLib does not define UINT*_C like macros for some reason... -#define XN_UINT64_C(x) ((x) + (XN_MAX_UINT64 - XN_MAX_UINT64)) -#define XN_UINT32_C(x) ((x) + (XN_MAX_UINT32 - XN_MAX_UINT32)) - -namespace { - -enum PropertyType -{ - PROPERTY_TYPE_GENERAL, - PROPERTY_TYPE_INTEGER, - PROPERTY_TYPE_REAL -}; - -const struct PropertyTable { - XnUInt32 propertyId; - const char* propertyName; - PropertyType propertyType; -} propertyTable[] = { - { XN_STREAM_PROPERTY_INPUT_FORMAT, "InputFormat" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_CROPPING_MODE, "CroppingMode" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED, "WhiteBalancedEnabled", PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_GAIN, "Gain" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_HOLE_FILTER, "HoleFilter" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_REGISTRATION_TYPE, "RegistrationType" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_AGC_BIN, "AGCBin" , PROPERTY_TYPE_GENERAL }, - { XN_STREAM_PROPERTY_CONST_SHIFT, "ConstShift" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR, "PixelSizeFactor" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_MAX_SHIFT, "MaxShift" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_PARAM_COEFF, "ParamCoeff" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_SHIFT_SCALE, "ShiftScale" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_S2D_TABLE, "S2D" , PROPERTY_TYPE_GENERAL }, - { XN_STREAM_PROPERTY_D2S_TABLE, "D2S" , PROPERTY_TYPE_GENERAL }, - { XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, "ZPD" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE, "ZPPS" , PROPERTY_TYPE_REAL }, - { XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE, "LDDIS" , PROPERTY_TYPE_REAL }, - { XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE, "DCRCDIS" , PROPERTY_TYPE_REAL }, - { XN_STREAM_PROPERTY_CLOSE_RANGE, "CloseRange" , PROPERTY_TYPE_INTEGER }, - { XN_STREAM_PROPERTY_PIXEL_REGISTRATION, "PixelRegistration" , PROPERTY_TYPE_GENERAL }, -}; - -const XnSizeT propertyTableItemsCount = sizeof(propertyTable) / sizeof(propertyTable[0]); - -} // namespace - -/** - * Is used by Recorder to make it possible to undo failed records. - * - * The usage pattern is: - * - * void Recorder::YourMethod() { - * // Create an undo point. - * Memento undoPoint(this); - * - * // Emit records here. If anything goes wrong - just return from this - * // method. - * - * // If anything went okay, release the undo point, so that nothing will - * // be undone. - * undoPoint.Release(); - * } - * - */ -class Recorder::Memento -{ -public: - /** - * Creates a Memento for the current state of the given Recorder. - */ - Memento(Recorder* pRecorder) - : m_pRecorder(pRecorder), m_offset(XN_UINT64_C(0)) - { - Reuse(); - } - - /** - * Destroys the Memento and reverts the Recorder back to the remembered state. - * - * @note The undo action will not be done if you have released the Memento. - */ - ~Memento() - { - if (m_needRollback) - { - Undo(); - } - } - - /** - * Releases the Memento. A released memento will not undo. - */ - void Release() - { - m_needRollback = false; - } - - /** - * ReUses the Memento. it will function like a brand-new one. - */ - void Reuse() - { - m_needRollback = true; - - XnStatus status = xnOSTellFile64(m_pRecorder->m_file, &m_offset); - if (status != XN_STATUS_OK) - { - m_pRecorder = NULL; - } - } - - /** - * Explicitly undo emits. Reverts the Recorder back to the remembered state. - */ - void Undo() - { - if (m_pRecorder != NULL) - { - xnOSSeekFile64(m_pRecorder->m_file, XN_OS_SEEK_SET, m_offset); - } - } - - /** - * An easy way to get the current position of the file. (and save for later use) - */ - XnUInt64 GetPosition() - { - return m_offset; - } - - /** - * An easey way to get the current position of the file. (for later use) - */ - void SetPosition(XnUInt64 pos) - { - if (m_pRecorder != NULL) - { - xnOSSeekFile64(m_pRecorder->m_file, XN_OS_SEEK_SET, pos); - } - } - -private: - Recorder* m_pRecorder; - XnUInt64 m_offset; - XnBool m_needRollback; -}; - -Recorder::Recorder(FrameManager& frameManager, xnl::ErrorLogger& errorLogger, OniRecorderHandle handle) - : m_frameManager(frameManager), - m_errorLogger(errorLogger), - m_handle(handle), - m_maxId(0), - m_configurationId(0), - m_propertyPriority(ms_priorityNormal), - m_file(XN_INVALID_FILE_HANDLE), - m_running(FALSE), - m_started(FALSE), - m_wasStarted(FALSE) -{ -} +Recorder::Recorder(OniRecorderHandle handle) : m_handle(handle), m_running(FALSE), m_started(FALSE), m_wasStarted(FALSE) +{} Recorder::~Recorder() { - stop(); - detachAllStreams(); - send(Message::MESSAGE_TERMINATE); - xnOSWaitForThreadExit(m_thread, XN_WAIT_INFINITE); - xnOSCloseThread(&m_thread); - if (NULL != m_handle) - { - m_handle->pRecorder = NULL; - } -} - -OniStatus Recorder::initialize(const char* fileName) -{ - m_fileName = fileName; - - // Probe if we can actually open the file. - XN_FILE_HANDLE fileHandle = XN_INVALID_FILE_HANDLE; - XnStatus status = xnOSOpenFile( - /* file name = */ fileName, - /* open flags = */ XN_OS_FILE_WRITE | XN_OS_FILE_TRUNCATE, - /* out handle = */ &fileHandle); - if (XN_STATUS_OK != status) - { - return ONI_STATUS_ERROR; - } - xnOSCloseFile(&fileHandle); - - m_assembler.initialize(); - - status = xnOSCreateThread(threadMain, this, &m_thread); - if (XN_STATUS_OK != status) - { - return ONI_STATUS_ERROR; - } - - send(Message::MESSAGE_INITIALIZE); - return ONI_STATUS_OK; -} - -OniStatus Recorder::attachStream(VideoStream& stream, OniBool allowLossyCompression) -{ - if (m_wasStarted) - { - return ONI_STATUS_ERROR; - } - - xnl::LockGuard guard(m_streams); - VideoStream* pStream = &stream; - if (m_streams.Find(pStream) == m_streams.End()) - { - if (ONI_STATUS_OK == pStream->addRecorder(*this)) - { - m_streams[pStream].nodeId = ++m_maxId; - m_streams[pStream].pCodec = NULL; - m_streams[pStream].allowLossyCompression = allowLossyCompression; - m_streams[pStream].frameId = 0; - m_streams[pStream].lastOutputTimestamp = 0; - m_streams[pStream].lastInputTimestamp = 0; - m_streams[pStream].lastNewDataRecordPosition = 0; - m_streams[pStream].dataIndex.Clear(); - send(Message::MESSAGE_ATTACH, pStream); - return ONI_STATUS_OK; - } - } - return ONI_STATUS_ERROR; -} - -OniStatus Recorder::detachStream(VideoStream& stream) -{ - xnl::LockGuard guard(m_streams); - VideoStream* pStream = &stream; - if (m_streams.End() != m_streams.Find(pStream)) - { - stream.removeRecorder(*this); - send(Message::MESSAGE_DETACH, pStream); - return ONI_STATUS_OK; - } - return ONI_STATUS_BAD_PARAMETER; -} - -OniStatus Recorder::detachAllStreams() -{ - xnl::LockGuard guard(m_streams); - for (AttachedStreams::Iterator - i = m_streams.Begin(), - e = m_streams.End(); - i != e; ++i) - { - detachStream(*i->Key()); - } - return ONI_STATUS_OK; -} - -OniStatus Recorder::start() -{ - m_wasStarted = true; - send(Message::MESSAGE_START); - return ONI_STATUS_OK; -} - -void Recorder::stop() -{ - m_started = false; + stop(); + detachAllStreams(); } -OniStatus Recorder::record(VideoStream& stream, OniFrame& aFrame) +OniStatus Recorder::initialize(const char* /*path*/) { - if (!m_started) - { - return ONI_STATUS_ERROR; - } - xnl::LockGuard< AttachedStreams > guard(m_streams); - VideoStream* pStream = &stream; - if (m_streams.Find(pStream) == m_streams.End()) - { - return ONI_STATUS_BAD_PARAMETER; - } - OniFrame* pFrame = &aFrame; - m_frameManager.addRef(pFrame); - send(Message::MESSAGE_RECORD, pStream, pFrame); - return ONI_STATUS_OK; + return ONI_STATUS_OK; } -OniStatus Recorder::recordStreamProperty( - VideoStream& stream, - int propertyId, - const void* pData, - int dataSize) +OniStatus Recorder::attachStream(VideoStream& stream, OniBool /*allowLossyCompression*/) { - xnl::LockGuard< AttachedStreams > guard(m_streams); - VideoStream* pStream = &stream; - if (m_streams.Find(pStream) == m_streams.End()) - { - return ONI_STATUS_BAD_PARAMETER; - } - // The original pData will not be valid after this function ends. - // Free this pointer when soon after handling the PropertyMessage! - void *newPtr = xnOSMalloc(dataSize); - xnOSMemCopy(newPtr, pData, dataSize); - send(Message::MESSAGE_RECORDPROPERTY, pStream, newPtr, propertyId, dataSize, m_propertyPriority); - return ONI_STATUS_OK; -} - -XN_THREAD_PROC Recorder::threadMain(XN_THREAD_PARAM pThreadParam) -{ - Recorder* pSelf = reinterpret_cast(pThreadParam); - if (NULL != pSelf) - { - pSelf->m_running = TRUE; - while (pSelf->m_running) - { - pSelf->messagePump(); - } - } - XN_THREAD_PROC_RETURN(XN_STATUS_OK); -} - -void Recorder::messagePump() -{ - XnStatus nRetVal = XN_STATUS_OK; - Message msg = { Message::MESSAGE_NO_OPERATION, 0, NULL, {NULL}, 0, 0 }; - + if (m_wasStarted) { - xnl::LockGuard guard(m_queue); - nRetVal = m_queue.Pop(msg); + return ONI_STATUS_ERROR; } - if (XN_STATUS_OK == nRetVal) - { - switch (msg.type) - { - case Message::MESSAGE_INITIALIZE: - { - onInitialize(); - } - break; - case Message::MESSAGE_TERMINATE: - { - onTerminate(); - m_running = FALSE; - } - break; - case Message::MESSAGE_ATTACH: - { - xnl::LockGuard streamsGuard(m_streams); - AttachedStreams::Iterator i = m_streams.Find(msg.pStream); - if (i != m_streams.End()) - { - onAttach(i->Value().nodeId, msg.pStream); - } - } - break; - case Message::MESSAGE_DETACH: - { - xnl::LockGuard streamsGuard(m_streams); - AttachedStreams::Iterator i = m_streams.Find(msg.pStream); - if (i != m_streams.End()) - { - onDetach(i->Value().nodeId); - XN_DELETE(m_streams[msg.pStream].pCodec); - m_streams.Remove(msg.pStream); - } - } - break; - case Message::MESSAGE_START: - { - xnl::LockGuard streamsGuard(m_streams); - for (AttachedStreams::Iterator - i = m_streams.Begin(), - e = m_streams.End(); - i != e; ++i) - { - onStart(i->Value().nodeId); - } - m_started = true; - } - break; - case Message::MESSAGE_RECORD: - { - xnl::LockGuard streamsGuard(m_streams); - AttachedStreams::Iterator i = m_streams.Find(msg.pStream); - if (i != m_streams.End()) - { - XnCodecBase* pCodec = m_streams[msg.pStream].pCodec; - XnUInt32 frameId = ++m_streams[msg.pStream].frameId; - XnUInt64 timestamp = 0; - if (frameId > 1) - { - timestamp = m_streams[msg.pStream].lastOutputTimestamp + (msg.pFrame->timestamp - m_streams[msg.pStream].lastInputTimestamp); - } - m_streams[msg.pStream].lastInputTimestamp = msg.pFrame->timestamp; - m_streams[msg.pStream].lastOutputTimestamp = timestamp; - onRecord(i->Value().nodeId, pCodec, msg.pFrame, frameId, timestamp); - m_frameManager.release(msg.pFrame); - } - } - break; - case Message::MESSAGE_RECORDPROPERTY: - { - xnl::LockGuard streamsGuard(m_streams); - AttachedStreams::Iterator i = m_streams.Find(msg.pStream); - if (i != m_streams.End()) - { - onRecordProperty( - i->Value().nodeId, - msg.propertyId, - msg.pData, - msg.dataSize); - } - // free the temporary buffer allocated earlier - xnOSFree((void*)msg.pData); - } - break; - default: - ; - } - } -} - -void Recorder::send( - Message::Type type, - VideoStream* pStream, - const void* pData, - XnUInt32 propertyId, - XnSizeT dataSize, - int priority) -{ - Message msg = - { - type, - pStream != NULL ? m_streams[pStream].nodeId : 0, - pStream, - {pData}, - propertyId, - dataSize - }; - xnl::LockGuard guard(m_queue); - m_queue.Push(msg, priority); -} - -void Recorder::onInitialize() -{ - XnStatus status = xnOSOpenFile( - /* file name = */ m_fileName.Data(), - /* open flags = */ XN_OS_FILE_WRITE | XN_OS_FILE_TRUNCATE, - /* out handle = */ &m_file); - - if (XN_STATUS_OK == status) - { - FileHeaderData fileHeader = - { - /* identity = */ { 'N', 'I', '1', '0' }, - /* version = */ { 1, 0, 1, 0 }, - /* maxTimeStamp = */ XN_MAX_UINT64, - /* maxNodeId = */ m_maxId, - }; - m_fileHeader = fileHeader; - xnOSWriteFile(m_file, &m_fileHeader, sizeof(m_fileHeader)); - } -} - -// A handy macro, that makes code more readable. -// Usage: -// -// void Recorder::YourMethod() { -// Memento undoPoint(this); -// EMIT(RECORD_END()) /* #1 */ -// EMIT(RECORD_END()) /* #2 */ -// undoPoint.Release(); -// } -// -// This will safely emit RECORD_END into the file, if either of (#1 or #2) -// expressions fail, the undoPoint will revert the file to the state, prior -// to YourMethod execution. -// -#define EMIT(expr) \ - if (ONI_STATUS_OK == (m_assembler.emit_##expr)) \ - { \ - if (ONI_STATUS_OK != m_assembler.serialize(m_file)) \ - { \ - return; \ - } \ - } \ - else \ - { \ - return; \ - } - -#define FIND_ATTACHED_STREAM_INFO(nodeId) \ - AttachedStreamInfo *pInfo = NULL; \ - xnl::LockGuard guard(m_streams); \ - for (AttachedStreams::Iterator \ - i = m_streams.Begin(), e = m_streams.End(); \ - i != e; \ - ++i) \ - { \ - if(i->Value().nodeId == nodeId) \ - { \ - pInfo = &(i->Value()); \ - break; \ - } \ - } - -XnUInt64 Recorder::getLastPropertyRecordPos(XnUInt32 nodeId, const char *propName, XnUInt64 newRecordPos) -{ - XnUInt64 pos = 0; - FIND_ATTACHED_STREAM_INFO(nodeId) - if (!pInfo) return 0; - - if (pInfo->lastPropertyRecordPosition.Find(propName) != pInfo->lastPropertyRecordPosition.End()) - { - pos = pInfo->lastPropertyRecordPosition[propName]; - } - pInfo->lastPropertyRecordPosition[propName] = newRecordPos; - return pos; -} - -void Recorder::onTerminate() -{ - // Truncate the file to it's last offset, so that undone records - // will not be serialized. - XnUInt64 truncationOffset = XN_UINT64_C(0); - if (XN_STATUS_OK == xnOSTellFile64(m_file, &truncationOffset)) - { - xnOSTruncateFile64(m_file, truncationOffset); - } - - Memento undoPoint(this); - EMIT(RECORD_END()) - undoPoint.Release(); - - // The file header needs being patched, because its maxNodeId field has become - // irrelevant by now. - m_fileHeader.maxNodeId = m_maxId; - xnOSSeekFile64(m_file, XN_OS_SEEK_SET, XN_UINT64_C(0)); - xnOSWriteFile(m_file, &m_fileHeader, sizeof(m_fileHeader)); - - xnOSCloseFile(&m_file); - m_file = XN_INVALID_FILE_HANDLE; -} - -typedef enum XnPixelFormat -{ - XN_PIXEL_FORMAT_RGB24 = 1, - XN_PIXEL_FORMAT_YUV422 = 2, - XN_PIXEL_FORMAT_GRAYSCALE_8_BIT = 3, - XN_PIXEL_FORMAT_GRAYSCALE_16_BIT = 4, - XN_PIXEL_FORMAT_MJPEG = 5, -} XnPixelFormat; - -typedef struct XnSupportedPixelFormats -{ - XnBool m_bRGB24 : 1; - XnBool m_bYUV422 : 1; - XnBool m_bGrayscale8Bit : 1; - XnBool m_bGrayscale16Bit : 1; - XnBool m_bMJPEG : 1; - XnUInt m_nPadding : 3; - XnUInt m_nReserved : 24; -} XnSupportedPixelFormats; - -XnPixelFormat toXnPixelFormat(OniPixelFormat oniFormat) -{ - switch(oniFormat) - { - // Depth - case ONI_PIXEL_FORMAT_DEPTH_1_MM: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; - case ONI_PIXEL_FORMAT_DEPTH_100_UM: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; - case ONI_PIXEL_FORMAT_SHIFT_9_2: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; - case ONI_PIXEL_FORMAT_SHIFT_9_3: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; - - // Color - case ONI_PIXEL_FORMAT_RGB888: return XN_PIXEL_FORMAT_RGB24; - case ONI_PIXEL_FORMAT_YUV422: return XN_PIXEL_FORMAT_YUV422; - case ONI_PIXEL_FORMAT_GRAY8: return XN_PIXEL_FORMAT_GRAYSCALE_8_BIT; - case ONI_PIXEL_FORMAT_GRAY16: return XN_PIXEL_FORMAT_GRAYSCALE_16_BIT; - case ONI_PIXEL_FORMAT_JPEG: return XN_PIXEL_FORMAT_MJPEG; - - default: - //not supported by OpenNI 1.x - return XnPixelFormat(0); - } -} - -void fillXnSupportedPixelFormats(XnSupportedPixelFormats &xnSPF, OniPixelFormat oniFormat) -{ - xnOSMemSet(&xnSPF, 0, sizeof(xnSPF)); - switch(toXnPixelFormat(oniFormat)) - { - case XN_PIXEL_FORMAT_RGB24: xnSPF.m_bRGB24 = 1; break; - case XN_PIXEL_FORMAT_YUV422: xnSPF.m_bYUV422 = 1; break; - case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: xnSPF.m_bGrayscale8Bit = 1; break; - case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT: xnSPF.m_bGrayscale16Bit = 1; break; - case XN_PIXEL_FORMAT_MJPEG: xnSPF.m_bMJPEG = 1; break; - } -} - -void Recorder::onAttach(XnUInt32 nodeId, VideoStream* pStream) -{ - if (nodeId == 0 || pStream == NULL) - { - return; - } - const OniSensorInfo* pSensorInfo = pStream->getSensorInfo(); - if (pSensorInfo == NULL) - { - return; - } - - // Assume we'll be using uncompressed codec. - XnUInt32 codecId = ONI_CODEC_UNCOMPRESSED; - - // Applicable for depth streams only. - int maxDepth = XN_MAX_UINT16; - - OniVideoMode curVideoMode; - int size = sizeof(OniVideoMode); - pStream->getProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, &curVideoMode, &size); - - // Guess codec type from video mode format. - switch (curVideoMode.pixelFormat) - { - case ONI_PIXEL_FORMAT_DEPTH_100_UM: - case ONI_PIXEL_FORMAT_DEPTH_1_MM: - { - size = int(sizeof(maxDepth)); - - pStream->getProperty( - ONI_STREAM_PROPERTY_MAX_VALUE, &maxDepth, &size); - - m_streams[pStream].pCodec = XN_NEW( - Xn16zEmbTablesCodec, static_cast(maxDepth)); - - codecId = ONI_CODEC_16Z_EMB_TABLES; - } - break; - case ONI_PIXEL_FORMAT_RGB888: - { - if (m_streams[pStream].allowLossyCompression) - { - m_streams[pStream].pCodec = XN_NEW( - XnJpegCodec, - /* bRGB = */ TRUE, - curVideoMode.resolutionX, - curVideoMode.resolutionY); - - codecId = ONI_CODEC_JPEG; - } - else - { - m_streams[pStream].pCodec = XN_NEW(XnUncompressedCodec); - } - } - break; - default: - m_streams[pStream].pCodec = XN_NEW(XnUncompressedCodec); - break; - } - - // If anything went wrong - fall back to uncompressed format. - if (XN_STATUS_OK != m_streams[pStream].pCodec->Init()) - { - XN_DELETE(m_streams[pStream].pCodec); - m_streams[pStream].pCodec = NULL; - codecId = ONI_CODEC_UNCOMPRESSED; - } - - Memento undoPoint(this); - // save the position of this record so we can override it upon detaching - m_streams[pStream].nodeAddedRecordPosition = undoPoint.GetPosition(); - - EMIT(RECORD_NODE_ADDED( - m_streams[pStream].nodeType = AsNodeType(pSensorInfo->sensorType), - nodeId, - m_streams[pStream].codecId = codecId, - /* numberOfFrames = */ XN_MAX_UINT32, - /* minTimeStamp = */ XN_UINT64_C(0), - /* maxTimeStamp = */ XN_MAX_UINT64, - /* seekTablePosition = */ XN_UINT64_C(0) - )) - undoPoint.Reuse(); - - // required data size (for cases where data is larger than video mode) - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "oniRequiredFrameSize", undoPoint.GetPosition()), - "oniRequiredFrameSize", - pStream->getRequiredFrameSize() - )); - undoPoint.Reuse(); - - // isGenerating (needed for OpenNI 1.x playback) - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnIsGenerating", undoPoint.GetPosition()), - "xnIsGenerating", - TRUE - )); - undoPoint.Reuse(); - - // xnDeviceMaxDepth - if (curVideoMode.pixelFormat == ONI_PIXEL_FORMAT_DEPTH_1_MM || - curVideoMode.pixelFormat == ONI_PIXEL_FORMAT_DEPTH_100_UM) - { - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnDeviceMaxDepth", undoPoint.GetPosition()), - "xnDeviceMaxDepth", - maxDepth - )) - } - undoPoint.Reuse(); - - // xnSupportedMapOutputModesCount - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnSupportedMapOutputModesCount", undoPoint.GetPosition()), - "xnSupportedMapOutputModesCount", - pSensorInfo->numSupportedVideoModes - )) - undoPoint.Reuse(); - - // xnSupportedMapOutputModes - VideoModeData* pVideoModes = XN_NEW_ARR( - VideoModeData, pSensorInfo->numSupportedVideoModes); - for (int i = 0; i < pSensorInfo->numSupportedVideoModes; ++i) - { - const OniVideoMode& videoMode = pSensorInfo->pSupportedVideoModes[i]; - pVideoModes[i].width = videoMode.resolutionX; - pVideoModes[i].height = videoMode.resolutionY; - pVideoModes[i].fps = videoMode.fps; - } - - EMIT(RECORD_GENERAL_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnSupportedMapOutputModes", undoPoint.GetPosition()), - "xnSupportedMapOutputModes", - pVideoModes, - sizeof(*pVideoModes) * pSensorInfo->numSupportedVideoModes - )) - undoPoint.Reuse(); - - // xnMapOutputMode - VideoModeData curVMD; - curVMD.width = curVideoMode.resolutionX; - curVMD.height = curVideoMode.resolutionY; - curVMD.fps = curVideoMode.fps; - EMIT(RECORD_GENERAL_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnMapOutputMode", undoPoint.GetPosition()), - "xnMapOutputMode", - &curVMD, - sizeof(curVMD) - )) - undoPoint.Reuse(); - - XnPixelFormat pixelFormat = toXnPixelFormat(curVideoMode.pixelFormat); - if (pixelFormat != 0) + xnl::LockGuard guard(m_frameIds); + VideoStream* pStream = &stream; + if (m_frameIds.Find(pStream) == m_frameIds.End()) { - // xnSupportedPixelFormats - XnSupportedPixelFormats supportedPixelFormats; - fillXnSupportedPixelFormats(supportedPixelFormats, curVideoMode.pixelFormat); - EMIT(RECORD_GENERAL_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnSupportedPixelFormats", undoPoint.GetPosition()), - "xnSupportedPixelFormats", - &supportedPixelFormats, - sizeof(supportedPixelFormats) - )) - undoPoint.Reuse(); - - // xnPixelFormat - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnPixelFormat", undoPoint.GetPosition()), - "xnPixelFormat", - pixelFormat - )) - undoPoint.Reuse(); - } - - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "oniPixelFormat", undoPoint.GetPosition()), - "oniPixelFormat", - curVideoMode.pixelFormat - )) - undoPoint.Reuse(); - - XN_DELETE_ARR(pVideoModes); - - size = sizeof(XnFloat); - float vdummy, hdummy; - if ( pStream->getProperty(ONI_STREAM_PROPERTY_HORIZONTAL_FOV, &hdummy, &size) == ONI_STATUS_OK && - pStream->getProperty(ONI_STREAM_PROPERTY_VERTICAL_FOV, &vdummy, &size) == ONI_STATUS_OK ) - { - // xnFOV - struct XnFieldOfView + if (ONI_STATUS_OK == pStream->addRecorder(*this)) { - /** Horizontal Field Of View, in radians. */ - XnDouble fHFOV; - /** Vertical Field Of View, in radians. */ - XnDouble fVFOV; - } fov = {hdummy, vdummy}; - - EMIT(RECORD_GENERAL_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnFOV", undoPoint.GetPosition()), - "xnFOV", - &fov, - sizeof(fov) - )) - undoPoint.Reuse(); - } - - // xnCropping - struct XnCropping - { - /** TRUE if cropping is turned on, FALSE otherwise. */ - XnBool bEnabled; - /** Offset in the X-axis, in pixels. */ - XnUInt16 nXOffset; - /** Offset in the Y-axis, in pixels. */ - XnUInt16 nYOffset; - /** Number of pixels in the X-axis. */ - XnUInt16 nXSize; - /** Number of pixels in the Y-axis. */ - XnUInt16 nYSize; - } xncropping = {0}; - OniCropping cropping; - size = sizeof(OniCropping); - if (pStream->getProperty(ONI_STREAM_PROPERTY_CROPPING, &cropping, &size) == ONI_STATUS_OK) - { - // we support cropping capability - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "Cropping", undoPoint.GetPosition()), - "Cropping", - TRUE - )); - - undoPoint.Reuse(); - - xncropping.bEnabled = cropping.enabled; - xncropping.nXOffset = (XnUInt16)cropping.originX; - xncropping.nYOffset = (XnUInt16)cropping.originY; - xncropping.nXSize = (XnUInt16)cropping.width; - xncropping.nYSize = (XnUInt16)cropping.height; - - EMIT(RECORD_GENERAL_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnCropping", undoPoint.GetPosition()), - "xnCropping", - &xncropping, - sizeof(xncropping) - )) - - undoPoint.Reuse(); - } - - OniBool bMirror = FALSE; - size = sizeof(bMirror); - if (pStream->getProperty(ONI_STREAM_PROPERTY_MIRRORING, &bMirror, &size) == ONI_STATUS_OK) - { - // we support mirroring capability - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "Mirror", undoPoint.GetPosition()), - "Mirror", - TRUE - )); - - undoPoint.Reuse(); - - // and now tell the mirror state - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, "xnMirror", undoPoint.GetPosition()), - "xnMirror", - bMirror - )) - - undoPoint.Reuse(); + m_frameIds[pStream] = 0; + return ONI_STATUS_OK; + } } - - m_propertyPriority = ms_priorityHigh; - pStream->notifyAllProperties(); - m_propertyPriority = ms_priorityNormal; - undoPoint.Release(); + return ONI_STATUS_ERROR; } -void Recorder::onDetach(XnUInt32 nodeId) +OniStatus Recorder::detachStream(VideoStream& stream) { - if (nodeId == 0) - { - return; - } - - FIND_ATTACHED_STREAM_INFO(nodeId) - if (!pInfo) return; - - Memento undoPoint(this); - EMIT(RECORD_NODE_REMOVED( - nodeId, - pInfo->nodeAddedRecordPosition - )) - undoPoint.Release(); - - undoPoint.Reuse(); - XnUInt64 nSeekTablePos = undoPoint.GetPosition(); - // write the seek table - EMIT(RECORD_SEEK_TABLE( - nodeId, - pInfo->frameId, - pInfo->dataIndex - )) - - undoPoint.Release(); - - undoPoint.Reuse(); - // Seek to position of node added record - undoPoint.SetPosition(pInfo->nodeAddedRecordPosition); - - // re-write this record, this time with seek data - EMIT(RECORD_NODE_ADDED( - pInfo->nodeType, - nodeId, - pInfo->codecId, - /* numberOfFrames = */ pInfo->frameId, - /* minTimeStamp = */ XN_UINT64_C(0), - /* maxTimeStamp = */ pInfo->lastOutputTimestamp, - /* seekTablePosition = */ nSeekTablePos - )) - undoPoint.Undo(); + xnl::LockGuard guard(m_frameIds); + VideoStream* pStream = &stream; + if (m_frameIds.End() != m_frameIds.Find(pStream)) + { + stream.removeRecorder(*this); + m_frameIds.Remove(pStream); + return ONI_STATUS_OK; + } + return ONI_STATUS_BAD_PARAMETER; } -void Recorder::onStart(XnUInt32 nodeId) +OniStatus Recorder::detachAllStreams() { - if (0 == nodeId) - { - return; - } - Memento undoPoint(this); - EMIT(RECORD_NODE_STATE_READY( - nodeId - )) + xnl::LockGuard guard(m_frameIds); + while (!m_frameIds.IsEmpty()) + { + detachStream(*m_frameIds.Begin()->Key()); + } - EMIT(RECORD_NODE_DATA_BEGIN( - nodeId, - /* framesCount = */ XN_MAX_UINT32, - /* maxTimeStamp = */ XN_MAX_UINT64 - )) - undoPoint.Release(); + return ONI_STATUS_OK; } -void Recorder::onRecord(XnUInt32 nodeId, XnCodecBase* pCodec, const OniFrame* pFrame, XnUInt32 frameId, XnUInt64 timestamp) +OniStatus Recorder::start() { - if (0 == nodeId || NULL == pFrame) - { - return; - } - - FIND_ATTACHED_STREAM_INFO(nodeId) - if (!pInfo) return; - - Memento undoPoint(this); - - if (NULL != pCodec) - { - XnUInt32 bufferSize_bytes32 = pFrame->dataSize * 2 + pCodec->GetOverheadSize(); - XnUInt8* buffer = XN_NEW_ARR(XnUInt8, bufferSize_bytes32); - - XnStatus status = pCodec->Compress(reinterpret_cast(pFrame->data), - pFrame->dataSize, buffer, &bufferSize_bytes32); - XnSizeT bufferSize_bytes = bufferSize_bytes32; - if (XN_STATUS_OK == status) - { - EMIT(RECORD_NEW_DATA( - nodeId, - pInfo->lastNewDataRecordPosition, - timestamp, - frameId, - buffer, - bufferSize_bytes)) - } - XN_DELETE_ARR(buffer); - } - else - { - EMIT(RECORD_NEW_DATA( - nodeId, - pInfo->lastNewDataRecordPosition, - pFrame->timestamp, - pFrame->frameIndex, - pFrame->data, - pFrame->dataSize - )) - } - undoPoint.Release(); - // save this record's position as the last one - pInfo->lastNewDataRecordPosition = undoPoint.GetPosition(); - - // write to seek table - DataIndexEntry dataIndexEntry; - dataIndexEntry.nTimestamp = timestamp; - dataIndexEntry.nConfigurationID = m_configurationId; - dataIndexEntry.nSeekPos = undoPoint.GetPosition(); - - pInfo->dataIndex.AddLast(dataIndexEntry); + m_wasStarted = true; + return ONI_STATUS_OK; } -void Recorder::onRecordProperty( - XnUInt32 nodeId, - XnUInt32 propertyId, - const void* pData, - XnSizeT dataSize) +void Recorder::stop() { - if (0 == nodeId || NULL == pData || 0 == dataSize) - { - return; - } - Memento undoPoint(this); - for (XnSizeT i = 0; i < propertyTableItemsCount; ++i) - { - if (propertyTable[i].propertyId == propertyId) - { - switch (propertyTable[i].propertyType) - { - case PROPERTY_TYPE_INTEGER: - { - uint64_t value = *(uint64_t*)pData; - if (dataSize == sizeof(int)) - { - value = (uint64_t)*(int*)pData; - } - EMIT(RECORD_INT_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, propertyTable[i].propertyName, undoPoint.GetPosition()), - propertyTable[i].propertyName, - value)) - } - break; - case PROPERTY_TYPE_REAL: - { - double value = *(double*)pData; - if (dataSize == sizeof(float)) - { - value = (double)*(float*)pData; - } - EMIT(RECORD_REAL_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, propertyTable[i].propertyName, undoPoint.GetPosition()), - propertyTable[i].propertyName, - value)) - } - break; - case PROPERTY_TYPE_GENERAL: - default: - { - EMIT(RECORD_GENERAL_PROPERTY( - nodeId, - getLastPropertyRecordPos(nodeId, propertyTable[i].propertyName, undoPoint.GetPosition()), - propertyTable[i].propertyName, - pData, - dataSize)) - } - } - } - } - undoPoint.Release(); - - // update the global configurationId - ++m_configurationId; + m_started = false; } ONI_NAMESPACE_IMPLEMENTATION_END diff --git a/Source/Core/OniRecorder.h b/Source/Core/OniRecorder.h index 082e1758..ab6096b8 100644 --- a/Source/Core/OniRecorder.h +++ b/Source/Core/OniRecorder.h @@ -18,32 +18,15 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef OPENNI_ONIRECORDER_H_ -#define OPENNI_ONIRECORDER_H_ 1 - -#include "XnErrorLogger.h" -#include "XnLockable.h" -#include "XnString.h" -#include "XnPriorityQueue.h" - -// These come from OniFile/Formats -#include "Xn16zEmbTablesCodec.h" -#include "XnJpegCodec.h" -#include "XnUncompressedCodec.h" - -#include "OniCommon.h" -#include "OniFrameManager.h" -#include "OniDataRecords.h" +#ifndef ONIRECORDER_H +#define ONIRECORDER_H 1 + #include "OniStream.h" -#include "OniCTypes.h" ONI_NAMESPACE_IMPLEMENTATION_BEGIN class VideoStream; -/** - * The private implementation of a recorder. - */ class Recorder { public: @@ -52,29 +35,29 @@ class Recorder * @note The newly constructed recorder becomes the owner of the handle. * @note The handle might be NULL. */ - Recorder(FrameManager& frameManager, xnl::ErrorLogger& errorLogger, OniRecorderHandle handle = NULL); + Recorder(OniRecorderHandle handle = NULL); /** * Destroys the recorder and stops recording if needed. */ - ~Recorder(); + virtual ~Recorder(); /** * Initializes the recorder. * @param fileName The file that will store the recording. */ - OniStatus initialize(const char* fileName); + virtual OniStatus initialize(const char* path); /** * Attaches a stream to the recorder. Can not be done if Start() has been * called at least once. */ - OniStatus attachStream(VideoStream& stream, OniBool allowLossyCompression); + virtual OniStatus attachStream(VideoStream& stream, OniBool allowLossyCompression); /** * Detaches a stream from the recorder. */ - OniStatus detachStream(VideoStream& stream); + virtual OniStatus detachStream(VideoStream& stream); /** * Detaches all streams from the recorder. @@ -86,166 +69,42 @@ class Recorder * @note There's a known side effect related to AttachStream(Stream&). * @see AttachStream(Stream&) */ - OniStatus start(); + virtual OniStatus start(); /** * Stops recording. */ - void stop(); + virtual void stop(); /** * Records a frame into the given stream. */ - OniStatus record(VideoStream& stream, OniFrame& aFrame); + virtual OniStatus record(VideoStream& stream, OniFrame& aFrame) = 0; /** * */ - OniStatus recordStreamProperty( - VideoStream& stream, - int propertyId, - const void* pData, - int dataSize); - -private: - XN_DISABLE_COPY_AND_ASSIGN(Recorder) - - // Messages are sent to Recorder's message loop and executed asynchronously. - // Please note: not all the fields are valid for every message. For example, - // Message::MESSAGE_DETACH relies only upon the nodeId field of the message, other - // fields are invalid and irrelevant for that message. - struct Message - { - enum Type - { - MESSAGE_NO_OPERATION, ///< Does not use any of Message fields. Does nothing. - MESSAGE_INITIALIZE, ///< Does not use any of Message fields. - MESSAGE_TERMINATE, ///< Does not use any of Message fields. - MESSAGE_ATTACH, ///< Uses: nodeId, pStream - MESSAGE_DETACH, ///< Uses: nodeId - MESSAGE_START, ///< Does not use any of Message fields. - MESSAGE_RECORD, ///< Uses: nodeId, pFrame - MESSAGE_RECORDPROPERTY, - } - type; - - XnUInt32 nodeId; - VideoStream* pStream; - union { - const void* pData; - OniFrame* pFrame; - }; - XnUInt32 propertyId; - XnSizeT dataSize; - - }; - - // Used for undo functionality. - class Memento; - friend class Memento; - - // The main function of Recorder's thread. - static XN_THREAD_PROC threadMain(XN_THREAD_PARAM pThreadParam); - - // Obtains the next message from the queue of messages and executes an - // action associated with that message. - void messagePump(); - - // Sends a message to the threadMain. - void send( - Message::Type type, - VideoStream* pStream = NULL, - const void* pData = NULL, - XnUInt32 propertyId = 0u, - XnSizeT dataSize = 0u, - int priority = ms_priorityNormal); - - // Message handlers: - void onInitialize(); - void onTerminate(); - void onAttach(XnUInt32 nodeId, VideoStream* pStream); - void onDetach(XnUInt32 nodeId); - void onStart (XnUInt32 nodeId); - void onRecord(XnUInt32 nodeId, XnCodecBase* pCodec, const OniFrame* pFrame, XnUInt32 frameId, XnUInt64 timestamp); - void onRecordProperty( - XnUInt32 nodeId, - XnUInt32 propertyId, - const void* pData, - XnSizeT dataSize); - - FrameManager& m_frameManager; - - // Error logger. - xnl::ErrorLogger& m_errorLogger; - - // There's a 1:1 mapping between a Recorder object and a handle to that object. - // The Recorder object owns its handle. - OniRecorderHandle m_handle; - - // Stores utility information about a stream. Currently the structure is - // pretty simple, but it might evolve in future. - struct AttachedStreamInfo - { - XnUInt32 nodeId; - XnUInt32 frameId; - XnCodecBase* pCodec; - OniBool allowLossyCompression; - XnUInt64 lastInputTimestamp; - XnUInt64 lastOutputTimestamp; - - // needed for overriding the NODE_ADDED record when detaching the stream - XnUInt64 nodeAddedRecordPosition; - XnUInt32 nodeType; - XnUInt32 codecId; - - // needed for keeping track of undoRecordPos field - XnUInt64 lastNewDataRecordPosition; - xnl::Hash - lastPropertyRecordPosition; - - // needed for generating the SeekTable in the end - DataIndexEntryList dataIndex; - }; - - // A map of stream -> stream information. - typedef xnl::Lockable< xnl::Hash > AttachedStreams; - AttachedStreams m_streams; - - // A helper function for the properties' undoRecordPos - XnUInt64 getLastPropertyRecordPos(XnUInt32 nodeId, const char *propName, XnUInt64 newRecordPos); - - // The maximum ID of a stream. This number grows with the every next stream - // attached to this Recorder and never decreases. - XnUInt32 m_maxId; - - // increased any time when a property changes in ANY attached stream, - // to avoid the player seeking with the tables when a configuration has changed. - XnUInt32 m_configurationId; - - // A message queue, used by threadMain and Send(). - typedef xnl::Lockable > MessageQueue; - MessageQueue m_queue; - int m_propertyPriority; - static const int ms_priorityLow = 2; - static const int ms_priorityNormal = 1; - static const int ms_priorityHigh = 0; - - // The Recorder uses RecordAssembler to assemble records correctly and to - // serialize them to a file. - RecordAssembler m_assembler; - - XN_THREAD_HANDLE m_thread; - FileHeaderData m_fileHeader; //< Will be patched during termination. - xnl::String m_fileName; - XN_FILE_HANDLE m_file; - XnBool m_running; //< TRUE whenever the threadMain is running. - XnBool m_started; //< TRUE whenever the recorder has started. - XnBool m_wasStarted; //< TRUE if the recorder has been started once. - -// Get rid of macros: -#undef ONI_DISABLE_COPY_AND_ASSIGN + virtual OniStatus recordStreamProperty( + VideoStream& stream, + int propertyId, + const void* pData, + int dataSize) = 0; + +protected: + // There's a 1:1 mapping between a Recorder object and a handle to that object. + // The Recorder object owns its handle. + OniRecorderHandle m_handle; + + // A map of stream -> stream information. + typedef xnl::Lockable< xnl::Hash > StreamFrameIDList; + StreamFrameIDList m_frameIds; + + XnBool m_running; //< TRUE whenever the threadMain is running. + XnBool m_started; //< TRUE whenever the recorder has started. + XnBool m_wasStarted; //< TRUE if the recorder has been started once. + }; ONI_NAMESPACE_IMPLEMENTATION_END -#endif // OPENNI_ONIRECORDER_H_ +#endif // ONIRECORDER_H diff --git a/Source/Core/OniSensor.cpp b/Source/Core/OniSensor.cpp index ccabcff1..8513eff8 100755 --- a/Source/Core/OniSensor.cpp +++ b/Source/Core/OniSensor.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "OniSensor.h" #include diff --git a/Source/Core/OniSensor.h b/Source/Core/OniSensor.h index b0e982b7..30afd203 100644 --- a/Source/Core/OniSensor.h +++ b/Source/Core/OniSensor.h @@ -1,5 +1,25 @@ -#ifndef _ONI_SENSOR_H_ -#define _ONI_SENSOR_H_ +/***************************************************************************** +* * +* 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 ONISENSOR_H +#define ONISENSOR_H #include "OniCommon.h" #include "OniFrameManager.h" @@ -79,4 +99,4 @@ class Sensor : OniStreamServices ONI_NAMESPACE_IMPLEMENTATION_END -#endif //_ONI_SENSOR_H_ \ No newline at end of file +#endif // ONISENSOR_H diff --git a/Source/Core/OniStream.cpp b/Source/Core/OniStream.cpp index 435dde69..b99d6295 100644 --- a/Source/Core/OniStream.cpp +++ b/Source/Core/OniStream.cpp @@ -57,6 +57,9 @@ VideoStream::VideoStream(Sensor* pSensor, const OniSensorInfo* pSensorInfo, Devi m_driverHandler.streamSetPropertyChangedCallback(m_pSensor->streamHandle(), stream_PropertyChanged, this); refreshWorldConversionCache(); + + xnFPSInit(&m_FPS, 180); + xnOSStrCopy(m_sensorName, getSensorName(pSensorInfo->sensorType), sizeof(m_sensorName)); } // Stream @@ -65,9 +68,16 @@ VideoStream::~VideoStream() // Make sure stream is stopped. stop(); + xnFPSFree(&m_FPS); + if (m_hNewFrameEvent != NULL) { - m_pSensor->newFrameEvent().Unregister(m_hNewFrameEvent); + //If device has no handle then the m_pSensor object is not valid + if(m_device.getHandle() != NULL) + { + m_pSensor->newFrameEvent().Unregister(m_hNewFrameEvent); + } + m_hNewFrameEvent = NULL; } @@ -341,6 +351,7 @@ void ONI_CALLBACK_TYPE VideoStream::stream_NewFrame(OniFrame* pFrame, void* pCoo void VideoStream::raiseNewFrameEvent() { + xnFPSMarkFrame(&m_FPS); xnOSSetEvent(m_newFrameInternalEvent); xnOSSetEvent(m_newFrameInternalEventForFrameHolder); m_newFrameCallback(m_newFrameCookie); @@ -396,11 +407,13 @@ OniStatus VideoStream::convertDepthToWorldCoordinates(float depthX, float depthY return ONI_STATUS_NOT_SUPPORTED; } + float depthZmm = depthZ * m_worldConvertCache.zFactor; + float normalizedX = depthX / m_worldConvertCache.resolutionX - .5f; float normalizedY = .5f - depthY / m_worldConvertCache.resolutionY; - *pWorldX = normalizedX * depthZ * m_worldConvertCache.xzFactor; - *pWorldY = normalizedY * depthZ * m_worldConvertCache.yzFactor; + *pWorldX = normalizedX * depthZmm * m_worldConvertCache.xzFactor; + *pWorldY = normalizedY * depthZmm * m_worldConvertCache.yzFactor; *pWorldZ = depthZ; return ONI_STATUS_OK; } @@ -413,8 +426,10 @@ OniStatus VideoStream::convertWorldToDepthCoordinates(float worldX, float worldY return ONI_STATUS_NOT_SUPPORTED; } - *pDepthX = m_worldConvertCache.coeffX * worldX / worldZ + m_worldConvertCache.halfResX; - *pDepthY = m_worldConvertCache.halfResY - m_worldConvertCache.coeffY * worldY / worldZ; + float worldZmm = worldZ * m_worldConvertCache.zFactor; + + *pDepthX = m_worldConvertCache.coeffX * worldX / worldZmm + m_worldConvertCache.halfResX; + *pDepthY = m_worldConvertCache.halfResY - m_worldConvertCache.coeffY * worldY / worldZmm; *pDepthZ = worldZ; return ONI_STATUS_OK; } @@ -431,8 +446,8 @@ void VideoStream::refreshWorldConversionCache() getProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, &videoMode, &size); size = sizeof(float); - float horizontalFov; - float verticalFov; + float horizontalFov = 0.0; + float verticalFov = 0.0; getProperty(ONI_STREAM_PROPERTY_HORIZONTAL_FOV, &horizontalFov, &size); getProperty(ONI_STREAM_PROPERTY_VERTICAL_FOV, &verticalFov, &size); @@ -444,6 +459,18 @@ void VideoStream::refreshWorldConversionCache() m_worldConvertCache.halfResY = m_worldConvertCache.resolutionY / 2; m_worldConvertCache.coeffX = m_worldConvertCache.resolutionX / m_worldConvertCache.xzFactor; m_worldConvertCache.coeffY = m_worldConvertCache.resolutionY / m_worldConvertCache.yzFactor; + + switch (videoMode.pixelFormat) + { + case ONI_PIXEL_FORMAT_DEPTH_1_MM: + m_worldConvertCache.zFactor = 1.f; + break; + case ONI_PIXEL_FORMAT_DEPTH_100_UM: + m_worldConvertCache.zFactor = 0.1f; + break; + default: + XN_ASSERT(FALSE); + } } OniStatus VideoStream::convertDepthToColorCoordinates(VideoStream* colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) @@ -467,4 +494,25 @@ int VideoStream::getRequiredFrameSize() return m_driverHandler.streamGetRequiredFrameSize(m_pSensor->streamHandle()); } +double VideoStream::calcCurrentFPS() +{ + return xnFPSCalc(&m_FPS); +} + +const XnChar* VideoStream::getSensorName(OniSensorType sensorType) +{ + switch (sensorType) + { + case ONI_SENSOR_DEPTH: + return "Depth"; + case ONI_SENSOR_COLOR: + return "Color"; + case ONI_SENSOR_IR: + return "IR"; + default: + XN_ASSERT(FALSE); + return "(Unknown)"; + } +} + ONI_NAMESPACE_IMPLEMENTATION_END diff --git a/Source/Core/OniStream.h b/Source/Core/OniStream.h index f1f30ed0..940a3928 100644 --- a/Source/Core/OniStream.h +++ b/Source/Core/OniStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_IMPL_STREAM_H_ -#define _ONI_IMPL_STREAM_H_ +#ifndef ONISTREAM_H +#define ONISTREAM_H #include "OniDriverHandler.h" #include "OniCommon.h" @@ -30,6 +30,7 @@ #include "XnErrorLogger.h" #include "XnHash.h" #include "XnLockable.h" +#include ONI_NAMESPACE_IMPLEMENTATION_BEGIN @@ -70,6 +71,7 @@ class VideoStream const OniSensorInfo* getSensorInfo() const; Device& getDevice(); + const XnChar* getSensorName() { return m_sensorName; } void* getHandle() const; @@ -90,6 +92,8 @@ class VideoStream int getRequiredFrameSize(); + double calcCurrentFPS(); + protected: XN_EVENT_HANDLE m_newFrameInternalEvent; XN_EVENT_HANDLE m_newFrameInternalEventForFrameHolder; @@ -114,6 +118,7 @@ class VideoStream static void ONI_CALLBACK_TYPE stream_PropertyChanged(void* streamHandle, int propertyId, const void* data, int dataSize, void* pCookie); void refreshWorldConversionCache(); + static const XnChar* getSensorName(OniSensorType sensorType); NewFrameFuncPtr m_newFrameCallback; void* m_newFrameCookie; @@ -131,6 +136,8 @@ class VideoStream // Recorder* -> Recorder* map to mimic a set. typedef xnl::Lockable > Recorders; Recorders m_recorders; + XnFPSData m_FPS; + XnChar m_sensorName[80]; struct WorldConversionCache { @@ -142,9 +149,10 @@ class VideoStream int resolutionY; int halfResX; int halfResY; + float zFactor; } m_worldConvertCache; }; ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_IMPL_STREAM_H_ +#endif // ONISTREAM_H diff --git a/Source/Core/OniStreamFrameHolder.h b/Source/Core/OniStreamFrameHolder.h index 223fe932..5f7a9bc3 100644 --- a/Source/Core/OniStreamFrameHolder.h +++ b/Source/Core/OniStreamFrameHolder.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_IMPL_STREAM_FRAME_HOLDER_H_ -#define _ONI_IMPL_STREAM_FRAME_HOLDER_H_ +#ifndef ONISTREAMFRAMEHOLDER_H +#define ONISTREAMFRAMEHOLDER_H #include "OniCommon.h" #include "OniFrameHolder.h" @@ -68,4 +68,4 @@ class StreamFrameHolder : public FrameHolder ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_IMPL_STREAM_FRAME_HOLDER_H_ +#endif // ONISTREAMFRAMEHOLDER_H diff --git a/Source/Core/OniSyncedStreamsFrameHolder.h b/Source/Core/OniSyncedStreamsFrameHolder.h index 27ea7870..e1f52a48 100644 --- a/Source/Core/OniSyncedStreamsFrameHolder.h +++ b/Source/Core/OniSyncedStreamsFrameHolder.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _ONI_IMPL_SYNCED_STREAMS_FRAME_HOLDER_H_ -#define _ONI_IMPL_SYNCED_STREAMS_FRAME_HOLDER_H_ +#ifndef ONISYNCEDSTREAMSFRAMEHOLDER_H +#define ONISYNCEDSTREAMSFRAMEHOLDER_H #include "OniCommon.h" #include "OniFrameHolder.h" @@ -81,4 +81,4 @@ class SyncedStreamsFrameHolder : public FrameHolder ONI_NAMESPACE_IMPLEMENTATION_END -#endif // _ONI_IMPL_SYNCED_STREAMS_FRAME_HOLDER_H_ +#endif // ONISYNCEDSTREAMSFRAMEHOLDER_H diff --git a/Source/Core/OpenNI.vcxproj b/Source/Core/OpenNI.vcxproj index 12189dec..205245d3 100644 --- a/Source/Core/OpenNI.vcxproj +++ b/Source/Core/OpenNI.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ DynamicLibrary true MultiByte + v120 DynamicLibrary true MultiByte + v120 DynamicLibrary false true MultiByte + v120 DynamicLibrary false true MultiByte + v120 @@ -84,7 +88,7 @@ Disabled - ..\..\Include;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;..\..\ThirdParty\LibJPEG;%(AdditionalIncludeDirectories) + ..\..\Include;..\Drivers\OniFile;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;%(AdditionalIncludeDirectories) _WINDLL;%(PreprocessorDefinitions);OPENNI2_EXPORT ProgramDatabase Level4 @@ -106,7 +110,7 @@ Disabled - ..\..\Include;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;..\..\ThirdParty\LibJPEG;%(AdditionalIncludeDirectories) + ..\..\Include;..\Drivers\OniFile;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;..\..\ThirdParty\LibJPEG;%(AdditionalIncludeDirectories) _WINDLL;%(PreprocessorDefinitions);OPENNI2_EXPORT ProgramDatabase Level4 @@ -131,7 +135,7 @@ MaxSpeed true _MBCS;%(PreprocessorDefinitions);OPENNI2_EXPORT - ..\..\Include;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;..\..\ThirdParty\LibJPEG;%(AdditionalIncludeDirectories) + ..\..\Include;..\Drivers\OniFile;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;%(AdditionalIncludeDirectories) true true AnySuitable @@ -160,7 +164,7 @@ MaxSpeed true _MBCS;%(PreprocessorDefinitions);OPENNI2_EXPORT - ..\..\Include;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;..\..\ThirdParty\LibJPEG;%(AdditionalIncludeDirectories) + ..\..\Include;..\Drivers\OniFile;..\Drivers\OniFile\Formats;..\..\ThirdParty\PSCommon\XnLib\Include;..\..\ThirdParty\LibJPEG;%(AdditionalIncludeDirectories) true true AnySuitable @@ -186,9 +190,11 @@ + + @@ -205,6 +211,7 @@ + @@ -216,466 +223,6 @@ - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - - - false - false - false - false - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - TurnOffAllWarnings - @@ -683,6 +230,7 @@ + diff --git a/Source/Core/OpenNI.vcxproj.filters b/Source/Core/OpenNI.vcxproj.filters index 772c332e..e315fe3d 100644 --- a/Source/Core/OpenNI.vcxproj.filters +++ b/Source/Core/OpenNI.vcxproj.filters @@ -91,6 +91,15 @@ Header files + + Header files\API + + + Header files + + + Header files + @@ -111,12 +120,9 @@ {55e9600f-1711-4d5e-a48e-e65dc51bdd60} - + {7f764055-6a63-460f-9d1c-1013093ce542} - - {240bc040-07e2-4ff0-b823-9f95f737f8e5} - @@ -150,148 +156,7 @@ Source files - Header files\Formats - - - Header files\Formats - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG - - - Header files\Formats\LibJPEG + Source files\Formats Source files @@ -299,6 +164,12 @@ Source files + + Source files + + + Source files\Formats + diff --git a/Source/DepthUtils/Android.mk b/Source/DepthUtils/Android.mk index ba488c01..cab7263a 100644 --- a/Source/DepthUtils/Android.mk +++ b/Source/DepthUtils/Android.mk @@ -17,6 +17,8 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +include $(LOCAL_PATH)/../../ThirdParty/PSCommon/BuildSystem/CommonAndroid.mk + # Sources MY_SRC_FILES := \ $(LOCAL_PATH)/*.cpp \ @@ -24,15 +26,15 @@ MY_SRC_FILES := \ MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) -# C/CPP Flags -LOCAL_CFLAGS += $(OPENNI2_CFLAGS) - # Includes -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../../Include \ - $(LOCAL_PATH)/../../ThirdParty/PSCommon/XnLib/Include \ - +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Include + +LOCAL_STATIC_LIBRARIES := XnLib + # Output LOCAL_MODULE := DepthUtils include $(BUILD_STATIC_LIBRARY) + +#include XnLib +include $(LOCAL_PATH)/../../ThirdParty/PSCommon/XnLib/Source/Android.mk diff --git a/Source/DepthUtils/DepthUtils.cpp b/Source/DepthUtils/DepthUtils.cpp index de1fc571..01a9c490 100644 --- a/Source/DepthUtils/DepthUtils.cpp +++ b/Source/DepthUtils/DepthUtils.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "DepthUtils.h" #include "DepthUtilsImpl.h" diff --git a/Source/DepthUtils/DepthUtils.h b/Source/DepthUtils/DepthUtils.h index d3fef820..aab5c7a6 100644 --- a/Source/DepthUtils/DepthUtils.h +++ b/Source/DepthUtils/DepthUtils.h @@ -1,5 +1,25 @@ -#ifndef _DEPTH_UTILS_H_ -#define _DEPTH_UTILS_H_ +/***************************************************************************** +* * +* 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 DEPTHUTILS_H +#define DEPTHUTILS_H #include "OniCTypes.h" @@ -94,4 +114,4 @@ extern "C" int DepthUtilsSetColorResolution(DepthUtilsHandle handle, int xres, int yres); } -#endif // _DEPTH_UTILS_H_ \ No newline at end of file +#endif // DEPTHUTILS_H diff --git a/Source/DepthUtils/DepthUtils.vcxproj b/Source/DepthUtils/DepthUtils.vcxproj index dcab0b76..69bf8c88 100644 --- a/Source/DepthUtils/DepthUtils.vcxproj +++ b/Source/DepthUtils/DepthUtils.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -35,23 +35,27 @@ StaticLibrary true MultiByte + v120 StaticLibrary true MultiByte + v120 StaticLibrary false true MultiByte + v120 StaticLibrary false true MultiByte + v120 diff --git a/Source/DepthUtils/DepthUtilsImpl.cpp b/Source/DepthUtils/DepthUtilsImpl.cpp index 8da3e139..b2c42821 100644 --- a/Source/DepthUtils/DepthUtilsImpl.cpp +++ b/Source/DepthUtils/DepthUtilsImpl.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "DepthUtilsImpl.h" static XnInt32 GetFieldValueSigned(XnUInt32 regValue, XnInt32 fieldWidth, XnInt32 fieldOffset) @@ -262,33 +282,47 @@ XnStatus DepthUtilsImpl::TranslateSinglePixel(XnUInt32 x, XnUInt32 y, unsigned s ///////////////////////////////////// - XnDouble fullXRes = m_colorResolution.x; + XnDouble fullXRes; XnDouble fullYRes; XnBool bCrop = FALSE; - if ((9 * m_colorResolution.x / m_colorResolution.y) == 16) + // if color aspect ratio is different from depth one, assume it's cropped + if (m_colorResolution.x * m_depthResolution.y < m_colorResolution.y * m_depthResolution.x) { - fullYRes = m_colorResolution.x * 4 / 5; + fullXRes = m_colorResolution.x; + fullYRes = fullXRes * m_depthResolution.y / m_depthResolution.x; + bCrop = TRUE; + } + else if (m_colorResolution.x * m_depthResolution.y > m_colorResolution.y * m_depthResolution.x) + { + fullYRes = m_colorResolution.y; + fullXRes = fullYRes * m_depthResolution.x / m_depthResolution.y; bCrop = TRUE; } else { + fullXRes = m_colorResolution.x; fullYRes = m_colorResolution.y; bCrop = FALSE; } - // inflate to full res + // inflate translated pixel from current resolution into full one imageX = (XnUInt32)(fullXRes / m_depthResolution.x * imageX); imageY = (XnUInt32)(fullYRes / m_depthResolution.y * imageY); if (bCrop) { // crop from center - imageY -= (XnUInt32)(fullYRes - m_colorResolution.y)/2; + imageY += (XnUInt32)(m_colorResolution.y - fullYRes)/2; if (imageY > (XnUInt32)m_colorResolution.y) { return XN_STATUS_BAD_PARAM; } + imageX += (XnUInt32)(m_colorResolution.x - fullXRes)/2; + if (imageX > (XnUInt32)m_colorResolution.x) + { + return XN_STATUS_BAD_PARAM; + } } return XN_STATUS_OK; diff --git a/Source/DepthUtils/DepthUtilsImpl.h b/Source/DepthUtils/DepthUtilsImpl.h index 49fc794d..cfe8e3eb 100644 --- a/Source/DepthUtils/DepthUtilsImpl.h +++ b/Source/DepthUtils/DepthUtilsImpl.h @@ -1,5 +1,25 @@ -#ifndef _DEPTH_UTILS_IMPL_H_ -#define _DEPTH_UTILS_IMPL_H_ +/***************************************************************************** +* * +* 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 DEPTHUTILSIMPL_H +#define DEPTHUTILSIMPL_H #include #include "DepthUtils.h" @@ -74,4 +94,4 @@ class DepthUtilsImpl }; -#endif \ No newline at end of file +#endif // DEPTHUTILSIMPL_H diff --git a/Source/DepthUtils/Makefile b/Source/DepthUtils/Makefile index ce4de1f1..4cf1d211 100644 --- a/Source/DepthUtils/Makefile +++ b/Source/DepthUtils/Makefile @@ -12,9 +12,15 @@ SRC_FILES = \ *.cpp \ ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib - LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib + LDFLAGS += \ + -framework CoreFoundation \ + -framework IOKit endif SLIB_NAME = DepthUtils diff --git a/Source/Documentation/Doxyfile b/Source/Documentation/Doxyfile index 6ba86238..4e99f61d 100644 --- a/Source/Documentation/Doxyfile +++ b/Source/Documentation/Doxyfile @@ -885,7 +885,7 @@ GENERATE_HTML = YES # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. -HTML_OUTPUT = html +HTML_OUTPUT = cpp # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank diff --git a/Source/Documentation/Runme.py b/Source/Documentation/Runme.py index b0b87282..b67a0f68 100755 --- a/Source/Documentation/Runme.py +++ b/Source/Documentation/Runme.py @@ -1,4 +1,25 @@ -#!/usr/bin/python +#!/usr/bin/python2.7 +#/**************************************************************************** +#* * +#* 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. * +#* * +#****************************************************************************/ +#!/usr/bin/python2 import os import sys @@ -38,7 +59,7 @@ def create_page(orig_path, page_name, page_header): else: javaDocExe = 'javadoc' -javaSrc = os.path.join('..', '..', 'Wrappers', 'java', 'OpenNI.java', 'src', 'org', 'openni') +javaSrc = os.path.join('..', '..', 'Wrappers', 'java', 'src', 'org', 'openni') # workaround a strange linux behavior where you must pass the list of files cmd = [javaDocExe, '-d', 'java'] diff --git a/Source/Drivers/DummyDevice/DummyDevice.vcxproj b/Source/Drivers/DummyDevice/DummyDevice.vcxproj index 56c59443..69b41de0 100644 --- a/Source/Drivers/DummyDevice/DummyDevice.vcxproj +++ b/Source/Drivers/DummyDevice/DummyDevice.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ DynamicLibrary true MultiByte + v120 DynamicLibrary true MultiByte + v120 DynamicLibrary false true MultiByte + v120 DynamicLibrary false true MultiByte + v120 diff --git a/Source/Drivers/DummyDevice/Makefile b/Source/Drivers/DummyDevice/Makefile index bb4ebc74..80254118 100644 --- a/Source/Drivers/DummyDevice/Makefile +++ b/Source/Drivers/DummyDevice/Makefile @@ -10,9 +10,15 @@ SRC_FILES = \ *.cpp ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib - LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib + LDFLAGS += \ + -framework CoreFoundation \ + -framework IOKit endif LIB_NAME = DummyDevice diff --git a/Source/Drivers/Kinect/BaseKinectStream.cpp b/Source/Drivers/Kinect/BaseKinectStream.cpp index 93f81751..fd4c3e07 100644 --- a/Source/Drivers/Kinect/BaseKinectStream.cpp +++ b/Source/Drivers/Kinect/BaseKinectStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "BaseKinectStream.h" #include "KinectStreamImpl.h" #include @@ -16,6 +36,7 @@ BaseKinectStream::BaseKinectStream(KinectStreamImpl* pStreamImpl): { m_running = false; m_cropping.enabled = FALSE; + m_mirroring = FALSE; pStreamImpl->addStream(this); } @@ -44,6 +65,7 @@ void BaseKinectStream::destroy() m_pStreamImpl->removeStream(this); } +// TODO: EXACT_PROP_SIZE_OR_XXX should be used for property size checking rather than copy-and-pasting OniStatus BaseKinectStream::getProperty(int propertyId, void* data, int* pDataSize) { OniStatus status = ONI_STATUS_NOT_SUPPORTED; @@ -60,6 +82,13 @@ OniStatus BaseKinectStream::getProperty(int propertyId, void* data, int* pDataSi status = GetCropping((OniCropping*)data); } break; + case ONI_STREAM_PROPERTY_MIRRORING: + { + EXACT_PROP_SIZE_OR_RETURN(*pDataSize, OniBool); + *(OniBool*)data = m_mirroring; + status = ONI_STATUS_OK; + } + break; case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: { float* val = (float*)data; @@ -118,6 +147,12 @@ OniStatus BaseKinectStream::setProperty(int propertyId, const void* data, int da } status = SetCropping((OniCropping*)data); } + else if (propertyId == ONI_STREAM_PROPERTY_MIRRORING) + { + EXACT_PROP_SIZE_OR_RETURN(dataSize, OniBool); + m_mirroring = *(OniBool*)data; + status = ONI_STATUS_OK; + } else if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) { if (dataSize != sizeof(OniVideoMode)) @@ -136,6 +171,7 @@ OniBool BaseKinectStream::isPropertySupported(int propertyId) switch (propertyId) { case ONI_STREAM_PROPERTY_CROPPING: + case ONI_STREAM_PROPERTY_MIRRORING: case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: case ONI_STREAM_PROPERTY_VERTICAL_FOV: case ONI_STREAM_PROPERTY_VIDEO_MODE: diff --git a/Source/Drivers/Kinect/BaseKinectStream.h b/Source/Drivers/Kinect/BaseKinectStream.h index 5b36760e..d7bfedbc 100644 --- a/Source/Drivers/Kinect/BaseKinectStream.h +++ b/Source/Drivers/Kinect/BaseKinectStream.h @@ -1,5 +1,25 @@ -#ifndef _BASE_KINECT_STREAM_H_ -#define _BASE_KINECT_STREAM_H_ +/***************************************************************************** +* * +* 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 BASEKINECTSTREAM_H +#define BASEKINECTSTREAM_H #include "Driver\OniDriverAPI.h" #include "XnLib.h" @@ -53,6 +73,7 @@ class BaseKinectStream : public oni::driver::StreamBase KinectStreamImpl *m_pStreamImpl; OniVideoMode m_videoMode; OniCropping m_cropping; + OniBool m_mirroring; bool m_running; private: @@ -60,4 +81,17 @@ class BaseKinectStream : public oni::driver::StreamBase }; } // namespace kinect_device -#endif //_BASE_KINECT_STREAM_H_ + +// Macro to ensure the property size. +// To be used in getProperty/setProperty implementation. +// Borrowed from Drivers/PSLink/PrimeClientDefs.h and modified a bit. +#define EXACT_PROP_SIZE_OR_DO(size, type) if ((size_t)(size) != sizeof(type)) + +#define EXACT_PROP_SIZE_OR_RETURN(size, type) \ + EXACT_PROP_SIZE_OR_DO(size, type) \ + { \ + printf("Unexpected size: %d != %d\n", (size), sizeof(type)); /* TODO: Better to use log */ \ + return ONI_STATUS_ERROR; \ + } + +#endif // BASEKINECTSTREAM_H diff --git a/Source/Drivers/Kinect/ColorKinectStream.cpp b/Source/Drivers/Kinect/ColorKinectStream.cpp index d7255eaf..fd0ca6b6 100644 --- a/Source/Drivers/Kinect/ColorKinectStream.cpp +++ b/Source/Drivers/Kinect/ColorKinectStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "ColorKinectStream.h" #include @@ -38,83 +58,20 @@ OniStatus ColorKinectStream::start() void ColorKinectStream::frameReceived(NUI_IMAGE_FRAME& imageFrame, NUI_LOCKED_RECT &LockedRect) { OniFrame* pFrame = getServices().acquireFrame(); + if (m_videoMode.pixelFormat == ONI_PIXEL_FORMAT_RGB888) { - struct Rgba { unsigned char b, g, r, a; }; - struct Rgb { unsigned char r, g, b; }; - if (!m_cropping.enabled) - { - Rgba* data_in = reinterpret_cast(LockedRect.pBits); - Rgb* data_out = reinterpret_cast(pFrame->data); - pFrame->dataSize = m_videoMode.resolutionY * m_videoMode.resolutionX * 3; - Rgba * data_in_end = data_in + (m_videoMode.resolutionY * m_videoMode.resolutionX); - while (data_in < data_in_end) - { - data_out->b = data_in->b; - data_out->r = data_in->r; - data_out->g = data_in->g; - ++data_in; - ++data_out; - } - pFrame->stride = m_videoMode.resolutionX * 3; - } - else - { - Rgba* data_in = reinterpret_cast(LockedRect.pBits); - Rgb* data_out = reinterpret_cast(pFrame->data); - pFrame->dataSize = m_cropping.height * m_cropping.width * 3; - int cropX = m_cropping.originX; - int cropY = m_cropping.originY; - while (cropY < m_cropping.originY + m_cropping.height) - { - while (cropX < m_cropping.originX + m_cropping.width) - { - Rgba* iter = data_in + (cropX + m_videoMode.resolutionX * cropY); - unsigned char c = iter->b; - data_out->b = c; - data_out->r = iter->r; - data_out->g = iter->g; - ++data_out; - ++cropX; - } - ++cropY; - cropX = m_cropping.originX; - } - pFrame->stride = m_cropping.width * 3; - } + copyFrameRGB888(pFrame, imageFrame, LockedRect); + } + else if (m_videoMode.pixelFormat == ONI_PIXEL_FORMAT_YUV422) + { + copyFrameYUV422(pFrame, imageFrame, LockedRect); } else { - if (!m_cropping.enabled) - { - xnOSMemCopy(pFrame->data, LockedRect.pBits, LockedRect.size); - pFrame->dataSize = LockedRect.size; - pFrame->stride = m_videoMode.resolutionX * 2; - } - else - { - unsigned short* data_in = reinterpret_cast(LockedRect.pBits); - unsigned short* data_out = reinterpret_cast(pFrame->data); - pFrame->dataSize = m_cropping.height * m_cropping.width * 2; - - int cropX = m_cropping.originX; - int cropY = m_cropping.originY; - while (cropY < m_cropping.originY + m_cropping.height) - { - while (cropX < m_cropping.originX + m_cropping.width) - { - unsigned short* iter = data_in + (cropX + m_videoMode.resolutionX * cropY); - *data_out = *iter; - ++data_out; - ++cropX; - } - cropY++; - cropX = m_cropping.originX; - } - pFrame->stride = m_cropping.width * 2; - - } + XN_ASSERT(FALSE); // unsupported format. should not come here. } + pFrame->videoMode.resolutionX = m_videoMode.resolutionX; pFrame->videoMode.resolutionY = m_videoMode.resolutionY; if (m_cropping.enabled) @@ -142,6 +99,96 @@ void ColorKinectStream::frameReceived(NUI_IMAGE_FRAME& imageFrame, NUI_LOCKED_RE getServices().releaseFrame(pFrame); } +void ColorKinectStream::copyFrameRGB888(OniFrame* pFrame, NUI_IMAGE_FRAME& imageFrame, NUI_LOCKED_RECT &LockedRect) +{ + struct Rgba { unsigned char b, g, r, a; }; + + struct RgbaToRgbPixelCopier + { + void operator()(const Rgba* const in, OniRGB888Pixel* const out) + { + out->r = in->r; + out->g = in->g; + out->b = in->b; + } + }; + + typedef LineCopier > ForwardLineCopier; + typedef RectCopier, ForwardMover > ForwardRectCopier; + typedef RectCopier, ForwardMover > MirrorRectCopier; + + Rgba* in = reinterpret_cast(LockedRect.pBits); + OniRGB888Pixel* out = reinterpret_cast(pFrame->data); + + FrameCopier copyFrame; + copyFrame(in, out, pFrame, m_videoMode, m_cropping, m_mirroring); +} + +void ColorKinectStream::copyFrameYUV422(OniFrame* pFrame, NUI_IMAGE_FRAME& imageFrame, NUI_LOCKED_RECT &LockedRect) +{ + // I YUV422, two pixels are packed into a 4-byte sequence. + // We need a little tricky mapping implementation for mirror mode. + + OniYUV422DoublePixel* in = reinterpret_cast(LockedRect.pBits); + OniYUV422DoublePixel* out = reinterpret_cast(pFrame->data); + + int resolutionXInPackets = m_videoMode.resolutionX / 2; + + struct SwappedYUV422PixelCopier + { + void operator()(const OniYUV422DoublePixel* const in, OniYUV422DoublePixel* const out) + { + out->u = in->u; + out->y1 = in->y2; + out->v = in->v; + out->y2 = in->y1; + } + }; + + typedef RectCopier, + ForwardMover, ForwardMover > ForwardRectCopier; + typedef RectCopier, ForwardMover > MirrorRectCopier; + + if (!m_cropping.enabled) + { + pFrame->dataSize = LockedRect.size; + pFrame->stride = m_videoMode.resolutionX * 2; + + if (!m_mirroring) + { + // optimized copy + xnOSMemCopy(pFrame->data, LockedRect.pBits, LockedRect.size); + } else { + MirrorRectCopier copyRect; + copyRect(in + resolutionXInPackets - 1, out, + resolutionXInPackets, resolutionXInPackets, m_videoMode.resolutionY); + } + } + else + { + int pixelCount = m_cropping.height * m_cropping.width; + pFrame->dataSize = pixelCount * 2; + pFrame->stride = m_cropping.width * 2; + + int originXInPackets = m_cropping.originX / 2; + int copyWidthInPackets = m_cropping.width / 2; + + if (!m_mirroring) + { + ForwardRectCopier copyRect; + OniYUV422DoublePixel* origin = in + m_cropping.originY * resolutionXInPackets + originXInPackets; + copyRect(origin, out, copyWidthInPackets, resolutionXInPackets, m_cropping.height); + } + else + { + MirrorRectCopier copyRect; + OniYUV422DoublePixel* origin = in + (m_cropping.originY+1) * resolutionXInPackets - originXInPackets - 1; + copyRect(origin, out, copyWidthInPackets, resolutionXInPackets, m_cropping.height); + } + } +} + OniStatus ColorKinectStream::getProperty(int propertyId, void* data, int* pDataSize) { OniStatus status = ONI_STATUS_NOT_IMPLEMENTED; diff --git a/Source/Drivers/Kinect/ColorKinectStream.h b/Source/Drivers/Kinect/ColorKinectStream.h index 2a5a3631..a8de345d 100644 --- a/Source/Drivers/Kinect/ColorKinectStream.h +++ b/Source/Drivers/Kinect/ColorKinectStream.h @@ -1,5 +1,25 @@ -#ifndef _COLOR_KINECT_STREAM_H_ -#define _COLOR_KINECT_STREAM_H_ +/***************************************************************************** +* * +* 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 COLORKINECTSTREAM_H +#define COLORKINECTSTREAM_H #include "BaseKinectStream.h" @@ -21,7 +41,11 @@ class ColorKinectStream : public BaseKinectStream virtual OniStatus setProperty(int propertyId, const void* data, int pDataSize); virtual OniBool isPropertySupported(int propertyId); + +private: + void copyFrameRGB888(OniFrame* pFrame, NUI_IMAGE_FRAME& imageFrame, NUI_LOCKED_RECT &LockedRect); + void copyFrameYUV422(OniFrame* pFrame, NUI_IMAGE_FRAME& imageFrame, NUI_LOCKED_RECT &LockedRect); }; } // namespace kinect_device -#endif //_COLOR_KINECT_STREAM_H_ +#endif // COLORKINECTSTREAM_H diff --git a/Source/Drivers/Kinect/D2S.h.h b/Source/Drivers/Kinect/D2S.h.h index 4456f2a5..87b08ee2 100644 --- a/Source/Drivers/Kinect/D2S.h.h +++ b/Source/Drivers/Kinect/D2S.h.h @@ -1,3 +1,26 @@ +/***************************************************************************** +* * +* 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 D2S_H_H +#define D2S_H_H + XnUInt16 D2S[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1001,3 +1024,5 @@ XnUInt16 D2S[] = { 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052}; + +#endif // D2S_H_H diff --git a/Source/Drivers/Kinect/DepthKinectStream.cpp b/Source/Drivers/Kinect/DepthKinectStream.cpp index 505c400f..d68efec1 100644 --- a/Source/Drivers/Kinect/DepthKinectStream.cpp +++ b/Source/Drivers/Kinect/DepthKinectStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "DepthKinectStream.h" #include @@ -9,6 +29,7 @@ #include "D2S.h.h" #include "S2D.h.h" #include "KinectStreamImpl.h" +#include "KinectProperties.h" using namespace oni::driver; using namespace kinect_device; @@ -57,6 +78,7 @@ void DepthKinectStream::populateFrameImageMetadata(OniFrame* pFrame, int dataUni pFrame->cropOriginY = m_cropping.originY; pFrame->croppingEnabled = TRUE; } + pFrame->dataSize = pFrame->width * pFrame->height * dataUnitSize; pFrame->stride = pFrame->width * dataUnitSize; pFrame->videoMode.resolutionY = m_videoMode.resolutionY; pFrame->videoMode.resolutionX = m_videoMode.resolutionX; @@ -78,96 +100,114 @@ static void recordAverageProcessTime(const char* message, LARGE_INTEGER* pAccTim // Copy the depth pixels (NUI_DEPTH_IMAGE_PIXEL) to OniDriverFrame // with applying cropping but NO depth-to-image registration. -void DepthKinectStream::copyDepthPixelsStraight(const NUI_DEPTH_IMAGE_PIXEL* source, int numPoints, OniFrame* pFrame) +void DepthKinectStream::copyDepthPixelsStraight(const NUI_DEPTH_IMAGE_PIXEL* in, int numPoints, OniFrame* pFrame) { - // Note: The local variable assignments and const qualifiers are carefully designed to generate - // a high performance code with VC 2010. We recommend check the performance when changing the code - // even if it was a trivial change. - - // For benchmarking purpose + // FIXME: for preliminary benchmarking purpose LARGE_INTEGER startTime; QueryPerformanceCounter(&startTime); - unsigned short* target = (unsigned short*) pFrame->data; - - const unsigned int width = pFrame->width; - const unsigned int height = pFrame->height; - const unsigned int skipWidth = m_videoMode.resolutionX - width; - - // Offset the starting position - source += pFrame->cropOriginX + pFrame->cropOriginY * m_videoMode.resolutionX; - - for (unsigned int y = 0; y < height; y++) + struct DepthPixelCopier { - for (unsigned int x = 0; x < width; x++) + void operator()(const NUI_DEPTH_IMAGE_PIXEL* const in, OniDepthPixel* const out) { - *(target++) = filterReliableDepthValue((source++)->depth); + *out = filterReliableDepthValue(in->depth); } - source += skipWidth; - } + }; + + typedef LineCopier > ForwardLineCopier; + typedef RectCopier, ForwardMover > ForwardRectCopier; + typedef RectCopier, ForwardMover > MirrorRectCopier; + + OniDepthPixel* out = reinterpret_cast(pFrame->data); + + FrameCopier copyFrame; + copyFrame(in, out, pFrame, m_videoMode, m_cropping, m_mirroring); // FIXME: for preliminary benchmarking purpose static LARGE_INTEGER accTime, accCount; recordAverageProcessTime("No Image Reg", &accTime, &accCount, startTime); } +// // Copy the depth pixels (NUI_DEPTH_IMAGE_PIXEL) to OniDriverFrame // with applying cropping and depth-to-image registration. +// +// Note: The local variable assignments and const qualifiers are carefully designed to generate +// a high performance code with VC 2010. We recommend check the performance when changing the code +// even if it was a trivial change. +// + +// Helper template +template +struct DepthMapper +{ + void operator()(const NUI_DEPTH_IMAGE_PIXEL* const in, OniDepthPixel* const out, + const int* mappedCoordsIter, const unsigned int numPoints, OniFrame* pFrame, XTransformer transformX) + { + const unsigned int width = pFrame->width; + const unsigned int height = pFrame->height; + const unsigned int minX = pFrame->cropOriginX; + const unsigned int minY = pFrame->cropOriginY; + + for (unsigned int i = 0; i < numPoints; i++) + { + const unsigned int x = transformX(*mappedCoordsIter++) - minX; + const unsigned int y = *mappedCoordsIter++ - minY; + if (x < width - 1 && y < height) { + const unsigned short d = filterReliableDepthValue((in+i)->depth); + OniDepthPixel* p = out + x + y * width; + if (*p == 0 || *p > d) *p = d; + p++; + if (*p == 0 || *p > d) *p = d; + } + } + } +}; + +// Function body void DepthKinectStream::copyDepthPixelsWithImageRegistration(const NUI_DEPTH_IMAGE_PIXEL* source, int numPoints, OniFrame* pFrame) { // Note: We evaluated another possible implementation using INuiCoordinateMapper*::MapColorFrameToDepthFrame, // but, counterintuitively, it turned out to be slower than this implementation. We reverted it back. - // Note: The local variable assignments and const qualifiers are carefully designed to generate - // a high performance code with VC 2010. We recommend check the performance when changing the code - // even if it was a trivial change. - - // For benchmarking purpose + // FIXME: for preliminary benchmarking purpose LARGE_INTEGER startTime; QueryPerformanceCounter(&startTime); - NUI_IMAGE_RESOLUTION nuiResolution = - m_pStreamImpl->getNuiImagResolution(pFrame->videoMode.resolutionX, pFrame->videoMode.resolutionY); - - unsigned short* const target = (unsigned short*) pFrame->data; + OniDepthPixel* const target = (OniDepthPixel*) pFrame->data; xnOSMemSet(target, 0, pFrame->dataSize); - m_depthValuesBuffer.SetSize(numPoints); m_mappedCoordsBuffer.SetSize(numPoints * 2); - // Pack depth data for NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution - USHORT* depthValuesIter = m_depthValuesBuffer.GetData(); - for (int i = 0; i < numPoints; i++) { - *(depthValuesIter++) = (source + i)->depth << 3; - } - - // Need review: not sure if it is a good idea to directly invoke INuiSensore here. - m_pStreamImpl->getNuiSensor()->NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution( - nuiResolution, // assume the target image with the same resolution as the source. - nuiResolution, + HRESULT hr = m_pStreamImpl->convertDepthFrameToColorCoordinates( + m_videoMode, // assume the target image with the same resolution as the source. + source, numPoints, - m_depthValuesBuffer.GetData(), - numPoints * 2, m_mappedCoordsBuffer.GetData() ); + XN_ASSERT(SUCCEEDED(hr)); - const unsigned int minX = pFrame->cropOriginX; - const unsigned int minY = pFrame->cropOriginY; - const unsigned int width = pFrame->width; - const unsigned int height = pFrame->height; - const LONG* mappedCoordsIter = m_mappedCoordsBuffer.GetData(); + if (!m_mirroring) { + struct ForwardXTransformer + { + unsigned int operator()(const unsigned int x) { return x; } + }; - for (int i = 0; i < numPoints; i++) - { - const unsigned int x = *mappedCoordsIter++ - minX; - const unsigned int y = *mappedCoordsIter++ - minY; - if (x < width - 1 && y < height) { - const unsigned short d = filterReliableDepthValue((source+i)->depth); - unsigned short* p = target + x + y * width; - if (*p == 0 || *p > d) *p = d; - p++; - if (*p == 0 || *p > d) *p = d; - } + DepthMapper mapDepth; + mapDepth(source, target, m_mappedCoordsBuffer.GetData(), numPoints, pFrame, ForwardXTransformer()); + } else { + struct BackwardXTransformer + { + const unsigned int m_width; + + BackwardXTransformer(unsigned int width) : m_width(width) {} + + // Note the range of x is 0 <= x <= width - 2 + unsigned int operator()(const unsigned int x) { return m_width - x - 2; } + }; + + DepthMapper mapDepth; + mapDepth(source, target, m_mappedCoordsBuffer.GetData(), numPoints, pFrame, BackwardXTransformer(pFrame->videoMode.resolutionX)); } // FIXME: for preliminary benchmarking purpose @@ -217,13 +257,6 @@ OniStatus DepthKinectStream::getProperty(int propertyId, void* data, int* pDataS status = ONI_STATUS_OK; break; } - case ONI_STREAM_PROPERTY_MIRRORING: - { - XnBool * val = (XnBool *)data; - *val = TRUE; - status = ONI_STATUS_OK; - break; - } case XN_STREAM_PROPERTY_CLOSE_RANGE: case XN_STREAM_PROPERTY_INPUT_FORMAT: case XN_STREAM_PROPERTY_CROPPING_MODE: @@ -311,6 +344,12 @@ OniStatus DepthKinectStream::getProperty(int propertyId, void* data, int* pDataS status = ONI_STATUS_OK; break; } + case KINECT_DEPTH_PROPERTY_CLOSE_RANGE: + { + EXACT_PROP_SIZE_OR_RETURN(*pDataSize, OniBool); + status = getNearMode((OniBool*)data); + break; + } default: status = BaseKinectStream::getProperty(propertyId, data, pDataSize); break; @@ -319,6 +358,25 @@ OniStatus DepthKinectStream::getProperty(int propertyId, void* data, int* pDataS return status; } +OniStatus DepthKinectStream::setProperty(int propertyId, const void* data, int dataSize) +{ + OniStatus status = ONI_STATUS_NOT_SUPPORTED; + switch (propertyId) + { + case KINECT_DEPTH_PROPERTY_CLOSE_RANGE: + { + EXACT_PROP_SIZE_OR_RETURN(dataSize, OniBool); + status = setNearMode(*(OniBool*)data); + break; + } + default: + status = BaseKinectStream::setProperty(propertyId, data, dataSize); + break; + } + + return status; +} + OniBool DepthKinectStream::isPropertySupported(int propertyId) { OniBool status = FALSE; @@ -336,6 +394,7 @@ OniBool DepthKinectStream::isPropertySupported(int propertyId) case XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE: case XN_STREAM_PROPERTY_S2D_TABLE: case XN_STREAM_PROPERTY_D2S_TABLE: + case KINECT_DEPTH_PROPERTY_CLOSE_RANGE: status = TRUE; default: status = BaseKinectStream::isPropertySupported(propertyId); @@ -382,5 +441,27 @@ void DepthKinectStream::notifyAllProperties() size = sizeof(D2S); getProperty(XN_STREAM_PROPERTY_D2S_TABLE, nBuff, &size); raisePropertyChanged(XN_STREAM_PROPERTY_D2S_TABLE, nBuff, size); + + size = sizeof(PARAM_COEFF_VAL); + getProperty(XN_STREAM_PROPERTY_PARAM_COEFF, nBuff, &size); + raisePropertyChanged(XN_STREAM_PROPERTY_PARAM_COEFF, nBuff, size); + + // Is this really necessary to save? Just in case. + OniBool nearMode; + size = sizeof(nearMode); + getProperty(KINECT_DEPTH_PROPERTY_CLOSE_RANGE, &nearMode, &size); + raisePropertyChanged(KINECT_DEPTH_PROPERTY_CLOSE_RANGE, &nearMode, size); + BaseKinectStream::notifyAllProperties(); } + +OniStatus DepthKinectStream::setNearMode(OniBool value) +{ + return m_pStreamImpl->setImageFrameFlags(NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE, value); +} + +OniStatus DepthKinectStream::getNearMode(OniBool* pValue) +{ + *pValue = m_pStreamImpl->getImageFrameFlags(NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE); + return ONI_STATUS_OK; +} diff --git a/Source/Drivers/Kinect/DepthKinectStream.h b/Source/Drivers/Kinect/DepthKinectStream.h index 32616359..645744bf 100644 --- a/Source/Drivers/Kinect/DepthKinectStream.h +++ b/Source/Drivers/Kinect/DepthKinectStream.h @@ -1,5 +1,25 @@ -#ifndef _DEPTH_KINECT_STREAM_H_ -#define _DEPTH_KINECT_STREAM_H_ +/***************************************************************************** +* * +* 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 DEPTHKINECTSTREAM_H +#define DEPTHKINECTSTREAM_H #include "BaseKinectStream.h" #include "XnArray.h" @@ -18,17 +38,21 @@ class DepthKinectStream : public BaseKinectStream virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize); + virtual OniStatus setProperty(int propertyId, const void* data, int dataSize); + virtual OniBool isPropertySupported(int propertyId); virtual void notifyAllProperties(); private: - xnl::Array m_depthValuesBuffer; - xnl::Array m_mappedCoordsBuffer; + xnl::Array m_mappedCoordsBuffer; void populateFrameImageMetadata(OniFrame* pFrame, int dataUnitSize); void copyDepthPixelsStraight(const NUI_DEPTH_IMAGE_PIXEL* source, int numPoints, OniFrame* pFrame); void copyDepthPixelsWithImageRegistration(const NUI_DEPTH_IMAGE_PIXEL* source, int numPoints, OniFrame* pFrame); + + OniStatus setNearMode(OniBool value); + OniStatus getNearMode(OniBool* pValue); }; } // namespace kinect_device -#endif //_DEPTH_KINECT_STREAM_H_ +#endif // DEPTHKINECTSTREAM_H diff --git a/Source/Drivers/Kinect/IRKinectStream.cpp b/Source/Drivers/Kinect/IRKinectStream.cpp index 2aa43df7..3fb9621f 100644 --- a/Source/Drivers/Kinect/IRKinectStream.cpp +++ b/Source/Drivers/Kinect/IRKinectStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "IRKinectStream.h" #include @@ -38,109 +58,73 @@ OniStatus IRKinectStream::start() void IRKinectStream::frameReceived(NUI_IMAGE_FRAME& imageFrame, NUI_LOCKED_RECT &LockedRect) { OniFrame* pFrame = getServices().acquireFrame(); + if (m_videoMode.pixelFormat == ONI_PIXEL_FORMAT_GRAY16) { - unsigned short* data_in = reinterpret_cast(LockedRect.pBits); - unsigned short* data_out = reinterpret_cast(pFrame->data); - if (!m_cropping.enabled) + struct IRToGray16PixelCopier { - unsigned short* data_in_end = data_in + (m_videoMode.resolutionY * m_videoMode.resolutionX); - while (data_in < data_in_end) + void operator()(const USHORT* const in, OniGrayscale16Pixel* const out) { - unsigned short intensity = (*data_in)>> 6; - *data_out = intensity; - ++data_in; - ++data_out; + *out = (*in) >> 6; } - pFrame->stride = m_videoMode.resolutionX * 2; - } - else - { - int cropY = m_cropping.originY; - while (cropY < m_cropping.originY + m_cropping.height) - { - int cropX = m_cropping.originX; - while (cropX < m_cropping.originX + m_cropping.width) - { - unsigned short *iter = data_in + (cropY * m_videoMode.resolutionX + cropX++); - *(data_out++) = (*iter) >> 6; - } - cropY++; - } - pFrame->stride = m_cropping.width * 2; - } + }; + + typedef LineCopier > ForwardLineCopier; + typedef RectCopier, ForwardMover > ForwardRectCopier; + typedef RectCopier, ForwardMover > MirrorRectCopier; + + USHORT* in = reinterpret_cast(LockedRect.pBits); + OniGrayscale16Pixel* out = reinterpret_cast(pFrame->data); + + FrameCopier copyFrame; + copyFrame(in, out, pFrame, m_videoMode, m_cropping, m_mirroring); } else if (m_videoMode.pixelFormat == ONI_PIXEL_FORMAT_GRAY8) { - unsigned short* data_in = reinterpret_cast(LockedRect.pBits); - char* data_out = reinterpret_cast(pFrame->data); - if (!m_cropping.enabled) + struct IRToGray8PixelCopier { - unsigned short* data_in_end = data_in + (m_videoMode.resolutionY * m_videoMode.resolutionX); - while (data_in < data_in_end) + void operator()(const USHORT* const in, OniGrayscale8Pixel* const out) { - char intensity = (*data_in)>> 8; - (*data_out) = intensity; - ++data_in; - ++data_out; + *out = (*in) >> 8; } - pFrame->stride = m_videoMode.resolutionX; - } - else + }; + + typedef LineCopier > ForwardLineCopier; + typedef RectCopier, ForwardMover > ForwardRectCopier; + typedef RectCopier, ForwardMover > MirrorRectCopier; + + USHORT* in = reinterpret_cast(LockedRect.pBits); + OniGrayscale8Pixel* out = reinterpret_cast(pFrame->data); + + FrameCopier copyFrame; + copyFrame(in, out, pFrame, m_videoMode, m_cropping, m_mirroring); + } + else if (m_videoMode.pixelFormat == ONI_PIXEL_FORMAT_RGB888) + { + struct IRToRgbPixelCopier { - int cropY = m_cropping.originY; - while (cropY < m_cropping.originY + m_cropping.height) + void operator()(const USHORT* const in, OniRGB888Pixel* const out) { - int cropX = m_cropping.originX; - while (cropX < m_cropping.originX + m_cropping.width) - { - unsigned short *iter = data_in + (cropY * m_videoMode.resolutionX + cropX++); - char intensity = (*iter) >> 8; - *(data_out++) = intensity; - } - cropY++; + BYTE intensity = (*in) >> 8; + out->r = intensity; + out->g = intensity; + out->b = intensity; } - pFrame->stride = m_cropping.width * 2; + }; + + typedef LineCopier > ForwardLineCopier; + typedef RectCopier, ForwardMover > ForwardRectCopier; + typedef RectCopier, ForwardMover > MirrorRectCopier; - } + USHORT* in = reinterpret_cast(LockedRect.pBits); + OniRGB888Pixel* out = reinterpret_cast(pFrame->data); + + FrameCopier copyFrame; + copyFrame(in, out, pFrame, m_videoMode, m_cropping, m_mirroring); } else { - struct Rgb { unsigned char r, g, b; }; - unsigned short* data_in = reinterpret_cast(LockedRect.pBits); - Rgb* data_out = reinterpret_cast(pFrame->data); - if (!m_cropping.enabled) - { - unsigned short* data_in_end = data_in + (m_videoMode.resolutionY * m_videoMode.resolutionX); - while (data_in < data_in_end) - { - char intensity = (*data_in)>> 8; - data_out->b = intensity; - data_out->r = intensity; - data_out->g = intensity; - ++data_in; - ++data_out; - } - pFrame->stride = m_videoMode.resolutionX * 3; - } - else - { - int cropY = m_cropping.originY; - while (cropY < m_cropping.originY + m_cropping.height) - { - int cropX = m_cropping.originX; - while (cropX < m_cropping.originX + m_cropping.width) - { - unsigned short *iter = data_in + (cropY * m_videoMode.resolutionX + cropX++); - char intensity = (*iter) >> 8; - data_out->b = intensity; - data_out->r = intensity; - data_out++->g = intensity; - } - cropY++; - } - pFrame->stride = m_cropping.width * 3; - } + XN_ASSERT(FALSE); // unsupported format. should not come here. } if (!m_cropping.enabled) diff --git a/Source/Drivers/Kinect/IRKinectStream.h b/Source/Drivers/Kinect/IRKinectStream.h index 3f93f0a4..e723325d 100644 --- a/Source/Drivers/Kinect/IRKinectStream.h +++ b/Source/Drivers/Kinect/IRKinectStream.h @@ -1,5 +1,25 @@ -#ifndef _IR_KINECT_STREAM_H_ -#define _IR_KINECT_STREAM_H_ +/***************************************************************************** +* * +* 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 IRKINECTSTREAM_H +#define IRKINECTSTREAM_H #include "BaseKinectStream.h" @@ -18,4 +38,4 @@ class IRKinectStream : public BaseKinectStream }; } // namespace kinect_device -#endif //_IR_KINECT_STREAM_H_ +#endif // IRKINECTSTREAM_H diff --git a/Source/Drivers/Kinect/Kinect.vcxproj b/Source/Drivers/Kinect/Kinect.vcxproj index f54e8b2f..26143d38 100644 --- a/Source/Drivers/Kinect/Kinect.vcxproj +++ b/Source/Drivers/Kinect/Kinect.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,12 +28,14 @@ true Unicode true + v120 DynamicLibrary true Unicode true + v120 DynamicLibrary @@ -41,6 +43,7 @@ true MultiByte true + v120 DynamicLibrary @@ -48,6 +51,7 @@ true MultiByte true + v120 @@ -68,28 +72,21 @@ $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ - $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include - $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib; true $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ - $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; - $(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64; true $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ - $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; - $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib; false $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ - $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include false diff --git a/Source/Drivers/Kinect/KinectDevice.cpp b/Source/Drivers/Kinect/KinectDevice.cpp index 89247f79..adf83e3a 100644 --- a/Source/Drivers/Kinect/KinectDevice.cpp +++ b/Source/Drivers/Kinect/KinectDevice.cpp @@ -1,10 +1,30 @@ +/***************************************************************************** +* * +* 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 "KinectDevice.h" +#include "KinectProperties.h" #include "DepthKinectStream.h" #include "ColorKinectStream.h" #include "IRKinectStream.h" #include #include "NuiApi.h" -#include "XnLog.h" using namespace kinect_device; using namespace oni::driver; @@ -133,15 +153,28 @@ OniStatus KinectDevice::setProperty(int propertyId, const void* data, int dataSi switch (propertyId) { case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: { - // FIXME data size validation + EXACT_PROP_SIZE_OR_RETURN(dataSize, OniImageRegistrationMode); if (m_pDepthStream) { OniImageRegistrationMode* pMode = (OniImageRegistrationMode*)data; m_pDepthStream->setImageRegistrationMode(*pMode); return ONI_STATUS_OK; - } else { + } + else + { return ONI_STATUS_ERROR; } } + case KINECT_DEVICE_PROPERTY_CAMERA_ELEVATION: + { + EXACT_PROP_SIZE_OR_RETURN(dataSize, long); + return SUCCEEDED(m_pNuiSensor->NuiCameraElevationSetAngle(*(long*)data)) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } + case KINECT_DEVICE_PROPERTY_EMITTER_STATE: + { + EXACT_PROP_SIZE_OR_RETURN(dataSize, OniBool); + OniBool b = *(OniBool*)data; + return SUCCEEDED(m_pNuiSensor->NuiSetForceInfraredEmitterOff(!b)) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } } return ONI_STATUS_NOT_IMPLEMENTED; @@ -152,15 +185,65 @@ OniStatus KinectDevice::getProperty(int propertyId, void* data, int* pDataSize) switch (propertyId) { case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: { - // FIXME data size validation - if (m_pDepthStream) { + EXACT_PROP_SIZE_OR_RETURN(*pDataSize, OniImageRegistrationMode); + if (m_pDepthStream) + { OniImageRegistrationMode* pMode = (OniImageRegistrationMode*)data; *pMode = m_pDepthStream->getImageRegistrationMode(); return ONI_STATUS_OK; - } else { + } + else + { return ONI_STATUS_ERROR; } } + case KINECT_DEVICE_PROPERTY_CAMERA_ELEVATION: + { + EXACT_PROP_SIZE_OR_RETURN(*pDataSize, long); + return SUCCEEDED(m_pNuiSensor->NuiCameraElevationGetAngle((long*)data)) ? ONI_STATUS_OK : ONI_STATUS_ERROR; + } + case KINECT_DEVICE_PROPERTY_ACCELEROMETER: + { + EXACT_PROP_SIZE_OR_RETURN(*pDataSize, KinectVector3f); + Vector4 v; + if (SUCCEEDED(m_pNuiSensor->NuiAccelerometerGetCurrentReading(&v))) + { + KinectVector3f* pVector3f = (KinectVector3f*)(data); + pVector3f->x = v.x; + pVector3f->y = v.y; + pVector3f->z = v.z; + return ONI_STATUS_OK; + } + else + { + return ONI_STATUS_ERROR; + } + } + case KINECT_DEVICE_PROPERTY_EMITTER_STATE: + { + EXACT_PROP_SIZE_OR_RETURN(*pDataSize, OniBool); + *(OniBool*)data = !m_pNuiSensor->NuiGetForceInfraredEmitterOff(); + return ONI_STATUS_OK; + } + case KINECT_DEVICE_PROPERTY_AUDIO_ARRAY_ID: + { + char* arrayId = (char*)data; + BSTR wcsArrayId = m_pNuiSensor->NuiAudioArrayId(); + size_t len = wcstombs(arrayId, wcsArrayId, *pDataSize - 1); + SysFreeString(wcsArrayId); + + if (len == -1) + { + *pDataSize = 0; + return ONI_STATUS_ERROR; + } + else + { + arrayId[len] = '\0'; + *pDataSize = int(len + 1); + return ONI_STATUS_OK; + } + } } return ONI_STATUS_NOT_IMPLEMENTED; @@ -168,7 +251,16 @@ OniStatus KinectDevice::getProperty(int propertyId, void* data, int* pDataSize) OniBool KinectDevice::isPropertySupported(int propertyId) { - return (propertyId == ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION); + switch (propertyId) + { + case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: + case KINECT_DEVICE_PROPERTY_CAMERA_ELEVATION: + case KINECT_DEVICE_PROPERTY_ACCELEROMETER: + case KINECT_DEVICE_PROPERTY_EMITTER_STATE: + case KINECT_DEVICE_PROPERTY_AUDIO_ARRAY_ID: + return true; + } + return false; } OniBool KinectDevice::isCommandSupported(int commandId) diff --git a/Source/Drivers/Kinect/KinectDevice.h b/Source/Drivers/Kinect/KinectDevice.h index 0fd22646..1794d500 100644 --- a/Source/Drivers/Kinect/KinectDevice.h +++ b/Source/Drivers/Kinect/KinectDevice.h @@ -1,5 +1,25 @@ -#ifndef _KINECT_DEVICE_H_ -#define _KINECT_DEVICE_H_ +/***************************************************************************** +* * +* 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 KINECTDEVICE_H +#define KINECTDEVICE_H #include "Driver\OniDriverAPI.h" #include "KinectStreamImpl.h" @@ -38,4 +58,4 @@ class KinectDevice : public oni::driver::DeviceBase OniSensorInfo m_sensors[10]; }; } // namespace kinect_device -#endif //_KINECT_DRIVER_H_ \ No newline at end of file +#endif // KINECTDEVICE_H diff --git a/Source/Drivers/Kinect/KinectDriver.cpp b/Source/Drivers/Kinect/KinectDriver.cpp index b70e7369..f6c8be40 100644 --- a/Source/Drivers/Kinect/KinectDriver.cpp +++ b/Source/Drivers/Kinect/KinectDriver.cpp @@ -1,8 +1,27 @@ +/***************************************************************************** +* * +* 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 "KinectDriver.h" #include "KinectDevice.h" #include #include "NuiApi.h" -#include #include "XnLog.h" using namespace oni::driver; diff --git a/Source/Drivers/Kinect/KinectDriver.h b/Source/Drivers/Kinect/KinectDriver.h index 3d1b437e..f2b5dda7 100644 --- a/Source/Drivers/Kinect/KinectDriver.h +++ b/Source/Drivers/Kinect/KinectDriver.h @@ -1,5 +1,25 @@ -#ifndef _KINECT_DRIVER_H_ -#define _KINECT_DRIVER_H_ +/***************************************************************************** +* * +* 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 KINECTDRIVER_H +#define KINECTDRIVER_H #include "Driver\OniDriverAPI.h" #include "XnHash.h" @@ -33,4 +53,4 @@ class KinectDriver : public oni::driver::DriverBase xnl::Hash m_devices; }; } // namespace kinect_device -#endif //_KINECT_DRIVER_H_ +#endif // KINECTDRIVER_H diff --git a/Source/Drivers/Kinect/KinectStreamImpl.cpp b/Source/Drivers/Kinect/KinectStreamImpl.cpp index b9111784..7fe64fc4 100644 --- a/Source/Drivers/Kinect/KinectStreamImpl.cpp +++ b/Source/Drivers/Kinect/KinectStreamImpl.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "KinectStreamImpl.h" #include "BaseKinectStream.h" @@ -10,10 +30,11 @@ using namespace xnl; #define DEFAULT_FPS 30 KinectStreamImpl::KinectStreamImpl(INuiSensor *pNuiSensor, OniSensorType sensorType): + m_imageFrameFlags(0), m_pNuiSensor(pNuiSensor), m_sensorType(sensorType), m_running(FALSE), m_hStreamHandle(INVALID_HANDLE_VALUE), - m_hNextFrameEvent(CreateEvent(NULL, TRUE, FALSE, NULL)) - + m_hNextFrameEvent(CreateEvent(NULL, TRUE, FALSE, NULL)), + m_depthToImageCoordsConverter(pNuiSensor) { setDefaultVideoMode(); } @@ -61,7 +82,7 @@ OniStatus KinectStreamImpl::start() // Open a color image stream to receive frames HRESULT hr = m_pNuiSensor->NuiImageStreamOpen( getNuiImageType(), - getNuiImagResolution(m_videoMode.resolutionX, m_videoMode.resolutionY), + getNuiImageResolution(m_videoMode.resolutionX, m_videoMode.resolutionY), 0, 2, m_hNextFrameEvent, @@ -72,7 +93,10 @@ OniStatus KinectStreamImpl::start() return ONI_STATUS_ERROR; } - //m_pNuiSensor->NuiImageStreamSetImageFrameFlags(m_pStreamHandle, NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE); + if (pushImageFrameFlags() != ONI_STATUS_OK) + { + // ignore error + } XnStatus nRetVal = xnOSCreateThread(threadFunc, this, &m_threadHandle); if (nRetVal != XN_STATUS_OK) @@ -228,14 +252,20 @@ OniStatus KinectStreamImpl::convertDepthToColorCoordinates(StreamBase* colorStre if (ONI_STATUS_OK != colorStream->getProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, &videoMode, &size)) return ONI_STATUS_ERROR; HRESULT hr = m_pNuiSensor->NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution( - getNuiImagResolution(videoMode.resolutionX, videoMode.resolutionY), - getNuiImagResolution(m_videoMode.resolutionX, m_videoMode.resolutionY), + getNuiImageResolution(videoMode.resolutionX, videoMode.resolutionY), + getNuiImageResolution(m_videoMode.resolutionX, m_videoMode.resolutionY), NULL, depthX, depthY, depthZ << 3, (LONG*)pColorX, (LONG*)pColorY); if (FAILED(hr)) return ONI_STATUS_ERROR; return ONI_STATUS_OK; } +OniStatus KinectStreamImpl::convertDepthFrameToColorCoordinates(const OniVideoMode& colorVideoMode, + const NUI_DEPTH_IMAGE_PIXEL* depthPixels, int numPoints, int* colorXYs) +{ + return m_depthToImageCoordsConverter.convert(m_videoMode, colorVideoMode, depthPixels, numPoints, colorXYs); +} + void KinectStreamImpl::setDefaultVideoMode() { switch (m_sensorType) @@ -265,7 +295,7 @@ void KinectStreamImpl::setDefaultVideoMode() } } -NUI_IMAGE_RESOLUTION KinectStreamImpl::getNuiImagResolution(int resolutionX, int resolutionY) +NUI_IMAGE_RESOLUTION KinectStreamImpl::getNuiImageResolution(int resolutionX, int resolutionY) { NUI_IMAGE_RESOLUTION imgResolution = NUI_IMAGE_RESOLUTION_320x240; if (resolutionX == KINECT_RESOLUTION_X_80 && resolutionY == KINECT_RESOLUTION_Y_60 ) @@ -317,3 +347,85 @@ XN_THREAD_PROC KinectStreamImpl::threadFunc(XN_THREAD_PARAM pThreadParam) pStream->mainLoop(); XN_THREAD_PROC_RETURN(XN_STATUS_OK); } + +DWORD KinectStreamImpl::getImageFrameFlags() +{ + if (m_hStreamHandle != INVALID_HANDLE_VALUE) + { + // Read the up-to-date status. Ignore errors. + m_pNuiSensor->NuiImageStreamGetImageFrameFlags(m_hStreamHandle, &m_imageFrameFlags); + } + + return m_imageFrameFlags; +} + +OniStatus KinectStreamImpl::setImageFrameFlags(DWORD value) +{ + m_imageFrameFlags = value; + + if (m_hStreamHandle != INVALID_HANDLE_VALUE) + { + return pushImageFrameFlags(); + } + else + { + // The stream is not initialized yet. + // Suspend pushing the flag to the stream for now. + return ONI_STATUS_OK; + } +} + +OniStatus KinectStreamImpl::setImageFrameFlags(DWORD mask, OniBool value) +{ + return setImageFrameFlags(value ? (m_imageFrameFlags | mask) : (m_imageFrameFlags & ~mask)); +} + +OniStatus KinectStreamImpl::pushImageFrameFlags() +{ + XN_ASSERT(m_hStreamHandle != INVALID_HANDLE_VALUE); + + HRESULT hr; + + // Push the flag + hr = m_pNuiSensor->NuiImageStreamSetImageFrameFlags(m_hStreamHandle, m_imageFrameFlags); + + if (FAILED(hr)) + { + printf("Failed to set ImageFrameFlags to %08x\n", m_imageFrameFlags); // TODO: use log + getImageFrameFlags(); + return ONI_STATUS_ERROR; + } + + return ONI_STATUS_OK; +} + +// Depth to image coordinates converter + +KinectStreamImpl::DepthToImageCoordsConverter::DepthToImageCoordsConverter(INuiSensor* pNuiSensor) : m_pNuiSensor(pNuiSensor) +{ +} + +OniStatus KinectStreamImpl::DepthToImageCoordsConverter::convert(const OniVideoMode& depthVideoMode, + const OniVideoMode& colorVideoMode, const NUI_DEPTH_IMAGE_PIXEL* const depthPixels, const int numPoints, int* const outCoords) +{ + XN_ASSERT(sizeof(LONG) == sizeof(int)); + + m_depthValuesBuffer.SetSize(numPoints); + + // Pack depth data for NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution + USHORT* depthValuesIter = m_depthValuesBuffer.GetData(); + for (int i = 0; i < numPoints; i++) { + *(depthValuesIter++) = (depthPixels + i)->depth << 3; + } + + HRESULT hr = m_pNuiSensor->NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution( + KinectStreamImpl::getNuiImageResolution(colorVideoMode.resolutionX, colorVideoMode.resolutionY), + KinectStreamImpl::getNuiImageResolution(depthVideoMode.resolutionX, depthVideoMode.resolutionY), + numPoints, + m_depthValuesBuffer.GetData(), + numPoints * 2, + reinterpret_cast(outCoords) + ); + + return SUCCEEDED(hr) ? ONI_STATUS_OK : ONI_STATUS_ERROR; +} diff --git a/Source/Drivers/Kinect/KinectStreamImpl.h b/Source/Drivers/Kinect/KinectStreamImpl.h index de3cbdd9..ca9c40ec 100644 --- a/Source/Drivers/Kinect/KinectStreamImpl.h +++ b/Source/Drivers/Kinect/KinectStreamImpl.h @@ -1,10 +1,31 @@ -#ifndef _KINECT_STREAM_IMPL_H_ -#define _KINECT_STREAM_IMPL_H_ +/***************************************************************************** +* * +* 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 KINECTSTREAMIMPL_H +#define KINECTSTREAMIMPL_H #include "BaseKinectStream.h" #include #include "NuiApi.h" #include "XnList.h" +#include "XnArray.h" struct INuiSensor; @@ -51,22 +72,35 @@ class KinectStreamImpl OniStatus convertDepthToColorCoordinates(oni::driver::StreamBase* colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY); - static NUI_IMAGE_RESOLUTION getNuiImagResolution(int resolutionX, int resolutionY); + OniStatus convertDepthFrameToColorCoordinates(const OniVideoMode& colorVideoMode, + const NUI_DEPTH_IMAGE_PIXEL* depthPixels, int numPoints, int* colorXYs); + + DWORD getImageFrameFlags(); + + OniBool getImageFrameFlags(DWORD mask) { return (getImageFrameFlags() & mask) != 0; } + + OniStatus setImageFrameFlags(DWORD value); + + OniStatus setImageFrameFlags(DWORD mask, OniBool value); - INuiSensor* getNuiSensor() { return m_pNuiSensor; } // Need review: not sure if it is a good idea to expose this. - private: void setDefaultVideoMode(); NUI_IMAGE_TYPE getNuiImageType(); + OniStatus pushImageFrameFlags(); + static XN_THREAD_PROC threadFunc(XN_THREAD_PARAM pThreadParam); + static NUI_IMAGE_RESOLUTION getNuiImageResolution(int resolutionX, int resolutionY); + xnl::List m_streamList; OniImageRegistrationMode m_imageRegistrationMode; + DWORD m_imageFrameFlags; + // Thread INuiSensor* m_pNuiSensor; OniSensorType m_sensorType; @@ -76,7 +110,123 @@ class KinectStreamImpl OniVideoMode m_videoMode; XN_THREAD_HANDLE m_threadHandle; + + // Helper class to depth frame to image coordinate conversion + class DepthToImageCoordsConverter + { + public: + DepthToImageCoordsConverter(INuiSensor* pNuiSensor); + OniStatus convert(const OniVideoMode& depthVideoMode, const OniVideoMode& colorVideoMode, const NUI_DEPTH_IMAGE_PIXEL* depthPixels, int numPoints, int* colorXYs); + + private: + INuiSensor* m_pNuiSensor; + xnl::Array m_depthValuesBuffer; // temporary buffer for depth values shifted by 3 bits + } m_depthToImageCoordsConverter; +}; + +// +// Helper templates for frame copy +// + +// This is the most standard pixel copy implementation. +// You can create your own pixel copy implementation if any conversion is necessary. +template +struct PixelCopier +{ + void operator()(const SourceType* const in, DestType* const out) + { + *out = *in; + } }; + +template +struct LineCopier +{ + void operator()(const SourceType* in, DestType* out, const int count) + { + PixelCopier copyPixel; + SourceMover moveSource; + const SourceType* end = moveSource(in, count); + while (in != end) { + copyPixel(in, out); + in = moveSource(in, 1); + ++out; + } + } +}; + +template +struct RectCopier +{ + void operator()(const SourceType* in, DestType* out, const int copyWidth, const int totalWidth, const int copyHeight) + { + LineCopier copyLine; + VerticalSourceMover moveSource; + const SourceType* end = moveSource(in, totalWidth * copyHeight); + while (in != end) { + copyLine(in, out, copyWidth); + in = moveSource(in, totalWidth); + out += copyWidth; + } + } +}; + +template +struct ForwardMover { + T* operator()(T* const p, const int offset) { return p+offset; } + const T* operator()(const T* const p, const int offset) { return p+offset; } +}; + +template +struct BackwardMover { + T* operator()(T* const p, const int offset) { return p-offset; } + const T* operator()(const T* const p, const int offset) { return p-offset; } +}; + +template +struct FrameCopier { + void operator()(const SourceType* in, DestType* out, OniFrame* pFrame, const OniVideoMode& videoMode, const OniCropping& cropping, OniBool mirroring) + { + const int resX = videoMode.resolutionX; + const int resY = videoMode.resolutionY; + + if (!cropping.enabled) + { + const int pixelCount = resX * resY; + pFrame->dataSize = pixelCount * sizeof(DestType); + pFrame->stride = resX * sizeof(DestType); + + if (!mirroring) + { + ForwardLineCopier copyLine; + copyLine(in, out, pixelCount); + } else { + MirrorRectCopier copyRect; + copyRect(in+resX-1, out, resX, resX, resY); + } + } + else + { + const int pixelCount = cropping.height * cropping.width; + pFrame->dataSize = pixelCount * sizeof(DestType); + pFrame->stride = cropping.width * sizeof(DestType); + + if (!mirroring) + { + ForwardRectCopier copyRect; + const SourceType* origin = in + cropping.originY * resX + cropping.originX; + copyRect(origin, out, cropping.width, resX, cropping.height); + } + else + { + MirrorRectCopier copyRect; + const SourceType* origin = in + (cropping.originY+1) * resX - cropping.originX - 1; + copyRect(origin, out, cropping.width, resX, cropping.height); + } + } + } +}; + } // namespace kinect_device -#endif //_KINECT_STREAM_IMPL_H_ +#endif // KINECTSTREAMIMPL_H diff --git a/Source/Drivers/Kinect/S2D.h.h b/Source/Drivers/Kinect/S2D.h.h index efc53a04..8e72ae45 100644 --- a/Source/Drivers/Kinect/S2D.h.h +++ b/Source/Drivers/Kinect/S2D.h.h @@ -1,3 +1,26 @@ +/***************************************************************************** +* * +* 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 S2D_H_H +#define S2D_H_H + XnUInt16 S2D[] = { 0, 315, 315, 315, 316, 316, 316, 316, 317, 317, 317, 318, 318, 318, 319, 319, 319, 319, 320, 320, @@ -205,3 +228,5 @@ XnUInt16 S2D[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +#endif // S2D_H_H diff --git a/Source/Drivers/Kinect2/BaseKinect2Stream.cpp b/Source/Drivers/Kinect2/BaseKinect2Stream.cpp new file mode 100755 index 00000000..85976905 --- /dev/null +++ b/Source/Drivers/Kinect2/BaseKinect2Stream.cpp @@ -0,0 +1,157 @@ +#include "BaseKinect2Stream.h" +#include "Kinect2StreamImpl.h" +#include "XnMath.h" + +using namespace oni::driver; +using namespace kinect2_device; + +BaseKinect2Stream::BaseKinect2Stream(Kinect2StreamImpl* pStreamImpl) + : m_pStreamImpl(pStreamImpl) +{ + m_running = false; + m_frameIdx = 0; + m_cropping.enabled = FALSE; + pStreamImpl->addStream(this); +} + +BaseKinect2Stream::~BaseKinect2Stream() +{ + stop(); + m_pStreamImpl->removeStream(this); +} + +OniStatus BaseKinect2Stream::start() +{ + OniStatus status = m_pStreamImpl->start(); + if (status == ONI_STATUS_OK) + m_running = TRUE; + return status; +} + +void BaseKinect2Stream::stop() +{ + m_running = FALSE; + m_pStreamImpl->stop(); +} + +OniStatus BaseKinect2Stream::getProperty(int propertyId, void* data, int* pDataSize) +{ + OniStatus status = ONI_STATUS_NOT_SUPPORTED; + switch (propertyId) + { + case ONI_STREAM_PROPERTY_CROPPING: + if (*pDataSize != sizeof(OniCropping)) + { + printf("Unexpected size: %d != %d\n", *pDataSize, sizeof(OniCropping)); + status = ONI_STATUS_ERROR; + } + else + { + status = GetCropping((OniCropping*)data); + } + break; + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: + { + float* val = (float*)data; + XnDouble tmp = m_pStreamImpl->getHorizontalFov()*xnl::Math::DTR; + *val = (float)tmp; + status = ONI_STATUS_OK; + break; + } + case ONI_STREAM_PROPERTY_VERTICAL_FOV: + { + float* val = (float*)data; + XnDouble tmp = m_pStreamImpl->getVerticalFov()*xnl::Math::DTR; + *val = (float)tmp; + status = ONI_STATUS_OK; + break; + } + case ONI_STREAM_PROPERTY_VIDEO_MODE: + if (*pDataSize != sizeof(OniVideoMode)) + { + printf("Unexpected size: %d != %d\n", *pDataSize, sizeof(OniVideoMode)); + status = ONI_STATUS_ERROR; + } + else + { + status = GetVideoMode((OniVideoMode*)data); + } + break; + default: + status = ONI_STATUS_NOT_SUPPORTED; + break; + } + + return status; +} + +OniStatus BaseKinect2Stream::setProperty(int propertyId, const void* data, int dataSize) +{ + OniStatus status = ONI_STATUS_NOT_SUPPORTED; + if (propertyId == ONI_STREAM_PROPERTY_CROPPING) + { + if (dataSize != sizeof(OniCropping)) + { + printf("Unexpected size: %d != %d\n", dataSize, sizeof(OniCropping)); + status = ONI_STATUS_ERROR; + } + status = SetCropping((OniCropping*)data); + } + else if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) + { + if (dataSize != sizeof(OniVideoMode)) + { + printf("Unexpected size: %d != %d\n", dataSize, sizeof(OniVideoMode)); + status = ONI_STATUS_ERROR; + } + status = SetVideoMode((OniVideoMode*)data); + } + return status; +} + +OniBool BaseKinect2Stream::isPropertySupported(int propertyId) +{ + OniBool status = FALSE; + switch (propertyId) + { + case ONI_STREAM_PROPERTY_CROPPING: + case ONI_STREAM_PROPERTY_HORIZONTAL_FOV: + case ONI_STREAM_PROPERTY_VERTICAL_FOV: + case ONI_STREAM_PROPERTY_VIDEO_MODE: + status = TRUE; + break; + default: + status = FALSE; + break; + } + return status; +} + +OniStatus BaseKinect2Stream::SetVideoMode(OniVideoMode* videoMode) +{ + if (!m_pStreamImpl->isRunning()) + { + m_videoMode = *videoMode; + m_pStreamImpl->setVideoMode(videoMode); + return ONI_STATUS_OK; + } + return ONI_STATUS_OUT_OF_FLOW; +} + +OniStatus BaseKinect2Stream::GetVideoMode(OniVideoMode* pVideoMode) +{ + *pVideoMode = m_videoMode; + return ONI_STATUS_OK; +} + +OniStatus BaseKinect2Stream::SetCropping(OniCropping* cropping) +{ + m_cropping = *cropping; + return ONI_STATUS_OK; +} + +OniStatus BaseKinect2Stream::GetCropping(OniCropping* cropping) +{ + *cropping = m_cropping; + return ONI_STATUS_OK; +} diff --git a/Source/Drivers/Kinect2/BaseKinect2Stream.h b/Source/Drivers/Kinect2/BaseKinect2Stream.h new file mode 100755 index 00000000..1d7fc541 --- /dev/null +++ b/Source/Drivers/Kinect2/BaseKinect2Stream.h @@ -0,0 +1,42 @@ +#ifndef _BASE_KINECT2_STREAM_H_ +#define _BASE_KINECT2_STREAM_H_ + +#include "Driver\OniDriverAPI.h" + +namespace kinect2_device +{ + class Kinect2StreamImpl; + + class BaseKinect2Stream : public oni::driver::StreamBase + { + public: + BaseKinect2Stream(Kinect2StreamImpl* pStreamImpl); + virtual ~BaseKinect2Stream(); + + virtual OniStatus start(); + virtual void stop(); + + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize); + virtual OniStatus setProperty(int propertyId, const void* data, int dataSize); + virtual OniBool isPropertySupported(int propertyId); + + virtual OniStatus SetVideoMode(OniVideoMode* pVideoMode); + virtual OniStatus GetVideoMode(OniVideoMode* pVideoMode); + + virtual OniStatus SetCropping(OniCropping* cropping); + virtual OniStatus GetCropping(OniCropping* cropping); + + bool isRunning() { return m_running; } + + virtual void frameReady(void* data, int width, int height, double timestamp) = 0; + + protected: + Kinect2StreamImpl *m_pStreamImpl; + OniVideoMode m_videoMode; + OniCropping m_cropping; + bool m_running; + int m_frameIdx; + }; +} // namespace kinect2_device + +#endif //_BASE_KINECT2_STREAM_H_ diff --git a/Source/Drivers/Kinect2/ColorKinect2Stream.cpp b/Source/Drivers/Kinect2/ColorKinect2Stream.cpp new file mode 100755 index 00000000..7a63354d --- /dev/null +++ b/Source/Drivers/Kinect2/ColorKinect2Stream.cpp @@ -0,0 +1,66 @@ +#include "ColorKinect2Stream.h" + +#include "Kinect2StreamImpl.h" + +using namespace oni::driver; +using namespace kinect2_device; +#define DEFAULT_FPS 30 + +ColorKinect2Stream::ColorKinect2Stream(Kinect2StreamImpl* pStreamImpl) + : BaseKinect2Stream(pStreamImpl) +{ + m_videoMode.pixelFormat = ONI_PIXEL_FORMAT_RGB888; + m_videoMode.fps = DEFAULT_FPS; + m_videoMode.resolutionX = 960; + m_videoMode.resolutionY = 540; +} + +void ColorKinect2Stream::frameReady(void* data, int width, int height, double timestamp) +{ + OniFrame* pFrame = getServices().acquireFrame(); + pFrame->videoMode.resolutionX = m_videoMode.resolutionX; + pFrame->videoMode.resolutionY = m_videoMode.resolutionY; + pFrame->croppingEnabled = m_cropping.enabled; + if (m_cropping.enabled) + { + pFrame->width = m_cropping.width; + pFrame->height = m_cropping.height; + pFrame->cropOriginX = m_cropping.originX; + pFrame->cropOriginY = m_cropping.originY; + } + else + { + pFrame->cropOriginX = 0; + pFrame->cropOriginY = 0; + pFrame->width = m_videoMode.resolutionX; + pFrame->height = m_videoMode.resolutionY; + } + pFrame->dataSize = pFrame->height * pFrame->width * sizeof(OniRGB888Pixel); + pFrame->stride = pFrame->width * sizeof(OniRGB888Pixel); + pFrame->videoMode.pixelFormat = m_videoMode.pixelFormat; + pFrame->videoMode.fps = m_videoMode.fps; + pFrame->sensorType = ONI_SENSOR_COLOR; + pFrame->frameIndex = m_frameIdx++; + pFrame->timestamp = static_cast(timestamp); + + RGBQUAD* data_in = reinterpret_cast(data); + OniRGB888Pixel* data_out = reinterpret_cast(pFrame->data); + const int xStride = width/m_videoMode.resolutionX; + const int yStride = height/m_videoMode.resolutionY; + const int frameX = pFrame->cropOriginX * xStride; + const int frameY = pFrame->cropOriginY * yStride; + const int frameWidth = pFrame->width * xStride; + const int frameHeight = pFrame->height * yStride; + for (int y = frameY; y < frameY + frameHeight; y += yStride) { + for (int x = frameX; x < frameX + frameWidth; x += xStride) { + RGBQUAD* iter = data_in + (y*width + x); + data_out->b = iter->rgbBlue; + data_out->r = iter->rgbRed; + data_out->g = iter->rgbGreen; + data_out++; + } + } + + raiseNewFrame(pFrame); + getServices().releaseFrame(pFrame); +} diff --git a/Source/Drivers/Kinect2/ColorKinect2Stream.h b/Source/Drivers/Kinect2/ColorKinect2Stream.h new file mode 100755 index 00000000..f1997fa9 --- /dev/null +++ b/Source/Drivers/Kinect2/ColorKinect2Stream.h @@ -0,0 +1,18 @@ +#ifndef _COLOR_KINECT2_STREAM_H_ +#define _COLOR_KINECT2_STREAM_H_ + +#include "BaseKinect2Stream.h" + +struct IColorFrameReader; + +namespace kinect2_device +{ + class ColorKinect2Stream : public BaseKinect2Stream + { + public: + ColorKinect2Stream(Kinect2StreamImpl* pStreamImpl); + virtual void frameReady(void* data, int width, int height, double timestamp); + }; +} // namespace kinect2_device + +#endif //_COLOR_KINECT2_STREAM_H_ diff --git a/Source/Drivers/Kinect2/DepthKinect2Stream.cpp b/Source/Drivers/Kinect2/DepthKinect2Stream.cpp new file mode 100755 index 00000000..68c40b68 --- /dev/null +++ b/Source/Drivers/Kinect2/DepthKinect2Stream.cpp @@ -0,0 +1,211 @@ +#include "DepthKinect2Stream.h" + +#include "Kinect2StreamImpl.h" + +using namespace oni::driver; +using namespace kinect2_device; +#define DEFAULT_FPS 30 + +#define DEVICE_MAX_DEPTH_VAL 10000 +#define FILTER_RELIABLE_DEPTH_VALUE(VALUE) (((VALUE) < DEVICE_MAX_DEPTH_VAL) ? (VALUE) : 0) + +DepthKinect2Stream::DepthKinect2Stream(Kinect2StreamImpl* pStreamImpl) + : BaseKinect2Stream(pStreamImpl) +{ + m_videoMode.pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; + m_videoMode.fps = DEFAULT_FPS; + m_videoMode.resolutionX = 512; + m_videoMode.resolutionY = 424; + m_colorSpaceCoords = new ColorSpacePoint[512*424]; + m_registeredDepthMap = new UINT16[512*424]; +} + +DepthKinect2Stream::~DepthKinect2Stream() +{ + delete[] m_colorSpaceCoords; + delete[] m_registeredDepthMap; +} + +void DepthKinect2Stream::frameReady(void* data, int width, int height, double timestamp) +{ + OniFrame* pFrame = getServices().acquireFrame(); + pFrame->videoMode.resolutionY = m_videoMode.resolutionY; + pFrame->videoMode.resolutionX = m_videoMode.resolutionX; + pFrame->croppingEnabled = m_cropping.enabled; + if (m_cropping.enabled) + { + pFrame->width = m_cropping.width; + pFrame->height = m_cropping.height; + pFrame->cropOriginX = m_cropping.originX; + pFrame->cropOriginY = m_cropping.originY; + } + else { + pFrame->cropOriginX = 0; + pFrame->cropOriginY = 0; + pFrame->width = m_videoMode.resolutionX; + pFrame->height = m_videoMode.resolutionY; + } + pFrame->dataSize = pFrame->height * pFrame->width * 2; + pFrame->stride = pFrame->width * 2; + pFrame->videoMode.pixelFormat = m_videoMode.pixelFormat; + pFrame->videoMode.fps = m_videoMode.fps; + pFrame->sensorType = ONI_SENSOR_DEPTH; + pFrame->frameIndex = m_frameIdx++; + pFrame->timestamp = static_cast(timestamp); + + UINT16* data_in = reinterpret_cast(data); + if (m_pStreamImpl->getImageRegistrationMode() == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { + copyDepthPixelsWithImageRegistration(data_in, width, height, pFrame); + } else { + copyDepthPixelsStraight(data_in, width, height, pFrame); + } + + raiseNewFrame(pFrame); + getServices().releaseFrame(pFrame); +} + +OniStatus DepthKinect2Stream::getProperty(int propertyId, void* data, int* pDataSize) +{ + OniStatus status = ONI_STATUS_NOT_SUPPORTED; + switch (propertyId) + { + case ONI_STREAM_PROPERTY_MAX_VALUE: + { + XnInt * val = (XnInt *)data; + *val = DEVICE_MAX_DEPTH_VAL; + status = ONI_STATUS_OK; + break; + } + case ONI_STREAM_PROPERTY_MIRRORING: + { + XnBool * val = (XnBool *)data; + *val = TRUE; + status = ONI_STATUS_OK; + break; + } + default: + status = BaseKinect2Stream::getProperty(propertyId, data, pDataSize); + break; + } + + return status; +} + +OniBool DepthKinect2Stream::isPropertySupported(int propertyId) +{ + OniBool status = FALSE; + switch (propertyId) + { + case ONI_STREAM_PROPERTY_MAX_VALUE: + case ONI_STREAM_PROPERTY_MIRRORING: + status = TRUE; + default: + status = BaseKinect2Stream::isPropertySupported(propertyId); + break; + } + return status; +} + +void DepthKinect2Stream::notifyAllProperties() +{ + XnInt nInt; + int size = sizeof(nInt); + getProperty(ONI_STREAM_PROPERTY_MAX_VALUE, &nInt, &size); + raisePropertyChanged(ONI_STREAM_PROPERTY_MAX_VALUE, &nInt, size); + + BaseKinect2Stream::notifyAllProperties(); +} + +void DepthKinect2Stream::copyDepthPixelsStraight(const UINT16* data_in, int width, int height, OniFrame* pFrame) +{ + // Copy the depth pixels to OniDriverFrame + // with applying cropping but NO depth-to-image registration. + + const int xStride = width/m_videoMode.resolutionX; + const int yStride = height/m_videoMode.resolutionY; + const int frameX = pFrame->cropOriginX * xStride; + const int frameY = pFrame->cropOriginY * yStride; + const int frameWidth = pFrame->width * xStride; + const int frameHeight = pFrame->height * yStride; + + unsigned short* data_out = (unsigned short*) pFrame->data; + for (int y = frameY; y < frameY + frameHeight; y += yStride) { + for (int x = frameX; x < frameX + frameWidth; x += xStride) { + unsigned short* iter = const_cast(data_in + (y*width + x)); + *data_out = FILTER_RELIABLE_DEPTH_VALUE(*iter); + data_out++; + } + } +} + +void DepthKinect2Stream::copyDepthPixelsWithImageRegistration(const UINT16* data_in, int width, int height, OniFrame* pFrame) +{ + // Copy the depth pixels to OniDriverFrame + // with applying cropping and depth-to-image registration. + + const int xStride = width/m_videoMode.resolutionX; + const int yStride = height/m_videoMode.resolutionY; + const int frameX = pFrame->cropOriginX * xStride; + const int frameY = pFrame->cropOriginY * yStride; + const int frameWidth = pFrame->width * xStride; + const int frameHeight = pFrame->height * yStride; + const float xFactor = static_cast(width)/1920.0f; + const float yFactor = static_cast(height)/1080.0f; + + ICoordinateMapper* coordinateMapper = m_pStreamImpl->getCoordinateMapper(); + if (coordinateMapper == NULL) { + return; + } + + HRESULT hr = coordinateMapper->MapDepthFrameToColorSpace(width*height, data_in, width*height, m_colorSpaceCoords); + if (FAILED(hr)) { + return; + } + + unsigned short* data_out = (unsigned short*) m_registeredDepthMap; + xnOSMemSet(data_out, 0, width*height*2); + + const ColorSpacePoint* mappedCoordsIter = m_colorSpaceCoords; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + const float fX = mappedCoordsIter->X*xFactor; + const float fY = mappedCoordsIter->Y*yFactor; + const int cx = static_cast(fX + 0.5f); + const int cy = static_cast(fY + 0.5f); + if (cx >= 0 && cy >= 0 && cx < width && cy < height) { + unsigned short* iter = const_cast(data_in + (y*width + x)); + const unsigned short d = FILTER_RELIABLE_DEPTH_VALUE(*iter); + unsigned short* const p = data_out + cx + cy * width; + if (*p == 0 || *p > d) *p = d; + } + mappedCoordsIter++; + } + } + + // Fill vertical gaps caused by the difference in the aspect ratio between depth and color resolutions + data_out = (unsigned short*) pFrame->data; + for (int y = frameY; y < frameY + frameHeight; y += yStride) { + for (int x = frameX; x < frameX + frameWidth; x += xStride) { + unsigned short* iter = const_cast(m_registeredDepthMap + (y*width + x)); + if (*iter == 0) { + unsigned short davg = 0; + int dw = 0; + for (int ky = max(y - 1, 0); ky <= y + 1 && ky < height; ky++) { + unsigned short* kiter = const_cast(m_registeredDepthMap + (ky*width + x)); + if (*kiter != 0) { + davg += *kiter; + dw += abs(ky - y); + } + } + *data_out = davg; + if (dw) { + *data_out /= dw; + } + } + else { + *data_out = FILTER_RELIABLE_DEPTH_VALUE(*iter); + } + data_out++; + } + } +} diff --git a/Source/Drivers/Kinect2/DepthKinect2Stream.h b/Source/Drivers/Kinect2/DepthKinect2Stream.h new file mode 100755 index 00000000..ff7814fa --- /dev/null +++ b/Source/Drivers/Kinect2/DepthKinect2Stream.h @@ -0,0 +1,31 @@ +#ifndef _DEPTH_KINECT2_STREAM_H_ +#define _DEPTH_KINECT2_STREAM_H_ + +#include "BaseKinect2Stream.h" +#include + +namespace kinect2_device +{ + class DepthKinect2Stream : public BaseKinect2Stream + { + public: + DepthKinect2Stream(Kinect2StreamImpl* pStreamImpl); + virtual ~DepthKinect2Stream(); + + virtual void frameReady(void* data, int width, int height, double timestamp); + + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize); + virtual OniBool isPropertySupported(int propertyId); + virtual void notifyAllProperties(); + + private: + void copyDepthPixelsStraight(const UINT16* data_in, int width, int height, OniFrame* pFrame); + void copyDepthPixelsWithImageRegistration(const UINT16* data_in, int width, int height, OniFrame* pFrame); + + private: + ColorSpacePoint* m_colorSpaceCoords; + UINT16* m_registeredDepthMap; + }; +} // namespace kinect2_device + +#endif //_DEPTH_KINECT2_STREAM_H_ diff --git a/Source/Drivers/Kinect2/IRKinect2Stream.cpp b/Source/Drivers/Kinect2/IRKinect2Stream.cpp new file mode 100755 index 00000000..3d06940e --- /dev/null +++ b/Source/Drivers/Kinect2/IRKinect2Stream.cpp @@ -0,0 +1,64 @@ +#include "IRKinect2Stream.h" + +#include "Kinect2StreamImpl.h" + +using namespace oni::driver; +using namespace kinect2_device; +#define DEFAULT_FPS 30 + +IRKinect2Stream::IRKinect2Stream(Kinect2StreamImpl* pStreamImpl) + : BaseKinect2Stream(pStreamImpl) +{ + m_videoMode.pixelFormat = ONI_PIXEL_FORMAT_GRAY16; + m_videoMode.fps = DEFAULT_FPS; + m_videoMode.resolutionX = 512; + m_videoMode.resolutionY = 424; +} + +void IRKinect2Stream::frameReady(void* data, int width, int height, double timestamp) +{ + OniFrame* pFrame = getServices().acquireFrame(); + pFrame->videoMode.resolutionX = m_videoMode.resolutionX; + pFrame->videoMode.resolutionY = m_videoMode.resolutionY; + pFrame->croppingEnabled = m_cropping.enabled; + if (m_cropping.enabled) + { + pFrame->width = m_cropping.width; + pFrame->height = m_cropping.height; + pFrame->cropOriginX = m_cropping.originX; + pFrame->cropOriginY = m_cropping.originY; + } + else + { + pFrame->cropOriginX = 0; + pFrame->cropOriginY = 0; + pFrame->width = m_videoMode.resolutionX; + pFrame->height = m_videoMode.resolutionY; + } + pFrame->dataSize = pFrame->height * pFrame->width * 2; + pFrame->stride = pFrame->width * 2; + pFrame->videoMode.pixelFormat = m_videoMode.pixelFormat; + pFrame->videoMode.fps = m_videoMode.fps; + pFrame->sensorType = ONI_SENSOR_IR; + pFrame->frameIndex = m_frameIdx++; + pFrame->timestamp = static_cast(timestamp); + + unsigned short* data_in = reinterpret_cast(data); + unsigned short* data_out = reinterpret_cast(pFrame->data); + const int xStride = width/m_videoMode.resolutionX; + const int yStride = height/m_videoMode.resolutionY; + const int frameX = pFrame->cropOriginX * xStride; + const int frameY = pFrame->cropOriginY * yStride; + const int frameWidth = pFrame->width * xStride; + const int frameHeight = pFrame->height * yStride; + for (int y = frameY; y < frameY + frameHeight; y += yStride) { + for (int x = frameX; x < frameX + frameWidth; x += xStride) { + unsigned short* iter = data_in + (y*width + x); + *data_out = *iter; + data_out++; + } + } + + raiseNewFrame(pFrame); + getServices().releaseFrame(pFrame); +} diff --git a/Source/Drivers/Kinect2/IRKinect2Stream.h b/Source/Drivers/Kinect2/IRKinect2Stream.h new file mode 100755 index 00000000..a8c2a2dc --- /dev/null +++ b/Source/Drivers/Kinect2/IRKinect2Stream.h @@ -0,0 +1,18 @@ +#ifndef _IR_KINECT2_STREAM_H_ +#define _IR_KINECT2_STREAM_H_ + +#include "BaseKinect2Stream.h" + +struct IInfraredFrameReader; + +namespace kinect2_device +{ + class IRKinect2Stream : public BaseKinect2Stream + { + public: + IRKinect2Stream(Kinect2StreamImpl* pStreamImpl); + virtual void frameReady(void* data, int width, int height, double timestamp); + }; +} // namespace kinect2_device + +#endif //_IR_KINECT2_STREAM_H_ diff --git a/Source/Drivers/Kinect2/Kinect2.vcxproj b/Source/Drivers/Kinect2/Kinect2.vcxproj new file mode 100755 index 00000000..93a2bfce --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2.vcxproj @@ -0,0 +1,198 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {950CCD82-B435-4C10-8852-DDD8AAD14119} + Kinect2 + + + + DynamicLibrary + true + Unicode + true + v120 + + + DynamicLibrary + true + Unicode + true + v120 + + + DynamicLibrary + false + true + MultiByte + true + v120 + + + DynamicLibrary + false + true + MultiByte + true + v120 + + + + + + + + + + + + + + + + + + + $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ + $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;;$(IncludePath) + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(LibraryPath) + true + + + $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ + $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ + true + + + $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ + $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;;$(IncludePath) + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(LibraryPath) + false + + + $(SolutionDir)Bin\$(Platform)-$(Configuration)\OpenNI2\Drivers\ + $(SolutionDir)Bin\Intermediate\$(Platform)-$(Configuration)\$(ProjectName)\ + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;;$(IncludePath) + false + + + + Level3 + Disabled + ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;$(KINECTSDK20_DIR)\inc + _WINDLL;%(PreprocessorDefinitions);_WINDOWS + false + true + + + true + Kinect20.lib;XnLib.lib;%(AdditionalDependencies) + $(SolutionDir)Bin\$(Platform)-$(Configuration)\;$(KINECTSDK20_DIR)\lib\x86 + true + + + + + Level3 + Disabled + ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;$(KINECTSDK20_DIR)\inc + _WINDLL;%(PreprocessorDefinitions);_WINDOWS + false + true + + + true + Kinect20.lib;XnLib.lib;%(AdditionalDependencies) + $(SolutionDir)Bin\$(Platform)-$(Configuration)\;$(KINECTSDK20_DIR)\lib\x64 + + + + + true + + + + + Level3 + MaxSpeed + true + true + ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;$(KINECTSDK20_DIR)\inc + true + + + true + true + true + Kinect20.lib;XnLib.lib;%(AdditionalDependencies) + $(SolutionDir)Bin\$(Platform)-$(Configuration)\;$(KINECTSDK20_DIR)\lib\x86 + true + + + + + Level3 + MaxSpeed + true + true + ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;$(KINECTSDK20_DIR)\inc + true + + + true + true + true + Kinect20.lib;XnLib.lib;%(AdditionalDependencies) + $(SolutionDir)Bin\$(Platform)-$(Configuration)\;$(KINECTSDK20_DIR)\lib\x64 + true + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\Include + ..\..\..\Include + ..\..\..\Include + ..\..\..\Include + + + + + + diff --git a/Source/Drivers/Kinect2/Kinect2.vcxproj.filters b/Source/Drivers/Kinect2/Kinect2.vcxproj.filters new file mode 100755 index 00000000..fe057fd9 --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2.vcxproj.filters @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + {aede41a2-2b14-4dfc-abfa-2561ae67c9f5} + + + + + Resource Files + + + \ No newline at end of file diff --git a/Source/Drivers/Kinect2/Kinect2Device.cpp b/Source/Drivers/Kinect2/Kinect2Device.cpp new file mode 100755 index 00000000..e04a3f09 --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2Device.cpp @@ -0,0 +1,179 @@ +#include "Kinect2Device.h" +#include "DepthKinect2Stream.h" +#include "ColorKinect2Stream.h" +#include "IRKinect2Stream.h" +#include + +using namespace kinect2_device; +using namespace oni::driver; +#define DEFAULT_FPS 30 + +Kinect2Device::Kinect2Device(IKinectSensor* pKinectSensor) + : m_pDepthStream(NULL), + m_pColorStream(NULL), + m_pIRStream(NULL), + m_pKinectSensor(pKinectSensor) +{ + m_numSensors = 3; + + m_sensors[0].sensorType = ONI_SENSOR_DEPTH; + m_sensors[0].numSupportedVideoModes = 1; + m_sensors[0].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, 1); + m_sensors[0].pSupportedVideoModes[0].pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; + m_sensors[0].pSupportedVideoModes[0].fps = DEFAULT_FPS; + m_sensors[0].pSupportedVideoModes[0].resolutionX = 512; + m_sensors[0].pSupportedVideoModes[0].resolutionY = 424; + + m_sensors[1].sensorType = ONI_SENSOR_COLOR; + m_sensors[1].numSupportedVideoModes = 2; + m_sensors[1].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, 2); + m_sensors[1].pSupportedVideoModes[0].pixelFormat = ONI_PIXEL_FORMAT_RGB888; + m_sensors[1].pSupportedVideoModes[0].fps = DEFAULT_FPS; + m_sensors[1].pSupportedVideoModes[0].resolutionX = 960; + m_sensors[1].pSupportedVideoModes[0].resolutionY = 540; + + m_sensors[1].pSupportedVideoModes[1].pixelFormat = ONI_PIXEL_FORMAT_RGB888; + m_sensors[1].pSupportedVideoModes[1].fps = DEFAULT_FPS; + m_sensors[1].pSupportedVideoModes[1].resolutionX = 1920; + m_sensors[1].pSupportedVideoModes[1].resolutionY = 1080; + + m_sensors[2].sensorType = ONI_SENSOR_IR; + m_sensors[2].numSupportedVideoModes = 1; + m_sensors[2].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, 1); + m_sensors[2].pSupportedVideoModes[0].pixelFormat = ONI_PIXEL_FORMAT_GRAY16; + m_sensors[2].pSupportedVideoModes[0].fps = DEFAULT_FPS; + m_sensors[2].pSupportedVideoModes[0].resolutionX = 512; + m_sensors[2].pSupportedVideoModes[0].resolutionY = 424; + + LARGE_INTEGER qpc = {0}; + if (QueryPerformanceCounter(&qpc)) + { + m_perfCounter = qpc.QuadPart; + } +} + +Kinect2Device::~Kinect2Device() +{ + if (m_pDepthStream != NULL) { + XN_DELETE(m_pDepthStream); + } + + if (m_pColorStream!= NULL) { + XN_DELETE(m_pColorStream); + } + + if (m_pIRStream!= NULL) { + XN_DELETE(m_pIRStream); + } + + if (m_pKinectSensor) { + m_pKinectSensor->Close(); + m_pKinectSensor->Release(); + } +} + +OniStatus Kinect2Device::getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) +{ + *numSensors = m_numSensors; + *pSensors = m_sensors; + return ONI_STATUS_OK; +} + +StreamBase* Kinect2Device::createStream(OniSensorType sensorType) +{ + BaseKinect2Stream* pImage = NULL; + + if (sensorType == ONI_SENSOR_COLOR) + { + if (m_pColorStream == NULL) + { + m_pColorStream = XN_NEW(Kinect2StreamImpl, m_pKinectSensor, sensorType, m_perfCounter); + } + pImage = XN_NEW(ColorKinect2Stream, m_pColorStream); + } + else if (sensorType == ONI_SENSOR_DEPTH) + { + if (m_pDepthStream == NULL) + { + m_pDepthStream = XN_NEW(Kinect2StreamImpl, m_pKinectSensor, sensorType, m_perfCounter); + } + pImage = XN_NEW(DepthKinect2Stream, m_pDepthStream); + } + else if (sensorType == ONI_SENSOR_IR) + { + if (m_pIRStream == NULL) + { + m_pIRStream = XN_NEW(Kinect2StreamImpl, m_pKinectSensor, sensorType, m_perfCounter); + } + pImage = XN_NEW(IRKinect2Stream, m_pIRStream); + } + return pImage; +} + +void kinect2_device::Kinect2Device::destroyStream(oni::driver::StreamBase* pStream) +{ + XN_DELETE(pStream); +} + +OniStatus Kinect2Device::setProperty(int propertyId, const void* data, int dataSize) +{ + switch (propertyId) { + case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: + if (dataSize == sizeof(OniImageRegistrationMode)) { + if (m_pDepthStream) { + OniImageRegistrationMode* pMode = (OniImageRegistrationMode*)data; + m_pDepthStream->setImageRegistrationMode(*pMode); + return ONI_STATUS_OK; + } + else { + return ONI_STATUS_ERROR; + } + } + else { + printf("Unexpected size: %d != %d\n", dataSize, sizeof(OniImageRegistrationMode)); + return ONI_STATUS_ERROR; + } + } + return ONI_STATUS_NOT_IMPLEMENTED; +} + +OniStatus Kinect2Device::getProperty(int propertyId, void* data, int* pDataSize) +{ + switch (propertyId) { + case ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION: + if (*pDataSize == sizeof(OniImageRegistrationMode)) { + if (m_pDepthStream) { + OniImageRegistrationMode* pMode = (OniImageRegistrationMode*)data; + *pMode = m_pDepthStream->getImageRegistrationMode(); + return ONI_STATUS_OK; + } else { + return ONI_STATUS_ERROR; + } + } + else { + printf("Unexpected size: %d != %d\n", *pDataSize, sizeof(OniImageRegistrationMode)); + return ONI_STATUS_ERROR; + } + } + return ONI_STATUS_NOT_IMPLEMENTED; +} + +OniBool Kinect2Device::isPropertySupported(int propertyId) +{ + return (propertyId == ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION); +} + +OniBool Kinect2Device::isCommandSupported(int commandId) +{ + return ONI_STATUS_NOT_IMPLEMENTED; +} + +OniStatus Kinect2Device::tryManualTrigger() +{ + return ONI_STATUS_NOT_IMPLEMENTED; +} + +OniBool Kinect2Device::isImageRegistrationModeSupported(OniImageRegistrationMode mode) +{ + return (mode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR || mode == ONI_IMAGE_REGISTRATION_OFF); +} diff --git a/Source/Drivers/Kinect2/Kinect2Device.h b/Source/Drivers/Kinect2/Kinect2Device.h new file mode 100755 index 00000000..76366d48 --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2Device.h @@ -0,0 +1,43 @@ +#ifndef _KINECT2_DEVICE_H_ +#define _KINECT2_DEVICE_H_ + +#include "Driver\OniDriverAPI.h" +#include "Kinect2StreamImpl.h" + +struct IKinectSensor; + +namespace kinect2_device +{ + class Kinect2Device : public oni::driver::DeviceBase + { + public: + Kinect2Device(IKinectSensor* pKinectSensor); + virtual ~Kinect2Device(); + + virtual OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSources); + + virtual oni::driver::StreamBase* createStream(OniSensorType streamSource); + virtual void destroyStream(oni::driver::StreamBase* pStream); + + virtual OniStatus setProperty(int propertyId, const void* data, int dataSize); + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize); + virtual OniBool isPropertySupported(int propertyId); + + virtual OniBool isCommandSupported(int commandId); + + virtual OniStatus tryManualTrigger(); + + virtual OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode); + + private: + IKinectSensor* m_pKinectSensor; + Kinect2StreamImpl* m_pDepthStream; + Kinect2StreamImpl* m_pColorStream; + Kinect2StreamImpl* m_pIRStream; + int m_numSensors; + LONGLONG m_perfCounter; + OniSensorInfo m_sensors[10]; + }; +} // namespace kinect2_device + +#endif //_KINECT2_DRIVER_H_ diff --git a/Source/Drivers/Kinect2/Kinect2Driver.cpp b/Source/Drivers/Kinect2/Kinect2Driver.cpp new file mode 100755 index 00000000..d440e9b1 --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2Driver.cpp @@ -0,0 +1,160 @@ +#include "Kinect2Driver.h" +#include "Kinect2Device.h" +#include + +using namespace oni::driver; +using namespace kinect2_device; + +static const char VENDOR_VAL[] = "Microsoft"; +static const char NAME_VAL[] = "Kinect v2"; + +Kinect2Driver::Kinect2Driver(OniDriverServices* pDriverServices) + : DriverBase(pDriverServices) +{} + +Kinect2Driver::~Kinect2Driver() +{} + +OniStatus Kinect2Driver::initialize(DeviceConnectedCallback connectedCallback, + DeviceDisconnectedCallback disconnectedCallback, + DeviceStateChangedCallback deviceStateChangedCallback, + void* pCookie) +{ + HRESULT hr; + DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); + + // Get sensor instance + IKinectSensor* pKinectSensor = NULL; + hr = ::GetDefaultKinectSensor(&pKinectSensor); + if (FAILED(hr)) { + if (pKinectSensor) { + pKinectSensor->Release(); + } + return ONI_STATUS_NO_DEVICE; + } + + hr = pKinectSensor->Open(); + if (FAILED(hr)) { + pKinectSensor->Release(); + return ONI_STATUS_ERROR; + } + + // Wait some time to let the sensor initialize + Sleep(500); + + BOOLEAN available; + hr = pKinectSensor->get_IsAvailable(&available); + if (FAILED(hr) || !available) { + pKinectSensor->Close(); + pKinectSensor->Release(); + return ONI_STATUS_NO_DEVICE; + } + + // Get sensor info + OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); + WCHAR sensorId[ONI_MAX_STR]; + pKinectSensor->get_UniqueKinectId(ONI_MAX_STR, sensorId); + size_t convertedChars = 0; + const size_t newsize = ONI_MAX_STR; + size_t origsize = wcslen(sensorId) + 1; + wcstombs_s(&convertedChars, pInfo->uri, origsize, sensorId, _TRUNCATE); + xnOSStrCopy(pInfo->vendor, VENDOR_VAL, ONI_MAX_STR); + xnOSStrCopy(pInfo->name, NAME_VAL, ONI_MAX_STR); + m_devices[pInfo] = NULL; + deviceConnected(pInfo); + deviceStateChanged(pInfo, S_OK); // Sensor is ready + + // Close sensor instance + pKinectSensor->Close(); + pKinectSensor->Release(); + + return ONI_STATUS_OK; +} + +DeviceBase* Kinect2Driver::deviceOpen(const char* uri, const char* /*mode*/) +{ + for (xnl::Hash::Iterator iter = m_devices.Begin(); iter != m_devices.End(); ++iter) + { + if (xnOSStrCmp(iter->Key()->uri, uri) == 0) + { + // Found + if (iter->Value() != NULL) + { + // already using + return iter->Value(); + } + else + { + // Get sensor instance + IKinectSensor* pKinectSensor = NULL; + HRESULT hr; + hr = ::GetDefaultKinectSensor(&pKinectSensor); + if (FAILED(hr)) { + if (pKinectSensor) { + pKinectSensor->Release(); + } + return NULL; + } + + // Compare sensor id. TODO: To be removed when multi-device support is added + char sensorUri[ONI_MAX_STR]; + WCHAR sensorId[ONI_MAX_STR]; + pKinectSensor->get_UniqueKinectId(ONI_MAX_STR, sensorId); + size_t convertedChars = 0; + const size_t newsize = ONI_MAX_STR; + size_t origsize = wcslen(sensorId) + 1; + wcstombs_s(&convertedChars, sensorUri, origsize, sensorId, _TRUNCATE); + if (xnOSStrCmp(iter->Key()->uri, sensorUri) != 0) { + pKinectSensor->Release(); + return NULL; + } + + // Initialize the Kinect2 + hr = pKinectSensor->Open(); + Kinect2Device* pDevice = XN_NEW(Kinect2Device, pKinectSensor); + if (!pDevice) { + pKinectSensor->Close(); + pKinectSensor->Release(); + return NULL; + } + iter->Value() = pDevice; + return pDevice; + } + } + } + return NULL; +} + +void kinect2_device::Kinect2Driver::deviceClose(oni::driver::DeviceBase* pDevice) +{ + for (xnl::Hash::Iterator iter = m_devices.Begin(); iter != m_devices.End(); ++iter) + { + if (iter->Value() == pDevice) + { + iter->Value() = NULL; + XN_DELETE(pDevice); + return; + } + } + + // not our device?! + XN_ASSERT(FALSE); +} + +void Kinect2Driver::shutdown() +{} + +OniStatus Kinect2Driver::tryDevice(const char* uri) +{ + return ONI_STATUS_OK; +} + +void* Kinect2Driver::enableFrameSync(StreamBase** pStreams, int streamCount) +{ + return NULL; +} + +void Kinect2Driver::disableFrameSync(void* frameSyncGroup) +{} + +ONI_EXPORT_DRIVER(kinect2_device::Kinect2Driver) diff --git a/Source/Drivers/Kinect2/Kinect2Driver.h b/Source/Drivers/Kinect2/Kinect2Driver.h new file mode 100755 index 00000000..acc22b1e --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2Driver.h @@ -0,0 +1,35 @@ +#ifndef _KINECT2_DRIVER_H_ +#define _KINECT2_DRIVER_H_ + +#include "Driver\OniDriverAPI.h" +#include "XnHash.h" + +namespace kinect2_device +{ + class Kinect2Driver : public oni::driver::DriverBase + { + public: + Kinect2Driver(OniDriverServices* pDriverServices); + + virtual OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, + oni::driver::DeviceDisconnectedCallback disconnectedCallback, + oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, + void* pCookie); + virtual ~Kinect2Driver(); + + virtual oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode); + virtual void deviceClose(oni::driver::DeviceBase* pDevice); + + virtual void shutdown(); + + virtual OniStatus tryDevice(const char* uri); + + virtual void* enableFrameSync(oni::driver::StreamBase** pStreams, int streamCount); + virtual void disableFrameSync(void* frameSyncGroup); + + private: + xnl::Hash m_devices; + }; +} // namespace kinect2_device + +#endif //_KINECT2_DRIVER_H_ diff --git a/Source/Drivers/Kinect2/Kinect2StreamImpl.cpp b/Source/Drivers/Kinect2/Kinect2StreamImpl.cpp new file mode 100755 index 00000000..d2e33e48 --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2StreamImpl.cpp @@ -0,0 +1,455 @@ +#include "Kinect2StreamImpl.h" +#include "BaseKinect2Stream.h" + +#include + +using namespace oni::driver; +using namespace kinect2_device; +using namespace xnl; + +#define DEFAULT_FPS 30 + +Kinect2StreamImpl::Kinect2StreamImpl(IKinectSensor *pKinectSensor, OniSensorType sensorType, LONGLONG basePerfCounter) + : m_pKinectSensor(pKinectSensor), + m_pCoordinateMapper(NULL), + m_sensorType(sensorType), + m_imageRegistrationMode(ONI_IMAGE_REGISTRATION_OFF), + m_running(FALSE), + m_perfCounter(basePerfCounter), + m_perfFreq(1.0) +{ + HRESULT hr = pKinectSensor->get_CoordinateMapper(&m_pCoordinateMapper); + if (FAILED(hr)) { + m_pCoordinateMapper = NULL; + } + + m_pFrameBuffer.color = NULL; + m_pFrameBuffer.depth = NULL; + m_pFrameBuffer.infrared = NULL; + createFrameBuffer(); + + m_pFrameReader.color = NULL; + m_pFrameReader.depth = NULL; + m_pFrameReader.infrared = NULL; + openFrameReader(); + + LARGE_INTEGER qpf = {0}; + if (QueryPerformanceFrequency(&qpf)) + { + m_perfFreq = double(qpf.QuadPart)/1000000.0; + } + + setDefaultVideoMode(); +} + +Kinect2StreamImpl::~Kinect2StreamImpl() +{ + if (m_running) { + m_running = FALSE; + xnOSWaitForThreadExit(m_threadHandle, INFINITE); + xnOSCloseThread(&m_threadHandle); + } + + closeFrameReader(); + destroyFrameBuffer(); + + if (m_pCoordinateMapper) { + m_pCoordinateMapper->Release(); + } +} + +void Kinect2StreamImpl::addStream(BaseKinect2Stream* stream) +{ + m_streamList.AddLast(stream); +} + +void Kinect2StreamImpl::removeStream(BaseKinect2Stream* stream) +{ + m_streamList.Remove(stream); +} + +unsigned int Kinect2StreamImpl::getStreamCount() +{ + return m_streamList.Size(); +} + +void Kinect2StreamImpl::setVideoMode(OniVideoMode* videoMode) +{ + m_videoMode.fps = videoMode->fps; + m_videoMode.pixelFormat = videoMode->pixelFormat; + m_videoMode.resolutionX = videoMode->resolutionX; + m_videoMode.resolutionY = videoMode->resolutionY; +} + +OniStatus Kinect2StreamImpl::start() +{ + if (m_running != TRUE) { + XnStatus nRetVal = xnOSCreateThread(threadFunc, this, &m_threadHandle); + if (nRetVal != XN_STATUS_OK) { + return ONI_STATUS_ERROR; + } + return ONI_STATUS_OK; + } + else { + return ONI_STATUS_OK; + } +} + +void Kinect2StreamImpl::stop() +{ + if (m_running == true) { + List::Iterator iter = m_streamList.Begin(); + while( iter != m_streamList.End()) { + if (((BaseKinect2Stream*)(*iter))->isRunning()) { + return; + } + ++iter; + } + m_running = false; + xnOSWaitForThreadExit(m_threadHandle, INFINITE); + xnOSCloseThread(&m_threadHandle); + } +} + +void Kinect2StreamImpl::setSensorType(OniSensorType sensorType) +{ + if (m_sensorType != sensorType) { + closeFrameReader(); + destroyFrameBuffer(); + + m_sensorType = sensorType; + + createFrameBuffer(); + openFrameReader(); + + setDefaultVideoMode(); + } +} + +void Kinect2StreamImpl::mainLoop() +{ + m_running = TRUE; + while (m_running) { + int width, height; + void* data = populateFrameBuffer(width, height); + + LARGE_INTEGER qpc = {0}; + QueryPerformanceCounter(&qpc); + double timestamp = static_cast(qpc.QuadPart - m_perfCounter)/m_perfFreq; + + List::ConstIterator iter = m_streamList.Begin(); + while( iter != m_streamList.End()) { + if (((BaseKinect2Stream*)(*iter))->isRunning()) { + ((BaseKinect2Stream*)(*iter))->frameReady(data, width, height, timestamp); + } + ++iter; + } + } + return; +} + +XnDouble Kinect2StreamImpl::getHorizontalFov() +{ + IFrameDescription* frameDescription = NULL; + if (m_sensorType == ONI_SENSOR_DEPTH && m_imageRegistrationMode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { + frameDescription = getFrameDescription(ONI_SENSOR_COLOR); + } + else { + frameDescription = getFrameDescription(m_sensorType); + } + + if (frameDescription == NULL) { + return 0; + } + + float fov; + HRESULT hr = frameDescription->get_HorizontalFieldOfView(&fov); + frameDescription->Release(); + if (FAILED(hr)) { + return 0; + } + return fov; +} + +XnDouble Kinect2StreamImpl::getVerticalFov() +{ + IFrameDescription* frameDescription = NULL; + if (m_sensorType == ONI_SENSOR_DEPTH && m_imageRegistrationMode == ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR) { + frameDescription = getFrameDescription(ONI_SENSOR_COLOR); + } + else { + frameDescription = getFrameDescription(m_sensorType); + } + + if (frameDescription == NULL) { + return 0; + } + + float fov; + HRESULT hr = frameDescription->get_VerticalFieldOfView(&fov); + frameDescription->Release(); + if (FAILED(hr)) { + return 0; + } + return fov; +} + +void Kinect2StreamImpl::setDefaultVideoMode() +{ + switch (m_sensorType) + { + case ONI_SENSOR_COLOR: + m_videoMode.pixelFormat = ONI_PIXEL_FORMAT_RGB888; + m_videoMode.fps = DEFAULT_FPS; + m_videoMode.resolutionX = 960; + m_videoMode.resolutionY = 540; + break; + case ONI_SENSOR_DEPTH: + m_videoMode.pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; + m_videoMode.fps = DEFAULT_FPS; + m_videoMode.resolutionX = 512; + m_videoMode.resolutionY = 424; + break; + case ONI_SENSOR_IR: + m_videoMode.pixelFormat = ONI_PIXEL_FORMAT_GRAY16; + m_videoMode.fps = DEFAULT_FPS; + m_videoMode.resolutionX = 512; + m_videoMode.resolutionY = 424; + break; + default: + break; + } +} + +IFrameDescription* Kinect2StreamImpl::getFrameDescription(OniSensorType sensorType) +{ + if (!m_pKinectSensor) { + return NULL; + } + + IFrameDescription* frameDescription = NULL; + if (sensorType == ONI_SENSOR_COLOR) { + IColorFrameSource* frameSource = NULL; + HRESULT hr = m_pKinectSensor->get_ColorFrameSource(&frameSource); + if (SUCCEEDED(hr)) { + hr = frameSource->get_FrameDescription(&frameDescription); + if (FAILED(hr) && frameDescription) { + frameDescription->Release(); + frameDescription = NULL; + } + } + if (frameSource) { + frameSource->Release(); + } + } + else if (sensorType == ONI_SENSOR_DEPTH) { + IDepthFrameSource* frameSource = NULL; + HRESULT hr = m_pKinectSensor->get_DepthFrameSource(&frameSource); + if (SUCCEEDED(hr)) { + hr = frameSource->get_FrameDescription(&frameDescription); + if (FAILED(hr) && frameDescription) { + frameDescription->Release(); + frameDescription = NULL; + } + } + if (frameSource) { + frameSource->Release(); + } + } + else { // ONI_SENSOR_IR + IInfraredFrameSource* frameSource = NULL; + HRESULT hr = m_pKinectSensor->get_InfraredFrameSource(&frameSource); + if (SUCCEEDED(hr)) { + hr = frameSource->get_FrameDescription(&frameDescription); + if (FAILED(hr) && frameDescription) { + frameDescription->Release(); + frameDescription = NULL; + } + } + if (frameSource) { + frameSource->Release(); + } + } + + return frameDescription; +} + +void Kinect2StreamImpl::createFrameBuffer() +{ + if (m_sensorType == ONI_SENSOR_COLOR && !m_pFrameBuffer.color) { + m_pFrameBuffer.color = new RGBQUAD[1920*1080]; + } + else if (m_sensorType == ONI_SENSOR_DEPTH && !m_pFrameBuffer.depth) { + m_pFrameBuffer.depth = new UINT16[512*424]; + } + else if (!m_pFrameBuffer.infrared) { // ONI_SENSOR_IR + m_pFrameBuffer.infrared = new UINT16[512*424]; + } +} + +void Kinect2StreamImpl::destroyFrameBuffer() +{ + if (m_sensorType == ONI_SENSOR_COLOR && m_pFrameBuffer.color) { + delete[] m_pFrameBuffer.color; + m_pFrameBuffer.color = NULL; + } + else if (m_sensorType == ONI_SENSOR_DEPTH && m_pFrameBuffer.depth) { + delete[] m_pFrameBuffer.depth; + m_pFrameBuffer.depth = NULL; + } + else if (m_pFrameBuffer.infrared) { // ONI_SENSOR_IR + delete[] m_pFrameBuffer.infrared; + m_pFrameBuffer.infrared = NULL; + } +} + +void Kinect2StreamImpl::openFrameReader() +{ + if (!m_pKinectSensor) { + return; + } + + if (m_sensorType == ONI_SENSOR_COLOR && !m_pFrameReader.color) { + IColorFrameSource* frameSource = NULL; + HRESULT hr = m_pKinectSensor->get_ColorFrameSource(&frameSource); + if (SUCCEEDED(hr)) { + hr = frameSource->OpenReader(&m_pFrameReader.color); + if (FAILED(hr) && m_pFrameReader.color) { + m_pFrameReader.color->Release(); + m_pFrameReader.color = NULL; + } + } + if (frameSource) { + frameSource->Release(); + } + } + else if (m_sensorType == ONI_SENSOR_DEPTH && !m_pFrameReader.depth) { + IDepthFrameSource* frameSource = NULL; + HRESULT hr = m_pKinectSensor->get_DepthFrameSource(&frameSource); + if (SUCCEEDED(hr)) { + hr = frameSource->OpenReader(&m_pFrameReader.depth); + if (FAILED(hr) && m_pFrameReader.depth) { + m_pFrameReader.depth->Release(); + m_pFrameReader.depth = NULL; + } + } + if (frameSource) { + frameSource->Release(); + } + } + else if(!m_pFrameReader.infrared) { // ONI_SENSOR_IR + IInfraredFrameSource* frameSource = NULL; + HRESULT hr = m_pKinectSensor->get_InfraredFrameSource(&frameSource); + if (SUCCEEDED(hr)) { + hr = frameSource->OpenReader(&m_pFrameReader.infrared); + if (FAILED(hr) && m_pFrameReader.infrared) { + m_pFrameReader.infrared->Release(); + m_pFrameReader.infrared = NULL; + } + } + if (frameSource) { + frameSource->Release(); + } + } +} + +void Kinect2StreamImpl::closeFrameReader() +{ + if (m_sensorType == ONI_SENSOR_COLOR && m_pFrameReader.color) { + m_pFrameReader.color->Release(); + m_pFrameReader.color = NULL; + } + else if (m_sensorType == ONI_SENSOR_DEPTH && m_pFrameReader.depth) { + m_pFrameReader.depth->Release(); + m_pFrameReader.depth = NULL; + } + else if (m_pFrameReader.infrared) { // ONI_SENSOR_IR + m_pFrameReader.infrared->Release(); + m_pFrameReader.infrared = NULL; + } +} + +void* Kinect2StreamImpl::populateFrameBuffer(int& buffWidth, int& buffHeight) +{ + buffWidth = 0; + buffHeight = 0; + + if (m_sensorType == ONI_SENSOR_COLOR) { + if (m_pFrameReader.color && m_pFrameBuffer.color) { + buffWidth = 1920; + buffHeight = 1080; + + IColorFrame* frame = NULL; + HRESULT hr = m_pFrameReader.color->AcquireLatestFrame(&frame); + if (SUCCEEDED(hr)) { + ColorImageFormat imageFormat = ColorImageFormat_None; + hr = frame->get_RawColorImageFormat(&imageFormat); + if (SUCCEEDED(hr)) { + if (imageFormat == ColorImageFormat_Bgra) { + RGBQUAD* data; + UINT bufferSize; + frame->AccessRawUnderlyingBuffer(&bufferSize, reinterpret_cast(&data)); + memcpy(m_pFrameBuffer.color, data, 1920*1080*sizeof(RGBQUAD)); + } + else { + frame->CopyConvertedFrameDataToArray(1920*1080*sizeof(RGBQUAD), reinterpret_cast(m_pFrameBuffer.color), ColorImageFormat_Bgra); + } + } + } + if (frame) { + frame->Release(); + } + + return reinterpret_cast(m_pFrameBuffer.color); + } + } + else if (m_sensorType == ONI_SENSOR_DEPTH) { + if (m_pFrameReader.depth && m_pFrameBuffer.depth) { + buffWidth = 512; + buffHeight = 424; + + IDepthFrame* frame = NULL; + HRESULT hr = m_pFrameReader.depth->AcquireLatestFrame(&frame); + if (SUCCEEDED(hr)) { + UINT16* data; + UINT bufferSize; + frame->AccessUnderlyingBuffer(&bufferSize, &data); + memcpy(m_pFrameBuffer.depth, data, 512*424*sizeof(UINT16)); + } + if (frame) { + frame->Release(); + } + + return reinterpret_cast(m_pFrameBuffer.depth); + } + } + else { // ONI_SENSOR_IR + if (m_pFrameReader.infrared && m_pFrameBuffer.infrared) { + buffWidth = 512; + buffHeight = 424; + + IInfraredFrame* frame = NULL; + HRESULT hr = m_pFrameReader.infrared->AcquireLatestFrame(&frame); + if (SUCCEEDED(hr)) { + UINT16* data; + UINT bufferSize; + frame->AccessUnderlyingBuffer(&bufferSize, &data); + memcpy(m_pFrameBuffer.infrared, data, 512*424*sizeof(UINT16)); + } + if (frame) { + frame->Release(); + } + + return reinterpret_cast(m_pFrameBuffer.infrared); + } + } + + return NULL; +} + +XN_THREAD_PROC Kinect2StreamImpl::threadFunc(XN_THREAD_PARAM pThreadParam) +{ + Kinect2StreamImpl* pStream = (Kinect2StreamImpl*)pThreadParam; + pStream->mainLoop(); + XN_THREAD_PROC_RETURN(XN_STATUS_OK); +} diff --git a/Source/Drivers/Kinect2/Kinect2StreamImpl.h b/Source/Drivers/Kinect2/Kinect2StreamImpl.h new file mode 100755 index 00000000..aef7a776 --- /dev/null +++ b/Source/Drivers/Kinect2/Kinect2StreamImpl.h @@ -0,0 +1,83 @@ +#ifndef _KINECT2_STREAM_IMPL_H_ +#define _KINECT2_STREAM_IMPL_H_ + +#include "BaseKinect2Stream.h" +#include "XnList.h" + +struct IKinectSensor; +struct ICoordinateMapper; +struct IFrameDescription; +struct IColorFrameReader; +struct IDepthFrameReader; +struct IInfraredFrameReader; + +namespace kinect2_device +{ + class Kinect2StreamImpl + { + public: + Kinect2StreamImpl(IKinectSensor * pKinectSensor, OniSensorType sensorType, LONGLONG basePerfCounter); + virtual ~Kinect2StreamImpl(); + + void addStream(BaseKinect2Stream* stream); + void removeStream(BaseKinect2Stream* stream); + unsigned int getStreamCount(); + + void setVideoMode(OniVideoMode* videoMode); + + OniStatus virtual start(); + void virtual stop(); + bool isRunning() { return m_running; } + + OniSensorType getSensorType () { return m_sensorType; } + void setSensorType(OniSensorType sensorType); + + void mainLoop(); + + XnDouble getHorizontalFov(); + XnDouble getVerticalFov(); + + OniImageRegistrationMode getImageRegistrationMode() const { return m_imageRegistrationMode; } + void setImageRegistrationMode(OniImageRegistrationMode mode) { m_imageRegistrationMode = mode; } + + IKinectSensor* getKinectSensor() { return m_pKinectSensor; } // Need review: not sure if it is a good idea to expose this. + ICoordinateMapper* getCoordinateMapper() { return m_pCoordinateMapper; } + + private: + void setDefaultVideoMode(); + IFrameDescription* getFrameDescription(OniSensorType sensorType); + void createFrameBuffer(); + void destroyFrameBuffer(); + void openFrameReader(); + void closeFrameReader(); + void* populateFrameBuffer(int& buffWidth, int& buffHeight); + + static XN_THREAD_PROC threadFunc(XN_THREAD_PARAM pThreadParam); + + private: + IKinectSensor* m_pKinectSensor; + ICoordinateMapper* m_pCoordinateMapper; + union { + RGBQUAD* color; + UINT16* depth; + UINT16* infrared; + } m_pFrameBuffer; + union { + IColorFrameReader* color; + IDepthFrameReader* depth; + IInfraredFrameReader* infrared; + } m_pFrameReader; + OniSensorType m_sensorType; + OniImageRegistrationMode m_imageRegistrationMode; + OniVideoMode m_videoMode; + xnl::List m_streamList; + + // Thread + bool m_running; + LONGLONG m_perfCounter; + double m_perfFreq; + XN_THREAD_HANDLE m_threadHandle; + }; +} // namespace kinect2_device + +#endif //_KINECT2_STREAM_IMPL_H_ diff --git a/Source/Drivers/Kinect2/README.md b/Source/Drivers/Kinect2/README.md new file mode 100644 index 00000000..d8535a59 --- /dev/null +++ b/Source/Drivers/Kinect2/README.md @@ -0,0 +1,43 @@ +# OpenNI 2 Kinect v2 Driver # + +## Contributors ## + +Miguel Angel Vico + +--------------------------------------------------------------------------------------------------- + +## Contact ## + +Miguel Angel Vico (mvm9289@gmail.com) + +--------------------------------------------------------------------------------------------------- + +## Summary ## + +This OpenNI 2 Driver adds support for the Microsoft Kinect v2 sensor. It allows to fetch data from +either color, depth and infrared streams. It also gives support for DEPTH_TO_COLOR_REGISTRATION. + +The videomodes available through this driver are: +* Color: RGB888 1920x1080 30fps +* Color: RGB888 960x540 30fps +* Depth: DepthPixel 512x424 30fps +* IR: Gray16 (ushort) 512x424 30fps + +This driver only works on Windows 8 platforms as it is based on the Microsoft official SDK. + +--------------------------------------------------------------------------------------------------- + +## How to build ## + +First of all, since this driver is based on the official Microsoft SDK, it will only compile on +Windows 8. Additionally, even though this driver is shipped with a Visual Studio 2010 vcxproj file, +it is required to use Visual Studio 2012 or higher in order to build it. + +In order to build this driver: + +1. Place 'Kinect2' folder under 'Source/Drivers' of OpenNI 2 source directory +2. Add 'Kinect2.vcxproj' to the OpenNI 2 Visual Studio solution +3. Build it as any other OpenNI 2 driver + +--------------------------------------------------------------------------------------------------- + diff --git a/Source/Drivers/OniFile/Android.mk b/Source/Drivers/OniFile/Android.mk index 7cedeae8..2a502642 100644 --- a/Source/Drivers/OniFile/Android.mk +++ b/Source/Drivers/OniFile/Android.mk @@ -17,47 +17,34 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +include $(LOCAL_PATH)/../../../ThirdParty/PSCommon/BuildSystem/CommonAndroid.mk + # Sources MY_SRC_FILES := \ $(LOCAL_PATH)/*.cpp \ $(LOCAL_PATH)/Formats/*.cpp \ $(LOCAL_PATH)/XnLibExtensions/*.cpp -ifdef OPENNI2_ANDROID_NDK_BUILD - MY_SRC_FILES += $(LOCAL_PATH)/../../../ThirdParty/LibJPEG/*.c -endif - MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) -# C/CPP Flags -LOCAL_CFLAGS += $(OPENNI2_CFLAGS) - # Includes LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../../../Include \ - $(LOCAL_PATH)/../../../ThirdParty/PSCommon/XnLib/Include \ - $(LOCAL_PATH)/../../../ThirdParty/LibJPEG \ $(LOCAL_PATH)/Formats -ifdef OPENNI2_ANDROID_NDK_BUILD - LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ThirdParty/LibJPEG -else - LOCAL_C_INCLUDES += external/jpeg -endif - # Dependencies LOCAL_STATIC_LIBRARIES := XnLib -LOCAL_SHARED_LIBRARIES := liblog -ifdef OPENNI2_ANDROID_OS_BUILD - LOCAL_SHARED_LIBRARIES += libjpeg -else - LOCAL_LDLIBS += -llog +ifdef PS_OS_BUILD + LOCAL_SHARED_LIBRARIES += libjpeg endif # Output LOCAL_MODULE:= libOniFile include $(BUILD_SHARED_LIBRARY) + +#include XnLib +include $(LOCAL_PATH)/../../../ThirdParty/PSCommon/XnLib/Source/Android.mk diff --git a/Source/Drivers/OniFile/DataRecords.h b/Source/Drivers/OniFile/DataRecords.h index 37056e63..be057c61 100644 --- a/Source/Drivers/OniFile/DataRecords.h +++ b/Source/Drivers/OniFile/DataRecords.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __DATA_RECORDS_H__ -#define __DATA_RECORDS_H__ +#ifndef DATARECORDS_H +#define DATARECORDS_H #include "XnPlatform.h" #include "XnStatus.h" @@ -386,4 +386,4 @@ class EndRecord : public Record }; #pragma pack(pop) -#endif //__DATA_RECORDS_H__ +#endif // DATARECORDS_H diff --git a/Source/Drivers/OniFile/FileProperties.h b/Source/Drivers/OniFile/FileProperties.h new file mode 100644 index 00000000..381d2120 --- /dev/null +++ b/Source/Drivers/OniFile/FileProperties.h @@ -0,0 +1,28 @@ +/***************************************************************************** +* * +* 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 FILEPROPERTIES_H +#define FILEPROPERTIES_H + +enum { + ONI_FILE_PROPERTY_ORIGINAL_DEVICE = 0x00010001 +}; + +#endif // FILEPROPERTIES_H diff --git a/Source/Drivers/OniFile/Formats/Xn16zCodec.h b/Source/Drivers/OniFile/Formats/Xn16zCodec.h index 3b945818..7e6ac774 100644 --- a/Source/Drivers/OniFile/Formats/Xn16zCodec.h +++ b/Source/Drivers/OniFile/Formats/Xn16zCodec.h @@ -18,15 +18,16 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_16Z_CODEC_H__ -#define __XN_16Z_CODEC_H__ +#ifndef XN16ZCODEC_H +#define XN16ZCODEC_H //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnCodecBase.h" -#include "XnStreamCompression.h" +#include "XnJpeg.h" #include "XnCodecIDs.h" +#include "XnStreamCompression.h" //--------------------------------------------------------------------------- // Types @@ -52,4 +53,4 @@ class Xn16zCodec : public XnCodecBase } }; -#endif //__XN_16Z_CODEC_H__ \ No newline at end of file +#endif // XN16ZCODEC_H diff --git a/Source/Drivers/OniFile/Formats/Xn16zEmbTablesCodec.h b/Source/Drivers/OniFile/Formats/Xn16zEmbTablesCodec.h index a3c63663..6a990da9 100644 --- a/Source/Drivers/OniFile/Formats/Xn16zEmbTablesCodec.h +++ b/Source/Drivers/OniFile/Formats/Xn16zEmbTablesCodec.h @@ -18,14 +18,15 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_16Z_EMB_TABLES_CODEC_H__ -#define __XN_16Z_EMB_TABLES_CODEC_H__ +#ifndef XN16ZEMBTABLESCODEC_H +#define XN16ZEMBTABLESCODEC_H //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- -#include "XnCodecBase.h" +#include #include "XnStreamCompression.h" +#include "XnCodecBase.h" #include "XnCodecIDs.h" //--------------------------------------------------------------------------- @@ -57,4 +58,4 @@ class Xn16zEmbTablesCodec : public XnCodecBase XnUInt16 m_nMaxValue; }; -#endif //__XN_16Z_EMB_TABLES_CODEC_H__ \ No newline at end of file +#endif // XN16ZEMBTABLESCODEC_H diff --git a/Source/Drivers/OniFile/Formats/Xn8zCodec.h b/Source/Drivers/OniFile/Formats/Xn8zCodec.h index ef2e9919..69c1158a 100644 --- a/Source/Drivers/OniFile/Formats/Xn8zCodec.h +++ b/Source/Drivers/OniFile/Formats/Xn8zCodec.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_8Z_CODEC_H__ -#define __XN_8Z_CODEC_H__ +#ifndef XN8ZCODEC_H +#define XN8ZCODEC_H //--------------------------------------------------------------------------- // Includes @@ -51,4 +51,4 @@ class Xn8zCodec : public XnCodecBase } }; -#endif //__XN_8Z_CODEC_H__ \ No newline at end of file +#endif // XN8ZCODEC_H diff --git a/Source/Drivers/OniFile/Formats/XnCodec.h b/Source/Drivers/OniFile/Formats/XnCodec.h index 3aa3fca8..72df5a86 100644 --- a/Source/Drivers/OniFile/Formats/XnCodec.h +++ b/Source/Drivers/OniFile/Formats/XnCodec.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_CODEC_H__ -#define __XN_CODEC_H__ +#ifndef XNCODEC_H +#define XNCODEC_H //--------------------------------------------------------------------------- // Includes @@ -52,4 +52,4 @@ class XnCodec static XnCodecID GetCodecIDFromCompressionFormat(XnCompressionFormats format); }; -#endif //__XN_CODEC_H__ +#endif // XNCODEC_H diff --git a/Source/Drivers/OniFile/Formats/XnCodecBase.h b/Source/Drivers/OniFile/Formats/XnCodecBase.h index 71c67746..c2512395 100644 --- a/Source/Drivers/OniFile/Formats/XnCodecBase.h +++ b/Source/Drivers/OniFile/Formats/XnCodecBase.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_CODEC_BASE_H__ -#define __XN_CODEC_BASE_H__ +#ifndef XNCODECBASE_H +#define XNCODECBASE_H //--------------------------------------------------------------------------- // Includes @@ -83,4 +83,4 @@ class XnCodecBase : public XnCodec virtual XnStatus DecompressImpl(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) = 0; }; -#endif // __XN_CODEC_BASE_H__ \ No newline at end of file +#endif // XNCODECBASE_H diff --git a/Source/Drivers/OniFile/Formats/XnCodecIDs.h b/Source/Drivers/OniFile/Formats/XnCodecIDs.h index e8ecc6d6..ee5b8a37 100644 --- a/Source/Drivers/OniFile/Formats/XnCodecIDs.h +++ b/Source/Drivers/OniFile/Formats/XnCodecIDs.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __NICODECIDS_H__ -#define __NICODECIDS_H__ +#ifndef XNCODECIDS_H +#define XNCODECIDS_H /** Define a Codec ID by 4 characters, e.g. XN_CODEC_ID('J','P','E','G') **/ #define XN_CODEC_ID(c1, c2, c3, c4) (XnCodecID)((c4 << 24) | (c3 << 16) | (c2 << 8) | c1) @@ -31,4 +31,4 @@ #define XN_CODEC_16Z_EMB_TABLES XN_CODEC_ID('1','6','z','T') #define XN_CODEC_8Z XN_CODEC_ID('I','m','8','z') -#endif // __NICODECIDS_H__ +#endif // XNCODECIDS_H diff --git a/Source/Drivers/OniFile/Formats/XnJpegCodec.h b/Source/Drivers/OniFile/Formats/XnJpegCodec.h index 8ae3689a..147aa43c 100644 --- a/Source/Drivers/OniFile/Formats/XnJpegCodec.h +++ b/Source/Drivers/OniFile/Formats/XnJpegCodec.h @@ -18,14 +18,14 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_JPEG_CODEC_H__ -#define __XN_JPEG_CODEC_H__ +#ifndef XNJPEGCODEC_H +#define XNJPEGCODEC_H //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnCodecBase.h" -#include "XnStreamCompression.h" +#include "XnJpeg.h" #include "XnCodecIDs.h" //--------------------------------------------------------------------------- @@ -35,13 +35,13 @@ class XnJpegCodec : public XnCodecBase { public: XnJpegCodec(XnBool bRGB, XnUInt32 nXRes, XnUInt32 nYRes, XnUInt32 nQuality = XN_STREAM_COMPRESSION_JPEG_DEFAULT_QUALITY) : - m_bRGB(bRGB), m_nXRes(nXRes), m_nYRes(nYRes), m_nQuality(nQuality) + m_bRGB(bRGB), m_nXRes(nXRes), m_nYRes(nYRes), m_nQuality(nQuality), mp_CompJPEGContext(NULL), mp_UncompJPEGContext(NULL) {} ~XnJpegCodec() { - XnStreamFreeCompressImageJ(&m_CompJPEGContext); - XnStreamFreeUncompressImageJ(&m_UncompJPEGContext); + XnStreamFreeCompressImageJ(&mp_CompJPEGContext); + XnStreamFreeUncompressImageJ(&mp_UncompJPEGContext); } virtual XnCodecID GetCodecID() const { return XN_CODEC_JPEG; } @@ -50,13 +50,13 @@ class XnJpegCodec : public XnCodecBase { XnStatus nRetVal = XN_STATUS_OK; - nRetVal = XnStreamInitCompressImageJ(&m_CompJPEGContext); + nRetVal = XnStreamInitCompressImageJ(&mp_CompJPEGContext); XN_IS_STATUS_OK(nRetVal); - nRetVal = XnStreamInitUncompressImageJ(&m_UncompJPEGContext); + nRetVal = XnStreamInitUncompressImageJ(&mp_UncompJPEGContext); if (nRetVal != XN_STATUS_OK) { - XnStreamFreeCompressImageJ(&m_CompJPEGContext); + XnStreamFreeCompressImageJ(&mp_CompJPEGContext); return (nRetVal); } @@ -74,17 +74,17 @@ class XnJpegCodec : public XnCodecBase { if (m_bRGB) { - return XnStreamCompressImage24J(&m_CompJPEGContext, pData, pCompressedData, pnCompressedDataSize, m_nXRes, m_nYRes, m_nQuality); + return XnStreamCompressImage24J(&mp_CompJPEGContext, pData, pCompressedData, pnCompressedDataSize, m_nXRes, m_nYRes, m_nQuality); } else { - return XnStreamCompressImage8J(&m_CompJPEGContext, pData, pCompressedData, pnCompressedDataSize, m_nXRes, m_nYRes, m_nQuality); + return XnStreamCompressImage8J(&mp_CompJPEGContext, pData, pCompressedData, pnCompressedDataSize, m_nXRes, m_nYRes, m_nQuality); } } virtual XnStatus DecompressImpl(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) { - return XnStreamUncompressImageJ(&m_UncompJPEGContext, pCompressedData, nCompressedDataSize, pData, pnDataSize); + return XnStreamUncompressImageJ(&mp_UncompJPEGContext, pCompressedData, nCompressedDataSize, pData, pnDataSize); } private: @@ -92,8 +92,8 @@ class XnJpegCodec : public XnCodecBase const XnUInt32 m_nXRes; const XnUInt32 m_nYRes; const XnUInt32 m_nQuality; - XnStreamCompJPEGContext m_CompJPEGContext; - XnStreamUncompJPEGContext m_UncompJPEGContext; + XnStreamCompJPEGContext *mp_CompJPEGContext; + XnStreamUncompJPEGContext *mp_UncompJPEGContext; }; -#endif //__XN_JPEG_CODEC_H__ \ No newline at end of file +#endif // XNJPEGCODEC_H diff --git a/Source/Drivers/OniFile/Formats/XnStreamCompression.cpp b/Source/Drivers/OniFile/Formats/XnStreamCompression.cpp index ddd0d5b9..a489e981 100644 --- a/Source/Drivers/OniFile/Formats/XnStreamCompression.cpp +++ b/Source/Drivers/OniFile/Formats/XnStreamCompression.cpp @@ -23,7 +23,6 @@ //--------------------------------------------------------------------------- #include "XnStreamCompression.h" #include -#include #include #define XN_MASK_STREAM_COMPRESSION "xnStreamCompression" @@ -31,11 +30,12 @@ //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) +XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize, XnUInt16 nMaxValue) { // Local function variables const XnUInt16* pInputEnd = pInput + (nInputSize / sizeof(XnUInt16)); - XnUInt8* pOrigOutput = pOutput; + const XnUInt16* pOrigInput = pInput; + const XnUInt8* pOrigOutput = pOutput; XnUInt16 nCurrValue = 0; XnUInt16 nLastValue = 0; XnUInt16 nAbsDiffValue = 0; @@ -43,6 +43,8 @@ XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputS XnUInt8 cOutStage = 0; XnUInt8 cOutChar = 0; XnUInt8 cZeroCounter = 0; + static XnUInt16 nEmbTable[XN_MAX_UINT16]; + XnUInt16 nEmbTableIdx=0; // Note: this function does not make sure it stay within the output memory boundaries! @@ -51,21 +53,43 @@ XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputS XN_VALIDATE_INPUT_PTR(pOutput); XN_VALIDATE_INPUT_PTR(pnOutputSize); - if (nInputSize == 0) + // Create the embedded value translation table... + pOutput+=2; + xnOSMemSet(&nEmbTable[0], 0, nMaxValue*sizeof(XnUInt16)); + + while (pInput != pInputEnd) { - *pnOutputSize = 0; - return XN_STATUS_OK; + nEmbTable[*pInput] = 1; + pInput++; + } + + for (XnUInt32 i=0; i> 8); + *(XnUInt16*)pOutput = XN_PREPARE_VAR16_IN_BUFFER((nCurrValue << 8) + (nCurrValue >> 8)); pOutput+=2; } } @@ -172,12 +196,162 @@ XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputS return (XN_STATUS_OK); } -XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize, XnUInt16 nMaxValue) +XnStatus XnStreamUncompressDepth16ZWithEmbTable(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize) +{ + // Local function variables + const XnUInt8* pInputEnd = pInput + nInputSize; + XnUInt16* pOutputEnd = 0; + XnUInt16* pOrigOutput = pOutput; + XnUInt16 nLastFullValue = 0; + XnUInt8 cInput = 0; + XnUInt8 cZeroCounter = 0; + XnInt8 cInData1 = 0; + XnInt8 cInData2 = 0; + XnUInt8 cInData3 = 0; + XnUInt16* pEmbTable = NULL; + XnUInt16 nEmbTableIdx = 0; + + // Validate the input/output pointers (to make sure none of them is NULL) + XN_VALIDATE_INPUT_PTR(pInput); + XN_VALIDATE_INPUT_PTR(pOutput); + XN_VALIDATE_INPUT_PTR(pnOutputSize); + + if (nInputSize < sizeof(XnUInt16)) + { + xnLogError(XN_MASK_STREAM_COMPRESSION, "Input size too small"); + return (XN_STATUS_BAD_PARAM); + } + + nEmbTableIdx = XN_PREPARE_VAR16_IN_BUFFER(*(XnUInt16*)pInput); + pInput+=2; + pEmbTable = (XnUInt16*)pInput; + pInput+=nEmbTableIdx * 2; + for (XnUInt32 i = 0; i < nEmbTableIdx; i++) + pEmbTable[i] = XN_PREPARE_VAR16_IN_BUFFER(pEmbTable[i]); + + pOutputEnd = pOutput + (*pnOutputSize / sizeof(XnUInt16)); + + // Decode the data... + nLastFullValue = XN_PREPARE_VAR16_IN_BUFFER(*(XnUInt16*)pInput); + *pOutput = pEmbTable[nLastFullValue]; + pInput+=2; + pOutput++; + + while (pInput != pInputEnd) + { + cInput = *pInput; + + if (cInput < 0xE0) + { + cInData1 = cInput >> 4; + cInData2 = (cInput & 0x0f); + + nLastFullValue -= (cInData1 - 6); + XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); + *pOutput = pEmbTable[nLastFullValue]; + pOutput++; + + if (cInData2 != 0x0f) + { + if (cInData2 != 0x0d) + { + nLastFullValue -= (cInData2 - 6); + XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); + *pOutput = pEmbTable[nLastFullValue]; + pOutput++; + } + + pInput++; + } + else + { + pInput++; + + cInData3 = *pInput; + if (cInData3 & 0x80) + { + nLastFullValue -= (cInData3 - 192); + + XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); + *pOutput = pEmbTable[nLastFullValue]; + + pOutput++; + pInput++; + } + else + { + nLastFullValue = cInData3 << 8; + pInput++; + nLastFullValue += *pInput; + + XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); + *pOutput = pEmbTable[nLastFullValue]; + + pOutput++; + pInput++; + } + } + } + else if (cInput == 0xFF) + { + pInput++; + + cInData3 = *pInput; + + if (cInData3 & 0x80) + { + nLastFullValue -= (cInData3 - 192); + + XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); + *pOutput = pEmbTable[nLastFullValue]; + + pInput++; + pOutput++; + } + else + { + nLastFullValue = cInData3 << 8; + pInput++; + nLastFullValue += *pInput; + + XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); + *pOutput = pEmbTable[nLastFullValue]; + + pInput++; + pOutput++; + } + } + else //It must be 0xE? + { + cZeroCounter = cInput - 0xE0; + + while (cZeroCounter != 0) + { + XN_CHECK_OUTPUT_OVERFLOW(pOutput+1, pOutputEnd); + *pOutput = pEmbTable[nLastFullValue]; + pOutput++; + + *pOutput = pEmbTable[nLastFullValue]; + pOutput++; + + cZeroCounter--; + } + + pInput++; + } + } + + *pnOutputSize = (XnUInt32)((pOutput - pOrigOutput) * sizeof(XnUInt16)); + + // All is good... + return (XN_STATUS_OK); +} + +XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) { // Local function variables const XnUInt16* pInputEnd = pInput + (nInputSize / sizeof(XnUInt16)); - const XnUInt16* pOrigInput = pInput; - const XnUInt8* pOrigOutput = pOutput; + XnUInt8* pOrigOutput = pOutput; XnUInt16 nCurrValue = 0; XnUInt16 nLastValue = 0; XnUInt16 nAbsDiffValue = 0; @@ -185,8 +359,6 @@ XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pInput, const XnUI XnUInt8 cOutStage = 0; XnUInt8 cOutChar = 0; XnUInt8 cZeroCounter = 0; - static XnUInt16 nEmbTable[XN_MAX_UINT16]; - XnUInt16 nEmbTableIdx=0; // Note: this function does not make sure it stay within the output memory boundaries! @@ -195,43 +367,21 @@ XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pInput, const XnUI XN_VALIDATE_INPUT_PTR(pOutput); XN_VALIDATE_INPUT_PTR(pnOutputSize); - // Create the embedded value translation table... - pOutput+=2; - xnOSMemSet(&nEmbTable[0], 0, nMaxValue*sizeof(XnUInt16)); - - while (pInput != pInputEnd) - { - nEmbTable[*pInput] = 1; - pInput++; - } - - for (XnUInt32 i=0; i> 8)); + *(XnUInt16*)pOutput = (nCurrValue << 8) + (nCurrValue >> 8); pOutput+=2; } } @@ -480,170 +630,19 @@ XnStatus XnStreamUncompressDepth16Z(const XnUInt8* pInput, const XnUInt32 nInput return (XN_STATUS_OK); } -XnStatus XnStreamUncompressDepth16ZWithEmbTable(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize) +XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) { // Local function variables const XnUInt8* pInputEnd = pInput + nInputSize; - XnUInt16* pOutputEnd = 0; - XnUInt16* pOrigOutput = pOutput; - XnUInt16 nLastFullValue = 0; - XnUInt8 cInput = 0; + const XnUInt8* pOrigOutput = pOutput; + XnUInt8 nCurrValue = 0; + XnUInt8 nLastValue = 0; + XnUInt8 nAbsDiffValue = 0; + XnInt8 nDiffValue = 0; + XnUInt8 cOutStage = 0; + XnUInt8 cOutChar = 0; XnUInt8 cZeroCounter = 0; - XnInt8 cInData1 = 0; - XnInt8 cInData2 = 0; - XnUInt8 cInData3 = 0; - XnUInt16* pEmbTable = NULL; - XnUInt16 nEmbTableIdx = 0; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - if (nInputSize < sizeof(XnUInt16)) - { - xnLogError(XN_MASK_STREAM_COMPRESSION, "Input size too small"); - return (XN_STATUS_BAD_PARAM); - } - - nEmbTableIdx = XN_PREPARE_VAR16_IN_BUFFER(*(XnUInt16*)pInput); - pInput+=2; - pEmbTable = (XnUInt16*)pInput; - pInput+=nEmbTableIdx * 2; - for (XnUInt32 i = 0; i < nEmbTableIdx; i++) - pEmbTable[i] = XN_PREPARE_VAR16_IN_BUFFER(pEmbTable[i]); - - pOutputEnd = pOutput + (*pnOutputSize / sizeof(XnUInt16)); - - // Decode the data... - nLastFullValue = XN_PREPARE_VAR16_IN_BUFFER(*(XnUInt16*)pInput); - *pOutput = pEmbTable[nLastFullValue]; - pInput+=2; - pOutput++; - - while (pInput != pInputEnd) - { - cInput = *pInput; - - if (cInput < 0xE0) - { - cInData1 = cInput >> 4; - cInData2 = (cInput & 0x0f); - - nLastFullValue -= (cInData1 - 6); - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - - if (cInData2 != 0x0f) - { - if (cInData2 != 0x0d) - { - nLastFullValue -= (cInData2 - 6); - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - } - - pInput++; - } - else - { - pInput++; - - cInData3 = *pInput; - if (cInData3 & 0x80) - { - nLastFullValue -= (cInData3 - 192); - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pOutput++; - pInput++; - } - else - { - nLastFullValue = cInData3 << 8; - pInput++; - nLastFullValue += *pInput; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pOutput++; - pInput++; - } - } - } - else if (cInput == 0xFF) - { - pInput++; - - cInData3 = *pInput; - - if (cInData3 & 0x80) - { - nLastFullValue -= (cInData3 - 192); - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pInput++; - pOutput++; - } - else - { - nLastFullValue = cInData3 << 8; - pInput++; - nLastFullValue += *pInput; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pInput++; - pOutput++; - } - } - else //It must be 0xE? - { - cZeroCounter = cInput - 0xE0; - - while (cZeroCounter != 0) - { - XN_CHECK_OUTPUT_OVERFLOW(pOutput+1, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - - cZeroCounter--; - } - - pInput++; - } - } - - *pnOutputSize = (XnUInt32)((pOutput - pOrigOutput) * sizeof(XnUInt16)); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - const XnUInt8* pOrigOutput = pOutput; - XnUInt8 nCurrValue = 0; - XnUInt8 nLastValue = 0; - XnUInt8 nAbsDiffValue = 0; - XnInt8 nDiffValue = 0; - XnUInt8 cOutStage = 0; - XnUInt8 cOutChar = 0; - XnUInt8 cZeroCounter = 0; - XnBool bFlag = FALSE; + XnBool bFlag = FALSE; // Note: this function does not make sure it stay within the output memory boundaries! @@ -888,427 +887,3 @@ XnStatus XnStreamUncompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputS return (XN_STATUS_OK); } -XnStatus XnStreamCompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - const XnUInt8* pOrigOutput = pOutput; - - // Note: this function does not make sure it stay within the output memory boundaries! - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - // Encode the data... - while (pInput != pInputEnd) - { - *pOutput = *pInput << 4; - pInput++; - - *pOutput += *pInput; - pInput++; - - pOutput++; - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamUncompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - const XnUInt8* pOutputEnd = 0; - const XnUInt8* pOrigOutput = pOutput; - XnUInt8 nValue1; - XnUInt8 nValue2; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - if (nInputSize < sizeof(XnUInt8)) - { - xnLogError(XN_MASK_STREAM_COMPRESSION, "Input size too small"); - return (XN_STATUS_BAD_PARAM); - } - - if (nInputSize % 2 != 0) - { - xnLogError(XN_MASK_STREAM_COMPRESSION, "Input size not word-aligned"); - return (XN_STATUS_BAD_PARAM); - } - - pOutputEnd = pOutput + *pnOutputSize; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput + (nInputSize * 2), pOutputEnd); - - while (pInput != pInputEnd) - { - nValue1 = pInput[0]; - nValue2 = pInput[1]; - - pOutput[0] = nValue1 >> 4; - pOutput[1] = nValue1 & 0xF; - pOutput[2] = nValue2 >> 4; - pOutput[3] = nValue2 & 0xF; - - pOutput+=4; - pInput+=2; - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -void XnStreamJPEGCompDummyFunction(struct jpeg_compress_struct* /*pjCompStruct*/) -{ - // Dummy libjpeg function to wrap internal buffers usage... -} - -boolean XnStreamJPEGCompDummyFailFunction(struct jpeg_compress_struct* /*pjCompStruct*/) -{ - // If we ever got to the point we need to allocate more memory, something is wrong! - return (FALSE); -} - -void XnStreamJPEGDummyErrorExit(j_common_ptr cinfo) -{ - XnLibJpegErrorMgr* errMgr = (XnLibJpegErrorMgr*)cinfo->err; - - longjmp(errMgr->setjmpBuffer, 1); -} - -void XnStreamJPEGOutputMessage(j_common_ptr cinfo) -{ - struct jpeg_error_mgr* err = cinfo->err; - int msg_code = err->msg_code; - if (msg_code == JWRN_EXTRANEOUS_DATA) - { - // NOTE: we are aware this problem occurs. Log a warning every once in a while - static XnUInt32 nTimes = 0; - if (++nTimes == 50) - { - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - - //Temporary disabled this error since it happens all the time and it's a known issue. - //xnLogWarning(XN_MASK_JPEG, "JPEG: The following warning occurred 50 times: %s", buffer); - nTimes = 0; - } - } - else - { - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - - xnLogWarning(XN_MASK_JPEG, "JPEG: %s", buffer); - } -} - -XnStatus XnStreamInitCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_OUTPUT_PTR(pStreamCompJPEGContext); - - pStreamCompJPEGContext->jCompStruct.err = jpeg_std_error(&pStreamCompJPEGContext->jErrMgr.pub); - pStreamCompJPEGContext->jErrMgr.pub.output_message = XnStreamJPEGOutputMessage; - pStreamCompJPEGContext->jErrMgr.pub.error_exit = XnStreamJPEGDummyErrorExit; - - jpeg_create_compress(&pStreamCompJPEGContext->jCompStruct); - - pStreamCompJPEGContext->jCompStruct.dest = &pStreamCompJPEGContext->jDestMgr; - pStreamCompJPEGContext->jCompStruct.dest->init_destination = XnStreamJPEGCompDummyFunction; - pStreamCompJPEGContext->jCompStruct.dest->empty_output_buffer = XnStreamJPEGCompDummyFailFunction; - pStreamCompJPEGContext->jCompStruct.dest->term_destination = XnStreamJPEGCompDummyFunction; - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamFreeCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamCompJPEGContext); - - jpeg_destroy_compress(&pStreamCompJPEGContext->jCompStruct); - - // All is good... - return (XN_STATUS_OK); -} - -#ifdef _WIN32 -// to allow the use of setjmp -#pragma warning(push) -#pragma warning(disable: 4611) -#endif - -XnStatus XnStreamCompressImage8J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality) -{ - // Local function variables - XnUInt8* pCurrScanline = (XnUInt8*)pInput; - XnUInt32 nYIndex = 0; - jpeg_compress_struct* pjCompStruct = NULL; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamCompJPEGContext); - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_OUTPUT_PTR(pOutput); - XN_VALIDATE_OUTPUT_PTR(pnOutputSize); - - pjCompStruct = &pStreamCompJPEGContext->jCompStruct; - - if (setjmp(pStreamCompJPEGContext->jErrMgr.setjmpBuffer)) - { - //If we get here, the JPEG code has signaled an error. - XnStreamFreeCompressImageJ(pStreamCompJPEGContext); - XnStreamInitCompressImageJ(pStreamCompJPEGContext); - - *pnOutputSize = 0; - - xnLogError(XN_MASK_JPEG, "JPEG compressor error :("); - return (XN_STATUS_ERROR); - } - - pjCompStruct->in_color_space = JCS_GRAYSCALE; - jpeg_set_defaults(pjCompStruct); - pjCompStruct->input_components = 1; - pjCompStruct->num_components = 1; - pjCompStruct->image_width = nXRes; - pjCompStruct->image_height = nYRes; - pjCompStruct->data_precision = 8; - pjCompStruct->input_gamma = 1.0; - - jpeg_set_quality(pjCompStruct, nQuality, FALSE); - - pjCompStruct->dest->next_output_byte = (JOCTET*)pOutput; - pjCompStruct->dest->free_in_buffer = *pnOutputSize; - - jpeg_start_compress(pjCompStruct, TRUE); - - for (nYIndex = 0; nYIndex < nYRes; nYIndex++) - { - jpeg_write_scanlines(pjCompStruct, &pCurrScanline, 1); - - pCurrScanline += nXRes; - } - - jpeg_finish_compress(pjCompStruct); - - *pnOutputSize -= (XnUInt32)pjCompStruct->dest->free_in_buffer; - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamCompressImage24J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality) -{ - // Local function variables - XnUInt8* pCurrScanline = (XnUChar*)pInput; - XnUInt32 nYIndex = 0; - XnUInt32 nScanLineSize = 0; - jpeg_compress_struct* pjCompStruct = NULL; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamCompJPEGContext); - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_OUTPUT_PTR(pOutput); - XN_VALIDATE_OUTPUT_PTR(pnOutputSize); - - pjCompStruct = &pStreamCompJPEGContext->jCompStruct; - - if (setjmp(pStreamCompJPEGContext->jErrMgr.setjmpBuffer)) - { - //If we get here, the JPEG code has signaled an error. - XnStreamFreeCompressImageJ(pStreamCompJPEGContext); - XnStreamInitCompressImageJ(pStreamCompJPEGContext); - - *pnOutputSize = 0; - - xnLogError(XN_MASK_JPEG, "JPEG compressor error :("); - return (XN_STATUS_ERROR); - } - - pjCompStruct->in_color_space = JCS_RGB; - jpeg_set_defaults(pjCompStruct); - pjCompStruct->input_components = 3; - pjCompStruct->num_components = 3; - pjCompStruct->image_width = nXRes; - pjCompStruct->image_height = nYRes; - pjCompStruct->data_precision = 8; - pjCompStruct->input_gamma = 1.0; - - jpeg_set_quality(pjCompStruct, nQuality, FALSE); - - pjCompStruct->dest->next_output_byte = (JOCTET*)pOutput; - pjCompStruct->dest->free_in_buffer = *pnOutputSize; - - jpeg_start_compress(pjCompStruct, TRUE); - - nScanLineSize = nXRes * 3; - for (nYIndex = 0; nYIndex < nYRes; nYIndex++) - { - jpeg_write_scanlines(pjCompStruct, &pCurrScanline, 1); - - pCurrScanline += nScanLineSize; - } - - jpeg_finish_compress(pjCompStruct); - - *pnOutputSize -= (XnUInt32)pjCompStruct->dest->free_in_buffer; - - // All is good... - return (XN_STATUS_OK); -} - -void XnStreamJPEGDecompDummyFunction(struct jpeg_decompress_struct* /*pjDecompStruct*/) -{ - // Dummy libjpeg function to wrap internal buffers usage... -} - -boolean XnStreamJPEGDecompDummyFailFunction(struct jpeg_decompress_struct* /*pjDecompStruct*/) -{ - // If we ever got to the point we need to allocate more memory, something is wrong! - return (FALSE); -} - -void XnStreamJPEGDecompSkipFunction(struct jpeg_decompress_struct* pjDecompStruct, long nNumBytes) -{ - // Skip bytes in the internal buffer - pjDecompStruct->src->next_input_byte += (size_t)nNumBytes; - pjDecompStruct->src->bytes_in_buffer -= (size_t)nNumBytes; -} - -XnStatus XnStreamInitUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_OUTPUT_PTR(pStreamUncompJPEGContext); - - pStreamUncompJPEGContext->jDecompStruct.err = jpeg_std_error(&pStreamUncompJPEGContext->jErrMgr.pub); - pStreamUncompJPEGContext->jErrMgr.pub.output_message = XnStreamJPEGOutputMessage; - pStreamUncompJPEGContext->jErrMgr.pub.error_exit = XnStreamJPEGDummyErrorExit; - - jpeg_create_decompress(&pStreamUncompJPEGContext->jDecompStruct); - - pStreamUncompJPEGContext->jDecompStruct.src = &pStreamUncompJPEGContext->jSrcMgr; - pStreamUncompJPEGContext->jDecompStruct.src->init_source = XnStreamJPEGDecompDummyFunction; - pStreamUncompJPEGContext->jDecompStruct.src->fill_input_buffer = XnStreamJPEGDecompDummyFailFunction; - pStreamUncompJPEGContext->jDecompStruct.src->skip_input_data = XnStreamJPEGDecompSkipFunction; - pStreamUncompJPEGContext->jDecompStruct.src->resync_to_restart = jpeg_resync_to_restart; - pStreamUncompJPEGContext->jDecompStruct.src->term_source = XnStreamJPEGDecompDummyFunction; - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamFreeUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamUncompJPEGContext); - - jpeg_destroy_decompress(&pStreamUncompJPEGContext->jDecompStruct); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext, const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - XnUInt8* pCurrScanline = pOutput; - XnUInt8* pNextScanline = NULL; - XnUInt8* pOutputEnd = 0; - XnUInt32 nScanLineSize = 0; - XnUInt32 nOutputSize = 0; - jpeg_decompress_struct* pjDecompStruct = NULL; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamUncompJPEGContext); - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_OUTPUT_PTR(pOutput); - XN_VALIDATE_OUTPUT_PTR(pnOutputSize); - - if (nInputSize == 0) - { - xnLogError(XN_MASK_JPEG, "Input size is 0"); - return (XN_STATUS_BAD_PARAM); - } - - pOutputEnd = pOutput + *pnOutputSize; - - pjDecompStruct = &pStreamUncompJPEGContext->jDecompStruct; - - pjDecompStruct->src->bytes_in_buffer = nInputSize; - pjDecompStruct->src->next_input_byte = pInput; - - if (setjmp(pStreamUncompJPEGContext->jErrMgr.setjmpBuffer)) - { - //If we get here, the JPEG code has signaled an error. - XnStreamFreeUncompressImageJ(pStreamUncompJPEGContext); - XnStreamInitUncompressImageJ(pStreamUncompJPEGContext); - - *pnOutputSize = 0; - - xnLogError(XN_MASK_JPEG, "JPEG compressor error :("); - return (XN_STATUS_ERROR); - } - - jpeg_read_header(pjDecompStruct, TRUE); - - jpeg_start_decompress(pjDecompStruct); - - nScanLineSize = pjDecompStruct->output_width * pjDecompStruct->num_components; - - nOutputSize = pjDecompStruct->output_height * nScanLineSize; - if (nOutputSize > *pnOutputSize) - { - XnStreamFreeUncompressImageJ(pStreamUncompJPEGContext); - XnStreamInitUncompressImageJ(pStreamUncompJPEGContext); - - *pnOutputSize = 0; - - xnLogError(XN_MASK_JPEG, "JPEG compressor error :("); - return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); - } - - while (pStreamUncompJPEGContext->jDecompStruct.output_scanline < pStreamUncompJPEGContext->jDecompStruct.output_height) - { - pNextScanline = pCurrScanline+nScanLineSize; - - if (pNextScanline > pOutputEnd) - { - XnStreamFreeUncompressImageJ(pStreamUncompJPEGContext); - XnStreamInitUncompressImageJ(pStreamUncompJPEGContext); - - *pnOutputSize = 0; - - xnLogError(XN_MASK_JPEG, "JPEG compressor error :("); - return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); - } - - jpeg_read_scanlines(pjDecompStruct, &pCurrScanline, 1); - pCurrScanline = pNextScanline; - } - - jpeg_finish_decompress(pjDecompStruct); - - *pnOutputSize = nOutputSize; - - // All is good... - return (XN_STATUS_OK); -} -#ifdef _WIN32 -#pragma warning(pop) -#endif diff --git a/Source/Drivers/OniFile/Formats/XnStreamCompression.h b/Source/Drivers/OniFile/Formats/XnStreamCompression.h index 79e84d13..f9dd7460 100644 --- a/Source/Drivers/OniFile/Formats/XnStreamCompression.h +++ b/Source/Drivers/OniFile/Formats/XnStreamCompression.h @@ -18,86 +18,28 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_STREAMCOMPRESSION_H_ -#define _XN_STREAMCOMPRESSION_H_ +#ifndef XNSTREAMCOMPRESSION_H +#define XNSTREAMCOMPRESSION_H //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include -extern "C" { -#include -} -#include - -//--------------------------------------------------------------------------- -// Defines -//--------------------------------------------------------------------------- -#define XN_STREAM_COMPRESSION_DEPTH16Z_WORSE_RATIO 1.333F -#define XN_STREAM_COMPRESSION_IMAGE8Z_WORSE_RATIO 1.333F -#define XN_STREAM_COMPRESSION_IMAGEJ_WORSE_RATIO 1.2F -#define XN_STREAM_COMPRESSION_CONF4_WORSE_RATIO 0.51F -#define XN_STREAM_COMPRESSION_JPEG_DEFAULT_QUALITY 90 - -#define XN_STREAM_STRING_BAD_FORMAT -1 - -#define XN_MASK_JPEG "JPEG" - -//--------------------------------------------------------------------------- -// Structs -//--------------------------------------------------------------------------- - -XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_STRUCT_PADDED_WARNING_ID); - -typedef struct XnLibJpegErrorMgr -{ - struct jpeg_error_mgr pub; - - jmp_buf setjmpBuffer; -} XnLibJpegErrorMgr; - -XN_PRAGMA_STOP_DISABLED_WARNING_SECTION; - -typedef struct XnStreamCompJPEGContext -{ - jpeg_compress_struct jCompStruct; - XnLibJpegErrorMgr jErrMgr; - struct jpeg_destination_mgr jDestMgr; -} XnStreamCompJPEGContext; - -typedef struct XnStreamUncompJPEGContext -{ - jpeg_decompress_struct jDecompStruct; - XnLibJpegErrorMgr jErrMgr; - struct jpeg_source_mgr jSrcMgr; -} XnStreamUncompJPEGContext; +#include //--------------------------------------------------------------------------- // Functions Declaration //--------------------------------------------------------------------------- -XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize, XnUInt16 nMaxValue); -XnStatus XnStreamUncompressDepth16Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize); + XnStatus XnStreamUncompressDepth16ZWithEmbTable(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamUncompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); +XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamCompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamUncompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); +XnStatus XnStreamUncompressDepth16Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize); -void XnStreamJPEGCompDummyFunction(struct jpeg_compress_struct* pjCompStruct); -boolean XnStreamJPEGCompDummyFailFunction(struct jpeg_compress_struct* pjCompStruct); -XnStatus XnStreamInitCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext); -XnStatus XnStreamFreeCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext); -XnStatus XnStreamCompressImage8J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality); -XnStatus XnStreamCompressImage24J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality); +XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -void XnStreamJPEGDecompDummyFunction(struct jpeg_decompress_struct* pjDecompStruct); -boolean XnStreamJPEGDecompDummyFailFunction(struct jpeg_decompress_struct* pjDecompStruct); -void XnStreamJPEGDecompSkipFunction(struct jpeg_decompress_struct* pjDecompStruct, XnInt nNumBytes); -XnStatus XnStreamInitUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext); -XnStatus XnStreamFreeUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext); -XnStatus XnStreamUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext, const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); +XnStatus XnStreamUncompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -#endif //_XN_STREAMCOMPRESSION_H_ +#endif // XNSTREAMCOMPRESSION_H diff --git a/Source/Drivers/OniFile/Formats/XnStreamFormats.h b/Source/Drivers/OniFile/Formats/XnStreamFormats.h index 818cfc35..38ff221a 100644 --- a/Source/Drivers/OniFile/Formats/XnStreamFormats.h +++ b/Source/Drivers/OniFile/Formats/XnStreamFormats.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_STREAM_FORMATS_H__ -#define __XN_STREAM_FORMATS_H__ +#ifndef XNSTREAMFORMATS_H +#define XNSTREAMFORMATS_H //--------------------------------------------------------------------------- // Includes @@ -46,4 +46,4 @@ typedef enum XN_COMPRESSION_10BIT_PACKED = 5, } XnCompressionFormats; -#endif //__XN_STREAM_FORMATS_H__ \ No newline at end of file +#endif // XNSTREAMFORMATS_H diff --git a/Source/Drivers/OniFile/Formats/XnUncompressedCodec.h b/Source/Drivers/OniFile/Formats/XnUncompressedCodec.h index ca9351ad..86673f18 100644 --- a/Source/Drivers/OniFile/Formats/XnUncompressedCodec.h +++ b/Source/Drivers/OniFile/Formats/XnUncompressedCodec.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_UNCOMPRESSED_CODEC_H__ -#define __XN_UNCOMPRESSED_CODEC_H__ +#ifndef XNUNCOMPRESSEDCODEC_H +#define XNUNCOMPRESSEDCODEC_H //--------------------------------------------------------------------------- // Includes @@ -68,4 +68,4 @@ class XnUncompressedCodec : public XnCodecBase } }; -#endif //__XN_UNCOMPRESSED_CODEC_H__ \ No newline at end of file +#endif // XNUNCOMPRESSEDCODEC_H diff --git a/Source/Drivers/OniFile/Makefile b/Source/Drivers/OniFile/Makefile index 69daf8f0..22d1e17f 100644 --- a/Source/Drivers/OniFile/Makefile +++ b/Source/Drivers/OniFile/Makefile @@ -6,26 +6,26 @@ INC_DIRS = \ . \ ../../../Include \ ../../../ThirdParty/PSCommon/XnLib/Include \ - ../../../ThirdParty/LibJPEG \ Formats SRC_FILES = \ *.cpp \ Formats/*.cpp \ XnLibExtensions/*.cpp \ - ../../../ThirdParty/LibJPEG/*.c - ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib -# LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib endif LIB_NAME = OniFile LIB_DIRS = ../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) -USED_LIBS = XnLib pthread +USED_LIBS = XnLib pthread dl ifneq ("$(OSTYPE)","Darwin") USED_LIBS += rt endif diff --git a/Source/Drivers/OniFile/OniFile.vcxproj b/Source/Drivers/OniFile/OniFile.vcxproj index 9b173f7d..55a86b64 100644 --- a/Source/Drivers/OniFile/OniFile.vcxproj +++ b/Source/Drivers/OniFile/OniFile.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,23 +28,27 @@ DynamicLibrary true MultiByte + v120 DynamicLibrary true MultiByte + v120 DynamicLibrary false true MultiByte + v120 DynamicLibrary false true MultiByte + v120 @@ -97,7 +101,7 @@ Level4 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;ONIFILESPLAYER_EXPORTS;%(PreprocessorDefinitions) - ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;..\..\..\ThirdParty\LibJPEG + ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include true true @@ -168,7 +172,7 @@ MaxSpeed true WIN32;NDEBUG;_WINDOWS;_USRDLL;ONIFILESPLAYER_EXPORTS;%(PreprocessorDefinitions) - ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;..\..\..\ThirdParty\LibJPEG + ..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include true true AnySuitable @@ -248,6 +252,7 @@ + @@ -268,466 +273,6 @@ - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - - - Level3 - Level3 - false - false - Level3 - Level3 - false - false - @@ -746,6 +291,9 @@ ..\..\..\Include + + + diff --git a/Source/Drivers/OniFile/OniFile.vcxproj.filters b/Source/Drivers/OniFile/OniFile.vcxproj.filters index 6b6a4234..b0181a53 100644 --- a/Source/Drivers/OniFile/OniFile.vcxproj.filters +++ b/Source/Drivers/OniFile/OniFile.vcxproj.filters @@ -19,8 +19,8 @@ {2b5f0f3a-dcdb-4faa-9b5f-d6b2d0c24222} - - {8505174a-1146-4871-8927-07bbe186c5e5} + + {61985e27-6425-4e2a-9e4d-b944a16c8db4} @@ -81,149 +81,14 @@ Header Files + + Header Files + Source Files\Formats - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - - - Source Files\Formats\LibJPEG - Source Files @@ -254,4 +119,9 @@ Resource Files - \ No newline at end of file + + + Config + + + diff --git a/Source/Drivers/OniFile/PlayerCodecFactory.h b/Source/Drivers/OniFile/PlayerCodecFactory.h index e054dbe2..af35623c 100644 --- a/Source/Drivers/OniFile/PlayerCodecFactory.h +++ b/Source/Drivers/OniFile/PlayerCodecFactory.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __PLAYER_CODEC_FACTORY_H__ -#define __PLAYER_CODEC_FACTORY_H__ +#ifndef PLAYERCODECFACTORY_H +#define PLAYERCODECFACTORY_H //--------------------------------------------------------------------------- // Includes @@ -41,4 +41,4 @@ class PlayerCodecFactory } // namespace oni_files_player -#endif //__PLAYER_CODEC_FACTORY_H__ \ No newline at end of file +#endif // PLAYERCODECFACTORY_H diff --git a/Source/Drivers/OniFile/PlayerDevice.cpp b/Source/Drivers/OniFile/PlayerDevice.cpp index c79efd8b..34ce2191 100644 --- a/Source/Drivers/OniFile/PlayerDevice.cpp +++ b/Source/Drivers/OniFile/PlayerDevice.cpp @@ -31,11 +31,14 @@ #include "Formats/XnCodec.h" #include "PlayerCodecFactory.h" #include "PS1080.h" +#include "PSLink.h" +#include "XnOSStrings.h" namespace oni_file { namespace driver = oni::driver; +#define XN_PLAYER_CONFIGURATION_FILE "OniFile.ini" #define DEVICE_DESTROY_THREAD_TIMEOUT 3000 #define DEVICE_READY_FOR_DATA_EVENT_SANITY_SLEEP 2000 #define DEVICE_MANUAL_TRIGGER_STANITY_SLEEP 2000 @@ -43,6 +46,10 @@ namespace driver = oni::driver; #define XN_PLAYBACK_SPEED_FASTEST 0.0 #define XN_PLAYBACK_SPEED_MANUAL (-1.0) +#define ONI_INIFILE_SECTION_PLAYER "Player" +#define ONI_INIFILE_ENTRY_SPEED "Speed" +#define ONI_INIFILE_ENTRY_REPEAT "Repeat" + #ifndef ARRAYSIZE #define ARRAYSIZE(a) (sizeof(a)/sizeof((a)[0])) #endif //ARRAYSIZE @@ -55,9 +62,9 @@ typedef struct // Name of the property. XnChar propertyName[40]; -} PS1080Property; +} PropertyEntry; -static PS1080Property PS1080PropertyList[] = +static PropertyEntry PS1080PropertyList[] = { { XN_STREAM_PROPERTY_INPUT_FORMAT, "InputFormat" }, { XN_STREAM_PROPERTY_CROPPING_MODE, "CroppingMode" }, @@ -78,6 +85,7 @@ static PS1080Property PS1080PropertyList[] = { XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE, "LDDIS" }, { XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE, "DCRCDIS" }, { XN_STREAM_PROPERTY_CLOSE_RANGE, "CloseRange" }, + { XN_STREAM_PROPERTY_FAST_ZOOM_CROP, "FastZoomCrop" }, { XN_STREAM_PROPERTY_PIXEL_REGISTRATION, "PixelRegistration" }, /*{ XN_MODULE_PROPERTY_SDK_VERSION, "SDKVersion" }, { XN_MODULE_PROPERTY_DEVICE_NAME, "DeviceName" }, @@ -90,11 +98,98 @@ static PS1080Property PS1080PropertyList[] = */ }; +static PropertyEntry PSLinkPropertyList[] = +{ + { LINK_PROP_MAX_SHIFT, "MaxShift" }, + { LINK_PROP_ZERO_PLANE_DISTANCE, "ZPD" }, + { LINK_PROP_CONST_SHIFT, "ConstShift" }, + { LINK_PROP_PARAM_COEFF, "ParamCoeff" }, + { LINK_PROP_SHIFT_SCALE, "ShiftScale" }, + { LINK_PROP_ZERO_PLANE_PIXEL_SIZE, "ZPPS" }, + { LINK_PROP_ZERO_PLANE_OUTPUT_PIXEL_SIZE, "ZPOPS" }, + { LINK_PROP_EMITTER_DEPTH_CMOS_DISTANCE, "LDDIS" }, + { LINK_PROP_SHIFT_TO_DEPTH_TABLE, "S2D" }, + { LINK_PROP_DEPTH_TO_SHIFT_TABLE, "D2S" }, +}; + +XnStatus PlayerDevice::ResolveGlobalConfigFileName(XnChar* strConfigFile, XnUInt32 nBufSize, const XnChar* strConfigDir) +{ + XnStatus rc = XN_STATUS_OK; + + // If strConfigDir is NULL, tries to resolve the config file based on the driver's directory + XnChar strBaseDir[XN_FILE_MAX_PATH]; + if (strConfigDir == NULL) + { +#if XN_PLATFORM == XN_PLATFORM_ANDROID_ARM + // support for applications + xnOSGetApplicationFilesDir(strBaseDir, nBufSize); + + XnChar strTempFileName[XN_FILE_MAX_PATH]; + xnOSStrCopy(strTempFileName, strBaseDir, sizeof(strTempFileName)); + rc = xnOSAppendFilePath(strTempFileName, XN_PLAYER_CONFIGURATION_FILE, sizeof(strTempFileName)); + XN_IS_STATUS_OK(rc); + + XnBool bExists; + xnOSDoesFileExist(strTempFileName, &bExists); + + if (bExists) + { + strConfigDir = strBaseDir; + } + else + { + // support for native use - search in current dir + strConfigDir = "."; + } +#else + if (xnOSGetModulePathForProcAddress((void*)(&PlayerDevice::ResolveGlobalConfigFileName), strBaseDir) == XN_STATUS_OK && + xnOSGetDirName(strBaseDir, strBaseDir, XN_FILE_MAX_PATH) == XN_STATUS_OK) + { + // Successfully obtained the driver's path + strConfigDir = strBaseDir; + } + else + { + // Something wrong happened. Use the current directory as the fallback. + strConfigDir = "."; + } +#endif + } + + XN_VALIDATE_STR_COPY(strConfigFile, strConfigDir, nBufSize, rc); + return xnOSAppendFilePath(strConfigFile, XN_PLAYER_CONFIGURATION_FILE, nBufSize); +} + +void PlayerDevice::LoadConfigurationFromIniFile() +{ + XnStatus nRetVal; + XnDouble dSpeed = 0; + XnInt32 nRepearMode = 0; + + nRetVal = xnOSReadDoubleFromINI(m_iniFilePath,ONI_INIFILE_SECTION_PLAYER, ONI_INIFILE_ENTRY_SPEED, &dSpeed); + + if (XN_STATUS_OK == nRetVal) + { + m_dPlaybackSpeed = dSpeed; + } + + nRetVal = xnOSReadIntFromINI(m_iniFilePath, ONI_INIFILE_SECTION_PLAYER, ONI_INIFILE_ENTRY_REPEAT, &nRepearMode); + + if (XN_STATUS_OK == nRetVal) + { + m_bRepeat = nRepearMode; + } + + +} + PlayerDevice::PlayerDevice(const xnl::String& filePath) : m_filePath(filePath), m_fileHandle(0), m_threadHandle(NULL), m_running(FALSE), m_isSeeking(FALSE), m_dPlaybackSpeed(1.0), m_nStartTimestamp(0), m_nStartTime(0), m_bHasTimeReference(FALSE), m_bRepeat(TRUE), m_player(filePath.Data()), m_driverEOFCallback(NULL), m_driverCookie(NULL) { + xnOSMemSet(m_originalDevice, 0, sizeof(m_originalDevice)); + // Create the events. m_readyForDataInternalEvent.Create(FALSE); m_manualTriggerInternalEvent.Create(FALSE); @@ -178,6 +273,19 @@ OniStatus PlayerDevice::Initialize() return ONI_STATUS_ERROR; } + status = ResolveGlobalConfigFileName(m_iniFilePath, sizeof(m_iniFilePath), NULL); + if (XN_STATUS_OK != status) + { + return ONI_STATUS_ERROR; + } + + XnBool bIsExist = FALSE; + xnOSDoesFileExist(m_iniFilePath, &bIsExist); + + if (bIsExist) + { + LoadConfigurationFromIniFile(); + } return ONI_STATUS_OK; } @@ -201,7 +309,7 @@ void PlayerDevice::close() m_player.Destroy(); // Delete all the sources and streams. - Lock(); + xnl::AutoCSLocker lock(m_cs); while (m_streams.Begin() != m_streams.End()) { PlayerStream* pStream = *m_streams.Begin(); @@ -213,12 +321,11 @@ void PlayerDevice::close() m_sources.Remove(pSource); XN_DELETE(pSource); } - Unlock(); } OniStatus PlayerDevice::getSensorInfoList(OniSensorInfo** pSources, int* numSources) { - Lock(); + xnl::AutoCSLocker lock(m_cs); // Update source count. *numSources = (int)m_sources.Size(); @@ -231,25 +338,25 @@ OniStatus PlayerDevice::getSensorInfoList(OniSensorInfo** pSources, int* numSour xnOSMemCopy(&(*pSources)[i], (*iter)->GetInfo(), sizeof(OniSensorInfo)); } - Unlock(); - return ONI_STATUS_OK; } driver::StreamBase* PlayerDevice::createStream(OniSensorType sensorType) { // Find the requested source. - Lock(); PlayerSource* pSource = NULL; - for (SourceList::Iterator iter = m_sources.Begin(); iter != m_sources.End(); ++iter) + { - if ((*iter)->GetInfo()->sensorType == sensorType) + xnl::AutoCSLocker lock(m_cs); + for (SourceList::Iterator iter = m_sources.Begin(); iter != m_sources.End(); ++iter) { - pSource = (*iter); - break; + if ((*iter)->GetInfo()->sensorType == sensorType) + { + pSource = (*iter); + break; + } } } - Unlock(); // Check if source was found. if (pSource == NULL) @@ -258,7 +365,7 @@ driver::StreamBase* PlayerDevice::createStream(OniSensorType sensorType) } // Create a new stream using the source. - PlayerStream* pStream = XN_NEW(PlayerStream, pSource); + PlayerStream* pStream = XN_NEW(PlayerStream, this, pSource); if (pStream == NULL) { return NULL; @@ -272,12 +379,10 @@ driver::StreamBase* PlayerDevice::createStream(OniSensorType sensorType) return NULL; } - Lock(); - + xnl::AutoCSLocker lock(m_cs); XnStatus xnrc = m_streams.AddLast(pStream); if (xnrc != XN_STATUS_OK) { - Unlock(); XN_DELETE(pStream); return NULL; } @@ -289,7 +394,6 @@ driver::StreamBase* PlayerDevice::createStream(OniSensorType sensorType) if (rc != ONI_STATUS_OK) { m_streams.Remove(pStream); - Unlock(); XN_DELETE(pStream); return NULL; } @@ -300,18 +404,16 @@ driver::StreamBase* PlayerDevice::createStream(OniSensorType sensorType) if (rc != ONI_STATUS_OK) { m_streams.Remove(pStream); - Unlock(); XN_DELETE(pStream); return NULL; } - Unlock(); - return pStream; } void PlayerDevice::destroyStream(oni::driver::StreamBase* pStream) { + xnl::AutoCSLocker lock(m_cs); m_streams.Remove((PlayerStream*)pStream); XN_DELETE(pStream); } @@ -359,9 +461,8 @@ OniStatus PlayerDevice::getProperty(int propertyId, void* data, int* pDataSize) else { // Get the property. - Lock(); + xnl::AutoCSLocker lock(m_cs); rc = m_properties.GetProperty(propertyId, data, pDataSize); - Unlock(); } return rc; @@ -402,9 +503,8 @@ OniStatus PlayerDevice::setProperty(int propertyId, const void* data, int dataSi else { // Set the property. - Lock(); + xnl::AutoCSLocker lock(m_cs); rc = m_properties.SetProperty(propertyId, data, dataSize); - Unlock(); } return rc; @@ -461,7 +561,7 @@ OniBool PlayerDevice::isCommandSupported(int commandId) PlayerSource* PlayerDevice::FindSource(const XnChar* strNodeName) { - Lock(); + xnl::AutoCSLocker lock(m_cs); // Find the relevant source. for (SourceList::Iterator iter = m_sources.Begin(); iter != m_sources.End(); ++iter) @@ -469,13 +569,10 @@ PlayerSource* PlayerDevice::FindSource(const XnChar* strNodeName) if (strcmp((*iter)->GetNodeName(), strNodeName) == 0) { PlayerSource* pSource = *iter; - Unlock(); return pSource; } } - Unlock(); - return NULL; } @@ -484,20 +581,19 @@ void PlayerDevice::SleepToTimestamp(XnUInt64 nTimeStamp) XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); - m_cs.Lock(); - XnBool bHasTimeReference = TRUE; - if (!m_bHasTimeReference /*&& (nTimeStamp <= m_nStartTimestamp)*/) { - m_nStartTimestamp = nTimeStamp; - m_nStartTime = nNow; + xnl::AutoCSLocker lock(m_cs); + if (!m_bHasTimeReference /*&& (nTimeStamp <= m_nStartTimestamp)*/) + { + m_nStartTimestamp = nTimeStamp; + m_nStartTime = nNow; - m_bHasTimeReference = TRUE; - bHasTimeReference = FALSE; + m_bHasTimeReference = TRUE; + bHasTimeReference = FALSE; + } } - m_cs.Unlock(); - if (bHasTimeReference && (m_dPlaybackSpeed > 0.0f)) { // check this data timestamp compared to when we started @@ -604,9 +700,8 @@ void ONI_CALLBACK_TYPE PlayerDevice::ReadyForDataCallback(const PlayerStream::Re void ONI_CALLBACK_TYPE PlayerDevice::StreamDestroyCallback(const PlayerStream::DestroyEventArgs& destroyEventArgs, void* pCookie) { PlayerDevice* pThis = (PlayerDevice*)(pCookie); - pThis->Lock(); + xnl::AutoCSLocker lock(pThis->m_cs); pThis->m_streams.Remove(destroyEventArgs.pStream); - pThis->Unlock(); } XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeAdded(void* pCookie, const XnChar* strNodeName, XnProductionNodeType type, XnCodecID /*compression*/, XnUInt32 nNumberOfFrames) @@ -641,9 +736,8 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeAdded(void* pCookie, const XnChar* pSource->SetProperty(ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES, &nNumberOfFrames, sizeof(int)); // Add the source. - pThis->Lock(); + xnl::AutoCSLocker lock(pThis->m_cs); pThis->m_sources.AddLast(pSource); - pThis->Unlock(); } break; @@ -663,21 +757,7 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeAdded(void* pCookie, const XnChar* XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeRemoved(void* /*pCookie*/, const XnChar* /*strNodeName*/) { - /*PlayerDevice* pThis = (PlayerDevice*)pCookie; - - // Remove the source. - pThis->Lock(); - PlayerSource* pSource = pThis->FindSource(strNodeName); - if (pSource != NULL) - { - pThis->m_sources.Remove(pSource); - XN_DELETE(pSource); - } - pThis->Unlock(); - - return (pSource != NULL) ? XN_STATUS_OK : XN_STATUS_NO_MATCH;*/ - - // Do not remove the node. + // Do not remove the node (sensors can't disappear) return XN_STATUS_OK; } @@ -688,7 +768,6 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeIntPropChanged(void* pCookie, cons OniStatus rc; // Find the source. - pThis->Lock(); PlayerSource* pSource = pThis->FindSource(strNodeName); if (pSource != NULL) { @@ -785,7 +864,6 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeIntPropChanged(void* pCookie, cons nRetVal = pThis->AddPrivateProperty(pSource, strPropName, sizeof(nValue), &nValue); } } - pThis->Unlock(); return nRetVal; } @@ -796,13 +874,11 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeRealPropChanged(void* pCookie, con XnStatus nRetVal = XN_STATUS_OK; // Find the source. - pThis->Lock(); PlayerSource* pSource = pThis->FindSource(strNodeName); if (pSource != NULL) { nRetVal = pThis->AddPrivateProperty(pSource, strPropName, sizeof(dValue), &dValue); } - pThis->Unlock(); return nRetVal; } @@ -813,13 +889,11 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeStringPropChanged(void* pCookie, c XnStatus nRetVal = XN_STATUS_OK; // Find the source. - pThis->Lock(); PlayerSource* pSource = pThis->FindSource(strNodeName); if (pSource != NULL) { nRetVal = pThis->AddPrivateProperty(pSource, strPropName, (XnUInt32)strlen(strValue)+1, strValue); } - pThis->Unlock(); return nRetVal; } @@ -831,7 +905,6 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeGeneralPropChanged(void* pCookie, OniStatus rc; // Find the source. - pThis->Lock(); PlayerSource* pSource = pThis->FindSource(strNodeName); if (pSource != NULL) { @@ -943,12 +1016,15 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeGeneralPropChanged(void* pCookie, } } } + else if (strcmp(strPropName, XN_PROP_ORIGINAL_DEVICE) == 0) + { + xnOSStrCopy(pThis->m_originalDevice, (char*)pBuffer, sizeof(pThis->m_originalDevice)); + } else { nRetVal = pThis->AddPrivateProperty(pSource, strPropName, nBufferSize, pBuffer); } } - pThis->Unlock(); return nRetVal; } @@ -980,19 +1056,20 @@ XnStatus XN_CALLBACK_TYPE PlayerDevice::OnNodeNewData(void* pCookie, const XnCha { // Check if any stream is ready to receive the frames. // NOTE: all the streams have a local 'last frame' buffer, so worst case other streams on source will buffer the frame. - pThis->Lock(); - hasStreams = FALSE; - for (StreamList::Iterator iter = pThis->m_streams.Begin(); iter != pThis->m_streams.End(); iter++) { - PlayerStream* pStream = *iter; - if (pStream->GetSource() == pSource) + xnl::AutoCSLocker lock(pThis->m_cs); + hasStreams = FALSE; + for (StreamList::Iterator iter = pThis->m_streams.Begin(); iter != pThis->m_streams.End(); iter++) { - hasStreams = TRUE; - ready = TRUE; - break; + PlayerStream* pStream = *iter; + if (pStream->GetSource() == pSource) + { + hasStreams = TRUE; + ready = TRUE; + break; + } } } - pThis->Unlock(); // If no ready device found, wait for ready for data event. if (hasStreams) @@ -1037,9 +1114,10 @@ void XN_CALLBACK_TYPE PlayerDevice::OnEndOfFileReached(void* pCookie) { // Reset time reference for all streams. PlayerDevice* pThis = (PlayerDevice*)pCookie; - pThis->Lock(); - pThis->m_bHasTimeReference = FALSE; - pThis->Unlock(); + { + xnl::AutoCSLocker lock(pThis->m_cs); + pThis->m_bHasTimeReference = FALSE; + } // Notify the driver in case the player has finished playing (no-rewind) if (pThis->isPlayerEOF()) @@ -1049,6 +1127,36 @@ void XN_CALLBACK_TYPE PlayerDevice::OnEndOfFileReached(void* pCookie) } XnStatus PlayerDevice::AddPrivateProperty(PlayerSource* pSource, const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer) +{ + if (xnOSStrCmp(m_originalDevice, "PSLink") == 0) + { + return AddPrivateProperty_PSLink(pSource, strPropName, nBufferSize, pBuffer); + } + return AddPrivateProperty_PS1080(pSource, strPropName, nBufferSize, pBuffer); +} + +XnStatus PlayerDevice::AddPrivateProperty_PSLink(PlayerSource* pSource, const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer) +{ + XnStatus nRetVal = XN_STATUS_OK; + + // Find the property name in the PSLink properties. + int numProperties = ARRAYSIZE(PSLinkPropertyList); + for (int i = 0; i < numProperties; ++i) + { + if (strcmp(strPropName, PSLinkPropertyList[i].propertyName) == 0) + { + OniStatus rc = pSource->SetProperty(PSLinkPropertyList[i].propertyId, pBuffer, nBufferSize); + if (rc != ONI_STATUS_OK) + { + nRetVal = XN_STATUS_ERROR; + } + break; + } + } + + return nRetVal; +} +XnStatus PlayerDevice::AddPrivateProperty_PS1080(PlayerSource* pSource, const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer) { XnStatus nRetVal = XN_STATUS_OK; diff --git a/Source/Drivers/OniFile/PlayerDevice.h b/Source/Drivers/OniFile/PlayerDevice.h index 2bcba8ed..d6195498 100644 --- a/Source/Drivers/OniFile/PlayerDevice.h +++ b/Source/Drivers/OniFile/PlayerDevice.h @@ -22,8 +22,8 @@ /// Contains the declaration of Device class that implements a virtual OpenNI /// device, capable of reading data from a *.ONI file. -#ifndef __PLAYER_DEVICE_H__ -#define __PLAYER_DEVICE_H__ +#ifndef PLAYERDEVICE_H +#define PLAYERDEVICE_H #include "Driver/OniDriverAPI.h" #include "XnString.h" @@ -82,16 +82,15 @@ class PlayerDevice : public oni::driver::DeviceBase }; void TriggerDriverEOFCallback() { if(m_driverEOFCallback) (m_driverEOFCallback)(m_driverCookie, m_filePath.Data()); }; + const char* getOriginalDevice() {return m_originalDevice;} protected: - - void Lock() { m_cs.Lock(); } - void Unlock() { m_cs.Unlock(); } - PlayerSource* FindSource(const XnChar* strNodeName); // Wake up when timestamp is valid. void SleepToTimestamp(XnUInt64 nTimeStamp); + void LoadConfigurationFromIniFile(); + private: void close(); @@ -102,6 +101,7 @@ class PlayerDevice : public oni::driver::DeviceBase } Seek; void MainLoop(); + static XN_THREAD_PROC ThreadProc(XN_THREAD_PARAM pThreadParam); static void ONI_CALLBACK_TYPE ReadyForDataCallback(const PlayerStream::ReadyForDataEventArgs& newDataEventArgs, void* pCookie); @@ -117,6 +117,8 @@ class PlayerDevice : public oni::driver::DeviceBase static XnStatus XN_CALLBACK_TYPE OnNodeNewData(void* pCookie, const XnChar* strNodeName, XnUInt64 nTimeStamp, XnUInt32 nFrame, const void* pData, XnUInt32 nSize); static void XN_CALLBACK_TYPE OnEndOfFileReached(void* pCookie); XnStatus AddPrivateProperty(PlayerSource* pSource, const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer); + XnStatus AddPrivateProperty_PS1080(PlayerSource* pSource, const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer); + XnStatus AddPrivateProperty_PSLink(PlayerSource* pSource, const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer); static XnStatus XN_CALLBACK_TYPE FileOpen(void* pCookie); static XnStatus XN_CALLBACK_TYPE FileRead(void* pCookie, void* pBuffer, XnUInt32 nSize, XnUInt32* pnBytesRead); @@ -128,6 +130,8 @@ class PlayerDevice : public oni::driver::DeviceBase static XnStatus XN_CALLBACK_TYPE CodecCreate(void* pCookie, const char* strNodeName, XnCodecID nCodecId, XnCodec** ppCodec); static void XN_CALLBACK_TYPE CodecDestroy(void* pCookie, XnCodec* pCodec); + + static XnStatus ResolveGlobalConfigFileName(XnChar* strConfigFile, XnUInt32 nBufSize, const XnChar* strConfigDir); // Name of the node (used for identifying the device in the callbacks). xnl::String m_nodeName; @@ -188,8 +192,13 @@ class PlayerDevice : public oni::driver::DeviceBase // Critical section. xnl::CriticalSection m_cs; + + char m_originalDevice[ONI_MAX_STR]; + + char m_iniFilePath[XN_FILE_MAX_PATH]; + }; } // namespace oni_files_player -#endif //__PLAYER_DEVICE_H__ +#endif // PLAYERDEVICE_H diff --git a/Source/Drivers/OniFile/PlayerDriver.h b/Source/Drivers/OniFile/PlayerDriver.h index 0be4f3c6..d9a989d7 100644 --- a/Source/Drivers/OniFile/PlayerDriver.h +++ b/Source/Drivers/OniFile/PlayerDriver.h @@ -22,6 +22,8 @@ /// Contains the declaration of Driver class that implements an OpenNI driver, /// which manages virtual OpenNI devices. Those devices read their data from /// *.ONI files. +#ifndef PLAYERDRIVER_H +#define PLAYERDRIVER_H #ifndef _ONIFILESPLAYER_DRIVER_H_ #define _ONIFILESPLAYER_DRIVER_H_ 1 @@ -74,3 +76,5 @@ class PlayerDriver : public oni::driver::DriverBase } // namespace oni_files_player #endif // _ONIFILESPLAYER_DRIVER_H_ + +#endif // PLAYERDRIVER_H diff --git a/Source/Drivers/OniFile/PlayerNode.h b/Source/Drivers/OniFile/PlayerNode.h index 3c215a3c..f4670155 100644 --- a/Source/Drivers/OniFile/PlayerNode.h +++ b/Source/Drivers/OniFile/PlayerNode.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __PLAYER_H__ -#define __PLAYER_H__ +#ifndef PLAYERNODE_H +#define PLAYERNODE_H #include "DataRecords.h" #include "XnPlayerTypes.h" @@ -192,4 +192,4 @@ class PlayerNode } -#endif //__PLAYER_H__ +#endif // PLAYERNODE_H diff --git a/Source/Drivers/OniFile/PlayerProperties.h b/Source/Drivers/OniFile/PlayerProperties.h index 64ce6b96..6bad74b0 100644 --- a/Source/Drivers/OniFile/PlayerProperties.h +++ b/Source/Drivers/OniFile/PlayerProperties.h @@ -18,10 +18,11 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __PLAYER_PROPERTIES_H__ -#define __PLAYER_PROPERTIES_H__ +#ifndef PLAYERPROPERTIES_H +#define PLAYERPROPERTIES_H -#include "XnHash.h" +#include +#include #include "Driver/OniDriverTypes.h" namespace oni_file { @@ -43,6 +44,7 @@ class PlayerProperties OniBool Exists(int propertyId) { + xnl::AutoCSLocker lock(m_cs); if (m_properties.Find(propertyId) != m_properties.End()) { return TRUE; @@ -52,6 +54,8 @@ class PlayerProperties OniStatus GetProperty(int propertyId, void* data, int* pDataSize) const { + xnl::AutoCSLocker lock(m_cs); + // Get the property and make sure it exists. PropertiesHash::ConstIterator iter = m_properties.Find(propertyId); if (iter == m_properties.End()) @@ -69,6 +73,8 @@ class PlayerProperties OniStatus SetProperty(int propertyId, const void* data, int dataSize) { + xnl::AutoCSLocker lock(m_cs); + // Check if property exists. PropertiesHash::Iterator iter = m_properties.Find(propertyId); if (iter != m_properties.End()) @@ -84,6 +90,9 @@ class PlayerProperties return ONI_STATUS_OK; } + typedef xnl::Hash PropertiesHash; + PropertiesHash::ConstIterator Begin() const {return m_properties.Begin();} + PropertiesHash::ConstIterator End() const {return m_properties.End();} private: OniGeneralBuffer* CreateBuffer(const void* data, int dataSize) @@ -113,10 +122,10 @@ class PlayerProperties XN_DELETE(pBuffer); } - typedef xnl::Hash PropertiesHash; + xnl::CriticalSection m_cs; PropertiesHash m_properties; }; } // namespace oni_files_player -#endif //__PLAYER_PROPERTIES_H__ +#endif // PLAYERPROPERTIES_H diff --git a/Source/Drivers/OniFile/PlayerSource.cpp b/Source/Drivers/OniFile/PlayerSource.cpp index 747cc7af..0b530467 100644 --- a/Source/Drivers/OniFile/PlayerSource.cpp +++ b/Source/Drivers/OniFile/PlayerSource.cpp @@ -44,6 +44,7 @@ PlayerSource::~PlayerSource() /// Return the source info associated with the source. OniSensorInfo* PlayerSource::GetInfo() { + xnl::AutoCSLocker lock(m_cs); return &m_sourceInfo; } @@ -55,12 +56,14 @@ const XnChar* PlayerSource::GetNodeName() /// Get property. OniStatus PlayerSource::GetProperty(int propertyId, void* data, int* pDataSize) { + xnl::AutoCSLocker lock(m_cs); return m_properties.GetProperty(propertyId, data, pDataSize); } /// Set property. OniStatus PlayerSource::SetProperty(int propertyId, const void* data, int dataSize) { + xnl::AutoCSLocker lock(m_cs); if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) { if(m_sourceInfo.numSupportedVideoModes == 0) diff --git a/Source/Drivers/OniFile/PlayerSource.h b/Source/Drivers/OniFile/PlayerSource.h index 631a079c..284b2ad6 100644 --- a/Source/Drivers/OniFile/PlayerSource.h +++ b/Source/Drivers/OniFile/PlayerSource.h @@ -22,8 +22,8 @@ /// Contains the declaration of Device class that implements a virtual OpenNI /// device, capable of reading data from a *.ONI file. -#ifndef __PLAYER_SOURCE_H__ -#define __PLAYER_SOURCE_H__ +#ifndef PLAYERSOURCE_H +#define PLAYERSOURCE_H #include "PlayerProperties.h" #include "OniCProperties.h" @@ -86,6 +86,8 @@ class PlayerSource void SetRequiredFrameSize(int requiredFrameSize) { m_requiredFrameSize = requiredFrameSize; } int GetRequiredFrameSize() const { return m_requiredFrameSize; } + PlayerProperties::PropertiesHash::ConstIterator Begin() {return m_properties.Begin();} + PlayerProperties::PropertiesHash::ConstIterator End() {return m_properties.End();} protected: XN_DISABLE_COPY_AND_ASSIGN(PlayerSource); @@ -102,8 +104,10 @@ class PlayerSource NewDataEvent m_newDataEvent; int m_requiredFrameSize; + + xnl::CriticalSection m_cs; }; } // namespace oni_files_player -#endif //__PLAYER_DEVICE_H__ +#endif // PLAYERSOURCE_H diff --git a/Source/Drivers/OniFile/PlayerStream.cpp b/Source/Drivers/OniFile/PlayerStream.cpp index 9803f556..aed55426 100644 --- a/Source/Drivers/OniFile/PlayerStream.cpp +++ b/Source/Drivers/OniFile/PlayerStream.cpp @@ -24,6 +24,8 @@ #include "PlayerStream.h" #include "PlayerSource.h" +#include "PlayerDevice.h" +#include "FileProperties.h" #include "XnMemory.h" #include "OniProperties.h" #include "XnPlatform.h" @@ -31,8 +33,8 @@ namespace oni_file { -PlayerStream::PlayerStream(PlayerSource* pSource) : - m_pSource(pSource), m_newDataHandle(NULL), m_isStarted(false), m_requiredFrameSize(0) +PlayerStream::PlayerStream(PlayerDevice* pDevice, PlayerSource* pSource) : + m_pSource(pSource), m_newDataHandle(NULL), m_isStarted(false), m_requiredFrameSize(0), m_pDevice(pDevice) { } @@ -75,13 +77,16 @@ void PlayerStream::destroy() OniStatus PlayerStream::start() { + xnl::AutoCSLocker lock(m_cs); m_isStarted = true; m_requiredFrameSize = getRequiredFrameSize(); + return ONI_STATUS_OK; } void PlayerStream::stop() { + xnl::AutoCSLocker lock(m_cs); m_isStarted = false; } @@ -93,20 +98,48 @@ PlayerSource* PlayerStream::GetSource() OniStatus PlayerStream::getProperty(int propertyId, void* pData, int* pDataSize) { // Check if the property exists. - m_cs.Lock(); + xnl::AutoCSLocker lock(m_cs); OniStatus rc = m_properties.GetProperty(propertyId, pData, pDataSize); if (rc != ONI_STATUS_OK) { rc = m_pSource->GetProperty(propertyId, pData, pDataSize); } - m_cs.Unlock(); return rc; } -OniStatus PlayerStream::setProperty(int /*propertyId*/, const void* /*pData*/, int /*dataSize*/) +OniStatus PlayerStream::setProperty(int propertyId, const void* pData, int dataSize) { - return ONI_STATUS_ERROR; + OniStatus nRetVal = ONI_STATUS_OK; + + if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) + { + if (dataSize != sizeof(OniVideoMode)) + { + return ONI_STATUS_BAD_PARAMETER; + } + + OniVideoMode currMode; + int size = sizeof(currMode); + nRetVal = getProperty(ONI_STREAM_PROPERTY_VIDEO_MODE, &currMode, &size); + XN_ASSERT(nRetVal == ONI_STATUS_OK); + XN_REFERENCE_VARIABLE(nRetVal); + + OniVideoMode* pRequestedMode = (OniVideoMode*)pData; + if (pRequestedMode->resolutionX == currMode.resolutionX && + pRequestedMode->resolutionY == currMode.resolutionY && + pRequestedMode->fps == currMode.fps && + pRequestedMode->pixelFormat == currMode.pixelFormat) + { + return ONI_STATUS_OK; + } + + return ONI_STATUS_BAD_PARAMETER; + } + else + { + return ONI_STATUS_ERROR; + } } OniStatus PlayerStream::RegisterReadyForDataEvent(ReadyForDataCallback callback, void* pCookie, OniCallbackHandle& handle) @@ -142,6 +175,7 @@ void PlayerStream::UnregisterDestroyEvent(OniCallbackHandle handle) void ONI_CALLBACK_TYPE PlayerStream::OnNewDataCallback(const PlayerSource::NewDataEventArgs& newDataEventArgs, void* pCookie) { PlayerStream* pStream = (PlayerStream*)pCookie; + xnl::AutoCSLocker lock(pStream->m_cs); // Don't process new frames until the stream is started. if(!pStream->m_isStarted) @@ -171,17 +205,13 @@ void ONI_CALLBACK_TYPE PlayerStream::OnNewDataCallback(const PlayerSource::NewDa // Set the cropping property. OniCropping cropping; - cropping.enabled = FALSE; int dataSize = sizeof(cropping); rc = pStream->m_pSource->GetProperty(ONI_STREAM_PROPERTY_CROPPING, &cropping, &dataSize); if (rc != ONI_STATUS_OK) { - XN_ASSERT(FALSE); - return; + cropping.enabled = FALSE; } - pStream->m_cs.Lock(); - // Allocate new frame and fill it. OniFrame* pFrame = pStream->getServices().acquireFrame(); if (pFrame == NULL) @@ -227,8 +257,6 @@ void ONI_CALLBACK_TYPE PlayerStream::OnNewDataCallback(const PlayerSource::NewDa } memcpy(pFrame->data, newDataEventArgs.pData, pFrame->dataSize); - pStream->m_cs.Unlock(); - // Process the new frame. pStream->raiseNewFrame(pFrame); pStream->getServices().releaseFrame(pFrame); @@ -236,6 +264,7 @@ void ONI_CALLBACK_TYPE PlayerStream::OnNewDataCallback(const PlayerSource::NewDa int PlayerStream::getRequiredFrameSize() { + xnl::AutoCSLocker lock(m_cs); int requiredFrameSize = m_pSource->GetRequiredFrameSize(); if (requiredFrameSize == 0) { @@ -246,4 +275,22 @@ int PlayerStream::getRequiredFrameSize() return requiredFrameSize; } +void PlayerStream::notifyAllProperties() +{ + xnl::AutoCSLocker lock(m_cs); + raisePropertyChanged(ONI_FILE_PROPERTY_ORIGINAL_DEVICE, m_pDevice->getOriginalDevice(), ONI_MAX_STR); + + for (PlayerProperties::PropertiesHash::ConstIterator property = m_properties.Begin(); + property != m_properties.End(); ++property) + { + raisePropertyChanged(property->Key(), property->Value()->data, property->Value()->dataSize); + } + + for (PlayerProperties::PropertiesHash::ConstIterator property = m_pSource->Begin(); + property != m_pSource->End(); ++property) + { + raisePropertyChanged(property->Key(), property->Value()->data, property->Value()->dataSize); + } +} + } // namespace oni_files_player diff --git a/Source/Drivers/OniFile/PlayerStream.h b/Source/Drivers/OniFile/PlayerStream.h index e8e36c95..0c79410f 100644 --- a/Source/Drivers/OniFile/PlayerStream.h +++ b/Source/Drivers/OniFile/PlayerStream.h @@ -22,8 +22,8 @@ /// Contains the declaration of Stream class that implements a stream from /// a virtual OpenNI device. -#ifndef __PLAYER_STREAM_H__ -#define __PLAYER_STREAM_H__ +#ifndef PLAYERSTREAM_H +#define PLAYERSTREAM_H #include "Driver/OniDriverAPI.h" #include "PlayerProperties.h" @@ -33,6 +33,7 @@ namespace oni_file { class Decoder; +class PlayerDevice; /// Implements a stream from a virtual OpenNI device. class PlayerStream : public oni::driver::StreamBase @@ -59,7 +60,7 @@ class PlayerStream : public oni::driver::StreamBase public: /// Constructor. - PlayerStream(PlayerSource* pSource); + PlayerStream(PlayerDevice* pDevice, PlayerSource* pSource); /// Destructor. virtual ~PlayerStream(); @@ -99,6 +100,7 @@ class PlayerStream : public oni::driver::StreamBase // Unregister from 'destroy' event. void UnregisterDestroyEvent(OniCallbackHandle handle); + void notifyAllProperties(); private: void destroy(); @@ -133,8 +135,10 @@ class PlayerStream : public oni::driver::StreamBase bool m_isStarted; int m_requiredFrameSize; + + PlayerDevice* m_pDevice; }; } // namespace oni_files_player -#endif //__PLAYER_STREAM_H__ +#endif // PLAYERSTREAM_H diff --git a/Source/Drivers/OniFile/XnPlayerTypes.h b/Source/Drivers/OniFile/XnPlayerTypes.h index 9d822421..fb15b2db 100644 --- a/Source/Drivers/OniFile/XnPlayerTypes.h +++ b/Source/Drivers/OniFile/XnPlayerTypes.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PLAYER_TYPES_H__ -#define __XN_PLAYER_TYPES_H__ +#ifndef XNPLAYERTYPES_H +#define XNPLAYERTYPES_H //--------------------------------------------------------------------------- // Includes @@ -362,4 +362,4 @@ typedef struct XnNodeNotifications } XnNodeNotifications; -#endif //__XN_PLAYER_TYPES_H__ +#endif // XNPLAYERTYPES_H diff --git a/Source/Drivers/OniFile/XnPropNames.h b/Source/Drivers/OniFile/XnPropNames.h index 7019a6dd..e03d85b6 100644 --- a/Source/Drivers/OniFile/XnPropNames.h +++ b/Source/Drivers/OniFile/XnPropNames.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PROP_NAMES_H__ -#define __XN_PROP_NAMES_H__ +#ifndef XNPROPNAMES_H +#define XNPROPNAMES_H //ProductionNode #define XN_PROP_STATE_READY "xnStateReady" // int. Meant only for mock nodes. @@ -62,4 +62,6 @@ #define XN_PROP_ONI_PIXEL_FORMAT "oniPixelFormat" #define XN_PROP_ONI_REQUIRED_FRAME_SIZE "oniRequiredFrameSize" -#endif //__XN_PROP_NAMES_H__ +#define XN_PROP_ORIGINAL_DEVICE "oniOriginalDevice" + +#endif // XNPROPNAMES_H diff --git a/Source/Drivers/PS1080/Android.mk b/Source/Drivers/PS1080/Android.mk index 45250415..68498a69 100644 --- a/Source/Drivers/PS1080/Android.mk +++ b/Source/Drivers/PS1080/Android.mk @@ -17,6 +17,8 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +include $(LOCAL_PATH)/../../../ThirdParty/PSCommon/BuildSystem/CommonAndroid.mk + # Sources MY_SRC_FILES := \ $(LOCAL_PATH)/Core/*.cpp \ @@ -26,16 +28,11 @@ MY_SRC_FILES := \ $(LOCAL_PATH)/Include/*.cpp \ $(LOCAL_PATH)/Sensor/*.cpp -ifdef OPENNI2_ANDROID_NDK_BUILD - MY_SRC_FILES += $(LOCAL_PATH)/../../../ThirdParty/LibJPEG/*.c -endif - MY_SRC_FILE_EXPANDED := $(wildcard $(MY_SRC_FILES)) LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) # C/CPP Flags -LOCAL_CFLAGS += $(OPENNI2_CFLAGS) -LOCAL_CPPFLAGS := -frtti +LOCAL_CPP_FEATURES := rtti # Includes LOCAL_C_INCLUDES := \ @@ -43,19 +40,12 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/Include \ $(LOCAL_PATH)/../../DepthUtils \ $(LOCAL_PATH)/../../../Include \ - $(LOCAL_PATH)/../../../ThirdParty/PSCommon/XnLib/Include - -ifdef OPENNI2_ANDROID_NDK_BUILD - LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../ThirdParty/LibJPEG -else - LOCAL_C_INCLUDES += external/jpeg -endif # Dependencies LOCAL_STATIC_LIBRARIES := XnLib DepthUtils -LOCAL_SHARED_LIBRARIES := liblog libdl libusb libgabi++ +LOCAL_SHARED_LIBRARIES := libusb -ifdef OPENNI2_ANDROID_OS_BUILD +ifdef PS_OS_BUILD LOCAL_SHARED_LIBRARIES += libjpeg else LOCAL_LDLIBS += -llog @@ -65,3 +55,6 @@ endif LOCAL_MODULE:= libPS1080 include $(BUILD_SHARED_LIBRARY) + +#include XnLib +include $(LOCAL_PATH)/../../../ThirdParty/PSCommon/XnLib/Source/Android.mk diff --git a/Source/Drivers/PS1080/Core/XnBuffer.h b/Source/Drivers/PS1080/Core/XnBuffer.h index 29fd630a..f1092ec6 100644 --- a/Source/Drivers/PS1080/Core/XnBuffer.h +++ b/Source/Drivers/PS1080/Core/XnBuffer.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_BUFFER_H__ -#define __XN_BUFFER_H__ +#ifndef XNBUFFER_H +#define XNBUFFER_H //--------------------------------------------------------------------------- // Includes @@ -186,4 +186,4 @@ class XnBuffer XN_IS_STATUS_OK(rc); \ } -#endif //__XN_BUFFER_H__ +#endif // XNBUFFER_H diff --git a/Source/Drivers/PS1080/Core/XnCoreGlobals.h b/Source/Drivers/PS1080/Core/XnCoreGlobals.h index 347ff16f..bc1258f9 100644 --- a/Source/Drivers/PS1080/Core/XnCoreGlobals.h +++ b/Source/Drivers/PS1080/Core/XnCoreGlobals.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_COREGLOBALS_H_ -#define _XN_COREGLOBALS_H_ +#ifndef XNCOREGLOBALS_H +#define XNCOREGLOBALS_H //--------------------------------------------------------------------------- // Includes @@ -55,4 +55,4 @@ extern XnBool g_bXnCoreWasInit; return (XN_STATUS_ALREADY_INIT); \ } -#endif //_XN_COREGLOBALS_H_ \ No newline at end of file +#endif // XNCOREGLOBALS_H diff --git a/Source/Drivers/PS1080/DDK/XnActualGeneralProperty.h b/Source/Drivers/PS1080/DDK/XnActualGeneralProperty.h index f3412991..97fe93cb 100644 --- a/Source/Drivers/PS1080/DDK/XnActualGeneralProperty.h +++ b/Source/Drivers/PS1080/DDK/XnActualGeneralProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ACTUAL_GENERAL_PROPERTY_H__ -#define __XN_ACTUAL_GENERAL_PROPERTY_H__ +#ifndef XNACTUALGENERALPROPERTY_H +#define XNACTUALGENERALPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -78,4 +78,4 @@ class XnActualGeneralProperty : public XnGeneralProperty XnBool m_bOwner; }; -#endif //__XN_ACTUAL_GENERAL_PROPERTY_H__ +#endif // XNACTUALGENERALPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnActualIntProperty.h b/Source/Drivers/PS1080/DDK/XnActualIntProperty.h index e8431046..b661db42 100644 --- a/Source/Drivers/PS1080/DDK/XnActualIntProperty.h +++ b/Source/Drivers/PS1080/DDK/XnActualIntProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ACTUAL_INT_PROPERTY_H__ -#define __XN_ACTUAL_INT_PROPERTY_H__ +#ifndef XNACTUALINTPROPERTY_H +#define XNACTUALINTPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -65,4 +65,4 @@ class XnActualIntProperty : public XnIntProperty XnUInt64 m_nValue; }; -#endif //__XN_ACTUAL_INT_PROPERTY_H__ +#endif // XNACTUALINTPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnActualPropertiesHash.h b/Source/Drivers/PS1080/DDK/XnActualPropertiesHash.h index 100f7129..26fde212 100644 --- a/Source/Drivers/PS1080/DDK/XnActualPropertiesHash.h +++ b/Source/Drivers/PS1080/DDK/XnActualPropertiesHash.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ACTUAL_PROPERTIES_HASH_H__ -#define __XN_ACTUAL_PROPERTIES_HASH_H__ +#ifndef XNACTUALPROPERTIESHASH_H +#define XNACTUALPROPERTIESHASH_H #include "XnProperty.h" #include "XnActualIntProperty.h" @@ -66,4 +66,4 @@ class XnActualPropertiesHash XnChar m_strName[XN_DEVICE_MAX_STRING_LENGTH]; }; -#endif //__XN_ACTUAL_PROPERTIES_HASH_H__ +#endif // XNACTUALPROPERTIESHASH_H diff --git a/Source/Drivers/PS1080/DDK/XnActualRealProperty.h b/Source/Drivers/PS1080/DDK/XnActualRealProperty.h index 3413d7dd..2795716f 100644 --- a/Source/Drivers/PS1080/DDK/XnActualRealProperty.h +++ b/Source/Drivers/PS1080/DDK/XnActualRealProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ACTUAL_REAL_PROPERTY_H__ -#define __XN_ACTUAL_REAL_PROPERTY_H__ +#ifndef XNACTUALREALPROPERTY_H +#define XNACTUALREALPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -65,4 +65,4 @@ class XnActualRealProperty : public XnRealProperty XnDouble m_dValue; }; -#endif //__XN_ACTUAL_REAL_PROPERTY_H__ +#endif // XNACTUALREALPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnActualStringProperty.h b/Source/Drivers/PS1080/DDK/XnActualStringProperty.h index 6131ff11..34cc8f61 100644 --- a/Source/Drivers/PS1080/DDK/XnActualStringProperty.h +++ b/Source/Drivers/PS1080/DDK/XnActualStringProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ACTUAL_STRING_PROPERTY_H__ -#define __XN_ACTUAL_STRING_PROPERTY_H__ +#ifndef XNACTUALSTRINGPROPERTY_H +#define XNACTUALSTRINGPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -65,4 +65,4 @@ class XnActualStringProperty : public XnStringProperty XnChar m_strValue[XN_DEVICE_MAX_STRING_LENGTH]; }; -#endif //__XN_ACTUAL_STRING_PROPERTY_H__ +#endif // XNACTUALSTRINGPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnAudioStream.h b/Source/Drivers/PS1080/DDK/XnAudioStream.h index f9b7ab58..88346f03 100644 --- a/Source/Drivers/PS1080/DDK/XnAudioStream.h +++ b/Source/Drivers/PS1080/DDK/XnAudioStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_AUDIO_STREAM_H__ -#define __XN_AUDIO_STREAM_H__ +#ifndef XNAUDIOSTREAM_H +#define XNAUDIOSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -80,4 +80,4 @@ class XnAudioStream : public XnStreamingStream XnUInt32 m_nMaxNumberOfChannels; }; -#endif //__XN_AUDIO_STREAM_H__ \ No newline at end of file +#endif // XNAUDIOSTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnCodecFactory.cpp b/Source/Drivers/PS1080/DDK/XnCodecFactory.cpp deleted file mode 100644 index 36809d88..00000000 --- a/Source/Drivers/PS1080/DDK/XnCodecFactory.cpp +++ /dev/null @@ -1,113 +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. * -* * -*****************************************************************************/ -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnCodecFactory.h" -#include "XnIntProperty.h" -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------------- -// Code -//--------------------------------------------------------------------------- -XnStatus XnCodecFactory::Create(XnCompressionFormats nFormat, XnDeviceModule* pStream, const XnChar* /*StreamName*/, XnCodec** ppCodec) -{ - XnStatus nRetVal = XN_STATUS_OK; - XnCodec* pCodec = NULL; - - switch (nFormat) - { - case XN_COMPRESSION_NONE: - { - XN_VALIDATE_NEW_AND_INIT(pCodec, XnUncompressedCodec); - } - break; - case XN_COMPRESSION_16Z: - { - XN_VALIDATE_NEW_AND_INIT(pCodec, Xn16zCodec); - } - break; - case XN_COMPRESSION_16Z_EMB_TABLE: - { - // first we need to find max depth - XnUInt64 nMaxDepth; - - nRetVal = pStream->GetProperty(XN_STREAM_PROPERTY_MAX_DEPTH, &nMaxDepth); - XN_IS_STATUS_OK(nRetVal); - - XN_VALIDATE_NEW_AND_INIT(pCodec, Xn16zEmbTablesCodec, (OniDepthPixel)nMaxDepth); - } - break; - case XN_COMPRESSION_COLOR_8Z: - { - XN_VALIDATE_NEW_AND_INIT(pCodec, Xn8zCodec); - } - break; - case XN_COMPRESSION_JPEG: - { - // check what is the output format - XnUInt64 nOutputFormat; - nRetVal = pStream->GetProperty(XN_STREAM_PROPERTY_OUTPUT_FORMAT, &nOutputFormat); - XN_IS_STATUS_OK(nRetVal); - - XnBool bRGB = FALSE; - - switch (nOutputFormat) - { - case ONI_PIXEL_FORMAT_GRAY8: - bRGB = FALSE; - break; - case ONI_PIXEL_FORMAT_RGB888: - bRGB = TRUE; - break; - default: - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Codec factory currently supports JPEG codec only for streams of type Gray8 or RGB24!"); - } - - // take X and Y res - XnUInt64 nXRes, nYRes; - nRetVal = pStream->GetProperty(XN_STREAM_PROPERTY_X_RES, &nXRes); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = pStream->GetProperty(XN_STREAM_PROPERTY_Y_RES, &nYRes); - XN_IS_STATUS_OK(nRetVal); - - XN_VALIDATE_NEW_AND_INIT(pCodec, XnJpegCodec, bRGB, (XnUInt32)nXRes, (XnUInt32)nYRes); - } - break; - default: - XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Codec factory does not support compression type %d", nFormat); - } - - *ppCodec = pCodec; - return (XN_STATUS_OK); -} - -void XnCodecFactory::Destroy(XnCodec* pCodec) -{ - XN_DELETE(pCodec); -} - diff --git a/Source/Drivers/PS1080/DDK/XnDepthStream.h b/Source/Drivers/PS1080/DDK/XnDepthStream.h index 34ff8bf4..8a890c13 100644 --- a/Source/Drivers/PS1080/DDK/XnDepthStream.h +++ b/Source/Drivers/PS1080/DDK/XnDepthStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEPTH_STREAM_H__ -#define __XN_DEPTH_STREAM_H__ +#ifndef XNDEPTHSTREAM_H +#define XNDEPTHSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -116,4 +116,4 @@ class XnDepthStream : public XnPixelStream XnShiftToDepthStreamHelper m_S2DHelper; }; -#endif //__XN_DEPTH_STREAM_H__ \ No newline at end of file +#endif // XNDEPTHSTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnDeviceBase.h b/Source/Drivers/PS1080/DDK/XnDeviceBase.h index e0aed0a0..b285557f 100644 --- a/Source/Drivers/PS1080/DDK/XnDeviceBase.h +++ b/Source/Drivers/PS1080/DDK/XnDeviceBase.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEVICE_BASE_H__ -#define __XN_DEVICE_BASE_H__ +#ifndef XNDEVICEBASE_H +#define XNDEVICEBASE_H //--------------------------------------------------------------------------- // Includes @@ -101,7 +101,7 @@ class XnDeviceBase virtual XnStatus UnregisterFromPropertyChange(const XnChar* Module, XnUInt32 propertyId, XnCallbackHandle hCallback); typedef xnl::Event NewStreamDataEvent; - NewStreamDataEvent::EventInterface& OnNewStreamDataEvent() { return m_OnNewStreamDataEvent; } + NewStreamDataEvent::Interface& OnNewStreamDataEvent() { return m_OnNewStreamDataEvent; } /** * Finds a stream (a module which has the IS_STREAM property set to TRUE). @@ -229,4 +229,4 @@ class XnDeviceBase XN_CRITICAL_SECTION_HANDLE m_hLock; }; -#endif //__XN_DEVICE_BASE_H__ +#endif // XNDEVICEBASE_H diff --git a/Source/Drivers/PS1080/DDK/XnDeviceModule.cpp b/Source/Drivers/PS1080/DDK/XnDeviceModule.cpp index 463225a1..29efb3f5 100644 --- a/Source/Drivers/PS1080/DDK/XnDeviceModule.cpp +++ b/Source/Drivers/PS1080/DDK/XnDeviceModule.cpp @@ -231,7 +231,7 @@ XnStatus XnDeviceModule::GetProperty(XnUInt32 propertyId, void* data, int* pData nRetVal = GetProperty(propertyId, &nValue); if (nRetVal != XN_STATUS_OK) { - XN_ASSERT(FALSE); + // XN_ASSERT(FALSE); // This could happen when the property was write only return XN_STATUS_ERROR; } diff --git a/Source/Drivers/PS1080/DDK/XnDeviceModule.h b/Source/Drivers/PS1080/DDK/XnDeviceModule.h index 4ae67bf7..b58af311 100644 --- a/Source/Drivers/PS1080/DDK/XnDeviceModule.h +++ b/Source/Drivers/PS1080/DDK/XnDeviceModule.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEVICE_MODULE_H__ -#define __XN_DEVICE_MODULE_H__ +#ifndef XNDEVICEMODULE_H +#define XNDEVICEMODULE_H //--------------------------------------------------------------------------- // Includes @@ -114,4 +114,4 @@ class XnDeviceModule } -#endif //__XN_DEVICE_MODULE_H__ +#endif // XNDEVICEMODULE_H diff --git a/Source/Drivers/PS1080/DDK/XnDeviceModuleHolder.h b/Source/Drivers/PS1080/DDK/XnDeviceModuleHolder.h index 2ba877ac..b7302ae4 100644 --- a/Source/Drivers/PS1080/DDK/XnDeviceModuleHolder.h +++ b/Source/Drivers/PS1080/DDK/XnDeviceModuleHolder.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEVICE_MODULE_HOLDER_H__ -#define __XN_DEVICE_MODULE_HOLDER_H__ +#ifndef XNDEVICEMODULEHOLDER_H +#define XNDEVICEMODULEHOLDER_H #include "XnActualPropertiesHash.h" #include "XnDeviceModule.h" @@ -51,4 +51,4 @@ class XnDeviceModuleHolder typedef xnl::List XnDeviceModuleHolderList; -#endif //__XN_DEVICE_MODULE_HOLDER_H__ +#endif // XNDEVICEMODULEHOLDER_H diff --git a/Source/Drivers/PS1080/DDK/XnDeviceStream.h b/Source/Drivers/PS1080/DDK/XnDeviceStream.h index 1ce3a4c4..620bf1b1 100644 --- a/Source/Drivers/PS1080/DDK/XnDeviceStream.h +++ b/Source/Drivers/PS1080/DDK/XnDeviceStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEVICE_STREAM_H__ -#define __XN_DEVICE_STREAM_H__ +#ifndef XNDEVICESTREAM_H +#define XNDEVICESTREAM_H //--------------------------------------------------------------------------- // Includes @@ -139,4 +139,4 @@ class XnDeviceStream : public XnDeviceModule XN_CRITICAL_SECTION_HANDLE m_hOpenLock; }; -#endif //__XN_DEVICE_STREAM_H__ +#endif // XNDEVICESTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnFrameBufferManager.h b/Source/Drivers/PS1080/DDK/XnFrameBufferManager.h index 9e9d5909..b0f45f04 100644 --- a/Source/Drivers/PS1080/DDK/XnFrameBufferManager.h +++ b/Source/Drivers/PS1080/DDK/XnFrameBufferManager.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_MULTI_FRAME_BUFFER_H__ -#define __XN_MULTI_FRAME_BUFFER_H__ +#ifndef XNFRAMEBUFFERMANAGER_H +#define XNFRAMEBUFFERMANAGER_H //--------------------------------------------------------------------------- // Includes @@ -77,4 +77,4 @@ class XnFrameBufferManager XnBuffer m_writeBuffer; }; -#endif //__XN_MULTI_FRAME_BUFFER_H__ \ No newline at end of file +#endif // XNFRAMEBUFFERMANAGER_H diff --git a/Source/Drivers/PS1080/DDK/XnFrameStream.h b/Source/Drivers/PS1080/DDK/XnFrameStream.h index e20d4c48..f6edaa23 100644 --- a/Source/Drivers/PS1080/DDK/XnFrameStream.h +++ b/Source/Drivers/PS1080/DDK/XnFrameStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_FRAME_STREAM_H__ -#define __XN_FRAME_STREAM_H__ +#ifndef XNFRAMESTREAM_H +#define XNFRAMESTREAM_H //--------------------------------------------------------------------------- // Includes @@ -90,4 +90,4 @@ class XnFrameStream : public XnDeviceStream XnActualIntProperty m_FPS; }; -#endif //__XN_FRAME_STREAM_H__ +#endif // XNFRAMESTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnGeneralProperty.h b/Source/Drivers/PS1080/DDK/XnGeneralProperty.h index 8a795078..a0b06f63 100644 --- a/Source/Drivers/PS1080/DDK/XnGeneralProperty.h +++ b/Source/Drivers/PS1080/DDK/XnGeneralProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_GENERAL_PROPERTY_H__ -#define __XN_GENERAL_PROPERTY_H__ +#ifndef XNGENERALPROPERTY_H +#define XNGENERALPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -85,4 +85,4 @@ class XnGeneralProperty : public XnProperty ReadValueFromFileFuncPtr m_pReadFromFileFunc; }; -#endif //__XN_GENERAL_PROPERTY_H__ \ No newline at end of file +#endif // XNGENERALPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnIRStream.cpp b/Source/Drivers/PS1080/DDK/XnIRStream.cpp index 8858fe20..95b59325 100644 --- a/Source/Drivers/PS1080/DDK/XnIRStream.cpp +++ b/Source/Drivers/PS1080/DDK/XnIRStream.cpp @@ -26,7 +26,18 @@ //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- -XnIRStream::XnIRStream(const XnChar* csName, XnBool bAllowCustomResolutions) : - XnPixelStream(XN_STREAM_TYPE_IR, csName, bAllowCustomResolutions) +XnIRStream::XnIRStream(const XnChar* csName, XnBool bAllowCustomResolutions, OniIRPixel nDeviceMaxIR) : + XnPixelStream(XN_STREAM_TYPE_IR, csName, bAllowCustomResolutions), + m_DeviceMaxIR(XN_STREAM_PROPERTY_DEVICE_MAX_IR, "DeviceMaxIR", nDeviceMaxIR) { } + +XnStatus XnIRStream::Init() +{ + XnStatus nRetVal = XnPixelStream::Init(); + XN_IS_STATUS_OK(nRetVal); + + XN_VALIDATE_ADD_PROPERTIES(this, &m_DeviceMaxIR); + + return XN_STATUS_OK; +} diff --git a/Source/Drivers/PS1080/DDK/XnIRStream.h b/Source/Drivers/PS1080/DDK/XnIRStream.h index fe132bba..1327626e 100644 --- a/Source/Drivers/PS1080/DDK/XnIRStream.h +++ b/Source/Drivers/PS1080/DDK/XnIRStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_IR_STREAM_H__ -#define __XN_IR_STREAM_H__ +#ifndef XNIRSTREAM_H +#define XNIRSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -34,7 +34,26 @@ class XnIRStream : public XnPixelStream { public: - XnIRStream(const XnChar* csName, XnBool bAllowCustomResolutions); + XnIRStream(const XnChar* csName, XnBool bAllowCustomResolutions, OniIRPixel nDeviceMaxIR); + + XnStatus Init(); + + //--------------------------------------------------------------------------- + // Getters + //--------------------------------------------------------------------------- + inline OniIRPixel GetDeviceMaxIR() const { return (OniIRPixel)m_DeviceMaxIR.GetValue(); } + +protected: + //--------------------------------------------------------------------------- + // Properties Getters + //--------------------------------------------------------------------------- + inline XnActualIntProperty& DeviceMaxIRProperty() { return m_DeviceMaxIR; } + +private: + //--------------------------------------------------------------------------- + // Members + //--------------------------------------------------------------------------- + XnActualIntProperty m_DeviceMaxIR; }; -#endif //__XN_IR_STREAM_H__ \ No newline at end of file +#endif // XNIRSTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnImageStream.h b/Source/Drivers/PS1080/DDK/XnImageStream.h index bcc524ec..56e21bfe 100644 --- a/Source/Drivers/PS1080/DDK/XnImageStream.h +++ b/Source/Drivers/PS1080/DDK/XnImageStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_IMAGE_STREAM_H__ -#define __XN_IMAGE_STREAM_H__ +#ifndef XNIMAGESTREAM_H +#define XNIMAGESTREAM_H //--------------------------------------------------------------------------- // Includes @@ -37,4 +37,4 @@ class XnImageStream : public XnPixelStream XnImageStream(const XnChar* csName, XnBool bAllowCustomResolutions); }; -#endif //__XN_IMAGE_STREAM_H__ \ No newline at end of file +#endif // XNIMAGESTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnIntProperty.h b/Source/Drivers/PS1080/DDK/XnIntProperty.h index 1986566f..63f20366 100644 --- a/Source/Drivers/PS1080/DDK/XnIntProperty.h +++ b/Source/Drivers/PS1080/DDK/XnIntProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_INT_PROPERTY_H__ -#define __XN_INT_PROPERTY_H__ +#ifndef XNINTPROPERTY_H +#define XNINTPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -82,4 +82,4 @@ class XnIntProperty : public XnProperty virtual XnBool ConvertValueToString(XnChar* csValue, const void* pValue) const; }; -#endif //__XN_INT_PROPERTY_H__ +#endif // XNINTPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnIntPropertySynchronizer.h b/Source/Drivers/PS1080/DDK/XnIntPropertySynchronizer.h index af804567..fb8b979d 100644 --- a/Source/Drivers/PS1080/DDK/XnIntPropertySynchronizer.h +++ b/Source/Drivers/PS1080/DDK/XnIntPropertySynchronizer.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_INT_PROPERTY_SYNCHRONIZER_H__ -#define __XN_INT_PROPERTY_SYNCHRONIZER_H__ +#ifndef XNINTPROPERTYSYNCHRONIZER_H +#define XNINTPROPERTYSYNCHRONIZER_H //--------------------------------------------------------------------------- // Includes @@ -47,4 +47,4 @@ class XnIntPropertySynchronizer CookiesList m_Cookies; }; -#endif //__XN_INT_PROPERTY_SYNCHRONIZER_H__ +#endif // XNINTPROPERTYSYNCHRONIZER_H diff --git a/Source/Drivers/PS1080/DDK/XnPixelStream.h b/Source/Drivers/PS1080/DDK/XnPixelStream.h index 3fa24f30..8b8a9b4d 100644 --- a/Source/Drivers/PS1080/DDK/XnPixelStream.h +++ b/Source/Drivers/PS1080/DDK/XnPixelStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PIXEL_STREAM_H__ -#define __XN_PIXEL_STREAM_H__ +#ifndef XNPIXELSTREAM_H +#define XNPIXELSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -135,4 +135,4 @@ class XnPixelStream : public XnFrameStream XnBool m_bAllowCustomResolutions; }; -#endif //__XN_PIXEL_STREAM_H__ \ No newline at end of file +#endif // XNPIXELSTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnProperty.h b/Source/Drivers/PS1080/DDK/XnProperty.h index 94bc1e74..f98fe966 100644 --- a/Source/Drivers/PS1080/DDK/XnProperty.h +++ b/Source/Drivers/PS1080/DDK/XnProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PROPERTY_H__ -#define __XN_PROPERTY_H__ +#ifndef XNPROPERTY_H +#define XNPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -141,4 +141,4 @@ typedef xnl::List XnPropertiesList; /** A hash table, mapping property name to the property */ typedef xnl::Hash XnPropertiesHash; -#endif //__XN_PROPERTY_H__ +#endif // XNPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnPropertySetInternal.h b/Source/Drivers/PS1080/DDK/XnPropertySetInternal.h index 9ee82c66..d382871d 100644 --- a/Source/Drivers/PS1080/DDK/XnPropertySetInternal.h +++ b/Source/Drivers/PS1080/DDK/XnPropertySetInternal.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PROPERTY_SET_INTERNAL_H__ -#define __XN_PROPERTY_SET_INTERNAL_H__ +#ifndef XNPROPERTYSETINTERNAL_H +#define XNPROPERTYSETINTERNAL_H #include #include "XnActualPropertiesHash.h" @@ -55,4 +55,4 @@ XnStatus XnPropertySetDataAttachModule(XnPropertySetData* pSetData, const XnChar XnStatus XnPropertySetDataDetachModule(XnPropertySetData* pSetData, const XnChar* strModuleName, XnActualPropertiesHash** ppModule); XnStatus XnPropertySetCloneModule(const XnPropertySet* pSource, XnPropertySet* pDest, const XnChar* strModule, const XnChar* strNewName); -#endif //__XN_PROPERTY_SET_INTERNAL_H__ +#endif // XNPROPERTYSETINTERNAL_H diff --git a/Source/Drivers/PS1080/DDK/XnRealProperty.h b/Source/Drivers/PS1080/DDK/XnRealProperty.h index 9b25daa9..c9defa68 100644 --- a/Source/Drivers/PS1080/DDK/XnRealProperty.h +++ b/Source/Drivers/PS1080/DDK/XnRealProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_REAL_PROPERTY_H__ -#define __XN_REAL_PROPERTY_H__ +#ifndef XNREALPROPERTY_H +#define XNREALPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -82,4 +82,4 @@ class XnRealProperty : public XnProperty virtual XnBool ConvertValueToString(XnChar* csValue, const void* pValue) const; }; -#endif //__XN_REAL_PROPERTY_H__ +#endif // XNREALPROPERTY_H diff --git a/Source/Drivers/PS1080/DDK/XnShiftToDepth.h b/Source/Drivers/PS1080/DDK/XnShiftToDepth.h index 68071102..5503ce18 100644 --- a/Source/Drivers/PS1080/DDK/XnShiftToDepth.h +++ b/Source/Drivers/PS1080/DDK/XnShiftToDepth.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_SHIFT_TO_DEPTH_H_ -#define _XN_SHIFT_TO_DEPTH_H_ +#ifndef XNSHIFTTODEPTH_H +#define XNSHIFTTODEPTH_H //--------------------------------------------------------------------------- // Includes @@ -75,4 +75,4 @@ XnStatus XnShiftToDepthUpdate(XnShiftToDepthTables* pShiftToDepth, const XnShift XnStatus XnShiftToDepthConvert(XnShiftToDepthTables* pShiftToDepth, XnUInt16* pInput, XnUInt32 nInputSize, OniDepthPixel* pOutput); XnStatus XnShiftToDepthFree(XnShiftToDepthTables* pShiftToDepth); -#endif //_XN_SHIFT_TO_DEPTH_H_ +#endif // XNSHIFTTODEPTH_H diff --git a/Source/Drivers/PS1080/DDK/XnShiftToDepthStreamHelper.h b/Source/Drivers/PS1080/DDK/XnShiftToDepthStreamHelper.h index fce20af7..df55bb67 100644 --- a/Source/Drivers/PS1080/DDK/XnShiftToDepthStreamHelper.h +++ b/Source/Drivers/PS1080/DDK/XnShiftToDepthStreamHelper.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SHIFT_TO_DEPTH_STREAM_HELPER_H__ -#define __XN_SHIFT_TO_DEPTH_STREAM_HELPER_H__ +#ifndef XNSHIFTTODEPTHSTREAMHELPER_H +#define XNSHIFTTODEPTHSTREAMHELPER_H #include #include @@ -62,4 +62,4 @@ class XnShiftToDepthStreamHelper XnBool m_bPropertiesAdded; }; -#endif //__XN_SHIFT_TO_DEPTH_STREAM_HELPER_H__ +#endif // XNSHIFTTODEPTHSTREAMHELPER_H diff --git a/Source/Drivers/PS1080/DDK/XnStreamingStream.h b/Source/Drivers/PS1080/DDK/XnStreamingStream.h index 789a0a6b..fdff689b 100644 --- a/Source/Drivers/PS1080/DDK/XnStreamingStream.h +++ b/Source/Drivers/PS1080/DDK/XnStreamingStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_STREAMING_STREAM_H__ -#define __XN_STREAMING_STREAM_H__ +#ifndef XNSTREAMINGSTREAM_H +#define XNSTREAMINGSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -68,4 +68,4 @@ class XnStreamingStream : public XnDeviceStream XnActualIntProperty m_ReadChunkSize; }; -#endif //__XN_STREAMING_STREAM_H__ \ No newline at end of file +#endif // XNSTREAMINGSTREAM_H diff --git a/Source/Drivers/PS1080/DDK/XnStringProperty.h b/Source/Drivers/PS1080/DDK/XnStringProperty.h index 50678df1..ced73360 100644 --- a/Source/Drivers/PS1080/DDK/XnStringProperty.h +++ b/Source/Drivers/PS1080/DDK/XnStringProperty.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_STRING_PROPERTY_H__ -#define __XN_STRING_PROPERTY_H__ +#ifndef XNSTRINGPROPERTY_H +#define XNSTRINGPROPERTY_H //--------------------------------------------------------------------------- // Includes @@ -84,4 +84,4 @@ class XnStringProperty : public XnProperty virtual XnBool ConvertValueToString(XnChar* csValue, const void* pValue) const; }; -#endif //__XN_STRING_PROPERTY_H__ \ No newline at end of file +#endif // XNSTRINGPROPERTY_H diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniColorStream.h b/Source/Drivers/PS1080/DriverImpl/XnOniColorStream.h index a91cdaab..5ee35cb5 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniColorStream.h +++ b/Source/Drivers/PS1080/DriverImpl/XnOniColorStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ONI_COLOR_STREAM_H__ -#define __XN_ONI_COLOR_STREAM_H__ +#ifndef XNONICOLORSTREAM_H +#define XNONICOLORSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -42,4 +42,4 @@ class XnOniColorStream : static XnBool IsPreferredInputFormat(XnIOImageFormats inputFormat, XnIOImageFormats thanFormat, OniPixelFormat oniFormat); }; -#endif // __XN_ONI_COLOR_STREAM_H__ +#endif // XNONICOLORSTREAM_H diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniDepthStream.h b/Source/Drivers/PS1080/DriverImpl/XnOniDepthStream.h index 0856961d..08fa84f7 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniDepthStream.h +++ b/Source/Drivers/PS1080/DriverImpl/XnOniDepthStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ONI_DEPTH_STREAM_H__ -#define __XN_ONI_DEPTH_STREAM_H__ +#ifndef XNONIDEPTHSTREAM_H +#define XNONIDEPTHSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -41,4 +41,4 @@ class XnOniDepthStream : virtual OniStatus convertDepthToColorCoordinates(StreamBase* colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY); }; -#endif // __XN_ONI_DEPTH_STREAM_H__ \ No newline at end of file +#endif // XNONIDEPTHSTREAM_H diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniDevice.h b/Source/Drivers/PS1080/DriverImpl/XnOniDevice.h index d2ca94ea..39a648ec 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniDevice.h +++ b/Source/Drivers/PS1080/DriverImpl/XnOniDevice.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ONI_DEVICE_H__ -#define __XN_ONI_DEVICE_H__ +#ifndef XNONIDEVICE_H +#define XNONIDEVICE_H //--------------------------------------------------------------------------- // Includes @@ -85,4 +85,4 @@ class XnOniDevice : XnOniDriver* m_pDriver; }; -#endif // __XN_ONI_DEVICE_H__ +#endif // XNONIDEVICE_H diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniDriver.cpp b/Source/Drivers/PS1080/DriverImpl/XnOniDriver.cpp index 84c5a697..0c1b0935 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniDriver.cpp +++ b/Source/Drivers/PS1080/DriverImpl/XnOniDriver.cpp @@ -233,11 +233,8 @@ void XN_CALLBACK_TYPE XnOniDriver::OnDevicePropertyChanged(const XnChar* ModuleN XnStatus nRetVal = pSensor->GetProperty(ModuleName, XN_MODULE_PROPERTY_ERROR_STATE, &errorState); if (nRetVal == XN_STATUS_OK) { - if (errorState == XN_STATUS_DEVICE_NOT_CONNECTED) - { - pThis->deviceDisconnected(pDevice->GetInfo()); - } - else + // ignore NOT_CONNECTED state. It's already handled by the DeviceEnumeration class + if (errorState != XN_STATUS_DEVICE_NOT_CONNECTED) { int errorStateValue = XN_ERROR_STATE_OK; switch (errorState) diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniDriver.h b/Source/Drivers/PS1080/DriverImpl/XnOniDriver.h index 8283651f..88d952a2 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniDriver.h +++ b/Source/Drivers/PS1080/DriverImpl/XnOniDriver.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ONI_DRIVER_H__ -#define __XN_ONI_DRIVER_H__ +#ifndef XNONIDRIVER_H +#define XNONIDRIVER_H //--------------------------------------------------------------------------- // Includes @@ -81,4 +81,4 @@ class XnOniDriver : XnCallbackHandle m_disconnectedEventHandle; }; -#endif // __XN_ONI_DRIVER_H__ \ No newline at end of file +#endif // XNONIDRIVER_H diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.cpp b/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.cpp index 413b5fb3..1821b35d 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.cpp +++ b/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.cpp @@ -27,9 +27,33 @@ // XnOniIRStream class //--------------------------------------------------------------------------- -XnOniIRStream::XnOniIRStream(XnSensor* pSensor, XnOniDevice* pDevice) : - XnOniMapStream(pSensor, XN_STREAM_TYPE_IR, ONI_SENSOR_IR, pDevice) +XnOniIRStream::XnOniIRStream(XnSensor* pSensor, XnOniDevice* pDevice) : XnOniMapStream(pSensor, XN_STREAM_TYPE_IR, ONI_SENSOR_IR, pDevice) { } +OniStatus XnOniIRStream::getProperty(int propertyId, void* data, int* pDataSize) +{ + switch (propertyId) + { + case ONI_STREAM_PROPERTY_MAX_VALUE: + if (*pDataSize != sizeof(int)) + { + return ONI_STATUS_BAD_PARAMETER; + } + + XnUInt64 nValue; + m_pSensor->GetProperty(m_strType, XN_STREAM_PROPERTY_DEVICE_MAX_IR, &nValue); + + *(int*)data = (int)nValue; + return ONI_STATUS_OK; + default: + return XnOniMapStream::getProperty(propertyId, data, pDataSize); + } +} +OniBool XnOniIRStream::isPropertySupported(int propertyId) +{ + return ( + propertyId == ONI_STREAM_PROPERTY_MAX_VALUE || + XnOniMapStream::isPropertySupported(propertyId)); +} diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.h b/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.h index 52a42b4d..c7363694 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.h +++ b/Source/Drivers/PS1080/DriverImpl/XnOniIRStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ONI_IR_STREAM_H__ -#define __XN_ONI_IR_STREAM_H__ +#ifndef XNONIIRSTREAM_H +#define XNONIIRSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -34,7 +34,9 @@ class XnOniIRStream : public XnOniMapStream { public: - XnOniIRStream(XnSensor* pSensor, XnOniDevice* pDevice); + XnOniIRStream(XnSensor* pSensor, XnOniDevice* pDevice); + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize); + virtual OniBool isPropertySupported(int propertyId); }; -#endif // __XN_ONI_IR_STREAM_H__ \ No newline at end of file +#endif // XNONIIRSTREAM_H diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniMapStream.h b/Source/Drivers/PS1080/DriverImpl/XnOniMapStream.h index 924fbe85..264faff6 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniMapStream.h +++ b/Source/Drivers/PS1080/DriverImpl/XnOniMapStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ONI_MAP_STREAM_H__ -#define __XN_ONI_MAP_STREAM_H__ +#ifndef XNONIMAPSTREAM_H +#define XNONIMAPSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -66,4 +66,4 @@ class XnOniMapStream : XnStatus FillSupportedVideoModes(); }; -#endif // __XN_ONI_MAP_STREAM_H__ +#endif // XNONIMAPSTREAM_H diff --git a/Source/Drivers/PS1080/DriverImpl/XnOniStream.h b/Source/Drivers/PS1080/DriverImpl/XnOniStream.h index 176bee0b..c5d6a048 100644 --- a/Source/Drivers/PS1080/DriverImpl/XnOniStream.h +++ b/Source/Drivers/PS1080/DriverImpl/XnOniStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_ONI_STREAM_H__ -#define __XN_ONI_STREAM_H__ +#ifndef XNONISTREAM_H +#define XNONISTREAM_H //--------------------------------------------------------------------------- // Includes @@ -74,4 +74,4 @@ class XnOniStream : static void XN_CALLBACK_TYPE OnNewStreamDataEventHandler(const XnNewStreamDataEventArgs& args, void* pCookie); }; -#endif // __XN_ONI_STREAM_H__ +#endif // XNONISTREAM_H diff --git a/Source/Drivers/PS1080/Formats/Xn16zEmbTablesCodec.h b/Source/Drivers/PS1080/Formats/Xn16zEmbTablesCodec.h deleted file mode 100644 index 91be2b31..00000000 --- a/Source/Drivers/PS1080/Formats/Xn16zEmbTablesCodec.h +++ /dev/null @@ -1,58 +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 __XN_16Z_EMB_TABLES_CODEC_H__ -#define __XN_16Z_EMB_TABLES_CODEC_H__ - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnCodecBase.h" -#include - -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -class Xn16zEmbTablesCodec : public XnCodecBase -{ -public: - Xn16zEmbTablesCodec(XnUInt16 nMaxValue) : m_nMaxValue(nMaxValue) {} - - virtual XnCompressionFormats GetCompressionFormat() const { return XN_COMPRESSION_16Z_EMB_TABLE; } - - virtual XnFloat GetWorseCompressionRatio() const { return XN_STREAM_COMPRESSION_DEPTH16Z_WORSE_RATIO; } - virtual XnUInt32 GetOverheadSize() const { return m_nMaxValue * sizeof(XnUInt16); } - -protected: - virtual XnStatus CompressImpl(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) - { - return XnStreamCompressDepth16ZWithEmbTable((XnUInt16*)pData, nDataSize, pCompressedData, pnCompressedDataSize, m_nMaxValue); - } - - virtual XnStatus DecompressImpl(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) - { - return XnStreamUncompressDepth16ZWithEmbTable(pCompressedData, nCompressedDataSize, (XnUInt16*)pData, pnDataSize); - } - -private: - XnUInt16 m_nMaxValue; -}; - -#endif //__XN_16Z_EMB_TABLES_CODEC_H__ \ No newline at end of file diff --git a/Source/Drivers/PS1080/Formats/XnCodecBase.h b/Source/Drivers/PS1080/Formats/XnCodecBase.h deleted file mode 100644 index 71c67746..00000000 --- a/Source/Drivers/PS1080/Formats/XnCodecBase.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 __XN_CODEC_BASE_H__ -#define __XN_CODEC_BASE_H__ - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnCodec.h" - -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -class XnCodecBase : public XnCodec -{ -public: - static XnCompressionFormats GetCompressionFormatFromCodecID(XnCodecID codecID); - static XnCodecID GetCodecIDFromCompressionFormat(XnCompressionFormats format); - - XnCodecBase() {} - virtual ~XnCodecBase() {} - - virtual XnStatus Init() { return XN_STATUS_OK; } - - virtual XnCompressionFormats GetCompressionFormat() const = 0; - - XnStatus Compress(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) - { - XnStatus nRetVal = XN_STATUS_OK; - - XN_VALIDATE_INPUT_PTR(pData); - XN_VALIDATE_INPUT_PTR(pCompressedData); - XN_VALIDATE_OUTPUT_PTR(pnCompressedDataSize); - - if ((nDataSize * GetWorseCompressionRatio() + GetOverheadSize()) > *pnCompressedDataSize) - { - return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; - } - - nRetVal = CompressImpl(pData, nDataSize, pCompressedData, pnCompressedDataSize); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); - } - - XnStatus Decompress(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) - { - XnStatus nRetVal = XN_STATUS_OK; - - XN_VALIDATE_INPUT_PTR(pCompressedData); - XN_VALIDATE_INPUT_PTR(pData); - XN_VALIDATE_OUTPUT_PTR(pnDataSize); - - nRetVal = DecompressImpl(pCompressedData, nCompressedDataSize, pData, pnDataSize); - XN_IS_STATUS_OK(nRetVal); - - return (XN_STATUS_OK); - } - - virtual XnUInt32 GetOverheadSize() const = 0; - virtual XnFloat GetWorseCompressionRatio() const = 0; - -protected: - virtual XnStatus CompressImpl(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) = 0; - virtual XnStatus DecompressImpl(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) = 0; -}; - -#endif // __XN_CODEC_BASE_H__ \ No newline at end of file diff --git a/Source/Drivers/PS1080/Formats/XnFormats.h b/Source/Drivers/PS1080/Formats/XnFormats.h index a84bd32d..9241ed33 100644 --- a/Source/Drivers/PS1080/Formats/XnFormats.h +++ b/Source/Drivers/PS1080/Formats/XnFormats.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_FORMATS_H_ -#define _XN_FORMATS_H_ +#ifndef XNFORMATS_H +#define XNFORMATS_H //--------------------------------------------------------------------------- // Types @@ -48,4 +48,4 @@ */ XnStatus XnFormatsMirrorPixelData(OniPixelFormat nOutputFormat, XnUChar* pBuffer, XnUInt32 nBufferSize, XnUInt32 nXRes); -#endif //_XN_FORMATS_H_ +#endif // XNFORMATS_H diff --git a/Source/Drivers/PS1080/Formats/XnJpegCodec.h b/Source/Drivers/PS1080/Formats/XnJpegCodec.h deleted file mode 100644 index dfd9298a..00000000 --- a/Source/Drivers/PS1080/Formats/XnJpegCodec.h +++ /dev/null @@ -1,96 +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 __XN_JPEG_CODEC_H__ -#define __XN_JPEG_CODEC_H__ - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnCodecBase.h" -#include - -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -class XnJpegCodec : public XnCodecBase -{ -public: - XnJpegCodec(XnBool bRGB, XnUInt32 nXRes, XnUInt32 nYRes, XnUInt32 nQuality = XN_STREAM_COMPRESSION_JPEG_DEFAULT_QUALITY) : - m_bRGB(bRGB), m_nXRes(nXRes), m_nYRes(nYRes), m_nQuality(nQuality) - {} - - ~XnJpegCodec() - { - XnStreamFreeCompressImageJ(&m_CompJPEGContext); - XnStreamFreeUncompressImageJ(&m_UncompJPEGContext); - } - - XnStatus Init() - { - XnStatus nRetVal = XN_STATUS_OK; - - nRetVal = XnStreamInitCompressImageJ(&m_CompJPEGContext); - XN_IS_STATUS_OK(nRetVal); - - nRetVal = XnStreamInitUncompressImageJ(&m_UncompJPEGContext); - if (nRetVal != XN_STATUS_OK) - { - XnStreamFreeCompressImageJ(&m_CompJPEGContext); - return (nRetVal); - } - - return (XN_STATUS_OK); - } - - virtual XnCompressionFormats GetCompressionFormat() const { return XN_COMPRESSION_JPEG; } - virtual XnFloat GetWorseCompressionRatio() const { return XN_STREAM_COMPRESSION_IMAGEJ_WORSE_RATIO; } - virtual XnUInt32 GetOverheadSize() const { return 0; } - -protected: - XN_DISABLE_COPY_AND_ASSIGN(XnJpegCodec); - - virtual XnStatus CompressImpl(const XnUChar* pData, XnUInt32 /*nDataSize*/, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) - { - if (m_bRGB) - { - return XnStreamCompressImage24J(&m_CompJPEGContext, pData, pCompressedData, pnCompressedDataSize, m_nXRes, m_nYRes, m_nQuality); - } - else - { - return XnStreamCompressImage8J(&m_CompJPEGContext, pData, pCompressedData, pnCompressedDataSize, m_nXRes, m_nYRes, m_nQuality); - } - } - - virtual XnStatus DecompressImpl(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) - { - return XnStreamUncompressImageJ(&m_UncompJPEGContext, pCompressedData, nCompressedDataSize, pData, pnDataSize); - } - -private: - const XnBool m_bRGB; - const XnUInt32 m_nXRes; - const XnUInt32 m_nYRes; - const XnUInt32 m_nQuality; - XnStreamCompJPEGContext m_CompJPEGContext; - XnStreamUncompJPEGContext m_UncompJPEGContext; -}; - -#endif //__XN_JPEG_CODEC_H__ \ No newline at end of file diff --git a/Source/Drivers/PS1080/Formats/XnStreamCompression.cpp b/Source/Drivers/PS1080/Formats/XnStreamCompression.cpp deleted file mode 100644 index 129c3219..00000000 --- a/Source/Drivers/PS1080/Formats/XnStreamCompression.cpp +++ /dev/null @@ -1,1280 +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. * -* * -*****************************************************************************/ -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnStreamCompression.h" -#include -extern "C" { -#include -} -#include - -//--------------------------------------------------------------------------- -// Code -//--------------------------------------------------------------------------- -XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt16* pInputEnd = pInput + (nInputSize / sizeof(XnUInt16)); - XnUInt8* pOrigOutput = pOutput; - XnUInt16 nCurrValue = 0; - XnUInt16 nLastValue = 0; - XnUInt16 nAbsDiffValue = 0; - XnInt16 nDiffValue = 0; - XnUInt8 cOutStage = 0; - XnUInt8 cOutChar = 0; - XnUInt8 cZeroCounter = 0; - - // Note: this function does not make sure it stay within the output memory boundaries! - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - if (nInputSize == 0) - { - *pnOutputSize = 0; - return XN_STATUS_OK; - } - - // Encode the data... - nLastValue = *pInput; - *(XnUInt16*)pOutput = nLastValue; - pInput++; - pOutput+=2; - - while (pInput != pInputEnd) - { - nCurrValue = *pInput; - - nDiffValue = (nLastValue - nCurrValue); - nAbsDiffValue = (XnUInt16)abs(nDiffValue); - - if (nAbsDiffValue <= 6) - { - nDiffValue += 6; - - if (cOutStage == 0) - { - cOutChar = (XnUInt8)(nDiffValue << 4); - - cOutStage = 1; - } - else - { - cOutChar += (XnUInt8)nDiffValue; - - if (cOutChar == 0x66) - { - cZeroCounter++; - - if (cZeroCounter == 15) - { - *pOutput = 0xEF; - pOutput++; - - cZeroCounter = 0; - } - } - else - { - if (cZeroCounter != 0) - { - *pOutput = 0xE0 + cZeroCounter; - pOutput++; - - cZeroCounter = 0; - } - - *pOutput = cOutChar; - pOutput++; - } - - cOutStage = 0; - } - } - else - { - if (cZeroCounter != 0) - { - *pOutput = 0xE0 + cZeroCounter; - pOutput++; - - cZeroCounter = 0; - } - - if (cOutStage == 0) - { - cOutChar = 0xFF; - } - else - { - cOutChar += 0x0F; - cOutStage = 0; - } - - *pOutput = cOutChar; - pOutput++; - - if (nAbsDiffValue <= 63) - { - nDiffValue += 192; - - *pOutput = (XnUInt8)nDiffValue; - pOutput++; - } - else - { - *(XnUInt16*)pOutput = (nCurrValue << 8) + (nCurrValue >> 8); - pOutput+=2; - } - } - - nLastValue = nCurrValue; - pInput++; - } - - if (cOutStage != 0) - { - *pOutput = cOutChar + 0x0D; - pOutput++; - } - - if (cZeroCounter != 0) - { - *pOutput = 0xE0 + cZeroCounter; - pOutput++; - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize, XnUInt16 nMaxValue) -{ - // Local function variables - const XnUInt16* pInputEnd = pInput + (nInputSize / sizeof(XnUInt16)); - const XnUInt16* pOrigInput = pInput; - const XnUInt8* pOrigOutput = pOutput; - XnUInt16 nCurrValue = 0; - XnUInt16 nLastValue = 0; - XnUInt16 nAbsDiffValue = 0; - XnInt16 nDiffValue = 0; - XnUInt8 cOutStage = 0; - XnUInt8 cOutChar = 0; - XnUInt8 cZeroCounter = 0; - static XnUInt16 nEmbTable[XN_MAX_UINT16]; - XnUInt16 nEmbTableIdx=0; - - // Note: this function does not make sure it stay within the output memory boundaries! - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - // Create the embedded value translation table... - pOutput+=2; - xnOSMemSet(&nEmbTable[0], 0, nMaxValue*sizeof(XnUInt16)); - - while (pInput != pInputEnd) - { - nEmbTable[*pInput] = 1; - pInput++; - } - - for (XnUInt32 i=0; i> 8)); - pOutput+=2; - } - } - - nLastValue = nCurrValue; - pInput++; - } - - if (cOutStage != 0) - { - *pOutput = cOutChar + 0x0D; - pOutput++; - } - - if (cZeroCounter != 0) - { - *pOutput = 0xE0 + cZeroCounter; - pOutput++; - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamUncompressDepth16Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - XnUInt16* pOutputEnd = 0; - const XnUInt16* pOrigOutput = pOutput; - XnUInt16 nLastFullValue = 0; - XnUInt8 cInput = 0; - XnUInt8 cZeroCounter = 0; - XnInt8 cInData1 = 0; - XnInt8 cInData2 = 0; - XnUInt8 cInData3 = 0; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - if (nInputSize < sizeof(XnUInt16)) - { - return (XN_STATUS_IO_COMPRESSED_BUFFER_TOO_SMALL); - } - - pOutputEnd = pOutput + (*pnOutputSize / sizeof(XnUInt16)); - - // Decode the data... - nLastFullValue = *(XnUInt16*)pInput; - *pOutput = nLastFullValue; - pInput+=2; - pOutput++; - - while (pInput != pInputEnd) - { - cInput = *pInput; - - if (cInput < 0xE0) - { - cInData1 = cInput >> 4; - cInData2 = (cInput & 0x0f); - - nLastFullValue -= (cInData1 - 6); - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = nLastFullValue; - pOutput++; - - if (cInData2 != 0x0f) - { - if (cInData2 != 0x0d) - { - nLastFullValue -= (cInData2 - 6); - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = nLastFullValue; - pOutput++; - } - - pInput++; - } - else - { - pInput++; - - cInData3 = *pInput; - if (cInData3 & 0x80) - { - nLastFullValue -= (cInData3 - 192); - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = nLastFullValue; - - pOutput++; - pInput++; - } - else - { - nLastFullValue = cInData3 << 8; - pInput++; - nLastFullValue += *pInput; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = nLastFullValue; - - pOutput++; - pInput++; - } - } - } - else if (cInput == 0xFF) - { - pInput++; - - cInData3 = *pInput; - - if (cInData3 & 0x80) - { - nLastFullValue -= (cInData3 - 192); - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = nLastFullValue; - - pInput++; - pOutput++; - } - else - { - nLastFullValue = cInData3 << 8; - pInput++; - nLastFullValue += *pInput; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = nLastFullValue; - - pInput++; - pOutput++; - } - } - else //It must be 0xE? - { - cZeroCounter = cInput - 0xE0; - - while (cZeroCounter != 0) - { - XN_CHECK_OUTPUT_OVERFLOW(pOutput+1, pOutputEnd); - *pOutput = nLastFullValue; - pOutput++; - - *pOutput = nLastFullValue; - pOutput++; - - cZeroCounter--; - } - - pInput++; - } - } - - *pnOutputSize = (XnUInt32)((pOutput - pOrigOutput) * sizeof(XnUInt16)); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamUncompressDepth16ZWithEmbTable(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - XnUInt16* pOutputEnd = 0; - XnUInt16* pOrigOutput = pOutput; - XnUInt16 nLastFullValue = 0; - XnUInt8 cInput = 0; - XnUInt8 cZeroCounter = 0; - XnInt8 cInData1 = 0; - XnInt8 cInData2 = 0; - XnUInt8 cInData3 = 0; - XnUInt16* pEmbTable = NULL; - XnUInt16 nEmbTableIdx = 0; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - if (nInputSize < sizeof(XnUInt16)) - { - return (XN_STATUS_IO_COMPRESSED_BUFFER_TOO_SMALL); - } - - nEmbTableIdx = XN_PREPARE_VAR16_IN_BUFFER(*(XnUInt16*)pInput); - pInput+=2; - pEmbTable = (XnUInt16*)pInput; - pInput+=nEmbTableIdx * 2; - for (XnUInt32 i = 0; i < nEmbTableIdx; i++) - pEmbTable[i] = XN_PREPARE_VAR16_IN_BUFFER(pEmbTable[i]); - - pOutputEnd = pOutput + (*pnOutputSize / sizeof(XnUInt16)); - - // Decode the data... - nLastFullValue = XN_PREPARE_VAR16_IN_BUFFER(*(XnUInt16*)pInput); - *pOutput = pEmbTable[nLastFullValue]; - pInput+=2; - pOutput++; - - while (pInput != pInputEnd) - { - cInput = *pInput; - - if (cInput < 0xE0) - { - cInData1 = cInput >> 4; - cInData2 = (cInput & 0x0f); - - nLastFullValue -= (cInData1 - 6); - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - - if (cInData2 != 0x0f) - { - if (cInData2 != 0x0d) - { - nLastFullValue -= (cInData2 - 6); - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - } - - pInput++; - } - else - { - pInput++; - - cInData3 = *pInput; - if (cInData3 & 0x80) - { - nLastFullValue -= (cInData3 - 192); - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pOutput++; - pInput++; - } - else - { - nLastFullValue = cInData3 << 8; - pInput++; - nLastFullValue += *pInput; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pOutput++; - pInput++; - } - } - } - else if (cInput == 0xFF) - { - pInput++; - - cInData3 = *pInput; - - if (cInData3 & 0x80) - { - nLastFullValue -= (cInData3 - 192); - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pInput++; - pOutput++; - } - else - { - nLastFullValue = cInData3 << 8; - pInput++; - nLastFullValue += *pInput; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - - pInput++; - pOutput++; - } - } - else //It must be 0xE? - { - cZeroCounter = cInput - 0xE0; - - while (cZeroCounter != 0) - { - XN_CHECK_OUTPUT_OVERFLOW(pOutput+1, pOutputEnd); - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - - *pOutput = pEmbTable[nLastFullValue]; - pOutput++; - - cZeroCounter--; - } - - pInput++; - } - } - - *pnOutputSize = (XnUInt32)((pOutput - pOrigOutput) * sizeof(XnUInt16)); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - const XnUInt8* pOrigOutput = pOutput; - XnUInt8 nCurrValue = 0; - XnUInt8 nLastValue = 0; - XnUInt8 nAbsDiffValue = 0; - XnInt8 nDiffValue = 0; - XnUInt8 cOutStage = 0; - XnUInt8 cOutChar = 0; - XnUInt8 cZeroCounter = 0; - XnBool bFlag = FALSE; - - // Note: this function does not make sure it stay within the output memory boundaries! - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - // Encode the data... - nLastValue = *pInput; - *pOutput = nLastValue; - pInput++; - pOutput++; - - while (pInput != pInputEnd) - { - nCurrValue = *pInput; - - nDiffValue = (nLastValue - nCurrValue); - nAbsDiffValue = (XnUInt8)abs(nDiffValue); - - if (nAbsDiffValue <= 6) - { - nDiffValue += 6; - - if (cOutStage == 0) - { - cOutChar = nDiffValue << 4; - - cOutStage = 1; - } - else - { - cOutChar += nDiffValue; - - if ((cOutChar == 0x66) && (bFlag == FALSE)) - { - cZeroCounter++; - - if (cZeroCounter == 15) - { - *pOutput = 0xEF; - pOutput++; - - cZeroCounter = 0; - } - } - else - { - if (cZeroCounter != 0) - { - *pOutput = 0xE0 + cZeroCounter; - pOutput++; - - cZeroCounter = 0; - } - - *pOutput = cOutChar; - pOutput++; - - bFlag = FALSE; - } - - cOutStage = 0; - } - } - else - { - if (cZeroCounter != 0) - { - *pOutput = 0xE0 + cZeroCounter; - pOutput++; - - cZeroCounter = 0; - } - - if (cOutStage == 0) - { - cOutChar = 0xF0; - cOutChar += nCurrValue >> 4; - - *pOutput = cOutChar; - pOutput++; - - cOutChar = (nCurrValue & 0xF) << 4; - cOutStage = 1; - - bFlag = TRUE; - } - else - { - cOutChar += 0x0F; - cOutStage = 0; - - *pOutput = cOutChar; - pOutput++; - - *pOutput = nCurrValue; - pOutput++; - } - } - - nLastValue = nCurrValue; - pInput++; - } - - if (cOutStage != 0) - { - *pOutput = cOutChar + 0x0D; - pOutput++; - } - - if (cZeroCounter != 0) - { - *pOutput = 0xE0 + cZeroCounter; - pOutput++; - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamUncompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - const XnUInt8* pInputEnd = pInput + nInputSize; - const XnUInt8* pOrigOutput = pOutput; - XnUInt8 nLastFullValue = 0; - XnUInt8 cInput = 0; - XnUInt8 cZeroCounter = 0; - XnInt8 cInData1 = 0; - XnInt8 cInData2 = 0; - - // Note: this function does not make sure it stay within the output memory boundaries! - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - if (nInputSize < sizeof(XnUInt8)) - { - return (XN_STATUS_IO_COMPRESSED_BUFFER_TOO_SMALL); - } - - // Decode the data... - nLastFullValue = *pInput; - *pOutput = nLastFullValue; - pInput++; - pOutput++; - - while (pInput != pInputEnd) - { - cInput = *pInput; - - if (cInput < 0xE0) - { - cInData1 = cInput >> 4; - cInData2 = (cInput & 0x0f); - - nLastFullValue -= (cInData1 - 6); - *pOutput = nLastFullValue; - pOutput++; - - if (cInData2 != 0x0f) - { - if (cInData2 != 0x0d) - { - nLastFullValue -= (cInData2 - 6); - *pOutput = nLastFullValue; - pOutput++; - } - } - else - { - pInput++; - nLastFullValue = *pInput; - *pOutput = nLastFullValue; - pOutput++; - } - - pInput++; - } - else if (cInput >= 0xF0) - { - cInData1 = cInput << 4; - - pInput++; - cInput = *pInput; - - nLastFullValue = cInData1 + (cInput >> 4); - - *pOutput = nLastFullValue; - pOutput++; - - cInData2 = cInput & 0xF; - - if (cInData2 == 0x0F) - { - pInput++; - nLastFullValue = *pInput; - *pOutput = nLastFullValue; - pOutput++; - pInput++; - } - else - { - if (cInData2 != 0x0D) - { - nLastFullValue -= (cInData2 - 6); - *pOutput = nLastFullValue; - pOutput++; - } - - pInput++; - } - } - else //It must be 0xE? - { - cZeroCounter = cInput - 0xE0; - - while (cZeroCounter != 0) - { - *pOutput = nLastFullValue; - pOutput++; - - *pOutput = nLastFullValue; - pOutput++; - - cZeroCounter--; - } - - pInput++; - } - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamCompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - const XnUInt8* pOrigOutput = pOutput; - - // Note: this function does not make sure it stay within the output memory boundaries! - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - // Encode the data... - while (pInput != pInputEnd) - { - *pOutput = *pInput << 4; - pInput++; - - *pOutput += *pInput; - pInput++; - - pOutput++; - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamUncompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - const XnUInt8* pInputEnd = pInput + nInputSize; - const XnUInt8* pOutputEnd = 0; - const XnUInt8* pOrigOutput = pOutput; - XnUInt8 nValue1; - XnUInt8 nValue2; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_INPUT_PTR(pOutput); - XN_VALIDATE_INPUT_PTR(pnOutputSize); - - if (nInputSize < sizeof(XnUInt8)) - { - return (XN_STATUS_IO_COMPRESSED_BUFFER_TOO_SMALL); - } - - if (nInputSize % 2 != 0) - { - return (XN_STATUS_IO_INVALID_COMPRESSED_BUFFER_SIZE); - } - - pOutputEnd = pOutput + *pnOutputSize; - - XN_CHECK_OUTPUT_OVERFLOW(pOutput + (nInputSize * 2), pOutputEnd); - - while (pInput != pInputEnd) - { - nValue1 = pInput[0]; - nValue2 = pInput[1]; - - pOutput[0] = nValue1 >> 4; - pOutput[1] = nValue1 & 0xF; - pOutput[2] = nValue2 >> 4; - pOutput[3] = nValue2 & 0xF; - - pOutput+=4; - pInput+=2; - } - - *pnOutputSize = (XnUInt32)(pOutput - pOrigOutput); - - // All is good... - return (XN_STATUS_OK); -} - -void XnStreamJPEGCompDummyFunction(struct jpeg_compress_struct* /*pjCompStruct*/) -{ - // Dummy libjpeg function to wrap internal buffers usage... -} - -boolean XnStreamJPEGCompDummyFailFunction(struct jpeg_compress_struct* /*pjCompStruct*/) -{ - // If we ever got to the point we need to allocate more memory, something is wrong! - return (FALSE); -} - -XnStatus XnStreamInitCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_OUTPUT_PTR(pStreamCompJPEGContext); - - pStreamCompJPEGContext->jCompStruct.err = jpeg_std_error(&pStreamCompJPEGContext->jErrMgr); - - jpeg_create_compress(&pStreamCompJPEGContext->jCompStruct); - - pStreamCompJPEGContext->jCompStruct.dest = &pStreamCompJPEGContext->jDestMgr; - pStreamCompJPEGContext->jCompStruct.dest->init_destination = XnStreamJPEGCompDummyFunction; - pStreamCompJPEGContext->jCompStruct.dest->empty_output_buffer = XnStreamJPEGCompDummyFailFunction; - pStreamCompJPEGContext->jCompStruct.dest->term_destination = XnStreamJPEGCompDummyFunction; - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamFreeCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamCompJPEGContext); - - jpeg_destroy_compress(&pStreamCompJPEGContext->jCompStruct); - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamCompressImage8J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality) -{ - // Local function variables - XnUInt8* pCurrScanline = (XnUInt8*)pInput; - XnUInt32 nYIndex = 0; - jpeg_compress_struct* pjCompStruct = NULL; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamCompJPEGContext); - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_OUTPUT_PTR(pOutput); - XN_VALIDATE_OUTPUT_PTR(pnOutputSize); - - pjCompStruct = &pStreamCompJPEGContext->jCompStruct; - - pjCompStruct->in_color_space = JCS_GRAYSCALE; - jpeg_set_defaults(pjCompStruct); - pjCompStruct->input_components = 1; - pjCompStruct->num_components = 1; - pjCompStruct->image_width = nXRes; - pjCompStruct->image_height = nYRes; - pjCompStruct->data_precision = 8; - pjCompStruct->input_gamma = 1.0; - - jpeg_set_quality(pjCompStruct, nQuality, FALSE); - - pjCompStruct->dest->next_output_byte = (JOCTET*)pOutput; - pjCompStruct->dest->free_in_buffer = *pnOutputSize; - - jpeg_start_compress(pjCompStruct, TRUE); - - for (nYIndex = 0; nYIndex < nYRes; nYIndex++) - { - jpeg_write_scanlines(pjCompStruct, &pCurrScanline, 1); - - pCurrScanline += nXRes; - } - - jpeg_finish_compress(pjCompStruct); - - *pnOutputSize -= (XnUInt32)pjCompStruct->dest->free_in_buffer; - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamCompressImage24J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality) -{ - // Local function variables - XnUInt8* pCurrScanline = (XnUChar*)pInput; - XnUInt32 nYIndex = 0; - XnUInt32 nScanLineSize = 0; - jpeg_compress_struct* pjCompStruct = NULL; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamCompJPEGContext); - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_OUTPUT_PTR(pOutput); - XN_VALIDATE_OUTPUT_PTR(pnOutputSize); - - pjCompStruct = &pStreamCompJPEGContext->jCompStruct; - - pjCompStruct->in_color_space = JCS_RGB; - jpeg_set_defaults(pjCompStruct); - pjCompStruct->input_components = 3; - pjCompStruct->num_components = 3; - pjCompStruct->image_width = nXRes; - pjCompStruct->image_height = nYRes; - pjCompStruct->data_precision = 8; - pjCompStruct->input_gamma = 1.0; - - jpeg_set_quality(pjCompStruct, nQuality, FALSE); - - pjCompStruct->dest->next_output_byte = (JOCTET*)pOutput; - pjCompStruct->dest->free_in_buffer = *pnOutputSize; - - jpeg_start_compress(pjCompStruct, TRUE); - - nScanLineSize = nXRes * 3; - for (nYIndex = 0; nYIndex < nYRes; nYIndex++) - { - jpeg_write_scanlines(pjCompStruct, &pCurrScanline, 1); - - pCurrScanline += nScanLineSize; - } - - jpeg_finish_compress(pjCompStruct); - - *pnOutputSize -= (XnUInt32)pjCompStruct->dest->free_in_buffer; - - // All is good... - return (XN_STATUS_OK); -} - -void XnStreamJPEGDecompDummyFunction(struct jpeg_decompress_struct* /*pjDecompStruct*/) -{ - // Dummy libjpeg function to wrap internal buffers usage... -} - -boolean XnStreamJPEGDecompDummyFailFunction(struct jpeg_decompress_struct* /*pjDecompStruct*/) -{ - // If we ever got to the point we need to allocate more memory, something is wrong! - return (FALSE); -} - -void XnStreamJPEGDecompSkipFunction(struct jpeg_decompress_struct* pjDecompStruct, long nNumBytes) -{ - // Skip bytes in the internal buffer - pjDecompStruct->src->next_input_byte += (size_t)nNumBytes; - pjDecompStruct->src->bytes_in_buffer -= (size_t)nNumBytes; -} - -void XnStreamJPEGDummyErrorExit(j_common_ptr cinfo) -{ - XnLibJpegErrorMgr* errMgr = (XnLibJpegErrorMgr*)cinfo->err; - - longjmp(errMgr->setjmpBuffer, 1); -} - -void XnStreamJPEGOutputMessage(j_common_ptr cinfo) -{ - struct jpeg_error_mgr* err = cinfo->err; - int msg_code = err->msg_code; - if (msg_code == JWRN_EXTRANEOUS_DATA) - { - // NOTE: we are aware this problem occurs. Log a warning every once in a while - static XnUInt32 nTimes = 0; - if (++nTimes == 50) - { - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - - //Temporary disabled this error since it happens all the time and it's a known issue. - //xnLogWarning(XN_MASK_JPEG, "JPEG: The following warning occurred 50 times: %s", buffer); - nTimes = 0; - } - } - else - { - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - - xnLogWarning(XN_MASK_JPEG, "JPEG: %s", buffer); - } -} - -XnStatus XnStreamInitUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_OUTPUT_PTR(pStreamUncompJPEGContext); - - pStreamUncompJPEGContext->jDecompStruct.err = jpeg_std_error(&pStreamUncompJPEGContext->jErrMgr.pub); - pStreamUncompJPEGContext->jErrMgr.pub.output_message = XnStreamJPEGOutputMessage; - pStreamUncompJPEGContext->jErrMgr.pub.error_exit = XnStreamJPEGDummyErrorExit; - - jpeg_create_decompress(&pStreamUncompJPEGContext->jDecompStruct); - - pStreamUncompJPEGContext->jDecompStruct.src = &pStreamUncompJPEGContext->jSrcMgr; - pStreamUncompJPEGContext->jDecompStruct.src->init_source = XnStreamJPEGDecompDummyFunction; - pStreamUncompJPEGContext->jDecompStruct.src->fill_input_buffer = XnStreamJPEGDecompDummyFailFunction; - pStreamUncompJPEGContext->jDecompStruct.src->skip_input_data = XnStreamJPEGDecompSkipFunction; - pStreamUncompJPEGContext->jDecompStruct.src->resync_to_restart = jpeg_resync_to_restart; - pStreamUncompJPEGContext->jDecompStruct.src->term_source = XnStreamJPEGDecompDummyFunction; - - // All is good... - return (XN_STATUS_OK); -} - -XnStatus XnStreamFreeUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext) -{ - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamUncompJPEGContext); - - jpeg_destroy_decompress(&pStreamUncompJPEGContext->jDecompStruct); - - // All is good... - return (XN_STATUS_OK); -} - -// to allow the use of setjmp -#if (ONI_PLATFORM == ONI_PLATFORM_WIN32) -#pragma warning(push) -#pragma warning(disable: 4611) -#endif - -XnStatus XnStreamUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext, const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize) -{ - // Local function variables - XnUInt8* pCurrScanline = pOutput; - XnUInt8* pNextScanline = NULL; - XnUInt8* pOutputEnd = 0; - XnUInt32 nScanLineSize = 0; - XnUInt32 nOutputSize = 0; - jpeg_decompress_struct* pjDecompStruct = NULL; - - // Validate the input/output pointers (to make sure none of them is NULL) - XN_VALIDATE_INPUT_PTR(pStreamUncompJPEGContext); - XN_VALIDATE_INPUT_PTR(pInput); - XN_VALIDATE_OUTPUT_PTR(pOutput); - XN_VALIDATE_OUTPUT_PTR(pnOutputSize); - - if (nInputSize == 0) - { - return (XN_STATUS_IO_COMPRESSED_BUFFER_TOO_SMALL); - } - - pOutputEnd = pOutput + *pnOutputSize; - - pjDecompStruct = &pStreamUncompJPEGContext->jDecompStruct; - - pjDecompStruct->src->bytes_in_buffer = nInputSize; - pjDecompStruct->src->next_input_byte = pInput; - - if (setjmp(pStreamUncompJPEGContext->jErrMgr.setjmpBuffer)) - { - //If we get here, the JPEG code has signaled an error. - XnStreamFreeUncompressImageJ(pStreamUncompJPEGContext); - XnStreamInitUncompressImageJ(pStreamUncompJPEGContext); - - *pnOutputSize = 0; - - return (XN_STATUS_IO_DECOMPRESSION_FAILED); - } - - jpeg_read_header(pjDecompStruct, TRUE); - - jpeg_start_decompress(pjDecompStruct); - - nScanLineSize = pjDecompStruct->output_width * pjDecompStruct->num_components; - - nOutputSize = pjDecompStruct->output_height * nScanLineSize; - if (nOutputSize > *pnOutputSize) - { - XnStreamFreeUncompressImageJ(pStreamUncompJPEGContext); - XnStreamInitUncompressImageJ(pStreamUncompJPEGContext); - - *pnOutputSize = 0; - - return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); - } - - while (pStreamUncompJPEGContext->jDecompStruct.output_scanline < pStreamUncompJPEGContext->jDecompStruct.output_height) - { - pNextScanline = pCurrScanline+nScanLineSize; - - if (pNextScanline > pOutputEnd) - { - XnStreamFreeUncompressImageJ(pStreamUncompJPEGContext); - XnStreamInitUncompressImageJ(pStreamUncompJPEGContext); - - *pnOutputSize = 0; - - return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); - } - - jpeg_read_scanlines(pjDecompStruct, &pCurrScanline, 1); - pCurrScanline = pNextScanline; - } - - jpeg_finish_decompress(pjDecompStruct); - - *pnOutputSize = nOutputSize; - - // All is good... - return (XN_STATUS_OK); -} - -#if (ONI_PLATFORM == ONI_PLATFORM_WIN32) -#pragma warning(pop) -#endif diff --git a/Source/Drivers/PS1080/Formats/XnStreamCompression.h b/Source/Drivers/PS1080/Formats/XnStreamCompression.h deleted file mode 100644 index 9a762c06..00000000 --- a/Source/Drivers/PS1080/Formats/XnStreamCompression.h +++ /dev/null @@ -1,104 +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 _XN_STREAMCOMPRESSION_H_ -#define _XN_STREAMCOMPRESSION_H_ - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnFormats.h" -#include -extern "C" { -#include -} -#include - -//--------------------------------------------------------------------------- -// Defines -//--------------------------------------------------------------------------- -#define XN_STREAM_COMPRESSION_DEPTH16Z_WORSE_RATIO 1.333F -#define XN_STREAM_COMPRESSION_IMAGE8Z_WORSE_RATIO 1.333F -#define XN_STREAM_COMPRESSION_IMAGEJ_WORSE_RATIO 1.2F -#define XN_STREAM_COMPRESSION_CONF4_WORSE_RATIO 0.51F -#define XN_STREAM_COMPRESSION_JPEG_DEFAULT_QUALITY 90 - -#define XN_STREAM_STRING_BAD_FORMAT -1 - -#define XN_MASK_JPEG "JPEG" - -//--------------------------------------------------------------------------- -// Structs -//--------------------------------------------------------------------------- - -XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_STRUCT_PADDED_WARNING_ID); - -typedef struct XnLibJpegErrorMgr -{ - struct jpeg_error_mgr pub; - - jmp_buf setjmpBuffer; -} XnLibJpegErrorMgr; - -XN_PRAGMA_STOP_DISABLED_WARNING_SECTION; - -typedef struct XnStreamCompJPEGContext -{ - jpeg_compress_struct jCompStruct; - jpeg_error_mgr jErrMgr; - struct jpeg_destination_mgr jDestMgr; -} XnStreamCompJPEGContext; - -typedef struct XnStreamUncompJPEGContext -{ - jpeg_decompress_struct jDecompStruct; - XnLibJpegErrorMgr jErrMgr; - struct jpeg_source_mgr jSrcMgr; -} XnStreamUncompJPEGContext; - -//--------------------------------------------------------------------------- -// Functions Declaration -//--------------------------------------------------------------------------- -XnStatus XnStreamCompressDepth16Z(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamCompressDepth16ZWithEmbTable(const XnUInt16* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize, XnUInt16 nMaxValue); -XnStatus XnStreamUncompressDepth16Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamUncompressDepth16ZWithEmbTable(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt16* pOutput, XnUInt32* pnOutputSize); - -XnStatus XnStreamCompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamUncompressImage8Z(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); - -XnStatus XnStreamCompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); -XnStatus XnStreamUncompressConf4(const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); - -void XnStreamJPEGCompDummyFunction(struct jpeg_compress_struct* pjCompStruct); -boolean XnStreamJPEGCompDummyFailFunction(struct jpeg_compress_struct* pjCompStruct); -XnStatus XnStreamInitCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext); -XnStatus XnStreamFreeCompressImageJ(XnStreamCompJPEGContext* pStreamCompJPEGContext); -XnStatus XnStreamCompressImage8J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality); -XnStatus XnStreamCompressImage24J(XnStreamCompJPEGContext* pStreamCompJPEGContext, const XnUInt8* pInput, XnUInt8* pOutput, XnUInt32* pnOutputSize, const XnUInt32 nXRes, const XnUInt32 nYRes, const XnUInt32 nQuality); - -void XnStreamJPEGDecompDummyFunction(struct jpeg_decompress_struct* pjDecompStruct); -boolean XnStreamJPEGDecompDummyFailFunction(struct jpeg_decompress_struct* pjDecompStruct); -void XnStreamJPEGDecompSkipFunction(struct jpeg_decompress_struct* pjDecompStruct, XnInt nNumBytes); -XnStatus XnStreamInitUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext); -XnStatus XnStreamFreeUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext); -XnStatus XnStreamUncompressImageJ(XnStreamUncompJPEGContext* pStreamUncompJPEGContext, const XnUInt8* pInput, const XnUInt32 nInputSize, XnUInt8* pOutput, XnUInt32* pnOutputSize); - -#endif //_XN_STREAMCOMPRESSION_H_ diff --git a/Source/Drivers/PS1080/Include/XnCommon.h b/Source/Drivers/PS1080/Include/XnCommon.h index 86ffbd94..eddae7f7 100644 --- a/Source/Drivers/PS1080/Include/XnCommon.h +++ b/Source/Drivers/PS1080/Include/XnCommon.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_COMMON_H__ -#define __XN_COMMON_H__ +#ifndef XNCOMMON_H +#define XNCOMMON_H //--------------------------------------------------------------------------- // Includes @@ -52,4 +52,4 @@ typedef enum XnPrimeSenseErrorModules #define XN_PS_STATUS_MESSAGE_MAP_END(module) \ XN_STATUS_MESSAGE_MAP_END_FROM(XN_ERROR_GROUP_PRIMESENSE, module) -#endif // __XN_COMMON_H__ +#endif // XNCOMMON_H diff --git a/Source/Drivers/PS1080/Include/XnCore.h b/Source/Drivers/PS1080/Include/XnCore.h index 1e56aa50..b830cff3 100644 --- a/Source/Drivers/PS1080/Include/XnCore.h +++ b/Source/Drivers/PS1080/Include/XnCore.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_CORE_H_ -#define _XN_CORE_H_ +#ifndef XNCORE_H +#define XNCORE_H //--------------------------------------------------------------------------- // Includes @@ -104,4 +104,4 @@ XnUInt32 XnGetVersion(void); */ const XnChar* XnGetVersionString(void); -#endif //_XN_CORE_H_ +#endif // XNCORE_H diff --git a/Source/Drivers/PS1080/Include/XnDDK.h b/Source/Drivers/PS1080/Include/XnDDK.h index 1963bbc3..65c64d36 100644 --- a/Source/Drivers/PS1080/Include/XnDDK.h +++ b/Source/Drivers/PS1080/Include/XnDDK.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_DDK_H_ -#define _XN_DDK_H_ +#ifndef XNDDK_H +#define XNDDK_H #include #include @@ -50,4 +50,4 @@ XnResolutions XnDDKGetResolutionFromXY(XnUInt32 nXRes, XnUInt32 nYRes); XnBool XnDDKGetXYFromResolution(XnResolutions res, XnUInt32* pnXRes, XnUInt32* pnYRes); const XnChar* XnDDKGetResolutionName(XnResolutions res); -#endif //_XN_DDK_H_ +#endif // XNDDK_H diff --git a/Source/Drivers/PS1080/Include/XnDDKStatus.h b/Source/Drivers/PS1080/Include/XnDDKStatus.h index 7872bd7b..8b1bd556 100644 --- a/Source/Drivers/PS1080/Include/XnDDKStatus.h +++ b/Source/Drivers/PS1080/Include/XnDDKStatus.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_DDK_STATUS_H_ -#define _XN_DDK_STATUS_H_ +#ifndef XNDDKSTATUS_H +#define XNDDKSTATUS_H #include #include @@ -159,4 +159,4 @@ XN_STATUS_MESSAGE(XN_STATUS_IO_DEVICE_ROM_IO_ERROR, "The device ROM I/O command XN_STATUS_MESSAGE(XN_STATUS_IO_DEVICE_ROM_ERASE_ERROR, "Failed to delete a file from the device ROM!") XN_PS_STATUS_MESSAGE_MAP_END(XN_ERROR_GROUP_DDK) -#endif //_XN_DDK_STATUS_H_ +#endif // XNDDKSTATUS_H diff --git a/Source/Drivers/PS1080/Include/XnDevice.h b/Source/Drivers/PS1080/Include/XnDevice.h index 83babfca..67045980 100644 --- a/Source/Drivers/PS1080/Include/XnDevice.h +++ b/Source/Drivers/PS1080/Include/XnDevice.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_DEVICE_H_ -#define _XN_DEVICE_H_ +#ifndef XNDEVICE_H +#define XNDEVICE_H //--------------------------------------------------------------------------- // Includes @@ -52,4 +52,4 @@ typedef void (XN_CALLBACK_TYPE* XnDeviceOnPropertyChangedEventHandler)(const XnC typedef void (XN_CALLBACK_TYPE* XnDeviceOnNewStreamDataEventHandler)(const XnNewStreamDataEventArgs& args, void* pCookie); -#endif //_XN_DEVICE_H_ \ No newline at end of file +#endif // XNDEVICE_H diff --git a/Source/Drivers/PS1080/Include/XnDeviceProxy.h b/Source/Drivers/PS1080/Include/XnDeviceProxy.h index baa1cd28..9dd210ae 100644 --- a/Source/Drivers/PS1080/Include/XnDeviceProxy.h +++ b/Source/Drivers/PS1080/Include/XnDeviceProxy.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEVICE_PROXY_H__ -#define __XN_DEVICE_PROXY_H__ +#ifndef XNDEVICEPROXY_H +#define XNDEVICEPROXY_H //--------------------------------------------------------------------------- // Includes @@ -95,4 +95,4 @@ XN_DDK_API XnStatus XnDeviceProxyDestroyStreamOutputByName(const XnChar* csDevic */ XN_DDK_API XnStatus XnDeviceProxyGetDeviceName(XnDeviceHandle DeviceHandle, XnChar* csDeviceName); -#endif //__XN_DEVICE_PROXY_H__ \ No newline at end of file +#endif // XNDEVICEPROXY_H diff --git a/Source/Drivers/PS1080/Include/XnFormatsStatus.h b/Source/Drivers/PS1080/Include/XnFormatsStatus.h index a229760a..06f06801 100644 --- a/Source/Drivers/PS1080/Include/XnFormatsStatus.h +++ b/Source/Drivers/PS1080/Include/XnFormatsStatus.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_FORMATS_STATUS_H_ -#define _XN_FORMATS_STATUS_H_ +#ifndef XNFORMATSSTATUS_H +#define XNFORMATSSTATUS_H //--------------------------------------------------------------------------- // Includes @@ -60,4 +60,4 @@ XN_STATUS_MESSAGE(XN_STATUS_IO_INVALID_STREAM_AUDIO_BUFFER_SIZE, "Invalid Xiron XN_STATUS_MESSAGE(XN_STATUS_INVALID_OUTPUT_FORMAT_FOR_RESOLUTION, "Pixel format is not supported for this resolution!") XN_PS_STATUS_MESSAGE_MAP_END(XN_ERROR_GROUP_FORMATS) -#endif //_XN_FORMATS_STATUS_H_ +#endif // XNFORMATSSTATUS_H diff --git a/Source/Drivers/PS1080/Include/XnIOFileStream.h b/Source/Drivers/PS1080/Include/XnIOFileStream.h index 996177c7..cef4a0cd 100644 --- a/Source/Drivers/PS1080/Include/XnIOFileStream.h +++ b/Source/Drivers/PS1080/Include/XnIOFileStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_IO_FILE_STREAM_H__ -#define __XN_IO_FILE_STREAM_H__ +#ifndef XNIOFILESTREAM_H +#define XNIOFILESTREAM_H //--------------------------------------------------------------------------- // Includes @@ -50,4 +50,4 @@ class XnIOFileStream : public XnIOStream XN_FILE_HANDLE m_hFile; }; -#endif //__XN_IO_FILE_STREAM_H__ \ No newline at end of file +#endif // XNIOFILESTREAM_H diff --git a/Source/Drivers/PS1080/Include/XnIONetworkStream.h b/Source/Drivers/PS1080/Include/XnIONetworkStream.h index 8bad4973..a74a6ea1 100644 --- a/Source/Drivers/PS1080/Include/XnIONetworkStream.h +++ b/Source/Drivers/PS1080/Include/XnIONetworkStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_IO_NETWORK_STREAM_H__ -#define __XN_IO_NETWORK_STREAM_H__ +#ifndef XNIONETWORKSTREAM_H +#define XNIONETWORKSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -50,4 +50,4 @@ class XnIONetworkStream : public XnIOStream }; -#endif //__XN_IO_NETWORK_STREAM_H__ \ No newline at end of file +#endif // XNIONETWORKSTREAM_H diff --git a/Source/Drivers/PS1080/Include/XnIOStream.h b/Source/Drivers/PS1080/Include/XnIOStream.h index b9194099..c9ef288d 100644 --- a/Source/Drivers/PS1080/Include/XnIOStream.h +++ b/Source/Drivers/PS1080/Include/XnIOStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_IO_STREAM_H__ -#define __XN_IO_STREAM_H__ +#ifndef XNIOSTREAM_H +#define XNIOSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -43,4 +43,4 @@ class XnIOStream virtual XnStatus Free() { return XN_STATUS_OK; } }; -#endif //__XN_IO_STREAM_H__ \ No newline at end of file +#endif // XNIOSTREAM_H diff --git a/Source/Drivers/PS1080/Include/XnPlatformBC.h b/Source/Drivers/PS1080/Include/XnPlatformBC.h index 669303f3..d82928b7 100644 --- a/Source/Drivers/PS1080/Include/XnPlatformBC.h +++ b/Source/Drivers/PS1080/Include/XnPlatformBC.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PS_PLATFORM_H__ -#define __XN_PS_PLATFORM_H__ +#ifndef XNPLATFORMBC_H +#define XNPLATFORMBC_H //--------------------------------------------------------------------------- // Includes @@ -52,4 +52,4 @@ _XN_DEPRECATED_TYPE(XnUInt, XN_ULONG) XN_API_DEPRECATED("Please use OniDepthPixel instead") typedef XnUInt16 XN_DEPTH_TYPE; XN_API_DEPRECATED("Please use XnRGB24Pixel instead") typedef XnUChar XN_IMAGE_TYPE; -#endif // __XN_PS_PLATFORM_H__ +#endif // XNPLATFORMBC_H diff --git a/Source/Drivers/PS1080/Include/XnPropertySet.h b/Source/Drivers/PS1080/Include/XnPropertySet.h index b6ae1584..b9d7942e 100644 --- a/Source/Drivers/PS1080/Include/XnPropertySet.h +++ b/Source/Drivers/PS1080/Include/XnPropertySet.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PROPERTY_SET_H__ -#define __XN_PROPERTY_SET_H__ +#ifndef XNPROPERTYSET_H +#define XNPROPERTYSET_H //--------------------------------------------------------------------------- // Includes @@ -247,4 +247,4 @@ XnStatus XnPropertySetEnumeratorGetStringValue(const XnPropertySetEnumerator* pE */ XnStatus XnPropertySetEnumeratorGetGeneralValue(const XnPropertySetEnumerator* pEnumerator, OniGeneralBuffer* pgbValue); -#endif //__XN_PROPERTY_SET_H__ +#endif // XNPROPERTYSET_H diff --git a/Source/Drivers/PS1080/Include/XnPsVersion.h b/Source/Drivers/PS1080/Include/XnPsVersion.h index 78dbc750..474c8f6e 100644 --- a/Source/Drivers/PS1080/Include/XnPsVersion.h +++ b/Source/Drivers/PS1080/Include/XnPsVersion.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_PS_VERSION_H_ -#define _XN_PS_VERSION_H_ +#ifndef XNPSVERSION_H +#define XNPSVERSION_H //--------------------------------------------------------------------------- // Includes @@ -32,11 +32,11 @@ /** Xiron major version. */ #define XN_PS_MAJOR_VERSION 5 /** Xiron minor version. */ -#define XN_PS_MINOR_VERSION 1 +#define XN_PS_MINOR_VERSION 2 /** Xiron maintenance version. */ -#define XN_PS_MAINTENANCE_VERSION 4 +#define XN_PS_MAINTENANCE_VERSION 0 /** Xiron build version. */ -#define XN_PS_BUILD_VERSION 1 +#define XN_PS_BUILD_VERSION 0 /** Xiron version (in brief string format): "Major.Minor.Maintenance (Build)" */ #define XN_PS_BRIEF_VERSION_STRING \ @@ -53,5 +53,5 @@ XN_PS_BRIEF_VERSION_STRING "-" \ XN_PLATFORM_STRING " (" XN_TIMESTAMP ")" -#endif //_XN_VERSION_H_ +#endif // XNPSVERSION_H diff --git a/Source/Drivers/PS1080/Include/XnStreamFormats.h b/Source/Drivers/PS1080/Include/XnStreamFormats.h index f0600cd7..3da64e02 100644 --- a/Source/Drivers/PS1080/Include/XnStreamFormats.h +++ b/Source/Drivers/PS1080/Include/XnStreamFormats.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_STREAM_FORMATS_H__ -#define __XN_STREAM_FORMATS_H__ +#ifndef XNSTREAMFORMATS_H +#define XNSTREAMFORMATS_H //--------------------------------------------------------------------------- // Includes @@ -47,4 +47,4 @@ typedef enum XN_COMPRESSION_10BIT_PACKED = 5, } XnCompressionFormats; -#endif //__XN_STREAM_FORMATS_H__ \ No newline at end of file +#endif // XNSTREAMFORMATS_H diff --git a/Source/Drivers/PS1080/Include/XnStreamParams.h b/Source/Drivers/PS1080/Include/XnStreamParams.h index d2c158ec..cc2033fb 100644 --- a/Source/Drivers/PS1080/Include/XnStreamParams.h +++ b/Source/Drivers/PS1080/Include/XnStreamParams.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_STREAM_PARAMS_H_ -#define _XN_STREAM_PARAMS_H_ +#ifndef XNSTREAMPARAMS_H +#define XNSTREAMPARAMS_H //--------------------------------------------------------------------------- // Includes @@ -116,6 +116,12 @@ enum /** Integer */ XN_STREAM_PROPERTY_DEVICE_MAX_DEPTH = 0x1080FF43, // "DeviceMaxDepth" + //--------------------------------------------------------------------------- + // IR Specific Properties + //--------------------------------------------------------------------------- + /** Integer */ + XN_STREAM_PROPERTY_DEVICE_MAX_IR = 0x1080FF48, // "DeviceMaxIR" + //--------------------------------------------------------------------------- // Image Specific Properties //--------------------------------------------------------------------------- @@ -257,4 +263,4 @@ typedef struct XnCmosPreset #pragma pack (pop) -#endif // _XN_STREAM_PARAMS_H_ +#endif // XNSTREAMPARAMS_H diff --git a/Source/Drivers/PS1080/Makefile b/Source/Drivers/PS1080/Makefile index fdcc2138..bb0b3da1 100644 --- a/Source/Drivers/PS1080/Makefile +++ b/Source/Drivers/PS1080/Makefile @@ -7,7 +7,6 @@ INC_DIRS = \ Include \ ../../../Include \ ../../../ThirdParty/PSCommon/XnLib/Include \ - ../../../ThirdParty/LibJPEG \ ../../DepthUtils SRC_FILES = \ @@ -17,13 +16,18 @@ SRC_FILES = \ Formats/*.cpp \ Include/*.cpp \ Sensor/*.cpp \ - ../../../ThirdParty/LibJPEG/*.c ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib - LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib + LDFLAGS += \ + -framework CoreFoundation \ + -framework IOKit endif LIB_NAME = PS1080 diff --git a/Source/Drivers/PS1080/PS1080.vcxproj b/Source/Drivers/PS1080/PS1080.vcxproj index 2a1154d5..ba0c96e4 100644 --- a/Source/Drivers/PS1080/PS1080.vcxproj +++ b/Source/Drivers/PS1080/PS1080.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,282 +19,6 @@ - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - - - Level3 - Level3 - Level3 - Level3 - @@ -306,7 +30,6 @@ - @@ -337,11 +60,9 @@ - - @@ -393,18 +114,6 @@ - - - - - - - - - - - - @@ -414,7 +123,6 @@ - @@ -442,16 +150,7 @@ - - - - - - - - - @@ -506,12 +205,6 @@ - - - - - - @@ -525,23 +218,27 @@ DynamicLibrary true Unicode + v120 DynamicLibrary true Unicode + v120 DynamicLibrary false true Unicode + v120 DynamicLibrary false true Unicode + v120 @@ -586,7 +283,7 @@ Level4 Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;PS1080_EXPORTS;%(PreprocessorDefinitions) - .\Include;.\;..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;..\..\..\ThirdParty\LibJPEG;..\..\DepthUtils + .\Include;.\;..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;..\..\DepthUtils true StreamingSIMDExtensions2 true @@ -637,7 +334,7 @@ MaxSpeed true WIN32;NDEBUG;_WINDOWS;_USRDLL;PS1080_EXPORTS;%(PreprocessorDefinitions) - .\Include;.\;..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;..\..\..\ThirdParty\LibJPEG;..\..\DepthUtils + .\Include;.\;..\..\..\Include;..\..\..\ThirdParty\PSCommon\XnLib\Include;..\..\DepthUtils;..\..\..\ThirdParty\PSCommon\XnLib\ThirdParty\LibJPEG true StreamingSIMDExtensions2 true diff --git a/Source/Drivers/PS1080/PS1080.vcxproj.filters b/Source/Drivers/PS1080/PS1080.vcxproj.filters index e379b10f..4a3cbbd5 100644 --- a/Source/Drivers/PS1080/PS1080.vcxproj.filters +++ b/Source/Drivers/PS1080/PS1080.vcxproj.filters @@ -16,9 +16,6 @@ {056c2231-a841-4ed6-bb9c-02a136a9a969} - - {bd2edebe-84b9-468d-bfe0-3040945cfe57} - {84a4c5d6-dca7-41c2-8465-5c0d981decde} @@ -51,9 +48,6 @@ Core - - Formats - Formats @@ -63,9 +57,6 @@ Formats - - Formats - DDK @@ -84,9 +75,6 @@ DDK - - DDK - DDK @@ -186,144 +174,6 @@ DriverImpl - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - DriverImpl @@ -467,36 +317,9 @@ Core - - Formats - - - Formats - - - Formats - - - Formats - - - Formats - Formats - - Formats - - - Formats - - - Formats - - - Formats - DDK @@ -518,9 +341,6 @@ DDK - - DDK - DDK @@ -617,42 +437,6 @@ DriverImpl - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - DriverImpl @@ -801,20 +585,6 @@ Sensor\Data Processors - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - - Formats\LibJPEG - - Resources diff --git a/Source/Drivers/PS1080/PS1080Console/Makefile b/Source/Drivers/PS1080/PS1080Console/Makefile index 4737d917..bce5e28f 100644 --- a/Source/Drivers/PS1080/PS1080Console/Makefile +++ b/Source/Drivers/PS1080/PS1080Console/Makefile @@ -14,9 +14,15 @@ LIB_DIRS = ../../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) USED_LIBS = XnLib OpenNI2 dl pthread ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib - LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib + LDFLAGS += \ + -framework CoreFoundation \ + -framework IOKit endif ifneq ("$(OSTYPE)","Darwin") diff --git a/Source/Drivers/PS1080/PS1080Console/PS1080Console.cpp b/Source/Drivers/PS1080/PS1080Console/PS1080Console.cpp index 99291100..6a163bcd 100644 --- a/Source/Drivers/PS1080/PS1080Console/PS1080Console.cpp +++ b/Source/Drivers/PS1080/PS1080Console/PS1080Console.cpp @@ -1,9 +1,9 @@ /***************************************************************************** * * -* PrimeSense Sensor 5.x Alpha * +* OpenNI 2.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * -* This file is part of PrimeSense Sensor * +* 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. * @@ -137,7 +137,7 @@ bool byebye(openni::Device& /*Device*/, vector& /*Command*/) return false; } -bool Version(openni::Device& Device, vector& /*Command*/) +bool PrintVersion(openni::Device& Device, vector& /*Command*/) { openni::Status rc = Device.getProperty(XN_MODULE_PROPERTY_VERSION, &g_DeviceVersion); if (rc != openni::STATUS_OK) @@ -219,6 +219,14 @@ bool Version(openni::Device& Device, vector& /*Command*/) { printf ("V5.7"); } + else if (g_DeviceVersion.FWVer == XN_SENSOR_FW_VER_5_8) + { + printf ("V5.8"); + } + else if (g_DeviceVersion.FWVer == XN_SENSOR_FW_VER_5_9) + { + printf ("V5.9"); + } else if (g_DeviceVersion.FWVer == XN_SENSOR_FW_VER_UNKNOWN) { printf ("Unknown"); @@ -1616,7 +1624,7 @@ bool StartReadData(openni::Device& Device, vector& Command) if (!g_colorStream.isValid()) { - rc = g_depthStream.create(Device, openni::SENSOR_COLOR); + rc = g_colorStream.create(Device, openni::SENSOR_COLOR); if (rc != openni::STATUS_OK) { printf("Can't create image stream: %s\n", openni::OpenNI::getExtendedError()); @@ -1673,7 +1681,7 @@ int main(int argc, char **argv) } vector DummyCommand; - Version(Device, DummyCommand); + PrintVersion(Device, DummyCommand); RegisterCB("exit", &byebye, "Exit interactive mode"); RegisterMnemonic("bye", "exit"); @@ -1694,7 +1702,7 @@ int main(int argc, char **argv) RegisterCB("script", &Script, "Run in batch mode"); RegisterMnemonic("-s", "script"); - RegisterCB("Version", &Version, "Get version"); + RegisterCB("Version", &PrintVersion, "Get version"); RegisterCB("FileList", &FileList, "Get File List"); RegisterMnemonic("dir", "FileList"); diff --git a/Source/Drivers/PS1080/PS1080Console/PS1080Console.vcxproj b/Source/Drivers/PS1080/PS1080Console/PS1080Console.vcxproj index b9adfeab..643a3be4 100644 --- a/Source/Drivers/PS1080/PS1080Console/PS1080Console.vcxproj +++ b/Source/Drivers/PS1080/PS1080Console/PS1080Console.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,19 +28,23 @@ Application MultiByte true + v120 Application MultiByte + v120 Application MultiByte true + v120 Application MultiByte + v120 @@ -96,6 +100,7 @@ Console MachineX86 true + false diff --git a/Source/Drivers/PS1080/Sensor/Bayer.h b/Source/Drivers/PS1080/Sensor/Bayer.h index d0093e44..1441d344 100644 --- a/Source/Drivers/PS1080/Sensor/Bayer.h +++ b/Source/Drivers/PS1080/Sensor/Bayer.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_BAYER_H_ -#define _XN_BAYER_H_ +#ifndef BAYER_H +#define BAYER_H //--------------------------------------------------------------------------- // Includes @@ -39,4 +39,4 @@ //--------------------------------------------------------------------------- void Bayer2RGB888(const XnUInt8* pBayerImage, XnUInt8* pRGBImage, XnUInt32 nXRes, XnUInt32 nYRes, XnUInt32 nDownSampleStep); -#endif //_XN_BAYER_H_ +#endif // BAYER_H diff --git a/Source/Drivers/PS1080/Sensor/IXnSensorStream.h b/Source/Drivers/PS1080/Sensor/IXnSensorStream.h index b12095ed..4186c4ad 100644 --- a/Source/Drivers/PS1080/Sensor/IXnSensorStream.h +++ b/Source/Drivers/PS1080/Sensor/IXnSensorStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __I_XN_SENSOR_STREAM_H__ -#define __I_XN_SENSOR_STREAM_H__ +#ifndef IXNSENSORSTREAM_H +#define IXNSENSORSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -48,4 +48,4 @@ class IXnSensorStream virtual XnStatus MapPropertiesToFirmware() = 0; }; -#endif //__I_XN_SENSOR_STREAM_H__ +#endif // IXNSENSORSTREAM_H diff --git a/Source/Drivers/PS1080/Sensor/Uncomp.h b/Source/Drivers/PS1080/Sensor/Uncomp.h index 85837cda..a0faf52d 100644 --- a/Source/Drivers/PS1080/Sensor/Uncomp.h +++ b/Source/Drivers/PS1080/Sensor/Uncomp.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_UNCOMP_H_ -#define _XN_UNCOMP_H_ +#ifndef UNCOMP_H +#define UNCOMP_H //--------------------------------------------------------------------------- // Includes @@ -40,4 +40,4 @@ XnStatus XnStreamUncompressYUVImagePS(const XnUInt8* pInput, const XnUInt32 nInp XnUInt8* pOutput, XnUInt32* pnOutputSize, XnUInt16 nLineSize, XnUInt32* pnActualRead, XnBool bLastPart); -#endif //_XN_UNCOMP_H_ +#endif // UNCOMP_H diff --git a/Source/Drivers/PS1080/Sensor/XnAudioProcessor.h b/Source/Drivers/PS1080/Sensor/XnAudioProcessor.h index e639a308..8021c93d 100644 --- a/Source/Drivers/PS1080/Sensor/XnAudioProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnAudioProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_AUDIO_PROCESSOR_H__ -#define __XN_AUDIO_PROCESSOR_H__ +#ifndef XNAUDIOPROCESSOR_H +#define XNAUDIOPROCESSOR_H #if 0 // Audio support @@ -70,4 +70,4 @@ class XnAudioProcessor : public XnWholePacketProcessor }; #endif // Audio support -#endif //__XN_AUDIO_PROCESSOR_H__ +#endif // XNAUDIOPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnBayerImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnBayerImageProcessor.h index 65f5f290..717be1ae 100644 --- a/Source/Drivers/PS1080/Sensor/XnBayerImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnBayerImageProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_BAYER_IMAGE_PROCESSOR_H__ -#define __XN_BAYER_IMAGE_PROCESSOR_H__ +#ifndef XNBAYERIMAGEPROCESSOR_H +#define XNBAYERIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -54,4 +54,4 @@ class XnBayerImageProcessor : public XnImageProcessor XnBuffer m_UncompressedBayerBuffer; }; -#endif //__XN_BAYER_IMAGE_PROCESSOR_H__ +#endif // XNBAYERIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnCmosInfo.h b/Source/Drivers/PS1080/Sensor/XnCmosInfo.h index 00ce0909..08fd7a81 100644 --- a/Source/Drivers/PS1080/Sensor/XnCmosInfo.h +++ b/Source/Drivers/PS1080/Sensor/XnCmosInfo.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_CMOS_INFO_H__ -#define __XN_CMOS_INFO_H__ +#ifndef XNCMOSINFO_H +#define XNCMOSINFO_H //--------------------------------------------------------------------------- // Includes @@ -57,4 +57,4 @@ class XnCmosInfo XnCmosBlankingCoefficients* m_pCurrCmosBlankingInfo[XN_CMOS_COUNT]; }; -#endif //__XN_CMOS_INFO_H__ +#endif // XNCMOSINFO_H diff --git a/Source/Drivers/PS1080/Sensor/XnDataProcessor.h b/Source/Drivers/PS1080/Sensor/XnDataProcessor.h index 5aa45ddb..e39adb1f 100644 --- a/Source/Drivers/PS1080/Sensor/XnDataProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnDataProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DATA_PROCESSOR_H__ -#define __XN_DATA_PROCESSOR_H__ +#ifndef XNDATAPROCESSOR_H +#define XNDATAPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -99,4 +99,4 @@ class XnDataProcessor XnBool m_bUseHostTimestamps; }; -#endif //__XN_DATA_PROCESSOR_H__ +#endif // XNDATAPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnDataProcessorHolder.h b/Source/Drivers/PS1080/Sensor/XnDataProcessorHolder.h index 06c41419..45cfba6a 100644 --- a/Source/Drivers/PS1080/Sensor/XnDataProcessorHolder.h +++ b/Source/Drivers/PS1080/Sensor/XnDataProcessorHolder.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_STREAM_PROCESSOR_HOLDER_H__ -#define __XN_STREAM_PROCESSOR_HOLDER_H__ +#ifndef XNDATAPROCESSORHOLDER_H +#define XNDATAPROCESSORHOLDER_H //--------------------------------------------------------------------------- // Includes @@ -50,4 +50,4 @@ class XnDataProcessorHolder XnDataProcessor* m_pProcessor; }; -#endif //__XN_STREAM_PROCESSOR_HOLDER_H__ \ No newline at end of file +#endif // XNDATAPROCESSORHOLDER_H diff --git a/Source/Drivers/PS1080/Sensor/XnDepthProcessor.h b/Source/Drivers/PS1080/Sensor/XnDepthProcessor.h index 19406332..193a3762 100644 --- a/Source/Drivers/PS1080/Sensor/XnDepthProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnDepthProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEPTH_PROCESSOR_H__ -#define __XN_DEPTH_PROCESSOR_H__ +#ifndef XNDEPTHPROCESSOR_H +#define XNDEPTHPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -89,4 +89,4 @@ class XnDepthProcessor : public XnFrameStreamProcessor OniDepthPixel m_noDepthValue; }; -#endif //__XN_DEPTH_PROCESSOR_H__ +#endif // XNDEPTHPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnDeviceEnumeration.h b/Source/Drivers/PS1080/Sensor/XnDeviceEnumeration.h index bfc99027..159acb86 100644 --- a/Source/Drivers/PS1080/Sensor/XnDeviceEnumeration.h +++ b/Source/Drivers/PS1080/Sensor/XnDeviceEnumeration.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_DEVICE_ENUMERATION_H_ -#define _XN_DEVICE_ENUMERATION_H_ +#ifndef XNDEVICEENUMERATION_H +#define XNDEVICEENUMERATION_H #include #include @@ -66,4 +66,4 @@ class XnDeviceEnumeration static XN_CRITICAL_SECTION_HANDLE ms_lock; }; -#endif \ No newline at end of file +#endif // XNDEVICEENUMERATION_H diff --git a/Source/Drivers/PS1080/Sensor/XnDeviceSensor.h b/Source/Drivers/PS1080/Sensor/XnDeviceSensor.h index 110f802a..6b12e74c 100644 --- a/Source/Drivers/PS1080/Sensor/XnDeviceSensor.h +++ b/Source/Drivers/PS1080/Sensor/XnDeviceSensor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_DEVICESENSOR_H_ -#define _XN_DEVICESENSOR_H_ +#ifndef XNDEVICESENSOR_H +#define XNDEVICESENSOR_H //--------------------------------------------------------------------------- // Includes @@ -53,6 +53,8 @@ #define XN_DEVICE_SENSOR_NO_DEPTH_VALUE 0 #define XN_DEVICE_SENSOR_MAX_SHIFT_VALUE 2048/*336*/ +#define XN_DEVICE_SENSOR_MAX_IR 1023 + #define XN_DEVICE_SENSOR_BOARDID_SEP ":" #define XN_DEVICE_SENSOR_DEFAULT_ID "*" @@ -499,4 +501,4 @@ typedef struct XnAudioSharedBuffer XnStatus XnDeviceSensorSetParam(XnDevicePrivateData* pDevicePrivateData, const XnChar* cpParamName, const XnInt32 nValue); -#endif +#endif // XNDEVICESENSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnDeviceSensorIO.h b/Source/Drivers/PS1080/Sensor/XnDeviceSensorIO.h index bb58ea12..41b3a600 100644 --- a/Source/Drivers/PS1080/Sensor/XnDeviceSensorIO.h +++ b/Source/Drivers/PS1080/Sensor/XnDeviceSensorIO.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_DEVICE_SENSOR_I_O_H__ -#define __XN_DEVICE_SENSOR_I_O_H__ +#ifndef XNDEVICESENSORIO_H +#define XNDEVICESENSORIO_H //--------------------------------------------------------------------------- // Includes @@ -97,4 +97,4 @@ class XnSensorIO void* m_pCallbackData; }; -#endif //__XN_DEVICE_SENSOR_I_O_H__ +#endif // XNDEVICESENSORIO_H diff --git a/Source/Drivers/PS1080/Sensor/XnDeviceSensorInit.h b/Source/Drivers/PS1080/Sensor/XnDeviceSensorInit.h index 031eb1b5..27b5c8bf 100644 --- a/Source/Drivers/PS1080/Sensor/XnDeviceSensorInit.h +++ b/Source/Drivers/PS1080/Sensor/XnDeviceSensorInit.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_DEVICESENSORINIT_H_ -#define _XN_DEVICESENSORINIT_H_ +#ifndef XNDEVICESENSORINIT_H +#define XNDEVICESENSORINIT_H //--------------------------------------------------------------------------- // Includes @@ -94,4 +94,4 @@ XnStatus XnDeviceSensorConfigure(XnDevicePrivateData* pDevicePrivateData); XnStatus XnDeviceSensorInitCmosData(XnDevicePrivateData* pDevicePrivateData); -#endif //_XN_DEVICESENSORINIT_H_ +#endif // XNDEVICESENSORINIT_H diff --git a/Source/Drivers/PS1080/Sensor/XnDeviceSensorProtocol.h b/Source/Drivers/PS1080/Sensor/XnDeviceSensorProtocol.h index 3c9b9c2d..894685e2 100644 --- a/Source/Drivers/PS1080/Sensor/XnDeviceSensorProtocol.h +++ b/Source/Drivers/PS1080/Sensor/XnDeviceSensorProtocol.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_DEVICESENSORPROTOCOL_H_ -#define _XN_DEVICESENSORPROTOCOL_H_ +#ifndef XNDEVICESENSORPROTOCOL_H +#define XNDEVICESENSORPROTOCOL_H //--------------------------------------------------------------------------- // Includes @@ -131,4 +131,4 @@ XnStatus XnDeviceSensorProtocolUpdateImageProcessor(XnDevicePrivateData* pDevice XN_THREAD_PROC XnDeviceSensorProtocolScriptThread(XN_THREAD_PARAM pThreadParam); -#endif //_XN_DEVICESENSORPROTOCOL_H_ +#endif // XNDEVICESENSORPROTOCOL_H diff --git a/Source/Drivers/PS1080/Sensor/XnFirmwareCommands.h b/Source/Drivers/PS1080/Sensor/XnFirmwareCommands.h index 65d6b369..e40aea2d 100644 --- a/Source/Drivers/PS1080/Sensor/XnFirmwareCommands.h +++ b/Source/Drivers/PS1080/Sensor/XnFirmwareCommands.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_FIRMWARE_COMMANDS_H__ -#define __XN_FIRMWARE_COMMANDS_H__ +#ifndef XNFIRMWARECOMMANDS_H +#define XNFIRMWARECOMMANDS_H //--------------------------------------------------------------------------- // Includes @@ -47,4 +47,4 @@ class XnFirmwareCommands XnDevicePrivateData* m_pDevicePrivateData; }; -#endif //__XN_FIRMWARE_COMMANDS_H__ \ No newline at end of file +#endif // XNFIRMWARECOMMANDS_H diff --git a/Source/Drivers/PS1080/Sensor/XnFirmwareInfo.h b/Source/Drivers/PS1080/Sensor/XnFirmwareInfo.h index 61dc0a1f..51de9fe8 100644 --- a/Source/Drivers/PS1080/Sensor/XnFirmwareInfo.h +++ b/Source/Drivers/PS1080/Sensor/XnFirmwareInfo.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_FIRMWARE_INFO_H__ -#define __XN_FIRMWARE_INFO_H__ +#ifndef XNFIRMWAREINFO_H +#define XNFIRMWAREINFO_H //--------------------------------------------------------------------------- // Includes @@ -122,4 +122,4 @@ class XnFirmwareInfo xnl::Array irModes; }; -#endif //__XN_FIRMWARE_INFO_H__ \ No newline at end of file +#endif // XNFIRMWAREINFO_H diff --git a/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.cpp b/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.cpp index 22a5fa46..9dc93c94 100644 --- a/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.cpp +++ b/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.cpp @@ -152,7 +152,8 @@ XnStatus XnFirmwareStreams::CheckClaimStream(const XnChar* strType, XnResolution if (pIRStreamData->pOwner != NULL) { // check res - if (pIRStreamData->nRes != nRes && (pIRStreamData->nRes != XN_RESOLUTION_SXGA || nRes != XN_RESOLUTION_VGA)) + if (pIRStreamData->nRes != nRes && + !(pIRStreamData->nRes == XN_RESOLUTION_SXGA && nRes == XN_RESOLUTION_VGA)) { XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Cannot set depth stream to resolution %d when IR is set to resolution %d!", nRes, pIRStreamData->nRes); } @@ -184,7 +185,8 @@ XnStatus XnFirmwareStreams::CheckClaimStream(const XnChar* strType, XnResolution if (pDepthStreamData->pOwner != NULL) { // check res - if (pDepthStreamData->nRes != nRes && (nRes != XN_RESOLUTION_SXGA || pDepthStreamData->nRes != XN_RESOLUTION_VGA)) + if (pDepthStreamData->nRes != nRes && + !(nRes == XN_RESOLUTION_SXGA && pDepthStreamData->nRes == XN_RESOLUTION_VGA)) { if (m_pDevicePrivateData->FWInfo.nFWVer < XN_SENSOR_FW_VER_5_6) { diff --git a/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.h b/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.h index 816de817..0aee9351 100644 --- a/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.h +++ b/Source/Drivers/PS1080/Sensor/XnFirmwareStreams.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_FIRMWARE_STREAMS_H__ -#define __XN_FIRMWARE_STREAMS_H__ +#ifndef XNFIRMWARESTREAMS_H +#define XNFIRMWARESTREAMS_H //--------------------------------------------------------------------------- // Includes @@ -83,4 +83,4 @@ class XnFirmwareStreams XnDataProcessorHolder m_GeneralDebugProcessor2; }; -#endif //__XN_FIRMWARE_STREAMS_H__ \ No newline at end of file +#endif // XNFIRMWARESTREAMS_H diff --git a/Source/Drivers/PS1080/Sensor/XnFirmwareTypes.h b/Source/Drivers/PS1080/Sensor/XnFirmwareTypes.h index 612fd39f..d3f4b067 100644 --- a/Source/Drivers/PS1080/Sensor/XnFirmwareTypes.h +++ b/Source/Drivers/PS1080/Sensor/XnFirmwareTypes.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_FIRMWARE_TYPES_H__ -#define __XN_FIRMWARE_TYPES_H__ +#ifndef XNFIRMWARETYPES_H +#define XNFIRMWARETYPES_H //--------------------------------------------------------------------------- // Includes @@ -35,4 +35,4 @@ typedef struct XnUInt32 nTimeInMicroSeconds; } XnTaskCPUInfo; -#endif //__XN_FIRMWARE_TYPES_H__ \ No newline at end of file +#endif // XNFIRMWARETYPES_H diff --git a/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.h b/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.h index 5a4d7159..ebf9702e 100644 --- a/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnFrameStreamProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_FRAME_STREAM_PROCESSOR_H__ -#define __XN_FRAME_STREAM_PROCESSOR_H__ +#ifndef XNFRAMESTREAMPROCESSOR_H +#define XNFRAMESTREAMPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -180,4 +180,4 @@ class XnFrameStreamProcessor : public XnStreamProcessor XnUInt64 m_nFirstPacketTimestamp; }; -#endif //__XN_FRAME_STREAM_PROCESSOR_H__ +#endif // XNFRAMESTREAMPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnGMCDebugProcessor.h b/Source/Drivers/PS1080/Sensor/XnGMCDebugProcessor.h index 75a87a7a..c247faa9 100644 --- a/Source/Drivers/PS1080/Sensor/XnGMCDebugProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnGMCDebugProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_GMC_DEBUG_PROCESSOR_H__ -#define __XN_GMC_DEBUG_PROCESSOR_H__ +#ifndef XNGMCDEBUGPROCESSOR_H +#define XNGMCDEBUGPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -51,4 +51,4 @@ class XnGMCDebugProcessor : public XnWholePacketProcessor XnUInt32 m_nGMCTime; }; -#endif //__XN_GMC_DEBUG_PROCESSOR_H__ +#endif // XNGMCDEBUGPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.cpp b/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.cpp index f79ef3a5..7853fdef 100644 --- a/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.cpp +++ b/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnGeneralDebugProcessor.h" #include diff --git a/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.h b/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.h index 9899793e..4fee3b4d 100644 --- a/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnGeneralDebugProcessor.h @@ -1,9 +1,9 @@ /***************************************************************************** * * -* PrimeSense Sensor 5.x Alpha * +* OpenNI 2.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * -* This file is part of PrimeSense Sensor * +* 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. * @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_GENERAL_DEBUG_PROCESSOR_H__ -#define __XN_GENERAL_DEBUG_PROCESSOR_H__ +#ifndef XNGENERALDEBUGPROCESSOR_H +#define XNGENERALDEBUGPROCESSOR_H #include "XnDataProcessor.h" @@ -36,4 +36,4 @@ class XnGeneralDebugProcessor : public XnDataProcessor XnDumpFile* m_pDump; }; -#endif // __XN_GENERAL_DEBUG_PROCESSOR_H__ \ No newline at end of file +#endif // XNGENERALDEBUGPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnHostProtocol.cpp b/Source/Drivers/PS1080/Sensor/XnHostProtocol.cpp index 6fd4c50f..a2f22cb6 100644 --- a/Source/Drivers/PS1080/Sensor/XnHostProtocol.cpp +++ b/Source/Drivers/PS1080/Sensor/XnHostProtocol.cpp @@ -82,7 +82,11 @@ inline XnInt32 CompareVersion(XnUInt8 nMajor1, XnUInt8 nMinor1, XnUInt16 nBuild1 static XnFWVer GetFWVersion(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nBuild) { - if (CompareVersion(nMajor, nMinor, nBuild, 5, 8, 0) >= 0) + if (CompareVersion(nMajor, nMinor, nBuild, 5, 9, 0) >= 0) + { + return XN_SENSOR_FW_VER_5_9; + } + else if (CompareVersion(nMajor, nMinor, nBuild, 5, 8, 0) >= 0) { return XN_SENSOR_FW_VER_5_8; } @@ -667,9 +671,9 @@ XnStatus XnHostProtocolInitFWParams(XnDevicePrivateData* pDevicePrivateData, XnU pDevicePrivateData->FWInfo.nISOLowDepthAlternativeInterface = 2; } - if (CompareVersion(nMajor, nMinor, nBuild, 5, 9, 0) >= 0) + if (CompareVersion(nMajor, nMinor, nBuild, 5, 10, 0) >= 0) { - xnLogWarning(XN_MASK_SENSOR_PROTOCOL, "Sensor version %d.%d.%x is newer than latest known. Trying to use 5.8 protocol...", nMajor, nMinor, nBuild); + xnLogWarning(XN_MASK_SENSOR_PROTOCOL, "Sensor version %d.%d.%x is newer than latest known. Trying to use 5.9 protocol...", nMajor, nMinor, nBuild); } // If FW is already known, update image modes @@ -2066,7 +2070,7 @@ XnStatus XnHostProtocolInitUpload(XnDevicePrivateData* pDevicePrivateData, XnUIn XnHostProtocolInitHeader(pDevicePrivateData, buffer, nHeaderSize+nReadFromFile, pDevicePrivateData->FWInfo.nOpcodeInitFileUpload); XnUInt16 nDataSize; - XnUInt32* pValue; + XnUInt32* pValue = 0; XnHostProtocolExecute(pDevicePrivateData, buffer, pDevicePrivateData->FWInfo.nProtocolHeaderSize + nHeaderSize + (XnUInt16)nReadFromFile, diff --git a/Source/Drivers/PS1080/Sensor/XnHostProtocol.h b/Source/Drivers/PS1080/Sensor/XnHostProtocol.h index 3837891a..d4f1479c 100644 --- a/Source/Drivers/PS1080/Sensor/XnHostProtocol.h +++ b/Source/Drivers/PS1080/Sensor/XnHostProtocol.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef HOST_PROTOCOL_H -#define HOST_PROTOCOL_H +#ifndef XNHOSTPROTOCOL_H +#define XNHOSTPROTOCOL_H #include #include "XnParams.h" @@ -373,4 +373,4 @@ XnStatus XnHostProtocolWriteI2C(XnDevicePrivateData* pDevicePrivateData, const X XnStatus XnHostProtocolReadI2C(XnDevicePrivateData* pDevicePrivateData, XnI2CReadData* pI2CReadData); XnStatus XnHostProtocolSetFileAttributes(XnDevicePrivateData* pDevicePrivateData, XnUInt16 nFileId, XnUInt16 nAttributes); -#endif +#endif // XNHOSTPROTOCOL_H diff --git a/Source/Drivers/PS1080/Sensor/XnIRProcessor.h b/Source/Drivers/PS1080/Sensor/XnIRProcessor.h index 7b646be7..2f0fb121 100644 --- a/Source/Drivers/PS1080/Sensor/XnIRProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnIRProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_IR_PROCESSOR_H__ -#define __XN_IR_PROCESSOR_H__ +#ifndef XNIRPROCESSOR_H +#define XNIRPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -69,4 +69,4 @@ class XnIRProcessor : public XnFrameStreamProcessor XnDepthCMOSType m_DepthCMOSType; }; -#endif //__XN_IR_PROCESSOR_H__ +#endif // XNIRPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnImageProcessor.h index 0f751635..3c76da44 100644 --- a/Source/Drivers/PS1080/Sensor/XnImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnImageProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_IMAGE_PROCESSOR_H__ -#define __XN_IMAGE_PROCESSOR_H__ +#ifndef XNIMAGEPROCESSOR_H +#define XNIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -73,4 +73,4 @@ class XnImageProcessor : public XnFrameStreamProcessor XnBool m_bCompressedOutput; }; -#endif //__XN_IMAGE_PROCESSOR_H__ +#endif // XNIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnJpegImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnJpegImageProcessor.h index c47583db..6a3cc836 100644 --- a/Source/Drivers/PS1080/Sensor/XnJpegImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnJpegImageProcessor.h @@ -18,14 +18,14 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_JPEG_IMAGE_PROCESSOR_H__ -#define __XN_JPEG_IMAGE_PROCESSOR_H__ +#ifndef XNJPEGIMAGEPROCESSOR_H +#define XNJPEGIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "XnImageProcessor.h" -#include +#include //--------------------------------------------------------------------------- // Code @@ -41,4 +41,4 @@ class XnJpegImageProcessor : public XnImageProcessor virtual void ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); }; -#endif // __XN_JPEG_IMAGE_PROCESSOR_H__ \ No newline at end of file +#endif // XNJPEGIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.cpp b/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.cpp index 3227ccda..5e0fc3e5 100644 --- a/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.cpp +++ b/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.cpp @@ -21,22 +21,23 @@ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- +#include #include "XnJpegToRGBImageProcessor.h" #include //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- - -XnJpegToRGBImageProcessor::XnJpegToRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) : - XnImageProcessor(pStream, pHelper, pBufferManager) +XnJpegToRGBImageProcessor::XnJpegToRGBImageProcessor(XnSensorImageStream* pStream, XnSensorStreamHelper* pHelper, XnFrameBufferManager* pBufferManager) +: XnImageProcessor(pStream, pHelper, pBufferManager) +, mp_JPEGContext(NULL) { SetAllowDoubleSOFPackets(TRUE); } XnJpegToRGBImageProcessor::~XnJpegToRGBImageProcessor() { - XnStreamFreeUncompressImageJ(&m_JPEGContext); + XnStreamFreeUncompressImageJ(&mp_JPEGContext); } XnStatus XnJpegToRGBImageProcessor::Init() @@ -48,7 +49,7 @@ XnStatus XnJpegToRGBImageProcessor::Init() XN_VALIDATE_BUFFER_ALLOCATE(m_RawData, GetExpectedOutputSize()); - nRetVal = XnStreamInitUncompressImageJ(&m_JPEGContext); + nRetVal = XnStreamInitUncompressImageJ(&mp_JPEGContext); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); @@ -88,7 +89,7 @@ void XnJpegToRGBImageProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeade XnBuffer* pWriteBuffer = GetWriteBuffer(); XnUInt32 nOutputSize = pWriteBuffer->GetMaxSize(); - XnStatus nRetVal = XnStreamUncompressImageJ(&m_JPEGContext, m_RawData.GetData(), m_RawData.GetSize(), pWriteBuffer->GetUnsafeWritePointer(), &nOutputSize); + XnStatus nRetVal = XnStreamUncompressImageJ(&mp_JPEGContext, m_RawData.GetData(), m_RawData.GetSize(), pWriteBuffer->GetUnsafeWritePointer(), &nOutputSize); if (nRetVal != XN_STATUS_OK) { xnLogWarning(XN_MASK_SENSOR_PROTOCOL_IMAGE, "Failed to uncompress JPEG for frame %d: %s (%d)\n", GetCurrentFrameID(), xnGetStatusString(nRetVal), pWriteBuffer->GetSize()); diff --git a/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.h index 5d3a4147..f32935c7 100644 --- a/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnJpegToRGBImageProcessor.h @@ -18,14 +18,14 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_JPEG_TO_RGB_IMAGE_PROCESSOR_H__ -#define __XN_JPEG_TO_RGB_IMAGE_PROCESSOR_H__ +#ifndef XNJPEGTORGBIMAGEPROCESSOR_H +#define XNJPEGTORGBIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- +#include #include "XnImageProcessor.h" -#include //--------------------------------------------------------------------------- // Code @@ -52,7 +52,7 @@ class XnJpegToRGBImageProcessor : public XnImageProcessor //--------------------------------------------------------------------------- private: XnBuffer m_RawData; - XnStreamUncompJPEGContext m_JPEGContext; + XnStreamUncompJPEGContext* mp_JPEGContext; }; -#endif //__XN_JPEG_TO_RGB_IMAGE_PROCESSOR_H__ +#endif // XNJPEGTORGBIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.cpp b/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.cpp index e2100785..557f4d9e 100644 --- a/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.cpp +++ b/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.cpp @@ -1,9 +1,9 @@ /***************************************************************************** * * -* PrimeSense Sensor 5.x Alpha * +* OpenNI 2.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * -* This file is part of PrimeSense Sensor * +* 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. * diff --git a/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.h b/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.h index 5276cc97..42d2a0b4 100644 --- a/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnNesaDebugProcessor.h @@ -1,9 +1,9 @@ /***************************************************************************** * * -* PrimeSense Sensor 5.x Alpha * +* OpenNI 2.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * -* This file is part of PrimeSense Sensor * +* 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. * @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_NESA_DEBUG_PROCESSOR_H__ -#define __XN_NESA_DEBUG_PROCESSOR_H__ +#ifndef XNNESADEBUGPROCESSOR_H +#define XNNESADEBUGPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -49,4 +49,4 @@ class XnNesaDebugProcessor : public XnWholePacketProcessor XnDumpFile* m_Dump; }; -#endif //__XN_NESA_DEBUG_PROCESSOR_H__ +#endif // XNNESADEBUGPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnPSCompressedDepthProcessor.h b/Source/Drivers/PS1080/Sensor/XnPSCompressedDepthProcessor.h index a8bab3a5..d05dc2df 100644 --- a/Source/Drivers/PS1080/Sensor/XnPSCompressedDepthProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnPSCompressedDepthProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PS_COMPRESSED_DEPTH_PROCESSOR_H__ -#define __XN_PS_COMPRESSED_DEPTH_PROCESSOR_H__ +#ifndef XNPSCOMPRESSEDDEPTHPROCESSOR_H +#define XNPSCOMPRESSEDDEPTHPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -63,4 +63,4 @@ class XnPSCompressedDepthProcessor : public XnDepthProcessor static void XN_CALLBACK_TYPE OnRequiredSizeChanged(); }; -#endif //__XN_PS_COMPRESSED_DEPTH_PROCESSOR_H__ +#endif // XNPSCOMPRESSEDDEPTHPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnPSCompressedImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnPSCompressedImageProcessor.h index e5575960..cf02dfd0 100644 --- a/Source/Drivers/PS1080/Sensor/XnPSCompressedImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnPSCompressedImageProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PS_COMPRESSED_IMAGE_PROCESSOR_H__ -#define __XN_PS_COMPRESSED_IMAGE_PROCESSOR_H__ +#ifndef XNPSCOMPRESSEDIMAGEPROCESSOR_H +#define XNPSCOMPRESSEDIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -54,4 +54,4 @@ class XnPSCompressedImageProcessor : public XnImageProcessor XnBuffer m_UncompressedYUVBuffer; }; -#endif //__XN_PS_COMPRESSED_IMAGE_PROCESSOR_H__ +#endif // XNPSCOMPRESSEDIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnPacked11DepthProcessor.h b/Source/Drivers/PS1080/Sensor/XnPacked11DepthProcessor.h index 58d500f0..034b9c3a 100644 --- a/Source/Drivers/PS1080/Sensor/XnPacked11DepthProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnPacked11DepthProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PACKED_11_DEPTH_PROCESSOR_H__ -#define __XN_PACKED_11_DEPTH_PROCESSOR_H__ +#ifndef XNPACKED11DEPTHPROCESSOR_H +#define XNPACKED11DEPTHPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -59,4 +59,4 @@ class XnPacked11DepthProcessor : public XnDepthProcessor XnBuffer m_ContinuousBuffer; }; -#endif //__XN_PACKED_11_DEPTH_PROCESSOR_H__ +#endif // XNPACKED11DEPTHPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnPacked12DepthProcessor.h b/Source/Drivers/PS1080/Sensor/XnPacked12DepthProcessor.h index 781214ca..afda39ae 100644 --- a/Source/Drivers/PS1080/Sensor/XnPacked12DepthProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnPacked12DepthProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_PACKED_12_DEPTH_PROCESSOR_H__ -#define __XN_PACKED_12_DEPTH_PROCESSOR_H__ +#ifndef XNPACKED12DEPTHPROCESSOR_H +#define XNPACKED12DEPTHPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -59,4 +59,4 @@ class XnPacked12DepthProcessor : public XnDepthProcessor XnBuffer m_ContinuousBuffer; }; -#endif //__XN_PACKED_12_DEPTH_PROCESSOR_H__ +#endif // XNPACKED12DEPTHPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnParams.h b/Source/Drivers/PS1080/Sensor/XnParams.h index b03ad993..ab0f6b11 100644 --- a/Source/Drivers/PS1080/Sensor/XnParams.h +++ b/Source/Drivers/PS1080/Sensor/XnParams.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef XN_PARAMS_H -#define XN_PARAMS_H +#ifndef XNPARAMS_H +#define XNPARAMS_H typedef enum { @@ -122,6 +122,7 @@ typedef enum PARAM_IMAGE_LOW_LIGHT_COMPENSATION_MODE = 82, PARAM_DEPTH_CLOSE_RANGE = 84, PARAM_FILE_SYSTEM_LOCK = 85, + PARAM_FAST_ZOOM_CROP = 86, } EConfig_Params; typedef enum XnExecuter @@ -131,4 +132,4 @@ typedef enum XnExecuter XN_EXECUTER_HOST = 2, } XnExecuter; -#endif +#endif // XNPARAMS_H diff --git a/Source/Drivers/PS1080/Sensor/XnPassThroughImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnPassThroughImageProcessor.h index b2d48f55..1f41883f 100644 --- a/Source/Drivers/PS1080/Sensor/XnPassThroughImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnPassThroughImageProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_UNCOMPRESSED_YUV_IMAGE_PROCESSOR_H__ -#define __XN_UNCOMPRESSED_YUV_IMAGE_PROCESSOR_H__ +#ifndef XNPASSTHROUGHIMAGEPROCESSOR_H +#define XNPASSTHROUGHIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -43,4 +43,4 @@ class XnPassThroughImageProcessor : public XnImageProcessor virtual void ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); }; -#endif //__XN_UNCOMPRESSED_YUV_IMAGE_PROCESSOR_H__ +#endif // XNPASSTHROUGHIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensor.cpp b/Source/Drivers/PS1080/Sensor/XnSensor.cpp index 7f74a40f..abba8e8e 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensor.cpp +++ b/Source/Drivers/PS1080/Sensor/XnSensor.cpp @@ -100,6 +100,7 @@ XnSensor::XnSensor(XnBool bResetOnStartup /* = TRUE */, XnBool bLeanInit /* = FA m_FirmwareCPUInterval(XN_MODULE_PROPERTY_FIRMWARE_CPU_INTERVAL, "FirmwareCPUInterval", 0), m_APCEnabled(XN_MODULE_PROPERTY_APC_ENABLED, "APCEnabled", TRUE), m_FirmwareTecDebugPrint(XN_MODULE_PROPERTY_FIRMWARE_TEC_DEBUG_PRINT, "TecDebugPrint", FALSE), + m_ReadAllEndpoints(XN_MODULE_PROPERTY_READ_ALL_ENDPOINTS, "ReadAllEndpoints", 0), m_I2C(XN_MODULE_PROPERTY_I2C, "I2C", NULL), m_DeleteFile(XN_MODULE_PROPERTY_DELETE_FILE, "DeleteFile"), m_TecSetPoint(XN_MODULE_PROPERTY_TEC_SET_POINT, "TecSetPoint"), @@ -178,6 +179,7 @@ XnSensor::XnSensor(XnBool bResetOnStartup /* = TRUE */, XnBool bLeanInit /* = FA m_BIST.UpdateSetCallback(RunBISTCallback, this); m_ProjectorFault.UpdateSetCallback(SetProjectorFaultCallback, this); m_FirmwareTecDebugPrint.UpdateSetCallbackToDefault(); + m_ReadAllEndpoints.UpdateSetCallback(SetReadAllEndpointsCallback, this); // Clear the frame-synced streams. m_nFrameSyncEnabled = FALSE; @@ -376,7 +378,7 @@ XnStatus XnSensor::CreateDeviceModule(XnDeviceModuleHolder** ppModuleHolder) &m_FirmwareLogInterval, &m_FirmwareLogPrint, &m_FirmwareCPUInterval, &m_DeleteFile, &m_APCEnabled, &m_TecSetPoint, &m_TecStatus, &m_TecFastConvergenceStatus, &m_EmitterSetPoint, &m_EmitterStatus, &m_I2C, &m_FileAttributes, &m_FlashFile, &m_FirmwareLogFilter, &m_FirmwareLog, &m_FlashChunk, &m_FileList, - &m_ProjectorFault, &m_BIST, &m_FirmwareTecDebugPrint, &m_DeviceName + &m_ProjectorFault, &m_BIST, &m_FirmwareTecDebugPrint, &m_DeviceName, &m_ReadAllEndpoints }; nRetVal = pModule->AddProperties(pProps, sizeof(pProps)/sizeof(XnProperty*)); @@ -700,10 +702,34 @@ XnStatus XnSensor::ValidateSensorID(XnChar* csSensorID) XnStatus XnSensor::ResolveGlobalConfigFileName(XnChar* strConfigFile, XnUInt32 nBufSize, const XnChar* strConfigDir) { + XnStatus rc = XN_STATUS_OK; + // If strConfigDir is NULL, tries to resolve the config file based on the driver's directory XnChar strBaseDir[XN_FILE_MAX_PATH]; if (strConfigDir == NULL) { +#if XN_PLATFORM == XN_PLATFORM_ANDROID_ARM + // support for applications + xnOSGetApplicationFilesDir(strBaseDir, nBufSize); + + XnChar strTempFileName[XN_FILE_MAX_PATH]; + xnOSStrCopy(strTempFileName, strBaseDir, sizeof(strTempFileName)); + rc = xnOSAppendFilePath(strTempFileName, XN_GLOBAL_CONFIG_FILE_NAME, sizeof(strTempFileName)); + XN_IS_STATUS_OK(rc); + + XnBool bExists; + xnOSDoesFileExist(strTempFileName, &bExists); + + if (bExists) + { + strConfigDir = strBaseDir; + } + else + { + // support for native use - search in current dir + strConfigDir = "."; + } +#else if (xnOSGetModulePathForProcAddress(reinterpret_cast(&XnSensor::ResolveGlobalConfigFileName), strBaseDir) == XN_STATUS_OK && xnOSGetDirName(strBaseDir, strBaseDir, XN_FILE_MAX_PATH) == XN_STATUS_OK) { @@ -715,9 +741,9 @@ XnStatus XnSensor::ResolveGlobalConfigFileName(XnChar* strConfigFile, XnUInt32 n // Something wrong happened. Use the current directory as the fallback. strConfigDir = "."; } +#endif } - XnStatus rc; XN_VALIDATE_STR_COPY(strConfigFile, strConfigDir, nBufSize, rc); return xnOSAppendFilePath(strConfigFile, XN_GLOBAL_CONFIG_FILE_NAME, nBufSize); } @@ -1076,6 +1102,42 @@ XnStatus XnSensor::RunBIST(XnUInt32 nTestsMask, XnUInt32* pnFailures) return (XN_STATUS_OK); } +XnStatus XnSensor::SetReadAllEndpoints(XnBool bEnabled) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (m_ReadAllEndpoints.GetValue() == (XnUInt64)bEnabled) + { + return XN_STATUS_OK; + } + + if (bEnabled) + { + xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Creating USB depth read thread..."); + XnSpecificUsbDevice* pUSB = m_DevicePrivateData.pSpecificDepthUsb; + nRetVal = xnUSBInitReadThread(pUSB->pUsbConnection->UsbEp, pUSB->nChunkReadBytes, pUSB->nNumberOfBuffers, pUSB->nTimeout, XnDeviceSensorProtocolUsbEpCb, pUSB); + XN_IS_STATUS_OK(nRetVal); + + xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Creating USB image read thread..."); + pUSB = m_DevicePrivateData.pSpecificImageUsb; + nRetVal = xnUSBInitReadThread(pUSB->pUsbConnection->UsbEp, pUSB->nChunkReadBytes, pUSB->nNumberOfBuffers, pUSB->nTimeout, XnDeviceSensorProtocolUsbEpCb, pUSB); + XN_IS_STATUS_OK(nRetVal); + } + else + { + xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Shutting down USB depth read thread..."); + xnUSBShutdownReadThread(m_DevicePrivateData.pSpecificDepthUsb->pUsbConnection->UsbEp); + + xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Shutting down USB image read thread..."); + xnUSBShutdownReadThread(m_DevicePrivateData.pSpecificImageUsb->pUsbConnection->UsbEp); + } + + nRetVal = m_ReadAllEndpoints.UnsafeUpdateValue(bEnabled); + XN_IS_STATUS_OK(nRetVal); + + return (XN_STATUS_OK); +} + XnStatus XnSensor::SetErrorState(XnStatus errorState) { XnStatus nRetVal = XN_STATUS_OK; @@ -1831,6 +1893,12 @@ XnStatus XN_CALLBACK_TYPE XnSensor::SetFirmwareCPUIntervalCallback(XnActualIntPr return pThis->SetFirmwareCPUInterval((XnUInt32)nValue); } +XnStatus XN_CALLBACK_TYPE XnSensor::SetReadAllEndpointsCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) +{ + XnSensor* pThis = (XnSensor*)pCookie; + return pThis->SetReadAllEndpoints((XnBool)nValue); +} + XnStatus XN_CALLBACK_TYPE XnSensor::SetAPCEnabledCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) { XnSensor* pThis = (XnSensor*)pCookie; diff --git a/Source/Drivers/PS1080/Sensor/XnSensor.h b/Source/Drivers/PS1080/Sensor/XnSensor.h index 40b52858..4704f926 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensor.h +++ b/Source/Drivers/PS1080/Sensor/XnSensor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_H__ -#define __XN_SENSOR_H__ +#ifndef XNSENSOR_H +#define XNSENSOR_H //--------------------------------------------------------------------------- // Includes @@ -165,6 +165,7 @@ class XnSensor : public XnDeviceBase XnStatus WriteFlashFile(const XnParamFileData* pFile); XnStatus SetProjectorFault(XnProjectorFaultData* pProjectorFaultData); XnStatus RunBIST(XnUInt32 nTestsMask, XnUInt32* pnFailures); + XnStatus SetReadAllEndpoints(XnBool bEnabled); //--------------------------------------------------------------------------- // Callbacks @@ -202,6 +203,7 @@ class XnSensor : public XnDeviceBase static XnStatus XN_CALLBACK_TYPE SetFirmwareLogIntervalCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetFirmwareLogPrintCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetFirmwareCPUIntervalCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetReadAllEndpointsCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetAPCEnabledCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetI2CCallback(XnGeneralProperty* pSender, const OniGeneralBuffer& gbValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE DeleteFileCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie); @@ -259,6 +261,7 @@ class XnSensor : public XnDeviceBase XnActualIntProperty m_FirmwareCPUInterval; XnActualIntProperty m_APCEnabled; XnActualIntProperty m_FirmwareTecDebugPrint; + XnActualIntProperty m_ReadAllEndpoints; XnGeneralProperty m_I2C; XnIntProperty m_DeleteFile; XnIntProperty m_TecSetPoint; @@ -304,4 +307,4 @@ class XnSensor : public XnDeviceBase XnChar m_strGlobalConfigFile[XN_FILE_MAX_PATH]; }; -#endif //__XN_SENSOR_H__ \ No newline at end of file +#endif // XNSENSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorAudioStream.h b/Source/Drivers/PS1080/Sensor/XnSensorAudioStream.h index ab45c9d9..693adb0d 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorAudioStream.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorAudioStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_AUDIO_STREAM_H__ -#define __XN_SENSOR_AUDIO_STREAM_H__ +#ifndef XNSENSORAUDIOSTREAM_H +#define XNSENSORAUDIOSTREAM_H #if 0 // Audio support @@ -119,4 +119,4 @@ class XnSensorAudioStream : public XnAudioStream, public IXnSensorStream }; #endif // Audio support -#endif //__XN_SENSOR_AUDIO_STREAM_H__ +#endif // XNSENSORAUDIOSTREAM_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.cpp b/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.cpp index 445eaa9c..ec168efa 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.cpp +++ b/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.cpp @@ -632,7 +632,7 @@ XnStatus XnSensorDepthStream::SetRegistrationType(XnProcessingType type) { XnStatus nRetVal = XN_STATUS_OK; - if (type != m_RegistrationType.GetValue()) + if (type != (XnProcessingType)m_RegistrationType.GetValue()) { nRetVal = DecideFirmwareRegistration((XnBool)m_DepthRegistration.GetValue(), type, GetResolution()); XN_IS_STATUS_OK(nRetVal); diff --git a/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.h b/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.h index 3f773d38..d835ba30 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorDepthStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_DEPTH_STREAM_H__ -#define __XN_SENSOR_DEPTH_STREAM_H__ +#ifndef XNSENSORDEPTHSTREAM_H +#define XNSENSORDEPTHSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -189,4 +189,4 @@ class XnSensorDepthStream : public XnDepthStream, public IXnSensorStream XnCallbackHandle m_hReferenceSizeChangedCallback; }; -#endif //__XN_SENSOR_DEPTH_STREAM_H__ +#endif // XNSENSORDEPTHSTREAM_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorFPS.cpp b/Source/Drivers/PS1080/Sensor/XnSensorFPS.cpp index 379eefa4..bb43cc4b 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorFPS.cpp +++ b/Source/Drivers/PS1080/Sensor/XnSensorFPS.cpp @@ -38,24 +38,16 @@ XnSensorFPS::XnSensorFPS() : m_nLastPrint(0), m_FramesDump(NULL) { - xnFPSInit(&m_depth, XN_SENSOR_FPS_FRAME_COUNT); - xnFPSInit(&m_color, XN_SENSOR_FPS_FRAME_COUNT); - xnFPSInit(&m_ir, XN_SENSOR_FPS_FRAME_COUNT); - m_FramesDump = xnDumpFileOpen(XN_MASK_SENSOR_FPS, "FramesTimes.csv"); xnDumpFileWriteString(m_FramesDump, "TS,Type,FrameID,FrameTS\n"); } XnSensorFPS::~XnSensorFPS() { - xnFPSFree(&m_depth); - xnFPSFree(&m_color); - xnFPSFree(&m_ir); - xnDumpFileClose(m_FramesDump); } -void XnSensorFPS::Mark(XnFPSData* pFPS, const XnChar* csName, XnUInt32 nFrameID, XnUInt64 nTS) +void XnSensorFPS::Mark(XnFPSData* /*pFPS*/, const XnChar* csName, XnUInt32 nFrameID, XnUInt64 nTS) { if (!xnLogIsEnabled(XN_MASK_SENSOR_FPS, XN_LOG_VERBOSE)) return; @@ -63,17 +55,5 @@ void XnSensorFPS::Mark(XnFPSData* pFPS, const XnChar* csName, XnUInt32 nFrameID, XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); - xnFPSMarkFrame(pFPS, nNow); - xnDumpFileWriteString(m_FramesDump, "%llu,%s,%u,%llu\n", nNow, csName, nFrameID, nTS); - - // get current time in seconds - nNow /= 1000000; - - if (nNow != m_nLastPrint) - { - m_nLastPrint = nNow; - xnLogVerbose(XN_MASK_SENSOR_FPS, "[FPS] Frames - C: %5.2f, D: %5.2f, I: %5.2f", - xnFPSCalc(&m_color), xnFPSCalc(&m_depth), xnFPSCalc(&m_ir)); - } } diff --git a/Source/Drivers/PS1080/Sensor/XnSensorFPS.h b/Source/Drivers/PS1080/Sensor/XnSensorFPS.h index 9afef6a4..d3346acb 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorFPS.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorFPS.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_FPS_H__ -#define __XN_SENSOR_FPS_H__ +#ifndef XNSENSORFPS_H +#define XNSENSORFPS_H //--------------------------------------------------------------------------- // Includes @@ -55,4 +55,4 @@ class XnSensorFPS XnDumpFile* m_FramesDump; }; -#endif //__XN_SENSOR_FPS_H__ +#endif // XNSENSORFPS_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorFirmware.h b/Source/Drivers/PS1080/Sensor/XnSensorFirmware.h index e5a79d87..940eb5f3 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorFirmware.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorFirmware.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_FIRMWARE_H__ -#define __XN_SENSOR_FIRMWARE_H__ +#ifndef XNSENSORFIRMWARE_H +#define XNSENSORFIRMWARE_H //--------------------------------------------------------------------------- // Includes @@ -56,4 +56,4 @@ class XnSensorFirmware XnDevicePrivateData* m_pDevicePrivateData; }; -#endif //__XN_SENSOR_FIRMWARE_H__ \ No newline at end of file +#endif // XNSENSORFIRMWARE_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp b/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp index f93f333f..abb1f842 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp +++ b/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.cpp @@ -82,6 +82,7 @@ XnSensorFirmwareParams::XnSensorFirmwareParams(XnFirmwareInfo* pInfo, XnFirmware m_ImageLowLightCompensation(0, "ImageLowLightCompensation"), m_ImageGain(0, "ImageGain"), m_DepthCloseRange(0, "CloseRange"), + m_FastZoomCrop(0, "FastZoomCrop"), m_LogFilter(0, "LogFilter"), m_GMCDebug(0, "GMCDebug"), m_APCEnabled(0, "APCEnabled"), @@ -209,6 +210,8 @@ XnStatus XnSensorFirmwareParams::Init() XN_IS_STATUS_OK(nRetVal); nRetVal = AddFirmwareParam( m_DepthCloseRange, PARAM_DEPTH_CLOSE_RANGE, XN_SENSOR_FW_VER_5_6, XN_SENSOR_FW_VER_UNKNOWN, FALSE); XN_IS_STATUS_OK(nRetVal); + nRetVal = AddFirmwareParam( m_FastZoomCrop, PARAM_FAST_ZOOM_CROP, XN_SENSOR_FW_VER_5_9, XN_SENSOR_FW_VER_UNKNOWN, FALSE); + XN_IS_STATUS_OK(nRetVal); nRetVal = AddFirmwareParam( m_LogFilter, PARAM_MISC_LOG_FILTER); XN_IS_STATUS_OK(nRetVal); nRetVal = AddFirmwareParam( m_GMCDebug, PARAM_GMC_DEBUG, XN_SENSOR_FW_VER_5_0, XN_SENSOR_FW_VER_UNKNOWN, FALSE); diff --git a/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.h b/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.h index 6c10a5c7..b923cb06 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorFirmwareParams.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_FIRMWARE_PARAMS_H__ -#define __XN_SENSOR_FIRMWARE_PARAMS_H__ +#ifndef XNSENSORFIRMWAREPARAMS_H +#define XNSENSORFIRMWAREPARAMS_H //--------------------------------------------------------------------------- // Includes @@ -108,6 +108,7 @@ class XnSensorFirmwareParams XnActualIntProperty m_ImageLowLightCompensation; XnActualIntProperty m_ImageGain; XnActualIntProperty m_DepthCloseRange; + XnActualIntProperty m_FastZoomCrop; XnActualIntProperty m_LogFilter; XnActualIntProperty m_GMCDebug; XnActualIntProperty m_APCEnabled; @@ -158,4 +159,4 @@ class XnSensorFirmwareParams XnPropertyToValueHash m_Transaction; // maps a property to its new value }; -#endif //__XN_SENSOR_FIRMWARE_PARAMS_H__ +#endif // XNSENSORFIRMWAREPARAMS_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorFixedParams.h b/Source/Drivers/PS1080/Sensor/XnSensorFixedParams.h index 61f6a8e6..5941ae3a 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorFixedParams.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorFixedParams.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_FIXED_PARAMS_H__ -#define __XN_SENSOR_FIXED_PARAMS_H__ +#ifndef XNSENSORFIXEDPARAMS_H +#define XNSENSORFIXEDPARAMS_H //--------------------------------------------------------------------------- // Includes @@ -84,4 +84,4 @@ class XnSensorFixedParams XnChar m_strPlatformString[XN_DEVICE_MAX_STRING_LENGTH]; }; -#endif //__XN_SENSOR_FIXED_PARAMS_H__ \ No newline at end of file +#endif // XNSENSORFIXEDPARAMS_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorIRStream.cpp b/Source/Drivers/PS1080/Sensor/XnSensorIRStream.cpp index 31e390c7..789afdd1 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorIRStream.cpp +++ b/Source/Drivers/PS1080/Sensor/XnSensorIRStream.cpp @@ -36,7 +36,7 @@ // XnSensorIRStream class //--------------------------------------------------------------------------- XnSensorIRStream::XnSensorIRStream(const XnChar* StreamName, XnSensorObjects* pObjects) : - XnIRStream(StreamName, FALSE), + XnIRStream(StreamName, FALSE, XN_DEVICE_SENSOR_MAX_IR), m_InputFormat(XN_STREAM_PROPERTY_INPUT_FORMAT, "InputFormat", 0), m_CroppingMode(XN_STREAM_PROPERTY_CROPPING_MODE, "CroppingMode", XN_CROPPING_MODE_NORMAL), m_Helper(pObjects), @@ -60,7 +60,7 @@ XnStatus XnSensorIRStream::Init() // init base nRetVal = XnIRStream::Init(); - XN_IS_STATUS_OK(nRetVal); + XN_IS_STATUS_OK(nRetVal); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_ActualRead, &m_CroppingMode); @@ -251,11 +251,13 @@ XnStatus XnSensorIRStream::SetOutputFormat(OniPixelFormat nOutputFormat) switch (nOutputFormat) { case ONI_PIXEL_FORMAT_RGB888: - case ONI_PIXEL_FORMAT_GRAY16: - break; + case ONI_PIXEL_FORMAT_GRAY16: + nRetVal = DeviceMaxIRProperty().UnsafeUpdateValue(XN_DEVICE_SENSOR_MAX_IR); + break; default: XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DEVICE_SENSOR, "Unsupported IR output format: %d", nOutputFormat); } + XN_IS_STATUS_OK(nRetVal); nRetVal = m_Helper.BeforeSettingDataProcessorProperty(); XN_IS_STATUS_OK(nRetVal); diff --git a/Source/Drivers/PS1080/Sensor/XnSensorIRStream.h b/Source/Drivers/PS1080/Sensor/XnSensorIRStream.h index cf217c16..56f0ae26 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorIRStream.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorIRStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_IR_STREAM_H__ -#define __XN_SENSOR_IR_STREAM_H__ +#ifndef XNSENSORIRSTREAM_H +#define XNSENSORIRSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -106,4 +106,4 @@ class XnSensorIRStream : public XnIRStream, public IXnSensorStream }; -#endif //__XN_SENSOR_IR_STREAM_H__ +#endif // XNSENSORIRSTREAM_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorImageStream.cpp b/Source/Drivers/PS1080/Sensor/XnSensorImageStream.cpp index 6db13486..cd035c26 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorImageStream.cpp +++ b/Source/Drivers/PS1080/Sensor/XnSensorImageStream.cpp @@ -36,6 +36,7 @@ #include "Bayer.h" #include #include +#include //--------------------------------------------------------------------------- // XnSensorImageStream class @@ -59,6 +60,7 @@ XnSensorImageStream::XnSensorImageStream(const XnChar* StreamName, XnSensorObjec m_Exposure(ONI_STREAM_PROPERTY_EXPOSURE, "Exposure", XN_IMAGE_STREAM_DEFAULT_EXPOSURE_BAR), m_Gain(ONI_STREAM_PROPERTY_GAIN, "Gain", XN_IMAGE_STREAM_DEFAULT_GAIN), + m_FastZoomCrop(XN_STREAM_PROPERTY_FAST_ZOOM_CROP, "FastZoomCrop", false), m_ActualRead(XN_STREAM_PROPERTY_ACTUAL_READ_DATA, "ActualReadData", FALSE), m_HorizontalFOV(ONI_STREAM_PROPERTY_HORIZONTAL_FOV, "HorizontalFov"), @@ -84,12 +86,13 @@ XnStatus XnSensorImageStream::Init() m_AutoExposure.UpdateSetCallback(SetAutoExposureCallback, this); m_Exposure.UpdateSetCallback(SetExposureCallback, this); m_Gain.UpdateSetCallback(SetGainCallback, this); + m_FastZoomCrop.UpdateSetCallback(SetFastZoomCropCallback, this); m_AutoWhiteBalance.UpdateSetCallback(SetAutoWhiteBalanceCallback, this); m_ActualRead.UpdateSetCallback(SetActualReadCallback, this); // add properties XN_VALIDATE_ADD_PROPERTIES(this, &m_InputFormat, &m_AntiFlicker, &m_ImageQuality, - &m_CroppingMode, &m_ActualRead, &m_HorizontalFOV, &m_VerticalFOV, &m_AutoExposure, &m_AutoWhiteBalance, &m_Exposure, &m_Gain); + &m_CroppingMode, &m_ActualRead, &m_HorizontalFOV, &m_VerticalFOV, &m_AutoExposure, &m_AutoWhiteBalance, &m_Exposure, &m_Gain, &m_FastZoomCrop); // set base properties default values nRetVal = ResolutionProperty().UnsafeUpdateValue(XN_IMAGE_STREAM_DEFAULT_RESOLUTION); @@ -216,6 +219,8 @@ XnStatus XnSensorImageStream::MapPropertiesToFirmware() XN_IS_STATUS_OK(nRetVal);; nRetVal = m_Helper.MapFirmwareProperty(m_Gain, GetFirmwareParams()->m_ImageGain, TRUE); XN_IS_STATUS_OK(nRetVal);; + nRetVal = m_Helper.MapFirmwareProperty(m_FastZoomCrop, GetFirmwareParams()->m_FastZoomCrop, TRUE); + XN_IS_STATUS_OK(nRetVal);; return (XN_STATUS_OK); } @@ -754,6 +759,14 @@ XnStatus XnSensorImageStream::SetGain(XnUInt64 nValue) return (XN_STATUS_OK); } +XnStatus XnSensorImageStream::SetFastZoomCrop(XnBool bFastZoomCrop) +{ + XnStatus nRetVal = XN_STATUS_OK; + + nRetVal = m_Helper.SimpleSetFirmwareParam(m_FastZoomCrop, (XnUInt16)bFastZoomCrop); + + return nRetVal; +} XnStatus XnSensorImageStream::CropImpl(OniFrame* pFrame, const OniCropping* pCropping) { @@ -940,4 +953,9 @@ XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetGainCallback(XnActualIntProper { XnSensorImageStream* pStream = (XnSensorImageStream*)pCookie; return pStream->SetGain(nValue); -} \ No newline at end of file +} +XnStatus XN_CALLBACK_TYPE XnSensorImageStream::SetFastZoomCropCallback(XnActualIntProperty* /*pSender*/, XnUInt64 nValue, void* pCookie) +{ + XnSensorImageStream* pStream = (XnSensorImageStream*)pCookie; + return pStream->SetFastZoomCrop((XnBool)nValue); +} diff --git a/Source/Drivers/PS1080/Sensor/XnSensorImageStream.h b/Source/Drivers/PS1080/Sensor/XnSensorImageStream.h index 5d30c7cc..ede5f5f5 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorImageStream.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorImageStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_IMAGE_STREAM_H__ -#define __XN_SENSOR_IMAGE_STREAM_H__ +#ifndef XNSENSORIMAGESTREAM_H +#define XNSENSORIMAGESTREAM_H //--------------------------------------------------------------------------- // Includes @@ -112,6 +112,7 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream virtual XnStatus SetAutoWhiteBalance(XnBool bAutoWhiteBalance); virtual XnStatus SetExposure(XnUInt64 nValue); virtual XnStatus SetGain(XnUInt64 nValue); + virtual XnStatus SetFastZoomCrop(XnBool bFastZoomCrop); private: XnStatus ValidateMode(); XnStatus SetCroppingImpl(const OniCropping* pCropping, XnCroppingMode mode); @@ -127,6 +128,7 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream static XnStatus XN_CALLBACK_TYPE SetAutoWhiteBalanceCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetExposureCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); static XnStatus XN_CALLBACK_TYPE SetGainCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie); + static XnStatus XN_CALLBACK_TYPE SetFastZoomCropCallback(XnActualIntProperty* pSendoer, XnUInt64 nValue, void* pCookie); //--------------------------------------------------------------------------- // Members @@ -149,6 +151,7 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream XnActualIntProperty m_AutoWhiteBalance; XnActualIntProperty m_Exposure; XnActualIntProperty m_Gain; + XnActualIntProperty m_FastZoomCrop; XnActualIntProperty m_ActualRead; @@ -156,4 +159,4 @@ class XnSensorImageStream : public XnImageStream, public IXnSensorStream XnActualRealProperty m_VerticalFOV; }; -#endif //__XN_SENSOR_IMAGE_STREAM_H__ +#endif // XNSENSORIMAGESTREAM_H diff --git a/Source/Drivers/PS1080/Sensor/XnSensorStreamHelper.h b/Source/Drivers/PS1080/Sensor/XnSensorStreamHelper.h index 947ec212..3c99f519 100644 --- a/Source/Drivers/PS1080/Sensor/XnSensorStreamHelper.h +++ b/Source/Drivers/PS1080/Sensor/XnSensorStreamHelper.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_SENSOR_STREAM_HELPER_H__ -#define __XN_SENSOR_STREAM_HELPER_H__ +#ifndef XNSENSORSTREAMHELPER_H +#define XNSENSORSTREAMHELPER_H //--------------------------------------------------------------------------- // Includes @@ -140,4 +140,4 @@ class XnSensorStreamHolder : public XnDeviceModuleHolder XnSensorStreamHelper* m_pHelper; }; -#endif //__XN_SENSOR_STREAM_HELPER_H__ +#endif // XNSENSORSTREAMHELPER_H diff --git a/Source/Drivers/PS1080/Sensor/XnStreamProcessor.h b/Source/Drivers/PS1080/Sensor/XnStreamProcessor.h index 496c5f60..519164b1 100644 --- a/Source/Drivers/PS1080/Sensor/XnStreamProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnStreamProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_STREAM_PROCESSOR_H__ -#define __XN_STREAM_PROCESSOR_H__ +#ifndef XNSTREAMPROCESSOR_H +#define XNSTREAMPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -54,4 +54,4 @@ class XnStreamProcessor : public XnDataProcessor XnSensorStreamHelper* m_pHelper; }; -#endif //__XN_STREAM_PROCESSOR_H__ +#endif // XNSTREAMPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnTecDebugProcessor.h b/Source/Drivers/PS1080/Sensor/XnTecDebugProcessor.h index 27a47e6e..1cce4ccc 100644 --- a/Source/Drivers/PS1080/Sensor/XnTecDebugProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnTecDebugProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_TEC_DEBUG_PROCESSOR_H__ -#define __XN_TEC_DEBUG_PROCESSOR_H__ +#ifndef XNTECDEBUGPROCESSOR_H +#define XNTECDEBUGPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -49,4 +49,4 @@ class XnTecDebugProcessor : public XnWholePacketProcessor XnDumpFile* m_Dump; }; -#endif //__XN_TEC_DEBUG_PROCESSOR_H__ +#endif // XNTECDEBUGPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnUncompressedBayerProcessor.h b/Source/Drivers/PS1080/Sensor/XnUncompressedBayerProcessor.h index ac24c503..8a243bb5 100644 --- a/Source/Drivers/PS1080/Sensor/XnUncompressedBayerProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnUncompressedBayerProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_UNCOMPRESSED_BAYER_PROCESSOR_H__ -#define __XN_UNCOMPRESSED_BAYER_PROCESSOR_H__ +#ifndef XNUNCOMPRESSEDBAYERPROCESSOR_H +#define XNUNCOMPRESSEDBAYERPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -52,4 +52,4 @@ class XnUncompressedBayerProcessor : public XnImageProcessor XnBuffer m_UncompressedBayerBuffer; }; -#endif //__XN_UNCOMPRESSED_BAYER_PROCESSOR_H__ +#endif // XNUNCOMPRESSEDBAYERPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnUncompressedDepthProcessor.h b/Source/Drivers/PS1080/Sensor/XnUncompressedDepthProcessor.h index 6d0dfc6a..13d89b7f 100644 --- a/Source/Drivers/PS1080/Sensor/XnUncompressedDepthProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnUncompressedDepthProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_UNCOMPRESSED_DEPTH_PROCESSOR_H__ -#define __XN_UNCOMPRESSED_DEPTH_PROCESSOR_H__ +#ifndef XNUNCOMPRESSEDDEPTHPROCESSOR_H +#define XNUNCOMPRESSEDDEPTHPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -43,4 +43,4 @@ class XnUncompressedDepthProcessor : public XnDepthProcessor virtual void ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* pHeader, const XnUChar* pData, XnUInt32 nDataOffset, XnUInt32 nDataSize); }; -#endif //__XN_UNCOMPRESSED_DEPTH_PROCESSOR_H__ +#endif // XNUNCOMPRESSEDDEPTHPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnUncompressedYUV422toRGBImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnUncompressedYUV422toRGBImageProcessor.h index 8a04da00..1587deb5 100644 --- a/Source/Drivers/PS1080/Sensor/XnUncompressedYUV422toRGBImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnUncompressedYUV422toRGBImageProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_UNCOMPRESSED_YUV422_TO_RGB_IMAGE_PROCESSOR_H__ -#define __XN_UNCOMPRESSED_YUV422_TO_RGB_IMAGE_PROCESSOR_H__ +#ifndef XNUNCOMPRESSEDYUV422TORGBIMAGEPROCESSOR_H +#define XNUNCOMPRESSEDYUV422TORGBIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -50,4 +50,4 @@ class XnUncompressedYUV422toRGBImageProcessor : public XnImageProcessor XnBuffer m_ContinuousBuffer; }; -#endif //__XN_UNCOMPRESSED_YUV422_TO_RGB_IMAGE_PROCESSOR_H__ +#endif // XNUNCOMPRESSEDYUV422TORGBIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnUncompressedYUYVtoRGBImageProcessor.h b/Source/Drivers/PS1080/Sensor/XnUncompressedYUYVtoRGBImageProcessor.h index 227cda69..669c4328 100644 --- a/Source/Drivers/PS1080/Sensor/XnUncompressedYUYVtoRGBImageProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnUncompressedYUYVtoRGBImageProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_UNCOMPRESSED_YUYV_TO_RGB_IMAGE_PROCESSOR_H__ -#define __XN_UNCOMPRESSED_YUYV_TO_RGB_IMAGE_PROCESSOR_H__ +#ifndef XNUNCOMPRESSEDYUYVTORGBIMAGEPROCESSOR_H +#define XNUNCOMPRESSEDYUYVTORGBIMAGEPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -50,4 +50,4 @@ class XnUncompressedYUYVtoRGBImageProcessor : public XnImageProcessor XnBuffer m_ContinuousBuffer; }; -#endif //__XN_UNCOMPRESSED_YUYV_TO_RGB_IMAGE_PROCESSOR_H__ +#endif // XNUNCOMPRESSEDYUYVTORGBIMAGEPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnWavelengthCorrectionDebugProcessor.h b/Source/Drivers/PS1080/Sensor/XnWavelengthCorrectionDebugProcessor.h index 77dff9e6..04cf2711 100644 --- a/Source/Drivers/PS1080/Sensor/XnWavelengthCorrectionDebugProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnWavelengthCorrectionDebugProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_WAVELENGTH_CORRECTION_DEBUG_PROCESSOR_H__ -#define __XN_WAVELENGTH_CORRECTION_DEBUG_PROCESSOR_H__ +#ifndef XNWAVELENGTHCORRECTIONDEBUGPROCESSOR_H +#define XNWAVELENGTHCORRECTIONDEBUGPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -48,4 +48,4 @@ class XnWavelengthCorrectionDebugProcessor : public XnWholePacketProcessor XnDumpFile* m_DumpTxt; }; -#endif // __XN_WAVELENGTH_CORRECTION_DEBUG_PROCESSOR_H__ +#endif // XNWAVELENGTHCORRECTIONDEBUGPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/XnWholePacketProcessor.h b/Source/Drivers/PS1080/Sensor/XnWholePacketProcessor.h index cc3aad6f..9520445e 100644 --- a/Source/Drivers/PS1080/Sensor/XnWholePacketProcessor.h +++ b/Source/Drivers/PS1080/Sensor/XnWholePacketProcessor.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_WHOLE_PACKET_PROCESSOR_H__ -#define __XN_WHOLE_PACKET_PROCESSOR_H__ +#ifndef XNWHOLEPACKETPROCESSOR_H +#define XNWHOLEPACKETPROCESSOR_H //--------------------------------------------------------------------------- // Includes @@ -56,4 +56,4 @@ class XnWholePacketProcessor : public XnDataProcessor XnBuffer m_WholePacket; }; -#endif //__XN_WHOLE_PACKET_PROCESSOR_H__ +#endif // XNWHOLEPACKETPROCESSOR_H diff --git a/Source/Drivers/PS1080/Sensor/YUV.h b/Source/Drivers/PS1080/Sensor/YUV.h index 413b7c34..8d8e5cf6 100644 --- a/Source/Drivers/PS1080/Sensor/YUV.h +++ b/Source/Drivers/PS1080/Sensor/YUV.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _XN_YUV_H_ -#define _XN_YUV_H_ +#ifndef YUV_H +#define YUV_H //--------------------------------------------------------------------------- // Includes @@ -66,4 +66,4 @@ void YUV422ToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVS void YUYVToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVSize, XnUInt32* pnActualRead, XnUInt32* pnRGBSize); void YUV420ToRGB888(const XnUInt8* pYUVImage, XnUInt8* pRGBImage, XnUInt32 nYUVSize, XnUInt32 nRGBSize); -#endif //_XN_BAYER_H_ +#endif // YUV_H diff --git a/Source/Drivers/PS1080/XnPsVersion.h b/Source/Drivers/PS1080/XnPsVersion.h deleted file mode 100644 index 78dbc750..00000000 --- a/Source/Drivers/PS1080/XnPsVersion.h +++ /dev/null @@ -1,57 +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 _XN_PS_VERSION_H_ -#define _XN_PS_VERSION_H_ - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include - -//--------------------------------------------------------------------------- -// Defines -//--------------------------------------------------------------------------- -/** Xiron major version. */ -#define XN_PS_MAJOR_VERSION 5 -/** Xiron minor version. */ -#define XN_PS_MINOR_VERSION 1 -/** Xiron maintenance version. */ -#define XN_PS_MAINTENANCE_VERSION 4 -/** Xiron build version. */ -#define XN_PS_BUILD_VERSION 1 - -/** Xiron version (in brief string format): "Major.Minor.Maintenance (Build)" */ -#define XN_PS_BRIEF_VERSION_STRING \ - XN_STRINGIFY(XN_PS_MAJOR_VERSION) "." \ - XN_STRINGIFY(XN_PS_MINOR_VERSION) "." \ - XN_STRINGIFY(XN_PS_MAINTENANCE_VERSION) \ - " (Build " XN_STRINGIFY(XN_PS_BUILD_VERSION) ")" - -/** Xiron version (in numeric format): (Xiron major version * 100000000 + Xiron minor version * 1000000 + Xiron maintenance version * 10000 + Xiron build version). */ -#define XN_PS_VERSION (XN_PS_MAJOR_VERSION*100000000 + XN_PS_MINOR_VERSION*1000000 + XN_PS_MAINTENANCE_VERSION*10000 + XN_PS_BUILD_VERSION) - -/** Xiron version (in string format): "Major.Minor.Maintenance.Build-Platform (MMM DD YYYY HH:MM:SS)". */ -#define XN_PS_VERSION_STRING \ - XN_PS_BRIEF_VERSION_STRING "-" \ - XN_PLATFORM_STRING " (" XN_TIMESTAMP ")" - -#endif //_XN_VERSION_H_ - diff --git a/Source/Drivers/PSLink/Android.mk b/Source/Drivers/PSLink/Android.mk index 7c780573..a00e31b5 100644 --- a/Source/Drivers/PSLink/Android.mk +++ b/Source/Drivers/PSLink/Android.mk @@ -2,6 +2,8 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) +include $(LOCAL_PATH)/../../../ThirdParty/PSCommon/BuildSystem/CommonAndroid.mk + # set path to source MY_PREFIX := $(LOCAL_PATH) @@ -19,23 +21,16 @@ LOCAL_SRC_FILES := $(MY_SRC_FILE_EXPANDED:$(LOCAL_PATH)/%=%) LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/../../../Include \ - $(LOCAL_PATH)/../../../ThirdParty/PSCommon/XnLib/Include \ $(LOCAL_PATH) \ $(LOCAL_PATH)/Protocols/XnLinkProto \ $(LOCAL_PATH)/LinkProtoLib \ -LOCAL_CFLAGS:= -fvisibility=hidden -DXN_CORE_EXPORTS - -LOCAL_LDFLAGS += -Wl,--export-dynamic - LOCAL_STATIC_LIBRARIES := XnLib -LOCAL_SHARED_LIBRARIES := liblog libdl libusb libgabi++ -LOCAL_PREBUILT_LIBS := libc - -ifndef OPENNI2_ANDROID_OS_BUILD - LOCAL_LDLIBS += -llog -endif +LOCAL_SHARED_LIBRARIES := libusb LOCAL_MODULE := PSLink include $(BUILD_SHARED_LIBRARY) + +#include XnLib +include $(LOCAL_PATH)/../../../ThirdParty/PSCommon/XnLib/Source/Android.mk diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.cpp b/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.cpp index 45abe6e2..f7c7505e 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.cpp +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.cpp @@ -227,3 +227,24 @@ void LinkOniDepthStream::notifyAllProperties() raisePropertyChanged(LINK_PROP_DEPTH_TO_SHIFT_TABLE, pTables->pDepthToShiftTable, pTables->nDepthsCount * sizeof(XnUInt16)); } + +XnStatus LinkOniDepthStream::GetDefaultVideoMode( OniVideoMode* pVideoMode ) +{ + if(pVideoMode != NULL) + { + //ARM cannot handle QVGA, so we default to QQVGA +#if (XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_ANDROID_ARM) + pVideoMode->resolutionX = 160; + pVideoMode->resolutionY = 120; +#else + pVideoMode->resolutionX = 320; + pVideoMode->resolutionY = 240; +#endif + + return XN_STATUS_OK; + } + else + { + return LinkOniMapStream::GetDefaultVideoMode(pVideoMode); + } +} diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.h b/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.h index 61afb7e7..287d13b4 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.h +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniDepthStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __LINK_ONI_DEPTH_STREAM_H__ -#define __LINK_ONI_DEPTH_STREAM_H__ +#ifndef LINKONIDEPTHSTREAM_H +#define LINKONIDEPTHSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -37,6 +37,9 @@ class LinkOniDepthStream : virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize); virtual OniBool isPropertySupported(int propertyId); virtual void notifyAllProperties(); + +protected: + virtual XnStatus GetDefaultVideoMode( OniVideoMode* pVideoMode ); }; -#endif // __LINK_ONI_DEPTH_STREAM_H__ \ No newline at end of file +#endif // LINKONIDEPTHSTREAM_H diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.cpp b/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.cpp index 87f7cd10..7dbae61c 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.cpp +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.cpp @@ -34,6 +34,15 @@ #define XN_MASK_LINK_DEVICE "LinkDevice" #define CONFIG_DEVICE_SECTION "Device" +#if XN_PLATFORM == XN_PLATFORM_WIN32 + #define XN_DEFAULT_USB_INTERFACE PS_USB_INTERFACE_ISO_ENDPOINTS; +#elif XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_MACOSX || XN_PLATFORM == XN_PLATFORM_ANDROID_ARM + #define XN_DEFAULT_USB_INTERFACE PS_USB_INTERFACE_BULK_ENDPOINTS; +#else + #error Unsupported platform! +#endif + + LinkOniDevice::LinkOniDevice(const char* configFile, const XnChar* uri, oni::driver::DriverServices& driverServices, LinkOniDriver* pDriver) : m_configFile(configFile), m_pSensor(NULL), m_driverServices(driverServices), m_pDriver(pDriver) { @@ -67,15 +76,35 @@ XnStatus LinkOniDevice::readSupportedModesFromStream(XnFwStreamInfo &info, xnl:: return XN_STATUS_OK; } +XnStatus AddVideoMode(xnl::Array& modes, XnFwStreamVideoMode fwMode, OniPixelFormat pixelFormat) +{ + // make sure it's not in the list already + for (XnUInt32 i = 0; i < modes.GetSize(); ++i) + { + if (modes[i].resolutionX == (int)fwMode.m_nXRes && + modes[i].resolutionY == (int)fwMode.m_nYRes && + modes[i].fps == (int)fwMode.m_nFPS && + modes[i].pixelFormat == pixelFormat) + { + return XN_STATUS_OK; + } + } + + OniVideoMode mode; + mode.resolutionX = fwMode.m_nXRes; + mode.resolutionY = fwMode.m_nYRes; + mode.fps = fwMode.m_nFPS; + mode.pixelFormat = pixelFormat; + return modes.AddLast(mode); +} + XnStatus LinkOniDevice::FillSupportedVideoModes() { - int nSupportedModes = 0; xnl::Array aSupportedModes; - xnl::Array aEnumerated; + xnl::Array aVideoModes; int s = -1; - int writeIndex; // Depth m_pSensor->EnumerateStreams((XnStreamType)XN_LINK_STREAM_TYPE_SHIFTS, aEnumerated); @@ -84,42 +113,24 @@ XnStatus LinkOniDevice::FillSupportedVideoModes() XnStatus nRetVal = readSupportedModesFromStream(aEnumerated[c], aSupportedModes); XN_IS_STATUS_OK(nRetVal); - ++s; - m_sensors[s].sensorType = ONI_SENSOR_DEPTH; - m_sensors[s].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, aSupportedModes.GetSize()); - XN_VALIDATE_ALLOC_PTR(m_sensors[s].pSupportedVideoModes); - nSupportedModes = aSupportedModes.GetSize(); - - writeIndex = 0; - for(int i=0; i < nSupportedModes; ++i) + for (XnUInt32 i = 0; i < aSupportedModes.GetSize(); ++i) { - m_sensors[s].pSupportedVideoModes[writeIndex].pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; - m_sensors[s].pSupportedVideoModes[writeIndex].fps = aSupportedModes[i].m_nFPS; - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionX = aSupportedModes[i].m_nXRes; - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionY = aSupportedModes[i].m_nYRes; - - bool foundMatch = false; - for (int j = 0; j < writeIndex; ++j) - { - if (m_sensors[s].pSupportedVideoModes[writeIndex].pixelFormat == m_sensors[s].pSupportedVideoModes[j].pixelFormat && - m_sensors[s].pSupportedVideoModes[writeIndex].fps == m_sensors[s].pSupportedVideoModes[j].fps && - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionX == m_sensors[s].pSupportedVideoModes[j].resolutionX && - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionY == m_sensors[s].pSupportedVideoModes[j].resolutionY) - { - // Already know this configuration - foundMatch = true; - break; - } - } - if (!foundMatch) - { - ++writeIndex; - } + nRetVal = AddVideoMode(aVideoModes, aSupportedModes[i], ONI_PIXEL_FORMAT_DEPTH_1_MM); + XN_IS_STATUS_OK(nRetVal); + nRetVal = AddVideoMode(aVideoModes, aSupportedModes[i], ONI_PIXEL_FORMAT_DEPTH_100_UM); + XN_IS_STATUS_OK(nRetVal); } - m_sensors[s].numSupportedVideoModes = writeIndex; - m_numSensors = s+1; } + ++s; + m_sensors[s].sensorType = ONI_SENSOR_DEPTH; + m_sensors[s].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, aVideoModes.GetSize()); + XN_VALIDATE_ALLOC_PTR(m_sensors[s].pSupportedVideoModes); + xnOSMemCopy(m_sensors[s].pSupportedVideoModes, aVideoModes.GetData(), aVideoModes.GetSize() * sizeof(OniVideoMode)); + m_sensors[s].numSupportedVideoModes = aVideoModes.GetSize(); + + m_numSensors = s+1; aEnumerated.Clear(); + aVideoModes.Clear(); // IR m_pSensor->EnumerateStreams((XnStreamType)XN_LINK_STREAM_TYPE_IR, aEnumerated); @@ -128,102 +139,23 @@ XnStatus LinkOniDevice::FillSupportedVideoModes() XnStatus nRetVal = readSupportedModesFromStream(aEnumerated[c], aSupportedModes); XN_IS_STATUS_OK(nRetVal); - ++s; - m_sensors[s].sensorType = ONI_SENSOR_IR; - m_sensors[s].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, aSupportedModes.GetSize()); - XN_VALIDATE_ALLOC_PTR(m_sensors[s].pSupportedVideoModes); - nSupportedModes = aSupportedModes.GetSize(); - - writeIndex = 0; - for(int i=0; i < nSupportedModes; ++i) + for (XnUInt32 i = 0; i < aSupportedModes.GetSize(); ++i) { - m_sensors[s].pSupportedVideoModes[writeIndex].pixelFormat = ONI_PIXEL_FORMAT_GRAY16; - m_sensors[s].pSupportedVideoModes[writeIndex].fps = aSupportedModes[i].m_nFPS; - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionX = aSupportedModes[i].m_nXRes; - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionY = aSupportedModes[i].m_nYRes; - - bool foundMatch = false; - for (int j = 0; j < writeIndex; ++j) - { - if (m_sensors[s].pSupportedVideoModes[writeIndex].pixelFormat == m_sensors[s].pSupportedVideoModes[j].pixelFormat && - m_sensors[s].pSupportedVideoModes[writeIndex].fps == m_sensors[s].pSupportedVideoModes[j].fps && - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionX == m_sensors[s].pSupportedVideoModes[j].resolutionX && - m_sensors[s].pSupportedVideoModes[writeIndex].resolutionY == m_sensors[s].pSupportedVideoModes[j].resolutionY) - { - // Already know this configuration - foundMatch = true; - break; - } - } - if (!foundMatch) - { - ++writeIndex; - } + nRetVal = AddVideoMode(aVideoModes, aSupportedModes[i], ONI_PIXEL_FORMAT_GRAY16); + XN_IS_STATUS_OK(nRetVal); } - m_sensors[s].numSupportedVideoModes = writeIndex; - m_numSensors = s+1; } + ++s; + m_sensors[s].sensorType = ONI_SENSOR_IR; + m_sensors[s].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, aVideoModes.GetSize()); + XN_VALIDATE_ALLOC_PTR(m_sensors[s].pSupportedVideoModes); + xnOSMemCopy(m_sensors[s].pSupportedVideoModes, aVideoModes.GetData(), aVideoModes.GetSize() * sizeof(OniVideoMode)); + m_sensors[s].numSupportedVideoModes = aVideoModes.GetSize(); + + m_numSensors = s+1; aEnumerated.Clear(); + aVideoModes.Clear(); -/* // Color - - // first, make sure that our sensor actually supports Image - XnUInt64 nImageSupported = FALSE; - XnStatus nRetVal = m_sensor.GetProperty(XN_MASK_DEVICE, XN_MODULE_PROPERTY_IMAGE_SUPPORTED, &nImageSupported); - XN_IS_STATUS_OK(nRetVal); - if (nImageSupported) - { - ++s; - nSupportedModes = m_sensor.GetDevicePrivateData()->FWInfo.imageModes.GetSize(); - pSupportedModes = m_sensor.GetDevicePrivateData()->FWInfo.imageModes.GetData(); - - m_sensors[s].sensorType = ONI_SENSOR_COLOR; - m_sensors[s].numSupportedVideoModes = 0; // to be changed later.. - m_sensors[s].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, nSupportedModes * 10); - XN_VALIDATE_ALLOC_PTR(m_sensors[s].pSupportedVideoModes); - - writeIndex = 0; - for(XnUInt32 j=0; j < nSupportedModes; ++j) - { - // make an OniVideoMode for each OniFormat supported by the input format - OniPixelFormat aOniFormats[10]; - int nOniFormats = 0; - LinkOniColorStream::GetAllowedOniOutputFormatForInputFormat((XnIOImageFormats)pSupportedModes[j].nFormat, aOniFormats, &nOniFormats); - for(int curOni=0; curOniStartFWLog(); + } + if (retVal != XN_STATUS_OK) { XN_DELETE(pPrimeClient); @@ -540,6 +494,54 @@ OniStatus LinkOniDevice::getProperty(int propertyId, void* data, int* pDataSize) XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); } break; + case LINK_PROP_ACC_ENABLED: + { + ENSURE_PROP_SIZE(*pDataSize, XnBool); + + XnBool bActive; + nRetVal = m_pSensor->GetAccActive(bActive); + XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); + + ASSIGN_PROP_VALUE_INT(data, *pDataSize, bActive) + } + break; + + case LINK_PROP_VDD_ENABLED: + { + ENSURE_PROP_SIZE(*pDataSize, XnBool); + + XnBool bActive; + nRetVal = m_pSensor->GetVDDActive(bActive); + XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); + + ASSIGN_PROP_VALUE_INT(data, *pDataSize, bActive) + } + break; + + case LINK_PROP_PERIODIC_BIST_ENABLED: + { + ENSURE_PROP_SIZE(*pDataSize, XnBool); + + XnBool bActive; + nRetVal = m_pSensor->GetPeriodicBistActive(bActive); + XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); + + ASSIGN_PROP_VALUE_INT(data, *pDataSize, bActive) + } + break; + + + case LINK_PROP_PROJECTOR_POWER: + { + ENSURE_PROP_SIZE(*pDataSize, XnUInt16); + + XnUInt16 power; + nRetVal = m_pSensor->GetProjectorPower(power); + XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); + + ASSIGN_PROP_VALUE_INT(data, *pDataSize, power) + } + break; default: return ONI_STATUS_BAD_PARAMETER; @@ -587,11 +589,29 @@ OniStatus LinkOniDevice::setProperty(int propertyId, const void* data, int dataS // Internal Link Properties // int props - case LINK_PROP_EMITTER_ACTIVE: - nRetVal = m_pSensor->SetEmitterActive(*(XnBool*)data); - XN_IS_STATUS_OK_LOG_ERROR_RET("Set emitter active", nRetVal, ONI_STATUS_ERROR); + case LINK_PROP_PROJECTOR_ACTIVE: + nRetVal = m_pSensor->SetProjectorActive(*(XnBool*)data); + XN_IS_STATUS_OK_LOG_ERROR_RET("Set Projector active", nRetVal, ONI_STATUS_ERROR); break; + //controls if the firmware runs all its control loops (BIST) + case LINK_PROP_ACC_ENABLED: + nRetVal = m_pSensor->SetAccActive(*(XnBool*)data); + XN_IS_STATUS_OK_LOG_ERROR_RET("Set Acc active", nRetVal, ONI_STATUS_ERROR); + break; + + // + case LINK_PROP_VDD_ENABLED: + nRetVal = m_pSensor->SetVDDActive(*(XnBool*)data); + XN_IS_STATUS_OK_LOG_ERROR_RET("Set VDD active", nRetVal, ONI_STATUS_ERROR); + break; + + // + case LINK_PROP_PERIODIC_BIST_ENABLED: + nRetVal = m_pSensor->SetPeriodicBistActive(*(XnBool*)data); + XN_IS_STATUS_OK_LOG_ERROR_RET("Set PeriodicBist active", nRetVal, ONI_STATUS_ERROR); + break; + // string props case LINK_PROP_PRESET_FILE: nRetVal = m_pSensor->RunPresetFile((XnChar *)data); @@ -619,6 +639,12 @@ OniStatus LinkOniDevice::setProperty(int propertyId, const void* data, int dataS } break; + case LINK_PROP_PROJECTOR_POWER: + ENSURE_PROP_SIZE(dataSize, XnUInt16); + nRetVal = m_pSensor->SetProjectorPower(*(XnUInt16*)data); + XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); + break; + default: return ONI_STATUS_BAD_PARAMETER; } @@ -640,10 +666,14 @@ OniBool LinkOniDevice::isPropertySupported(int propertyId) case LINK_PROP_FW_VERSION: case LINK_PROP_VERSIONS_INFO_COUNT: case LINK_PROP_VERSIONS_INFO: - case LINK_PROP_EMITTER_ACTIVE: + case LINK_PROP_PROJECTOR_ACTIVE: + case LINK_PROP_ACC_ENABLED: + case LINK_PROP_VDD_ENABLED: + case LINK_PROP_PERIODIC_BIST_ENABLED: case LINK_PROP_PRESET_FILE: case PS_PROPERTY_USB_INTERFACE: case LINK_PROP_BOOT_STATUS: + case LINK_PROP_PROJECTOR_POWER: return true; default: return false; @@ -754,7 +784,20 @@ OniStatus LinkOniDevice::invoke(int commandId, void* data, int dataSize) nRetVal = m_pSensor->HardReset(); XN_IS_STATUS_OK_LOG_ERROR_RET("Power reset", nRetVal, ONI_STATUS_ERROR); break; - + case PS_COMMAND_READ_DEBUG_DATA: + { + EXACT_PROP_SIZE_DO(dataSize, XnCommandDebugData) + { + m_driverServices.errorLoggerAppend("Unexpected size: %d != %d\n", dataSize, sizeof(XnCommandDebugData)); + XN_ASSERT(FALSE); + return ONI_STATUS_BAD_PARAMETER; + } + + XnCommandDebugData* pArgs = reinterpret_cast(data); + nRetVal = m_pSensor->ReadDebugData(*pArgs); + XN_IS_STATUS_OK_LOG_ERROR_RET("Reading Debug Data", nRetVal, ONI_STATUS_ERROR); + } + break; case PS_COMMAND_BEGIN_FIRMWARE_UPDATE: nRetVal = m_pSensor->BeginUploadFileOnControlEP(); XN_IS_STATUS_OK_LOG_ERROR_RET("Begin update", nRetVal, ONI_STATUS_ERROR); @@ -890,6 +933,8 @@ OniStatus LinkOniDevice::invoke(int commandId, void* data, int dataSize) for (int i = 0; i < (int)devices.GetSize(); ++i) { + pArgs->devices[i].masterId = devices[i].m_nMasterID; + pArgs->devices[i].slaveId = devices[i].m_nSlaveID; pArgs->devices[i].id = devices[i].m_nID; xnOSStrCopy(pArgs->devices[i].name, devices[i].m_strName, sizeof(pArgs->devices[i].name)); } @@ -933,6 +978,55 @@ OniStatus LinkOniDevice::invoke(int commandId, void* data, int dataSize) } break; + case PS_COMMAND_GET_TEMP_LIST: + { + EXACT_PROP_SIZE_DO(dataSize, XnCommandGetTempList) + { + m_driverServices.errorLoggerAppend("Unexpected size: %d != %d\n", dataSize, sizeof(XnCommandGetTempList)); + XN_ASSERT(FALSE); + return ONI_STATUS_BAD_PARAMETER; + } + + XnCommandGetTempList* pArgs = reinterpret_cast(data); + if (pArgs->pTempInfos == NULL) + { + m_driverServices.errorLoggerAppend("Temp array must point to valid memory: \n"); + XN_ASSERT(FALSE); + return ONI_STATUS_BAD_PARAMETER; + } + + xnl::Array tempInfos; + nRetVal = m_pSensor->GetSupportedTempList(tempInfos); + XN_IS_STATUS_OK_LOG_ERROR_RET("Get Temp list", nRetVal, ONI_STATUS_ERROR); + + if (pArgs->count < tempInfos.GetSize()) + { + m_driverServices.errorLoggerAppend("Insufficient memory for Temperature list. available: %d, required: %d\n", pArgs->pTempInfos, tempInfos.GetSize()); + XN_ASSERT(FALSE); + return ONI_STATUS_BAD_PARAMETER; + } + + for (int i = 0; i < (int)tempInfos.GetSize(); ++i) + { + pArgs->pTempInfos[i] = tempInfos[i]; + } + pArgs->count = tempInfos.GetSize(); + } + break; + case PS_COMMAND_READ_TEMPERATURE: + { + XnCommandTemperatureResponse* pArg; + EXACT_PROP_SIZE_DO(dataSize,XnCommandTemperatureResponse) + { + m_driverServices.errorLoggerAppend("Unexpected size: %d != %d\n", dataSize, sizeof(XnCommandTemperatureResponse)); + XN_ASSERT(FALSE); + return ONI_STATUS_BAD_PARAMETER; + } + pArg = reinterpret_cast(data); + nRetVal = m_pSensor->GetTemperature(*pArg); + XN_IS_STATUS_OK_LOG_ERROR_RET("Get Temperature", nRetVal, ONI_STATUS_ERROR); + } + break; case PS_COMMAND_EXECUTE_BIST: { EXACT_PROP_SIZE_DO(dataSize, XnCommandExecuteBist) @@ -1276,6 +1370,28 @@ OniStatus LinkOniDevice::invoke(int commandId, void* data, int dataSize) } break; + case LINK_COMMAND_SET_PROJECTOR_PULSE: + { + EXACT_PROP_SIZE_DO(dataSize, XnCommandSetProjectorPulse) + { + m_driverServices.errorLoggerAppend("Unexpected size: %d != %d\n", dataSize, sizeof(XnCommandSetProjectorPulse)); + XN_ASSERT(FALSE); + return ONI_STATUS_BAD_PARAMETER; + } + + XnCommandSetProjectorPulse* pArgs = reinterpret_cast(data); + nRetVal = m_pSensor->EnableProjectorPulse((XnFloat)pArgs->delay, (XnFloat)pArgs->width, (XnFloat)pArgs->cycle); + XN_IS_STATUS_OK_LOG_ERROR_RET("Enable projector pulse", nRetVal, ONI_STATUS_ERROR); + } + break; + + case LINK_COMMAND_DISABLE_PROJECTOR_PULSE: + { + nRetVal = m_pSensor->DisableProjectorPulse(); + XN_IS_STATUS_OK_LOG_ERROR_RET("Disable projector pulse", nRetVal, ONI_STATUS_ERROR); + } + break; + default: return DeviceBase::invoke(commandId, data, dataSize); } @@ -1293,6 +1409,7 @@ OniBool LinkOniDevice::isCommandSupported(int commandId) case PS_COMMAND_I2C_WRITE: case PS_COMMAND_SOFT_RESET: case PS_COMMAND_POWER_RESET: + case PS_COMMAND_READ_DEBUG_DATA: case PS_COMMAND_BEGIN_FIRMWARE_UPDATE: case PS_COMMAND_END_FIRMWARE_UPDATE: case PS_COMMAND_UPLOAD_FILE: @@ -1302,6 +1419,8 @@ OniBool LinkOniDevice::isCommandSupported(int commandId) case PS_COMMAND_DUMP_ENDPOINT: case PS_COMMAND_GET_I2C_DEVICE_LIST: case PS_COMMAND_GET_BIST_LIST: + case PS_COMMAND_GET_TEMP_LIST: + case PS_COMMAND_READ_TEMPERATURE: case PS_COMMAND_EXECUTE_BIST: case PS_COMMAND_USB_TEST: case PS_COMMAND_GET_LOG_MASK_LIST: diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.h b/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.h index 0abe521f..be42bd69 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.h +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniDevice.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __LINK_ONI_DEVICE_H__ -#define __LINK_ONI_DEVICE_H__ +#ifndef LINKONIDEVICE_H +#define LINKONIDEVICE_H //--------------------------------------------------------------------------- // Includes @@ -99,4 +99,4 @@ class LinkOniDevice : LinkOniDriver* m_pDriver; }; -#endif // __LINK_ONI_DEVICE_H__ +#endif // LINKONIDEVICE_H diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.cpp b/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.cpp index eee80b12..9a69da8a 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.cpp +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.cpp @@ -27,6 +27,8 @@ #include #include +#define LINK_CONFIGURATION_FILE "PSLink.ini" + //--------------------------------------------------------------------------- // LinkOniDriver class //--------------------------------------------------------------------------- @@ -292,6 +294,21 @@ void LinkOniDriver::resolveConfigFilePath() { XnChar strModulePath[XN_FILE_MAX_PATH]; +#if XN_PLATFORM == XN_PLATFORM_ANDROID_ARM + XnStatus rc = XN_STATUS_OK; + // support for applications + xnOSGetApplicationFilesDir(strModulePath, XN_FILE_MAX_PATH); + xnOSAppendFilePath(strModulePath, LINK_CONFIGURATION_FILE, XN_FILE_MAX_PATH); + + XnBool bExists; + xnOSDoesFileExist(strModulePath, &bExists); + + if (!bExists) + { + // support for native use - search in current dir + xnOSStrCopy(strModulePath, LINK_CONFIGURATION_FILE, XN_FILE_MAX_PATH); + } +#else if (xnOSGetModulePathForProcAddress(reinterpret_cast(&LinkOniDriver::OnDeviceConnected), strModulePath) != XN_STATUS_OK || xnOSGetDirName(strModulePath, m_configFilePath, sizeof(m_configFilePath)) != XN_STATUS_OK) { @@ -300,5 +317,6 @@ void LinkOniDriver::resolveConfigFilePath() } xnOSAppendFilePath(m_configFilePath, "PSLink.ini", sizeof(m_configFilePath)); +#endif } diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.h b/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.h index 0e53e405..955d7386 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.h +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniDriver.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __LINK_ONI_DRIVER_H__ -#define __LINK_ONI_DRIVER_H__ +#ifndef LINKONIDRIVER_H +#define LINKONIDRIVER_H //--------------------------------------------------------------------------- // Includes @@ -88,4 +88,4 @@ class LinkOniDriver : char m_configFilePath[XN_FILE_MAX_PATH]; }; -#endif // __LINK_ONI_DRIVER_H__ +#endif // LINKONIDRIVER_H diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.cpp b/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.cpp index f71270e7..71242d3d 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.cpp +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.cpp @@ -23,6 +23,8 @@ //--------------------------------------------------------------------------- #include "LinkOniIRStream.h" +#define LINK_MAX_IR_PIXEL_VALUE 4095 + //--------------------------------------------------------------------------- // LinkOniIRStream class //--------------------------------------------------------------------------- @@ -32,4 +34,21 @@ LinkOniIRStream::LinkOniIRStream(const char* configFile, xn::PrimeClient* pSenso { } - +OniStatus LinkOniIRStream::getProperty(int propertyId, void* data, int* pDataSize) +{ + switch (propertyId) + { + // int props + case ONI_STREAM_PROPERTY_MAX_VALUE: + { + int value = LINK_MAX_IR_PIXEL_VALUE; + ENSURE_PROP_SIZE(*pDataSize, int); + ASSIGN_PROP_VALUE_INT(data, *pDataSize, value); + } + break; + default: + return LinkOniMapStream::getProperty(propertyId, data, pDataSize); + } + + return ONI_STATUS_OK; +} diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.h b/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.h index 04b9993f..3cef88d7 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.h +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniIRStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __LINK_ONI_IR_STREAM_H__ -#define __LINK_ONI_IR_STREAM_H__ +#ifndef LINKONIIRSTREAM_H +#define LINKONIIRSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -34,6 +34,7 @@ class LinkOniIRStream : { public: LinkOniIRStream(const char* configFile, xn::PrimeClient* pSensor, LinkOniDevice* pDevice); + OniStatus getProperty(int propertyId, void* data, int* pDataSize); }; -#endif // __LINK_ONI_IR_STREAM_H__ \ No newline at end of file +#endif // LINKONIIRSTREAM_H diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.cpp b/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.cpp index f2698f61..57117598 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.cpp +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.cpp @@ -56,25 +56,29 @@ XnStatus LinkOniMapStream::Init() XN_IS_STATUS_OK(nRetVal); // read video mode - XnChar section[255]; - sprintf(section, "%s.VideoMode", m_configSection); + XnChar videoModeSection[255]; + sprintf(videoModeSection, "%s.VideoMode", m_configSection); OniVideoMode videoMode; GetVideoMode(&videoMode); + // override with streams default values + GetDefaultVideoMode(&videoMode); + + // override with INI config XnInt32 temp32; - if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "XResolution", &temp32)) + if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "XResolution", &temp32)) { videoMode.resolutionX = (int)temp32; } - if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "YResolution", &temp32)) + if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "YResolution", &temp32)) { videoMode.resolutionY = (int)temp32; } - if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "FPS", &temp32)) + if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "FPS", &temp32)) { videoMode.fps = (int)temp32; } - if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "PixelFormat", &temp32)) + if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "PixelFormat", &temp32)) { videoMode.pixelFormat = (OniPixelFormat)temp32; } @@ -89,7 +93,7 @@ XnStatus LinkOniMapStream::Init() XN_IS_STATUS_OK(nRetVal); OniBool bMirror = TRUE; - if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, section, "Mirror", &temp32)) + if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, m_configSection, "Mirror", &temp32)) { bMirror = (temp32 == 1); } @@ -134,6 +138,16 @@ OniStatus LinkOniMapStream::getProperty(int propertyId, void* data, int* pDataSi ASSIGN_PROP_VALUE_INT(data, *pDataSize, m_pInputStream->GetVideoMode().m_nCompression); break; + case PS_PROPERTY_GAIN: + { + ENSURE_PROP_SIZE(*pDataSize, XnUInt16); + XnUInt16 gain; + nRetVal = m_pInputStream->GetGain(gain); + XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); + ASSIGN_PROP_VALUE_INT(data, *pDataSize, gain); + } + break; + default: { return LinkOniStream::getProperty(propertyId, data, pDataSize); @@ -187,6 +201,14 @@ OniStatus LinkOniMapStream::setProperty(int propertyId, const void* data, int da break; } + case PS_PROPERTY_GAIN: + { + ENSURE_PROP_SIZE(dataSize, XnUInt16); + nRetVal = m_pInputStream->SetGain(*(XnUInt16*)data); + XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR); + break; + } + default: return LinkOniStream::setProperty(propertyId, data, dataSize); } @@ -242,10 +264,12 @@ XnStatus LinkOniMapStream::SetVideoMode(OniVideoMode* pVideoMode) { XnStatus nRetVal = XN_STATUS_OK; - OniVideoMode current; - GetVideoMode(¤t); + XnFwStreamVideoMode currFwMode = m_pInputStream->GetVideoMode(); - if (!xnOSMemCmp(¤t, pVideoMode, sizeof(OniVideoMode))) + if ((int)currFwMode.m_nXRes == pVideoMode->resolutionX && + (int)currFwMode.m_nYRes == pVideoMode->resolutionY && + (int)currFwMode.m_nFPS == pVideoMode->fps && + m_pInputStream->GetOutputFormat() == pVideoMode->pixelFormat) { // nothing to do here return (ONI_STATUS_OK); @@ -260,8 +284,17 @@ XnStatus LinkOniMapStream::SetVideoMode(OniVideoMode* pVideoMode) pVideoMode->resolutionY == (int)supportedModes[i].m_nYRes && pVideoMode->fps == (int)supportedModes[i].m_nFPS) { - selectedIndex = i; - break; + // prefer the one that also keeps on other parameters. If no such mode exists, switch to the first one on the list + if (supportedModes[i].m_nPixelFormat == currFwMode.m_nPixelFormat && + supportedModes[i].m_nCompression == currFwMode.m_nCompression) + { + selectedIndex = i; + break; + } + else if (selectedIndex == -1) + { + selectedIndex = i; + } } } @@ -273,12 +306,13 @@ XnStatus LinkOniMapStream::SetVideoMode(OniVideoMode* pVideoMode) return XN_STATUS_BAD_PARAM; } - nRetVal = m_pInputStream->SetVideoMode(supportedModes[selectedIndex]); - XN_IS_STATUS_OK_LOG_ERROR("Set video mode", nRetVal); - nRetVal = m_pInputStream->SetOutputFormat(pVideoMode->pixelFormat); XN_IS_STATUS_OK_LOG_ERROR("Set output format", nRetVal); + nRetVal = m_pInputStream->SetVideoMode(supportedModes[selectedIndex]); + XN_IS_STATUS_OK_LOG_ERROR("Set video mode", nRetVal); + + xnLogVerbose(XN_MASK_LINK,"Set video mode to %ux%u@%u fps & pixel format: %u", pVideoMode->resolutionX, pVideoMode->resolutionY, pVideoMode->fps, pVideoMode->pixelFormat); return XN_STATUS_OK; } @@ -329,3 +363,8 @@ XnStatus LinkOniMapStream::SetCropping(const OniCropping &cropping) return m_pInputStream->SetCropping(cropping); } +XnStatus LinkOniMapStream::GetDefaultVideoMode( OniVideoMode* /*pVideoMode*/ ) +{ + return XN_STATUS_IS_EMPTY; +} + diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.h b/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.h index 76d87e76..9e9d2d2e 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.h +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniMapStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __LINK_ONI_MAP_STREAM_H__ -#define __LINK_ONI_MAP_STREAM_H__ +#ifndef LINKONIMAPSTREAM_H +#define LINKONIMAPSTREAM_H //--------------------------------------------------------------------------- // Includes @@ -59,6 +59,8 @@ class LinkOniMapStream : XnFwPixelFormat nInputFormat; }; + virtual XnStatus GetDefaultVideoMode(OniVideoMode* pVideoMode); + int m_nSupportedModesCount; SupportedVideoMode* m_aSupportedModes; @@ -66,4 +68,4 @@ class LinkOniMapStream : XnStatus FillSupportedVideoModes(); }; -#endif // __LINK_ONI_MAP_STREAM_H__ +#endif // LINKONIMAPSTREAM_H diff --git a/Source/Drivers/PSLink/DriverImpl/LinkOniStream.h b/Source/Drivers/PSLink/DriverImpl/LinkOniStream.h index 8da79681..fec5f0cf 100644 --- a/Source/Drivers/PSLink/DriverImpl/LinkOniStream.h +++ b/Source/Drivers/PSLink/DriverImpl/LinkOniStream.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __LINK_ONI_STREAM_H__ -#define __LINK_ONI_STREAM_H__ +#ifndef LINKONISTREAM_H +#define LINKONISTREAM_H //--------------------------------------------------------------------------- // Includes @@ -81,4 +81,4 @@ class LinkOniStream : static void XN_CALLBACK_TYPE OnNewStreamDataEventHandler(const xn::NewFrameEventArgs& args, void* pCookie); }; -#endif // __LINK_ONI_STREAM_H__ +#endif // LINKONISTREAM_H diff --git a/Source/Drivers/PSLink/LinkDeviceEnumeration.h b/Source/Drivers/PSLink/LinkDeviceEnumeration.h index 1a5d68cf..d16ef658 100644 --- a/Source/Drivers/PSLink/LinkDeviceEnumeration.h +++ b/Source/Drivers/PSLink/LinkDeviceEnumeration.h @@ -18,8 +18,8 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef _LINK_DEVICE_ENUMERATION_H_ -#define _LINK_DEVICE_ENUMERATION_H_ +#ifndef LINKDEVICEENUMERATION_H +#define LINKDEVICEENUMERATION_H #include #include @@ -65,4 +65,4 @@ class LinkDeviceEnumeration static XN_CRITICAL_SECTION_HANDLE ms_lock; }; -#endif +#endif // LINKDEVICEENUMERATION_H diff --git a/Source/Drivers/PSLink/LinkErrorCodes.cpp b/Source/Drivers/PSLink/LinkErrorCodes.cpp new file mode 100644 index 00000000..daac84fb --- /dev/null +++ b/Source/Drivers/PSLink/LinkErrorCodes.cpp @@ -0,0 +1,24 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ + +// Register status codes +#include +#include "XnLinkStatusCodes.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/IAsyncInputConnection.h b/Source/Drivers/PSLink/LinkProtoLib/IAsyncInputConnection.h index a4cc9a5d..8e0f5656 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/IAsyncInputConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/IAsyncInputConnection.h @@ -1,5 +1,25 @@ -#ifndef __IASYNCINPUTCONNECTION_H__ -#define __IASYNCINPUTCONNECTION_H__ +/***************************************************************************** +* * +* 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 IASYNCINPUTCONNECTION_H +#define IASYNCINPUTCONNECTION_H #include "IConnection.h" #include @@ -24,4 +44,4 @@ class IAsyncInputConnection : virtual public IConnection } -#endif // __IASYNCINPUTCONNECTION_H__ \ No newline at end of file +#endif // IASYNCINPUTCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/IConnection.h b/Source/Drivers/PSLink/LinkProtoLib/IConnection.h index fc2a9231..c8d0cff8 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/IConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/IConnection.h @@ -1,5 +1,25 @@ -#ifndef __ICONNECTION_H__ -#define __ICONNECTION_H__ +/***************************************************************************** +* * +* 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 ICONNECTION_H +#define ICONNECTION_H #include @@ -17,4 +37,4 @@ class IConnection } -#endif // __ICONNECTION_H__ \ No newline at end of file +#endif // ICONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/IConnectionFactory.h b/Source/Drivers/PSLink/LinkProtoLib/IConnectionFactory.h index 81b4262f..1c7af40d 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/IConnectionFactory.h +++ b/Source/Drivers/PSLink/LinkProtoLib/IConnectionFactory.h @@ -1,5 +1,25 @@ -#ifndef __ICONNECTIONFACTORY_H__ -#define __ICONNECTIONFACTORY_H__ +/***************************************************************************** +* * +* 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 ICONNECTIONFACTORY_H +#define ICONNECTIONFACTORY_H #include #include @@ -31,4 +51,4 @@ class IConnectionFactory } -#endif // __ICONNECTIONFACTORY_H__ +#endif // ICONNECTIONFACTORY_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/ILinkOutputStream.h b/Source/Drivers/PSLink/LinkProtoLib/ILinkOutputStream.h index e9275b03..e9fb637b 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/ILinkOutputStream.h +++ b/Source/Drivers/PSLink/LinkProtoLib/ILinkOutputStream.h @@ -1,5 +1,25 @@ -#ifndef __ILINKOUTPUTSTREAM_H__ -#define __ILINKOUTPUTSTREAM_H__ +/***************************************************************************** +* * +* 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 ILINKOUTPUTSTREAM_H +#define ILINKOUTPUTSTREAM_H #include "XnLinkProtoLibDefs.h" #include "XnLinkProtoUtils.h" @@ -37,4 +57,4 @@ class ILinkOutputStream } -#endif // __ILINKOUTPUTSTREAM_H__ +#endif // ILINKOUTPUTSTREAM_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/IOutputConnection.h b/Source/Drivers/PSLink/LinkProtoLib/IOutputConnection.h index b3ca759e..a07ec37d 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/IOutputConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/IOutputConnection.h @@ -1,5 +1,25 @@ -#ifndef __IOUTPUTCONNECTION_H__ -#define __IOUTPUTCONNECTION_H__ +/***************************************************************************** +* * +* 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 IOUTPUTCONNECTION_H +#define IOUTPUTCONNECTION_H #include "IConnection.h" @@ -22,4 +42,4 @@ class IOutputConnection : virtual public IConnection } -#endif // __IOUTPUTCONNECTION_H__ \ No newline at end of file +#endif // IOUTPUTCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/ISyncIOConnection.h b/Source/Drivers/PSLink/LinkProtoLib/ISyncIOConnection.h index e3bf8801..c18a4617 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/ISyncIOConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/ISyncIOConnection.h @@ -1,5 +1,25 @@ -#ifndef __ISYNCIOCONNECTION_H__ -#define __ISYNCIOCONNECTION_H__ +/***************************************************************************** +* * +* 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 ISYNCIOCONNECTION_H +#define ISYNCIOCONNECTION_H #include #include @@ -35,4 +55,4 @@ class ISyncIOConnection : virtual public ISyncInputConnection, } -#endif // __ISYNCIOCONNECTION_H__ \ No newline at end of file +#endif // ISYNCIOCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/ISyncInputConnection.h b/Source/Drivers/PSLink/LinkProtoLib/ISyncInputConnection.h index 8df87ee3..9dda56d1 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/ISyncInputConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/ISyncInputConnection.h @@ -1,5 +1,25 @@ -#ifndef __ISYNCINPUTCONNECTION_H__ -#define __ISYNCINPUTCONNECTION_H__ +/***************************************************************************** +* * +* 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 ISYNCINPUTCONNECTION_H +#define ISYNCINPUTCONNECTION_H #include #include "IConnection.h" @@ -16,4 +36,4 @@ class ISyncInputConnection : virtual public IConnection } -#endif // __ISYNCINPUTCONNECTION_H__ \ No newline at end of file +#endif // ISYNCINPUTCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/LinkProtoLibVersion.h b/Source/Drivers/PSLink/LinkProtoLib/LinkProtoLibVersion.h index 2cc00191..19a7d30b 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/LinkProtoLibVersion.h +++ b/Source/Drivers/PSLink/LinkProtoLib/LinkProtoLibVersion.h @@ -1,5 +1,25 @@ -#ifndef __LINKPROTOLIBVERSION_H__ -#define __LINKPROTOLIBVERSION_H__ +/***************************************************************************** +* * +* 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 LINKPROTOLIBVERSION_H +#define LINKPROTOLIBVERSION_H //--------------------------------------------------------------------------- // Includes @@ -22,4 +42,4 @@ LINK_PROTO_LIB_BRIEF_VERSION_STRING "-" \ XN_PLATFORM_STRING " (" XN_TIMESTAMP ")" -#endif // __LINKPROTOLIBVERSION_H__ +#endif // LINKPROTOLIBVERSION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.cpp index 22b40b32..5668de06 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnClientSocketInConnection.h" #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.h b/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.h index 0df94bd9..61ad74a6 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientSocketInConnection.h @@ -1,5 +1,25 @@ -#ifndef __XNCLIENTSOCKETINCONNECTION_H__ -#define __XNCLIENTSOCKETINCONNECTION_H__ +/***************************************************************************** +* * +* 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 XNCLIENTSOCKETINCONNECTION_H +#define XNCLIENTSOCKETINCONNECTION_H #include "XnSocketInConnection.h" @@ -17,4 +37,4 @@ class ClientSocketInConnection : public SocketInConnection } -#endif // __XNCLIENTSOCKETINCONNECTION_H__ +#endif // XNCLIENTSOCKETINCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.cpp index e69de29b..143b6e89 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.cpp @@ -0,0 +1,20 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.h b/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.h index a03e92ab..cd2a9553 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientSyncSocketConnection.h @@ -1,3 +1,26 @@ +/***************************************************************************** +* * +* 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 XNCLIENTSYNCSOCKETCONNECTION_H +#define XNCLIENTSYNCSOCKETCONNECTION_H + #include "XnSyncSocketConnection.h" namespace xn @@ -9,3 +32,5 @@ class ClientSyncSocketConnection : public SyncSocketConnection }; } + +#endif // XNCLIENTSYNCSOCKETCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.cpp index ab3a011f..24b0181a 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnClientUSBConnectionFactory.h" #include "XnClientUSBControlEndpoint.h" #include "XnClientUSBOutDataEndpoint.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.h b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.h index 6ec7eac5..ed28c2fb 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBConnectionFactory.h @@ -1,5 +1,25 @@ -#ifndef __XNUSBCONNECTIONFACTORY_H__ -#define __XNUSBCONNECTIONFACTORY_H__ +/***************************************************************************** +* * +* 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 XNCLIENTUSBCONNECTIONFACTORY_H +#define XNCLIENTUSBCONNECTIONFACTORY_H #include "IConnectionFactory.h" #include "XnLinkProtoLibDefs.h" @@ -54,4 +74,4 @@ class ClientUSBConnectionFactory : public IConnectionFactory } -#endif // __XNUSBCONNECTIONFACTORY_H__ \ No newline at end of file +#endif // XNCLIENTUSBCONNECTIONFACTORY_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.cpp index 3ec29072..8ef06d80 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnClientUSBControlEndpoint.h" #include #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.h index 327b0431..c5f4712b 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBControlEndpoint.h @@ -1,5 +1,25 @@ -#ifndef __XNUSBCONTROLENDPOINT_H__ -#define __XNUSBCONTROLENDPOINT_H__ +/***************************************************************************** +* * +* 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 XNCLIENTUSBCONTROLENDPOINT_H +#define XNCLIENTUSBCONTROLENDPOINT_H #include "ISyncIOConnection.h" @@ -42,4 +62,4 @@ class ClientUSBControlEndpoint : virtual public ISyncIOConnection } -#endif // __XNUSBCONTROLENDPOINT_H__ \ No newline at end of file +#endif // XNCLIENTUSBCONTROLENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.cpp index 74c6f2c1..d61b559e 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnClientUSBInDataEndpoint.h" #include "XnLinkProtoLibDefs.h" #include @@ -103,10 +123,11 @@ void ClientUSBInDataEndpoint::Disconnect() XnStatus nRetVal = XN_STATUS_OK; if (m_bConnected) { + xnLogVerbose(XN_MASK_USB, "Shutting down endpoint 0x%x read thread...", m_nEndpointID); nRetVal = xnUSBShutdownReadThread(m_hEndpoint); if (nRetVal != XN_STATUS_OK) { - xnLogWarning("Failed to shutdown usb read thread: %s", xnGetStatusString(nRetVal)); + xnLogWarning(XN_MASK_USB, "Failed to shutdown endpoint 0x%x read thread: %s", m_nEndpointID, xnGetStatusString(nRetVal)); XN_ASSERT(FALSE); } m_bConnected = FALSE; diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.h index 003cd4ba..1f0b7a14 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBInDataEndpoint.h @@ -1,5 +1,25 @@ -#ifndef __XNUSBINDATAENDPOINT_H__ -#define __XNUSBINDATAENDPOINT_H__ +/***************************************************************************** +* * +* 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 XNCLIENTUSBINDATAENDPOINT_H +#define XNCLIENTUSBINDATAENDPOINT_H #include "IAsyncInputConnection.h" #include @@ -54,4 +74,4 @@ class ClientUSBInDataEndpoint : virtual public IAsyncInputConnection } -#endif // __XNUSBINDATAENDPOINT_H__ \ No newline at end of file +#endif // XNCLIENTUSBINDATAENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.cpp index e11d994a..dca67870 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnClientUSBOutDataEndpoint.h" #include #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.h index d1bdbf9e..c6619ad0 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnClientUSBOutDataEndpoint.h @@ -1,5 +1,25 @@ -#ifndef __XNUSBOUTDATAENDPOINT_H__ -#define __XNUSBOUTDATAENDPOINT_H__ +/***************************************************************************** +* * +* 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 XNCLIENTUSBOUTDATAENDPOINT_H +#define XNCLIENTUSBOUTDATAENDPOINT_H #include "IOutputConnection.h" #include @@ -40,4 +60,4 @@ class ClientUSBOutDataEndpoint : virtual public IOutputConnection } -#endif // __XNUSBOUTDATAENDPOINT_H__ \ No newline at end of file +#endif // XNCLIENTUSBOUTDATAENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnCyclicBuffer.h b/Source/Drivers/PSLink/LinkProtoLib/XnCyclicBuffer.h index 31cfdc5a..9a0c9de4 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnCyclicBuffer.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnCyclicBuffer.h @@ -1,5 +1,25 @@ -#ifndef __XNCYCLICBUFFER_H__ -#define __XNCYCLICBUFFER_H__ +/***************************************************************************** +* * +* 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 XNCYCLICBUFFER_H +#define XNCYCLICBUFFER_H #include @@ -120,4 +140,4 @@ class CyclicBuffer } -#endif // __XNCYCLICBUFFER_H__ +#endif // XNCYCLICBUFFER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.cpp index 225516ef..9af17507 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLink11BitS2DParser.h" #include "XnShiftToDepth.h" #include "XnLinkProtoUtils.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.h index e46c0257..2d6b6716 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink11BitS2DParser.h @@ -1,5 +1,25 @@ -#ifndef __XNLINK11BITS2DPARSER_H__ -#define __XNLINK11BITS2DPARSER_H__ +/***************************************************************************** +* * +* 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 XNLINK11BITS2DPARSER_H +#define XNLINK11BITS2DPARSER_H #include "XnLinkMsgParser.h" #include "XnShiftToDepth.h" @@ -28,4 +48,4 @@ class Link11BitS2DParser : public LinkMsgParser } -#endif // __XNLINK11BITS2DPARSER_H__ +#endif // XNLINK11BITS2DPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.cpp index 403af41b..2218b593 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLink12BitS2DParser.h" #include "XnShiftToDepth.h" #include "XnLinkProtoUtils.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.h index 7ba174e1..3d8f34bc 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink12BitS2DParser.h @@ -1,5 +1,25 @@ -#ifndef __XNLINK12BITS2DPARSER_H__ -#define __XNLINK12BITS2DPARSER_H__ +/***************************************************************************** +* * +* 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 XNLINK12BITS2DPARSER_H +#define XNLINK12BITS2DPARSER_H #include "XnLinkMsgParser.h" #include "XnShiftToDepth.h" @@ -36,4 +56,4 @@ class Link12BitS2DParser : public LinkMsgParser } -#endif // __XNLINK12BITS2DPARSER_H__ +#endif // XNLINK12BITS2DPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.cpp index 1a39ca56..b2f0dfc7 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLink16zParser.h" #include "XnShiftToDepth.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.h index 45725eee..c31854c3 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink16zParser.h @@ -1,3 +1,26 @@ +/***************************************************************************** +* * +* 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 XNLINK16ZPARSER_H +#define XNLINK16ZPARSER_H + #include "XnLinkMsgParser.h" struct XnShiftToDepthTables; @@ -42,3 +65,5 @@ class Link16zParser : public LinkMsgParser }; } + +#endif // XNLINK16ZPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.cpp index b7d34454..fdb5f0fa 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 #include "XnLink24zYuv422Parser.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.h index eb9d74e2..d94fcaee 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink24zYuv422Parser.h @@ -1,5 +1,25 @@ -#ifndef _XN_LINK_24Z_YUV422_PARSER_H_ -#define _XN_LINK_24Z_YUV422_PARSER_H_ +/***************************************************************************** +* * +* 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 XNLINK24ZYUV422PARSER_H +#define XNLINK24ZYUV422PARSER_H #include "XnLinkMsgParser.h" @@ -41,4 +61,4 @@ class Link24zYuv422Parser : public LinkMsgParser } -#endif //_XN_LINK_24Z_YUV422_PARSER_H_ \ No newline at end of file +#endif // XNLINK24ZYUV422PARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.cpp index ff544a68..a47e537d 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLink6BitParser.h" #include "XnLinkProtoUtils.h" #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.h index c48ba2bb..8c021a1a 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLink6BitParser.h @@ -1,5 +1,25 @@ -#ifndef _XNLINK6BITPARSER_H_ -#define _XNLINK6BITPARSER_H_ +/***************************************************************************** +* * +* 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 XNLINK6BITPARSER_H +#define XNLINK6BITPARSER_H #include "XnLinkMsgParser.h" @@ -26,4 +46,4 @@ class Link6BitParser : public LinkMsgParser } -#endif // _XNLINK6BITPARSER_H_ +#endif // XNLINK6BITPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.cpp index c4c14b2e..56eecba9 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkContInputStream.h" #include "XnLinkProtoUtils.h" #include "XnLinkProtoLibDefs.h" @@ -200,11 +220,13 @@ XnStatus LinkContInputStream::StartImpl() //We only need log buffer output if dumping is on m_logParser.GenerateOutputBuffer(m_pDumpFile != NULL); + //We must set the streaming flag first cuz the data handler checks it + m_bStreaming = TRUE; + nRetVal = m_pConnection->Connect(); XN_IS_STATUS_OK_LOG_ERROR("Connect stream's input connection", nRetVal); nRetVal = m_pLinkControlEndpoint->StartStreaming(m_nStreamID); XN_IS_STATUS_OK_LOG_ERROR("Start streaming", nRetVal); - m_bStreaming = TRUE; return XN_STATUS_OK; } diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.h index a5ff7dfc..642399b9 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkContInputStream.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKCONTINPUTSTREAM_H__ -#define __XNLINKCONTINPUTSTREAM_H__ +/***************************************************************************** +* * +* 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 XNLINKCONTINPUTSTREAM_H +#define XNLINKCONTINPUTSTREAM_H #include "XnLinkMsgParser.h" #include "XnLinkInputStream.h" @@ -76,4 +96,4 @@ class LinkContInputStream : public LinkInputStream } -#endif // __XNLINKCONTINPUTSTREAM_H__ \ No newline at end of file +#endif // XNLINKCONTINPUTSTREAM_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.cpp index 6d61c54e..16c85563 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkControlEndpoint.h" #include "XnLinkMsgEncoder.h" #include "XnLinkMsgParser.h" @@ -660,12 +680,7 @@ XnStatus LinkControlEndpoint::ExecuteImpl(XnUInt16 nMsgType, m_msgEncoder.EndEncoding(XnLinkFragmentation(fragmentation & XN_LINK_FRAG_END)); XnUInt32 nBytesLeftToSend = m_msgEncoder.GetEncodedSize(); - union - { - const XnUInt8* pRawCommandPacket; - XnLinkPacket* pCommandPacket; - }; - pRawCommandPacket = reinterpret_cast(m_msgEncoder.GetEncodedData()); + const XnUInt8* pRawCommandPacket = reinterpret_cast(m_msgEncoder.GetEncodedData()); /* Second step - Send each packet and get a response for it. */ while (nBytesLeftToSend > 0) @@ -831,6 +846,26 @@ XnStatus LinkControlEndpoint::HardReset() return XN_STATUS_OK; } +XnStatus LinkControlEndpoint::ReadDebugData(XnCommandDebugData& commandDebugData) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Getting debug data with ID %d...", commandDebugData.dataID); + + XnLinkGetDebugDataParams params; + params.m_nID = commandDebugData.dataID; + + XnUInt32 nResponseSize = m_nMaxResponseSize; + + XnLinkDebugDataResponse* pDebugDataRespondHeader = (XnLinkDebugDataResponse*)m_pIncomingResponse; + nRetVal = ExecuteCommand(XN_LINK_MSG_GET_DEBUG_DATA,XN_LINK_STREAM_ID_NONE, ¶ms, sizeof(params), m_pIncomingResponse, nResponseSize); + XN_IS_STATUS_OK_LOG_ERROR("Execute get debug data command", nRetVal); + + nRetVal = xnLinkReadDebugData(commandDebugData, pDebugDataRespondHeader); + XN_IS_STATUS_OK(nRetVal); + + return nRetVal; +} XnStatus LinkControlEndpoint::GetSupportedI2CDevices(xnl::Array& supportedDevices) { @@ -890,6 +925,40 @@ XnStatus LinkControlEndpoint::GetSupportedBistTests(xnl::Array& supp return XN_STATUS_OK; } +XnStatus LinkControlEndpoint::GetSupportedTempList(xnl::Array& supportedTempList) +{ + XnStatus nRetVal = XN_STATUS_OK; + xnLogVerbose(XN_MASK_LINK, "LINK: Getting supported Temperature list..."); + + XnLinkTemperatureSensorsList* pSupportedList = + reinterpret_cast(m_pIncomingResponse); + XnUInt32 nResponseSize = m_nMaxResponseSize; + + nRetVal = GetGeneralProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_TEMPERATURE_LIST, nResponseSize, pSupportedList); + XN_IS_STATUS_OK_LOG_ERROR("Execute get supported Temperature list command", nRetVal); + + nRetVal = xnLinkParseSupportedTempList(pSupportedList, nResponseSize, supportedTempList); + XN_IS_STATUS_OK(nRetVal); + + return XN_STATUS_OK; +} +XnStatus LinkControlEndpoint::GetTemperature(XnCommandTemperatureResponse& tempData) +{ + XnStatus nRetVal = XN_STATUS_OK; + xnLogVerbose(XN_MASK_LINK, "LINK: Getting Temperature for id %d...",tempData.id); + + XnLinkTemperatureResponse* pTemp = + reinterpret_cast(m_pIncomingResponse); + XnUInt32 nResponseSize = m_nMaxResponseSize; + + nRetVal = ExecuteCommand(XN_LINK_MSG_READ_TEMPERATURE, XN_LINK_STREAM_ID_NONE, &tempData,sizeof(XnCommandTemperatureResponse),pTemp, nResponseSize); + XN_IS_STATUS_OK_LOG_ERROR("Execute Get Temperature command", nRetVal); + + nRetVal = xnLinkParseGetTemperature(pTemp, nResponseSize, tempData); + XN_IS_STATUS_OK(nRetVal); + + return XN_STATUS_OK; +} XnStatus LinkControlEndpoint::ExecuteBistTests(XnUInt32 nID, uint32_t& errorCode, uint32_t& extraDataSize, uint8_t* extraData) { XnStatus nRetVal = XN_STATUS_OK; @@ -1171,7 +1240,6 @@ XnStatus LinkControlEndpoint::EnumerateStreams(xnl::Array& aStre for (XnUInt32 i = 0; i < nNumNodes; i++) { aStreamInfos[i].type = (XnFwStreamType)XN_PREPARE_VAR32_IN_BUFFER(pEnumerateNodesResponse->m_streamInfos[i].m_nStreamType); - XN_COMPILER_ASSERT(sizeof(aStreamInfos[i].creationInfo) >= sizeof(pEnumerateNodesResponse->m_streamInfos[i].m_strCreationInfo)); xnOSStrCopy(aStreamInfos[i].creationInfo, pEnumerateNodesResponse->m_streamInfos[i].m_strCreationInfo, sizeof(aStreamInfos[i].creationInfo)); @@ -1581,20 +1649,114 @@ XnStatus LinkControlEndpoint::GetSupportedInterfaces(XnUInt16 nStreamID, xnl::Bi return XN_STATUS_OK; } -XnStatus LinkControlEndpoint::SetEmitterActive(XnBool bActive) +XnStatus LinkControlEndpoint::SetProjectorActive(XnBool bActive) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Turning Projector %s...", bActive ? "on" : "off"); + + nRetVal = SetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_PROJECTOR_ENABLED, XnUInt64(bActive)); + XN_IS_STATUS_OK(nRetVal); + + xnLogInfo(XN_MASK_LINK, "LINK: Projector was turned %s", bActive ? "on" : "off"); + + return (XN_STATUS_OK); +} + +// Enables/Disables the BIST +XnStatus LinkControlEndpoint::SetAccActive(XnBool bActive) { XnStatus nRetVal = XN_STATUS_OK; - xnLogVerbose(XN_MASK_LINK, "LINK: Turning emitter %s...", bActive ? "on" : "off"); + xnLogVerbose(XN_MASK_LINK, "LINK: Turning Acc %s...", bActive ? "on" : "off"); - nRetVal = SetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_EMITTER_ACTIVE, XnUInt64(bActive)); + nRetVal = SetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_ACC_ENABLED, XnUInt64(bActive)); XN_IS_STATUS_OK(nRetVal); - xnLogInfo(XN_MASK_LINK, "LINK: Emitter was turned %s", bActive ? "on" : "off"); + xnLogInfo(XN_MASK_LINK, "LINK: Acc was turned %s", bActive ? "on" : "off"); return (XN_STATUS_OK); } +XnStatus LinkControlEndpoint::GetAccActive(XnBool& bActive) +{ + XnUInt64 nValue; + + xnLogVerbose(XN_MASK_LINK, "LINK: Getting Acc ..."); + + XnStatus nRetVal = GetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_ACC_ENABLED, nValue); + XN_IS_STATUS_OK(nRetVal); + + bActive = (nValue == TRUE); + + xnLogInfo(XN_MASK_LINK, "LINK: Acc is %s", bActive ? "on" : "off"); + + return nRetVal; +} + +// Enables/Disables the BIST +XnStatus LinkControlEndpoint::SetVDDActive(XnBool bActive) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Turning VDD %s...", bActive ? "on" : "off"); + + nRetVal = SetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_VDD_ENABLED, XnUInt64(bActive)); + XN_IS_STATUS_OK(nRetVal); + + xnLogInfo(XN_MASK_LINK, "LINK: VDD was turned %s", bActive ? "on" : "off"); + + return (XN_STATUS_OK); +} +// Enables/Disables the VDD - Valid Depth Detect (XN_LINK_PROP_ID_VDD_ENABLED) +//on - Safety mechanism is on | off - reduce power +XnStatus LinkControlEndpoint::GetVDDActive(XnBool& bActive) +{ + XnUInt64 nValue; + + xnLogVerbose(XN_MASK_LINK, "LINK: Getting VDD ..."); + + XnStatus nRetVal = GetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_VDD_ENABLED, nValue); + XN_IS_STATUS_OK(nRetVal); + + bActive = (nValue == TRUE); + + xnLogInfo(XN_MASK_LINK, "LINK: VDD is %s", bActive ? "on" : "off"); + + return nRetVal; +} + + +// Enables/Disables the Periodic BIST - monitors the +XnStatus LinkControlEndpoint::SetPeriodicBistActive(XnBool bActive) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Turning Periodic BIST %s...", bActive ? "on" : "off"); + + nRetVal = SetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_PERIODIC_BIST_ENABLED, XnUInt64(bActive)); + XN_IS_STATUS_OK(nRetVal); + + xnLogInfo(XN_MASK_LINK, "LINK: Periodic BIST was turned %s", bActive ? "on" : "off"); + + return (XN_STATUS_OK); +} + +XnStatus LinkControlEndpoint::GetPeriodicBistActive(XnBool& bActive) +{ + XnUInt64 nValue; + + xnLogVerbose(XN_MASK_LINK, "LINK: Getting Periodic BIST ..."); + + XnStatus nRetVal = GetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_PERIODIC_BIST_ENABLED, nValue); + XN_IS_STATUS_OK(nRetVal); + + bActive = (nValue == TRUE); + + xnLogInfo(XN_MASK_LINK, "LINK: Periodic BIST is %s", bActive ? "on" : "off"); + + return nRetVal; +} XnStatus LinkControlEndpoint::GetStreamFragLevel(XnUInt16 nStreamID, XnStreamFragLevel& streamFragLevel) { XnStatus nRetVal = XN_STATUS_OK; @@ -1739,4 +1901,112 @@ XnStatus LinkControlEndpoint::CloseFWLogFile(XnUInt8 logID, XnUInt16 nLogStreamI return XN_STATUS_OK; } +XnStatus LinkControlEndpoint::SetProjectorPulse(XnBool enabled, XnFloat delay, XnFloat width, XnFloat cycle) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Setting projector pulse..."); + + XnLinkProjectorPulse pulse; + pulse.m_bEnabled = enabled ? 1 : 0; + pulse.m_nDelay = XN_PREPARE_VAR_FLOAT_IN_BUFFER(delay); + pulse.m_nWidth = XN_PREPARE_VAR_FLOAT_IN_BUFFER(width); + pulse.m_nCycle = XN_PREPARE_VAR_FLOAT_IN_BUFFER(cycle); + + nRetVal = SetGeneralProperty(XN_LINK_PROP_ID_NONE, XN_LINK_PROP_ID_PROJECTOR_PULSE, sizeof(pulse), &pulse); + XN_IS_STATUS_OK(nRetVal); + + xnLogInfo(XN_MASK_LINK, "LINK: Projector pulse set"); + + return XN_STATUS_OK; +} + +XnStatus LinkControlEndpoint::GetProjectorPulse(XnBool& enabled, XnFloat& delay, XnFloat& width, XnFloat& framesToskip) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Getting projector pulse..."); + + XnLinkProjectorPulse pulse; + XnUInt32 nPropSize = sizeof(pulse); + nRetVal = GetGeneralProperty(XN_LINK_PROP_ID_NONE, XN_LINK_PROP_ID_FW_VERSION, nPropSize, &pulse); + XN_IS_STATUS_OK_LOG_ERROR("Execute get version command", nRetVal); + + if (nPropSize != sizeof(pulse)) + { + xnLogError(XN_MASK_LINK, "LINK: Got bad size of projector pulse property: %u instead of %u", nPropSize, sizeof(pulse)); + XN_ASSERT(FALSE); + return XN_STATUS_LINK_BAD_RESPONSE_SIZE; + } + + enabled = (pulse.m_bEnabled != 0); + delay = XN_PREPARE_VAR_FLOAT_IN_BUFFER(pulse.m_nDelay); + width = XN_PREPARE_VAR16_IN_BUFFER(pulse.m_nWidth); + framesToskip = XnFloat(pulse.m_nCycle); + + return XN_STATUS_OK; +} + +XnStatus LinkControlEndpoint::SetProjectorPower(XnUInt16 power) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Setting Projector power to %u...", power); + + nRetVal = SetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_PROJECTOR_POWER, XnUInt64(power)); + XN_IS_STATUS_OK(nRetVal); + + xnLogInfo(XN_MASK_LINK, "LINK: Projector power was set to %u", power); + + return (XN_STATUS_OK); +} + +XnStatus LinkControlEndpoint::GetProjectorPower(XnUInt16& power) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Getting projector power..."); + + XnUInt64 power64 = 0; + nRetVal = GetIntProperty(XN_LINK_STREAM_ID_NONE, XN_LINK_PROP_ID_PROJECTOR_POWER, power64); + XN_IS_STATUS_OK(nRetVal); + + power = (XnUInt16)power64; + + xnLogInfo(XN_MASK_LINK, "LINK: Projector power is %u", power); + + return (XN_STATUS_OK); +} + +XnStatus LinkControlEndpoint::SetGain(XnUInt16 streamID, XnUInt16 gain) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Setting stream %u gain to %u...", streamID, gain); + + nRetVal = SetIntProperty(streamID, XN_LINK_PROP_ID_GAIN, XnUInt64(gain)); + XN_IS_STATUS_OK(nRetVal); + + xnLogInfo(XN_MASK_LINK, "LINK: Stream %u gain was set to %u", streamID, gain); + + return (XN_STATUS_OK); +} + +XnStatus LinkControlEndpoint::GetGain(XnUInt16 streamID, XnUInt16& gain) +{ + XnStatus nRetVal = XN_STATUS_OK; + + xnLogVerbose(XN_MASK_LINK, "LINK: Getting stream %u gain...", streamID); + + XnUInt64 gain64 = 0; + nRetVal = GetIntProperty(streamID, XN_LINK_PROP_ID_GAIN, gain64); + XN_IS_STATUS_OK(nRetVal); + + gain = (XnUInt16)gain64; + + xnLogInfo(XN_MASK_LINK, "LINK: Stream %u gain is %u", streamID, gain); + + return (XN_STATUS_OK); +} + } diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.h index dee023d2..e6904427 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkControlEndpoint.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKCONTROLENDPOINT_H__ -#define __XNLINKCONTROLENDPOINT_H__ +/***************************************************************************** +* * +* 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 XNLINKCONTROLENDPOINT_H +#define XNLINKCONTROLENDPOINT_H #include "ISyncIOConnection.h" #include "XnLinkMsgEncoder.h" @@ -8,7 +28,6 @@ #include "XnLinkDefs.h" #include "XnLinkProtoLibDefs.h" #include -#include #include struct XnShiftToDepthConfig; @@ -64,7 +83,10 @@ class LinkControlEndpoint XnStatus StopStreaming(XnUInt16 nStreamID); XnStatus SoftReset(); XnStatus HardReset(); + XnStatus ReadDebugData(XnCommandDebugData& commandDebugData); XnStatus GetSupportedBistTests(xnl::Array& supportedTests); + XnStatus GetSupportedTempList(xnl::Array& supportedTests); + XnStatus GetTemperature(XnCommandTemperatureResponse& temp); XnStatus ExecuteBistTests(XnUInt32 nID, uint32_t& errorCode, uint32_t& extraDataSize, uint8_t* extraData); XnStatus StartUsbTest(); XnStatus StopUsbTest(); @@ -82,12 +104,23 @@ class LinkControlEndpoint XnStatus DestroyInputStream(XnUInt16 nStreamID); XnStatus SetCropping(XnUInt16 nStreamID, const OniCropping& cropping); XnStatus GetCropping(XnUInt16 nStreamID, OniCropping& cropping); - XnStatus SetEmitterActive(XnBool bActive); + XnStatus SetProjectorActive(XnBool bActive); + XnStatus SetAccActive(XnBool bActive); + XnStatus GetAccActive(XnBool& bActive); + XnStatus SetVDDActive(XnBool bActive); + XnStatus GetVDDActive(XnBool& bActive); + XnStatus SetPeriodicBistActive(XnBool bActive); + XnStatus GetPeriodicBistActive(XnBool& bActive); XnStatus GetSupportedLogFiles(xnl::Array& supportedFiles); XnStatus OpenFWLogFile(XnUInt8 logID, XnUInt16 nLogStreamID); XnStatus CloseFWLogFile(XnUInt8 logID, XnUInt16 nLogStreamID); - - //TODO: Implement Get emitter active + XnStatus SetProjectorPulse(XnBool enabled, XnFloat delay, XnFloat width, XnFloat cycle); + XnStatus GetProjectorPulse(XnBool& enabled, XnFloat& delay, XnFloat& width, XnFloat& framesToskip); + XnStatus SetProjectorPower(XnUInt16 power); + XnStatus GetProjectorPower(XnUInt16& power); + XnStatus SetGain(XnUInt16 streamID, XnUInt16 gain); + XnStatus GetGain(XnUInt16 streamID, XnUInt16& gain); + //TODO: Implement Get emitter active XnStatus GetStreamFragLevel(XnUInt16 nStreamID, XnStreamFragLevel& streamFragLevel); XnStatus GetMirror(XnUInt16 nStreamID, XnBool& bMirror); @@ -163,4 +196,4 @@ class LinkControlEndpoint }; } -#endif // __XNLINKCONTROLENDPOINT_H__ +#endif // XNLINKCONTROLENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.cpp index c7d27787..a109ffdc 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkFrameInputStream.h" #include "XnLinkProtoUtils.h" #include "XnLinkControlEndpoint.h" @@ -196,14 +216,14 @@ XnStatus LinkFrameInputStream::HandlePacket(const LinkPacketHeader& origHeader, header.SetSize(header.GetSize() - sizeof(XnUInt64)); // TEMP: inject the host's timestamp. Firmware can't produce timestamps yet - XnUInt64 nTimestamp; + XnUInt64 nTimestamp; nRetVal = xnOSGetHighResTimeStamp(&nTimestamp); if (nRetVal != XN_STATUS_OK) { xnLogWarning(XN_MASK_LINK, "Failed to get timestamp from os: %s", xnGetStatusString(nRetVal)); XN_ASSERT(FALSE); } - m_pCurrFrame->timestamp = nTimestamp; + m_pCurrFrame->timestamp = nTimestamp; // begin parsing frame nRetVal = m_pLinkMsgParser->BeginParsing(m_pCurrFrame->data, m_nBufferSize); @@ -248,9 +268,7 @@ XnStatus LinkFrameInputStream::HandlePacket(const LinkPacketHeader& origHeader, { //Save actual size of data in working buffer info m_pCurrFrame->dataSize = m_pLinkMsgParser->GetParsedSize(); - m_pCurrFrame->frameIndex = m_frameIndex++; - - m_pCurrFrame->frameIndex = m_frameIndex++; + m_pCurrFrame->frameIndex = ++m_frameIndex; m_pCurrFrame->croppingEnabled = m_cropping.enabled; if (m_cropping.enabled) { @@ -409,6 +427,7 @@ XnUInt32 LinkFrameInputStream::GetOutputBytesPerPixel() const switch (m_outputFormat) { case ONI_PIXEL_FORMAT_DEPTH_1_MM: + case ONI_PIXEL_FORMAT_DEPTH_100_UM: return sizeof(OniDepthPixel); case ONI_PIXEL_FORMAT_YUV422: return sizeof(OniYUV422DoublePixel)/2; @@ -486,13 +505,10 @@ XnBool LinkFrameInputStream::IsOutputFormatSupported(OniPixelFormat format) cons switch (format) { case ONI_PIXEL_FORMAT_DEPTH_1_MM: + case ONI_PIXEL_FORMAT_DEPTH_100_UM: return (m_streamType == XN_LINK_STREAM_TYPE_SHIFTS); - case ONI_PIXEL_FORMAT_YUV422: - return (m_streamType == XN_LINK_STREAM_TYPE_COLOR) && (m_videoMode.m_nPixelFormat == XN_FW_PIXEL_FORMAT_YUV422); - case ONI_PIXEL_FORMAT_RGB888: - return (m_streamType == XN_LINK_STREAM_TYPE_COLOR) && (m_videoMode.m_nPixelFormat == XN_FW_PIXEL_FORMAT_BAYER8); case ONI_PIXEL_FORMAT_GRAY16: - return (m_streamType == XN_LINK_STREAM_TYPE_COLOR) && (m_videoMode.m_nPixelFormat == XN_FW_PIXEL_FORMAT_GRAYSCALE16); + return (m_streamType == XN_LINK_STREAM_TYPE_IR) && (m_videoMode.m_nPixelFormat == XN_FW_PIXEL_FORMAT_GRAYSCALE16); default: return LinkInputStream::IsOutputFormatSupported(format); } @@ -541,11 +557,22 @@ XnStatus LinkFrameInputStream::SetVideoMode(const XnFwStreamVideoMode& videoMode nRetVal = UpdateCameraIntrinsics(); XN_IS_STATUS_OK_LOG_ERROR("Update Camera Intrinsics", nRetVal); - + // if needed, build shift-to-depth tables if (m_streamType == XN_LINK_STREAM_TYPE_SHIFTS) { nRetVal = m_pLinkControlEndpoint->GetShiftToDepthConfig(m_nStreamID, m_shiftToDepthConfig); + + if (m_outputFormat == ONI_PIXEL_FORMAT_DEPTH_100_UM) + { + m_shiftToDepthConfig.nDeviceMaxDepthValue = XN_MIN(m_shiftToDepthConfig.nDeviceMaxDepthValue * 10, XN_MAX_UINT16); + m_shiftToDepthConfig.nDepthMaxCutOff = XN_MIN(m_shiftToDepthConfig.nDepthMaxCutOff * 10, XN_MAX_UINT16); + m_shiftToDepthConfig.dDepthScale = 10.0; + + nRetVal = XnShiftToDepthInit(&m_shiftToDepthTables, &m_shiftToDepthConfig); + XN_IS_STATUS_OK_LOG_ERROR("Init shift to depth tables", nRetVal); + } + XN_IS_STATUS_OK(nRetVal); // construct tables @@ -574,34 +601,6 @@ XnStatus LinkFrameInputStream::GetShiftToDepthTables(const XnShiftToDepthTables* return XN_STATUS_OK; } -XnStatus LinkFrameInputStream::SetDepthScale(XnDouble dDepthScale) -{ - XnStatus nRetVal = XN_STATUS_OK; - - XnDouble dPrevScale = m_shiftToDepthConfig.dDepthScale; - - if (dDepthScale != dPrevScale) - { - XnDouble dNewMaxCutOff = m_shiftToDepthConfig.nDepthMaxCutOff / dPrevScale * dDepthScale; - if (dNewMaxCutOff > m_shiftToDepthConfig.nDeviceMaxDepthValue) - { - xnLogError(XN_MASK_LINK, "Can't set depth scale to %f: this will create a cut off larger than max depth (%u > %u)", - dDepthScale, (XnUInt32)dNewMaxCutOff, m_shiftToDepthConfig.nDeviceMaxDepthValue); - XN_ASSERT(FALSE); - return XN_STATUS_BAD_PARAM; - } - - m_shiftToDepthConfig.dDepthScale = dDepthScale; - m_shiftToDepthConfig.nDepthMaxCutOff = (OniDepthPixel)(m_shiftToDepthConfig.nDepthMaxCutOff / dPrevScale * dDepthScale); - m_shiftToDepthConfig.nDepthMinCutOff = (OniDepthPixel)(m_shiftToDepthConfig.nDepthMinCutOff / dPrevScale * dDepthScale); - - nRetVal = XnShiftToDepthUpdate(&m_shiftToDepthTables, &m_shiftToDepthConfig); - XN_IS_STATUS_OK(nRetVal); - } - - return (XN_STATUS_OK); -} - const OniCropping& LinkFrameInputStream::GetCropping() const { return m_cropping; @@ -659,12 +658,13 @@ LinkMsgParser* LinkFrameInputStream::CreateLinkMsgParser() } switch (outputFormat) { + case ONI_PIXEL_FORMAT_DEPTH_100_UM: case ONI_PIXEL_FORMAT_DEPTH_1_MM: { if (pixelFormat != XN_FW_PIXEL_FORMAT_SHIFTS_9_3) { xnLogError(XN_MASK_LINK, "Cannot convert from pixel format %d to depth!", pixelFormat); - XN_ASSERT(pixelFormat == XN_LINK_PIXEL_FORMAT_SHIFTS_9_3); + XN_ASSERT(pixelFormat == XN_FW_PIXEL_FORMAT_SHIFTS_9_3); return NULL; } @@ -689,7 +689,7 @@ LinkMsgParser* LinkFrameInputStream::CreateLinkMsgParser() if (pixelFormat != XN_FW_PIXEL_FORMAT_YUV422) { xnLogError(XN_MASK_LINK, "Cannot convert from pixel format %d to YUV422!", pixelFormat); - XN_ASSERT(pixelFormat == XN_LINK_PIXEL_FORMAT_YUV422); + XN_ASSERT(pixelFormat == XN_FW_PIXEL_FORMAT_YUV422); return NULL; } diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.h index d6068a84..a9bf8db1 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkFrameInputStream.h @@ -1,11 +1,30 @@ -#ifndef __XNLINKFRAMEINPUTSTREAM_H__ -#define __XNLINKFRAMEINPUTSTREAM_H__ +/***************************************************************************** +* * +* 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 XNLINKFRAMEINPUTSTREAM_H +#define XNLINKFRAMEINPUTSTREAM_H #include "XnLinkMsgParser.h" #include "XnLinkInputStream.h" #include #include -#include #include @@ -49,7 +68,7 @@ class LinkFrameInputStream : public LinkInputStream virtual XnStreamFragLevel GetStreamFragLevel() const { return XN_LINK_STREAM_FRAG_LEVEL_FRAMES; } typedef void (XN_CALLBACK_TYPE* NewFrameEventHandler)(const NewFrameEventArgs& args, void* pCookie); - NewFrameEvent::EventInterface& GetNewFrameEvent() { return m_newFrameEvent; } + NewFrameEvent::Interface& GetNewFrameEvent() { return m_newFrameEvent; } virtual XnBool IsOutputFormatSupported(OniPixelFormat format) const; @@ -59,7 +78,6 @@ class LinkFrameInputStream : public LinkInputStream virtual const XnShiftToDepthConfig& GetShiftToDepthConfig() const; virtual XnStatus GetShiftToDepthTables(const XnShiftToDepthTables*& pTables) const; - virtual XnStatus SetDepthScale(XnDouble dDepthScale); virtual const XnLinkCameraIntrinsics& GetCameraIntrinsics() const { return m_cameraIntrinsics; } @@ -134,4 +152,4 @@ class LinkFrameInputStream : public LinkInputStream } -#endif // __XNLINKFRAMEINPUTSTREAM_H__ +#endif // XNLINKFRAMEINPUTSTREAM_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.cpp index f472dd36..78d4d807 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkInputDataEndpoint.h" #include "IConnectionFactory.h" #include "XnLinkInputStreamsMgr.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.h index 2c0318a4..da195f51 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputDataEndpoint.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKINPUTDATAENDPOINT_H__ -#define __XNLINKINPUTDATAENDPOINT_H__ +/***************************************************************************** +* * +* 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 XNLINKINPUTDATAENDPOINT_H +#define XNLINKINPUTDATAENDPOINT_H #include "IAsyncInputConnection.h" #include "IConnection.h" @@ -55,4 +75,4 @@ class LinkInputDataEndpoint : public IDataDestination, public IConnection } -#endif // __XNLINKINPUTDATAENDPOINT_H__ +#endif // XNLINKINPUTDATAENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.cpp index 6832785d..883270ad 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkInputStream.h" #include "XnLinkControlEndpoint.h" @@ -170,4 +190,14 @@ XnStatus LinkInputStream::SetOutputFormat(OniPixelFormat format) return XN_STATUS_OK; } +XnStatus LinkInputStream::SetGain(XnUInt16 gain) +{ + return m_pLinkControlEndpoint->SetGain(m_nStreamID, gain); +} + +XnStatus LinkInputStream::GetGain(XnUInt16& gain) +{ + return m_pLinkControlEndpoint->GetGain(m_nStreamID, gain); +} + } diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.h index 89705d2a..1ea84b8b 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStream.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKINPUTSTREAM_H__ -#define __XNLINKINPUTSTREAM_H__ +/***************************************************************************** +* * +* 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 XNLINKINPUTSTREAM_H +#define XNLINKINPUTSTREAM_H #include "XnBitSet.h" #include "XnLinkProtoLibDefs.h" @@ -51,6 +71,9 @@ class LinkInputStream virtual XnBool GetMirror() const; virtual XnStatus SetMirror(XnBool bMirror); + virtual XnStatus SetGain(XnUInt16 gain); + virtual XnStatus GetGain(XnUInt16& gain); + protected: virtual XnStatus StartImpl() = 0; virtual XnStatus StopImpl() = 0; @@ -70,4 +93,4 @@ class LinkInputStream } -#endif // __XNLINKINPUTSTREAM_H__ +#endif // XNLINKINPUTSTREAM_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.cpp index 1decd934..d97c305a 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkInputStreamsMgr.h" #include "XnLinkProtoUtils.h" #include "XnLinkStatusCodes.h" @@ -229,7 +249,6 @@ void LinkInputStreamsMgr::HandlePacket(const LinkPacketHeader* pLinkPacketHeader nPacketID, nStreamID, xnFragmentationFlagsToStr(fragmentation), xnFragmentationFlagsToStr(pStreamInfo->prevFragmentation)); - XN_ASSERT(FALSE); pStreamInfo->packetLoss = TRUE; } @@ -247,7 +266,6 @@ void LinkInputStreamsMgr::HandlePacket(const LinkPacketHeader* pLinkPacketHeader { xnLogWarning(XN_MASK_LINK, "Inconsistent msg type for stream %u - expected 0x%04X but got 0x%04X", nStreamID, pStreamInfo->nMsgType, nMsgType); - XN_ASSERT(FALSE); pStreamInfo->packetLoss = TRUE; return; } @@ -267,7 +285,6 @@ void LinkInputStreamsMgr::HandlePacket(const LinkPacketHeader* pLinkPacketHeader { xnLogWarning(XN_MASK_LINK, "Failed to handle packet of %u bytes in stream %u: %s", pLinkPacketHeader->GetDataSize(), nStreamID, xnGetStatusString(nRetVal)); - XN_ASSERT(FALSE); return; } } diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.h index d89e9456..d544823d 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkInputStreamsMgr.h @@ -1,5 +1,25 @@ -#ifndef __LINKINPUTSTREAMSMGR_H__ -#define __LINKINPUTSTREAMSMGR_H__ +/***************************************************************************** +* * +* 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 XNLINKINPUTSTREAMSMGR_H +#define XNLINKINPUTSTREAMSMGR_H #include "XnLinkDefs.h" #include "XnLinkProtoLibDefs.h" @@ -66,4 +86,4 @@ class LinkInputStreamsMgr } -#endif // __LINKINPUTSTREAMSMGR_H__ +#endif // XNLINKINPUTSTREAMSMGR_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.cpp index 97868c7f..7962476f 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkLogParser.h" #include "XnLinkProtoUtils.h" #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.h index ff8ca4cf..d436b5b1 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkLogParser.h @@ -1,5 +1,25 @@ -#ifndef _XNLINKLOGPARSER_H_ -#define _XNLINKLOGPARSER_H_ +/***************************************************************************** +* * +* 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 XNLINKLOGPARSER_H +#define XNLINKLOGPARSER_H #include "XnLinkMsgParser.h" #include @@ -32,4 +52,4 @@ class LinkLogParser : public LinkMsgParser } -#endif // _XNLINKLOGPARSER_H_ +#endif // XNLINKLOGPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.cpp index b6139e47..876361b2 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkMsgEncoder.h" #include "XnLinkProtoUtils.h" #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.h index 0b835d7a..7aedf730 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgEncoder.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKENCODEDDATAUNIT_H__ -#define __XNLINKENCODEDDATAUNIT_H__ +/***************************************************************************** +* * +* 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 XNLINKMSGENCODER_H +#define XNLINKMSGENCODER_H #include "XnLinkDefs.h" #include "XnLinkProto.h" @@ -60,4 +80,4 @@ class LinkMsgEncoder } -#endif // __XNLINKENCODEDDATAUNIT_H__ \ No newline at end of file +#endif // XNLINKMSGENCODER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.cpp index faacfe7a..e66ff27c 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkMsgParser.h" #include "XnLinkProtoUtils.h" #include "XnLinkDefs.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.h index f46cff2e..ecaedd50 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkMsgParser.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKMSGPARSER_H__ -#define __XNLINKMSGPARSER_H__ +/***************************************************************************** +* * +* 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 XNLINKMSGPARSER_H +#define XNLINKMSGPARSER_H #include #include "XnLinkProtoUtils.h" @@ -37,4 +57,4 @@ class LinkMsgParser } -#endif // __XNLINKMSGPARSER_H__ \ No newline at end of file +#endif // XNLINKMSGPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.cpp index 59409371..5a571f99 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkOutputDataEndpoint.h" #include "IConnectionFactory.h" #include "IOutputConnection.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.h index af360409..1187b3d7 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputDataEndpoint.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKOUTPUTDATAENDPOINT_H__ -#define __XNLINKOUTPUTDATAENDPOINT_H__ +/***************************************************************************** +* * +* 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 XNLINKOUTPUTDATAENDPOINT_H +#define XNLINKOUTPUTDATAENDPOINT_H #include #include @@ -37,4 +57,4 @@ class LinkOutputDataEndpoint } -#endif // __XNLINKOUTPUTDATAENDPOINT_H__ +#endif // XNLINKOUTPUTDATAENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.cpp index 450aa29b..d9e7318b 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkOutputStream.h" #include "XnLinkMsgEncoder.h" #include "XnLinkOutputDataEndpoint.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.h index 1f048123..9f6afa15 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStream.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKOUTPUTSTREAM_H__ -#define __XNLINKOUTPUTSTREAM_H__ +/***************************************************************************** +* * +* 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 XNLINKOUTPUTSTREAM_H +#define XNLINKOUTPUTSTREAM_H #include "ILinkOutputStream.h" #include "XnLinkProtoUtils.h" @@ -45,4 +65,4 @@ class LinkOutputStream : public ILinkOutputStream }; } -#endif // __XNLINKOUTPUTSTREAM_H__ +#endif // XNLINKOUTPUTSTREAM_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.cpp index 1c3cd2ea..3d16407d 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkOutputStreamsMgr.h" #include "ILinkOutputStream.h" #include "XnLinkOutputStream.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.h index 0019f5ff..c94a7501 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkOutputStreamsMgr.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKOUTPUTSTREAMSMGR_H__ -#define __XNLINKOUTPUTSTREAMSMGR_H__ +/***************************************************************************** +* * +* 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 XNLINKOUTPUTSTREAMSMGR_H +#define XNLINKOUTPUTSTREAMSMGR_H #include "XnLinkProtoLibDefs.h" #include "XnLinkProtoUtils.h" @@ -46,4 +66,4 @@ class LinkOutputStreamsMgr } -#endif // __XNLINKOUTPUTSTREAMSMGR_H__ +#endif // XNLINKOUTPUTSTREAMSMGR_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.cpp index e9511ecf..4a797141 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkPacked10BitParser.h" #include "XnLinkProtoUtils.h" #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.h index 07a345f6..a677a5d9 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkPacked10BitParser.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKPACKED10BITPARSER_H__ -#define __XNLINKPACKED10BITPARSER_H__ +/***************************************************************************** +* * +* 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 XNLINKPACKED10BITPARSER_H +#define XNLINKPACKED10BITPARSER_H #include "XnLinkMsgParser.h" @@ -24,4 +44,4 @@ class LinkPacked10BitParser : public LinkMsgParser } -#endif // __XNLINKPACKED10BITPARSER_H__ \ No newline at end of file +#endif // XNLINKPACKED10BITPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoLibDefs.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoLibDefs.h index 94fe46ee..f1fd19e8 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoLibDefs.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoLibDefs.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKPROTOLIBDEFS_H__ -#define __XNLINKPROTOLIBDEFS_H__ +/***************************************************************************** +* * +* 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 XNLINKPROTOLIBDEFS_H +#define XNLINKPROTOLIBDEFS_H #include #include @@ -66,4 +86,4 @@ typedef struct XnComponentVersion XnChar m_strVersion[XN_MAX_VERSION_LENGTH]; } XnComponentVersion; -#endif // __XNLINKPROTOLIBDEFS_H__ +#endif // XNLINKPROTOLIBDEFS_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.cpp index 13737a32..c27f9281 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkProtoUtils.h" #include "XnLinkProto.h" #include "XnLinkDefs.h" @@ -64,6 +84,14 @@ XnStatus xnLinkResponseCodeToStatus(XnUInt16 nResponseCode) return XN_STATUS_LINK_RESP_BAD_PARAMETERS; case XN_LINK_RESPONSE_CORRUPT_PACKET: return XN_STATUS_LINK_RESP_CORRUPT_PACKET; + case XN_LINK_RESPONSE_FILE_CORRUPT: + return XN_STATUS_LINK_RESP_CORRUPT_FILE; + case XN_LINK_RESPONSE_BAD_CRC: + return XN_STATUS_LINK_RESP_BAD_CRC; + case XN_LINK_RESPONSE_INCORRECT_SIZE: + return XN_STATUS_LINK_RESP_INCORRECT_SIZE; + case XN_LINK_RESPONSE_INPUT_BUFFER_OVERFLOW: + return XN_STATUS_LINK_RESP_INPUT_BUFFER_OVERFLOW; default: return XN_STATUS_LINK_RESP_UNKNOWN; } @@ -577,7 +605,7 @@ const XnChar* xnLinkPropTypeToStr(XnLinkPropType propType) "General", //0x0004 }; - return (propType < sizeof(PROP_TYPE_STRS) / sizeof(PROP_TYPE_STRS[0])) ? PROP_TYPE_STRS[propType] : "Unknown"; + return ((size_t)propType < sizeof(PROP_TYPE_STRS) / sizeof(PROP_TYPE_STRS[0])) ? PROP_TYPE_STRS[propType] : "Unknown"; } /*XnProductionNodeType xnLinkStreamTypeToNINodeType(XnLinkStreamType streamType) @@ -940,6 +968,24 @@ XnUInt32 xnLinkGetPixelSizeByStreamType(XnLinkStreamType streamType) return 0; } } +XnStatus xnLinkReadDebugData(XnCommandDebugData& commandDebugData, XnLinkDebugDataResponse* pDebugDataResponse) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if(commandDebugData.dataSize < pDebugDataResponse->m_header.m_nValueSize) + { + xnLogError(XN_MASK_LINK, "Size of retrieved data was larger than requested: %u bytes, must be at least %u.", pDebugDataResponse->m_header.m_nValueSize, + commandDebugData.dataSize); + XN_ASSERT(FALSE); + return XN_STATUS_LINK_BAD_PROP_SIZE; + } + commandDebugData.dataSize = pDebugDataResponse->m_header.m_nValueSize; //if the sized received is smaller than expected + for(int i = 0; i < commandDebugData.dataSize; i++) + { + commandDebugData.data[i] = pDebugDataResponse->m_data[i]; + } + return nRetVal; +} XnStatus xnLinkParseSupportedI2CDevices(const XnLinkSupportedI2CDevices* pDevicesList, XnUInt32 nBufferSize, xnl::Array& supportedDevices) { @@ -975,6 +1021,8 @@ XnStatus xnLinkParseSupportedI2CDevices(const XnLinkSupportedI2CDevices* pDevice supportedDevices[i].m_nID = XN_PREPARE_VAR32_IN_BUFFER(pDevicesList->m_aI2CDevices[i].m_nID); nRetVal = xnOSStrCopy(supportedDevices[i].m_strName, pDevicesList->m_aI2CDevices[i].m_strName, sizeof(supportedDevices[i].m_strName)); XN_IS_STATUS_OK_LOG_ERROR("Copy I2C device name", nRetVal); + supportedDevices[i].m_nMasterID = pDevicesList->m_aI2CDevices[i].m_nMasterID; + supportedDevices[i].m_nSlaveID = pDevicesList->m_aI2CDevices[i].m_nSlaveID; } return XN_STATUS_OK; @@ -1058,6 +1106,73 @@ XnStatus xnLinkParseSupportedBistTests(const XnLinkSupportedBistTests* pSupporte return XN_STATUS_OK; } +XnStatus xnLinkParseSupportedTempList(const XnLinkTemperatureSensorsList* pSupportedList, XnUInt32 nBufferSize, xnl::Array& supportedTempList) +{ + XnStatus nRetVal = XN_STATUS_OK; + XnUInt32 nTemp = 0; + XnUInt32 nExpectedSize = 0; + + XN_VALIDATE_INPUT_PTR(pSupportedList); + + if (nBufferSize < sizeof(pSupportedList->m_nCount)) + { + xnLogError(XN_MASK_LINK, "Size of link supported Temperature list was only %u bytes, must be at least %u.", nBufferSize, + sizeof(pSupportedList->m_nCount)); + XN_ASSERT(FALSE); + return XN_STATUS_LINK_BAD_PROP_SIZE; + } + + nTemp = XN_PREPARE_VAR32_IN_BUFFER(pSupportedList->m_nCount); + nExpectedSize = (sizeof(pSupportedList->m_nCount) + + (sizeof(pSupportedList->m_aSensors[0]) * nTemp)); + if (nBufferSize != nExpectedSize) + { + xnLogError(XN_MASK_LINK, "Got bad size of 'supported Temperature list' property: %u instead of %u", nBufferSize, nExpectedSize); + XN_ASSERT(FALSE); + return XN_STATUS_LINK_BAD_RESPONSE_SIZE; + } + + nRetVal = supportedTempList.SetSize(nTemp); + XN_IS_STATUS_OK_LOG_ERROR("Set size of output supported Temperature list array", nRetVal); + + for (XnUInt32 i = 0; i < nTemp; i++) + { + supportedTempList[i].id = XN_PREPARE_VAR32_IN_BUFFER(pSupportedList->m_aSensors[i].m_nID); + nRetVal = xnOSStrCopy(supportedTempList[i].name, (const XnChar*) pSupportedList->m_aSensors[i].m_strName, sizeof(supportedTempList[i].name)); + XN_IS_STATUS_OK_LOG_ERROR("Copy Temperature list name", nRetVal); + } + + return XN_STATUS_OK; +} + +XnStatus xnLinkParseGetTemperature(const XnLinkTemperatureResponse* tempResponse, XnUInt32 nBufferSize, XnCommandTemperatureResponse& tempData) +{ + XnStatus nRetVal = XN_STATUS_OK; + XnUInt32 nExpectedSize = 0; + + XN_VALIDATE_INPUT_PTR(tempResponse); + + if (nBufferSize < sizeof(tempData.temperature)) + { + xnLogError(XN_MASK_LINK, "Size of link Get Temperature was only %u bytes, must be at least %u.", nBufferSize, + sizeof(tempData.temperature)); + XN_ASSERT(FALSE); + return XN_STATUS_LINK_BAD_PROP_SIZE; + } + + nExpectedSize = (sizeof(tempResponse)); + if (nBufferSize != nExpectedSize) + { + xnLogError(XN_MASK_LINK, "Got bad size of 'Temperature struct' property: %u instead of %u", nBufferSize, nExpectedSize); + XN_ASSERT(FALSE); + return XN_STATUS_LINK_BAD_RESPONSE_SIZE; + } + tempData.id = XN_PREPARE_VAR32_IN_BUFFER(tempResponse->m_nID); + tempData.temperature = XN_PREPARE_VAR_FLOAT_IN_BUFFER(tempResponse->value); + XN_IS_STATUS_OK_LOG_ERROR("Copy Temperature value", nRetVal); + + return XN_STATUS_OK; +} const XnChar* xnLinkPixelFormatToName(XnFwPixelFormat pixelFormat) { switch (pixelFormat) diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.h index d3f16b73..1b1f55d0 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkProtoUtils.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKPROTOUTILS_H__ -#define __XNLINKPROTOUTILS_H__ +/***************************************************************************** +* * +* 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 XNLINKPROTOUTILS_H +#define XNLINKPROTOUTILS_H #include "XnLinkDefs.h" #include "XnLinkProto.h" @@ -14,10 +34,6 @@ #define XN_MASK_LINK "xnLink" -#ifndef XN_COMPILER_ASSERT -#define XN_COMPILER_ASSERT(x) typedef int compileAssert[x ? 1 : -1] -#endif - template class XnArray; @@ -48,8 +64,6 @@ class LinkPacketHeader : private XnLinkPacketHeader void SetCID(XnUInt16 nCID) { m_nCID = nCID; } }; -XN_COMPILER_ASSERT(sizeof(xn::LinkPacketHeader) == sizeof(XnLinkPacketHeader)); - } XnStatus xnLinkResponseCodeToStatus(XnUInt16 nResponseCode); @@ -152,6 +166,9 @@ XnStatus xnLinkParseFrameSyncStreamIDsProp(XnLinkPropType propType, const void* XnStatus xnLinkParseComponentVersionsListProp(XnLinkPropType propType, const void* pValue, XnUInt32 nValueSize, xnl::Array& componentVersions); XnStatus xnLinkParseSupportedBistTests(const XnLinkSupportedBistTests* pSupportedTests, XnUInt32 nBufferSize, xnl::Array& supportedTests); +XnStatus xnLinkParseSupportedTempList(const XnLinkTemperatureSensorsList* pSupportedList, XnUInt32 nBufferSize, xnl::Array& supportedTempList); +XnStatus xnLinkParseGetTemperature(const XnLinkTemperatureResponse* tempResponse, XnUInt32 nBufferSize, XnCommandTemperatureResponse& tempData); +XnStatus xnLinkReadDebugData(XnCommandDebugData& commandDebugData, XnLinkDebugDataResponse* pDebugDataResponse); XnStatus xnLinkParseSupportedI2CDevices(const XnLinkSupportedI2CDevices* pSupportedTests, XnUInt32 nBufferSize, xnl::Array& supportedDevices); XnStatus xnLinkParseSupportedLogFiles(const XnLinkSupportedLogFiles* pFilesList, XnUInt32 nBufferSize, xnl::Array& supportedFiles); @@ -160,4 +177,4 @@ void xnLinkParseBootStatus(XnBootStatus& bootStatus, const XnLinkBootStatus& lin XnUInt32 xnLinkGetPixelSizeByStreamType(XnLinkStreamType streamType); void xnLinkVideoModeToString(XnFwStreamVideoMode videoMode, XnChar* buffer, XnUInt32 bufferSize); -#endif // __XNLINKPROTOUTILS_H__ +#endif // XNLINKPROTOUTILS_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.cpp index 740fe2fd..f7f2a74b 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkResponseMsgParser.h" #include "XnLinkStatusCodes.h" #include "XnLinkProtoUtils.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.h index 5da63157..7645c408 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkResponseMsgParser.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKRESPONSEMSGPARSER_H__ -#define __XNLINKRESPONSEMSGPARSER_H__ +/***************************************************************************** +* * +* 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 XNLINKRESPONSEMSGPARSER_H +#define XNLINKRESPONSEMSGPARSER_H #include "XnLinkMsgParser.h" @@ -18,5 +38,5 @@ class LinkResponseMsgParser : public LinkMsgParser } -#endif // __XNLINKRESPONSEMSGPARSER_H__ +#endif // XNLINKRESPONSEMSGPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.cpp index 35f4f2bf..94dfe3ed 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ // registration is done by including XnStatusRegister *before* including the list of errors #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.h index f460699b..b7e483f7 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkStatusCodes.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKSTATUSCODES_H__ -#define __XNLINKSTATUSCODES_H__ +/***************************************************************************** +* * +* 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 XNLINKSTATUSCODES_H +#define XNLINKSTATUSCODES_H #include #include "XnLinkProtoLibDefs.h" @@ -60,16 +80,16 @@ XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_BAD_PARAMETERS, "Link response: bad parame XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_CORRUPT_PACKET, "Link response: Corrupt packet") //31785 -XN_STATUS_MESSAGE(XN_STATUS_LINK_RESERVED1, "RESERVED1") +XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_CORRUPT_FILE, "Link response: File is corrupt") //31786 -XN_STATUS_MESSAGE(XN_STATUS_LINK_RESERVED2, "RESERVED2") +XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_BAD_CRC, "Link response: Bad CRC") //31787 -XN_STATUS_MESSAGE(XN_STATUS_LINK_RESERVED3, "RESERVED3") +XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_INCORRECT_SIZE, "Link response: Incorrect size") //31788 -XN_STATUS_MESSAGE(XN_STATUS_LINK_RESERVED4, "RESERVED4") +XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_INPUT_BUFFER_OVERFLOW, "Link response: Input buffer overflow") //31789 XN_STATUS_MESSAGE(XN_STATUS_LINK_RESP_UNKNOWN, "Link response: Unknown response code") @@ -115,4 +135,4 @@ XN_STATUS_MESSAGE(XN_STATUS_LINK_BAD_PROP_SIZE, "Bad property size") XN_PS_STATUS_MESSAGE_MAP_END(XN_ERROR_GROUP_LINKPROTOLIB) -#endif // __XNEESTATUSCODES_H__ +#endif // XNLINKSTATUSCODES_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.cpp index 174f9486..41800b5e 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkUnpackedDataReductionParser.h" #include "XnLinkProtoUtils.h" #include "XnLinkDefs.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.h index ff2abb40..4995b147 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedDataReductionParser.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKUNPACKEDDATAREDUCTIONPARSER_H__ -#define __XNLINKUNPACKEDDATAREDUCTIONPARSER_H__ +/***************************************************************************** +* * +* 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 XNLINKUNPACKEDDATAREDUCTIONPARSER_H +#define XNLINKUNPACKEDDATAREDUCTIONPARSER_H #include #include "XnLinkDefs.h" @@ -29,4 +49,4 @@ class LinkUnpackedDataReductionParser : public LinkMsgParser } -#endif // __XNLINKUNPACKEDDATAREDUCTIONPARSER_H__ +#endif // XNLINKUNPACKEDDATAREDUCTIONPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.cpp index 9766a223..8d1ef438 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkUnpackedS2DParser.h" #include "XnShiftToDepth.h" #include "XnLinkProtoUtils.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.h index bd82d4b8..4c42ad6e 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkUnpackedS2DParser.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKUNPACKEDS2DPARSER_H__ -#define __XNLINKUNPACKEDS2DPARSER_H__ +/***************************************************************************** +* * +* 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 XNLINKUNPACKEDS2DPARSER_H +#define XNLINKUNPACKEDS2DPARSER_H #include "XnLinkMsgParser.h" #include "XnShiftToDepth.h" @@ -25,4 +45,4 @@ class LinkUnpackedS2DParser : public LinkMsgParser } -#endif // __XNLINKUNPACKEDS2DPARSER_H__ +#endif // XNLINKUNPACKEDS2DPARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.cpp index 1922f06c..036d2a62 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnLinkYuv422ToRgb888Parser.h" #include "XnLinkYuvToRgb.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.h index 3a6d9977..8566cbcc 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuv422ToRgb888Parser.h @@ -1,5 +1,25 @@ -#ifndef _XN_LINK_YUV_422_TO_RGB_888_PARSER_H_ -#define _XN_LINK_YUV_422_TO_RGB_888_PARSER_H_ +/***************************************************************************** +* * +* 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 XNLINKYUV422TORGB888PARSER_H +#define XNLINKYUV422TORGB888PARSER_H #include "XnLinkMsgParser.h" @@ -23,4 +43,4 @@ class LinkYuv422ToRgb888Parser : public LinkMsgParser } -#endif //_XN_LINK_YUV_422_TO_RGB_888_PARSER_H_ \ No newline at end of file +#endif // XNLINKYUV422TORGB888PARSER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.cpp index 6c775ba0..29343e8a 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 #include #if (XN_PLATFORM == XN_PLATFORM_WIN32) diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.h b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.h index 4cf7a3c5..a8eb3a57 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnLinkYuvToRgb.h @@ -1,5 +1,25 @@ -#ifndef _XN_LINK_YUV_TO_RGB_H_ -#define _XN_LINK_YUV_TO_RGB_H_ +/***************************************************************************** +* * +* 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 XNLINKYUVTORGB_H +#define XNLINKYUVTORGB_H namespace xn { @@ -17,4 +37,4 @@ class LinkYuvToRgb } -#endif //_XN_LINK_YUV_TO_RGB_H_ \ No newline at end of file +#endif // XNLINKYUVTORGB_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnMapSequenceListConverter.h b/Source/Drivers/PSLink/LinkProtoLib/XnMapSequenceListConverter.h index aaa7f0a5..0a206f46 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnMapSequenceListConverter.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnMapSequenceListConverter.h @@ -1,7 +1,27 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ // XnMapSequenceListConverter.h -#ifndef _XNMAPSEQUENCELISTCONVERTER_H_ -#define _XNMAPSEQUENCELISTCONVERTER_H_ +#ifndef XNMAPSEQUENCELISTCONVERTER_H +#define XNMAPSEQUENCELISTCONVERTER_H namespace xn @@ -203,4 +223,4 @@ class XnMapSequenceListConverter } -#endif +#endif // XNMAPSEQUENCELISTCONVERTER_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.cpp index 04ee85d8..51dae925 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnServerSocketInConnection.h" #include diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.h b/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.h index b620846e..94ef3e84 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnServerSocketInConnection.h @@ -1,6 +1,26 @@ - -#ifndef _XNSERVERSOCKETINCONNECTION_H_ -#define _XNSERVERSOCKETINCONNECTION_H_ +/***************************************************************************** +* * +* 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 XNSERVERSOCKETINCONNECTION_H +#define XNSERVERSOCKETINCONNECTION_H #include "XnSocketInConnection.h" @@ -21,4 +41,4 @@ class ServerSocketInConnection : public SocketInConnection } -#endif \ No newline at end of file +#endif // XNSERVERSOCKETINCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxConnectionFactory.h b/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxConnectionFactory.h index ca553e9a..f70a647c 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxConnectionFactory.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxConnectionFactory.h @@ -1,5 +1,25 @@ -#ifndef __XNSERVERLINUXUSBCONNECTIONFACTORY_H__ -#define __XNSERVERLINUXUSBCONNECTIONFACTORY_H__ +/***************************************************************************** +* * +* 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 XNSERVERUSBLINUXCONNECTIONFACTORY_H +#define XNSERVERUSBLINUXCONNECTIONFACTORY_H #include "IConnectionFactory.h" #include "XnServerUSBLinuxControlEndpoint.h" @@ -37,4 +57,4 @@ class ServerUSBLinuxConnectionFactory : public IConnectionFactory } -#endif // __XNSERVERLINUXUSBCONNECTIONFACTORY_H__ +#endif // XNSERVERUSBLINUXCONNECTIONFACTORY_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxControlEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxControlEndpoint.h index 53c1a4da..2de6fa8c 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxControlEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxControlEndpoint.h @@ -1,3 +1,26 @@ +/***************************************************************************** +* * +* 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 XNSERVERUSBLINUXCONTROLENDPOINT_H +#define XNSERVERUSBLINUXCONTROLENDPOINT_H + #include "ISyncIOConnection.h" #include @@ -34,4 +57,5 @@ class ServerUSBLinuxControlEndpoint : virtual public ISyncIOConnection XnBool m_bConnected; }; -} \ No newline at end of file +} +#endif // XNSERVERUSBLINUXCONTROLENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxOutDataEndpoint.h b/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxOutDataEndpoint.h index 025fff44..a62508d1 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxOutDataEndpoint.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnServerUSBLinuxOutDataEndpoint.h @@ -1,5 +1,25 @@ -#ifndef __XNSERVERUSBLINUXOUTDATAENDPOINT_H__ -#define __XNSERVERUSBLINUXOUTDATAENDPOINT_H__ +/***************************************************************************** +* * +* 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 XNSERVERUSBLINUXOUTDATAENDPOINT_H +#define XNSERVERUSBLINUXOUTDATAENDPOINT_H #include "IOutputConnection.h" @@ -30,4 +50,4 @@ class ServerUSBLinuxOutDataEndpoint : virtual public IOutputConnection } -#endif // __XNSERVERUSBLINUXOUTDATAENDPOINT_H__ +#endif // XNSERVERUSBLINUXOUTDATAENDPOINT_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.cpp index cc6cc4e8..6fc79a05 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- @@ -85,7 +105,7 @@ XnStatus XnShiftToDepthUpdate(XnShiftToDepthTables* pShiftToDepth, const XnShift } } - for (XnUInt16 i = nLastDepth; i <= pConfig->nDeviceMaxDepthValue; i++) + for (XnUInt32 i = nLastDepth; i <= pConfig->nDeviceMaxDepthValue; i++) pDepthToShiftTable[i] = nLastIndex; return XN_STATUS_OK; diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.h b/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.h index 48b2ac00..48a04af9 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnShiftToDepth.h @@ -1,6 +1,26 @@ +/***************************************************************************** +* * +* 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 _XN_SHIFT_TO_DEPTH_H_ -#define _XN_SHIFT_TO_DEPTH_H_ +#ifndef XNSHIFTTODEPTH_H +#define XNSHIFTTODEPTH_H //--------------------------------------------------------------------------- // Includes @@ -64,4 +84,4 @@ XnStatus XnShiftToDepthConvert(const XnShiftToDepthTables* pShiftToDepth, XnStatus XnShiftToDepthFree(XnShiftToDepthTables* pShiftToDepth); -#endif //_XN_SHIFT_TO_DEPTH_H_ +#endif // XNSHIFTTODEPTH_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.cpp index a1470b1a..b743a034 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnSocketConnectionFactory.h" #include "XnSyncSocketConnection.h" #include "XnSocketInConnection.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.h b/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.h index 3b34c2b4..bd110531 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSocketConnectionFactory.h @@ -1,5 +1,25 @@ -#ifndef __SOCKETCONNECTIONFACTORY_H__ -#define __SOCKETCONNECTIONFACTORY_H__ +/***************************************************************************** +* * +* 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 XNSOCKETCONNECTIONFACTORY_H +#define XNSOCKETCONNECTIONFACTORY_H #include "IConnectionFactory.h" #include "XnSyncSocketConnection.h" @@ -74,5 +94,5 @@ class SocketConnectionFactory: public IConnectionFactory } -#endif // __SOCKETCONNECTIONFACTORY_H__ +#endif // XNSOCKETCONNECTIONFACTORY_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.cpp index 754cb0d4..75d03643 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnSocketInConnection.h" #include "XnLinkProto.h" #include "XnLinkProtoUtils.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.h b/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.h index dcc2c528..073a372e 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSocketInConnection.h @@ -1,5 +1,25 @@ -#ifndef __XNSOCKETINCONNECTION_H__ -#define __XNSOCKETINCONNECTION_H__ +/***************************************************************************** +* * +* 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 XNSOCKETINCONNECTION_H +#define XNSOCKETINCONNECTION_H #include "IAsyncInputConnection.h" #include "XnLinkProtoLibDefs.h" @@ -52,4 +72,4 @@ class SocketInConnection : public IAsyncInputConnection } -#endif // __XNSOCKETINCONNECTION_H__ \ No newline at end of file +#endif // XNSOCKETINCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.cpp index 8a483e4c..b263fcd1 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.cpp @@ -1,8 +1,27 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ // XnSyncServerSocketConnection.cpp #include "XnSyncServerSocketConnection.h" -#include namespace xn { diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.h b/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.h index 961d7441..b5c0e9a4 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSyncServerSocketConnection.h @@ -1,7 +1,27 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ // XnSyncServerSocketConnection.h -#ifndef _XNSYNCSERVERSOCKETCONNECTION_H_ -#define _XNSYNCSERVERSOCKETCONNECTION_H_ +#ifndef XNSYNCSERVERSOCKETCONNECTION_H +#define XNSYNCSERVERSOCKETCONNECTION_H #include "XnSyncSocketConnection.h" #include "XnStatusCodes.h" @@ -99,4 +119,4 @@ class SyncServerSocketListener } -#endif //_XNSYNCSERVERSOCKETCONNECTION_H_ +#endif // XNSYNCSERVERSOCKETCONNECTION_H diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.cpp b/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.cpp index 37e7002c..8dddc836 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.cpp +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "XnSyncSocketConnection.h" #include "XnLinkProto.h" #include "XnLinkProtoUtils.h" diff --git a/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.h b/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.h index 3ec9428b..38b8a790 100644 --- a/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.h +++ b/Source/Drivers/PSLink/LinkProtoLib/XnSyncSocketConnection.h @@ -1,5 +1,25 @@ -#ifndef __SYNCSOCKETCONNECTION_H__ -#define __SYNCSOCKETCONNECTION_H__ +/***************************************************************************** +* * +* 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 XNSYNCSOCKETCONNECTION_H +#define XNSYNCSOCKETCONNECTION_H #include "ISyncIOConnection.h" #include "XnLinkProtoLibDefs.h" @@ -47,4 +67,4 @@ class SyncSocketConnection : virtual public ISyncIOConnection } -#endif // __SYNCSOCKETCONNECTION_H__ \ No newline at end of file +#endif // XNSYNCSOCKETCONNECTION_H diff --git a/Source/Drivers/PSLink/Makefile b/Source/Drivers/PSLink/Makefile index 7a72defa..729b84f3 100644 --- a/Source/Drivers/PSLink/Makefile +++ b/Source/Drivers/PSLink/Makefile @@ -19,9 +19,15 @@ LIB_DIRS += $(BIN_DIR)/$(PLATFORM)-$(CFG) USED_LIBS = XnLib dl pthread ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib - LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib + LDFLAGS += \ + -framework CoreFoundation \ + -framework IOKit endif ifneq ("$(OSTYPE)","Darwin") diff --git a/Source/Drivers/PSLink/PS1200Device.cpp b/Source/Drivers/PSLink/PS1200Device.cpp index caff56ed..2fe872ae 100644 --- a/Source/Drivers/PSLink/PS1200Device.cpp +++ b/Source/Drivers/PSLink/PS1200Device.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "PS1200Device.h" #include "XnClientUSBConnectionFactory.h" #include "XnSocketConnectionFactory.h" @@ -39,18 +59,6 @@ XnStatus PS1200Device::Init(const XnChar* strConnString, XnTransportType transpo nRetVal = PrimeClient::Init(strConnString, XN_TRANSPORT_TYPE_USB); XN_IS_STATUS_OK_LOG_ERROR("Init EE Device", nRetVal); -#if (XN_PLATFORM == XN_PLATFORM_WIN32) - // On all platforms other than Windows, prefer BULK - nRetVal = SetUsbAltInterface(0); - XN_IS_STATUS_OK_LOG_ERROR("Switch to ISO", nRetVal); -#elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_MACOSX || XN_PLATFORM == XN_PLATFORM_ANDROID_ARM) - // On all platforms other than Windows, prefer BULK - nRetVal = SetUsbAltInterface(1); - XN_IS_STATUS_OK_LOG_ERROR("Switch to BULK", nRetVal); -#else - #error "Unsupported platform" -#endif - m_bInitialized = TRUE; return XN_STATUS_OK; } diff --git a/Source/Drivers/PSLink/PS1200Device.h b/Source/Drivers/PSLink/PS1200Device.h index 4886d541..546bc584 100644 --- a/Source/Drivers/PSLink/PS1200Device.h +++ b/Source/Drivers/PSLink/PS1200Device.h @@ -1,5 +1,25 @@ -#ifndef __PS1200DEVICE_H__ -#define __PS1200DEVICE_H__ +/***************************************************************************** +* * +* 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 PS1200DEVICE_H +#define PS1200DEVICE_H #include "PrimeClient.h" #include @@ -50,4 +70,4 @@ class PS1200Device : public PrimeClient } -#endif // __PS1200DEVICE_H__ +#endif // PS1200DEVICE_H diff --git a/Source/Drivers/PSLink/PSLink.vcxproj b/Source/Drivers/PSLink/PSLink.vcxproj index 8915163a..f540eba5 100644 --- a/Source/Drivers/PSLink/PSLink.vcxproj +++ b/Source/Drivers/PSLink/PSLink.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,19 +28,23 @@ DynamicLibrary Unicode true + v120 DynamicLibrary Unicode + v120 DynamicLibrary Unicode true + v120 DynamicLibrary Unicode + v120 @@ -96,6 +100,7 @@ Windows MachineX86 true + false @@ -249,6 +254,7 @@ + diff --git a/Source/Drivers/PSLink/PSLink.vcxproj.filters b/Source/Drivers/PSLink/PSLink.vcxproj.filters index bcf95649..ab8b6d4e 100644 --- a/Source/Drivers/PSLink/PSLink.vcxproj.filters +++ b/Source/Drivers/PSLink/PSLink.vcxproj.filters @@ -10,6 +10,21 @@ {9ad7f4c4-30f7-4229-a39e-869596ebeb88} + + {1fd8ff78-3304-4e56-a928-985d804a94a9} + + + {694a7b9e-e358-4446-ab98-9f7d02befa4c} + + + {594fa818-6886-4fbe-bfa7-93cdea955e82} + + + {aa427e5a-0908-4545-938f-0e8164954f70} + + + {b274b874-bb4a-4afd-a68e-99f7155eb917} + @@ -32,166 +47,166 @@ DriverImpl - - LinkProtoLib - - - LinkProtoLib - - + LinkProtoLib - + LinkProtoLib - + LinkProtoLib - - LinkProtoLib + + + + Protocol - - LinkProtoLib + + Protocol - - LinkProtoLib + + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections + + + LinkProtoLib\Connections + + + LinkProtoLib\Connections + + + LinkProtoLib\Connections + + + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib - - - LinkProtoLib + LinkProtoLib\Streams - LinkProtoLib - - - LinkProtoLib + LinkProtoLib\Streams - - LinkProtoLib + + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Endpoints - - LinkProtoLib + + LinkProtoLib\Endpoints - LinkProtoLib + LinkProtoLib\Endpoints - LinkProtoLib + LinkProtoLib\Streams - - LinkProtoLib + + LinkProtoLib\Streams - - LinkProtoLib + + LinkProtoLib\Streams - - LinkProtoLib + + LinkProtoLib\Streams - - LinkProtoLib + + LinkProtoLib\Streams - - LinkProtoLib + + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - - LinkProtoLib - - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Utils - - LinkProtoLib + + LinkProtoLib\Utils - - - - Protocol + + LinkProtoLib\Utils - - Protocol + + LinkProtoLib\Utils + + + LinkProtoLib\Utils @@ -217,115 +232,118 @@ DriverImpl + + + + DriverImpl + - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib - - - LinkProtoLib + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Streams - LinkProtoLib + LinkProtoLib\Streams - - LinkProtoLib - - - LinkProtoLib + + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Endpoints - - LinkProtoLib + + LinkProtoLib\Endpoints - LinkProtoLib + LinkProtoLib\Endpoints + + + LinkProtoLib\Streams + + + LinkProtoLib\Streams - LinkProtoLib + LinkProtoLib\Streams - LinkProtoLib + LinkProtoLib\Streams - LinkProtoLib - - - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - LinkProtoLib + LinkProtoLib\Parsers - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - LinkProtoLib + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Connections - - LinkProtoLib + + LinkProtoLib\Utils - - LinkProtoLib + + LinkProtoLib\Utils + + + LinkProtoLib\Utils - - \ No newline at end of file diff --git a/Source/Drivers/PSLink/PSLinkConsole/Makefile b/Source/Drivers/PSLink/PSLinkConsole/Makefile index 0f0ff971..7b11009c 100644 --- a/Source/Drivers/PSLink/PSLinkConsole/Makefile +++ b/Source/Drivers/PSLink/PSLinkConsole/Makefile @@ -18,9 +18,15 @@ LIB_DIRS = ../../../../ThirdParty/PSCommon/XnLib/Bin/$(PLATFORM)-$(CFG) USED_LIBS = OpenNI2 XnLib dl pthread ifeq ("$(OSTYPE)","Darwin") - INC_DIRS += /opt/local/include - LIB_DIRS += /opt/local/lib - LDFLAGS += -framework CoreFoundation -framework IOKit + INC_DIRS += \ + /usr/local/include \ + /opt/local/include + LIB_DIRS += \ + /usr/local/lib \ + /opt/local/lib + LDFLAGS += \ + -framework CoreFoundation \ + -framework IOKit endif ifneq ("$(OSTYPE)","Darwin") diff --git a/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.cpp b/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.cpp index 922cfe6f..6e37a39f 100644 --- a/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.cpp +++ b/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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. * +* * +*****************************************************************************/ // PSLinkConsole.cpp : Defines the entry point for the console application. // @@ -268,20 +288,8 @@ const char* fwVideoModeToString(XnFwStreamVideoMode videoMode) //--------------------------------------------------------------------------- // Framework //--------------------------------------------------------------------------- -void RunCommand(XnChar* strCmdLine) +void RunCommand(int argc, const char* argv[]) { - enum {CMD_MAX_ARGS = 256}; - const char* argv[CMD_MAX_ARGS] = {NULL}; - int argc = CMD_MAX_ARGS; - - SplitStr(strCmdLine, argv, &argc); - - if (argc == 0) - { - //Ignore empty lines - return; - } - char commandName[XN_FILE_MAX_PATH]; xnOSStrCopy(commandName, argv[0], sizeof(commandName)); @@ -303,6 +311,23 @@ void RunCommand(XnChar* strCmdLine) command.handler(argc, argv); } +void RunCommand(XnChar* strCmdLine) +{ + enum {CMD_MAX_ARGS = 256}; + const char* argv[CMD_MAX_ARGS] = {NULL}; + int argc = CMD_MAX_ARGS; + + SplitStr(strCmdLine, argv, &argc); + + if (argc == 0) + { + //Ignore empty lines + return; + } + + RunCommand(argc, argv); +} + void ExecuteCommandsFromStream(FILE* pStream, XnBool bPrompt) { XnChar strCmdLine[1024]; @@ -1042,30 +1067,164 @@ int HardReset(int /*argc*/, const char* /*argv*/[]) return nRetVal; } +// Retrieve data from firmware according to the command number received from user +int ReadDebugData(int argc, const char* argv[]) +{ + + XnStatus nRetVal = XN_STATUS_OK; + XnCommandDebugData commandDebugData = {0}; + if (argc < 2) + { + printf("\nUsage: %s \n\n", argv[0]); + return -1; + } + + XnUInt8 debugData[1024]; + commandDebugData.dataID = (uint16_t)MyAtoi(argv[1]); + commandDebugData.dataSize = sizeof(debugData); + commandDebugData.data = debugData; + + nRetVal = g_device.invoke(PS_COMMAND_READ_DEBUG_DATA, &commandDebugData, sizeof(commandDebugData)); + if (nRetVal == STATUS_OK) + { + printf("\nCommand: %x Data size: %d \nData:" ,commandDebugData.dataID, commandDebugData.dataSize); + for(int i = 0; i < commandDebugData.dataSize; i++) + { + if(i % 8 == 0) + { + printf("\n"); + } + printf("%02x ",commandDebugData.data[i]); + } + printf("\n\n"); + } + else + { + printf("Failed to retrieve data: %s\n\n", OpenNI::getExtendedError()); + } + + return nRetVal; +} -int Emitter(int argc, const char* argv[]) +// Enables/Disables the BIST (XN_LINK_PROP_ID_ACC_ENABLED) +int Acc(int argc, const char* argv[]) { - if ((argc < 2) || - ((xnOSStrCaseCmp(argv[1], "on") != 0) && (xnOSStrCaseCmp(argv[1], "off") != 0))) + XnBool bAccEnabled; + Status nRetVal; + if(argc == 1) + { + nRetVal = g_device.getProperty(LINK_PROP_ACC_ENABLED, &bAccEnabled); + if (nRetVal == STATUS_OK) + { + printf("Acc is %s.\n\n", (bAccEnabled ? "on" : "off")); + } + else + { + printf("Failed to get Acc: %s\n\n", OpenNI::getExtendedError()); + } + + return nRetVal; + } + + if((xnOSStrCaseCmp(argv[1], "on") != 0) && (xnOSStrCaseCmp(argv[1], "off") != 0)) + { + printf("Usage: %s \n\n", argv[0]); + return -1; + } + const XnChar* strAccActive = argv[1]; + bAccEnabled = (xnOSStrCaseCmp(strAccActive, "on") == 0); + nRetVal = g_device.setProperty(LINK_PROP_ACC_ENABLED, bAccEnabled); + if (nRetVal == STATUS_OK) { - printf("Usage: %s \n\n", argv[0]); - return -1; + printf("Acc is now %s.\n\n", strAccActive); + } + else + { + printf("Failed to set Acc %s: %s\n\n", strAccActive, OpenNI::getExtendedError()); } - const XnChar* strEmitterActive = argv[1]; - XnBool bEmitterActive = (xnOSStrCaseCmp(strEmitterActive, "on") == 0); - Status nRetVal = g_device.setProperty(LINK_PROP_EMITTER_ACTIVE, bEmitterActive); + + return nRetVal; +} +// Enables/Disables the VDD - Valid Depth Detect (XN_LINK_PROP_ID_VDD_ENABLED) +//on - Safety mechanism is on | off - reduce power +int VDD(int argc, const char* argv[]) +{ + XnBool bAccEnabled; + Status nRetVal; + if(argc == 1) + { + nRetVal = g_device.getProperty(LINK_PROP_VDD_ENABLED, &bAccEnabled); + if (nRetVal == STATUS_OK) + { + printf("VDD is %s.\n\n", (bAccEnabled ? "on" : "off")); + } + else + { + printf("Failed to get VDD: %s\n\n", OpenNI::getExtendedError()); + } + + return nRetVal; + } + + if((xnOSStrCaseCmp(argv[1], "on") != 0) && (xnOSStrCaseCmp(argv[1], "off") != 0)) + { + printf("Usage: %s \n\n", argv[0]); + return -1; + } + const XnChar* strAccActive = argv[1]; + bAccEnabled = (xnOSStrCaseCmp(strAccActive, "on") == 0); + nRetVal = g_device.setProperty(LINK_PROP_VDD_ENABLED, bAccEnabled); if (nRetVal == STATUS_OK) { - printf("Emitter is now %s.\n\n", strEmitterActive); + printf("VDD is now %s.\n\n", strAccActive); } else { - printf("Failed to set emitter %s: %s\n\n", strEmitterActive, OpenNI::getExtendedError()); + printf("Failed to set VDD %s: %s\n\n", strAccActive, OpenNI::getExtendedError()); } return nRetVal; } +// Enables/Disables the Periodic BIST (XN_LINK_PROP_ID_PERIODIC_BIST_ENABLED) +int PeriodicBist(int argc, const char* argv[]) +{ + XnBool bAccEnabled; + Status nRetVal; + if(argc == 1) + { + nRetVal = g_device.getProperty(LINK_PROP_PERIODIC_BIST_ENABLED, &bAccEnabled); + if (nRetVal == STATUS_OK) + { + printf("Periodic BIST is %s.\n\n", (bAccEnabled ? "on" : "off")); + } + else + { + printf("Failed to get Periodic BIST: %s\n\n", OpenNI::getExtendedError()); + } + + return nRetVal; + } + + if((xnOSStrCaseCmp(argv[1], "on") != 0) && (xnOSStrCaseCmp(argv[1], "off") != 0)) + { + printf("Usage: %s \n\n", argv[0]); + return -1; + } + const XnChar* strAccActive = argv[1]; + bAccEnabled = (xnOSStrCaseCmp(strAccActive, "on") == 0); + nRetVal = g_device.setProperty(LINK_PROP_PERIODIC_BIST_ENABLED, bAccEnabled); + if (nRetVal == STATUS_OK) + { + printf("Periodic BIST is now %s.\n\n", strAccActive); + } + else + { + printf("Failed to set Periodic BIST %s: %s\n\n", strAccActive, OpenNI::getExtendedError()); + } + + return nRetVal; +} xnl::Array& GetLogMaskList() { static xnl::Array s_masks; @@ -1248,9 +1407,13 @@ int PrintLogFilesList(int /*argc*/, const char* /*argv*/[]) int PrintI2CList(int /*argc*/, const char* /*argv*/[]) { xnl::Array& deviceList = GetI2CDeviceList(); + + printf("%2s %32s %9s %8s", "ID", "NAME", "MASTER-ID", "SLAVE-ID\n"); + printf("%2s %32s %9s %8s", "==", "====", "=========", "========\n"); + for (XnUInt32 i = 0; i < deviceList.GetSize(); ++i) { - printf("%4u %s\n", deviceList[i].id, deviceList[i].name); + printf("%2u %32s %9u %8u\n", deviceList[i].id, deviceList[i].name, deviceList[i].masterId, deviceList[i].slaveId); } return 0; @@ -1280,96 +1443,197 @@ int PrintBistList(int /*argc*/, const char* /*argv*/[]) return 0; } - int RunBist(int argc, const char* argv[]) +{ + Status nRetVal = STATUS_OK; + + if (argc < 2) + { + printf("Usage: %s ALL | ...\n\n", argv[0]); + return -1; + } + + XnBistInfo bistInfos[20]; + XnCommandGetBistList supportedTests; + supportedTests.tests = bistInfos; + supportedTests.count = sizeof(bistInfos)/sizeof(bistInfos[0]); + + if (STATUS_OK != g_device.invoke(PS_COMMAND_GET_BIST_LIST, supportedTests)) + { + printf("Failed getting tests list: %s\n\n", OpenNI::getExtendedError()); + return -2; + } + + xnl::BitSet requestedTests; + + if (xnOSStrCaseCmp(argv[1], "ALL") == 0) + { + for (XnUInt32 i = 0; i < supportedTests.count; ++i) + { + requestedTests.Set(supportedTests.tests[i].id, TRUE); + } + } + else + { + for (int i = 1; i < argc; ++i) + { + requestedTests.Set(MyAtoi(argv[i]), TRUE); + } + } + + XnUInt8 response[512]; + XnCommandExecuteBist args; + args.extraData = response; + + for (XnUInt32 i = 0; i < requestedTests.GetSize(); ++i) + { + if (!requestedTests.IsSet(i)) + { + continue; + } + + // search for test in list (for its name) + const XnChar* testName = "Unknown"; + for (XnUInt32 j = 0; j < supportedTests.count; ++j) + { + if (supportedTests.tests[j].id == i) + { + testName = supportedTests.tests[j].name; + break; + } + } + + printf("Executing test %u (%s)...\n", i, testName); + + args.id = i; + args.extraDataSize = sizeof(response); + nRetVal = g_device.invoke(PS_COMMAND_EXECUTE_BIST, args); + if (nRetVal != STATUS_OK) + { + printf("\nFailed to execute: %s\n\n", OpenNI::getExtendedError()); + return nRetVal; + } + + printf("Test %u (%s) ", i, testName); + + if (args.errorCode != 0) + { + printf("Failed (error code 0x%04X).", args.errorCode); + } + else + { + printf("Passed."); + } + + printf("\n"); + + // extra data + if (args.extraDataSize > 0) + { + printf("Extra Data: "); + for (XnUInt32 j = 0; j < args.extraDataSize; ++j) + { + printf("%02X ", args.extraData[j]); + } + printf("\n"); + } + } + + printf("\n"); + + return (XN_STATUS_OK); +} +//Prints option list in which the user can choose to get the temperature +int PrintTempList(int /*argc*/, const char* /*argv*/[]) +{ + XnTempInfo tempInfo[20]; + XnCommandGetTempList args; + args.pTempInfos = tempInfo; + args.count = sizeof(tempInfo)/sizeof(tempInfo[0]); + + if (STATUS_OK != g_device.invoke(PS_COMMAND_GET_TEMP_LIST, args)) + { + printf("Failed getting Temperature list: %s\n\n", OpenNI::getExtendedError()); + return 1; + } + else + { + for (XnUInt32 i = 0; i < args.count; ++i) + { + printf("%4u %s\n", tempInfo[i].id, tempInfo[i].name); + } + + printf("\n"); + } + + return 0; +} +int ReadTemps(int argc, const char* argv[]) { Status nRetVal = STATUS_OK; if (argc < 2) { - printf("Usage: %s ALL | ...\n\n", argv[0]); + printf("Usage: %s ALL | | ...\n\n", argv[0]); return -1; } - xnl::BitSet requestedTests; + XnTempInfo TempInfos[20]; + XnCommandGetTempList supportedTempList; + supportedTempList.pTempInfos = TempInfos; + supportedTempList.count = sizeof(TempInfos)/sizeof(TempInfos[0]); - if (xnOSStrCaseCmp(argv[1], "ALL") == 0) + if (STATUS_OK != g_device.invoke(PS_COMMAND_GET_TEMP_LIST, supportedTempList)) { - XnBistInfo tests[20]; - XnCommandGetBistList args; - args.tests = tests; - args.count = sizeof(tests)/sizeof(tests[0]); - - if (STATUS_OK != g_device.invoke(PS_COMMAND_GET_BIST_LIST, args)) - { - printf("Failed getting tests list: %s\n\n", OpenNI::getExtendedError()); - return -2; - } - - for (XnUInt32 i = 0; i < args.count; ++i) - { - requestedTests.Set(tests[i].id, TRUE); - } - } - else - { - for (int i = 1; i < argc; ++i) - { - requestedTests.Set(MyAtoi(argv[i]), TRUE); - } + printf("Failed getting Temperature list: %s\n\n", OpenNI::getExtendedError()); + return -2; } - XnUInt8 response[512]; - XnCommandExecuteBist args; - args.extraData = response; - for (XnUInt32 i = 0; i < requestedTests.GetSize(); ++i) + XnCommandTemperatureResponse response; + if (xnOSStrCaseCmp(argv[1], "ALL") == 0) { - if (!requestedTests.IsSet(i)) + for (XnUInt32 i = 0; i < supportedTempList.count; ++i) { - continue; - } - - printf("Executing test %u...\n", i); - args.id = i; - args.extraDataSize = sizeof(response); - nRetVal = g_device.invoke(PS_COMMAND_EXECUTE_BIST, args); - if (nRetVal != STATUS_OK) - { - printf("\nFailed to execute: %s\n\n", OpenNI::getExtendedError()); - return nRetVal; - } - - printf("Test %u ", i); - - if (args.errorCode != 0) - { - printf("Failed (error code 0x%04X).", args.errorCode); - } - else - { - printf("Passed."); - } - - printf("\n"); - - // extra data - if (args.extraDataSize > 0) - { - printf("Extra Data: "); - for (XnUInt32 j = 0; j < args.extraDataSize; ++j) - { - printf("%02X ", args.extraData[j]); - } - printf("\n"); + response.id = supportedTempList.pTempInfos[i].id; + nRetVal = g_device.invoke(PS_COMMAND_READ_TEMPERATURE, response); + if(nRetVal != STATUS_OK) + { + printf("Failed getting Temperature data for id %d: %s\n\n", response.id, OpenNI::getExtendedError()); + } + else + { + printf("%s \t Temperature: %f \n\n", supportedTempList.pTempInfos[i].name, response.temperature); + } } } - - printf("\n"); + else + { + XnInt32 argInt= (argv[1][0] >= '0' && argv[1][0] <= '9') ? MyAtoi(argv[1]) : -1; + for (XnUInt32 i = 0; i < supportedTempList.count; ++i) + { + if ((xnOSStrCaseCmp(argv[1],supportedTempList.pTempInfos[i].name) == 0) + || (argInt == (XnInt32)supportedTempList.pTempInfos[i].id) ) + { + response.id = supportedTempList.pTempInfos[i].id; + nRetVal = g_device.invoke(PS_COMMAND_READ_TEMPERATURE, response); + if(nRetVal != STATUS_OK) + { + printf("Failed getting Temperature data for id %d: %s\n\n", response.id, OpenNI::getExtendedError()); + } + else + { + printf("%s \t Temperature: %f \n\n", supportedTempList.pTempInfos[i].name, response.temperature); + } + break; + } + } + } return (XN_STATUS_OK); } + int Quit(int /*argc*/, const char* /*argv*/[]) { g_continue = FALSE; @@ -1440,7 +1704,9 @@ int FormatZone(int argc, const char* argv[]) } XnUInt32 nZone = MyAtoi(argv[1]); - Status nRetVal = g_device.invoke(PS_COMMAND_FORMAT_ZONE, nZone); + XnCommandFormatZone formatZone; + formatZone.zone = (uint8_t)nZone; + Status nRetVal = g_device.invoke(PS_COMMAND_FORMAT_ZONE, formatZone); if (nRetVal == STATUS_OK) { printf("Successfully formatZone.\n\n"); @@ -1496,6 +1762,106 @@ int TestAll(int /*argc*/, const char* /*argv*/[]) return XN_STATUS_OK; } +int Projector(int argc, const char* argv[]) +{ + XnStatus nRetVal = XN_STATUS_OK; + + if (argc > 1) + { + //Projector command + XnBool bProjectorActive = (xnOSStrCaseCmp(argv[1], "on") == 0); + if((bProjectorActive || xnOSStrCaseCmp(argv[1], "off") == 0)) + { + Status nRetVal = g_device.setProperty(LINK_PROP_PROJECTOR_ACTIVE, bProjectorActive); + if (nRetVal == STATUS_OK) + { + printf("Projector is now %s.\n\n", argv[1]); + } + else + { + printf("Failed to set Projector %s: %s\n\n", argv[1], OpenNI::getExtendedError()); + } + + return nRetVal; + } + + if (xnOSStrCaseCmp(argv[1], "power") == 0) + { + if (argc > 2) + { + // set power + XnUInt16 power = (XnUInt16)MyAtoi(argv[2]); + nRetVal = g_device.setProperty(LINK_PROP_PROJECTOR_POWER, power); + if (nRetVal != XN_STATUS_OK) + { + printf("Failed to set projector power: %s\n\n", xnGetStatusString(nRetVal)); + return -2; + } + + return 0; + } + else + { + // get power + XnUInt16 power; + nRetVal = g_device.getProperty(LINK_PROP_PROJECTOR_POWER, &power); + if (nRetVal != XN_STATUS_OK) + { + printf("Failed to get projector power: %s\n\n", xnGetStatusString(nRetVal)); + return -3; + } + + printf("Projector power is %u\n\n", power); + return 0; + } + } + else if (xnOSStrCaseCmp(argv[1], "pulse") == 0) + { + if (argc > 2) + { + if (xnOSStrCaseCmp(argv[2], "on") == 0 && argc > 5) + { + XnCommandSetProjectorPulse args; + args.delay = (float)atof(argv[3]); + args.cycle = (float)atof(argv[5]); + args.width = (float)atof(argv[4]); //where both delay and width are in ms, and can be float + + nRetVal = g_device.invoke(LINK_COMMAND_SET_PROJECTOR_PULSE, args); + if (nRetVal != XN_STATUS_OK) + { + printf("Failed to set projector pulse: %s\n\n", xnGetStatusString(nRetVal)); + return -3; + } + + printf("Projector pulse set\n\n"); + return 0; + } + else if (xnOSStrCaseCmp(argv[2], "off") == 0) + { + nRetVal = g_device.invoke(LINK_COMMAND_DISABLE_PROJECTOR_PULSE, NULL, 0); + if (nRetVal != XN_STATUS_OK) + { + printf("Failed to disable projector pulse: %s\n\n", xnGetStatusString(nRetVal)); + return -3; + } + + printf("Projector pulse disabled\n\n"); + return 0; + } + } + } + } + + // if we got here, something was wrong with the arguments + printf("Usage: \n"); + printf("\t%s \n", argv[0]); + printf("\t%s power [newVal]\n", argv[0]); + printf("\t%s pulse on \n", argv[0]); + printf("\t%s pulse off\n", argv[0]); + printf("\n"); + return -1; +} + void RegisterCommands() { RegisterCommand("Help", Help); @@ -1523,17 +1889,23 @@ void RegisterCommands() RegisterCommand("WriteAHB", WriteAHB); RegisterCommand("ReadAHB", ReadAHB); RegisterCommand("SoftReset", SoftReset); - RegisterCommand("HardReset", HardReset); - RegisterCommand("Emitter", Emitter); + RegisterCommand("HardReset", HardReset); + RegisterCommand("ReadDebugData", ReadDebugData); + RegisterCommand("Acc", Acc); + RegisterCommand("VDD", VDD); + RegisterCommand("PeriodBist", PeriodicBist); RegisterCommand("Log", Log); RegisterCommand("LogList", PrintLogFilesList); RegisterCommand("Script", Script); RegisterCommand("BistList", PrintBistList); - RegisterCommand("Bist", RunBist); + RegisterCommand("Bist", RunBist); + RegisterCommand("TempList", PrintTempList); + RegisterCommand("Temp", ReadTemps); RegisterCommand("UsbInterface", UsbInterface); RegisterCommand("FormatZone", FormatZone); RegisterCommand("UsbTest", UsbTest); RegisterCommand("TestAll", TestAll); + RegisterCommand("Projector", Projector); RegisterCommand("Quit", Quit); RegisterCommand("Bye", Quit); RegisterCommand("Exit", Quit); @@ -1544,7 +1916,8 @@ int main(int argc, char* argv[]) Status nRetVal = STATUS_OK; const XnChar* strScriptFile = NULL; XnUInt16 nProductID = 0; - XnBool bQuit = FALSE; + const char** commandArgv = NULL; + int commandArgc = 0; // printf("PSLinkConsole version %s\n", XN_PS_VERSION_STRING); @@ -1566,11 +1939,8 @@ int main(int argc, char* argv[]) else if (xnOSStrCaseCmp(argv[nArgIndex], "-help") == 0) { printf("USAGE\n"); - printf("\t%s [-transport ] [-product ] [-script ] [-help]\n", argv[0]); + printf("\t%s [-product ] [-script ] [-help] [command]\n", argv[0]); printf("OPTIONS\n"); - printf("\t-transport \n"); - printf("\t\tOpen a device from a specific transport, either USB or from a specific IP and port number.\n"); - printf("\t\tWhen omitted, USB will be used.\n"); printf("\t-product \n"); printf("\t\tOpen only devices with a specific product ID. By default, any device can be opened.\n"); printf("\t-script \n"); @@ -1587,8 +1957,9 @@ int main(int argc, char* argv[]) } else { - printf("Unknown option: %s\n. Run %s -help for usage.\n", argv[nArgIndex], argv[0]); - return -1; + commandArgc = argc - nArgIndex; + commandArgv = (const char**)(argv + nArgIndex); + break; } } @@ -1657,13 +2028,17 @@ int main(int argc, char* argv[]) return -5; } - if (bQuit) - { - return 0; - } + return 0; + } + else if (commandArgc != 0) + { + RunCommand(commandArgc, commandArgv); + return 0; + } + else + { + ExecuteCommandsFromStream(stdin, TRUE); } - - ExecuteCommandsFromStream(stdin, TRUE); g_device.close(); OpenNI::shutdown(); diff --git a/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.vcxproj b/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.vcxproj index e6c7c8cb..e166a82d 100644 --- a/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.vcxproj +++ b/Source/Drivers/PSLink/PSLinkConsole/PSLinkConsole.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,19 +28,23 @@ Application MultiByte true + v120 Application MultiByte + v120 Application MultiByte true + v120 Application MultiByte + v120 @@ -96,6 +100,7 @@ Console MachineX86 true + false diff --git a/Source/Drivers/PSLink/PrimeClient.cpp b/Source/Drivers/PSLink/PrimeClient.cpp index bd871c23..c6ff846a 100644 --- a/Source/Drivers/PSLink/PrimeClient.cpp +++ b/Source/Drivers/PSLink/PrimeClient.cpp @@ -1,3 +1,23 @@ +/***************************************************************************** +* * +* 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 "PrimeClient.h" #include "XnLinkInputStreamsMgr.h" #include @@ -207,6 +227,11 @@ XnStatus PrimeClient::HardReset() return m_linkControlEndpoint.HardReset(); } +XnStatus PrimeClient::ReadDebugData(XnCommandDebugData& commandDebugData) +{ + return m_linkControlEndpoint.ReadDebugData(commandDebugData); +} + XnStatus PrimeClient::WriteI2C(XnUInt8 nDeviceID, XnUInt8 nAddressSize, XnUInt32 nAddress, XnUInt8 nValueSize, XnUInt32 nValue, XnUInt32 nMask) { return m_linkControlEndpoint.WriteI2C(nDeviceID, nAddressSize, nAddress, nValueSize, nValue, nMask); @@ -330,11 +355,40 @@ XnStatus PrimeClient::DownloadFile(XnUInt16 zone, const XnChar* strFirmwareFileN return m_linkControlEndpoint.DownloadFile(zone, strFirmwareFileName, strTargetFile); } -XnStatus PrimeClient::SetEmitterActive(XnBool bActive) +XnStatus PrimeClient::SetProjectorActive(XnBool bActive) +{ + return m_linkControlEndpoint.SetProjectorActive(bActive); +} + +XnStatus PrimeClient::SetAccActive(XnBool bActive) +{ + return m_linkControlEndpoint.SetAccActive(bActive); +} + +XnStatus PrimeClient::GetAccActive(XnBool& bActive) +{ + return m_linkControlEndpoint.GetAccActive(bActive); +} + +XnStatus PrimeClient::SetVDDActive(XnBool bActive) +{ + return m_linkControlEndpoint.SetVDDActive(bActive); +} + +XnStatus PrimeClient::GetVDDActive(XnBool& bActive) { - return m_linkControlEndpoint.SetEmitterActive(bActive); + return m_linkControlEndpoint.GetVDDActive(bActive); } +XnStatus PrimeClient::SetPeriodicBistActive(XnBool bActive) +{ + return m_linkControlEndpoint.SetPeriodicBistActive(bActive); +} + +XnStatus PrimeClient::GetPeriodicBistActive(XnBool& bActive) +{ + return m_linkControlEndpoint.GetPeriodicBistActive(bActive); +} void PrimeClient::LogVersions() { static XnBool bVersionsLoggedOnce = FALSE; @@ -560,6 +614,18 @@ XnStatus PrimeClient::RunPresetFile(const XnChar* strFileName) { continue; } + // skip comments + int i; + int length = (int)strlen(strLine); + for(i = 0; i < length; i++) { + if(strLine[i] == ' ' || strLine[i] == '\t') { + continue; + } + } + if (i < length && strLine[i] == '#' ) + { + continue; + } // block name XnChar* pToken = strtok(strLine, ","); @@ -613,7 +679,14 @@ XnStatus PrimeClient::GetSupportedBistTests(xnl::Array& supportedTes { return m_linkControlEndpoint.GetSupportedBistTests(supportedTests); } - +XnStatus PrimeClient::GetSupportedTempList(xnl::Array& supportedTempList) +{ + return m_linkControlEndpoint.GetSupportedTempList(supportedTempList); +} +XnStatus PrimeClient::GetTemperature(XnCommandTemperatureResponse& temp) +{ + return m_linkControlEndpoint.GetTemperature(temp); +} XnStatus PrimeClient::GetSupportedI2CDevices(xnl::Array& supportedDevices) { return m_linkControlEndpoint.GetSupportedI2CDevices(supportedDevices); @@ -641,4 +714,29 @@ XnStatus PrimeClient::GetBootStatus(XnBootStatus& bootStatus) return m_linkControlEndpoint.GetBootStatus(bootStatus); } +XnStatus PrimeClient::EnableProjectorPulse(XnFloat delay, XnFloat width, XnFloat cycle) +{ + return m_linkControlEndpoint.SetProjectorPulse(TRUE, delay, width, cycle); +} + +XnStatus PrimeClient::DisableProjectorPulse() +{ + return m_linkControlEndpoint.SetProjectorPulse(FALSE, 0, 0, 0); +} + +XnStatus PrimeClient::GetProjectorPulse(XnBool& enabled, XnFloat& delay, XnFloat& width, XnFloat& framesToskip) +{ + return m_linkControlEndpoint.GetProjectorPulse(enabled, delay, width, framesToskip); +} + +XnStatus PrimeClient::SetProjectorPower(XnUInt16 power) +{ + return m_linkControlEndpoint.SetProjectorPower(power); +} + +XnStatus PrimeClient::GetProjectorPower(XnUInt16& power) +{ + return m_linkControlEndpoint.GetProjectorPower(power); +} + } diff --git a/Source/Drivers/PSLink/PrimeClient.h b/Source/Drivers/PSLink/PrimeClient.h index e95c3f06..1c1aff48 100644 --- a/Source/Drivers/PSLink/PrimeClient.h +++ b/Source/Drivers/PSLink/PrimeClient.h @@ -1,5 +1,25 @@ -#ifndef __PRIMECLIENT_H__ -#define __PRIMECLIENT_H__ +/***************************************************************************** +* * +* 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 PRIMECLIENT_H +#define PRIMECLIENT_H #include "XnLinkProtoLibDefs.h" #include "XnLinkControlEndpoint.h" @@ -53,7 +73,14 @@ class PrimeClient : virtual XnStatus ReadAHB(XnUInt32 nAddress, XnUInt8 nBitOffset, XnUInt8 nBitWidth, XnUInt32& nValue); virtual XnStatus SoftReset(); virtual XnStatus HardReset(); - virtual XnStatus SetEmitterActive(XnBool bActive); + virtual XnStatus ReadDebugData(XnCommandDebugData& commandDebugData); + virtual XnStatus SetProjectorActive(XnBool bActive); + virtual XnStatus SetAccActive(XnBool bActive); + virtual XnStatus GetAccActive(XnBool& bActive); + virtual XnStatus SetVDDActive(XnBool bActive); + virtual XnStatus GetVDDActive(XnBool& bActive); + virtual XnStatus SetPeriodicBistActive(XnBool bActive); + virtual XnStatus GetPeriodicBistActive(XnBool& bActive); virtual XnStatus StartFWLog(); virtual XnStatus StopFWLog(); virtual XnStatus OpenFWLogFile(XnUInt8 logID); @@ -62,6 +89,8 @@ class PrimeClient : virtual XnStatus RunPresetFile(const XnChar* strFileName); virtual XnStatus GetSupportedBistTests(xnl::Array& supportedTests); + virtual XnStatus GetSupportedTempList(xnl::Array& supportedTempList); + virtual XnStatus GetTemperature(XnCommandTemperatureResponse& temp); virtual XnStatus ExecuteBist(XnUInt32 nID, uint32_t& errorCode, uint32_t& extraDataSize, uint8_t* extraData); virtual XnStatus FormatZone(XnUInt8 nZone); //TODO: Implement Get emitter active @@ -89,6 +118,12 @@ class PrimeClient : virtual XnStatus GetFileList(xnl::Array& files); virtual XnStatus DownloadFile(XnUInt16 zone, const XnChar* strFirmwareFileName, const XnChar* strTargetFile); + virtual XnStatus EnableProjectorPulse(XnFloat delay, XnFloat width, XnFloat cycle); + virtual XnStatus DisableProjectorPulse(); + virtual XnStatus GetProjectorPulse(XnBool& enabled, XnFloat& delay, XnFloat& width, XnFloat& framesToskip); + virtual XnStatus SetProjectorPower(XnUInt16 power); + virtual XnStatus GetProjectorPower(XnUInt16& power); + virtual void HandleLinkDataEndpointDisconnection(XnUInt16 nEndpointID); protected: @@ -124,4 +159,4 @@ class PrimeClient : } -#endif // __PRIMECLIENT_H__ +#endif // PRIMECLIENT_H diff --git a/Source/Drivers/PSLink/PrimeClientDefs.h b/Source/Drivers/PSLink/PrimeClientDefs.h index e678f23f..27e4acfa 100644 --- a/Source/Drivers/PSLink/PrimeClientDefs.h +++ b/Source/Drivers/PSLink/PrimeClientDefs.h @@ -1,5 +1,25 @@ -#ifndef __PRIMECLIENTDEFS_H__ -#define __PRIMECLIENTDEFS_H__ +/***************************************************************************** +* * +* 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 PRIMECLIENTDEFS_H +#define PRIMECLIENTDEFS_H #ifdef PRIMECLIENT_EXPORTS #define XN_PRIME_CLIENT_CPP_API XN_API_EXPORT @@ -37,4 +57,4 @@ else if (dataSize == 1) dest = (int)*(int8_t*)data; \ else return ONI_STATUS_BAD_PARAMETER; -#endif // __PRIMECLIENTDEFS_H__ +#endif // PRIMECLIENTDEFS_H diff --git a/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkDefs.h b/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkDefs.h index 42991ce4..50cfaea4 100644 --- a/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkDefs.h +++ b/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkDefs.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKDEFS_H__ -#define __XNLINKDEFS_H__ +/***************************************************************************** +* * +* 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 XNLINKDEFS_H +#define XNLINKDEFS_H /* Version */ #define XN_LINK_PROTOCOL_MAJOR_VERSION 0 @@ -22,6 +42,8 @@ #define XN_LINK_MAX_VERSION_LENGTH 32 #define XN_LINK_MAX_I2C_DEVICE_NAME_LENGTH 32 #define XN_LINK_MAX_LOG_FILE_NAME_LENGTH 32 +#define XN_LINK_MAX_SENSOR_NAME_LENGTH 16 +#define XN_LINK_MAX_TEMPERATURE_SENSORS 2 /* Interface ID's */ typedef enum XnLinkInterfaceID @@ -108,6 +130,8 @@ typedef enum XnLinkMsgType XN_LINK_MSG_STOP_USB_TEST = 0x020B, XN_LINK_MSG_START_LOG_FILE = 0x020C, XN_LINK_MSG_STOP_LOG_FILE = 0x020D, + XN_LINK_MSG_READ_TEMPERATURE = 0x020E, + //XN_LINK_INTERFACE_DATA_STREAMING - Data streaming messages - group 0x03 XN_LINK_MSG_START_STREAMING = 0x0300, @@ -130,6 +154,7 @@ typedef enum XnLinkMsgType XN_LINK_MSG_GET_PROP = 0x0701, XN_LINK_MSG_SET_PROP = 0x0702, XN_LINK_MSG_SET_MULTI_PROPS = 0x0703, + XN_LINK_MSG_GET_DEBUG_DATA = 0x0704, //XN_LINK_INTERFACE_HANDS_GENERATOR - HandGenerator messages - group 0x09 XN_LINK_MSG_START_TARCKING_HAND = 0x0901, @@ -324,10 +349,10 @@ typedef enum XnLinkPropID XN_LINK_PROP_ID_SUPPORTED_PROPS = 0x0005, //General property, holds XnLinkIDSet (read only property) XN_LINK_PROP_ID_HW_VERSION = 0x0006, //Int property (read only property) XN_LINK_PROP_ID_SERIAL_NUMBER = 0x0007, //General property, holds XnLinkSerialNumber (read only property) - XN_LINK_PROP_ID_EMITTER_ACTIVE = 0x0008, //Int property, 1/0 for emitter on/off + XN_LINK_PROP_ID_RESERVED = 0x0008, XN_LINK_PROP_ID_COMPONENT_VERSIONS = 0x0009, //General property, holds XnLinkComponentVersionsList (read only property) XN_LINK_PROP_ID_BOOT_STATUS = 0x000A, //General property, holds XnLinkBootStatus (read only property) - + XN_LINK_PROP_ID_VDD_STATUS = 0x000B, //System management properties - group 0x02 (All of these are global, not related to specific stream) XN_LINK_PROP_ID_SUPPORTED_BIST_TESTS = 0x0201, //General property, holds XnLinkSupportedBistTests XN_LINK_PROP_ID_SUPPORTED_I2C_DEVICES = 0x0202, //General property, holds XnLinkSupportedI2CDevices @@ -366,7 +391,12 @@ typedef enum XnLinkPropID // PROJECTOR_MGMT messages - group 0x2B XN_LINK_PROP_ID_PROJECTOR_PULSE = 0x2B01, //General property, holds XnLinkProjectorPulse XN_LINK_PROP_ID_PROJECTOR_POWER = 0x2B02, //Int property - + XN_LINK_PROP_ID_ACC_ENABLED = 0x2B03, //Int property ACC, 0 = disabled, 1 = enabled + XN_LINK_PROP_ID_VDD_ENABLED = 0x2B04, //Int property vdd sampling , 0 = disabled, 1 = enabled + XN_LINK_PROP_ID_PROJECTOR_ENABLED = 0x2B05, //Int property projector, 0 = OFF, 1 = ON + XN_LINK_PROP_ID_PERIODIC_BIST_ENABLED = 0x2B06, //Int property voltage sampling , 0 = disabled, 1 = enabled + XN_LINK_PROP_ID_TEMPERATURE_LIST = 0x2B07, + //INVALID XN_LINK_PROP_ID_INVALID = 0xFFFF, //Indicates invalid property ID } XnLinkPropID; @@ -454,4 +484,4 @@ typedef enum XnLinkBootErrorCode XN_LINK_BOOT_FW_LOAD_FAILED = 0x0003, } XnLinkBootErrorCode; -#endif // __XNLINKDEFS_H__ +#endif // XNLINKDEFS_H diff --git a/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkProto.h b/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkProto.h index 647a3006..7e476754 100644 --- a/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkProto.h +++ b/Source/Drivers/PSLink/Protocols/XnLinkProto/XnLinkProto.h @@ -1,5 +1,25 @@ -#ifndef __XNLINKPROTO_H__ -#define __XNLINKPROTO_H__ +/***************************************************************************** +* * +* 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 XNLINKPROTO_H +#define XNLINKPROTO_H #include #include "XnLinkDefs.h" @@ -423,6 +443,9 @@ typedef struct XnLinkCameraIntrinsics typedef struct XnLinkI2CDevice { + XnUInt8 m_nMasterID; + XnUInt8 m_nSlaveID; + XnUInt16 m_nReserved; XnUInt32 m_nID; XnChar m_strName[XN_LINK_MAX_I2C_DEVICE_NAME_LENGTH]; } XnLinkI2CDevice; @@ -447,13 +470,23 @@ typedef struct XnLinkSupportedLogFiles typedef struct XnLinkProjectorPulse { - XnUInt8 m_bEnabled; - XnUInt8 m_nReserved; - XnUInt16 m_nDelay; // Delay between frame start and the start of pulse, in milliseconds - XnUInt16 m_nWidth; // Pulse width, in milliseconds - XnUInt16 m_nFramesToSkip; // number of frames to skip between projector pulses, from pulse start to next pulse start. + XnUInt16 m_bEnabled; + XnUInt16 m_nReserved; + XnFloat m_nDelay; // Delay between frame start and the start of pulse, in milliseconds + XnFloat m_nWidth; // Pulse width, in milliseconds + XnFloat m_nCycle; // in pulse mode: number of frames to skip between projector pulses, from pulse start to next pulse start. in PWM : Cycle time } XnLinkProjectorPulse; +typedef struct XnLinkTemperatureSensor +{ + XnUInt32 m_nID; + XnUInt8 m_strName[XN_LINK_MAX_SENSOR_NAME_LENGTH]; +} XnLinkTemperatureSensor; + +typedef struct XnLinkTemperatureSensorsList{ + XnUInt32 m_nCount; + XnLinkTemperatureSensor m_aSensors[XN_LINK_MAX_TEMPERATURE_SENSORS]; +}XnLinkTemperatureSensorsList; //----------------------------------------------------------------------- // Command Parameters //----------------------------------------------------------------------- @@ -576,9 +609,25 @@ typedef struct XnLinkLogOpenCloseParams XnUInt8 m_nID; } XnLinkLogOpenCloseParams; +typedef struct XnLinkGetTemperatureParams +{ + XnUInt32 m_nID; +} XnLinkGetTemperatureParams; + +typedef struct XnLinkGetDebugDataParams +{ + XnUInt32 m_nID; +} XnLinkGetDebugDataParams; + //----------------------------------------------------------------------- // Command Response Structures //----------------------------------------------------------------------- +typedef struct XnLinkTemperatureResponse +{ + XnUInt32 m_nID; + XnFloat value; +} XnLinkTemperatureResponse; + typedef struct XnLinkResponseInfo { XnUInt16 m_nResponseCode; @@ -768,6 +817,18 @@ typedef struct XnLinkGetFileListResponse XnLinkFileEntry m_aFileEntries[1]; } XnLinkGetFileListResponse; +typedef struct XnLinkDebugDataResponseHeader +{ + XnUInt16 m_nDataID; //Values come from XnLinkInternalPropID + XnUInt16 m_nValueSize; +} XnLinkDebugDataResponseHeader; + +typedef struct XnLinkDebugDataResponse +{ + XnLinkDebugDataResponseHeader m_header; + XnUInt8 m_data[1]; +} XnLinkDebugDataResponse; + typedef struct XnLinkBootStatus { XnUInt8 m_nZone; //Values come from XnLinkBootZone @@ -783,4 +844,4 @@ typedef struct XnLinkBootStatus #pragma pack (pop) #endif -#endif // __XNLINKPROTO_H__ +#endif // XNLINKPROTO_H diff --git a/Source/Drivers/PSLink/XnPsVersion.h b/Source/Drivers/PSLink/XnPsVersion.h index 14c4a8ba..2e4cbac3 100644 --- a/Source/Drivers/PSLink/XnPsVersion.h +++ b/Source/Drivers/PSLink/XnPsVersion.h @@ -1,5 +1,25 @@ -#ifndef _XN_PS_VERSION_H_ -#define _XN_PS_VERSION_H_ +/***************************************************************************** +* * +* 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 XNPSVERSION_H +#define XNPSVERSION_H //--------------------------------------------------------------------------- // Includes @@ -33,4 +53,4 @@ XN_PS_BRIEF_VERSION_STRING "-" \ XN_PLATFORM_STRING " (" XN_TIMESTAMP ")" -#endif //_XN_VERSION_H_ +#endif // XNPSVERSION_H diff --git a/Source/Drivers/TestDevice/TestDevice.cpp b/Source/Drivers/TestDevice/TestDevice.cpp index e1832bfb..b6389141 100644 --- a/Source/Drivers/TestDevice/TestDevice.cpp +++ b/Source/Drivers/TestDevice/TestDevice.cpp @@ -18,403 +18,75 @@ * limitations under the License. * * * *****************************************************************************/ -#include "Driver\OniDriverAPI.h" -#include "XnLib.h" -#include "XnHash.h" -#include "XnEvent.h" +#include "TestDevice.h" -#define TEST_RESOLUTION_X 320 -#define TEST_RESOLUTION_Y 240 - -class TestStream : public oni::driver::StreamBase +TestDevice::TestDevice(OniDeviceInfo* pInfo, oni::driver::DriverServices& driverServices) : m_pInfo(pInfo), m_driverServices(driverServices) { -public: - TestStream() : oni::driver::StreamBase() - { - m_osEvent.Create(TRUE); - m_sendCount = 0; - } - - ~TestStream() - { - stop(); - } - - OniStatus start() - { - xnOSCreateThread(threadFunc, this, &m_threadHandle); - - return ONI_STATUS_OK; - } - - void stop() - { - m_running = false; - } - - virtual OniStatus SetVideoMode(OniVideoMode*) = 0; - virtual OniStatus GetVideoMode(OniVideoMode* pVideoMode) = 0; - - OniStatus getProperty(int propertyId, void* data, int* pDataSize) - { - if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) - { - if (*pDataSize != sizeof(OniVideoMode)) - { - printf("Unexpected size: %d != %d\n", *pDataSize, sizeof(OniVideoMode)); - return ONI_STATUS_ERROR; - } - return GetVideoMode((OniVideoMode*)data); - } - - return ONI_STATUS_NOT_IMPLEMENTED; - } - - OniStatus setProperty(int propertyId, const void* data, int dataSize) - { - if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) - { - if (dataSize != sizeof(OniVideoMode)) - { - printf("Unexpected size: %d != %d\n", dataSize, sizeof(OniVideoMode)); - return ONI_STATUS_ERROR; - } - return SetVideoMode((OniVideoMode*)data); - } - else if (propertyId == 666) - { - if (dataSize != sizeof(int)) - { - printf("Unexpected size: %d != %d\n", dataSize, sizeof(int)); - return ONI_STATUS_ERROR; - } - - // Increment the send count. - m_cs.Lock(); - m_sendCount += *((int*)data); - m_cs.Unlock(); - - // Raise the OS event, to allow thread to start working. - m_osEvent.Set(); - } - - return ONI_STATUS_NOT_IMPLEMENTED; - } + OniSensorType sensorTypes[] = { ONI_SENSOR_DEPTH, ONI_SENSOR_COLOR, ONI_SENSOR_IR }; + int count = sizeof(sensorTypes)/sizeof(sensorTypes[0]); - virtual int GetBytesPerPixel() = 0; + XN_ASSERT(count < sizeof(m_sensors)/sizeof(m_sensors[0])); -protected: - - // Thread - static XN_THREAD_PROC threadFunc(XN_THREAD_PARAM pThreadParam) + for (int i = 0; i < count; ++i) { - TestStream* pStream = (TestStream*)pThreadParam; - pStream->m_running = true; - - while (pStream->m_running) - { - pStream->m_osEvent.Wait(XN_WAIT_INFINITE); - int count = 0; - do - { - // Get the current count. - pStream->m_cs.Lock(); - count = pStream->m_sendCount; - if (pStream->m_sendCount > 0) - { - pStream->m_sendCount--; - } - pStream->m_cs.Unlock(); - - // Send the frame. - if (count > 0) - { - OniFrame* pFrame = pStream->getServices().acquireFrame(); - pStream->BuildFrame(pFrame); - pStream->raiseNewFrame(pFrame); - pStream->getServices().releaseFrame(pFrame); - } - - } while (count > 0); - } - - XN_THREAD_PROC_RETURN(XN_STATUS_OK); + m_sensors[i].sensorType = sensorTypes[i]; + m_sensors[i].numSupportedVideoModes = 1; + m_sensors[i].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, 1); + m_sensors[i].pSupportedVideoModes[0].pixelFormat = TestStream::getDefaultPixelFormat(m_sensors[i].sensorType); + m_sensors[i].pSupportedVideoModes[0].fps = DEFAULT_FPS; + m_sensors[i].pSupportedVideoModes[0].resolutionX = DEFAULT_RESOLUTION_X; + m_sensors[i].pSupportedVideoModes[0].resolutionY = DEFAULT_RESOLUTION_Y; } - virtual int BuildFrame(OniFrame* pFrame) = 0; - - int singleRes(int x, int y) {return y*TEST_RESOLUTION_X+x;} - - bool m_running; - int m_sendCount; + m_numSensors = count; +} - XN_THREAD_HANDLE m_threadHandle; - - xnl::CriticalSection m_cs; - xnl::OSEvent m_osEvent; -}; - -class TestDepthStream : public TestStream +OniDeviceInfo* TestDevice::GetInfo() { -public: + return m_pInfo; +} - TestDepthStream() : TestStream() - { - m_frameId = 1; - } - - OniStatus SetVideoMode(OniVideoMode*) {return ONI_STATUS_NOT_IMPLEMENTED;} - OniStatus GetVideoMode(OniVideoMode* pVideoMode) - { - pVideoMode->pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; - pVideoMode->fps = 30; - pVideoMode->resolutionX = TEST_RESOLUTION_X; - pVideoMode->resolutionY = TEST_RESOLUTION_Y; - return ONI_STATUS_OK; - } - - virtual int GetBytesPerPixel() { return sizeof(OniDepthPixel); } - -private: - - virtual int BuildFrame(OniFrame* pFrame) - { - pFrame->frameIndex = m_frameId; - - pFrame->videoMode.pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; - pFrame->videoMode.resolutionX = TEST_RESOLUTION_X; - pFrame->videoMode.resolutionY = TEST_RESOLUTION_Y; - pFrame->videoMode.fps = 30; - - pFrame->width = TEST_RESOLUTION_X; - pFrame->height = TEST_RESOLUTION_Y; - - pFrame->cropOriginX = pFrame->cropOriginY = 0; - pFrame->croppingEnabled = FALSE; - - pFrame->sensorType = ONI_SENSOR_DEPTH; - pFrame->stride = TEST_RESOLUTION_X*sizeof(OniDepthPixel); - pFrame->timestamp = m_frameId*33000; - m_frameId++; - return 1; - } - - int m_frameId; -}; - -class TestImageStream : public TestStream +OniStatus TestDevice::getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) { -public: - TestImageStream() : TestStream() - { - m_frameId = 1; - } + *numSensors = m_numSensors; + *pSensors = m_sensors; - OniStatus SetVideoMode(OniVideoMode*) {return ONI_STATUS_NOT_IMPLEMENTED;} - OniStatus GetVideoMode(OniVideoMode* pVideoMode) - { - pVideoMode->pixelFormat = ONI_PIXEL_FORMAT_RGB888; - pVideoMode->fps = 30; - pVideoMode->resolutionX = TEST_RESOLUTION_X; - pVideoMode->resolutionY = TEST_RESOLUTION_Y; - return ONI_STATUS_OK; - } - - virtual int GetBytesPerPixel() { return sizeof(OniRGB888Pixel); } - -private: - - virtual int BuildFrame(OniFrame* pFrame) - { - pFrame->frameIndex = m_frameId; - - pFrame->videoMode.pixelFormat = ONI_PIXEL_FORMAT_RGB888; - pFrame->videoMode.resolutionX = TEST_RESOLUTION_X; - pFrame->videoMode.resolutionY = TEST_RESOLUTION_Y; - pFrame->videoMode.fps = 30; - - pFrame->width = TEST_RESOLUTION_X; - pFrame->height = TEST_RESOLUTION_Y; - - pFrame->cropOriginX = pFrame->cropOriginY = 0; - pFrame->croppingEnabled = FALSE; + return ONI_STATUS_OK; +} - pFrame->sensorType = ONI_SENSOR_COLOR; - pFrame->stride = TEST_RESOLUTION_X*sizeof(OniRGB888Pixel); - pFrame->timestamp = m_frameId*33000; - m_frameId++; - return 1; - } - - int m_frameId; -}; - -class TestDevice : public oni::driver::DeviceBase +oni::driver::StreamBase* TestDevice::createStream(OniSensorType sensorType) { -public: - TestDevice(OniDeviceInfo* pInfo, oni::driver::DriverServices& driverServices) : m_pInfo(pInfo), m_driverServices(driverServices) - { - m_numSensors = 2; - - m_sensors[0].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, 1); - m_sensors[0].sensorType = ONI_SENSOR_DEPTH; - m_sensors[0].numSupportedVideoModes = 1; - m_sensors[0].pSupportedVideoModes[0].pixelFormat = ONI_PIXEL_FORMAT_DEPTH_1_MM; - m_sensors[0].pSupportedVideoModes[0].fps = 30; - m_sensors[0].pSupportedVideoModes[0].resolutionX = TEST_RESOLUTION_X; - m_sensors[0].pSupportedVideoModes[0].resolutionY = TEST_RESOLUTION_Y; - - m_sensors[1].pSupportedVideoModes = XN_NEW_ARR(OniVideoMode, 1); - m_sensors[1].sensorType = ONI_SENSOR_COLOR; - m_sensors[1].numSupportedVideoModes = 1; - m_sensors[1].pSupportedVideoModes[0].pixelFormat = ONI_PIXEL_FORMAT_RGB888; - m_sensors[1].pSupportedVideoModes[0].fps = 30; - m_sensors[1].pSupportedVideoModes[0].resolutionX = TEST_RESOLUTION_X; - m_sensors[1].pSupportedVideoModes[0].resolutionY = TEST_RESOLUTION_Y; - - } - OniDeviceInfo* GetInfo() - { - return m_pInfo; - } - - OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSensors) - { - *numSensors = m_numSensors; - *pSensors = m_sensors; - - return ONI_STATUS_OK; - } - - oni::driver::StreamBase* createStream(OniSensorType sensorType) - { - if (sensorType == ONI_SENSOR_DEPTH) - { - TestDepthStream* pDepth = XN_NEW(TestDepthStream); - return pDepth; - } - if (sensorType == ONI_SENSOR_COLOR) - { - TestImageStream* pImage = XN_NEW(TestImageStream); - return pImage; - } - - m_driverServices.errorLoggerAppend("TestDevice: Can't create a stream of type %d", sensorType); - return NULL; - } - - void destroyStream(oni::driver::StreamBase* pStream) - { - XN_DELETE(pStream); - } - - OniStatus getProperty(int propertyId, void* data, int* pDataSize) - { - OniStatus rc = ONI_STATUS_OK; - - switch (propertyId) - { - case ONI_DEVICE_PROPERTY_DRIVER_VERSION: - { - if (*pDataSize == sizeof(OniVersion)) - { - OniVersion* version = (OniVersion*)data; - version->major = version->minor = version->maintenance = version->build = 2; - } - else - { - m_driverServices.errorLoggerAppend("Unexpected size: %d != %d\n", *pDataSize, sizeof(OniVersion)); - rc = ONI_STATUS_ERROR; - } - } - break; - default: - m_driverServices.errorLoggerAppend("Unknown property: %d\n", propertyId); - rc = ONI_STATUS_ERROR; - } - return rc; - } -private: - TestDevice(const TestDevice&); - void operator=(const TestDevice&); - - OniDeviceInfo* m_pInfo; - int m_numSensors; - OniSensorInfo m_sensors[10]; - oni::driver::DriverServices& m_driverServices; -}; + return XN_NEW(TestStream, sensorType); +} +void TestDevice::destroyStream(oni::driver::StreamBase* pStream) +{ + XN_DELETE(pStream); +} -class TestDriver : public oni::driver::DriverBase +OniStatus TestDevice::getProperty(int propertyId, void* data, int* pDataSize) { -public: - TestDriver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) - {} + OniStatus rc = ONI_STATUS_OK; - virtual oni::driver::DeviceBase* deviceOpen(const char* uri, const char* /*mode*/) + switch (propertyId) { - for (xnl::Hash::Iterator iter = m_devices.Begin(); iter != m_devices.End(); ++iter) + case ONI_DEVICE_PROPERTY_DRIVER_VERSION: { - if (xnOSStrCmp(iter->Key()->uri, uri) == 0) + if (*pDataSize == sizeof(OniVersion)) { - // Found - if (iter->Value() != NULL) - { - // already using - return iter->Value(); - } - - TestDevice* pDevice = XN_NEW(TestDevice, iter->Key(), getServices()); - iter->Value() = pDevice; - return pDevice; + OniVersion* version = (OniVersion*)data; + version->major = version->minor = version->maintenance = version->build = 2; } - } - - getServices().errorLoggerAppend("Looking for '%s'", uri); - return NULL; - } - - virtual void deviceClose(oni::driver::DeviceBase* pDevice) - { - for (xnl::Hash::Iterator iter = m_devices.Begin(); iter != m_devices.End(); ++iter) - { - if (iter->Value() == pDevice) + else { - iter->Value() = NULL; - XN_DELETE(pDevice); - return; + m_driverServices.errorLoggerAppend("Unexpected size: %d != %d\n", *pDataSize, sizeof(OniVersion)); + rc = ONI_STATUS_ERROR; } } - - // not our device?! - XN_ASSERT(FALSE); - } - - virtual OniStatus tryDevice(const char* uri) - { - if (xnOSStrCmp(uri, "Test")) - { - return ONI_STATUS_ERROR; - } - - - OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); - xnOSStrCopy(pInfo->uri, uri, ONI_MAX_STR); - xnOSStrCopy(pInfo->vendor, "Test", ONI_MAX_STR); - m_devices[pInfo] = NULL; - - deviceConnected(pInfo); - - return ONI_STATUS_OK; + break; + default: + m_driverServices.errorLoggerAppend("Unknown property: %d\n", propertyId); + rc = ONI_STATUS_ERROR; } - - void shutdown() {} - -protected: - - XN_THREAD_HANDLE m_threadHandle; - - xnl::Hash m_devices; -}; - -ONI_EXPORT_DRIVER(TestDriver); + return rc; +} diff --git a/Source/Drivers/PS1080/Formats/XnCodec.h b/Source/Drivers/TestDevice/TestDevice.h similarity index 58% rename from Source/Drivers/PS1080/Formats/XnCodec.h rename to Source/Drivers/TestDevice/TestDevice.h index 3d51f35a..93f60964 100644 --- a/Source/Drivers/PS1080/Formats/XnCodec.h +++ b/Source/Drivers/TestDevice/TestDevice.h @@ -18,38 +18,34 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_CODEC_H__ -#define __XN_CODEC_H__ - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include -#include -#include -#include "XnFormats.h" - -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -typedef XnUInt32 XnCodecID; - -class XnCodec +#ifndef TESTDEVICE_H +#define TESTDEVICE_H + +#include +#include "TestStream.h" + +class TestDevice : public oni::driver::DeviceBase { public: - static XnCompressionFormats GetCompressionFormatFromCodecID(XnCodecID codecID); - static XnCodecID GetCodecIDFromCompressionFormat(XnCompressionFormats format); + TestDevice(OniDeviceInfo* pInfo, oni::driver::DriverServices& driverServices); + OniDeviceInfo* GetInfo(); + + OniStatus getSensorInfoList(OniSensorInfo** pSensors, int* numSensors); - XnCodec() {} - virtual ~XnCodec() {} + oni::driver::StreamBase* createStream(OniSensorType sensorType); - virtual XnStatus Init() { return XN_STATUS_OK; } + void destroyStream(oni::driver::StreamBase* pStream); - virtual XnCompressionFormats GetCompressionFormat() const = 0; + OniStatus getProperty(int propertyId, void* data, int* pDataSize); - virtual XnStatus Compress(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) = 0; +private: + TestDevice(const TestDevice&); + void operator=(const TestDevice&); - virtual XnStatus Decompress(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) = 0; + OniDeviceInfo* m_pInfo; + int m_numSensors; + OniSensorInfo m_sensors[10]; + oni::driver::DriverServices& m_driverServices; }; -#endif //__XN_CODEC_H__ +#endif // TESTDEVICE_H diff --git a/Source/Drivers/TestDevice/TestDevice.vcxproj b/Source/Drivers/TestDevice/TestDevice.vcxproj index e20a074d..d7b7292c 100644 --- a/Source/Drivers/TestDevice/TestDevice.vcxproj +++ b/Source/Drivers/TestDevice/TestDevice.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,27 @@ DynamicLibrary true MultiByte + v120 DynamicLibrary true MultiByte + v120 DynamicLibrary false true MultiByte + v120 DynamicLibrary false true MultiByte + v120 @@ -172,6 +176,13 @@ + + + + + + + diff --git a/Source/Drivers/PS1080/Formats/XnUncompressedCodec.h b/Source/Drivers/TestDevice/TestDriver.cpp similarity index 52% rename from Source/Drivers/PS1080/Formats/XnUncompressedCodec.h rename to Source/Drivers/TestDevice/TestDriver.cpp index bd98516a..96bc223f 100644 --- a/Source/Drivers/PS1080/Formats/XnUncompressedCodec.h +++ b/Source/Drivers/TestDevice/TestDriver.cpp @@ -18,51 +18,71 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_UNCOMPRESSED_CODEC_H__ -#define __XN_UNCOMPRESSED_CODEC_H__ +#include "TestDriver.h" +#include "TestDevice.h" +#include -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnCodecBase.h" +TestDriver::TestDriver(OniDriverServices* pDriverServices) : DriverBase(pDriverServices) +{} -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -class XnUncompressedCodec : public XnCodecBase +oni::driver::DeviceBase* TestDriver::deviceOpen(const char* uri, const char* /*mode*/) { -public: - XnUncompressedCodec() {} - virtual ~XnUncompressedCodec() {} - - virtual XnCompressionFormats GetCompressionFormat() const { return XN_COMPRESSION_NONE; } - virtual XnFloat GetWorseCompressionRatio() const { return 1.0; } - virtual XnUInt32 GetOverheadSize() const { return 0; } - -protected: - virtual XnStatus CompressImpl(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) + for (xnl::Hash::Iterator iter = m_devices.Begin(); iter != m_devices.End(); ++iter) { - if (nDataSize > *pnCompressedDataSize) + if (xnOSStrCmp(iter->Key()->uri, uri) == 0) { - return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); - } + // Found + if (iter->Value() != NULL) + { + // already using + return iter->Value(); + } - xnOSMemCopy(pCompressedData, pData, nDataSize); - *pnCompressedDataSize = nDataSize; - return (XN_STATUS_OK); + TestDevice* pDevice = XN_NEW(TestDevice, iter->Key(), getServices()); + iter->Value() = pDevice; + return pDevice; + } } - virtual XnStatus DecompressImpl(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) + getServices().errorLoggerAppend("Looking for '%s'", uri); + return NULL; +} + +void TestDriver::deviceClose(oni::driver::DeviceBase* pDevice) +{ + for (xnl::Hash::Iterator iter = m_devices.Begin(); iter != m_devices.End(); ++iter) { - if (nCompressedDataSize > *pnDataSize) + if (iter->Value() == pDevice) { - return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); + iter->Value() = NULL; + XN_DELETE(pDevice); + return; } + } + + // not our device?! + XN_ASSERT(FALSE); +} - xnOSMemCopy(pData, pCompressedData, nCompressedDataSize); - *pnDataSize = nCompressedDataSize; - return (XN_STATUS_OK); +OniStatus TestDriver::tryDevice(const char* uri) +{ + if (xnOSStrCmp(uri, TEST_DEVICE_NAME)) + { + return ONI_STATUS_ERROR; } -}; -#endif //__XN_UNCOMPRESSED_CODEC_H__ \ No newline at end of file + + OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); + xnOSStrCopy(pInfo->uri, uri, ONI_MAX_STR); + xnOSStrCopy(pInfo->vendor, "Test", ONI_MAX_STR); + m_devices[pInfo] = NULL; + + deviceConnected(pInfo); + + return ONI_STATUS_OK; +} + +void TestDriver::shutdown() +{} + +ONI_EXPORT_DRIVER(TestDriver); diff --git a/Source/Drivers/PS1080/DDK/XnCodecFactory.h b/Source/Drivers/TestDevice/TestDriver.h similarity index 68% rename from Source/Drivers/PS1080/DDK/XnCodecFactory.h rename to Source/Drivers/TestDevice/TestDriver.h index 3a198358..61b640c3 100644 --- a/Source/Drivers/PS1080/DDK/XnCodecFactory.h +++ b/Source/Drivers/TestDevice/TestDriver.h @@ -18,25 +18,28 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_CODEC_FACTORY_H__ -#define __XN_CODEC_FACTORY_H__ +#ifndef TESTDRIVER_H +#define TESTDRIVER_H -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include -#include -#include -#include +#include +#include +#include -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -class XnCodecFactory +class TestDriver : public oni::driver::DriverBase { public: - static XnStatus Create(XnCompressionFormats nFormat, XnDeviceModule* pStream, const XnChar* StreamName, XnCodec** ppCodec); - static void Destroy(XnCodec* pCodec); + TestDriver(OniDriverServices* pDriverServices); + + virtual oni::driver::DeviceBase* deviceOpen(const char* uri, const char* mode); + virtual void deviceClose(oni::driver::DeviceBase* pDevice); + virtual OniStatus tryDevice(const char* uri); + + void shutdown(); + +protected: + XN_THREAD_HANDLE m_threadHandle; + xnl::Hash m_devices; }; -#endif //__XN_CODEC_FACTORY_H__ \ No newline at end of file +#endif // TESTDRIVER_H + diff --git a/Source/Drivers/TestDevice/TestStream.cpp b/Source/Drivers/TestDevice/TestStream.cpp new file mode 100644 index 00000000..9b9d051e --- /dev/null +++ b/Source/Drivers/TestDevice/TestStream.cpp @@ -0,0 +1,181 @@ +/***************************************************************************** +* * +* 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 "TestStream.h" +#include + +TestStream::TestStream(OniSensorType sensorType) : oni::driver::StreamBase() +{ + m_osEvent.Create(TRUE); + m_sensorType = sensorType; + m_videoMode.resolutionX = DEFAULT_RESOLUTION_X; + m_videoMode.resolutionY = DEFAULT_RESOLUTION_Y; + m_videoMode.fps = DEFAULT_FPS; + m_videoMode.pixelFormat = getDefaultPixelFormat(sensorType); + m_frameIndex = 0; +} + +TestStream::~TestStream() +{ + stop(); +} + +OniPixelFormat TestStream::getDefaultPixelFormat(OniSensorType sensorType) +{ + switch (sensorType) + { + case ONI_SENSOR_DEPTH: + return ONI_PIXEL_FORMAT_DEPTH_1_MM; + case ONI_SENSOR_COLOR: + return ONI_PIXEL_FORMAT_RGB888; + case ONI_SENSOR_IR: + return ONI_PIXEL_FORMAT_GRAY16; + default: + XN_ASSERT(FALSE); + return (OniPixelFormat)-1; + } +} + +OniStatus TestStream::start() +{ + m_running = true; + return ONI_STATUS_OK; +} + +void TestStream::stop() +{ + m_running = false; +} + +OniStatus TestStream::getProperty(int propertyId, void* data, int* pDataSize) +{ + if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) + { + if (*pDataSize != sizeof(OniVideoMode)) + { + printf("Unexpected size: %d != %d\n", *pDataSize, sizeof(OniVideoMode)); + return ONI_STATUS_ERROR; + } + return getVideoMode((OniVideoMode*)data); + } + + return ONI_STATUS_NOT_IMPLEMENTED; +} + +OniStatus TestStream::setProperty(int propertyId, const void* data, int dataSize) +{ + if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE) + { + if (dataSize != sizeof(OniVideoMode)) + { + printf("Unexpected size: %d != %d\n", dataSize, sizeof(OniVideoMode)); + return ONI_STATUS_ERROR; + } + return setVideoMode((OniVideoMode*)data); + } + + return ONI_STATUS_NOT_IMPLEMENTED; +} + +OniStatus TestStream::setVideoMode(OniVideoMode* pVideoMode) +{ + xnOSMemCopy(&m_videoMode, pVideoMode, sizeof(m_videoMode)); + return ONI_STATUS_OK; +} + +OniStatus TestStream::getVideoMode(OniVideoMode* pVideoMode) +{ + xnOSMemCopy(pVideoMode, &m_videoMode, sizeof(m_videoMode)); + return ONI_STATUS_OK; +} + +int getBytesPerPixel(OniPixelFormat format) +{ + switch (format) + { + case ONI_PIXEL_FORMAT_GRAY8: + return 1; + case ONI_PIXEL_FORMAT_DEPTH_1_MM: + case ONI_PIXEL_FORMAT_DEPTH_100_UM: + case ONI_PIXEL_FORMAT_SHIFT_9_2: + case ONI_PIXEL_FORMAT_SHIFT_9_3: + case ONI_PIXEL_FORMAT_GRAY16: + return 2; + case ONI_PIXEL_FORMAT_RGB888: + return 3; + case ONI_PIXEL_FORMAT_YUV422: + case ONI_PIXEL_FORMAT_YUYV: + return 2; + case ONI_PIXEL_FORMAT_JPEG: + return 1; + default: + XN_ASSERT(FALSE); + return 0; + } +} + +OniStatus TestStream::invoke(int commandId, void* data, int dataSize) +{ + switch (commandId) + { + case TEST_COMMAND_ISSUE_FRAME: + { + if (dataSize != sizeof(TestCommandIssueFrame)) + { + printf("Unexpected size: %d != %d\n", dataSize, sizeof(TestCommandIssueFrame)); + return ONI_STATUS_BAD_PARAMETER; + } + + if (!m_running) + { + printf("Can't issue a frame if stream is not started\n"); + return ONI_STATUS_BAD_PARAMETER; + } + + TestCommandIssueFrame* pArgs = (TestCommandIssueFrame*)data; + + OniFrame* pFrame = getServices().acquireFrame(); + pFrame->frameIndex = ++m_frameIndex; + pFrame->timestamp = pArgs->timestamp; + xnOSMemCopy(pFrame->data, pArgs->data, pFrame->dataSize); + + pFrame->videoMode = m_videoMode; + + pFrame->width = m_videoMode.resolutionX; + pFrame->height = m_videoMode.resolutionY; + + pFrame->cropOriginX = pFrame->cropOriginY = 0; + pFrame->croppingEnabled = FALSE; + + pFrame->sensorType = m_sensorType; + pFrame->stride = m_videoMode.resolutionX * getBytesPerPixel(m_videoMode.pixelFormat); + + raiseNewFrame(pFrame); + getServices().releaseFrame(pFrame); + } + break; + + default: + return ONI_STATUS_BAD_PARAMETER; + } + + return ONI_STATUS_OK; +} + diff --git a/Source/Drivers/PS1080/Formats/Xn8zCodec.h b/Source/Drivers/TestDevice/TestStream.h similarity index 56% rename from Source/Drivers/PS1080/Formats/Xn8zCodec.h rename to Source/Drivers/TestDevice/TestStream.h index c799e354..d6563f61 100644 --- a/Source/Drivers/PS1080/Formats/Xn8zCodec.h +++ b/Source/Drivers/TestDevice/TestStream.h @@ -18,35 +18,43 @@ * limitations under the License. * * * *****************************************************************************/ -#ifndef __XN_8Z_CODEC_H__ -#define __XN_8Z_CODEC_H__ - -//--------------------------------------------------------------------------- -// Includes -//--------------------------------------------------------------------------- -#include "XnCodecBase.h" -#include - -//--------------------------------------------------------------------------- -// Types -//--------------------------------------------------------------------------- -class Xn8zCodec : public XnCodecBase +#ifndef TESTSTREAM_H +#define TESTSTREAM_H + +#include +#include +#include + +#define DEFAULT_RESOLUTION_X 640 +#define DEFAULT_RESOLUTION_Y 480 +#define DEFAULT_FPS 30 + +class TestStream : public oni::driver::StreamBase { public: - virtual XnCompressionFormats GetCompressionFormat() const { return XN_COMPRESSION_COLOR_8Z; } - virtual XnFloat GetWorseCompressionRatio() const { return XN_STREAM_COMPRESSION_IMAGE8Z_WORSE_RATIO; } - virtual XnUInt32 GetOverheadSize() const { return 0; } + TestStream(OniSensorType sensorType); + virtual ~TestStream(); + virtual OniStatus start(); + virtual void stop(); + virtual OniStatus getProperty(int propertyId, void* data, int* pDataSize); + virtual OniStatus setProperty(int propertyId, const void* data, int dataSize); + virtual OniStatus invoke(int commandId, void* data, int dataSize); + + static OniPixelFormat getDefaultPixelFormat(OniSensorType sensorType); protected: - virtual XnStatus CompressImpl(const XnUChar* pData, XnUInt32 nDataSize, XnUChar* pCompressedData, XnUInt32* pnCompressedDataSize) - { - return XnStreamCompressImage8Z(pData, nDataSize, pCompressedData, pnCompressedDataSize); - } - - virtual XnStatus DecompressImpl(const XnUChar* pCompressedData, XnUInt32 nCompressedDataSize, XnUChar* pData, XnUInt32* pnDataSize) - { - return XnStreamUncompressImage8Z(pCompressedData, nCompressedDataSize, pData, pnDataSize); - } + OniStatus setVideoMode(OniVideoMode*); + OniStatus getVideoMode(OniVideoMode* pVideoMode); + + bool m_running; + OniVideoMode m_videoMode; + OniSensorType m_sensorType; + int m_frameIndex; + + XN_THREAD_HANDLE m_threadHandle; + + xnl::CriticalSection m_cs; + xnl::OSEvent m_osEvent; }; -#endif //__XN_8Z_CODEC_H__ \ No newline at end of file +#endif // TESTSTREAM_H diff --git a/Source/Resources/Resource-OpenNI.h b/Source/Resources/Resource-OpenNI.h index 13c59a5f..42d23a10 100644 --- a/Source/Resources/Resource-OpenNI.h +++ b/Source/Resources/Resource-OpenNI.h @@ -22,6 +22,9 @@ // Microsoft Visual C++ generated include file. // Used by OpenNI.rc // +#ifndef RESOURCE_OPENNI_H +#define RESOURCE_OPENNI_H + #define IDI_MAINICON 110 // Next default values for new objects @@ -34,3 +37,5 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif + +#endif // RESOURCE_OPENNI_H diff --git a/Source/Tools/NiViewer.Android/.classpath b/Source/Tools/NiViewer.Android/.classpath new file mode 100644 index 00000000..51769745 --- /dev/null +++ b/Source/Tools/NiViewer.Android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Source/Tools/NiViewer.Android/.project b/Source/Tools/NiViewer.Android/.project new file mode 100644 index 00000000..e85a89d0 --- /dev/null +++ b/Source/Tools/NiViewer.Android/.project @@ -0,0 +1,33 @@ + + + NiViewer + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/Source/Tools/NiViewer.Android/AndroidManifest.xml b/Source/Tools/NiViewer.Android/AndroidManifest.xml new file mode 100644 index 00000000..706b5198 --- /dev/null +++ b/Source/Tools/NiViewer.Android/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Tools/NiViewer.Android/build.xml b/Source/Tools/NiViewer.Android/build.xml new file mode 100644 index 00000000..f0f9ddd1 --- /dev/null +++ b/Source/Tools/NiViewer.Android/build.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Tools/NiViewer.Android/ic_launcher-web.png b/Source/Tools/NiViewer.Android/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/Source/Tools/NiViewer.Android/ic_launcher-web.png differ diff --git a/Source/Tools/NiViewer.Android/proguard-project.txt b/Source/Tools/NiViewer.Android/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/Source/Tools/NiViewer.Android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/Source/Tools/NiViewer.Android/project.properties b/Source/Tools/NiViewer.Android/project.properties new file mode 100644 index 00000000..da7962e5 --- /dev/null +++ b/Source/Tools/NiViewer.Android/project.properties @@ -0,0 +1,15 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-14 +android.library.reference.1=../../../Wrappers/java diff --git a/Source/Tools/NiViewer.Android/res/drawable-hdpi/ic_launcher.png b/Source/Tools/NiViewer.Android/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/Source/Tools/NiViewer.Android/res/drawable-hdpi/ic_launcher.png differ diff --git a/Source/Tools/NiViewer.Android/res/drawable-mdpi/ic_launcher.png b/Source/Tools/NiViewer.Android/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/Source/Tools/NiViewer.Android/res/drawable-mdpi/ic_launcher.png differ diff --git a/Source/Tools/NiViewer.Android/res/drawable-xhdpi/ic_launcher.png b/Source/Tools/NiViewer.Android/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/Source/Tools/NiViewer.Android/res/drawable-xhdpi/ic_launcher.png differ diff --git a/Source/Tools/NiViewer.Android/res/drawable-xxhdpi/ic_launcher.png b/Source/Tools/NiViewer.Android/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/Source/Tools/NiViewer.Android/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/Source/Tools/NiViewer.Android/res/layout/activity_niviewer.xml b/Source/Tools/NiViewer.Android/res/layout/activity_niviewer.xml new file mode 100644 index 00000000..d42aa3f5 --- /dev/null +++ b/Source/Tools/NiViewer.Android/res/layout/activity_niviewer.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/Source/Tools/NiViewer.Android/res/layout/stream_view.xml b/Source/Tools/NiViewer.Android/res/layout/stream_view.xml new file mode 100644 index 00000000..c76d798c --- /dev/null +++ b/Source/Tools/NiViewer.Android/res/layout/stream_view.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + +