├── .gitignore ├── Kinect2SDK ├── 1_Basics │ ├── glut │ │ ├── GLUT_OpenGL.props │ │ ├── Kinect.props │ │ ├── KinectTutorial1.sln │ │ ├── KinectTutorial1.vcxproj │ │ ├── KinectTutorial1.vcxproj.filters │ │ └── glut.cpp │ └── sdl │ │ ├── Kinect.props │ │ ├── KinectTutorial1.sln │ │ ├── KinectTutorial1.vcxproj │ │ ├── KinectTutorial1.vcxproj.filters │ │ ├── SDL.cpp │ │ └── SDL_OpenGL.props ├── 2_Depth │ ├── GLUT_OpenGL.props │ ├── Kinect.props │ ├── KinectTutorial1.vcxproj │ ├── KinectTutorial1.vcxproj.filters │ ├── KinectTutorial2.sln │ ├── KinectTutorial2.vcxproj │ ├── KinectTutorial2.vcxproj.filters │ ├── SDL.cpp │ ├── SDL_OpenGL.props │ ├── glut.cpp │ ├── glut.h │ ├── main.cpp │ ├── main.h │ └── sdl.h ├── 3_PointCloud │ ├── GLUT_OpenGL.props │ ├── Kinect.props │ ├── KinectTutorial3.sln │ ├── KinectTutorial3.vcxproj │ ├── KinectTutorial3.vcxproj.filters │ ├── SDL.cpp │ ├── SDL_OpenGL.props │ ├── glut.cpp │ ├── glut.h │ ├── main.cpp │ ├── main.h │ └── sdl.h └── 4_SkeletalTracking │ ├── GLUT_OpenGL.props │ ├── Kinect.props │ ├── KinectTutorial4.sln │ ├── KinectTutorial4.vcxproj │ ├── KinectTutorial4.vcxproj.filters │ ├── SDL.cpp │ ├── SDL_OpenGL.props │ ├── glut.cpp │ ├── glut.h │ ├── main.cpp │ ├── main.h │ └── sdl.h ├── KinectSDK ├── 1_Basics │ ├── glut │ │ ├── GLUT_OpenGL.props │ │ ├── Kinect.props │ │ ├── KinectTutorial1.sln │ │ ├── KinectTutorial1.vcxproj │ │ ├── KinectTutorial1.vcxproj.filters │ │ └── glut.cpp │ ├── notes │ └── sdl │ │ ├── Kinect.props │ │ ├── KinectTutorial1.sln │ │ ├── KinectTutorial1.vcxproj │ │ ├── KinectTutorial1.vcxproj.filters │ │ ├── SDL.cpp │ │ └── SDL_OpenGL.props ├── 2_Depth │ ├── GLUT_OpenGL.props │ ├── Kinect.props │ ├── KinectTutorial2.sln │ ├── KinectTutorial2.vcxproj │ ├── KinectTutorial2.vcxproj.filters │ ├── SDL.cpp │ ├── SDL_OpenGL.props │ ├── glut.cpp │ ├── glut.h │ ├── main.cpp │ ├── main.h │ └── sdl.h ├── 3_PointCloud │ ├── GLUT_OpenGL.props │ ├── Kinect.props │ ├── KinectTutorial3.sln │ ├── KinectTutorial3.vcxproj │ ├── KinectTutorial3.vcxproj.filters │ ├── SDL.cpp │ ├── SDL_OpenGL.props │ ├── glut.cpp │ ├── glut.h │ ├── main.cpp │ ├── main.h │ └── sdl.h └── 4_SkeletalTracking │ ├── GLUT_OpenGL.props │ ├── Kinect.props │ ├── KinectTutorial4.sln │ ├── KinectTutorial4.vcxproj │ ├── KinectTutorial4.vcxproj.filters │ ├── SDL.cpp │ ├── SDL_OpenGL.props │ ├── glut.cpp │ ├── glut.h │ ├── main.cpp │ ├── main.h │ └── sdl.h ├── README.md └── docs ├── google-code-prettify ├── lang-apollo.js ├── lang-clj.js ├── lang-css.js ├── lang-go.js ├── lang-hs.js ├── lang-lisp.js ├── lang-lua.js ├── lang-ml.js ├── lang-n.js ├── lang-proto.js ├── lang-scala.js ├── lang-sql.js ├── lang-tex.js ├── lang-vb.js ├── lang-vhdl.js ├── lang-wiki.js ├── lang-xq.js ├── lang-yaml.js ├── prettify.css └── prettify.js ├── images ├── kinectv1.png └── kinectv2.jpg ├── index.html ├── kinect ├── 1_Basics.zip ├── 2_Depth.zip ├── 3_PointCloud.zip ├── 4_SkeletalTracking.zip ├── images │ ├── 0_0.jpg │ ├── 0_1.jpg │ ├── 0_2.jpg │ ├── 0_2_2.jpg │ ├── 0_3.jpg │ ├── kinect3.gif │ ├── kinect3_registered.png │ └── kinect3_unregistered.png ├── kinect0.html ├── kinect0_sdl.html ├── kinect1.html ├── kinect2.html ├── kinect3.html └── kinect4.html ├── kinect2 ├── 1_Basics.zip ├── 2_Depth.zip ├── 3_PointCloud.zip ├── 4_SkeletalTracking.zip ├── images │ ├── 0_0.jpg │ ├── 0_1.jpg │ ├── 0_2.jpg │ ├── 0_2_2.jpg │ ├── 0_3.jpg │ ├── kinect3.gif │ ├── kinect3_registered.png │ └── kinect3_unregistered.png ├── kinect0.html ├── kinect0_sdl.html ├── kinect1.html ├── kinect2.html ├── kinect3.html └── kinect4.html └── main.css /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | 9 | # Compiled Static libraries 10 | *.lai 11 | *.la 12 | *.a 13 | 14 | #OS junk files 15 | [Tt]humbs.db 16 | *.DS_Store 17 | 18 | #Visual Studio files 19 | *.[Oo]bj 20 | *.user 21 | *.aps 22 | *.pch 23 | *.vspscc 24 | *.vssscc 25 | *_i.c 26 | *_p.c 27 | *.ncb 28 | *.suo 29 | *.tlb 30 | *.tlh 31 | *.bak 32 | *.[Cc]ache 33 | *.ilk 34 | *.log 35 | *.lib 36 | *.sbr 37 | *.sdf 38 | *.opensdf 39 | *.unsuccessfulbuild 40 | ipch/ 41 | obj/ 42 | [Bb]in 43 | [Dd]ebug*/ 44 | [Rr]elease*/ 45 | Ankh.NoLoad 46 | 47 | #MonoDevelop 48 | *.pidb 49 | *.userprefs 50 | 51 | #Tooling 52 | _ReSharper*/ 53 | *.resharper 54 | [Tt]est[Rr]esult* 55 | 56 | #Project files 57 | [Bb]uild/ 58 | 59 | #Subversion files 60 | .svn 61 | 62 | # Office Temp Files 63 | ~$* 64 | 65 | #NuGet 66 | packages/ 67 | 68 | #ncrunch 69 | *ncrunch* 70 | *crunch*.local.xml 71 | 72 | # visual studio database projects 73 | *.dbmdl 74 | 75 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/glut/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | freeglut.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/glut/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK20_DIR)/inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK20_DIR)/lib/x86;%(AdditionalLibraryDirectories) 12 | kinect20.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/glut/KinectTutorial1.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial1", "KinectTutorial1.vcxproj", "{393AEF8A-3340-302A-20C7-3402DB4373CD}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Debug|Win32.Build.0 = Debug|Win32 14 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Release|Win32.ActiveCfg = Release|Win32 15 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/glut/KinectTutorial1.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | {393AEF8A-3340-302A-20C7-3402DB4373CD} 16 | 17 | 18 | 19 | Application 20 | true 21 | v120 22 | 23 | 24 | Application 25 | false 26 | v120 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | true 47 | 48 | 49 | 50 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 51 | MultiThreadedDebugDLL 52 | Level3 53 | ProgramDatabase 54 | Disabled 55 | 56 | 57 | MachineX86 58 | true 59 | Windows 60 | mainCRTStartup 61 | 62 | 63 | 64 | 65 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 66 | MultiThreadedDLL 67 | Level3 68 | ProgramDatabase 69 | 70 | 71 | MachineX86 72 | true 73 | Windows 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/glut/KinectTutorial1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/glut/glut.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #define width 1920 11 | #define height 1080 12 | 13 | // OpenGL Variables 14 | GLuint textureId; // ID of the texture to contain Kinect RGB Data 15 | GLubyte data[width*height*4]; // BGRA array containing the texture data 16 | 17 | // Kinect variables 18 | IKinectSensor* sensor; // Kinect sensor 19 | IColorFrameReader* reader; // Kinect color data source 20 | 21 | void draw(void); 22 | 23 | bool init(int argc, char* argv[]) { 24 | glutInit(&argc, argv); 25 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 26 | glutInitWindowSize(width,height); 27 | glutCreateWindow("Kinect SDK Tutorial"); 28 | glutDisplayFunc(draw); 29 | glutIdleFunc(draw); 30 | return true; 31 | } 32 | 33 | bool initKinect() { 34 | if (FAILED(GetDefaultKinectSensor(&sensor))) { 35 | return false; 36 | } 37 | if (sensor) { 38 | sensor->Open(); 39 | IColorFrameSource* framesource = NULL; 40 | sensor->get_ColorFrameSource(&framesource); 41 | framesource->OpenReader(&reader); 42 | if (framesource) { 43 | framesource->Release(); 44 | framesource = NULL; 45 | } 46 | return true; 47 | } else { 48 | return false; 49 | } 50 | } 51 | 52 | void getKinectData(GLubyte* dest) { 53 | IColorFrame* frame = NULL; 54 | if (SUCCEEDED(reader->AcquireLatestFrame(&frame))) { 55 | frame->CopyConvertedFrameDataToArray(width*height*4, data, ColorImageFormat_Bgra); 56 | } 57 | if (frame) frame->Release(); 58 | } 59 | 60 | void drawKinectData() { 61 | glBindTexture(GL_TEXTURE_2D, textureId); 62 | getKinectData(data); 63 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*)data); 64 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 65 | glBegin(GL_QUADS); 66 | glTexCoord2f(0.0f, 0.0f); 67 | glVertex3f(0, 0, 0); 68 | glTexCoord2f(1.0f, 0.0f); 69 | glVertex3f(width, 0, 0); 70 | glTexCoord2f(1.0f, 1.0f); 71 | glVertex3f(width, height, 0.0f); 72 | glTexCoord2f(0.0f, 1.0f); 73 | glVertex3f(0, height, 0.0f); 74 | glEnd(); 75 | } 76 | 77 | void draw() { 78 | drawKinectData(); 79 | glutSwapBuffers(); 80 | } 81 | 82 | void execute() { 83 | glutMainLoop(); 84 | } 85 | 86 | int main(int argc, char* argv[]) { 87 | if (!init(argc, argv)) return 1; 88 | if (!initKinect()) return 1; 89 | 90 | // Initialize textures 91 | glGenTextures(1, &textureId); 92 | glBindTexture(GL_TEXTURE_2D, textureId); 93 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 94 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 95 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*) data); 96 | glBindTexture(GL_TEXTURE_2D, 0); 97 | 98 | // OpenGL setup 99 | glClearColor(0,0,0,0); 100 | glClearDepth(1.0f); 101 | glEnable(GL_TEXTURE_2D); 102 | 103 | // Camera setup 104 | glViewport(0, 0, width, height); 105 | glMatrixMode(GL_PROJECTION); 106 | glLoadIdentity(); 107 | glOrtho(0, width, height, 0, 1, -1); 108 | glMatrixMode(GL_MODELVIEW); 109 | glLoadIdentity(); 110 | 111 | // Main loop 112 | execute(); 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/sdl/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK20_DIR)/inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK20_DIR)/lib/x86;%(AdditionalLibraryDirectories) 12 | kinect20.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/sdl/KinectTutorial1.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial1", "KinectTutorial1.vcxproj", "{CB1EBFE0-66A4-BC38-A967-34B20AC59481}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Debug|Win32.Build.0 = Debug|Win32 14 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Release|Win32.ActiveCfg = Release|Win32 15 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/sdl/KinectTutorial1.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | 16 | 17 | 18 | Application 19 | true 20 | 21 | 22 | Application 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | true 39 | 40 | 41 | true 42 | 43 | 44 | 45 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 46 | MultiThreadedDebugDLL 47 | Level3 48 | ProgramDatabase 49 | Disabled 50 | 51 | 52 | MachineX86 53 | true 54 | Windows 55 | 56 | 57 | 58 | 59 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 60 | MultiThreadedDLL 61 | Level3 62 | ProgramDatabase 63 | 64 | 65 | MachineX86 66 | true 67 | Windows 68 | true 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/sdl/KinectTutorial1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/sdl/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #define width 1920 10 | #define height 1080 11 | 12 | // OpenGL Variables 13 | GLuint textureId; // ID of the texture to contain Kinect RGB Data 14 | GLubyte data[width*height*4]; // BGRA array containing the texture data 15 | 16 | // Kinect variables 17 | IKinectSensor* sensor; // Kinect sensor 18 | IColorFrameReader* reader; // Kinect color data source 19 | 20 | bool init(int argc, char* argv[]) { 21 | SDL_Init(SDL_INIT_EVERYTHING); 22 | SDL_Surface* screen = 23 | SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 24 | return screen; 25 | } 26 | 27 | bool initKinect() { 28 | if (FAILED(GetDefaultKinectSensor(&sensor))) { 29 | return false; 30 | } 31 | if (sensor) { 32 | sensor->Open(); 33 | IColorFrameSource* framesource = NULL; 34 | sensor->get_ColorFrameSource(&framesource); 35 | framesource->OpenReader(&reader); 36 | if (framesource) { 37 | framesource->Release(); 38 | framesource = NULL; 39 | } 40 | return true; 41 | } else { 42 | return false; 43 | } 44 | } 45 | 46 | void getKinectData(GLubyte* dest) { 47 | IColorFrame* frame = NULL; 48 | if (SUCCEEDED(reader->AcquireLatestFrame(&frame))) { 49 | frame->CopyConvertedFrameDataToArray(width*height*4, data, ColorImageFormat_Bgra); 50 | } 51 | if (frame) frame->Release(); 52 | } 53 | 54 | void drawKinectData() { 55 | glBindTexture(GL_TEXTURE_2D, textureId); 56 | getKinectData(data); 57 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)data); 58 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 59 | glBegin(GL_QUADS); 60 | glTexCoord2f(0.0f, 0.0f); 61 | glVertex3f(0, 0, 0); 62 | glTexCoord2f(1.0f, 0.0f); 63 | glVertex3f(width, 0, 0); 64 | glTexCoord2f(1.0f, 1.0f); 65 | glVertex3f(width, height, 0.0f); 66 | glTexCoord2f(0.0f, 1.0f); 67 | glVertex3f(0, height, 0.0f); 68 | glEnd(); 69 | } 70 | 71 | void execute() { 72 | SDL_Event ev; 73 | bool running = true; 74 | while (running) { 75 | while (SDL_PollEvent(&ev)) { 76 | if (ev.type == SDL_QUIT) running = false; 77 | } 78 | drawKinectData(); 79 | SDL_GL_SwapBuffers(); 80 | } 81 | } 82 | 83 | int main(int argc, char* argv[]) { 84 | if (!init(argc, argv)) return 1; 85 | if (!initKinect()) return 1; 86 | 87 | // Initialize textures 88 | glGenTextures(1, &textureId); 89 | glBindTexture(GL_TEXTURE_2D, textureId); 90 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 91 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 92 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*) data); 93 | glBindTexture(GL_TEXTURE_2D, 0); 94 | 95 | // OpenGL setup 96 | glClearColor(0,0,0,0); 97 | glClearDepth(1.0f); 98 | glEnable(GL_TEXTURE_2D); 99 | 100 | // Camera setup 101 | glViewport(0, 0, width, height); 102 | glMatrixMode(GL_PROJECTION); 103 | glLoadIdentity(); 104 | glOrtho(0, width, height, 0, 1, -1); 105 | glMatrixMode(GL_MODELVIEW); 106 | glLoadIdentity(); 107 | 108 | // Main loop 109 | execute(); 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /Kinect2SDK/1_Basics/sdl/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)/include 9 | 10 | 11 | $(SDL_DIR)/lib/x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | freeglut.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK20_DIR)/inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK20_DIR)/lib/x86;%(AdditionalLibraryDirectories) 12 | kinect20.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/KinectTutorial1.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | KinectTutorial2 16 | {70310886-D860-75E0-1C0D-A80D659BF33F} 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | 24 | 25 | Application 26 | false 27 | v120 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | true 45 | 46 | 47 | true 48 | 49 | 50 | 51 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 52 | MultiThreadedDebugDLL 53 | Level3 54 | ProgramDatabase 55 | Disabled 56 | 57 | 58 | MachineX86 59 | true 60 | Windows 61 | mainCRTStartup 62 | 63 | 64 | 65 | 66 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 67 | MultiThreadedDLL 68 | Level3 69 | ProgramDatabase 70 | 71 | 72 | MachineX86 73 | true 74 | Windows 75 | true 76 | true 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/KinectTutorial1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/KinectTutorial2.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial2", "KinectTutorial2.vcxproj", "{70310886-D860-75E0-1C0D-A80D659BF33F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Debug|Win32.Build.0 = Debug|Win32 14 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Release|Win32.ActiveCfg = Release|Win32 15 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/KinectTutorial2.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | KinectTutorial2 16 | 17 | 18 | 19 | Application 20 | true 21 | 22 | 23 | Application 24 | false 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | true 47 | 48 | 49 | 50 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 51 | MultiThreadedDebugDLL 52 | Level3 53 | ProgramDatabase 54 | Disabled 55 | 56 | 57 | MachineX86 58 | true 59 | Windows 60 | mainCRTStartup 61 | 62 | 63 | 64 | 65 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 66 | MultiThreadedDLL 67 | Level3 68 | ProgramDatabase 69 | 70 | 71 | MachineX86 72 | true 73 | Windows 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/KinectTutorial2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "main.h" 3 | 4 | bool init(int argc, char* argv[]) { 5 | SDL_Init(SDL_INIT_EVERYTHING); 6 | SDL_Surface* screen = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 7 | return screen; 8 | } 9 | void execute() { 10 | SDL_Event ev; 11 | bool running = true; 12 | while (running) { 13 | while (SDL_PollEvent(&ev)) { 14 | if (ev.type == SDL_QUIT) running = false; 15 | } 16 | drawKinectData(); 17 | SDL_GL_SwapBuffers(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)\include 9 | 10 | 11 | $(SDL_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/glut.cpp: -------------------------------------------------------------------------------- 1 | #include "glut.h" 2 | #include "main.h" 3 | 4 | void draw() { 5 | drawKinectData(); 6 | glutSwapBuffers(); 7 | } 8 | 9 | void execute() { 10 | glutMainLoop(); 11 | } 12 | 13 | bool init(int argc, char* argv[]) { 14 | glutInit(&argc, argv); 15 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 16 | glutInitWindowSize(width,height); 17 | glutCreateWindow("Kinect SDK Tutorial"); 18 | glutDisplayFunc(draw); 19 | glutIdleFunc(draw); 20 | return true; 21 | } 22 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/glut.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | bool init(int argc, char* argv[]); 8 | void draw(); 9 | void execute(); -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "glut.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | // OpenGL Variables 10 | GLuint textureId; 11 | GLubyte data[width*height*4]; 12 | 13 | // Kinect variables 14 | IKinectSensor* sensor; // Kinect sensor 15 | IDepthFrameReader* reader; // Kinect depth data source 16 | 17 | bool initKinect() { 18 | if (FAILED(GetDefaultKinectSensor(&sensor))) { 19 | return false; 20 | } 21 | if (sensor) { 22 | sensor->Open(); 23 | IDepthFrameSource* framesource = NULL; 24 | sensor->get_DepthFrameSource(&framesource); 25 | framesource->OpenReader(&reader); 26 | if (framesource) { 27 | framesource->Release(); 28 | framesource = NULL; 29 | } 30 | return true; 31 | } else { 32 | return false; 33 | } 34 | } 35 | 36 | void getKinectData(GLubyte* dest) { 37 | IDepthFrame* frame = NULL; 38 | if (SUCCEEDED(reader->AcquireLatestFrame(&frame))) { 39 | unsigned int sz; 40 | unsigned short* buf; 41 | frame->AccessUnderlyingBuffer(&sz, &buf); 42 | 43 | const unsigned short* curr = (const unsigned short*)buf; 44 | const unsigned short* dataEnd = curr + (width*height); 45 | 46 | while (curr < dataEnd) { 47 | // Get depth in millimeters 48 | unsigned short depth = (*curr++); 49 | 50 | // Draw a grayscale image of the depth: 51 | // B,G,R are all set to depth%256, alpha set to 1. 52 | for (int i = 0; i < 3; ++i) 53 | *dest++ = (BYTE)depth % 256; 54 | *dest++ = 0xff; 55 | } 56 | } 57 | if (frame) frame->Release(); 58 | } 59 | 60 | void drawKinectData() { 61 | glBindTexture(GL_TEXTURE_2D, textureId); 62 | getKinectData(data); 63 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*)data); 64 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 65 | glBegin(GL_QUADS); 66 | glTexCoord2f(0.0f, 0.0f); 67 | glVertex3f(0, 0, 0); 68 | glTexCoord2f(1.0f, 0.0f); 69 | glVertex3f(width, 0, 0); 70 | glTexCoord2f(1.0f, 1.0f); 71 | glVertex3f(width, height, 0.0f); 72 | glTexCoord2f(0.0f, 1.0f); 73 | glVertex3f(0, height, 0.0f); 74 | glEnd(); 75 | } 76 | 77 | int main(int argc, char* argv[]) { 78 | if (!init(argc, argv)) return 1; 79 | if (!initKinect()) return 1; 80 | 81 | // Initialize textures 82 | glGenTextures(1, &textureId); 83 | glBindTexture(GL_TEXTURE_2D, textureId); 84 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 85 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 86 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*) data); 87 | glBindTexture(GL_TEXTURE_2D, 0); 88 | 89 | // OpenGL setup 90 | glClearColor(0,0,0,0); 91 | glClearDepth(1.0f); 92 | glEnable(GL_TEXTURE_2D); 93 | 94 | // Camera setup 95 | glViewport(0, 0, width, height); 96 | glMatrixMode(GL_PROJECTION); 97 | glLoadIdentity(); 98 | glOrtho(0, width, height, 0, 1, -1); 99 | glMatrixMode(GL_MODELVIEW); 100 | glLoadIdentity(); 101 | 102 | // Main loop 103 | execute(); 104 | return 0; 105 | } 106 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | const int width = 512; 3 | const int height = 424; 4 | 5 | void drawKinectData(); 6 | -------------------------------------------------------------------------------- /Kinect2SDK/2_Depth/sdl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | bool init(int argc, char* argv[]); 6 | void execute(); -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | glew32.lib;freeglut.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK20_DIR)/inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK20_DIR)/lib/x86;%(AdditionalLibraryDirectories) 12 | kinect20.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/KinectTutorial3.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial3", "KinectTutorial3.vcxproj", "{AFFAABC2-707F-4CE0-87D1-CCA550249103}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Debug|Win32.Build.0 = Debug|Win32 14 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Release|Win32.ActiveCfg = Release|Win32 15 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/KinectTutorial3.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | KinectTutorial3 16 | 17 | 18 | 19 | Application 20 | true 21 | 22 | 23 | Application 24 | false 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | true 47 | 48 | 49 | 50 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 51 | MultiThreadedDebugDLL 52 | Level3 53 | ProgramDatabase 54 | Disabled 55 | 56 | 57 | MachineX86 58 | true 59 | Windows 60 | mainCRTStartup 61 | 62 | 63 | 64 | 65 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 66 | MultiThreadedDLL 67 | Level3 68 | ProgramDatabase 69 | 70 | 71 | MachineX86 72 | true 73 | Windows 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/KinectTutorial3.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "main.h" 3 | 4 | bool init(int argc, char* argv[]) { 5 | SDL_Init(SDL_INIT_EVERYTHING); 6 | SDL_Surface* screen = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 7 | return screen; 8 | } 9 | void execute() { 10 | SDL_Event ev; 11 | bool running = true; 12 | while (running) { 13 | while (SDL_PollEvent(&ev)) { 14 | if (ev.type == SDL_QUIT) running = false; 15 | } 16 | drawKinectData(); 17 | SDL_GL_SwapBuffers(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)\include 9 | 10 | 11 | $(SDL_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glew32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/glut.cpp: -------------------------------------------------------------------------------- 1 | #include "glut.h" 2 | #include "main.h" 3 | 4 | void draw() { 5 | drawKinectData(); 6 | glutSwapBuffers(); 7 | } 8 | 9 | void execute() { 10 | glutMainLoop(); 11 | } 12 | 13 | bool init(int argc, char* argv[]) { 14 | glutInit(&argc, argv); 15 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 16 | glutInitWindowSize(width,height); 17 | glutCreateWindow("Kinect SDK Tutorial"); 18 | glutDisplayFunc(draw); 19 | glutIdleFunc(draw); 20 | glewInit(); 21 | return true; 22 | } 23 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/glut.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | bool init(int argc, char* argv[]); 9 | void draw(); 10 | void execute(); -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "glut.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | // We'll be using buffer objects to store the kinect point cloud 13 | GLuint vboId; 14 | GLuint cboId; 15 | 16 | // Intermediate Buffers 17 | unsigned char rgbimage[colorwidth*colorheight*4]; // Stores RGB color image 18 | ColorSpacePoint depth2rgb[width*height]; // Maps depth pixels to rgb pixels 19 | CameraSpacePoint depth2xyz[width*height]; // Maps depth pixels to 3d coordinates 20 | 21 | // Kinect Variables 22 | IKinectSensor* sensor; // Kinect sensor 23 | IMultiSourceFrameReader* reader; // Kinect data source 24 | ICoordinateMapper* mapper; // Converts between depth, color, and 3d coordinates 25 | 26 | bool initKinect() { 27 | if (FAILED(GetDefaultKinectSensor(&sensor))) { 28 | return false; 29 | } 30 | if (sensor) { 31 | sensor->get_CoordinateMapper(&mapper); 32 | 33 | sensor->Open(); 34 | sensor->OpenMultiSourceFrameReader( 35 | FrameSourceTypes::FrameSourceTypes_Depth | FrameSourceTypes::FrameSourceTypes_Color, 36 | &reader); 37 | return reader; 38 | } else { 39 | return false; 40 | } 41 | } 42 | 43 | void getDepthData(IMultiSourceFrame* frame, GLubyte* dest) { 44 | IDepthFrame* depthframe; 45 | IDepthFrameReference* frameref = NULL; 46 | frame->get_DepthFrameReference(&frameref); 47 | frameref->AcquireFrame(&depthframe); 48 | if (frameref) frameref->Release(); 49 | 50 | if (!depthframe) return; 51 | 52 | // Get data from frame 53 | unsigned int sz; 54 | unsigned short* buf; 55 | depthframe->AccessUnderlyingBuffer(&sz, &buf); 56 | 57 | // Write vertex coordinates 58 | mapper->MapDepthFrameToCameraSpace(width*height, buf, width*height, depth2xyz); 59 | float* fdest = (float*)dest; 60 | for (int i = 0; i < sz; i++) { 61 | *fdest++ = depth2xyz[i].X; 62 | *fdest++ = depth2xyz[i].Y; 63 | *fdest++ = depth2xyz[i].Z; 64 | } 65 | 66 | // Fill in depth2rgb map 67 | mapper->MapDepthFrameToColorSpace(width*height, buf, width*height, depth2rgb); 68 | if (depthframe) depthframe->Release(); 69 | } 70 | 71 | void getRgbData(IMultiSourceFrame* frame, GLubyte* dest) { 72 | IColorFrame* colorframe; 73 | IColorFrameReference* frameref = NULL; 74 | frame->get_ColorFrameReference(&frameref); 75 | frameref->AcquireFrame(&colorframe); 76 | if (frameref) frameref->Release(); 77 | 78 | if (!colorframe) return; 79 | 80 | // Get data from frame 81 | colorframe->CopyConvertedFrameDataToArray(colorwidth*colorheight*4, rgbimage, ColorImageFormat_Rgba); 82 | 83 | // Write color array for vertices 84 | float* fdest = (float*)dest; 85 | for (int i = 0; i < width*height; i++) { 86 | ColorSpacePoint p = depth2rgb[i]; 87 | // Check if color pixel coordinates are in bounds 88 | if (p.X < 0 || p.Y < 0 || p.X > colorwidth || p.Y > colorheight) { 89 | *fdest++ = 0; 90 | *fdest++ = 0; 91 | *fdest++ = 0; 92 | } 93 | else { 94 | int idx = (int)p.X + colorwidth*(int)p.Y; 95 | *fdest++ = rgbimage[4*idx + 0]/255.; 96 | *fdest++ = rgbimage[4*idx + 1]/255.; 97 | *fdest++ = rgbimage[4*idx + 2]/255.; 98 | } 99 | // Don't copy alpha channel 100 | } 101 | 102 | if (colorframe) colorframe->Release(); 103 | } 104 | 105 | void getKinectData() { 106 | IMultiSourceFrame* frame = NULL; 107 | if (SUCCEEDED(reader->AcquireLatestFrame(&frame))) { 108 | GLubyte* ptr; 109 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 110 | ptr = (GLubyte*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 111 | if (ptr) { 112 | getDepthData(frame, ptr); 113 | } 114 | glUnmapBuffer(GL_ARRAY_BUFFER); 115 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 116 | ptr = (GLubyte*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 117 | if (ptr) { 118 | getRgbData(frame, ptr); 119 | } 120 | glUnmapBuffer(GL_ARRAY_BUFFER); 121 | } 122 | if (frame) frame->Release(); 123 | } 124 | 125 | void rotateCamera() { 126 | static double angle = 0.; 127 | static double radius = 3.; 128 | double x = radius*sin(angle); 129 | double z = radius*(1-cos(angle)) - radius/2; 130 | glMatrixMode(GL_MODELVIEW); 131 | glLoadIdentity(); 132 | gluLookAt(x,0,z,0,0,radius/2,0,1,0); 133 | angle += 0.002; 134 | } 135 | 136 | void drawKinectData() { 137 | getKinectData(); 138 | rotateCamera(); 139 | 140 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 141 | glEnableClientState(GL_VERTEX_ARRAY); 142 | glEnableClientState(GL_COLOR_ARRAY); 143 | 144 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 145 | glVertexPointer(3, GL_FLOAT, 0, NULL); 146 | 147 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 148 | glColorPointer(3, GL_FLOAT, 0, NULL); 149 | 150 | glPointSize(1.f); 151 | glDrawArrays(GL_POINTS, 0, width*height); 152 | 153 | glDisableClientState(GL_VERTEX_ARRAY); 154 | glDisableClientState(GL_COLOR_ARRAY); 155 | } 156 | 157 | int main(int argc, char* argv[]) { 158 | if (!init(argc, argv)) return 1; 159 | if (!initKinect()) return 1; 160 | 161 | // OpenGL setup 162 | glClearColor(0,0,0,0); 163 | glClearDepth(1.0f); 164 | 165 | // Set up array buffers 166 | const int dataSize = width*height * 3 * 4; 167 | glGenBuffers(1, &vboId); 168 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 169 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 170 | glGenBuffers(1, &cboId); 171 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 172 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 173 | 174 | // Camera setup 175 | glViewport(0, 0, width, height); 176 | glMatrixMode(GL_PROJECTION); 177 | glLoadIdentity(); 178 | gluPerspective(45, width /(GLdouble) height, 0.1, 1000); 179 | glMatrixMode(GL_MODELVIEW); 180 | glLoadIdentity(); 181 | gluLookAt(0,0,0,0,0,1,0,1,0); 182 | 183 | // Main loop 184 | execute(); 185 | return 0; 186 | } 187 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | const int width = 512; 3 | const int height = 424; 4 | const int colorwidth = 1920; 5 | const int colorheight = 1080; 6 | 7 | void drawKinectData(); 8 | -------------------------------------------------------------------------------- /Kinect2SDK/3_PointCloud/sdl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | bool init(int argc, char* argv[]); 6 | void execute(); -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | glew32.lib;freeglut.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK20_DIR)/inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK20_DIR)/lib/x86;%(AdditionalLibraryDirectories) 12 | kinect20.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/KinectTutorial4.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial4", "KinectTutorial4.vcxproj", "{04B88BA4-4BF9-4C46-BACF-28B896538A14}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Debug|Win32.Build.0 = Debug|Win32 14 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Release|Win32.ActiveCfg = Release|Win32 15 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/KinectTutorial4.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {04B88BA4-4BF9-4C46-BACF-28B896538A14} 15 | KinectTutorial4 16 | 17 | 18 | 19 | Application 20 | true 21 | MultiByte 22 | 23 | 24 | Application 25 | false 26 | true 27 | MultiByte 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Level3 49 | Disabled 50 | 51 | 52 | true 53 | 54 | 55 | 56 | 57 | Level3 58 | MaxSpeed 59 | true 60 | true 61 | 62 | 63 | true 64 | true 65 | true 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/KinectTutorial4.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "main.h" 3 | 4 | bool init(int argc, char* argv[]) { 5 | SDL_Init(SDL_INIT_EVERYTHING); 6 | SDL_Surface* screen = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 7 | return screen; 8 | } 9 | void execute() { 10 | SDL_Event ev; 11 | bool running = true; 12 | while (running) { 13 | while (SDL_PollEvent(&ev)) { 14 | if (ev.type == SDL_QUIT) running = false; 15 | } 16 | drawKinectData(); 17 | SDL_GL_SwapBuffers(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)\include 9 | 10 | 11 | $(SDL_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glew32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/glut.cpp: -------------------------------------------------------------------------------- 1 | #include "glut.h" 2 | #include "main.h" 3 | 4 | void draw() { 5 | drawKinectData(); 6 | glutSwapBuffers(); 7 | } 8 | 9 | void execute() { 10 | glutMainLoop(); 11 | } 12 | 13 | bool init(int argc, char* argv[]) { 14 | glutInit(&argc, argv); 15 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 16 | glutInitWindowSize(width,height); 17 | glutCreateWindow("Kinect SDK Tutorial"); 18 | glutDisplayFunc(draw); 19 | glutIdleFunc(draw); 20 | glewInit(); 21 | return true; 22 | } 23 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/glut.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | bool init(int argc, char* argv[]); 9 | void draw(); 10 | void execute(); -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "glut.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | // We'll be using buffer objects to store the kinect point cloud 13 | GLuint vboId; 14 | GLuint cboId; 15 | 16 | // Intermediate Buffers 17 | unsigned char rgbimage[colorwidth*colorheight*4]; // Stores RGB color image 18 | ColorSpacePoint depth2rgb[width*height]; // Maps depth pixels to rgb pixels 19 | CameraSpacePoint depth2xyz[width*height]; // Maps depth pixels to 3d coordinates 20 | 21 | // Body tracking variables 22 | BOOLEAN tracked; // Whether we see a body 23 | Joint joints[JointType_Count]; // List of joints in the tracked body 24 | 25 | // Kinect Variables 26 | IKinectSensor* sensor; // Kinect sensor 27 | IMultiSourceFrameReader* reader; // Kinect data source 28 | ICoordinateMapper* mapper; // Converts between depth, color, and 3d coordinates 29 | 30 | bool initKinect() { 31 | if (FAILED(GetDefaultKinectSensor(&sensor))) { 32 | return false; 33 | } 34 | if (sensor) { 35 | sensor->get_CoordinateMapper(&mapper); 36 | 37 | sensor->Open(); 38 | sensor->OpenMultiSourceFrameReader( 39 | FrameSourceTypes::FrameSourceTypes_Depth | FrameSourceTypes::FrameSourceTypes_Color | FrameSourceTypes::FrameSourceTypes_Body, 40 | &reader); 41 | return reader; 42 | } else { 43 | return false; 44 | } 45 | } 46 | 47 | void getDepthData(IMultiSourceFrame* frame, GLubyte* dest) { 48 | IDepthFrame* depthframe; 49 | IDepthFrameReference* frameref = NULL; 50 | frame->get_DepthFrameReference(&frameref); 51 | frameref->AcquireFrame(&depthframe); 52 | if (frameref) frameref->Release(); 53 | 54 | if (!depthframe) return; 55 | 56 | // Get data from frame 57 | unsigned int sz; 58 | unsigned short* buf; 59 | depthframe->AccessUnderlyingBuffer(&sz, &buf); 60 | 61 | // Write vertex coordinates 62 | mapper->MapDepthFrameToCameraSpace(width*height, buf, width*height, depth2xyz); 63 | float* fdest = (float*)dest; 64 | for (int i = 0; i < sz; i++) { 65 | *fdest++ = depth2xyz[i].X; 66 | *fdest++ = depth2xyz[i].Y; 67 | *fdest++ = depth2xyz[i].Z; 68 | } 69 | 70 | // Fill in depth2rgb map 71 | mapper->MapDepthFrameToColorSpace(width*height, buf, width*height, depth2rgb); 72 | if (depthframe) depthframe->Release(); 73 | } 74 | 75 | void getRgbData(IMultiSourceFrame* frame, GLubyte* dest) { 76 | IColorFrame* colorframe; 77 | IColorFrameReference* frameref = NULL; 78 | frame->get_ColorFrameReference(&frameref); 79 | frameref->AcquireFrame(&colorframe); 80 | if (frameref) frameref->Release(); 81 | 82 | if (!colorframe) return; 83 | 84 | // Get data from frame 85 | colorframe->CopyConvertedFrameDataToArray(colorwidth*colorheight*4, rgbimage, ColorImageFormat_Rgba); 86 | 87 | // Write color array for vertices 88 | float* fdest = (float*)dest; 89 | for (int i = 0; i < width*height; i++) { 90 | ColorSpacePoint p = depth2rgb[i]; 91 | // Check if color pixel coordinates are in bounds 92 | if (p.X < 0 || p.Y < 0 || p.X > colorwidth || p.Y > colorheight) { 93 | *fdest++ = 0; 94 | *fdest++ = 0; 95 | *fdest++ = 0; 96 | } 97 | else { 98 | int idx = (int)p.X + colorwidth*(int)p.Y; 99 | *fdest++ = rgbimage[4*idx + 0]/255.; 100 | *fdest++ = rgbimage[4*idx + 1]/255.; 101 | *fdest++ = rgbimage[4*idx + 2]/255.; 102 | } 103 | } 104 | 105 | if (colorframe) colorframe->Release(); 106 | } 107 | 108 | void getBodyData(IMultiSourceFrame* frame) { 109 | IBodyFrame* bodyframe; 110 | IBodyFrameReference* frameref = NULL; 111 | frame->get_BodyFrameReference(&frameref); 112 | frameref->AcquireFrame(&bodyframe); 113 | if (frameref) frameref->Release(); 114 | 115 | if (!bodyframe) return; 116 | 117 | IBody* body[BODY_COUNT] = { 0 }; 118 | bodyframe->GetAndRefreshBodyData(BODY_COUNT, body); 119 | for (int i = 0; i < BODY_COUNT; i++) { 120 | body[i]->get_IsTracked(&tracked); 121 | if (tracked) { 122 | body[i]->GetJoints(JointType_Count, joints); 123 | break; 124 | } 125 | } 126 | 127 | if (bodyframe) bodyframe->Release(); 128 | } 129 | 130 | void getKinectData() { 131 | IMultiSourceFrame* frame = NULL; 132 | if (SUCCEEDED(reader->AcquireLatestFrame(&frame))) { 133 | GLubyte* ptr; 134 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 135 | ptr = (GLubyte*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 136 | if (ptr) { 137 | getDepthData(frame, ptr); 138 | } 139 | glUnmapBuffer(GL_ARRAY_BUFFER); 140 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 141 | ptr = (GLubyte*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 142 | if (ptr) { 143 | getRgbData(frame, ptr); 144 | } 145 | glUnmapBuffer(GL_ARRAY_BUFFER); 146 | getBodyData(frame); 147 | } 148 | if (frame) frame->Release(); 149 | } 150 | 151 | void rotateCamera() { 152 | static double angle = 0.; 153 | static double radius = 3.; 154 | double x = radius*sin(angle); 155 | double z = radius*(1-cos(angle)) - radius/2; 156 | glMatrixMode(GL_MODELVIEW); 157 | glLoadIdentity(); 158 | gluLookAt(x,0,z,0,0,radius/2,0,1,0); 159 | angle += 0.001; 160 | } 161 | 162 | void drawKinectData() { 163 | getKinectData(); 164 | rotateCamera(); 165 | 166 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 167 | glEnableClientState(GL_VERTEX_ARRAY); 168 | glEnableClientState(GL_COLOR_ARRAY); 169 | 170 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 171 | glVertexPointer(3, GL_FLOAT, 0, NULL); 172 | 173 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 174 | glColorPointer(3, GL_FLOAT, 0, NULL); 175 | 176 | glPointSize(1.f); 177 | glDrawArrays(GL_POINTS, 0, width*height); 178 | 179 | glDisableClientState(GL_VERTEX_ARRAY); 180 | glDisableClientState(GL_COLOR_ARRAY); 181 | 182 | if (tracked) { 183 | // Draw some arms 184 | const CameraSpacePoint& lh = joints[JointType_WristLeft].Position; 185 | const CameraSpacePoint& le = joints[JointType_ElbowLeft].Position;; 186 | const CameraSpacePoint& ls = joints[JointType_ShoulderLeft].Position;; 187 | const CameraSpacePoint& rh = joints[JointType_WristRight].Position;; 188 | const CameraSpacePoint& re = joints[JointType_ElbowRight].Position;; 189 | const CameraSpacePoint& rs = joints[JointType_ShoulderRight].Position;; 190 | glBegin(GL_LINES); 191 | glColor3f(1.f, 0.f, 0.f); 192 | glVertex3f(lh.X, lh.Y, lh.Z); 193 | glVertex3f(le.X, le.Y, le.Z); 194 | glVertex3f(le.X, le.Y, le.Z); 195 | glVertex3f(ls.X, ls.Y, ls.Z); 196 | glVertex3f(rh.X, rh.Y, rh.Z); 197 | glVertex3f(re.X, re.Y, re.Z); 198 | glVertex3f(re.X, re.Y, re.Z); 199 | glVertex3f(rs.X, rs.Y, rs.Z); 200 | glEnd(); 201 | } 202 | } 203 | 204 | int main(int argc, char* argv[]) { 205 | if (!init(argc, argv)) return 1; 206 | if (!initKinect()) return 1; 207 | 208 | // OpenGL setup 209 | glClearColor(0,0,0,0); 210 | glClearDepth(1.0f); 211 | 212 | // Set up array buffers 213 | const int dataSize = width*height * 3 * 4; 214 | glGenBuffers(1, &vboId); 215 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 216 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 217 | glGenBuffers(1, &cboId); 218 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 219 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 220 | 221 | // Camera setup 222 | glViewport(0, 0, width, height); 223 | glMatrixMode(GL_PROJECTION); 224 | glLoadIdentity(); 225 | gluPerspective(45, width /(GLdouble) height, 0.1, 1000); 226 | glMatrixMode(GL_MODELVIEW); 227 | glLoadIdentity(); 228 | gluLookAt(0,0,0,0,0,1,0,1,0); 229 | 230 | // Main loop 231 | execute(); 232 | return 0; 233 | } 234 | -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | const int width = 512; 3 | const int height = 424; 4 | const int colorwidth = 1920; 5 | const int colorheight = 1080; 6 | 7 | void drawKinectData(); -------------------------------------------------------------------------------- /Kinect2SDK/4_SkeletalTracking/sdl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | bool init(int argc, char* argv[]); 6 | void execute(); -------------------------------------------------------------------------------- /KinectSDK/1_Basics/glut/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/glut/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK10_DIR)\inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK10_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | kinect10.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/glut/KinectTutorial1.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial1", "KinectTutorial1.vcxproj", "{393AEF8A-3340-302A-20C7-3402DB4373CD}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Debug|Win32.Build.0 = Debug|Win32 14 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Release|Win32.ActiveCfg = Release|Win32 15 | {393AEF8A-3340-302A-20C7-3402DB4373CD}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/glut/KinectTutorial1.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | 16 | 17 | 18 | Application 19 | true 20 | 21 | 22 | Application 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | true 41 | 42 | 43 | true 44 | 45 | 46 | 47 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 48 | MultiThreadedDebugDLL 49 | Level3 50 | ProgramDatabase 51 | Disabled 52 | 53 | 54 | MachineX86 55 | true 56 | Windows 57 | mainCRTStartup 58 | 59 | 60 | 61 | 62 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 63 | MultiThreadedDLL 64 | Level3 65 | ProgramDatabase 66 | 67 | 68 | MachineX86 69 | true 70 | Windows 71 | true 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/glut/KinectTutorial1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/glut/glut.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define width 640 13 | #define height 480 14 | 15 | // OpenGL Variables 16 | GLuint textureId; // ID of the texture to contain Kinect RGB Data 17 | GLubyte data[width*height*4]; // BGRA array containing the texture data 18 | 19 | // Kinect variables 20 | HANDLE rgbStream; // The identifier of the Kinect's RGB Camera 21 | INuiSensor* sensor; // The kinect sensor 22 | 23 | void draw(void); 24 | 25 | bool init(int argc, char* argv[]) { 26 | glutInit(&argc, argv); 27 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 28 | glutInitWindowSize(width,height); 29 | glutCreateWindow("Kinect SDK Tutorial"); 30 | glutDisplayFunc(draw); 31 | glutIdleFunc(draw); 32 | return true; 33 | } 34 | 35 | bool initKinect() { 36 | // Get a working kinect sensor 37 | int numSensors; 38 | if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false; 39 | if (NuiCreateSensorByIndex(0, &sensor) < 0) return false; 40 | 41 | // Initialize sensor 42 | sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR); 43 | sensor->NuiImageStreamOpen( 44 | NUI_IMAGE_TYPE_COLOR, // Depth camera or rgb camera? 45 | NUI_IMAGE_RESOLUTION_640x480, // Image resolution 46 | 0, // Image stream flags, e.g. near mode 47 | 2, // Number of frames to buffer 48 | NULL, // Event handle 49 | &rgbStream); 50 | return sensor; 51 | } 52 | 53 | void getKinectData(GLubyte* dest) { 54 | NUI_IMAGE_FRAME imageFrame; 55 | NUI_LOCKED_RECT LockedRect; 56 | if (sensor->NuiImageStreamGetNextFrame(rgbStream, 0, &imageFrame) < 0) return; 57 | INuiFrameTexture* texture = imageFrame.pFrameTexture; 58 | texture->LockRect(0, &LockedRect, NULL, 0); 59 | if (LockedRect.Pitch != 0) 60 | { 61 | const BYTE* curr = (const BYTE*) LockedRect.pBits; 62 | const BYTE* dataEnd = curr + (width*height)*4; 63 | 64 | while (curr < dataEnd) { 65 | *dest++ = *curr++; 66 | } 67 | } 68 | texture->UnlockRect(0); 69 | sensor->NuiImageStreamReleaseFrame(rgbStream, &imageFrame); 70 | } 71 | 72 | void drawKinectData() { 73 | glBindTexture(GL_TEXTURE_2D, textureId); 74 | getKinectData(data); 75 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*)data); 76 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 77 | glBegin(GL_QUADS); 78 | glTexCoord2f(0.0f, 0.0f); 79 | glVertex3f(0, 0, 0); 80 | glTexCoord2f(1.0f, 0.0f); 81 | glVertex3f(width, 0, 0); 82 | glTexCoord2f(1.0f, 1.0f); 83 | glVertex3f(width, height, 0.0f); 84 | glTexCoord2f(0.0f, 1.0f); 85 | glVertex3f(0, height, 0.0f); 86 | glEnd(); 87 | } 88 | 89 | void draw() { 90 | drawKinectData(); 91 | glutSwapBuffers(); 92 | } 93 | 94 | void execute() { 95 | glutMainLoop(); 96 | } 97 | 98 | int main(int argc, char* argv[]) { 99 | if (!init(argc, argv)) return 1; 100 | if (!initKinect()) return 1; 101 | 102 | // Initialize textures 103 | glGenTextures(1, &textureId); 104 | glBindTexture(GL_TEXTURE_2D, textureId); 105 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 106 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 107 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*) data); 108 | glBindTexture(GL_TEXTURE_2D, 0); 109 | 110 | // OpenGL setup 111 | glClearColor(0,0,0,0); 112 | glClearDepth(1.0f); 113 | glEnable(GL_TEXTURE_2D); 114 | 115 | // Camera setup 116 | glViewport(0, 0, width, height); 117 | glMatrixMode(GL_PROJECTION); 118 | glLoadIdentity(); 119 | glOrtho(0, width, height, 0, 1, -1); 120 | glMatrixMode(GL_MODELVIEW); 121 | glLoadIdentity(); 122 | 123 | // Main loop 124 | execute(); 125 | return 0; 126 | } 127 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/notes: -------------------------------------------------------------------------------- 1 | SDL Instructions: 2 | 3 | Prereqs: Windows, Visual Studio. C, OpenGL. 4 | 5 | 0. Install SDL - Download, unzip, remember directory 6 | 1. Set up project: 7 | - Open visual studio, new project. 8 | - Set up config cards 9 | - View > Property Manager 10 | - Right-click project, Add New Project Property Sheet, call it 11 | SDL_OpenGL (Kinect) (GLUT) 12 | - Right-click new sheet, Properties. 13 | C/C++ > Additional Include Directories: $(SDL_DIR)\include 14 | Linker > Additional Library Directories: $(SDL_DIR)\lib\x86 15 | Linker > Input > Additional Dependencies: opengl32.lib, glu32.lib, SDL.lib, SDLmain.lib (glut32.lib) 16 | C/C++ > Additional Include Directories: $(KINECTSDK10_DIR)\include 17 | Linker > Additional Library Directories: $(KINECTSDK10_DIR)\lib\x86 18 | Linker > Input > Additional Dependencies: kinect10.lib, FaceTrackLib.lib 19 | - Optionally, add to release. 20 | 21 | 2. Code 22 | Includes - windows, NUI, SDL 23 | 24 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/sdl/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK10_DIR)\inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK10_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | kinect10.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/sdl/KinectTutorial1.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial1", "KinectTutorial1.vcxproj", "{CB1EBFE0-66A4-BC38-A967-34B20AC59481}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Debug|Win32.Build.0 = Debug|Win32 14 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Release|Win32.ActiveCfg = Release|Win32 15 | {CB1EBFE0-66A4-BC38-A967-34B20AC59481}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/sdl/KinectTutorial1.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | 16 | 17 | 18 | Application 19 | true 20 | 21 | 22 | Application 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | true 39 | 40 | 41 | true 42 | 43 | 44 | 45 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 46 | MultiThreadedDebugDLL 47 | Level3 48 | ProgramDatabase 49 | Disabled 50 | 51 | 52 | MachineX86 53 | true 54 | Windows 55 | 56 | 57 | 58 | 59 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 60 | MultiThreadedDLL 61 | Level3 62 | ProgramDatabase 63 | 64 | 65 | MachineX86 66 | true 67 | Windows 68 | true 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/sdl/KinectTutorial1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/sdl/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define width 640 12 | #define height 480 13 | 14 | // OpenGL Variables 15 | GLuint textureId; // ID of the texture to contain Kinect RGB Data 16 | GLubyte data[width*height*4]; // BGRA array containing the texture data 17 | 18 | // Kinect variables 19 | HANDLE rgbStream; // The identifier of the Kinect's RGB Camera 20 | INuiSensor* sensor; // The kinect sensor 21 | 22 | bool init(int argc, char* argv[]) { 23 | SDL_Init(SDL_INIT_EVERYTHING); 24 | SDL_Surface* screen = 25 | SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 26 | return screen; 27 | } 28 | 29 | bool initKinect() { 30 | // Get a working kinect sensor 31 | int numSensors; 32 | if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false; 33 | if (NuiCreateSensorByIndex(0, &sensor) < 0) return false; 34 | 35 | // Initialize sensor 36 | sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR); 37 | sensor->NuiImageStreamOpen( 38 | NUI_IMAGE_TYPE_COLOR, // Depth camera or rgb camera? 39 | NUI_IMAGE_RESOLUTION_640x480, // Image resolution 40 | 0, // Image stream flags, e.g. near mode 41 | 2, // Number of frames to buffer 42 | NULL, // Event handle 43 | &rgbStream); 44 | return sensor; 45 | } 46 | 47 | void getKinectData(GLubyte* dest) { 48 | NUI_IMAGE_FRAME imageFrame; 49 | NUI_LOCKED_RECT LockedRect; 50 | if (sensor->NuiImageStreamGetNextFrame(rgbStream, 0, &imageFrame) < 0) return; 51 | INuiFrameTexture* texture = imageFrame.pFrameTexture; 52 | texture->LockRect(0, &LockedRect, NULL, 0); 53 | if (LockedRect.Pitch != 0) 54 | { 55 | const BYTE* curr = (const BYTE*) LockedRect.pBits; 56 | const BYTE* dataEnd = curr + (width*height)*4; 57 | 58 | while (curr < dataEnd) { 59 | *dest++ = *curr++; 60 | } 61 | } 62 | texture->UnlockRect(0); 63 | sensor->NuiImageStreamReleaseFrame(rgbStream, &imageFrame); 64 | } 65 | 66 | void drawKinectData() { 67 | glBindTexture(GL_TEXTURE_2D, textureId); 68 | getKinectData(data); 69 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)data); 70 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 71 | glBegin(GL_QUADS); 72 | glTexCoord2f(0.0f, 0.0f); 73 | glVertex3f(0, 0, 0); 74 | glTexCoord2f(1.0f, 0.0f); 75 | glVertex3f(width, 0, 0); 76 | glTexCoord2f(1.0f, 1.0f); 77 | glVertex3f(width, height, 0.0f); 78 | glTexCoord2f(0.0f, 1.0f); 79 | glVertex3f(0, height, 0.0f); 80 | glEnd(); 81 | } 82 | 83 | void execute() { 84 | SDL_Event ev; 85 | bool running = true; 86 | while (running) { 87 | while (SDL_PollEvent(&ev)) { 88 | if (ev.type == SDL_QUIT) running = false; 89 | } 90 | drawKinectData(); 91 | SDL_GL_SwapBuffers(); 92 | } 93 | } 94 | 95 | int main(int argc, char* argv[]) { 96 | if (!init(argc, argv)) return 1; 97 | if (!initKinect()) return 1; 98 | 99 | // Initialize textures 100 | glGenTextures(1, &textureId); 101 | glBindTexture(GL_TEXTURE_2D, textureId); 102 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 103 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 104 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*) data); 105 | glBindTexture(GL_TEXTURE_2D, 0); 106 | 107 | // OpenGL setup 108 | glClearColor(0,0,0,0); 109 | glClearDepth(1.0f); 110 | glEnable(GL_TEXTURE_2D); 111 | 112 | // Camera setup 113 | glViewport(0, 0, width, height); 114 | glMatrixMode(GL_PROJECTION); 115 | glLoadIdentity(); 116 | glOrtho(0, width, height, 0, 1, -1); 117 | glMatrixMode(GL_MODELVIEW); 118 | glLoadIdentity(); 119 | 120 | // Main loop 121 | execute(); 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /KinectSDK/1_Basics/sdl/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)\include 9 | 10 | 11 | $(SDL_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK10_DIR)\inc;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK10_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | kinect10.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/KinectTutorial2.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial2", "KinectTutorial2.vcxproj", "{70310886-D860-75E0-1C0D-A80D659BF33F}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Debug|Win32.Build.0 = Debug|Win32 14 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Release|Win32.ActiveCfg = Release|Win32 15 | {70310886-D860-75E0-1C0D-A80D659BF33F}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/KinectTutorial2.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | KinectTutorial2 16 | 17 | 18 | 19 | Application 20 | true 21 | 22 | 23 | Application 24 | false 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | true 47 | 48 | 49 | 50 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 51 | MultiThreadedDebugDLL 52 | Level3 53 | ProgramDatabase 54 | Disabled 55 | 56 | 57 | MachineX86 58 | true 59 | Windows 60 | mainCRTStartup 61 | 62 | 63 | 64 | 65 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 66 | MultiThreadedDLL 67 | Level3 68 | ProgramDatabase 69 | 70 | 71 | MachineX86 72 | true 73 | Windows 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/KinectTutorial2.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "main.h" 3 | 4 | bool init(int argc, char* argv[]) { 5 | SDL_Init(SDL_INIT_EVERYTHING); 6 | SDL_Surface* screen = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 7 | return screen; 8 | } 9 | void execute() { 10 | SDL_Event ev; 11 | bool running = true; 12 | while (running) { 13 | while (SDL_PollEvent(&ev)) { 14 | if (ev.type == SDL_QUIT) running = false; 15 | } 16 | drawKinectData(); 17 | SDL_GL_SwapBuffers(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)\include 9 | 10 | 11 | $(SDL_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/glut.cpp: -------------------------------------------------------------------------------- 1 | #include "glut.h" 2 | #include "main.h" 3 | 4 | void draw() { 5 | drawKinectData(); 6 | glutSwapBuffers(); 7 | } 8 | 9 | void execute() { 10 | glutMainLoop(); 11 | } 12 | 13 | bool init(int argc, char* argv[]) { 14 | glutInit(&argc, argv); 15 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 16 | glutInitWindowSize(width,height); 17 | glutCreateWindow("Kinect SDK Tutorial"); 18 | glutDisplayFunc(draw); 19 | glutIdleFunc(draw); 20 | return true; 21 | } 22 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/glut.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | bool init(int argc, char* argv[]); 8 | void draw(); 9 | void execute(); -------------------------------------------------------------------------------- /KinectSDK/2_Depth/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "glut.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | // OpenGL Variables 12 | GLuint textureId; 13 | GLubyte data[width*height*4]; 14 | 15 | // Kinect variables 16 | HANDLE depthStream; 17 | INuiSensor* sensor; 18 | 19 | bool initKinect() { 20 | // Get a working kinect sensor 21 | int numSensors; 22 | if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false; 23 | if (NuiCreateSensorByIndex(0, &sensor) < 0) return false; 24 | 25 | // Initialize sensor 26 | sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR); 27 | sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_DEPTH, // Depth camera or rgb camera? 28 | NUI_IMAGE_RESOLUTION_640x480, // Image resolution 29 | NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE, // Image stream flags, e.g. near mode 30 | 2, // Number of frames to buffer 31 | NULL, // Event handle 32 | &depthStream); 33 | return sensor; 34 | } 35 | 36 | void getKinectData(GLubyte* dest) { 37 | NUI_IMAGE_FRAME imageFrame; 38 | NUI_LOCKED_RECT LockedRect; 39 | if (sensor->NuiImageStreamGetNextFrame(depthStream, 0, &imageFrame) < 0) return; 40 | INuiFrameTexture* texture = imageFrame.pFrameTexture; 41 | texture->LockRect(0, &LockedRect, NULL, 0); 42 | if (LockedRect.Pitch != 0) 43 | { 44 | const USHORT* curr = (const USHORT*) LockedRect.pBits; 45 | const USHORT* dataEnd = curr + (width*height); 46 | 47 | while (curr < dataEnd) { 48 | // Get depth in millimeters 49 | USHORT depth = NuiDepthPixelToDepth(*curr++); 50 | 51 | // Draw a grayscale image of the depth: 52 | // B,G,R are all set to depth%256, alpha set to 1. 53 | for (int i = 0; i < 3; ++i) 54 | *dest++ = (BYTE) depth%256; 55 | *dest++ = 0xff; 56 | } 57 | } 58 | texture->UnlockRect(0); 59 | sensor->NuiImageStreamReleaseFrame(depthStream, &imageFrame); 60 | } 61 | 62 | void drawKinectData() { 63 | glBindTexture(GL_TEXTURE_2D, textureId); 64 | getKinectData(data); 65 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*)data); 66 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 67 | glBegin(GL_QUADS); 68 | glTexCoord2f(0.0f, 0.0f); 69 | glVertex3f(0, 0, 0); 70 | glTexCoord2f(1.0f, 0.0f); 71 | glVertex3f(width, 0, 0); 72 | glTexCoord2f(1.0f, 1.0f); 73 | glVertex3f(width, height, 0.0f); 74 | glTexCoord2f(0.0f, 1.0f); 75 | glVertex3f(0, height, 0.0f); 76 | glEnd(); 77 | } 78 | 79 | int main(int argc, char* argv[]) { 80 | if (!init(argc, argv)) return 1; 81 | if (!initKinect()) return 1; 82 | 83 | // Initialize textures 84 | glGenTextures(1, &textureId); 85 | glBindTexture(GL_TEXTURE_2D, textureId); 86 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 87 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 88 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (GLvoid*) data); 89 | glBindTexture(GL_TEXTURE_2D, 0); 90 | 91 | // OpenGL setup 92 | glClearColor(0,0,0,0); 93 | glClearDepth(1.0f); 94 | glEnable(GL_TEXTURE_2D); 95 | 96 | // Camera setup 97 | glViewport(0, 0, width, height); 98 | glMatrixMode(GL_PROJECTION); 99 | glLoadIdentity(); 100 | glOrtho(0, width, height, 0, 1, -1); 101 | glMatrixMode(GL_MODELVIEW); 102 | glLoadIdentity(); 103 | 104 | // Main loop 105 | execute(); 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /KinectSDK/2_Depth/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | const int width = 640; 3 | const int height = 480; 4 | 5 | void drawKinectData(); -------------------------------------------------------------------------------- /KinectSDK/2_Depth/sdl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | bool init(int argc, char* argv[]); 6 | void execute(); -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | glew32.lib;freeglut.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK10_DIR)\inc\;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK10_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | kinect10.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/KinectTutorial3.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial3", "KinectTutorial3.vcxproj", "{AFFAABC2-707F-4CE0-87D1-CCA550249103}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Debug|Win32.Build.0 = Debug|Win32 14 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Release|Win32.ActiveCfg = Release|Win32 15 | {AFFAABC2-707F-4CE0-87D1-CCA550249103}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/KinectTutorial3.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | Win32Proj 15 | KinectTutorial3 16 | 17 | 18 | 19 | Application 20 | true 21 | 22 | 23 | Application 24 | false 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | true 47 | 48 | 49 | 50 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 51 | MultiThreadedDebugDLL 52 | Level3 53 | ProgramDatabase 54 | Disabled 55 | 56 | 57 | MachineX86 58 | true 59 | Windows 60 | mainCRTStartup 61 | 62 | 63 | 64 | 65 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 66 | MultiThreadedDLL 67 | Level3 68 | ProgramDatabase 69 | 70 | 71 | MachineX86 72 | true 73 | Windows 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/KinectTutorial3.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "main.h" 3 | 4 | bool init(int argc, char* argv[]) { 5 | SDL_Init(SDL_INIT_EVERYTHING); 6 | SDL_Surface* screen = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 7 | return screen; 8 | } 9 | void execute() { 10 | SDL_Event ev; 11 | bool running = true; 12 | while (running) { 13 | while (SDL_PollEvent(&ev)) { 14 | if (ev.type == SDL_QUIT) running = false; 15 | } 16 | drawKinectData(); 17 | SDL_GL_SwapBuffers(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)\include 9 | 10 | 11 | $(SDL_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glew32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/glut.cpp: -------------------------------------------------------------------------------- 1 | #include "glut.h" 2 | #include "main.h" 3 | 4 | void draw() { 5 | drawKinectData(); 6 | glutSwapBuffers(); 7 | } 8 | 9 | void execute() { 10 | glutMainLoop(); 11 | } 12 | 13 | bool init(int argc, char* argv[]) { 14 | glutInit(&argc, argv); 15 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 16 | glutInitWindowSize(width,height); 17 | glutCreateWindow("Kinect SDK Tutorial"); 18 | glutDisplayFunc(draw); 19 | glutIdleFunc(draw); 20 | glewInit(); 21 | return true; 22 | } 23 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/glut.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | bool init(int argc, char* argv[]); 9 | void draw(); 10 | void execute(); -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "glut.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | // OpenGL Variables 15 | long depthToRgbMap[width*height*2]; 16 | // We'll be using buffer objects to store the kinect point cloud 17 | GLuint vboId; 18 | GLuint cboId; 19 | 20 | // Kinect variables 21 | HANDLE depthStream; 22 | HANDLE rgbStream; 23 | INuiSensor* sensor; 24 | 25 | bool initKinect() { 26 | // Get a working kinect sensor 27 | int numSensors; 28 | if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false; 29 | if (NuiCreateSensorByIndex(0, &sensor) < 0) return false; 30 | 31 | // Initialize sensor 32 | sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR); 33 | sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_DEPTH, // Depth camera or rgb camera? 34 | NUI_IMAGE_RESOLUTION_640x480, // Image resolution 35 | 0, // Image stream flags, e.g. near mode 36 | 2, // Number of frames to buffer 37 | NULL, // Event handle 38 | &depthStream); 39 | sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR, // Depth camera or rgb camera? 40 | NUI_IMAGE_RESOLUTION_640x480, // Image resolution 41 | 0, // Image stream flags, e.g. near mode 42 | 2, // Number of frames to buffer 43 | NULL, // Event handle 44 | &rgbStream); 45 | return sensor; 46 | } 47 | 48 | void getDepthData(GLubyte* dest) { 49 | float* fdest = (float*) dest; 50 | long* depth2rgb = (long*) depthToRgbMap; 51 | NUI_IMAGE_FRAME imageFrame; 52 | NUI_LOCKED_RECT LockedRect; 53 | if (sensor->NuiImageStreamGetNextFrame(depthStream, 0, &imageFrame) < 0) return; 54 | INuiFrameTexture* texture = imageFrame.pFrameTexture; 55 | texture->LockRect(0, &LockedRect, NULL, 0); 56 | if (LockedRect.Pitch != 0) { 57 | const USHORT* curr = (const USHORT*) LockedRect.pBits; 58 | for (int j = 0; j < height; ++j) { 59 | for (int i = 0; i < width; ++i) { 60 | // Get depth of pixel in millimeters 61 | USHORT depth = NuiDepthPixelToDepth(*curr++); 62 | // Store coordinates of the point corresponding to this pixel 63 | Vector4 pos = NuiTransformDepthImageToSkeleton(i, j, depth<<3, NUI_IMAGE_RESOLUTION_640x480); 64 | *fdest++ = pos.x/pos.w; 65 | *fdest++ = pos.y/pos.w; 66 | *fdest++ = pos.z/pos.w; 67 | // Store the index into the color array corresponding to this pixel 68 | NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution( 69 | NUI_IMAGE_RESOLUTION_640x480, NUI_IMAGE_RESOLUTION_640x480, NULL, 70 | i, j, depth<<3, depth2rgb, depth2rgb+1); 71 | depth2rgb += 2; 72 | } 73 | } 74 | } 75 | texture->UnlockRect(0); 76 | sensor->NuiImageStreamReleaseFrame(depthStream, &imageFrame); 77 | } 78 | 79 | void getRgbData(GLubyte* dest) { 80 | float* fdest = (float*) dest; 81 | long* depth2rgb = (long*) depthToRgbMap; 82 | NUI_IMAGE_FRAME imageFrame; 83 | NUI_LOCKED_RECT LockedRect; 84 | if (sensor->NuiImageStreamGetNextFrame(rgbStream, 0, &imageFrame) < 0) return; 85 | INuiFrameTexture* texture = imageFrame.pFrameTexture; 86 | texture->LockRect(0, &LockedRect, NULL, 0); 87 | if (LockedRect.Pitch != 0) { 88 | const BYTE* start = (const BYTE*) LockedRect.pBits; 89 | for (int j = 0; j < height; ++j) { 90 | for (int i = 0; i < width; ++i) { 91 | // Determine rgb color for each depth pixel 92 | long x = *depth2rgb++; 93 | long y = *depth2rgb++; 94 | // If out of bounds, then don't color it at all 95 | if (x < 0 || y < 0 || x > width || y > height) { 96 | for (int n = 0; n < 3; ++n) *(fdest++) = 0.0f; 97 | } 98 | else { 99 | const BYTE* curr = start + (x + width*y)*4; 100 | for (int n = 0; n < 3; ++n) *(fdest++) = curr[2-n]/255.0f; 101 | } 102 | 103 | } 104 | } 105 | } 106 | texture->UnlockRect(0); 107 | sensor->NuiImageStreamReleaseFrame(rgbStream, &imageFrame); 108 | } 109 | 110 | void getKinectData() { 111 | GLubyte* ptr; 112 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 113 | ptr = (GLubyte*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 114 | if (ptr) { 115 | getDepthData(ptr); 116 | } 117 | glUnmapBuffer(GL_ARRAY_BUFFER); 118 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 119 | ptr = (GLubyte*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 120 | if (ptr) { 121 | getRgbData(ptr); 122 | } 123 | glUnmapBuffer(GL_ARRAY_BUFFER); 124 | } 125 | 126 | void rotateCamera() { 127 | static double angle = 0.; 128 | static double radius = 3.; 129 | double x = radius*sin(angle); 130 | double z = radius*(1-cos(angle)) - radius/2; 131 | glMatrixMode(GL_MODELVIEW); 132 | glLoadIdentity(); 133 | gluLookAt(x,0,z,0,0,radius/2,0,1,0); 134 | angle += 0.05; 135 | } 136 | 137 | void drawKinectData() { 138 | getKinectData(); 139 | rotateCamera(); 140 | 141 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 142 | glEnableClientState(GL_VERTEX_ARRAY); 143 | glEnableClientState(GL_COLOR_ARRAY); 144 | 145 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 146 | glVertexPointer(3, GL_FLOAT, 0, NULL); 147 | 148 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 149 | glColorPointer(3, GL_FLOAT, 0, NULL); 150 | 151 | glPointSize(1.f); 152 | glDrawArrays(GL_POINTS, 0, width*height); 153 | 154 | glDisableClientState(GL_VERTEX_ARRAY); 155 | glDisableClientState(GL_COLOR_ARRAY); 156 | } 157 | 158 | int main(int argc, char* argv[]) { 159 | if (!init(argc, argv)) return 1; 160 | if (!initKinect()) return 1; 161 | 162 | // OpenGL setup 163 | glClearColor(0,0,0,0); 164 | glClearDepth(1.0f); 165 | 166 | // Set up array buffers 167 | const int dataSize = width*height * 3 * 4; 168 | glGenBuffers(1, &vboId); 169 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 170 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 171 | glGenBuffers(1, &cboId); 172 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 173 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 174 | 175 | // Camera setup 176 | glViewport(0, 0, width, height); 177 | glMatrixMode(GL_PROJECTION); 178 | glLoadIdentity(); 179 | gluPerspective(45, width /(GLdouble) height, 0.1, 1000); 180 | glMatrixMode(GL_MODELVIEW); 181 | glLoadIdentity(); 182 | gluLookAt(0,0,0,0,0,1,0,1,0); 183 | 184 | // Main loop 185 | execute(); 186 | return 0; 187 | } 188 | -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | const int width = 640; 3 | const int height = 480; 4 | 5 | void drawKinectData(); -------------------------------------------------------------------------------- /KinectSDK/3_PointCloud/sdl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | bool init(int argc, char* argv[]); 6 | void execute(); -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/GLUT_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | glew32.lib;freeglut.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/Kinect.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(KINECTSDK10_DIR)\inc\;%(AdditionalIncludeDirectories) 9 | 10 | 11 | $(KINECTSDK10_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | kinect10.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/KinectTutorial4.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinectTutorial4", "KinectTutorial4.vcxproj", "{04B88BA4-4BF9-4C46-BACF-28B896538A14}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Debug|Win32.Build.0 = Debug|Win32 14 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Release|Win32.ActiveCfg = Release|Win32 15 | {04B88BA4-4BF9-4C46-BACF-28B896538A14}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/KinectTutorial4.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {04B88BA4-4BF9-4C46-BACF-28B896538A14} 15 | KinectTutorial4 16 | 17 | 18 | 19 | Application 20 | true 21 | MultiByte 22 | 23 | 24 | Application 25 | false 26 | true 27 | MultiByte 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Level3 49 | Disabled 50 | 51 | 52 | true 53 | 54 | 55 | 56 | 57 | Level3 58 | MaxSpeed 59 | true 60 | true 61 | 62 | 63 | true 64 | true 65 | true 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/KinectTutorial4.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/SDL.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #include "main.h" 3 | 4 | bool init(int argc, char* argv[]) { 5 | SDL_Init(SDL_INIT_EVERYTHING); 6 | SDL_Surface* screen = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL); 7 | return screen; 8 | } 9 | void execute() { 10 | SDL_Event ev; 11 | bool running = true; 12 | while (running) { 13 | while (SDL_PollEvent(&ev)) { 14 | if (ev.type == SDL_QUIT) running = false; 15 | } 16 | drawKinectData(); 17 | SDL_GL_SwapBuffers(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/SDL_OpenGL.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | $(SDL_DIR)\include 9 | 10 | 11 | $(SDL_DIR)\lib\x86;%(AdditionalLibraryDirectories) 12 | SDL.lib;SDLmain.lib;opengl32.lib;glew32.lib;glu32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/glut.cpp: -------------------------------------------------------------------------------- 1 | #include "glut.h" 2 | #include "main.h" 3 | 4 | void draw() { 5 | drawKinectData(); 6 | glutSwapBuffers(); 7 | } 8 | 9 | void execute() { 10 | glutMainLoop(); 11 | } 12 | 13 | bool init(int argc, char* argv[]) { 14 | glutInit(&argc, argv); 15 | glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); 16 | glutInitWindowSize(width,height); 17 | glutCreateWindow("Kinect SDK Tutorial"); 18 | glutDisplayFunc(draw); 19 | glutIdleFunc(draw); 20 | glewInit(); 21 | return true; 22 | } 23 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/glut.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | bool init(int argc, char* argv[]); 9 | void draw(); 10 | void execute(); -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "glut.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | // OpenGL Variables 15 | long depthToRgbMap[width*height*2]; 16 | // We'll be using buffer objects to store the kinect point cloud 17 | GLuint vboId; 18 | GLuint cboId; 19 | 20 | // Kinect variables 21 | HANDLE depthStream; 22 | HANDLE rgbStream; 23 | INuiSensor* sensor; 24 | 25 | // Stores the coordinates of each joint 26 | Vector4 skeletonPosition[NUI_SKELETON_POSITION_COUNT]; 27 | 28 | bool initKinect() { 29 | // Get a working kinect sensor 30 | int numSensors; 31 | if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false; 32 | if (NuiCreateSensorByIndex(0, &sensor) < 0) return false; 33 | 34 | // Initialize sensor 35 | sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX | NUI_INITIALIZE_FLAG_USES_COLOR | NUI_INITIALIZE_FLAG_USES_SKELETON); 36 | sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX, // Depth camera or rgb camera? 37 | NUI_IMAGE_RESOLUTION_640x480, // Image resolution 38 | 0, // Image stream flags, e.g. near mode 39 | 2, // Number of frames to buffer 40 | NULL, // Event handle 41 | &depthStream); 42 | sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR, // Depth camera or rgb camera? 43 | NUI_IMAGE_RESOLUTION_640x480, // Image resolution 44 | 0, // Image stream flags, e.g. near mode 45 | 2, // Number of frames to buffer 46 | NULL, // Event handle 47 | &rgbStream); 48 | sensor->NuiSkeletonTrackingEnable(NULL, 0); // NUI_SKELETON_TRACKING_FLAG_ENABLE_SEATED_SUPPORT for only upper body 49 | return sensor; 50 | } 51 | 52 | void getDepthData(GLubyte* dest) { 53 | float* fdest = (float*) dest; 54 | long* depth2rgb = (long*) depthToRgbMap; 55 | NUI_IMAGE_FRAME imageFrame; 56 | NUI_LOCKED_RECT LockedRect; 57 | if (sensor->NuiImageStreamGetNextFrame(depthStream, 0, &imageFrame) < 0) return; 58 | INuiFrameTexture* texture = imageFrame.pFrameTexture; 59 | texture->LockRect(0, &LockedRect, NULL, 0); 60 | if (LockedRect.Pitch != 0) { 61 | const USHORT* curr = (const USHORT*) LockedRect.pBits; 62 | for (int j = 0; j < height; ++j) { 63 | for (int i = 0; i < width; ++i) { 64 | // Get depth of pixel in millimeters 65 | USHORT depth = NuiDepthPixelToDepth(*curr++); 66 | // Store coordinates of the point corresponding to this pixel 67 | Vector4 pos = NuiTransformDepthImageToSkeleton(i, j, depth<<3, NUI_IMAGE_RESOLUTION_640x480); 68 | *fdest++ = pos.x/pos.w; 69 | *fdest++ = pos.y/pos.w; 70 | *fdest++ = pos.z/pos.w; 71 | // Store the index into the color array corresponding to this pixel 72 | NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution( 73 | NUI_IMAGE_RESOLUTION_640x480, NUI_IMAGE_RESOLUTION_640x480, NULL, 74 | i, j, depth<<3, depth2rgb, depth2rgb+1); 75 | depth2rgb += 2; 76 | } 77 | } 78 | } 79 | texture->UnlockRect(0); 80 | sensor->NuiImageStreamReleaseFrame(depthStream, &imageFrame); 81 | } 82 | 83 | void getRgbData(GLubyte* dest) { 84 | float* fdest = (float*) dest; 85 | long* depth2rgb = (long*) depthToRgbMap; 86 | NUI_IMAGE_FRAME imageFrame; 87 | NUI_LOCKED_RECT LockedRect; 88 | if (sensor->NuiImageStreamGetNextFrame(rgbStream, 0, &imageFrame) < 0) return; 89 | INuiFrameTexture* texture = imageFrame.pFrameTexture; 90 | texture->LockRect(0, &LockedRect, NULL, 0); 91 | if (LockedRect.Pitch != 0) { 92 | const BYTE* start = (const BYTE*) LockedRect.pBits; 93 | for (int j = 0; j < height; ++j) { 94 | for (int i = 0; i < width; ++i) { 95 | // Determine rgb color for each depth pixel 96 | long x = *depth2rgb++; 97 | long y = *depth2rgb++; 98 | // If out of bounds, then don't color it at all 99 | if (x < 0 || y < 0 || x > width || y > height) { 100 | for (int n = 0; n < 3; ++n) *(fdest++) = 0.0f; 101 | } 102 | else { 103 | const BYTE* curr = start + (x + width*y)*4; 104 | for (int n = 0; n < 3; ++n) *(fdest++) = curr[2-n]/255.0f; 105 | } 106 | 107 | } 108 | } 109 | } 110 | texture->UnlockRect(0); 111 | sensor->NuiImageStreamReleaseFrame(rgbStream, &imageFrame); 112 | } 113 | 114 | void getSkeletalData() { 115 | NUI_SKELETON_FRAME skeletonFrame = {0}; 116 | if (sensor->NuiSkeletonGetNextFrame(0, &skeletonFrame) >= 0) { 117 | sensor->NuiTransformSmooth(&skeletonFrame, NULL); 118 | // Loop over all sensed skeletons 119 | for (int z = 0; z < NUI_SKELETON_COUNT; ++z) { 120 | const NUI_SKELETON_DATA& skeleton = skeletonFrame.SkeletonData[z]; 121 | // Check the state of the skeleton 122 | if (skeleton.eTrackingState == NUI_SKELETON_TRACKED) { 123 | // Copy the joint positions into our array 124 | for (int i = 0; i < NUI_SKELETON_POSITION_COUNT; ++i) { 125 | skeletonPosition[i] = skeleton.SkeletonPositions[i]; 126 | if (skeleton.eSkeletonPositionTrackingState[i] == NUI_SKELETON_POSITION_NOT_TRACKED) { 127 | skeletonPosition[i].w = 0; 128 | } 129 | } 130 | return; // Only take the data for one skeleton 131 | } 132 | } 133 | } 134 | } 135 | void getKinectData() { 136 | const int dataSize = width*height*3*4; 137 | GLubyte* ptr; 138 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 139 | ptr = (GLubyte*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 140 | if (ptr) { 141 | getDepthData(ptr); 142 | } 143 | glUnmapBuffer(GL_ARRAY_BUFFER); 144 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 145 | ptr = (GLubyte*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 146 | if (ptr) { 147 | getRgbData(ptr); 148 | } 149 | glUnmapBuffer(GL_ARRAY_BUFFER); 150 | getSkeletalData(); 151 | } 152 | 153 | void rotateCamera() { 154 | static double angle = 0.; 155 | static double radius = 3.; 156 | double x = radius*sin(angle); 157 | double z = radius*(1-cos(angle)) - radius/2; 158 | glMatrixMode(GL_MODELVIEW); 159 | glLoadIdentity(); 160 | gluLookAt(x,0,z,0,0,radius/2,0,1,0); 161 | angle += 0.05; 162 | } 163 | 164 | void drawKinectData() { 165 | getKinectData(); 166 | rotateCamera(); 167 | 168 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 169 | glEnableClientState(GL_VERTEX_ARRAY); 170 | glEnableClientState(GL_COLOR_ARRAY); 171 | 172 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 173 | glVertexPointer(3, GL_FLOAT, 0, NULL); 174 | 175 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 176 | glColorPointer(3, GL_FLOAT, 0, NULL); 177 | 178 | glPointSize(1.f); 179 | glDrawArrays(GL_POINTS, 0, width*height); 180 | 181 | glDisableClientState(GL_VERTEX_ARRAY); 182 | glDisableClientState(GL_COLOR_ARRAY); 183 | 184 | // Draw some arms 185 | const Vector4& lh = skeletonPosition[NUI_SKELETON_POSITION_HAND_LEFT]; 186 | const Vector4& le = skeletonPosition[NUI_SKELETON_POSITION_ELBOW_LEFT]; 187 | const Vector4& ls = skeletonPosition[NUI_SKELETON_POSITION_SHOULDER_LEFT]; 188 | const Vector4& rh = skeletonPosition[NUI_SKELETON_POSITION_HAND_RIGHT]; 189 | const Vector4& re = skeletonPosition[NUI_SKELETON_POSITION_ELBOW_RIGHT]; 190 | const Vector4& rs = skeletonPosition[NUI_SKELETON_POSITION_SHOULDER_RIGHT]; 191 | glBegin(GL_LINES); 192 | glColor3f(1.f, 0.f, 0.f); 193 | if (lh.w > 0 && le.w > 0 && ls.w > 0) { 194 | glVertex3f(lh.x, lh.y, lh.z); 195 | glVertex3f(le.x, le.y, le.z); 196 | glVertex3f(le.x, le.y, le.z); 197 | glVertex3f(ls.x, ls.y, ls.z); 198 | } 199 | if (rh.w > 0 && re.w > 0 && rs.w > 0) { 200 | glVertex3f(rh.x, rh.y, rh.z); 201 | glVertex3f(re.x, re.y, re.z); 202 | glVertex3f(re.x, re.y, re.z); 203 | glVertex3f(rs.x, rs.y, rs.z); 204 | } 205 | glEnd(); 206 | } 207 | 208 | int main(int argc, char* argv[]) { 209 | if (!init(argc, argv)) return 1; 210 | if (!initKinect()) return 1; 211 | 212 | // OpenGL setup 213 | glClearColor(0,0,0,0); 214 | glClearDepth(1.0f); 215 | 216 | // Set up array buffers 217 | const int dataSize = width*height * 3 * 4; 218 | glGenBuffers(1, &vboId); 219 | glBindBuffer(GL_ARRAY_BUFFER, vboId); 220 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 221 | glGenBuffers(1, &cboId); 222 | glBindBuffer(GL_ARRAY_BUFFER, cboId); 223 | glBufferData(GL_ARRAY_BUFFER, dataSize, 0, GL_DYNAMIC_DRAW); 224 | 225 | // Camera setup 226 | glViewport(0, 0, width, height); 227 | glMatrixMode(GL_PROJECTION); 228 | glLoadIdentity(); 229 | gluPerspective(45, width /(GLdouble) height, 0.1, 1000); 230 | glMatrixMode(GL_MODELVIEW); 231 | glLoadIdentity(); 232 | gluLookAt(0,0,0,0,0,1,0,1,0); 233 | 234 | // Main loop 235 | execute(); 236 | return 0; 237 | } 238 | -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | const int width = 640; 3 | const int height = 480; 4 | 5 | void drawKinectData(); -------------------------------------------------------------------------------- /KinectSDK/4_SkeletalTracking/sdl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | bool init(int argc, char* argv[]); 6 | void execute(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Tutorials 2 | ========= 3 | 4 | Code for a couple of tutorials for Kinect C++ SDK, both v1 (structured light 5 | sensor used in XBox 360) and v2 (time of flight sensor used in XBox One). 6 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-apollo.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-apollo.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-clj.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 Google Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | var a=null; 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/,a], 18 | ["typ",/^:[\dA-Za-z-]+/]]),["clj"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-go.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-go.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-hs.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t-\r ]+/,null,"\t\n \r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^\n\f\r'\\]|\\[^&])'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:--+[^\n\f\r]*|{-(?:[^-]|-+[^}-])*-})/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^\d'A-Za-z]|$)/, 2 | null],["pln",/^(?:[A-Z][\w']*\.)*[A-Za-z][\w']*/],["pun",/^[^\d\t-\r "'A-Za-z]+/]]),["hs"]); 3 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-lisp.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \xa0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/,a], 3 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","scm"]); 4 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-lua.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-lua.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-ml.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-ml.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-n.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:'(?:[^\n\r'\\]|\\.)*'|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,a,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,a,"#"],["pln",/^\s+/,a," \r\n\t\xa0"]],[["str",/^@"(?:[^"]|"")*(?:"|$)/,a],["str",/^<#[^#>]*(?:#>|$)/,a],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,a],["com",/^\/\/[^\n\r]*/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/, 3 | a],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/, 4 | a],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,a],["lit",/^@[$_a-z][\w$@]*/i,a],["typ",/^@[A-Z]+[a-z][\w$@]*/,a],["pln",/^'?[$_a-z][\w$@]*/i,a],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,a,"0123456789"],["pun",/^.[^\s\w"-$'./@`]*/,a]]),["n","nemerle"]); 5 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-proto.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]); 2 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-scala.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-scala.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-sql.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-sql.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-tex.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-tex.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-vb.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-vb.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-vhdl.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-vhdl.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-wiki.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/google-code-prettify/lang-wiki.js -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-yaml.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^\w+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]); 3 | -------------------------------------------------------------------------------- /docs/google-code-prettify/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} -------------------------------------------------------------------------------- /docs/images/kinectv1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/images/kinectv1.png -------------------------------------------------------------------------------- /docs/images/kinectv2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/images/kinectv2.jpg -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tutorials 5 | 6 | 7 | 21 | 22 | 23 | 29 |
30 |

Tutorials

31 |

Kinect v1 C++ SDK Basics

32 | 33 | 34 | 46 | 49 | 50 |
35 | Minimal tutorials on how to use a Kinect in C++, with OpenGL (GLUT or SDL). 36 | These tutorials are for the v1.8 SDK, which is compatible with the structured 37 | light Kinect sensors: The XBox 360 Kinect and the Kinect for Windows. 38 | 45 | 47 | 48 |
51 |

Kinect v2 C++ SDK Basics

52 | 53 | 54 | 66 | 69 | 70 |
55 | Minimal tutorials on how to use a Kinect in C++, with OpenGL (GLUT or SDL). 56 | These tutorials are for the v2 SDK, which is compatible with the time-of-flight 57 | Kinect sensor, i.e. the XBox One Kinect. 58 | 65 | 67 | 68 |
71 |
72 |

About

73 | While playing with various device APIs, I found that many of 74 | the tools I was using were poorly supported. As a reference, I wrote 75 | up a set of tutorials. My guiding principle is focus. 76 |
    77 |
  • 78 | Explanation only where necessary - I will take 79 | time to explain the stuff the tutorial is on - how to use the API in 80 | question. However, I will only give a high-level overview of the 81 | remaining code, for windowing and display. 82 | If you want to learn more about e.g. 83 | OpenGL or C++, there are plenty of tutorials that will focus on 84 | those aspects. I won't confuse you by trying to teach you three APIs 85 | and a language simultaneously. 86 |
  • 87 |
  • 88 | Concise code - I'll have exactly enough code to make it 89 | work, and little else. I will sacrifice a bit of structure just to 90 | save you the trouble of sorting through twice as many header files, 91 | so that you can focus on the relevant functionality. 92 |
  • 93 |
94 |
95 | 96 | 97 | -------------------------------------------------------------------------------- /docs/kinect/1_Basics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/1_Basics.zip -------------------------------------------------------------------------------- /docs/kinect/2_Depth.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/2_Depth.zip -------------------------------------------------------------------------------- /docs/kinect/3_PointCloud.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/3_PointCloud.zip -------------------------------------------------------------------------------- /docs/kinect/4_SkeletalTracking.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/4_SkeletalTracking.zip -------------------------------------------------------------------------------- /docs/kinect/images/0_0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/0_0.jpg -------------------------------------------------------------------------------- /docs/kinect/images/0_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/0_1.jpg -------------------------------------------------------------------------------- /docs/kinect/images/0_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/0_2.jpg -------------------------------------------------------------------------------- /docs/kinect/images/0_2_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/0_2_2.jpg -------------------------------------------------------------------------------- /docs/kinect/images/0_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/0_3.jpg -------------------------------------------------------------------------------- /docs/kinect/images/kinect3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/kinect3.gif -------------------------------------------------------------------------------- /docs/kinect/images/kinect3_registered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/kinect3_registered.png -------------------------------------------------------------------------------- /docs/kinect/images/kinect3_unregistered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect/images/kinect3_unregistered.png -------------------------------------------------------------------------------- /docs/kinect/kinect0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Kinect SDK C++ Tutorials - 0. Setup 5 | 6 | 7 | 8 | 15 | 16 | 17 | 23 |
24 |

Kinect v1 SDK C++ - 0. Setup

25 |
26 | 27 | 28 | 31 | 34 | 35 |
29 | 30 | 32 | Have a Kinect v2? Head over to the Kinect v2 Tutorial 0. This tutorial is for the v1 Kinect SDK. 33 |
36 |
37 | This series of tutorials is intended for C++ programmers who want to use Microsoft's Kinect SDK. 38 | There will be as little Windows code as possible. We will be using OpenGL for graphics. 39 |

40 | Goals: Ensure you have the necessary components for coding with Kinect. Set up a Visual Studio 41 | project with the proper build configurations.
42 | Source: 1_Basics.zip 43 |

44 | Prerequisites:

    45 |
  • Windows (this is the Windows SDK, after all)
  • 46 |
  • A Kinect (preferably Kinect for PC)
  • 47 |
  • Visual Studio (some recent version)
  • 48 |
  • Experience with C
  • 49 |
  • Familiarity (or willingness to learn) OpenGL
  • 50 |
51 | 52 | This tutorial will be compatible with both GLUT and SDL.
53 | 54 | Click here for SDL Version of 0. Setup 55 | 56 |
57 |

Installing GLUT

58 | Most windows systems do not come with GLUT. GLUT is an old but widely 59 | used system for windowing and handling events that is commonly used with 60 | OpenGL. 61 |
    62 |
  1. Download and unzip the MSVC freeglut binaries from http://www.transmissionzero.co.uk/software/freeglut-devel/
  2. 63 |
  3. Copy the contents of the Include/ and Lib/ directories you just 64 | unzipped into the appropriate Windows SDK directories. e.g. 65 |
      66 |
    • C:/Program Files/Microsoft SDKs/Windows/v7.0A/Include/ and 67 | C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib/ for Visual Studio 2010
    • 68 |
    • C:/Program Files/Windows Kits (x86)/8.1/Include/um/ and 69 | C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/ for Visual Studio 2012+
    • 70 |
    71 |
  4. 72 |
  5. Copy bin/x64/freeglut.dll into C:/Windows/System32 and bin/x86/freeglut.dll into C:/Windows/SysWOW64. If 73 | you have a 32-bit system, just move bin/x86/freeglut.dll into C:/Windows/System32
  6. 74 |
75 |

Creating a Kinect Project

76 | Open up Visual Studio and start a new Empty Project. Click 77 | File > New > Project...; then select C++ > General > Empty Project. 78 | Name it appropriately.

79 |

80 | To configure the build rules (i.e. includes and libs) we will use the Property Manager. This will 81 | allow us to save the configurations to separate files so that we can use them again later.

82 |

83 | Go to View > Property Manager. This will open up 84 | a pane in one of the subwindows in Visual Studio containing build 85 | rules. 86 |

87 |

88 | In the Property Manager, right click on the project name and select Add New Project Property Sheet; name it "OpenGL". Create another one named "KinectSDK". 89 | You should see several new items appear under "Debug" and "Release" 90 | with the names of your new Property Sheets. Property Sheets are files 91 | (extension .props) that contain build configuration data. For 92 | modularity, we will create one for our OpenGL info and one for our 93 | Kinect SDK info. 94 |

95 |

96 | Right-click the Kinect Property Sheet and click Properties. 97 |

    98 |
  • Under C/C++ > Additional Include Directories, add "$(KINECTSDK10_DIR)/include".
  • 99 |
  • Under Linker > Additional Library Directories, add "$(KINECTSDK10_DIR)/lib/x64" (or /x86 for 32-bit systems).
  • 100 |
  • Under Linker > Input > Additional Dependencies, add "kinect10.lib".
  • 101 |
102 | 103 | Note that to add Include and Library Directories, you can either just 104 | type into the box, or you can click the dropdown, select <Edit>, 105 | and enter the location in the resulting dialog. This method lets you 106 | manage multiple directories easily, as well as lets you browse for the 107 | exact directory (if you don't use environment variables like 108 | KINECTSDK10_DIR) 109 |

110 |

111 | Right-click the OpenGL Property Sheet and click Properties. Under Linker > Input > Additional Dependencies, add the following: 112 |

113 | opengl32.lib
114 | glu32.lib
115 | freeglut.lib
116 |         
117 |

118 | 119 |
120 |
121 | That's it for now - you have a project that is ready for some code. 122 |
123 |

124 | Next: Kinect Basics 125 |

126 |
127 | 128 | 129 | -------------------------------------------------------------------------------- /docs/kinect/kinect0_sdl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Kinect SDK C++ Tutorials - 0. Setup 5 | 6 | 7 | 8 | 15 | 16 | 17 | 23 |
24 |

Kinect v1 SDK C++ - 0. Setup

25 |
26 | 27 | 28 | 31 | 34 | 35 |
29 | 30 | 32 | Have a Kinect v2? Head over to the Kinect v2 Tutorial 0. This tutorial is for the v1 Kinect SDK. 33 |
36 |
37 | This series of tutorials is intended for C++ programmers who want to use Microsoft's Kinect SDK. 38 | There will be as little Windows code as possible. We will be using OpenGL for graphics. 39 |

40 | Goals: Ensure you have the necessary components for coding with Kinect. Set up a Visual Studio 41 | project with the proper build configurations.
42 | Source: View Source      Download: 1_Basics.zip 43 |

44 | Prerequisites:

    45 |
  • Windows (this is the Windows SDK, after all)
  • 46 |
  • A Kinect (preferably Kinect for PC)
  • 47 |
  • Visual Studio (some recent version)
  • 48 |
  • Experience with C
  • 49 |
  • Familiarity (or willingness to learn) OpenGL
  • 50 |
51 | 52 | This tutorial will be compatible with both GLUT and SDL.
53 | 54 | Click here for the GLUT Version of 0. Setup 55 | 56 |
57 |

Installing SDL

58 |

59 | Download the latest version of the Visual C++ SDL Development Libraries 60 | from libsdl.org; at the time of 61 | writing this was version 1.2.15 62 |

63 |

64 | Unzip the contents to a suitable place (e.g. C:\). 65 |

66 | To make our lives easier we will do two things: 67 |
    68 |
  1. Copy the SDL.dll file to our system directory. Go to 69 | C:\SDL-1.2.15\lib\x86 (or the equivalent) and copy SDL.dll. Paste 70 | it into C:\Windows\SysWOW64 if that folder exists (i.e. you have 71 | a 64-bit version of Windows). Otherwise, paste it into 72 | C:\Windows\System32
  2. 73 |
  3. Add the SDL folder as an environment variable. 74 | Open up the start menu, right click Computer, and select 75 | Properties. Click "Advanced System Settings" on the left 76 | side, go to the Advanced tab in the resulting dialog, and click 77 | the button labelled "Environment Variables". 78 |
    79 | Under User variables (the top set of buttons) click "New...". 80 | Enter "SDL_DIR" (no quotes) for the variable name and the 81 | path to the SDL directory (e.g. "C:\SDL-1.2.15") as the value. 82 |
  4. 83 |
84 | 85 |
86 |

Creating a Kinect Project

87 | Open up Visual Studio and start a new Empty Project. Click 88 | File > New > Project...; then select C++ > General > Empty Project. 89 | Name it appropriately.

90 |

91 | To configure the build rules (i.e. includes and libs) we will use the Property Manager. This will 92 | allow us to save the configurations to separate files so that we can use them again later.

93 |

94 | Go to View > Property Manager. This will open up 95 | a pane in one of the subwindows in Visual Studio containing build 96 | rules. 97 |

98 |

99 | In the Property Manager, right click on the project name and select Add New Project Property Sheet; name it "OpenGL". Create another one named "KinectSDK". 100 | You should see several new items appear under "Debug" and "Release" 101 | with the names of your new Property Sheets. Property Sheets are files 102 | (extension .props) that contain build configuration data. For 103 | modularity, we will create one for our OpenGL info and one for our 104 | Kinect SDK info. 105 |

106 |

107 | Right-click the Kinect Property Sheet and click Properties. 108 |

    109 |
  • Under C/C++ > Additional Include Directories, add "$(KINECTSDK10_DIR)/include".
  • 110 |
  • Under Linker > Additional Library Directories, add "$(KINECTSDK10_DIR)/lib/x64" (or /x86 for 32-bit systems).
  • 111 |
  • Under Linker > Input > Additional Dependencies, add "kinect10.lib".
  • 112 |
113 | 114 | Note that to add Include and Library Directories, you can either just 115 | type into the box, or you can click the dropdown, select <Edit>, 116 | and enter the location in the resulting dialog. This method lets you 117 | manage multiple directories easily, as well as lets you browse for the 118 | exact directory (if you don't use environment variables like 119 | KINECTSDK10_DIR) 120 |

121 |

122 | Right-click the OpenGL Property Sheet and click Properties. Under Linker > Input > Additional Dependencies, add the following: 123 |

    124 |
  • Under C/C++ > Additional Include Directories, add "$(SDL_DIR)\include".
  • 125 |
  • Under Linker > Additional Library Directories, add "$(SDL_DIR)\lib\x86".
  • 126 |
  • Under Linker > Input > Additional Dependencies, add the following:
  • 127 |
128 |
129 | opengl32.lib
130 | glu32.lib
131 | SDL.lib
132 | SDLmain.lib
133 |         
134 |

135 | 136 |
137 |
138 | That's it for now - you have a project that is ready for some code. 139 |
140 |

141 | Next: Kinect Basics 142 |

143 |
144 | 145 | 146 | -------------------------------------------------------------------------------- /docs/kinect/kinect2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Kinect SDK C++ Tutorials - 2. Depth Images 5 | 6 | 7 | 8 | 9 | 10 | 11 | 17 |
18 |

Kinect v1 SDK C++ - 2. Kinect Depth Data

19 |
20 | 21 | 22 | 25 | 28 | 29 |
23 | 24 | 26 | Have a Kinect v2? Head over to the Kinect v2 Tutorial 2. This tutorial is for the v1 Kinect SDK. 27 |
30 |
31 |

32 | Goals: Learn how to get depth data from a kinect and what 33 | the format of the data is.
34 | Source: View Source      Download: 2_Depth.zip 35 | 36 |


37 |

Overview

38 | This is a very short tutorial - there are only two real changes to the 39 | RGB code.

I have also refactored the SDL and Glut components into 40 | separate files to focus more on the Kinect specifics. 41 |
42 |

Contents

43 |
    44 |
  1. Kinect Code
  2. 45 |
  3. Display Frameworks
  4. 46 |
47 |
48 |

Kinect Code

49 |

Kinect Initialization

50 | To get the depth data from the kinect, simply change the arguments 51 | to NuiImageStreamOpen(). The first argument is now 52 | NUI_IMAGE_TYPE_DEPTH, telling the Kinect that we now 53 | want depth images instead of RGB images. (For clarity we also changed 54 | the name of the Handle to reflect this) 55 |

56 | When you're using the Kinect for Windows sensor (as opposed to the XBox 57 | Kinect) you can also enable Near Mode. Near Mode allows the Kinect to 58 | be more sensitive to closer objects (say from 50cm to 200cm), whereas 59 | without near mode it is sensitive from 80cm to 400cm.

60 | To enable near mode, pass in the flag NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE as the third argument. 61 |

 62 | // NEW VARIABLE
 63 | HANDLE depthStream;
 64 | 
 65 | bool initKinect() {
 66 |     // Get a working kinect sensor
 67 |     int numSensors;
 68 |     if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1) return false;
 69 |     if (NuiCreateSensorByIndex(0, &sensor) < 0) return false;
 70 | 
 71 |     // Initialize sensor
 72 |     sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR);
 73 | 
 74 |         // --------------- START CHANGED CODE -----------------
 75 |     sensor->NuiImageStreamOpen(
 76 |         NUI_IMAGE_TYPE_DEPTH,                     // Depth camera or rgb camera?
 77 |         NUI_IMAGE_RESOLUTION_640x480,             // Image resolution
 78 |         NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE,   // Image stream flags, e.g. near mode
 79 |         2,      // Number of frames to buffer
 80 |         NULL,   // Event handle
 81 |         &depthStream);
 82 |         // --------------- END CHANGED CODE -----------------
 83 |     return sensor;
 84 | }
 85 |         
86 | For more information about near mode, see this official blog post. 87 |

Getting a depth frame from the Kinect

88 | We'll display the depth image from the kinect in grayscale. Each pixel 89 | will just be the pixel's distance from the kinect (in millimeters) mod 90 | 256.

91 | The only thing to note here is the NuiDepthPixelToDepth 92 | function - each pixel in the actual depth map has both depth information 93 | and player information (i.e. which player can be associated with that 94 | pixel). Calling this function returns the depth in millimeters at that 95 | pixel. 96 |

The depth data is 16 bits, so we use a USHORT to read it in. 97 |

 98 |         const USHORT* curr = (const USHORT*) LockedRect.pBits;
 99 |         const USHORT* dataEnd = curr + (width*height);
100 | 
101 |         while (curr < dataEnd) {
102 |             // Get depth in millimeters
103 |             USHORT depth = NuiDepthPixelToDepth(*curr++);
104 | 
105 |             // Draw a grayscale image of the depth:
106 |             // B,G,R are all set to depth%256, alpha set to 1.
107 |             for (int i = 0; i < 3; ++i)
108 |                 *dest++ = (BYTE) depth%256;
109 |             *dest++ = 0xff;
110 |         }
111 | 
112 |         
113 |
114 | That's all the Kinect code! The rest is just how to get it onscreen. 115 |
116 |

Display Frameworks

117 | I refactored the code so that the glut and SDL specifics are bundled 118 | up into an init() function, a draw() function, 119 | and an execute() function. 120 |

To use one or the other, simply 121 | change the include at the top of main.cpp to use either 122 | sdl.h or glut.h. Make sure you have the 123 | appropriate includes and links in the Project Properties! 124 |


125 | The End! Build and run, making sure that your Kinect is plugged in. 126 | You should see a window containing a video stream of what your Kinect 127 | sees, in grayscale. 128 |
129 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /docs/kinect2/1_Basics.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/1_Basics.zip -------------------------------------------------------------------------------- /docs/kinect2/2_Depth.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/2_Depth.zip -------------------------------------------------------------------------------- /docs/kinect2/3_PointCloud.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/3_PointCloud.zip -------------------------------------------------------------------------------- /docs/kinect2/4_SkeletalTracking.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/4_SkeletalTracking.zip -------------------------------------------------------------------------------- /docs/kinect2/images/0_0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/0_0.jpg -------------------------------------------------------------------------------- /docs/kinect2/images/0_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/0_1.jpg -------------------------------------------------------------------------------- /docs/kinect2/images/0_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/0_2.jpg -------------------------------------------------------------------------------- /docs/kinect2/images/0_2_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/0_2_2.jpg -------------------------------------------------------------------------------- /docs/kinect2/images/0_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/0_3.jpg -------------------------------------------------------------------------------- /docs/kinect2/images/kinect3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/kinect3.gif -------------------------------------------------------------------------------- /docs/kinect2/images/kinect3_registered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/kinect3_registered.png -------------------------------------------------------------------------------- /docs/kinect2/images/kinect3_unregistered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyzyx/Tutorials/4552f7ab63c023bccc5ba6f9dcc8959779b588af/docs/kinect2/images/kinect3_unregistered.png -------------------------------------------------------------------------------- /docs/kinect2/kinect0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Kinect SDK C++ Tutorials - 0. Setup 5 | 6 | 7 | 8 | 15 | 16 | 17 | 23 |
24 |

Kinect v2 SDK C++ - 0. Setup

25 | This series of tutorials is intended for C++ programmers who want to use Microsoft's Kinect SDK. 26 | There will be as little Windows code as possible. We will be using OpenGL for graphics. 27 |

28 | Goals: Ensure you have the necessary components for coding with Kinect. Set up a Visual Studio 29 | project with the proper build configurations.
30 | Source: 1_Basics.zip 31 |

32 | Prerequisites:

    33 |
  • Windows (this is the Windows SDK, after all)
  • 34 |
  • A Kinect (preferably Kinect for PC)
  • 35 |
  • Visual Studio (some recent version)
  • 36 |
  • Experience with C
  • 37 |
  • Familiarity (or willingness to learn) OpenGL
  • 38 |
39 | 40 | This tutorial will be compatible with both GLUT and SDL.
41 | 42 | Click here for SDL Version of 0. Setup 43 | 44 |
45 |

Installing GLUT

46 | Most windows systems do not come with GLUT. GLUT is an old but widely 47 | used system for windowing and handling events that is commonly used with 48 | OpenGL. 49 |
    50 |
  1. Download and unzip the MSVC freeglut binaries from http://www.transmissionzero.co.uk/software/freeglut-devel/
  2. 51 |
  3. Copy the contents of the Include/ and Lib/ directories you just 52 | unzipped into the appropriate Windows SDK directories. e.g. 53 |
      54 |
    • C:/Program Files/Microsoft SDKs/Windows/v7.0A/Include/ and 55 | C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib/ for Visual Studio 2010
    • 56 |
    • C:/Program Files/Windows Kits (x86)/8.1/Include/um/ and 57 | C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/ for Visual Studio 2012+
    • 58 |
    59 |
  4. 60 |
  5. Copy bin/x64/freeglut.dll into C:/Windows/System32 and bin/x86/freeglut.dll into C:/Windows/SysWOW64. If 61 | you have a 32-bit system, just move bin/x86/freeglut.dll into C:/Windows/System32
  6. 62 |
63 |

Creating a Kinect Project

64 | Open up Visual Studio and start a new Empty Project. Click 65 | File > New > Project...; then select C++ > General > Empty Project. 66 | Name it appropriately.

67 |

68 | To configure the build rules (i.e. includes and libs) we will use the Property Manager. This will 69 | allow us to save the configurations to separate files so that we can use them again later.

70 |

71 | Go to View > Property Manager. This will open up 72 | a pane in one of the subwindows in Visual Studio containing build 73 | rules. 74 |

75 |

76 | In the Property Manager, right click on the project name and select Add New Project Property Sheet; name it "OpenGL". Create another one named "KinectSDK". 77 | You should see several new items appear under "Debug" and "Release" 78 | with the names of your new Property Sheets. Property Sheets are files 79 | (extension .props) that contain build configuration data. For 80 | modularity, we will create one for our OpenGL info and one for our 81 | Kinect SDK info. 82 |

83 |

84 | Right-click the Kinect Property Sheet and click Properties. 85 |

    86 |
  • Under C/C++ > Additional Include Directories, add "$(KINECTSDK20_DIR)/include".
  • 87 |
  • Under Linker > Additional Library Directories, add "$(KINECTSDK20_DIR)/lib/x64" (or /x86 for 32-bit systems).
  • 88 |
  • Under Linker > Input > Additional Dependencies, add "kinect20.lib".
  • 89 |
90 | 91 | Note that to add Include and Library Directories, you can either just 92 | type into the box, or you can click the dropdown, select <Edit>, 93 | and enter the location in the resulting dialog. This method lets you 94 | manage multiple directories easily, as well as lets you browse for the 95 | exact directory (if you don't use environment variables like 96 | KINECTSDK20_DIR) 97 |

98 |

99 | Right-click the OpenGL Property Sheet and click Properties. Under Linker > Input > Additional Dependencies, add the following: 100 |

101 | opengl32.lib
102 | glu32.lib
103 | freeglut.lib
104 |         
105 |

106 | 107 |
108 |
109 | That's it for now - you have a project that is ready for some code. 110 |
111 |

112 | Next: Kinect Basics 113 |

114 |
115 | 116 | 117 | -------------------------------------------------------------------------------- /docs/kinect2/kinect0_sdl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Kinect SDK C++ Tutorials - 0. Setup 5 | 6 | 7 | 8 | 15 | 16 | 17 | 23 |
24 |

Kinect v2 SDK C++ - 0. Setup

25 | This series of tutorials is intended for C++ programmers who want to use Microsoft's Kinect SDK. 26 | There will be as little Windows code as possible. We will be using OpenGL for graphics. 27 |

28 | Goals: Ensure you have the necessary components for coding with Kinect. Set up a Visual Studio 29 | project with the proper build configurations.
30 | Source: View Source      Download: 1_Basics.zip 31 |

32 | Prerequisites:

    33 |
  • Windows (this is the Windows SDK, after all)
  • 34 |
  • A Kinect (preferably Kinect for PC)
  • 35 |
  • Visual Studio (some recent version)
  • 36 |
  • Experience with C
  • 37 |
  • Familiarity (or willingness to learn) OpenGL
  • 38 |
39 | 40 | This tutorial will be compatible with both GLUT and SDL.
41 | 42 | Click here for the GLUT Version of 0. Setup 43 | 44 |
45 |

Installing SDL

46 |

47 | Download the latest version of the Visual C++ SDL Development Libraries 48 | from libsdl.org; at the time of 49 | writing this was version 1.2.15 50 |

51 |

52 | Unzip the contents to a suitable place (e.g. C:\). 53 |

54 | To make our lives easier we will do two things: 55 |
    56 |
  1. Copy the SDL.dll file to our system directory. Go to 57 | C:\SDL-1.2.15\lib\x86 (or the equivalent) and copy SDL.dll. Paste 58 | it into C:\Windows\SysWOW64 if that folder exists (i.e. you have 59 | a 64-bit version of Windows). Otherwise, paste it into 60 | C:\Windows\System32
  2. 61 |
  3. Add the SDL folder as an environment variable. 62 | Open up the start menu, right click Computer, and select 63 | Properties. Click "Advanced System Settings" on the left 64 | side, go to the Advanced tab in the resulting dialog, and click 65 | the button labelled "Environment Variables". 66 |
    67 | Under User variables (the top set of buttons) click "New...". 68 | Enter "SDL_DIR" (no quotes) for the variable name and the 69 | path to the SDL directory (e.g. "C:\SDL-1.2.15") as the value. 70 |
  4. 71 |
72 | 73 |
74 |

Creating a Kinect Project

75 | Open up Visual Studio and start a new Empty Project. Click 76 | File > New > Project...; then select C++ > General > Empty Project. 77 | Name it appropriately.

78 |

79 | To configure the build rules (i.e. includes and libs) we will use the Property Manager. This will 80 | allow us to save the configurations to separate files so that we can use them again later.

81 |

82 | Go to View > Property Manager. This will open up 83 | a pane in one of the subwindows in Visual Studio containing build 84 | rules. 85 |

86 |

87 | In the Property Manager, right click on the project name and select Add New Project Property Sheet; name it "OpenGL". Create another one named "KinectSDK". 88 | You should see several new items appear under "Debug" and "Release" 89 | with the names of your new Property Sheets. Property Sheets are files 90 | (extension .props) that contain build configuration data. For 91 | modularity, we will create one for our OpenGL info and one for our 92 | Kinect SDK info. 93 |

94 |

95 | Right-click the Kinect Property Sheet and click Properties. 96 |

    97 |
  • Under C/C++ > Additional Include Directories, add "$(KINECTSDK20_DIR)/include".
  • 98 |
  • Under Linker > Additional Library Directories, add "$(KINECTSDK20_DIR)/lib/x64" (or /x86 for 32-bit systems).
  • 99 |
  • Under Linker > Input > Additional Dependencies, add "kinect20.lib".
  • 100 |
101 | 102 | Note that to add Include and Library Directories, you can either just 103 | type into the box, or you can click the dropdown, select <Edit>, 104 | and enter the location in the resulting dialog. This method lets you 105 | manage multiple directories easily, as well as lets you browse for the 106 | exact directory (if you don't use environment variables like 107 | KINECTSDK20_DIR) 108 |

109 |

110 | Right-click the OpenGL Property Sheet and click Properties. Under Linker > Input > Additional Dependencies, add the following: 111 |

    112 |
  • Under C/C++ > Additional Include Directories, add "$(SDL_DIR)\include".
  • 113 |
  • Under Linker > Additional Library Directories, add "$(SDL_DIR)\lib\x86".
  • 114 |
  • Under Linker > Input > Additional Dependencies, add the following:
  • 115 |
116 |
117 | opengl32.lib
118 | glu32.lib
119 | SDL.lib
120 | SDLmain.lib
121 |         
122 |

123 | 124 |
125 |
126 | That's it for now - you have a project that is ready for some code. 127 |
128 |

129 | Next: Kinect Basics 130 |

131 |
132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/kinect2/kinect2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Kinect SDK C++ Tutorials - 2. Depth Images 5 | 6 | 7 | 8 | 9 | 10 | 11 | 17 |
18 |

Kinect v2 SDK C++ - 2. Kinect Depth Data

19 |

20 | Goals: Learn how to get depth data from a kinect and what 21 | the format of the data is.
22 | Source: View Source      Download: 2_Depth.zip 23 | 24 |


25 |

Overview

26 | This is a very short tutorial - there are only two real changes to the 27 | RGB code.

I have also refactored the SDL and Glut components into 28 | separate files to focus more on the Kinect specifics. 29 |
30 |

Contents

31 |
    32 |
  1. Kinect Code
  2. 33 |
  3. Display Frameworks
  4. 34 |
35 |
36 |

Kinect Code

37 |

Kinect Initialization

38 | To get the depth data from the kinect, simply change the types of the 39 | framesource, framereader, and frame. Note also that the resolution of 40 | the depth camera is different from that of the color camera: 512*424 41 | instead of 1920*1080. 42 |
 43 | IDepthFrameReader* reader;     // Kinect depth data source
 44 | 
 45 | bool initKinect() {
 46 |     if (FAILED(GetDefaultKinectSensor(&sensor))) {
 47 |         return false;
 48 |     }
 49 |     if (sensor) {
 50 |         sensor->Open();
 51 |         IDepthFrameSource* framesource = NULL;
 52 |         sensor->get_DepthFrameSource(&framesource);
 53 |         framesource->OpenReader(&reader);
 54 |         if (framesource) {
 55 |             framesource->Release();
 56 |             framesource = NULL;
 57 |         }
 58 |         return true;
 59 |     } else {
 60 |         return false;
 61 |     }
 62 | }
 63 |         
64 |

Getting a depth frame from the Kinect

65 | We'll display the depth image from the kinect in grayscale. Each pixel 66 | will just be the pixel's distance from the kinect (in millimeters) mod 67 | 256.

68 |

 69 | void getKinectData(GLubyte* dest) {
 70 |     IDepthFrame* frame = NULL;
 71 |     if (SUCCEEDED(reader->AcquireLatestFrame(&frame))) {
 72 |         unsigned int sz;
 73 |         unsigned short* buf;
 74 |         frame->AccessUnderlyingBuffer(&sz, &buf);
 75 | 
 76 |         const unsigned short* curr = (const unsigned short*)buf;
 77 |         const unsigned short* dataEnd = curr + (width*height);
 78 | 
 79 |         while (curr < dataEnd) {
 80 |             // Get depth in millimeters
 81 |             unsigned short depth = (*curr++);
 82 | 
 83 |             // Draw a grayscale image of the depth:
 84 |             // B,G,R are all set to depth%256, alpha set to 1.
 85 |             for (int i = 0; i < 3; ++i)
 86 |                 *dest++ = (BYTE)depth % 256;
 87 |             *dest++ = 0xff;
 88 |         }
 89 |     }
 90 |     if (frame) frame->Release();
 91 | }
 92 |         
93 | Note that, unlike with the color frame, we just want to access the raw 94 | data from the frame. To do this, we use frame->AccessUnderlyingBuffer 95 | to get a pointer to the data. 96 |
97 | Then we convert the depth data and write it to our image array. 98 |
99 | That's all the Kinect code! The rest is just how to get it onscreen. 100 |
101 |

Display Frameworks

102 | I refactored the code so that the glut and SDL specifics are bundled 103 | up into an init() function, a draw() function, 104 | and an execute() function. 105 |

To use one or the other, simply 106 | change the include at the top of main.cpp to use either 107 | sdl.h or glut.h. Make sure you have the 108 | appropriate includes and links in the Project Properties! 109 |


110 | The End! Build and run, making sure that your Kinect is plugged in. 111 | You should see a window containing a video stream of what your Kinect 112 | sees, in grayscale. 113 |
114 |
130 | Previous: Basics 131 | 132 |

133 | Next: Kinect Point Cloud 134 |

135 |
121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /docs/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #69ca6f; 3 | } 4 | 5 | #content { 6 | position: relative; 7 | width: 61.8%; 8 | left: 19.6%; 9 | display: block; 10 | background-color: #ffffff; 11 | margin: 15px; 12 | padding: 15px; 13 | } 14 | 15 | #navbarcontainer { 16 | width: 100%; 17 | background-color: #35963c; 18 | } 19 | #navbar { 20 | list-style-type: none; 21 | margin: 0; 22 | padding: 0; 23 | overflow: hidden; 24 | } 25 | li.navitem { 26 | float: left; 27 | } 28 | a.nav:link, a.nav:visited { 29 | display: block; 30 | width: 140px; 31 | font-weight: bold; 32 | color: #FFFFFF; 33 | background-color: #35963c; 34 | text-align: center; 35 | padding: 4px; 36 | text-decoration: none; 37 | } 38 | a.nav:hover, a.nav:active { 39 | background-color: #116117; 40 | } 41 | img.screenshot { 42 | width: 50%; 43 | } 44 | div.boxedmessage { 45 | border-style: solid; 46 | border-width: 2px; 47 | margin: 20px; 48 | } 49 | --------------------------------------------------------------------------------
115 | Previous: Basics 116 | 117 |

118 | Next: Kinect Point Cloud 119 |

120 |