ofxKinectNui: an addon of Kinect SDK for oF

I’m trying to create a point cloud using the mesh format, like in the ofxKinect plugin demo. I seem to be getting strange results; see the attached screenshot (after some panning & zooming).

I use the following code:

  
  
//creating the mesh  
int w = 320;  
int h = 240;  
ofMesh mesh;  
mesh.setMode(OF_PRIMITIVE_POINTS);  
for(int y = 0; y < h; y++) {  
	for(int x = 0; x < w; x++) {  
		float distance = kinect.getDistanceAt(x, y);  
		if(distance > 500 && distance < 4000){  
			ofVec3f t = kinect.getWorldCoordinateFor(x, y);  
			ofColor c = kinect.getColorAt(x,y);  
			mesh.addColor(ofFloatColor(c.r/255.0, c.g/255.0, c.b/255.0,1.0));   
			mesh.addVertex(t);  
		}  
	}  
}  
  
//the drawing and cam controls  
easyCam.begin();  
glPointSize(3);  
ofPushMatrix();  
// the projected points are 'upside down' and 'backwards'   
ofScale(1, -1, -1);  
glEnable(GL_DEPTH_TEST);  
mesh.drawVertices();  
glDisable(GL_DEPTH_TEST);  
ofPopMatrix();  
  
easyCam.end();  
  

Any idea what’s wrong with it?

Thanks!

aha, figured it out. I was mixing world coordinates with x-y values. The following code gets the typical results:

  
  
//creating the mesh  
ofMesh mesh;  
mesh.setMode(OF_PRIMITIVE_POINTS);  
for(int x = 0; x < 320; x++) {  
	for(int y = 0; y < 240; y++) {  
		float distance = kinect.getDistanceAt(x,y);  
		if (distance > 100 && distance < 100000) {  
			ofColor c = kinect.getCalibratedColorAt(x,y);  
			mesh.addColor(ofFloatColor(c.r/255.0f, c.g/255.0f, c.b/255.0,1.0f));   
			mesh.addVertex(ofVec3f(x,y,distance/10.0f));  
		}  
	}  
}  
  
//draw the mesh  
glEnable(GL_DEPTH_TEST);  
easyCam.begin();  
glPointSize(3);  
ofPushMatrix();  
// the projected points are 'upside down' and 'backwards'   
ofScale(1, -1, -1);  
mesh.drawVertices();  
ofPopMatrix();	  
easyCam.end();  
glDisable(GL_DEPTH_TEST);  
  

hey man, thanks for the awesome addons. I had it working perfectly with 1 Kinect. however, when I used 2 Kinects, I couldn’t see any depth image from the second Kinect. I tried using your first example and uncomment sections to use it with 2 Kinects, however I got errors in building it, something related with draw() and drawDepth() function. I figured that that example may not be the right one if I want to work with 2 Kinects, but I can’t find any way to make it work.

Any help for this man? Thanks a lot :smiley:

Hi,

Im having some errors while trying to run the examples… ‘FOUR_CHAR_CODE’, any idea ?

thanks in advance,

my config.
win 7 x64 ultimate
OF 0071
VS express 2010 SP1
Win SDK 7 & 7.1

I’m having this error

1>c:\users\cexp\desktop\of_v0071_vs2010_release\of_v0071_vs2010_release\addons\ofxkinectnui\src\kinect\nui\kinect.h(23): fatal error C1083: Cannot open include file: ‘MSR_NuiApi.h’: No such file or directory

Like jatru, I’m trying to use ofxKinectNui on CodeBlocks without luck. I opened another thread with the steps I followed http://forum.openframeworks.cc/t/how-to-use-ofxkinectnui-on-codeblocks/10271/1

Hello Guys,

Thx so much for your replies and sorry for my absence.
I tried SDK 1.5 and as you know it has many cool functions.
I will try to add some of them in near future. especially i want to try speech library and face tracking library.

OK, I reply though it’s crazy slow.

@alexlangberg
Thx for your suggestion. : )
I fixed the position so now it may be OK.

@jamesalliban
Thx so much for your trial.
I and co-developer tried to tune up the code.
I hope it’s ok now. : )

@prisonerjohn
Thank you for your report and reply to @jamessalliban. : )

@irregular
Sorry for this late reply…
You can filter which skeleton data you will use, but you can’t choose in advance.

@Kj1
Thanks for reply and sharing your trial. : )
Great work!

@gabbagabba
Sorry for late reply…
Probably its because your PC only has single USB controller.
@see http://bit.ly/oG8Hwk

@monk
If you has OF 0071, I recommend you to use project generator to setup. : )
Check below.
https://github.com/openframeworks/openFrameworks/downloads

@fabricio
Thx for your post. (also on github)

If somebody got this error, please download version3.0 of ofxKinectNui. : )
For some reasons, I uploaded zipped previous version on github, but it only works with Kinect SDK beta2.

@camilosw
Thx for your trial. : )
Good luck for your trial and please let me know if you succeed.
I will also try use on Code::Blocks when i have time…

Hey Guys,

I downloaded the addon and it looks really good. I have a problem however when trying to compile the KinectNuiCV example. It says

LINK : fatal error LNK1181: cannot open input file ‘…\addons\ofxOsc\libs\oscpack\lib\vs2010\oscpack.lib’

I checked the directory and indeed i dont have a lib folder in the oscpack. Im new to openframeworks, but i assumed all the libs would come when i downloaded the file. Im using of 7.1 for vs2010. I tried looking for ofxosc and i just found lots of addons with the same name, none of which have the cv2010 folder.

I dont have any problem compiling the KinectNui Example btw.

Thanks for the help.

@am48

Hi, Thank you for using ofxKinectNui. : )

Yes, It’s because of my laziness of copying project from OpenCV example project.
I will fix this soon. (now I have short vacation and doesn’t have main machine here so it will be in a few days)

If you want to fix by yourself, please see the property of kinectNuiCvExample project, and remove oscpackd.lib and oscpack.lib from linker property.
(actually it may not need assimp.lib as well)

I attached where you should remove though it is in Japanese…

Hope it helps.

Thanks for the help sadmb!

I thought that the files were necessary and for some reason i didnt have them. It never occurred to me that i could just take them out.

Just to let you know, there are 2 more libraries that are called by the linker but are not in the folders

LINK : fatal error LNK1181: cannot open input file ‘…\addons\ofxOpenCv\libs\opencv\lib\vs2010**opencv_ts*231.lib’
LINK : fatal error LNK1181: cannot open input file '…\addons\ofxOpenCv\libs\opencv\lib\vs2010*opencv_lapack
.lib’

And also (this is probably a version problem) all the opencv calls are to xxx220, and my version of OF has xxx231 so i had to change them all.

Thanks again for the help!!

Got a strange error today (of 071, win7, VS2010, kinectSDK 1.5).

Some stuff like:

  
C:\Program Files\Microsoft SDKs\Kinect\v1.5\\inc\NuiSensor.h(46): error C2146: syntax error : missing ';' before identifier 'INuiAudioBeam'  
blablabla  
  

Got it fixed by making the ofxKinectNui the first include in each file you use it. Seems odd, but this might prevent other people wasting half a day on cryptic VS errors :slight_smile:

=> this works:

  
#pragma once  
#include "ofxKinectNui.h" //must come first  
#include "ofMain.h"  
class testApp : public ofBaseApp {  

Hi everybody,

I am running into this error when trying to compile ofxKinectNui.

1>AudioStream.obj : error LNK2019: unresolved external symbol _IID_IMediaBuffer referenced in function “public: virtual long __stdcall kinect::nui::StaticMediaBuffer::QueryInterface(struct _GUID const &,void * *)” (?QueryInterface@StaticMediaBuffer@nui@kinect@@UAGJABU_GUID@@PAPAX@Z)
1>AudioStream.obj : error LNK2019: unresolved external symbol _MoFreeMediaType@4 referenced in function “public: void __thiscall kinect::nui::AudioStream::Open(enum kinect::nui::AEC_SYSTEM_MODE)” (?Open@AudioStream@nui@kinect@@QAEXW4AEC_SYSTEM_MODE@23@@Z)
1>AudioStream.obj : error LNK2019: unresolved external symbol _MoInitMediaType@8 referenced in function “public: void __thiscall kinect::nui::AudioStream::Open(enum kinect::nui::AEC_SYSTEM_MODE)” (?Open@AudioStream@nui@kinect@@QAEXW4AEC_SYSTEM_MODE@23@@Z)
1>AudioStream.obj : error LNK2019: unresolved external symbol _IID_IMediaObject referenced in function “public: void __thiscall kinect::nui::AudioStream::Open(enum kinect::nui::AEC_SYSTEM_MODE)” (?Open@AudioStream@nui@kinect@@QAEXW4AEC_SYSTEM_MODE@23@@Z)

It seems to be a problem with linking. I think my settings are accurate.
The standard c++ project that comes with the KinectSDK compiles fine. I copied the include and linker settings regarding the Kinect SDK from that project into my oF project.

I am using oF0.72.

Thanks for your help everybody!

Found it, my mistake just forgot to link these:

WinMM.lib
amstrmid.lib
msdmo.lib
dmoguids.lib

Now it’s compiling but now I get these errors as mentioned by Kj1 eventhough the ofxKinectNui.h is implemented before the ofMain.h…

NuiSensor.h(46): error C2146: syntax error : missing ‘;’ before identifier ‘INuiAudioBeam’ and so on…

If anybody has a clue :slight_smile: thanks for your help!

This helped:

#include <Shlobj.h>
#include “ofxKinectNui.h”
#include “ofMain.h”

the magic is in the #include <Shlobj.h>. Why, I have no clue

I found the solution here:
http://www.dotblogs.com.tw/rz1974/archive/2012/09/07/74660.aspx

Cheers,

Hi,

Im not sure if this project can be compiled with VS2010 express? Can any one confirm that.

I am having problems when compiling with VS2010 Express. The error is

addons\ofxkinectnui\src\ofxkinectnui.cpp(225): error C2065: ‘NUI_IMAGE_TYPE_COLOR_INFRARED’ : undeclared identifier

Can anyone help? TIA

Hello @maximillion

Thanks for your report.
I am sorry, it’s my mistake. Now it’s fixed.
Recently I merged this project and didn’t checked enough.

The following is the reason why you got error.

NUI_IMAGE_TYPE_COLOR_INFRARED is an enum defined only for 1.6 or higher.
So you couldn’t compile with your Kinect SDK (maybe version is lower than 1.6)
I fixed this bug so now you can compile without using NUI_IMAGE_TYPE_COLOR_INFRARED. :slight_smile:

Thanks

sadam

Thanks Sadam,

That’s fixed it for me

Hi Sadam and the community,

Thank you very much for sharing your library -I’m very excited to start working with it!

Any help with the build errors I’m receiving would be much appreciated (forgive me if this is a simple solution:):

  
  
1>------ Build started: Project: kinectNuiExample, Configuration: Debug Win32 ------  
1>Build started 25/02/2013 19:38:18.  
1>InitializeBuildStatus:  
1>  Touching "obj\Debug\kinectNuiExample.unsuccessfulbuild".  
1>ClCompile:  
1>  testApp.cpp  
1>d:\offroot\openframeworks\v0.7.4\of_v0.7.4_vs2010_release\apps\myapps\example\src\testapp.h(15): fatal error C1083: Cannot open include file: 'ofxKinectNui.h': No such file or directory  
1>  main.cpp  
1>d:\offroot\openframeworks\v0.7.4\of_v0.7.4_vs2010_release\apps\myapps\example\src\testapp.h(15): fatal error C1083: Cannot open include file: 'ofxKinectNui.h': No such file or directory  
1>  ofxKinectNuiDraw.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\src\ofxKinectNuiDraw.cpp': No such file or directory  
1>  KinectContext.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\src\kinect\nui\KinectContext.cpp': No such file or directory  
1>  AudioStream.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\src\kinect\nui\AudioStream.cpp': No such file or directory  
1>  Event.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\win32\Event.cpp': No such file or directory  
1>  ofxKinectNuiRecorder.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\ofxKinectNuiRecorder.cpp': No such file or directory  
1>  ofxKinectNuiPlayer.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\ofxKinectNuiPlayer.cpp': No such file or directory  
1>  ofxKinectNui.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\ofxKinectNui.cpp': No such file or directory  
1>  SkeletonFrame.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\kinect\nui\SkeletonFrame.cpp': No such file or directory  
1>  SkeletonEngine.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\kinect\nui\SkeletonEngine.cpp': No such file or directory  
1>  Kinect.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\kinect\nui\Kinect.cpp': No such file or directory  
1>  ImageStream.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\kinect\nui\ImageStream.cpp': No such file or directory  
1>  ImageFrame.cpp  
1>c1xx : fatal error C1083: Cannot open source file: '..\..\..\addons\ofxKinectNui\src\kinect\nui\ImageFrame.cpp': No such file or directory  
1>  Generating Code...  
1>  
1>Build FAILED.  
1>  
1>Time Elapsed 00:00:00.18  
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========  
  
  

System specs:

  • Visual Studio 2010 Version 10.0.30319.1

  • Windows 8 x64

Ok the below is resolved (it seems that when downloading the zip from github ofxKinectNui was named ofxKinectNui-master. Renaming fixed it :slight_smile:

One last thing though: it does seem very slow, and I have a mid-powered GTX 660M, especially the point cloud. Can anyone clarify why this may be?

Hi @Curveau,

Thx use this library. :slight_smile:

Please try release mode.
For some reason, debug mode is very slow.
I will try fix this bug later.
Thx. ; )

sadmb

[quote=“Curveau, post:41, topic:8360”]
Ok the below is resolved (it seems that when downloading the zip from github ofxKinectNui was named ofxKinectNui-master. Renaming fixed it :slight_smile:

One last thing though: it does seem very slow, and I have a mid-powered GTX 660M, especially the point cloud. Can anyone clarify why this may be?