The file includes mexfunction code calling "Kinect for Windows SDK" to receive depth data and color image from Kinect and a Matlab code to reshape the information matries. Please see the Readme.txt for usage.
I got this nice code working with the latest SDK (1.6) following the fixes proposed by Chris. The the depth scaling however seems not to be working correctly. Any object closer than about 1 meter from the sensor will recieve zero depth. Starting at 1 meter and moving away from the sensor, the depth value starts to increase from zero with integer steps of 8. After about 30 cm, the depth value peaks at 4080 and then starts all over from zero again counting up in steps of 8 until it reaches 4080 after another 30 cm. I suspect that there is some confusion in the code between bits and bytes somwhow. How about this for a coincidence: dividing 4080 by 8 (8 bits = 1 byte) gives 510, which corresponds well with the 16 bit depht data of the Kinect sensor. So where does things go wrong in getimagedata.cpp? Please advice, I am a wizard in Matlab but a bozo in C.
I am running the same stuff as Chris Brunskill and believe I followed all the instructions correctly but when I try to run the program I get these error messages:
Creating library C:\Users\Kyle\AppData\Local\Temp\mex_pX365j\templib.x and object C:\Users\Kyle\AppData\Local\Temp\mex_pX365j\templib.exp
getimagedata.obj : error LNK2019: unresolved external symbol __imp__NuiImageStreamOpen@24 referenced in function "void __cdecl KinectInit(void)" (?KinectInit@@YAXXZ)
getimagedata.obj : error LNK2019: unresolved external symbol __imp__NuiInitialize@4 referenced in function "void __cdecl KinectInit(void)" (?KinectInit@@YAXXZ)
getimagedata.obj : error LNK2019: unresolved external symbol __imp__NuiShutdown@0 referenced in function "void __cdecl KinectShutdown(void)" (?KinectShutdown@@YAXXZ)
getimagedata.obj : error LNK2019: unresolved external symbol __imp__NuiImageStreamReleaseFrame@8 referenced in function "bool __cdecl Nui_GotDepthAlert(double (* const))" (?Nui_GotDepthAlert@@YA_NQAY0CIA@N@Z)
getimagedata.obj : error LNK2019: unresolved external symbol __imp__NuiImageStreamGetNextFrame@12 referenced in function "bool __cdecl Nui_GotDepthAlert(double (* const))" (?Nui_GotDepthAlert@@YA_NQAY0CIA@N@Z)
getimagedata.mexw32 : fatal error LNK1120: 5 unresolved externals
C:\PROGRA~2\BIN\MEX.PL: Error: Link of 'getimagedata.mexw32' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
I had the same problems as above and have fixed it with a little tweaking.
I am using Matlab 7.12.0a (R2011a) and Visual Studio 10 on Windows 7, all in 64 bit flavours. I have the Kinect SDK v1.5.
There are two problems. Firstly, Microsoft have changed a number of the api call names which require a little tweaking in getimagedata.cpp. Secondly, mex seems a little temperamental with where it looks for the header and library files (also, mex command in the Readme is incorrect).
You can see the changes I have made at the following link, which also has the fixed getimagedata.cpp source.
(if anyone knows a better way to share this please let me know)
You will also see I have changed the header location to "NuiApi.h". You will need to edit this header and do the same for the NuiImageCamera.h, NuiSensor.h and NuiSkeleton.h.
I found this the was easiest way to force mex to find the headers after copying them from the Kinect SDK include folder (e.g C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include) to my Matlab working folder. Crude, but it does the job.
I also moved Kinect10.lib from the Kinect SDK amd64 lib folder (e.g C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64) to the MS VS lib folder (in my case C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\LIB\amd64).
Then simply compile with mex specifying the kinect library filename
I had the same problem and I fixed it today. As far as I know the problem arises from the differences in the libraries of the SDK beta and the newly released SDK.
What I did was that I changed this code using the "SkeletalViewer" example of the SDK sample browser, and I was able to get it running on matlab.
Hope this helps, let me know if you have further questions.