Permalink
Browse files

First commit for public release

  • Loading branch information...
0 parents commit f6bd9150ef1acb773826da1f94bb0ba49a39ebc8 Simon Hamilton Ritchie committed Sep 6, 2011
132 README
@@ -0,0 +1,132 @@
+ofxMSKinect addon for openFrameworks 0.3
+Copyright (c) 2011 Matchbox Mobile Limited
+
+See _License.txt for license and copyright information.
+
+Feature list
+~~~~~~~~~~~~
+1. initialize multiple kinect devices
+ a. Second kinect doesn't support player info in the depth data
+ b. second kinect doesn't support skeleton tracking.
+2. video data
+3. depth Data
+4. transform depth to video
+5. multiple tracked skeleton data
+6. skeleton data contains ofVec3f joint positions
+7. transform joint position to depth position (used to help render in 2d)
+8. Helpful methods to retrieve data as ofTexture, ofImage, ofPixels so you can manipulate.
+
+Install
+~~~~~~~
+Please extract the zip file to the root directory of where you have openframeworks code.
+For example, mine is:
+ G:\Work\Projects\KinectOF\OFInstall\
+The zip only contains our new files, it will not overwrite any of your existing install.
+
+Once extracted, there will be a new folder in
+ addons\ofxMSKinect\
+And a new example in
+ apps\addonsExamples\msKinectExample\
+
+The example project shows how to use all our currently exposed functionality.
+
+How to use
+~~~~~~~~~~
+See msKinectExample for more details.
+
+Initialize
+~~~~~~~~~~
+ofxMSKinect* kinect;
+kinect = new ofxMSKinect();
+kinect->Init(SINGLE_DEVICE); //Pass MULTIPLE_DEVICES if you intend to use more than 1 kinect.
+
+if(kinect->HasKinectDevice())
+{
+ firstDevice = kinect->GetKinectDeviceDefault();
+
+ // init the video feed
+ firstDevice->StartRGB(IMAGE_RESOLUTION_640x480);
+
+ // init the depth buffer
+ firstDevice->StartDepth(IMAGE_RESOLUTION_320x240);
+
+ // init skeleton tracking
+ firstDevice->StartSkeletonTracking();
+}
+
+Multiple Kinects
+~~~~~~~~~~~
+//Using multiple kinects has the same interface as single kinect
+int count = kinect->GetKinectDeviceCount();
+firstDevice = kinect->GetKinectDevice(1);
+
+
+Camera Data
+~~~~~~~~~~~
+
+Get Video Data
+~~~~~~~~~~~~~~
+//First update the image
+bool isOk = firstDevice->UpdateRGBVideo
+
+//Now render it
+firstDevice->DrawVidImage(x, y, w, h);
+
+
+Get Depth Data
+~~~~~~~~~~~~~~
+//First update the image
+isOk = firstDevice->UpdateDepth() ;
+
+//Now render it
+firstDevice->DrawDepthTexture(x, y, w, h);
+
+
+
+Get Player index from depth
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+int player = ofxMSKinect::GetPlayerIndex(shortData[indexOfDepthData];
+
+Get distance from depth data - millimetres
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+int distance = ofxMSKinect::GetDepthDistance(shortData[depthIndex]);
+
+
+Skeletons
+~~~~~~~~~
+
+Check if skeleton data exists
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+if(firstDevice->HasSkeleton())
+
+Get the first tracked skeleton data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ofxMSKinectSkeleton skeletonData;
+
+hasSkeleton = firstDevice->GetFirstTrackedSkeleton(&skeletonData);
+
+Get a tracked skeleton by index
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ofxMSKinectSkeleton skeletonData;
+skeletonData = firstDevice->skeletons[0];
+
+Get Skeleton points
+~~~~~~~~~~~~~~~~~~~
+ofVec3f headPosition = skeletonData.SkeletonPositions[NUI_SKELETON_POSITION_HEAD];
+
+Known issues
+~~~~~~~~~~~~
+1. Depth data has a 4 pixel bar on the left if transposed to image data
+2. No Audio support
+
+
+
+Development Environment and Compiler SUpport
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Tested with the following IDE's: MS Visual Studio 10, CodeBlock (using Gcc compiler).
+
+NOTE: !! Developers useing CobeBlock Gcc compiler who require multi device support please define the following in the defines pannel of your project
+#define USING_CODE_BLOCKS_GCC_COMPILER
+
+This is required to allow the code to include an additional Interface definition which allows Codeblocks Gcc compiler to correctly
+confgure registers and stack in order the call into the MSKinetic.dll when addressing vtable entries which require access to the "this" ptr.
@@ -0,0 +1,24 @@
+Version 0.3 26/08/2011
+********************************************************
+* Added support for multiple kinect devices
+ * Trouble making this work with code::blocks due to the differences in gcc and MS compiler
+* Moved the texture allocation to inside the wrapper. Example code no longer requires its own reference
+* Added methods to support ofPixels and ofImage
+* Abstracted some render methods into the wrapper. Useful for debug purposes.
+* More bug fixes.
+
+Version 0.2 23/08/2011
+********************************************************
+* Added workspace files for Code::Blocks
+* Modifications made to header files to allow a successfull build in Code::Blocks
+* Added code for multiple kinect devices (untested)
+* Added support for multiple tracked skeleton data
+* Fixed a bug where the depth value was not passed to the transform method.
+* Fixed an out of bounds bug while parsing RGB data to Depth
+* Fixed some memory leaks
+* Refactored exposed classes. Many method names have changed casing and in some cases naming to better represent their function.
+
+
+Version 0.1 22/08/2011
+********************************************************
+Initial release
@@ -0,0 +1,31 @@
+The ofxMSKinect addon for openFrameworks is released under the MIT License.
+
+----------------------------------------------------------
+
+The MIT License
+
+Copyright (c) 2011 Matchbox Mobile Limited
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+----------------------------------------------------------
+
+The ofxMSKinect addon requires the following SDKs which may have different licenses and further dependencies.
+
+Kinect for Windows SDK (http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/)
@@ -0,0 +1,37 @@
+<install>
+
+ <version>0.3</version>
+ <author>Matchbox Mobile</author>
+ <url></url>
+
+ <requires>
+ </requires>
+
+ <add>
+ <addons_h>
+ #ifndef OF_ADDON_USING_OFXADDON
+ #include "ofxAddon.h" //this .h file includes every .h file we need. [[Adding Addons]]
+ #endif
+ </addons_h>
+
+ <src>
+ <folder name="addons/ofxMSKinect/src">
+ <file>../../../addons/ofxMSKinect/src/ofxMSKinect.h</file>
+ <file>../../../addons/ofxMSKinect/src/ofxMSKinect.cpp</file>
+ <file>../../../addons/ofxMSKinect/src/ofxMSKinectDevice.h</file>
+ <file>../../../addons/ofxMSKinect/src/ofxMSKinectDevice.cpp</file>
+ <file>../../../addons/ofxMSKinect/src/ofxMSKinectSkeleton.h</file>
+
+ </folder>
+ </src>
+
+ <include>
+ <path>../../../addons/ofxMSKinect/src</path>
+ </include>
+
+ <link>
+ </link>
+
+ </add>
+
+</install>
@@ -0,0 +1,109 @@
+
+#pragma once
+
+// This will stop compiler errors in CodeBlocks Gcc
+//Define to nothing if not defined
+#ifndef _In_
+#define _In_
+#define _In_opt_
+#define _Out_
+#define _Deref_out_
+#endif
+
+
+//Note: If you wish to use the multidevice interface provided by the MSKinect sdk and are
+//using the CodeBlocks Gcc compiler define this, USING_CODE_BLOCKS_GCC_COMPILER, in order that
+//the compiler will correctly configure stack and registers to call into the the MSKinect dlls
+//pure virtual functions.
+
+#if defined(USING_CODE_BLOCKS_GCC_COMPILER)
+// idea taken from here, thanks
+// http://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/281008-gcc-thiscall-calling-convention-linux-win32-mingw.html
+#define CODEBLOCK_FASTCALL __attribute__((fastcall))
+#define START_ARG_DECL int,
+#define NO_ARG_DECL int
+#define START_ARG 0,
+#define NO_ARG 0
+
+#else
+
+#define CODEBLOCK_FASTCALL
+#define START_ARG_DECL
+#define NO_ARG_DECL
+#define START_ARG
+#define NO_ARG
+
+#endif
+
+// must include MRS_NuiApi.h just here
+#include "MSR_NuiApi.h"
+
+//Create another version of the INuiInstance interface (called ofxINuiInstance) and configure for fastcall and an extra param "IF" using codeblocks
+//This is done in order to get the "this" ptr passed to the MSKinect dll in correct register and to have stack set correctly
+interface ofxINuiInstance
+{
+ virtual CODEBLOCK_FASTCALL int InstanceIndex(NO_ARG_DECL) = 0;
+ virtual CODEBLOCK_FASTCALL HRESULT NuiInitialize(START_ARG_DECL _In_ DWORD dwFlags ) = 0;
+ virtual CODEBLOCK_FASTCALL VOID NuiShutdown(NO_ARG_DECL ) = 0;
+ virtual CODEBLOCK_FASTCALL HRESULT NuiImageStreamOpen(START_ARG_DECL
+ _In_ NUI_IMAGE_TYPE eImageType,
+ _In_ NUI_IMAGE_RESOLUTION eResolution,
+ _In_ DWORD dwImageFrameFlags_NotUsed,
+ _In_ DWORD dwFrameLimit,
+ _In_opt_ HANDLE hNextFrameEvent,
+ _Out_ HANDLE *phStreamHandle
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiImageStreamGetNextFrame(START_ARG_DECL
+ _In_ HANDLE hStream,
+ _In_ DWORD dwMillisecondsToWait,
+ _Deref_out_ CONST NUI_IMAGE_FRAME **ppcImageFrame
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiImageStreamReleaseFrame(START_ARG_DECL
+ _In_ HANDLE hStream,
+ CONST NUI_IMAGE_FRAME *pImageFrame
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiImageGetColorPixelCoordinatesFromDepthPixel(START_ARG_DECL
+ _In_ NUI_IMAGE_RESOLUTION eColorResolution,
+ _In_opt_ CONST NUI_IMAGE_VIEW_AREA *pcViewArea,
+ _In_ LONG lDepthX,
+ _In_ LONG lDepthY,
+ _In_ USHORT usDepthValue,
+ _Out_ LONG *plColorX,
+ _Out_ LONG *plColorY
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiCameraElevationSetAngle(START_ARG_DECL
+ _In_ LONG lAngleDegrees
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiCameraElevationGetAngle(START_ARG_DECL
+ _In_ LONG * plAngleDegrees
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiSkeletonTrackingEnable(START_ARG_DECL
+ _In_opt_ HANDLE hNextFrameEvent,
+ _In_ DWORD dwFlags
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiSkeletonTrackingDisable(NO_ARG_DECL
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiSkeletonGetNextFrame(START_ARG_DECL
+ _In_ DWORD dwMillisecondsToWait,
+ _Out_ NUI_SKELETON_FRAME *pSkeletonFrame
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL HRESULT NuiTransformSmooth(START_ARG_DECL
+ NUI_SKELETON_FRAME *pSkeletonFrame,
+ const NUI_TRANSFORM_SMOOTH_PARAMETERS *pSmoothingParams
+ ) = 0;
+
+ virtual CODEBLOCK_FASTCALL bool MSR_NuiGetPropsBlob( START_ARG_DECL MsrNui::NUI_PROPSINDEX Index, void * pBlob, DWORD * pdwInOutSize ) = 0;
+ virtual CODEBLOCK_FASTCALL MsrNui::NUI_PROPSTYPE MSR_NuiGetPropsType( START_ARG_DECL MsrNui::NUI_PROPSINDEX Index ) = 0;
+};
+
+
+
Oops, something went wrong.

0 comments on commit f6bd915

Please sign in to comment.