File Exchange

image thumbnail

Kinect 2 Interface for Matlab

version 3.2.2.0 (1.5 MB) by Juan R. Terven
Kin2 Toolbox

12 Downloads

Updated 05 Jul 2017

View Version History

GitHub view license on GitHub

C++ wrapper functions for the Microsoft Kinect 2, using Microsoft SDK.
Requirements:
- Kinect2 SDK. http://www.microsoft.com/en-us/download/details.aspx?id=44561
- Visual Studio 2012 or newer compiler
- MATLAB 2013a or newer (for Visual Studio 2012 support)
- MATLAB 2015b or newer for pointCloudDemo2, which uses MATLAB's built-in pointCloud object
Usage:
1) Set the compiler using mex -setup C++
2) Open compile_cpp_files and set the include and lib paths of Kinect2 SDK (see the provided paths)
3) Add to the windows path the bin directory containing the Kinect20.Fusion.dll and Kinect20.Face.dll
For example: C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin
4) If you modify Windows path, close Matlab and open it again in order to detect the changes.
3) Run compile_cpp_files.m
Demos:
1) videoDemo.m: displays depth, color, and infrared video.
2) mappingDemo.m: displays depth and color video, and allows to map points from one image to the other (See usage comments at the beginning of the script).
3) mapping2CamDemo.m: displays depth and color and allows to map points from depth and color to camera space and viceversa.
4) bodyDemo.m: displays depth and color and the skeleton on both images
5) pointCloudDemo.m: displays depth and a colored point cloud on a scatter3
6) pointCloudDemo2.m displays depth and a colored point cloud using MATLAB's built-in pointCloud object and pcshow.
7) bodyIndexDemo.m: displays body index frames
8) faceDemo.m: detect and track faces showing the facial landmarks and face properties
9) faceHDDemo.m: detect and track faces showing the 17 animation units and the high definition model
10) faceHDDemo2.m: builds a face model for the user and track the faces using this model.
11) kinectFusionDemo.m: demonstrates the use of Kinect Fusion. This is still in BETA. Need fixing memory leakage in C++ causing MATLAB to crash on a second run.
12) calibrationDemo.m: obtain depth camera intrinsic parameters and color camera parameters.

Cite As

Juan R. Terven (2020). Kinect 2 Interface for Matlab (https://github.com/jrterven/Kin2), GitHub. Retrieved .

Comments and Ratings (185)

Guillermo

Hello guys, I have resolved my error. It was a configuration mistake in the step 3: Add to the windows path the bin directory containing the Kinect20.Fusion.dll....
I have created a new environment variable!
I resolved my problem by editing the *path* (existing) variable and adding the suggested path
Thanks to the creators of the toolbox, is working great!

Guillermo

@Muhammad Faique did you resolve your 2018 post?

I am getting a similar error:

Invalid MEX-file 'C:\Users\Jinvestigado01\Documents\MATLAB\jrterven-Kin2-afeec4f\Mex\Kin2_mex.mexw64': No
se puede encontrar el módulo especificado.

Error in Kin2 (line 202)
this.objectHandle = Kin2_mex('new', flags);

------2018 post
Hi Juan R. Terven,
I am getting this error while running demos:

Undefined function or variable 'Kin2_mex'.
Error in Kin2 (line 202)
this.objectHandle = Kin2_mex('new', flags);

Mauricio Castaño

Hi, I am facing the same problem that Jhon and Murad, any update about it?. Thanks

Ivo Campione

guifeng lin

Hi Juan,
I am facing the same problem that John Tayor is facing, and I have no idea how to fix it,could anyone give me some advice ,please

Bruno Marta

After 3 days of trying different methods and approaches i finally got this thing running. Thanks man.
Running with:
- Kinect v2
- Windows 10
- Matlab r2019a
- Visualstudio 2017 community

Mauro Ibarra

Hi, I am facing the same problem that Jhon and Murad, someone could you advise please. Thanks

Murad Almadani

Hi Juan,
I am facing the same problem that John Tayor is facing, could you advise please.
Thanks in advance

John Tayor

Can you please help solving the following errors when running compile_cpp_files. Thanks a lot.
>> compile_cpp_files
Verbose mode is on.
... Looking for compiler 'MinGW64 Compiler with Windows 10 SDK or later (C++)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset').
... Looking for file 'C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++.exe' ...Yes.
... Looking for folder 'C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0' InstallationFolder ...Yes ('C:\Program Files (x86)\Windows Kits\10\').
... Looking for folder 'C:\Program Files\Polyspace\R2019a' ...Yes.
... Executing command '"C:\Program Files\Polyspace\R2019a\bin\mbuild.bat" -getWin10SDKVersion' ...Yes ('10.0.18362.0').
Found installed compiler 'MinGW64 Compiler with Windows 10 SDK or later (C++)'.
Set PATH = C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin;C:\Program Files\Polyspace\R2019a\extern\include\win64;C:\Program Files\Polyspace\R2019a\extern\include;C:\Program Files\Polyspace\R2019a\simulink\include;C:\Program Files\Polyspace\R2019a\lib\win64;C:\Program Files (x86)\Windows Kits\10\\bin\10.0.18362.0\x64;C:\Program Files (x86)\Windows Kits\10\\bin\x64;;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.4.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Polyspace\R2019a\runtime\win64;C:\Program Files\Polyspace\R2019a\bin;C:\Program Files\Polyspace\R2019a\polyspace\bin;C:\Users\18324\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin;;C:\Program Files\Mozilla Firefox
Set INCLUDE = C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\include;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\shared;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\winrt;C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\include;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\shared;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\winrt;
Set LIB = C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\lib;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.18362.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.18362.0\um\x64;C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\lib;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.18362.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.18362.0\um\x64;
Set MW_TARGET_ARCH = win64;win64;
Set LIBPATH = C:\Program Files\Polyspace\R2019a\extern\lib\win64;C:\Program Files\Polyspace\R2019a\extern\lib\win64;
Options file details
-------------------------------------------------------------------
Compiler location: C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset
Options file: C:\Users\18324\AppData\Roaming\MathWorks\MATLAB\R2019a\mex_C++_win64.xml
CMDLINE2 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -m64 -Wl,--no-undefined -shared -static -s -Wl,"C:\Program Files\Polyspace\R2019a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mex.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_base.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mapping.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_face.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_fusion.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\cpp_mexapi_version.obj -lKinect20 -lKinect20.Fusion -lKinect20.Face "-LC:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Lib\x64" -L"C:\Program Files\Polyspace\R2019a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -llibMatlabDataArray -o Kin2_mex.mexw64
CXX : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++
COMPILER : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++
DEFINES : -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
CFLAGS : -fexceptions -fno-omit-frame-pointer
CXXFLAGS : -fexceptions -fno-omit-frame-pointer -std=c++11
INCLUDE : -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include"
CXXOPTIMFLAGS : -O2 -fwrapv -DNDEBUG
CXXDEBUGFLAGS : -g
LDXX : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++
LINKER : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++
LDFLAGS : -m64 -Wl,--no-undefined
LDTYPE : -shared -static
LINKEXPORT : -Wl,"C:\Program Files\Polyspace\R2019a/extern/lib/win64/mingw64/mexFunction.def"
LINKEXPORTVER : -Wl,"C:\Program Files\Polyspace\R2019a/extern/lib/win64/mingw64/exportsmexfileversion.def"
LIBLOC : C:\Program Files\Polyspace\R2019a\extern\lib\win64\mingw64
LINKLIBS : -lKinect20 -lKinect20.Fusion -lKinect20.Face "-LC:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Lib\x64" -L"C:\Program Files\Polyspace\R2019a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -llibMatlabDataArray
LDOPTIMFLAGS : -s
LDDEBUGFLAGS : -g
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
set CXXCOMPILER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++
set COMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set CXXCOMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -std=c++11 -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -DMATLAB_MEX_FILE
set OPTIMFLAGS=-O2 -fwrapv -DNDEBUG
set DEBUGFLAGS=-g
set LINKER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc
set CXXLINKER=C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++

set LINKFLAGS=-m64 -Wl,--no-undefined -shared -static -lKinect20 -llibKinect20 -lKinect20.Fusion -llibKinect20.Fusion -lKinect20.Face -llibKinect20.Face "-LC:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Lib\x64" -L"C:\Program Files\Polyspace\R2019a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -llibMatlabDataArray -Wl,"C:\Program Files\Polyspace\R2019a/extern/lib/win64/mingw64/mexFunction.def"
set LINKDEBUGFLAGS=-g
set NAME_OUTPUT= -o "%OUTDIR%%MEX_NAME%%MEX_EXT%"
MINGWROOT : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset
SDKROOT : C:\Program Files (x86)\Windows Kits\10\
SDKVERSION : 10.0.18362.0
MATLABROOT : C:\Program Files\Polyspace\R2019a
ARCH : win64
SRC : "E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp";"E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_base.cpp";"E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mapping.cpp";"E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_face.cpp";"E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_fusion.cpp";"C:\Program Files\Polyspace\R2019a\extern\version\cpp_mexapi_version.cpp"
OBJ : C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mex.obj;C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_base.obj;C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mapping.obj;C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_face.obj;C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_fusion.obj;C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\cpp_mexapi_version.obj
OBJS : C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mex.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_base.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mapping.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_face.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_fusion.obj C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\cpp_mexapi_version.obj
SRCROOT : E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex
DEF : C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mex.def
EXP : "Kin2_mex.exp"
LIB : "Kin2_mex.lib"
EXE : Kin2_mex.mexw64
ILK : "Kin2_mex.ilk"
MANIFEST : "Kin2_mex.mexw64.manifest"
TEMPNAME : Kin2_mex
EXEDIR :
EXENAME : Kin2_mex
OPTIM : -O2 -fwrapv -DNDEBUG
LINKOPTIM : -s
CMDLINE1_0 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -c -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O2 -fwrapv -DNDEBUG "E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp" -o C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mex.obj
CMDLINE1_1 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -c -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O2 -fwrapv -DNDEBUG "E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_base.cpp" -o C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_base.obj
CMDLINE1_2 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -c -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O2 -fwrapv -DNDEBUG "E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mapping.cpp" -o C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mapping.obj
CMDLINE1_3 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -c -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O2 -fwrapv -DNDEBUG "E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_face.cpp" -o C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_face.obj
CMDLINE1_4 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -c -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O2 -fwrapv -DNDEBUG "E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_fusion.cpp" -o C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_fusion.obj
CMDLINE1_5 : C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -c -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O2 -fwrapv -DNDEBUG "C:\Program Files\Polyspace\R2019a\extern\version\cpp_mexapi_version.cpp" -o C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\cpp_mexapi_version.obj
-------------------------------------------------------------------
Building with 'MinGW64 Compiler with Windows 10 SDK or later (C++)'.
C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\g++ -c -DMX_COMPAT_32 -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\Polyspace\R2019a/extern/include" -I"C:\Program Files\Polyspace\R2019a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O2 -fwrapv -DNDEBUG "E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp" -o C:\Users\18324\AppData\Local\Temp\mex_7844974573355_6896\Kin2_mex.obj
Error using mex
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:99:0,
from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:37,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionBase.h:98:8: warning: extra tokens at end of #endif directive
[-Wendif-labels]
#endif _Matrix4_
^~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionBase.h:108:8: warning: extra tokens at end of #endif directive
[-Wendif-labels]
#endif _NUI_FUSION_BUFFER_
^~~~~~~~~~~~~~~~~~~
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:37:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:112:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _Vector3_
^~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:135:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_IMAGE_TYPE_
^~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:146:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_RECONSTRUCTION_PARAMETERS_
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:156:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_RECONSTRUCTION_PROCESSOR_TYPE_
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:180:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_IMAGE_FRAME_
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:38:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionColorVolume.h:109:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _Vector3_
^~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionColorVolume.h:132:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_IMAGE_TYPE_
^~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionColorVolume.h:143:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_RECONSTRUCTION_PARAMETERS_
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionColorVolume.h:153:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_RECONSTRUCTION_PROCESSOR_TYPE_
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionColorVolume.h:177:8: warning: extra tokens at end of #endif
directive [-Wendif-labels]
#endif _NUI_FUSION_IMAGE_FRAME_
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:40:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionCameraPoseFinder.h:107:8: warning: extra tokens at end of
#endif directive [-Wendif-labels]
#endif _NUI_FUSION_CAMERA_POSE_FINDER_PARAMETERS_
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:44:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:564:14: error: use of enum '_KinectCapabilities' without previous
declaration
typedef enum _KinectCapabilities KinectCapabilities;
^~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:579:14: error: use of enum '_FrameSourceTypes' without previous
declaration
typedef enum _FrameSourceTypes FrameSourceTypes;
^~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:596:14: error: use of enum '_ColorImageFormat' without previous
declaration
typedef enum _ColorImageFormat ColorImageFormat;
^~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:611:14: error: use of enum '_HandState' without previous declaration
typedef enum _HandState HandState;
^~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:625:14: error: use of enum '_Expression' without previous
declaration
typedef enum _Expression Expression;
^~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:637:14: error: use of enum '_DetectionResult' without previous
declaration
typedef enum _DetectionResult DetectionResult;
^~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:650:14: error: use of enum '_TrackingConfidence' without previous
declaration
typedef enum _TrackingConfidence TrackingConfidence;
^~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:661:14: error: use of enum '_Activity' without previous declaration
typedef enum _Activity Activity;
^~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:676:14: error: use of enum '_Appearance' without previous
declaration
typedef enum _Appearance Appearance;
^~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:687:14: error: use of enum '_JointType' without previous declaration
typedef enum _JointType JointType;
^~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:722:14: error: use of enum '_TrackingState' without previous
declaration
typedef enum _TrackingState TrackingState;
^~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:734:14: error: use of enum '_FrameEdges' without previous
declaration
typedef enum _FrameEdges FrameEdges;
^~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:748:14: error: use of enum '_FrameCapturedStatus' without previous
declaration
typedef enum _FrameCapturedStatus FrameCapturedStatus;
^~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:760:14: error: use of enum '_AudioBeamMode' without previous
declaration
typedef enum _AudioBeamMode AudioBeamMode;
^~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:771:14: error: use of enum '_KinectAudioCalibrationState' without
previous declaration
typedef enum _KinectAudioCalibrationState KinectAudioCalibrationState;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:44:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:8078:14: error: use of enum '_PointerDeviceType' without previous
declaration
typedef enum _PointerDeviceType PointerDeviceType;
^~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:8091:14: error: use of enum '_HandType' without previous declaration
typedef enum _HandType HandType;
^~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:8103:14: error: use of enum '_KinectHoldingState' without previous
declaration
typedef enum _KinectHoldingState KinectHoldingState;
^~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:8115:14: error: use of enum '_KinectGestureSettings' without
previous declaration
typedef enum _KinectGestureSettings KinectGestureSettings;
^~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:8133:14: error: use of enum '_KinectInteractionMode' without
previous declaration
typedef enum _KinectInteractionMode KinectInteractionMode;
^~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.h:8145:14: error: use of enum '_KinectEngagementMode' without previous
declaration
typedef enum _KinectEngagementMode KinectEngagementMode;
^~~~~~~~~~~~~~~~~~~~~
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:37:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:653:5: error: '_Out_opt_z_cap_' has not been declared
_Out_opt_z_cap_(descriptionSizeInChars) PWSTR pDescription,
^~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:653:45: error: expected ',' or '...' before 'PWSTR'
_Out_opt_z_cap_(descriptionSizeInChars) PWSTR pDescription,
^~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:750:5: error: '_Deref_out_' has not been declared
_Deref_out_ INuiFusionReconstruction **ppNuiFusionReconstruction
^~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:750:42: error: expected ',' or '...' before '*' token
_Deref_out_ INuiFusionReconstruction **ppNuiFusionReconstruction
^
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:38:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionColorVolume.h:737:5: error: '_Deref_out_' has not been
declared
_Deref_out_ INuiFusionColorReconstruction **ppNuiFusionColorReconstruction
^~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionColorVolume.h:737:47: error: expected ',' or '...' before '*'
token
_Deref_out_ INuiFusionColorReconstruction **ppNuiFusionColorReconstruction
^
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:39:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionDepthProcessor.h:103:5: error: '_Deref_out_' has not been
declared
_Deref_out_ NUI_FUSION_IMAGE_FRAME **ppImageFrame
^~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionDepthProcessor.h:103:40: error: expected ',' or '...' before
'*' token
_Deref_out_ NUI_FUSION_IMAGE_FRAME **ppImageFrame
^
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:40:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:45,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionCameraPoseFinder.h:461:5: error: '_Deref_out_' has not been
declared
_Deref_out_ INuiFusionCameraPoseFinder **ppNuiFusionCameraPoseFinder
^~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionCameraPoseFinder.h:461:44: error: expected ',' or '...' before
'*' token
_Deref_out_ INuiFusionCameraPoseFinder **ppNuiFusionCameraPoseFinder
^
In file included from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:46:0,
from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:196:14: error: use of enum '_FacePointType' without previous
declaration
typedef enum _FacePointType FacePointType;
^~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:212:14: error: use of enum '_FaceFrameFeatures' without
previous declaration
typedef enum _FaceFrameFeatures FaceFrameFeatures;
^~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:235:14: error: use of enum '_FaceProperty' without previous
declaration
typedef enum _FaceProperty FaceProperty;
^~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:253:14: error: use of enum '_HighDetailFacePoints' without
previous declaration
typedef enum _HighDetailFacePoints HighDetailFacePoints;
^~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:297:14: error: use of enum '_FaceShapeAnimations' without
previous declaration
typedef enum _FaceShapeAnimations FaceShapeAnimations;
^~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:324:14: error: use of enum '_FaceShapeDeformations' without
previous declaration
typedef enum _FaceShapeDeformations FaceShapeDeformations;
^~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:428:14: error: use of enum '_FaceAlignmentQuality' without
previous declaration
typedef enum _FaceAlignmentQuality FaceAlignmentQuality;
^~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:439:14: error: use of enum '_FaceModelBuilderCollectionStatus'
without previous declaration
typedef enum _FaceModelBuilderCollectionStatus FaceModelBuilderCollectionStatus;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:454:14: error: use of enum '_FaceModelBuilderCaptureStatus'
without previous declaration
typedef enum _FaceModelBuilderCaptureStatus FaceModelBuilderCaptureStatus;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/Kinect.Face.h:470:14: error: use of enum '_FaceModelBuilderAttributes'
without previous declaration
typedef enum _FaceModelBuilderAttributes FaceModelBuilderAttributes;
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:0:
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:56:11: error: 'FrameSourceTypes' is not a class, namespace, or
enumeration
COLOR = FrameSourceTypes::FrameSourceTypes_Color,
^~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:57:11: error: 'FrameSourceTypes' is not a class, namespace, or
enumeration
DEPTH = FrameSourceTypes::FrameSourceTypes_Depth,
^~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:58:14: error: 'FrameSourceTypes' is not a class, namespace, or
enumeration
INFRARED = FrameSourceTypes::FrameSourceTypes_Infrared,
^~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:59:22: error: 'FrameSourceTypes' is not a class, namespace, or
enumeration
BODY_INDEX = FrameSourceTypes::FrameSourceTypes_BodyIndex,
^~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:60:10: error: 'FrameSourceTypes' is not a class, namespace, or
enumeration
BODY = FrameSourceTypes::FrameSourceTypes_Body,
^~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:70:21: error: 'FacePointType' is not a class, namespace, or enumeration
PointF facePoints[FacePointType::FacePointType_Count];
^~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:72:34: error: 'FaceProperty' is not a class, namespace, or enumeration
DetectionResult faceProperties[FaceProperty::FaceProperty_Count];
^~~~~~~~~~~~
In file included from E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:1:0:
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:208:3: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
FaceFrameFeatures::FaceFrameFeatures_BoundingBoxInColorSpace
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:209:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_PointsInColorSpace
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:210:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_RotationOrientation
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:211:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_Happy
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:212:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_RightEyeClosed
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:213:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_LeftEyeClosed
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:214:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_MouthOpen
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:215:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_MouthMoved
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:216:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_LookingAway
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:217:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_Glasses
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2.h:218:5: error: 'FaceFrameFeatures' is not a class, namespace, or
enumeration
| FaceFrameFeatures::FaceFrameFeatures_FaceEngagement;
^~~~~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp: In function 'void mexFunction(int, mxArray**, int, const
mxArray**)':
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:695:44: warning: narrowing conversion of
'facesData.std::vector<_Tp, _Alloc>::size<k2::_FaceData, std::allocator<k2::_FaceData> >()' from
'std::vector<k2::_FaceData>::size_type {aka long long unsigned int}' to 'mwSize {aka int}' inside { } [-Wnarrowing]
mwSize dims[2] = {1, facesData.size()};
~~~~~~~~~~~~~~^~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:715:36: error: 'FaceProperty' is not a class, namespace, or
enumeration
int facePropsDim[2]={1,FaceProperty::FaceProperty_Count};
^~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:729:28: error: 'FacePointType' is not a class, namespace, or
enumeration
for(int j=0; j<FacePointType::FacePointType_Count; j++)
^~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:732:46: error: 'k2::FaceData {aka struct k2::_FaceData}' has no
member named 'facePoints'; did you mean 'faceBox'?
facepointsptr[j*2] = curFace.facePoints[j].X;
^~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:733:50: error: 'k2::FaceData {aka struct k2::_FaceData}' has no
member named 'facePoints'; did you mean 'faceBox'?
facepointsptr[j*2 + 1] = curFace.facePoints[j].Y;
^~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:744:28: error: 'FaceProperty' is not a class, namespace, or
enumeration
for(int j=0; j<FaceProperty::FaceProperty_Count; j++)
^~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:747:48: error: 'k2::FaceData {aka struct k2::_FaceData}' has no
member named 'faceProperties'; did you mean 'faceRotation'?
facepropsptr[j] = (int)curFace.faceProperties[j];
^~~~~~~~~~~~~~
E:\Projects\HumanModeling\jrterven-Kin2-afeec4f\Mex\Kin2_mex.cpp:780:44: warning: narrowing conversion of
'facesData.std::vector<_Tp, _Alloc>::size<k2::_HDFaceData, std::allocator<k2::_HDFaceData> >()' from
'std::vector<k2::_HDFaceData>::size_type {aka long long unsigned int}' to 'mwSize {aka int}' inside { } [-Wnarrowing]
mwSize dims[2] = {1, facesData.size()};
~~~~~~~~~~~~~~^~

Error in compile_cpp_files (line 34)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...

Jonathan

Hi Juan
The code works very well and I appreciate. However i need your help. I am trying to use your mapping code from color to depth so that for the centroid that I find on an object on the color frame, I may be able to map it to the depth frame to calculate the distance of the object from the sensor. When I do this ıt only takes the first frame and continously repeats that without updating a new position of the object. How am I supposed to do this since the snapshot or getsnapshot or step functions for acquiring frames are not working.

Here is the code:

addpath('Mex');
clear
close all

redThresh = 0.25;
k2 = Kin2('color','depth');
% images sizes
d_width = 512; d_height = 424; outOfRange = 4000;
c_width = 1920; c_height = 1080;

% Color image is to big, let's scale it down
COL_SCALE = 0.5;

% Create matrices for the images
depth = zeros(d_height,d_width,'uint16');
color = zeros(c_height*COL_SCALE,c_width*COL_SCALE,3,'uint8');

% Images used to draw the markers
depthAdditions = zeros(d_height,d_width,3,'uint8');
colorAdditions = zeros(c_height*COL_SCALE, c_width*COL_SCALE,3,'uint8');

% depth stream figure
d.h = figure;
d.ax = axes('units','pixels');
d.im = imshow(depth,[0 255]);
title('Depth Source (press q to exit)')
% color stream figure
c.h = figure;
c.im = imshow(color,[]);
title('Color Source (press q to exit)');

while true
% Get frames from Kinect and save them on underlying buffer
validData = k2.updateData;

% Before processing the data, we need to make sure that a valid
% frame was acquired.
if validData
% Copy data to Matlab matrices
depth = k2.getDepth;
color = k2.getColor;

% update depth figure
depth8u = uint8(depth*(255/outOfRange));
depth8uc3 = repmat(depth8u,[1 1 3]);
set(d.im,'CData',depth8uc3 + depthAdditions);

% update color figure
color = imresize(color,COL_SCALE);
%drawnow
set(c.im,'CData',color + colorAdditions);
end
nFrame = 0;

while (nFrame<300)

red = color(:,:,1);
diffFrame = imsubtract(color(:,:,1), rgb2gray(color));
diffFrame = medfilt2(diffFrame, [3 3]);
binFrame = imbinarize(diffFrame, redThresh);
binFrame = bwareaopen(binFrame,300);
bw = bwlabel(binFrame, 8);

stats = regionprops((bw), 'BoundingBox', 'Centroid');
centroids = cat(1, stats.Centroid);
imshow(color)
hold on

%This is a loop to bound the red objects in a rectangular box.
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
plot(bc(1),bc(2), '-m+')
a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'yellow');
X = bc(1); Y = bc(2);
x = X;
y = Y;
disp('Input Color Coordinates')
disp([x y]);

depthCoords = k2.mapColorPoints2Depth([x/COL_SCALE y/COL_SCALE]);

disp('Output depth coordinates')
disp(depthCoords);
depthAdditions = insertMarker(depthAdditions,depthCoords,'Color','green');
end

pause(5)

end
nFrame = nFrame+1;
end
k2.delete;
close all

Please help if there is any wrong thing I am doing in terms of getting a frame after every 5 seconds for example.
Jonathan

Ankit Jaiswal

It works well. I used it for Kinect Camera Parameters and it gave me a very close answer to Checkerboard results.

Dan Sturm

Pranjal Biswas

Is this compatible with Linux? If I am correct official Kinect2 SDK does not exists for Linux, instead I use libfreenect2. How to use this in that case?

Muhammad Faique

Hi Juan R. Terven,
I am getting this error while running demos:

Undefined function or variable 'Kin2_mex'.
Error in Kin2 (line 202)
this.objectHandle = Kin2_mex('new', flags);

Henrik Wilhelm Becker

Hi Juan R. Terven,
i'm using MATLAB R2017a, VS 2015 and Windows 10, when I try to run "compile_cpp_files.m" i get the following Error:

Error using mex
Das System kann die angegebene Datei nicht finden.
(The System can't find the specified files)

Error in compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', …

I have Changed the "IncludePath" and the "LibPath" to the correct Location, and added the bin Directory to the Windows Path, as stated in the user Manual.
I have tried the solution from "M vd Heuvel" (13. June 2018), adding Kinect20.Face.dll, Kinect20.Fusion.dll, the "inc" folder, the Database folder and the NuiDatabase folder to the mex folder, but this doesen't seem to work.

Do you, or anyone else, have any sugestions or solutions to this problem?

Thanks a lot!

M vd Heuvel

If it is any help, for those getting an 'Access violation' error, there are probably some files that Matlab cannot find or open, not all of these are mentioned in the instructions. For all the files/folders mentioned below, either make sure to have them on the Windows path, or just put them in the 'Mex' folder within the main folder of this toolbox.

The ones mentioned are (from the Kinect v2 SDK 'bin' directory):

- Kinect20.Face.dll
- Kinect20.Fusion.dll

I also needed to add:

- The 'inc' folder from the SDK (the one containing NuiKinectFusionApi.h).

Putting this folder in the 'Mex' folder solved my problem. The author informed me you also may need to include these folders from the 'bin' directory:

- Database (the complete folder)
- NuiDatabase (the complete folder)

N.B. all of this is mostly the author's solution, not mine.

Murat

Sebastian Canon

Hi Juan R. Terven
Im using matlab R2017a and VS enterprise 2017. When I compile using mex -setup C++, it shows the following message:

MEX configured to use 'Microsoft Visual C++ 2017' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. You will be required
to update your code to utilize the new API.
You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

I compile the compile_cpp_file.m file, it shows the following message:

Microsoft (R) Manifest Tool

Copyright (c) Microsoft Corporation.

All rights reserved.

del Kin2_mex.exp Kin2_mex.lib Kin2_mex.mexw64.manifest Kin2_mex.ilk
MEX completed successfully.

When I try toto compile any example, it shows the following message:

Invalid character code sequence detected.

Could you, or anyone, give me some advice on how to solve it? Thanks a lot.

De Vuko

Hi, I had a detailed look into the calibrationDemo. The value of the Focal Length X equals with the value of Focal Length Y .... same with the values of Principal Point Y and Radial Distortion 2nd order ....
shouldn´t they be different ???
I´m looking forward to your comments and suggestions ;-) ... thx!

Lucas Reis Angst

Hi
I'm trying faceHDDemo and faceDemo and they don't seem to work. I'm getting Abnormal termination:Access violation and a messag that I have to close Matlab and re-start it.

Jae-hwan Bong

Awesome codes and work well.
How can I use these m-files with simulink?
I want to read skeleton data in simulink for conduct simulator.

Suran Huang

Hi Juan,I am using windows 10 (64-bit) ,VS2012, Matlab R2013a, and the compile_cpp_file.m file runs well,but when I try to run pointCloudDemo,the results are as follows:
No appropriate method, property, or field addParameter for class inputParser.

Error in Kin2/getPointCloud (line 329)
p.addParameter('color',defaultColor,@(x) any(validatestring(x,expectedColors)));

Error in pointCloudDemo (line 62)
[pc, pcColors] = k2.getPointCloud('output','raw','color','true');

when I try to run calibrationDemo and try to calibrate color camera,the results are as follows:
No appropriate method, property, or field addParameter for class inputParser.

Error in Kin2/getPointCloud (line 329)
p.addParameter('color',defaultColor,@(x) any(validatestring(x,expectedColors)));

Error in Kin2/getColorCalib (line 545)
pointcloud = this.getPointCloud;

Error in calibrationDemo (line 97)
calib = k2.getColorCalib;

What's the reason for these? Could you give me some advice on how to solve it? Thanks a lot.

Ali Ozdagli

EkoSusatio

Hi Juan, can you give an example in using time stamps. In my experiment it gives 12 digit time stamps data with int64 format. How to interpret that number to become an understandable time data like dd:mm:yy h:m:s? or may be other understandable time format.

Yeyu Shi

Ceresa van Lieshout

When I run any of the face tracking test files, just the camera projection appears (nothing additional). In the png attached it seems like red tracking dots should be overlayed. Can someone help? I want to view facial tracking information.

David Galarza

Hi Olaniyi Olatunde Ayeni , Yes I have already solved using VS 2012 , and the rest run successfully, thanks for your contribution
regards.

sufian ahmed

Hi juan. i can successfully run the code. But i want to set color resolution same as depth resolution. so that color image has same co-ordinates like depth image. how can i do that ?

liang wang

Hi,
Error using cd
Cannot CD to Mex (Name is nonexistent or not a directory).
How to deal with it,
Thank you.

Parimal sahu

I am new to Kinect and Matlab, in VideoDemo.m how to control the Depthrange, I want data upto 2 meter

@David Galarza,

VS 2017 does not work with Kinect V2 for Windows. I've successful ran the compile_cpp_files by installing VS 2015. This took forever to find the download so here it is - https://my.visualstudio.com/downloads?q=visual%20studio%20enterprise%202015 , click the green button to the right and when performing the install do NOT select the default option, instead select the Custom option, from here select the C++ entities (ref: https://stackoverflow.com/questions/31953769/visual-studio-doesnt-have-cl-exe), I selected everything because I don't have the time to check - 38Gb. Once installed from the Command Window in MATLAB entry the following - "mex -v -setup C++" you will be prompted to select the appropriate compiler if you have more than one on your system, I had MinGW on mine. If this works then run compile_cpp_files.
Good luck.

Hello David Galarza,
I'm now at the stage where I'm getting the same error as yourself. Have you came across a solution yet ?
Hello Iiujiachao,
thanks for that information, I've implemented the path now. I initially changed the source code "compile_cpp_files" to include the line "path('C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin', path)". Does this have the same effect ?

liujiachao

Usage 3 Add to the windows path the bin directory containing the Kinect20.Fusion.dll and Kinect20.Face.dll
高级系统设置--高级--环境变量--系统环境变量--Path--编辑
新建--浏览-……C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin
Advanced system settings--Advanced--environment variable--path--edit
new--view---C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin

David Galarza

Hello Juan R. Terven
When i run compile_cpp_files.m present this error:
Error in compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...
could you please help me on this ? ...................I'm using matlab R2015b, VS 2017,SDK v2.0, over SO Windows 10
Thanks.

Hello All members and Juan R. Terven,
I'm very new to the MATLAB, Simulinlk and Visual Studio environment. Hence I need some help which will hopefully save me amples of time setting up my laptop.
I installed the following - MATLAB R2017a, Simulink, Microsoft Visual Studio Community 2017 on my Windows 10 laptop. Download Juan's software and tried to follow the instructions. The first instruction :

1) Set the compiler using mex -setup C++ (note it doesn't work with compilers older than VS2012.

I loaded the compile_cpp_files.m and pressed the RUN tab, I'm assuming this will compile the code. The results are as follows:
Error using mex
No supported compiler or SDK was found. You can install the freely available MinGW-w64 C/C++ compiler; see
Install MinGW-w64 Compiler. For more options, visit http://www.mathworks.com/support/compilers/R2017a/.

Error in compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...

The prior messages show that its looking for versions of Visual Studio prior to 2017.
My questions are 1) is the RUN option the correct method to compile the compile_cpp_files.m and 2) does it work with Visual Studio 2017

Any help will be much appreciated,
thanks,

Ola

Juan R. Terven

Hi Luis Serrador!
To use two KinectV2 on the same computer you need to connect them on separate USB host controllers.
I haven't done this, but it should be possible. Try using the Kinect SDK 2.0. If that works, Kin2 should work too since it is an interface to the SDK.

Luís Serrador

Hi! I have to use this toolbox with two Kinect v2 at the same time. It is possible?

priya dnanabal

hai ...

how to run that program ...i will try to run that program error is came
i have only matlab 2014b ..

Arthur Fernandes

Gaurav

Awesome , Thank you :) :D . Its amazing

Xiaobin Tao

George Popescu

Hi,
the interface works very well for me.
However whem I try to save the matrices of the color stream and pointcloud I get a jerky video with black frames.
I guess Matlab is too slow to record live the frames?
Does anyone have a solution?
Here's my code:
k2 = Kin2('color','depth'); %Permet de lancer la kinect et de récolter les données voulues

% Create matrices for the images
depth_rec = [];
color_rec = [];
cloud_rec = [];

n=0;
stop=0;
while stop==0
n=n+1;
% Get frames from Kinect and save them on underlying buffer
validData = k2.updateData;

% Before processing the data, we need to make sure that a valid
% frame was acquired.
if validData
% Copy data to Matlab matrices




color_rec(:,:,:,n)=k2.getColor;
cloud_rec(:,:,n)=k2.getPointCloud;

end
pause(0.02)
if n==50
stop=1;
end

end
% Close kinect object
k2.delete;
save('video_enregistre.mat','color_rec','cloud_rec')
close all

Seyedali Mirjalili

Patrick Graf

Jonathan Michaels

Problem solved! Got Visual Studio 2015 Professional properly installed and recognized in Matlab.

Great work!

Jonathan Michaels

Hello Juan,

I've fixed the previous errors by changing the C++ compiler. I now have the current errors (Matlab 2016a, Microsoft SDK 7.1 C++ Compiler, Windows 10):

Error using mex
Kin2_mex.cpp
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2061: syntax error :
identifier '_Out_writes_z_'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2059: syntax error :
')'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : fatal error C1903: unable
to recover from previous error(s); stopping compilation

David

Im trying to store the depth and camera data acquired with Kinnect. Im facing the issue that it is very easy to run out of memory. Do you have any way to periodically save the data and flush the memory?

Jonathan Michaels

Hello Juan,

I have mex setup and the correct folder in the path. However, I always get the same pages and pages of errors. Here is just an excerpt. I'm using MATLAB 2016a on Windows 10.

Error using mex
In file included from C:\Program Files\Microsoft
SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:99:0,
from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:37,
from C:\Users\Jonathan\Dropbox\mFiles\Motion
Tracking\jrterven-Kin2-ff46b0c\Mex\Kin2.h:45,
from C:\Users\Jonathan\Dropbox\mFiles\Motion
Tracking\jrterven-Kin2-ff46b0c\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionBase.h:98:8: warning: extra
tokens at end of #endif directive
#endif _Matrix4_
^
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionBase.h:108:8: warning: extra
tokens at end of #endif directive
#endif _NUI_FUSION_BUFFER_
^
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:37:0,
from C:\Users\Jonathan\Dropbox\mFiles\Motion
Tracking\jrterven-Kin2-ff46b0c\Mex\Kin2.h:45,
from C:\Users\Jonathan\Dropbox\mFiles\Motion
Tracking\jrterven-Kin2-ff46b0c\Mex\Kin2_mex.cpp:1:
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:112:8: warning: extra
tokens at end of #endif directive
#endif _Vector3_
^
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:135:8: warning: extra
tokens at end of #endif directive
#endif _NUI_FUSION_IMAGE_TYPE_
^
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:146:8: warning: extra
tokens at end of #endif directive
#endif _NUI_FUSION_RECONSTRUCTION_PARAMETERS_
^
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:156:8: warning: extra
tokens at end of #endif directive
#endif _NUI_FUSION_RECONSTRUCTION_PROCESSOR_TYPE_
^
C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:180:8: warning: extra
tokens at end of #endif directive
#endif _NUI_FUSION_IMAGE_FRAME_

Thanks!

DELOWAR HOSSAIN

I am using windows 10 (64-bit) and Matlab R2014b. When I compile using mex -setup C++, it shows the following message:

MEX configured to use 'Microsoft Visual C++ 2012' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

Please give a solution. Thank you.

Juan R. Terven

Hi Delowar, yes. I have only tested it on Win 64-bit

Delowar Hossain

Is it possible to use this code in 64-bit windows platform?

Ngo Nguyen

The code is faster and cost less memory than Matlab built-in code.

Elena

Great Work!

Manish Sahu

I couldn't understand the this "3) Add to the windows path the bin directory containing the Kinect20.Fusion.dll and Kinect20.Face.dll"
Can someone please tell me what I have to do here?

Alex Nyamweya

imyfwu

Thanks,every demo seems works well, win10, vs2013 with update5, matlab2016a.More tests will be done later, thanks again.

Dominik Melcher

I am sorry, but i cant find a solution for my problem in the comments. What comment do you mean?

@Dominik Melcher.

Please Pay attention to the comments below.

In them is the solution

Dominik Melcher

Hi,

I tried to run the compile_cpp_file.m file and got the following error:

Error using mex
In file included from C:\Program Files\Microsoft
SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:99:0,
from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionApi.h:37,
from C:\Users\Temp\Downloads\jrterven-Kin2-ff46b0c\Mex\Kin2.h:45,
from C:\Users\Temp\Downloads\jrterven-Kin2-ff46b0c\Mex\Kin2_mex.cpp:1:

I have followed your README introduction and checked the windows path for several times, but it still doesnt work. I also copied the "Database", "NuiDatabase", "Kinect20.Face.dll" and "Kinect20.Fusion.dll" files in my Mex folder, but i cant find a way to run the compile_cpp_run.m file. Do you have any idea what could be wrong?

Tiffany

While running the videoDemo, we've found the memory stored in matlab runs up while the workspace variables themselves retain a constant size. We think it has to do with a memory leak from the C++ implementation. Have you/anyone been able to address this issue? The system tends to crash when the video runs for about 30 seconds, too much memory has been used by matlab, so it crashes. Obviously the time varies based on your computer... but we were hoping to clear the memory build-up all together. Any suggestions would be nice. Thanks! :)

Could you please give me more details about setting up the mex files? I am having trouble adding the step-3 of the mex setup-c++

WilliamBernal

I was able to run thanks

WilliamBernal

I dont know how to do this step
Set the compiler using mex -setup C++

Could you give me ore details please

lexi11

Hi,

Thank you for your good work and sharing it with the matlab community.
When I run faceDemo.m it does not seem to work properly. It gives the error: Error using imshow>validateParent(line 348) HAX must be a valid axes handle.
Error in imshow(line 253) validateParent(specific_args.Parent)
Error in faceDemo(line 73)
c.im = imshow(color,'Parent',c.ax)

could you please help me on this issue?
(I haven't tried other files but videoDemo works fine)
thanks

Márcio Marques

David

pius Shrestha

It works now... I was using minGW w64 compiler....
Thanks Much!

pius Shrestha

@Eduardo Hernandez Miranda- I am having the same problem

Error using mex
In file included from C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc/NuiKinectFusionVolume.h:99:0...................

Your hint would be great help!!! Thank you!

kalarmago

To return the bodyIndex image, why don't you fill the background with zeros and the body index as numbers in the way as the SDK provides?

I observed your program indexes sometimes the body as zero, as ones, as two, even in the case of a single user. I think that zero is incorrect.

MATLABFACE

I use win10 and vs2013,I am having the following error when I run compile_cpp_files:
error using mex
Kin2_mex.cpp
c:\users\yuan\downloads\jrterven-kin2-ff46b0c\mex\Kin2.h(44) : fatal error C1083: can't open the file: “Kinect.h”: No such file or directory
出错 compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...
I'hope for your help.thanks

MATLABFACE

I use win10 and vs2013,I am having the following error when I run compile_cpp_files:
错误使用 mex
Kin2_mex.cpp
c:\users\yuan\downloads\jrterven-kin2-ff46b0c\mex\Kin2.h(44) : fatal error C1083: 无法打开包括文件: “Kinect.h”: No such file or directory
出错 compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...
I'hope for your help.thanks

Hi, juan finally i successfully run compile_cpp_files in matlab 2015b with windows 10

Hi juan,
I use win10 and I am having the following error when I run compile_cpp_files:

Error using mex
Creando biblioteca Kin2_mex.lib y objeto Kin2_mex.exp
Kin2_base.obj : error LNK2019: símbolo externo __imp_NuiFusionReleaseImageFrame sin resolver al que se
hace referencia en la función "public: __cdecl Kin2::~Kin2(void)" (??1Kin2@@QEAA@XZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceFrameSource sin resolver al que se hace
referencia en la función "public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateHighDefinitionFaceFrameSource sin resolver al que
se hace referencia en la función "public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceAlignment sin resolver al que se hace
referencia en la función "public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceModel sin resolver al que se hace referencia en
la función "public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_face.obj : error LNK2019: símbolo externo GetFaceModelVertexCount sin resolver al que se hace
referencia en la función "public: void __cdecl Kin2::getHDFaces(bool,class std::vector<struct
k2::_HDFaceData,class std::allocator<struct k2::_HDFaceData> > &)"
(?getHDFaces@Kin2@@QEAAX_NAEAV?$vector@U_HDFaceData@k2@@V?$allocator@U_HDFaceData@k2@@@std@@@std@@@Z)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionGetDeviceInfo sin resolver al que se
hace referencia en la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)"
(?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionCreateReconstruction sin resolver al que
se hace referencia en la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)"
(?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionCreateImageFrame sin resolver al que se
hace referencia en la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)"
(?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionShadePointCloud sin resolver al que se
hace referencia en la función "private: void __cdecl Kin2::KF_ProcessDepth(void)"
(?KF_ProcessDepth@Kin2@@AEAAXXZ)
Kin2_mex.mexw64 : fatal error LNK1120: 10 externos sin resolver

Error in compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...

help me plss i tryed with the solution of 26/f but no working.

Wang Wei

Hi Juan,
I successfully ran compile_cpp_files with.m matlab R2015b(unsuccessfully with matlab R2013a and matlab R2014a)

Wang Wei

Hi Juan,
I have the same problem as Eduardo,please tell me
whether it has a answer.Thanks!

Juan R. Terven

Hi El,
I am just providing the timestamp that the Kinect provides.
Quoting https://social.msdn.microsoft.com/Forums/en-US/2e172449-3d18-4914-9370-fbc1cfa31aa6/timestamp-framenumber-and-synchronization-between-depth-and-color?forum=kinectsdk

"The timestamps indicate the relative times at which the frames were captured. These values should correlate across the streams. The Kinect for Windows runtime attempts to keep the color and depth streams as synchronized as it can, but there will typically be a small discrepancy of a few milliseconds between them"

Juan R. Terven

Hi Barbara,

Good point. The orientations provided by the SDK will not match the filtered data because the way it is implemented right now is that the joints and their orientations are obtained internally from the Kinect. However, you can calculate the orientations of your filtered joints separately.

Juan R. Terven

Hi kalarmago,
Sorry for the late response.
I haven't added a function to align the complete depth frame to color. However, you can map the coordinates using mapDepthPoints2Color.

Juan R. Terven

Hi Ali Al-Naji,

I am sorry for the late response. I didn't understand your question. Can you elaborate a bit more?

Juan R. Terven

Hi Md Shakir Khan,

You can use the KF_getMesh function (see the kinectFusionDemo line 96).
This function returns a structure containing the Vertices, TriangleIndices, and the Normals.
I haven't added a function to export this to a .ply/.obj/.stl yet. But, I think this can be done easily with built-in MATLAB functions.

Regarding your second question, I haven't added that yet. You can only get the current mesh.

Juan R. Terven

Hi dshashank1,

I haven't added the audio capture capabilities yet. I have added it to my TODO list.

Juan R. Terven

Hi Eduardo,
I was able to reproduce your exact error. It seems that it has to do with x86 and x64 issues.
If your MATLAB is 32-bit set the LibPath to the x86 libraries. Otherwise, if your MATLAB is 64-bit set the LibPath to the x64 libraries.
For example for 64-bit MATLAB:
LibPath = 'C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Lib\x64';

I haven't tested the library with 32 bits because my MATLAB is 64 bit, but I don't see any reason why it should not work.

Let me know if this solves your problem.

Hi, me again

i tryed with this
2) From the same bin directory copy and paste to the Kin2/Mex directory the following:
- Kinect20.Face.dll
- Kinect20.Fusion.dll
- Database (the complete folder)
- NuiDatabase (the complete folder)

but actually not working

Hi i need help plss

I
am having the following error when I run compile_cpp_files:

Error using mex
Creando biblioteca Kin2_mex.lib y objeto Kin2_mex.exp
Kin2_base.obj : error LNK2019: símbolo externo GetDefaultKinectSensor sin resolver al que se hace referencia en la
función "public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo __imp_NuiFusionReleaseImageFrame sin resolver al que se hace referencia en
la función "public: __cdecl Kin2::~Kin2(void)" (??1Kin2@@QEAA@XZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceFrameSource sin resolver al que se hace referencia en la función
"public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateHighDefinitionFaceFrameSource sin resolver al que se hace referencia
en la función "public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceAlignment sin resolver al que se hace referencia en la función
"public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceModel sin resolver al que se hace referencia en la función
"public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_face.obj : error LNK2019: símbolo externo GetFaceModelVertexCount sin resolver al que se hace referencia en la
función "public: void __cdecl Kin2::getHDFaces(bool,class std::vector<struct k2::_HDFaceData,class std::allocator<struct
k2::_HDFaceData> > &)"
(?getHDFaces@Kin2@@QEAAX_NAEAV?$vector@U_HDFaceData@k2@@V?$allocator@U_HDFaceData@k2@@@std@@@std@@@Z)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionGetDeviceInfo sin resolver al que se hace referencia en
la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)" (?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionCreateReconstruction sin resolver al que se hace
referencia en la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)"
(?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionCreateImageFrame sin resolver al que se hace referencia
en la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)" (?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionShadePointCloud sin resolver al que se hace referencia en
la función "private: void __cdecl Kin2::KF_ProcessDepth(void)" (?KF_ProcessDepth@Kin2@@AEAAXXZ)
Kin2_mex.mexw64 : fatal error LNK1120: 11 externos sin resolver

Error in compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...

EkoSusatio

Thankyou Juan, you've done a really good work.

dshashank1

Hi Juan, really good work! Can you also add the functionality to extract audio from the kinect data stream? Or is it already there? It will be great help for my project. Thanks in advance!

Md Shakir Khan

Hi, I have successfully run the code.
I have 2 questions.
1. Where the reconstructed volume data is saving when running KinectFusionDemo? I can only see the Volume Source in the figure 3. With MS SDK, we can create 3D mesh and save them as .ply/.obj/.stl format. Can we also do that using your Matlab code?
2. If I want to save the volumetric point cloud after the integration process take place but before the raycasting (that means constructing the mesh), how can I do it? We can easily save the point cloud data using Kinect but is it possible to save the integrated volumetric point clouds (which is a part of the KinectFusion algorithm) somehow?

Kind,
Shakir.

Md Shakir Khan

Hello Juan,

I am having the following error when I run compile_cpp_files:

Error using mex
Kin2_mex.cpp
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2061: syntax error : identifier
'_Out_writes_z_'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : fatal error C1903: unable to recover from
previous error(s); stopping compilation

Error in compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...

Before that when I run mex -setup c++
It returns: MEX configured to use 'Microsoft Windows SDK 7.1 (C++)
Though I have VS 2013 installed. But I think it also should compile with the Windows SDK 7.1.
I am using Windows 8.1,Matlab 2016a. Also tried with the Matlab 2014b. But got the same error.
I added to the windows path and also checked the IncludePath and LibPath. These are okay.

Can you please help me out?

TIA.

Ali Al-Naji

Dear Juan
how can I get one color frame from kinect and show it in figure form following m file bodybodyDemo.m?
Cheers

kalarmago

Great work, Juan

Do you have a function to mapping the depth image to color space, maybe alignDepth2Color?

Thanks in advance

Barbara Cardoso

Hi Juan,

The orientation of the joints is calculated based on their position, correct? So if I apply a low pass filter the void Kin2::getBodies function to the position coordinates, will the given orientation values be in accordance with that (I mean if the orientation also is filtered)?

Thanks in advance
Bárbara

El

Dear Juan,
I am seeing that in the latest version, timestampt has been added to some functions. What does this exactly mean and how does it work?

Ali Al-Naji

Thank you so much Mr. Juan
It works now
I took your advice in 26 Feb.

Juan R. Terven

Hi soullest,
I haven't try on Windows 10 yet. However, if the Kinect demos from the SDK browser work, the MATLAB demos should work too since they use the same SDK.
Regarding your compilation errors, take a look at my comment from Feb/26. Solution #2 might work in your case as well.

Juan R. Terven

Hi Sudeera,
Yes, I think they use factory calibration values to do the mapping. Without the depth values, it is not possible to map to the correct location on color space. At least with the Kinect for Windows SDK 2.0.

sudeera ranjan

Hi Juan,

I just use a median filter to fill the holes of the depth image. It use values of neighbor pixels and fill the zeros. Here I found many type of filters. http://people.clarkson.edu/~hudsonb/courses/cs611/

Problem is why the colored depth image contain noisy points same as depth image?It looks like we missed color information on that pixels(we cannot fill color values). I may be wrong on this.So is it possible to match the filtered depth image to color?.

How they Calculate the mapping between two cameras. Is it Using factory calibration data(Intrinsic /Extrinsic)?

Thanks

soullest

Hi Juan, I'm trying to run compile_cpp_files.m, but I get the follow error:

Error using mex
Creando biblioteca Kin2_mex.lib y objeto Kin2_mex.exp
Kin2_base.obj : error LNK2019: símbolo externo __imp_NuiFusionReleaseImageFrame sin resolver al que se hace referencia en
la función "public: __cdecl Kin2::~Kin2(void)" (??1Kin2@@QEAA@XZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceFrameSource sin resolver al que se hace referencia en la función
"public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateHighDefinitionFaceFrameSource sin resolver al que se hace referencia
en la función "public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceAlignment sin resolver al que se hace referencia en la función
"public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_base.obj : error LNK2019: símbolo externo CreateFaceModel sin resolver al que se hace referencia en la función
"public: void __cdecl Kin2::init(void)" (?init@Kin2@@QEAAXXZ)
Kin2_face.obj : error LNK2019: símbolo externo GetFaceModelVertexCount sin resolver al que se hace referencia en la
función "public: void __cdecl Kin2::getHDFaces(bool,class std::vector<struct k2::_HDFaceData,class std::allocator<struct
k2::_HDFaceData> > &)"
(?getHDFaces@Kin2@@QEAAX_NAEAV?$vector@U_HDFaceData@k2@@V?$allocator@U_HDFaceData@k2@@@std@@@std@@@Z)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionGetDeviceInfo sin resolver al que se hace referencia en la
función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)" (?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionCreateReconstruction sin resolver al que se hace
referencia en la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)"
(?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionCreateImageFrame sin resolver al que se hace referencia en
la función "private: long __cdecl Kin2::KF_InitializeKinectFusion(void)" (?KF_InitializeKinectFusion@Kin2@@AEAAJXZ)
Kin2_fusion.obj : error LNK2019: símbolo externo __imp_NuiFusionShadePointCloud sin resolver al que se hace referencia en
la función "private: void __cdecl Kin2::KF_ProcessDepth(void)" (?KF_ProcessDepth@Kin2@@AEAAXXZ)
Kin2_mex.mexw64 : fatal error LNK1120: 10 externos sin resolver

Error in compile_cpp_files (line 32)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', 'Kin2_base.cpp', ...

I'm using matlab 2014b configured for Visual Studio 2013 and Windows 10, do you have any clue about this thouble?

Thanks

Juan R. Terven

Hi Sudeera,
How do you elimiate the zeros?
Are you filling these zeros with other values?
I did it this way because internally I am using a function called MapDepthFrameToColorSpace that takes a complete depth frame as input and is more efficient than if I map point by point using a loop. It may be more efficient if you filter the resulting image after the alignment.
Let me know your thoughts about this.

Thanks

sudeera ranjan

Hi Juan,

I tried with the getAlignColor2Depth function. it is good and i have a suggestion It contain the noise as in the depth image.To eliminate the zeros in the depth image I use a filter. So it is good if we can input the filtered depth image and get the align color image to the filtered depth image for better visualization. Correct me If I am wrong.

Thanks

Juan R. Terven

Hi Ali,
Please see my comment from Feb/26. Solution #2 seems to work in your case.
Let me know if it worked.

Juan R. Terven

Hi El,
Yes, I think I know what is the problem. The camera coordinates are obtained from the depth information; even though you are mapping from the color image, internally the Kinect uses depth information and internal calibration parameters between the cameras to estimate the camera points. The color camera has a greater resolution and field of view than the depth camera, so there are many pixels that do not have a corresponding 3D point and are returned as Inf. Also, the depth camera can't see objects that are very close (<40cm) and the objects in the scene produce occlusions on the depth information. In summary, all missing depth information return Inf when mapping to camera space. A possible solution can be to ignore coordinates returning Inf and select another one that return valid values. In your case, a nearest neighbor approach may affect the calibration accuracy.

El

Dear Juan,

I am trying mapping2CamDemo. I was thinking that I could use it in order to get information about the position of the camera and calibrate it with reference to a specific object. So I would like to select specific points on the colour image and get the corresponding camera coordinates. However I am getting a lot of Inf as ouput of the function. Do you know what could be to blame?

Ali Al-Naji

Thank Sir For your work.
I did all what you told but I have this message:
Invalid MEX-file 'C:\Users\Hui Ren\Documents\MATLAB\Mex\Kin2_mex.mexw64': The specified
module could not be found.

Error in Kin2 (line 202)
this.objectHandle = Kin2_mex('new', flags);

Error in faceHDDemo (line 22)
k2 = Kin2('color','HDface');

Juan R. Terven

Hi Sudeera,
We have implemented a new method called geAlignColorToDepth. Take a look at the videoDemo.m for a sample usage.
Have you seen the pointCloudDemos?
Let me know if that helps.

Juan R. Terven

Hi Barbara,
I think that it is easier to apply it directly in MATLAB on the data returned by the getBodies method. Otherwise, you can apply a filter on C++ on the void Kin2::getBodies function inside the Kin2_base.cpp.

Juan R. Terven

Hi El, Yes they should agree.

El

Hi Juan!
Do the face points returnt by faceHD agree in indexes with that description: https://msdn.microsoft.com/en-us/library/%20microsoft.kinect.face.highdetailfacepoints.aspx ?

sudeera ranjan

Hi Juan,

In my project, I need a color image alligned with the depth image. I think you are working on this mapDepthFrame2Color function. But then color image need to crop. MATLAB 2016a has a function alignColorToDepth (introduce in 2014b) that support kinectv2 (they will remove it future). can you write a function like that to align the color image to depth image. I need it because I calibrate my kinect and used that data to calculate Camera coordinates. (if any one has suggestions,welcome )

Thank you for making this tool box.

Barbara Cardoso

Hi Juan

You told José to try low pass filter. Where should it be applied on the kin2 mex file?

Thanks in advance
Bárbara Cardoso

Juan R. Terven

Hi Mark,
When I break the code myself, I simply call clear on the Kin2 instance (or clear all). This call operation calls the Kin2 destructor, which release all resources and closes the Kinect connection. The k2.delete also do this. I don't know why it crashed since you did it right. Maybe we have some memory leakage somewhere (a C++ headache). I will try to reproduce your error to see if I find the cause.
Regarding the code modification, all improvements are welcome!
Thanks,
Juan

Juan R. Terven

Hi Jose Alves, try some kind of low-pass filter or a Kalman Filter might work.

Mark Tomaszewski

Juan, thanks for getting started on the MEX wrapper for this SDK! I was just about to start this myself from scratch :)

Quick question... What are the basic requirements for cleaning up the C++ and MEX state before deleting and clearing a Kin2 instance?

I just ran bodyDemo.m and accidentally broke the main loop by throwing an error due to accidental deletion of some handle graphics objects.

I then just typed "k2.delete; clear k2;" thinking this is all I had to do to free Kin2_mex resources and start over. Then the next time I ran a demo file MATLAB crashed with no indication of cause. I figured I'd ask quickly in case there's a simple solution before I get too deep into reading/learning your code.

Also, as I work with this, I may have more questions and/or some modifications to your code. Do you monitor your GitHub account?

José Alves

Hi Juan,

I think for my application i need that the Joints Orientation and Coordinates are more smoothed.
Do you know any way to smooth the signal (Orientation and coordinates) from the kinect?

Thanks in advance,
José

Juan R. Terven

Hi Ammar,

I haven't tried the toolbox on MATLAB 2016. But yes, you must run compile_cpp_files in order to generate the binaries of the Kin2 class for your specific platform and MATLAB version.

Ammar Al Saqri

if I have MATLAB2016 did I need to do these steps to run it??

Barbara Cardoso

Hi Juan,

Have you worked with angles between joints?
I've been troubling with that because I' not able to find the elevation and horizontal rotation of the arm.
Something similar to this:

https://s-media-cache-ak0.pinimg.com/236x/49/f5/d6/49f5d623c51ae986a5ece7a2f598a170.jpg

Thanks in advance!
Bárbara Cardoso

Barbara Cardoso

p.s. I've already tried rotation matrices, quaternions, euler angles and just with position :(

Bárbara Cardoso

Weiwei Wan

Excellent work.
I am not sure but it is not working on Windows 10, modules are not found.

kalarmago

Juan, it will be good.

Thanks,
Kal

Barbara Cardoso

Hi Juan
I'll take a look on it!
Thank for your work.
Bárbara Cardoso

Juan R. Terven

Thanks kalarmago. Regarding the mapping functions you suggest, I am working on that.
Thank you for the suggestion.

kalarmago

Great work!

Please, Juan, I am requiring to map depth images to color space, or conversely. Do you provide some function similar to:

MapDepthFrameToColorSpace(ushort[] depthFrameData, ColorSpacePoint[] colorSpacePoints);

and

MapColorFrameToDepthSpace(ushort[] depthFrameData, DepthSpacePoint[] depthSpacePoints);

?

Thanks,

Juan R. Terven

Hi Barbara, the new getBodies method now includes joints orientations in Quaternions or in Euler angles. Take a look at the bodyDemo.m

Juan R. Terven

Hi Barbara,
Kinect SDK 2.0 do provides joints orientations through the GetJointOrientations method of the IBody struct. However, I haven't found much information about that and I haven't included in the toolbox. I will do that this weekend. Thank you for pointing this one.
Regarding the face orientation provided by the toolbox. The getFaces method provides FaceRotation in pitch, roll, yaw angles. The getHDFaces provides FaceRotation in pitch, roll, yaw and also provides HeadPivot, which is the computed center of the head which the face may be rotated around.

Barbara Cardoso

Meanwhile I managed to get it by adapting your code of face orientation to the joints I'm interested in.
However I don't understand the given values. Is it supposed to be a quaternion (x,y,z,w)? These 4 values are correspondent to what, and in which measure?
I think the first 3 values are the euler angles in degrees (pitch, yaw, roll), but i'm not sure. Can you help me?

Thanks in advance :)

Bárbara Cardoso

Barbara Cardoso

Hi Juan,

There is any way of getting the joints orientation through your toolbox?
Thanks in advance

Bárbara Cardoso

Rogerio Goncalves

Hi Juan

I tried the solution 2 and it worked.

Thank you very much....

Rogerio

Amir

Hi Juan,
Thank you it's worked for me.
Sincerely,
Amir

José Alves

Hi Juan,
I tried the solution 2 and it worked.

Thank you very much,
Awesome Work!

Juan R. Terven

Hi Rogerio, José Alves, and Amir.
I reproduced the error that you are obtaining by installing the toolbox on a new computer.
If the compile_cpp_files work well but the samples fail showing the "Invalid MEX-file" error, it has to do with missing DLLs.

You can proceed in two ways:
1) Go to System->Advanced system settings->Environment Variables... Then go to System variables and look for the "Path" variable. Inside the "Value" field (at the end of the list) copy and paste the path of the bin directory (don't forget to put a semicolon at the beginning and at the end).
For example:
;C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin;

The other way to solve the problem is:
2) From the same bin directory copy and paste to the Kin2/Mex directory the following:
- Kinect20.Face.dll
- Kinect20.Fusion.dll
- Database (the complete folder)
- NuiDatabase (the complete folder)

Hope this helps. Let me know if you are still experiencing an error and describe me your system, compiler and MATLAB version.

Take a look at this:
http://www.mathworks.com/matlabcentral/answers/92040-why-do-i-receive-a-specified-module-could-not-be-found-error-while-running-a-mex-file-created-from

Rogerio Goncalves

Hi Juan,

Great and great work.

But, I'm have one problem. Can you help us please?

Invalid MEX-file
'F:\pos_doc\documentos_kinect\matlab_kinect\Kin2-master\Kin2-master\Mex\Kin2_mex.mexw64':
The specified module could not be found.

Error in Kin2 (line 122)
this.objectHandle = Kin2_mex('new', flags);

Error in bodyDemo (line 18)
k2 = Kin2('color','depth','body');

I'm using:

Matlab R2015b; visual studio 2015

This error occurs when I try the use of the sample.

The compile_cpp_filles work...

Thanks

Rogerio

José Alves

Hi Juan,
I'm having the same problem that Amir has. Can you help us please? I put the dlls on the path of matlab code. Is that correct?
Thank you

Amir

Hi Juan,
I added the path to DLLs.
and restart Matlab several times but still the same error was there.

Juan R. Terven

Hi Sudeera,
Indeed, the depth values are the distances in millimeters.
You mention that if you save using the official demos it worked, I'm curious about that, I had the idea that the toolbox functions return the same information as the SDK demos. Let me check that. One thing that comes to my mind is that the color image in the toolbox demos are shrinked for visualization purposes. If you use the shrink version, the calibration will provide bad results.
Thank you for the suggestions, I will add raw data and intrinsic parameters to the next update.

Juan R. Terven

Hi Amir,
Since it is a runtime error, I think it has to do with the DLLs.
Did you add to the path the directory containing the DLLs?
If you did this with MATLAB running, you may need to restart MATLAB.
Let me know if this fixed the problem.

Amir

Hi Juan, Thank you for your code, After compiling the Mex file I got below error, How can I fix it?

Invalid MEX-file 'C:\Users\Amir\Desktop\Kinect\Matlab\jrterven-Kin2-5151d5e\Mex\Kin2_mex.mexw64': The specified module could not be found.

Error in Kin2 (line 122)
this.objectHandle = Kin2_mex('new', flags);

Error in mapping2CamDemo (line 29)
k2 = Kin2('color','depth');

Juan R. Terven

Sarah

Hi Juan,
I am searching for a solution for the Kinect Xbos 360, simply getting the depht data into matlab..
Can you help me?

sudeera ranjan

Hei,Juan

I used the color and depth images from you toolbox to calibrate my kinect. But i did not results like many reserches says(i.e.foclal length and the principal point is not same). Once I save them from the kinect color basic, depth D2D example,it gave me acceptable results. What may be the reason?

if i get the depth values from your function it is not raw data, its the distance in mm. can you add a function to get raw depth values and intrinsic parameters of the Kinect v2 if it is possible.

You are doing a great work here for people who use MATLAB and don't know the C++.Thank you very much.

dshashank1

vassilis

My xef contains only one person. I have slightly modified your MATLAB code to save (instead of displaying) the frames and the face coordinates. I've tried to a) save face coords and b) save both face coords and RGB frames (on a pre-allocated matrix). In the second case the number of faces was smaller than the ones of the first case.

I'm afraid that it might needed a stronger PC than the one I have since (I assume that) some frames or xef are not saved because the processing time per frame is higher than 1/30 sec (kinect fps) thus some kinect frames are missed.

Juan R. Terven

Hi vassilis
When you call updateData, MATLAB fetches all the selected data (provided in the constructor of your Kin2 object) from the Kinect and save them inside the Kin2 object. Then, when you call getFace or getColor, it copies the data from the the Kin2 object to MATLAB matrices. The only thing that comes to my mind is the latency due to the copy of the color frame.
Can you elaborate a little more?
With more faces, do you mean more people in the room? or more frames with faces detected?

vassilis

Hi Juan
I'm trying to read a xef file using your code (and kinect studio). However, I'm counting the received faces and some are missed (e.g. I get more faces when I read only face coordinates (getFaces) than the case that I read both faces and RGB data (getFaces and getColor)). Can you propose any solution?

vassilis

Juan R. Terven

Hi Kalarmago, the pointcloud seems to work fine at my end. However, the plot in the pointCloudDemo is not very intuitive. Try zooming-in and changing the view.
Also remember that Kinect only sees in a range of ~40cm to ~8m from the device and the foreground objects block the background producing shadows with no data on the pointcloud.
Let me know if are still experiencing problems with the pointclouds.

Juan R. Terven

Hi torque, try image intensity adjustment, for example:
infrared = imadjust(infrared,[],[],0.5);
Performs Gamma corrections, and seems to produce good results in this case.

Juan R. Terven

Hi Cameron,
did you added the bin directory containing the Kinect20.Face.dll to the windows path? If not, this produces a run-time exception.

Gautam Gare

El

kalarmago

Compilation and execution was easy, however I think the cloud points have some mapping problem, it seems that map only the scene background. Could you review it?

Juan R. Terven

Hi Martin, for this version please add the bin directory containing the Kinect20.Fusion.dll and Kinect20.Face.dll to the windows path
For example the directory: C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\bin
I am testing the toolbox in different computers to determine what is problem. So far no problems, just this new requirement.

Martin Schätz

The older version worked fine, but I am not able to compile this one. I have bunch of unresolved external symbol errors in 9 functions. It seems they all are from the new face and fusion stuff.

torque

Works perfectly. But Infrared Video is completely dark?

And im also unable to run faceDemo or faceHDDemo.

Cameron Hohimer

I also am unable to run the faceDemo or faceHDDemo. I get the same Access violation error and forced to restart MATLAB.

Everything else appears to work as expected.

Cameron Hohimer

El

Previous problem solved. Kinect20.Fusion.dll and Kinect20.Face.dll hadn't been added correctly to the path. However, I'm trying faceHDDemo and faceDemo and they don't seem to work. I'm getting Abnormal termination:Access violation and a messag that I have to close Matlab and re-start it.

El

Hi!

Thank you for the nice contribution. I' m facing the following problem. I'm running compile_cpp_files and I'm getting that MEX completed successfully. However, when I'm trying to run the demos, I'm getting the warning "The following error was caught while executing 'Kin2' class destructor:
Invalid MEX-file" and then an error "Error in Kin2 (line 122)
this.objectHandle = Kin2_mex('new', flags);" It seems as if Kin2_mex has not been compiled

Mary Bucklin

The first line of code, mexfunction, was uncommented. When I commented it out, then it worked! Thank you again for your help

Juan R. Terven

Hi Mary, try opening the compile_cpp_files.m file and runing it

Mary Bucklin

Hi Juan,

Thank you for your response, it looks like we posted at the same time, so I did not see what you wrote before I replied with an update. I downloaded Kinect for Windows SDK 2.0 already (even before my first comment). Do you know why it would be using Microsoft Windows SDK 7.1 instead?

Thank you for your help!!

Mary Bucklin

Update: I downloaded Microsoft Visual C++ 2012 professional (since we are using Matlab 2015b) which is compatible, and we were able to select it as an option under mex setup, but now am getting this error:

Undefined function or variable 'mexfunction'.

Error in compile_cpp_files (line 1)
mexfunction compile_cpp_files

Error in run (line 96)
evalin('caller', [script ';']);

Juan R. Terven

Hi Mary. I think that the code is not compatible with the compiler that you are using (SDK 7.1). The software requirements for the "Kinect for Windows SDK 2.0" are Visual Studio 2012 or 2013; and the OS must be Windows 8 or 8.1. I know that it also works on Windows 10 but I haven't try it yet.
Take a look at "System Requirements" in this page:
https://www.microsoft.com/en-us/download/details.aspx?id=44561

Mary Bucklin

I am having trouble selecting a compiler. When I type in mex-setup and then select mex -setup C++, this is what shows up :
MEX configured to use 'Microsoft Windows SDK 7.1 (C++)' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

But, then when I try to run the cpp file
run('compile_cpp_files.m');

I get this error

Building with 'Microsoft Windows SDK 7.1 (C++)'.
cl /c /GR /W3 /EHs /nologo /MD -I"C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\inc" -I"C:\Program Files\MATLAB\R2015b\extern\include" -I"C:\Program Files\MATLAB\R2015b\simulink\include" /DMX_COMPAT_32 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /O2 /Oy- /DNDEBUG C:\Users\Mark\Desktop\ultsound\jrterven-Kin2-7f84306\jrterven-Kin2-7f84306\Mex\Kin2_mex.cpp /FoC:\Users\Mark\AppData\Local\Temp\mex_2324315354887_2004\Kin2_mex.obj
Error using mex
Kin2_mex.cpp
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2061: syntax error : identifier '_Out_writes_z_'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : fatal error C1903: unable to recover from previous
error(s); stopping compilation

Error in compile_cpp_files (line 24)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', ['-L' LibPath], ...

Error in run (line 96)
evalin('caller', [script ';']);

Any suggestions?

Jakob Ziegler

Juan R. Terven

Hi Miriam, check if your IncludePath and LibPath point to the right paths of the "Kinect for Windows SDK 2.0" installation. In the case of LibPath select the x64 directory instead of x86.
Which compiler are you using?
I know that it doesn't work with VS2010 and earlier, but I haven't tested on VS2015. Also the OS must be 64 bits Windows 8 or earlier, however, I haven't tested on Windows 10.
My configuration is Windows 8.1 64 bits and VS2013 or VS2012. All these requirements are imposed by the Kinect 2.0 SDK.

Miriam Iorwerth

Many thanks for your work Juan. Unfortunately I'm getting this error when compiling the code: Error using mex
LINK : fatal error LNK1104: cannot open file 'Kin2_mex.mexw64'

Can you help me at all?

sudeera ranjan

Hi Juan,

I did compile it, it works now.Thank you.

EkoSusatio

Thank you for the work, very useful and run as promised. Yet I have some questions.

1. Is there any more efficient way to get color image mapped from depth image? so the color image is same size as depth image with every pixel value represents color from a depth in the same position. The color value taken from color image acquired from kinect. I can use mapDepthPoints2Color and get the color value from color image based on mapped coordinate, but it work pixel by pixel. So far here is my code for doing this

kinect = Kin2('color','depth');
% images sizes
dWidth = 512; %depth image size
dHeight = 424;
outOfRange = 4000;
cWidth = 1920; %color image size
cHeight = 1080;
% Create matrices for the images
depth = zeros(dHeight,dWidth,'uint16');
color = zeros(cHeight,cWidth,3,'uint8');
flag=0;
%acquiring single frame
while ~flag
flag = kinect.updateKin2;
if flag
color = kinect.getColor;
depth = kinect.getDepth;
end
end

%Forming Color Image as depth image size with every pixel represent color of depth pixel
[r, c]=size(depth);
[iy, ix]=meshgrid(1:r,1:c);
depthCoord=[ix(:) iy(:)];
colorCoords = kinect.mapDepthPoints2Color(depthCoord);
colorMapped=uint8(zeros(dWidth,dHeight,3));
for k=1:size(colorCoords,1)
coord=colorCoords(k,:);
if coord(1)~=0 && coord(2)~=0 && coord(1) < 1920 && coord(2)<1080
colorMapped(depthCoord(k,1),depthCoord(k,2),:)=oriColor(coord(2),coord(1),:);
end
end
colorMapped=imrotate(fliplr(colorMapped),90);
figure;imshow(colorMapped)

is there any way to build colorMapped without doing that iteration?

2. The color image I produce seem to be distorted, its like its warped, is it normal?

3. When we run SDK Browser for Kinect V.2, there is a face demo showing face with eyes, nose and mouth marked and some text informing these face feature state. So could you please add this feature too to this interface? Thanks in advance.

Juan R. Terven

Hi Sudeera,
It seems that it is not recognizing the new function.
Did you compiled the files?

sudeera ranjan

Error using Kin2_mex
Command not recognized.
Ki Juan,

Thanks for the work. I run the demo but got this error. How can I fix it.

Error in Kin2/getPointCloud (line 114)
[varargout{1:nargout}] = Kin2_mex('getPointCloud', this.objectHandle, varargin{:});

Error in pointCloudDemo (line 56)
pointCloud = k2.getPointCloud;

Juan R. Terven

Hi Sudeera, It is possible to get the point cloud using the mapDepthPoints2Camera or the mapColorPoints2Camera functions by concatenating all the coordinates to the argument of any of these two functions. However, this is inefficient since internally it loops and gets the camera point for each provided coordinate. I have added a new function called getPointCloud that makes this way more efficient by getting camera points for the whole frame and return it as a nx3 matrix. I've included the pointCloudDemo.m

sudeera ranjan

Really a great work.

I've a question how to make a point cloud with the data obtain from color and depth image. I tried to input all the pixel location to mapColorPoints2Camera function inside a for loop but did not work. any suggestions.

Juan R. Terven

Hi Kai, Yes, you need VS2012 or above to compile the Kinect 2 SDK.

Kai Di

First, it looks great! Thanks for your work!
I tried to compile with Matlab 2013a & VC++ 2010 but failed.
Is VS 2012 or above a must?
Thank you again.

irfan kösesoy

Wonderful! Thank u very much Juan it works great.

Kia

Hi Juan,
thanks for your answer, I run
mex - setup C++
then I select VS2013 compiler and now it works perfectly!

Tiffany

Juan R. Terven

Hi Kia,
It seems to be a problem with the compiler.
Try running just
mex -setup
It will show you a list of available compilers and select the most appropriate (VS2012 or VS2013).

Kia

Sorry but I've some problems when I try to run compile_cpp_files.m
I set:
>> mex -setup:'C:\Program Files\MATLAB\R2014b\bin\win64\mexopts\msvc2013.xml' C
and, when I run:
>> run('C:\Program Files\MATLAB\R2014b\Kin2\compile_cpp_files.m');
i've got the following errors:
Error using mex
Kin2_mex.cpp
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2061: syntax error : identifier '_Out_writes_z_'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : error C2059: syntax error : ')'
c:\program files\microsoft sdks\kinect\v2.0_1409\inc\Kinect.INPC.h(120) : fatal error C1903: unable to recover from previous
error(s); stopping compilation

Error in compile_cpp_files (line 19)
mex ('-compatibleArrayDims', '-v', 'Kin2_mex.cpp', ['-L' LibPath], '-lKinect20', ...

Error in run (line 63)
evalin('caller', [script ';']);
How can I fix it?
Thanks in advance!

Joaquin

This is a great complement to the power of Matlab. Thanks much!

Martin Schätz

Great Work! The code works as promised. The FPS is realy godd even compared to apps outside of MatLab. I am looking forward to addition of skeletal data and its info.

Martin Schätz

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!