Wednesday, August 15, 2012

Hacking the Kinect 360: Installing OpenNI on OSX Lion - Mountain Lion - Mavericks

Tutorial to install OpenNI on OSX Lion / Mountain Lion / Mavericks  (and then, Osceleton).

Only for Kinect for Xbox 360!!!  Doesn't work with Kinect for Windows (and Kinect for Xbox One, I guess...)

Preparation
For OSX Lion and Mountain Lion, you must install (the latest version, preferably) of:
XCode
Command line tools for Xcode:
To install the Command Line Tools open XCode, go XCode> Open Developer Tool> More Developer Tools. Log in as an Apple developer, and download the Command Line Tool for your OS.


XQuartz
MacPorts

Installation
With the above programs installed, follow the installation order below.

Libtool
Open Terminal (Applications> Utilities> Terminal) and run the following command:

sudo port install libtool

Hit Enter, and then, enter the admnistrador password and hit Enter.

Libusb
Open terminal and run (exactly) the following command:

sudo port install libusb +universal

Hit Enter, and then, enter the admnistrador password and hit Enter.

OpenNI
First of all, I recommend creating a folder named "kinect" in "documents" (not required, do it only for organizational reasons).

Download this version of the OpenNI SDK and extract it in the "kinect" folder

Open Terminal;
Change directory to the OpenNI SDK folder;
Run the command to install:

sudo ./install.sh

Install SensorKinect
Download the latest version of SensorKinect and extract it in your "kinect" folder.
Go to the "bin" folder. Extract the file "SensorKinect093-Bin-MacOSX-v5.1.2.1.tar.bz2" in the same "bin" folder.
In Terminal, go to the extracted folder and run the command:

sudo . /install.sh

Install PrimeSense NITE
Download this version of NITE.

Extract the contents of the folder "kinect."
Open Terminal, go to the directory "NITE-Bin-MacOSX-Dev-v1.5.2.21"
Run the command:

sudo . /install.sh

TEST

To test the demos, copy all *. xml files that are in "NITE-Bin-Dev-MacOSX-v1.5.2.21/Data" to "SensorKinect-unstable/Data"

Plug the Kinect on the Mac to check if the demos work.

Run one of the examples of NITE.
Open Terminal,
Go to the directory "NITE-Bin-Dev-MacOSX-v1.5.2.21/Samples/Bin/x64-Release"
open the example "PointViewer" with the command:

. /Sample-PointViewer

Shake hands, OpenNI  will track your hand.


Installing Osceleton
Download the OSCeleton
Extract the content in the "kinect" folder

Open terminal
Go to folder "yourKinectFolder/OSCeleton-master"
Run the command:

make

If everything worked, you can now test OSCeleton:
In the folder "OSCeleton-master" double-click the executable "OSCeleton" or open it in Terminal.
Keep a distance of approximately two steps away from Kinect and stay in position of calibration, with both arms raised, as shown below:


Keep an eye on the Terminal to see if you are recognized.
If a recognition happens, the installation was successful.

Running OSCeleton and communicating with Processing

You will need to install Processing (first) and so the libraries oscP5 and pbox2d.

Download the libraries, extract and copy the folders "oscP5" and "pbox2d" to the Libraries folder inside the Processing folder (normally located in "Documents")

Download the examples for OSCeleton
Extract the folder and go to "Sensebloom-OSCeleton-examples-d56823f 2/processing/MotionCapture3D" and open the sketch "MotionCapture3D" in Processing.
Click "Run" and if you're recognized, you will see an avatar of spheres.


That's it!!

If you have any question, or if it worked (or don't) please, leave a comment!

64 comments:

  1. really appreciate your tutorial!!
    I got the following result which install NITE thu the terminal
    is it normal?


    Copying shared libraries... OK
    Copying includes... OK
    Installing java bindings... OK
    Installing module 'Features_1_3_0'...
    ls: Features_1_3_0/Bin/lib*dylib: No such file or directory
    Installing module 'Features_1_3_1'...
    ls: Features_1_3_1/Bin/lib*dylib: No such file or directory
    Installing module 'Features_1_4_1'...
    ls: Features_1_4_1/Bin/lib*dylib: No such file or directory
    Installing module 'Features_1_4_2'...
    ls: Features_1_4_2/Bin/lib*dylib: No such file or directory
    Installing module 'Features_1_5_2'...
    Registering module 'libXnVFeatures_1_5_2.dylib'... OK
    Copying XnVSceneServer... OK
    Installing module 'Features_1_5_2'
    ls: Hands_1_3_0/Bin/lib*dylib: No such file or directory
    Installing module 'Features_1_5_2'
    ls: Hands_1_3_1/Bin/lib*dylib: No such file or directory
    Installing module 'Features_1_5_2'
    ls: Hands_1_4_1/Bin/lib*dylib: No such file or directory


    ReplyDelete
    Replies
    1. I never had problem with this installer. Did you tried to install it again? The next step worked?

      Delete
    2. I got the same thing. It seems to work ok, but one problem is that when I test out the samples, it works for about 30 seconds then suddenly crashes with some kind of malloc error. Here is the exact error I get when I try Sample-Players:

      516 INFO New log started on 2012-11-10 00:59:13
      535 INFO OpenNI version is 1.5.4 (Build 0)-MacOSX (May 16 2012 10:22:59)
      538 INFO --- Filter Info --- Minimum Severity: UNKNOWN
      Look for pose
      Found pose "Psi" for user 1
      Calibration started
      Calibration done [1] successfully
      Sample-Players(4821,0x109409000) malloc: *** error for object 0x7fa4454e6c88: incorrect checksum for freed object - object was probably modified after being freed.
      *** set a breakpoint in malloc_error_break to debug
      Abort trap: 6


      Any ideas as to what I may have done wrong? Also the OSCeleton thing doesn't work for me at all.

      Delete
    3. I'm getting the same problem. Did you find a solution?

      Delete
  2. Thanks Italo, it worked like a charm on my MacBook Air, at least until Osceleton.

    BTW, installing NITE i also got messages like "Features_1_3_0/Bin/lib*dylib: No such file or directory" but it seem can be ignored, everything seems working fine.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Same thing here on 10.7.5.

      Delete
    3. Put all files in directories without "spaces" and "blanks" in the names...

      Delete
  3. Replies
    1. yep it seems worked, however while running osceleton i noticed USB ethernet is disconnected, perhaps some USB kinect driver issue. No big deal for me, i can use wireless.

      Here is the osceleton output:

      Initializing...
      Configured to send OSC messages to 127.0.0.1:7110
      Multipliers (x, y, z): 1.000000, 1.000000, 1.000000
      Offsets (x, y, z): 0.000000, 0.000000, 0.000000
      OSC Message format: Default OSCeleton format
      Initialized Kinect, looking for users...

      New User 1
      Calibration started for user 1
      Calibration complete, start tracking user 1
      Lost user 1

      Delete
  4. thanks for the tutorial.

    I have some kind of errors when try to run the samples, from OpenNI or NITE

    ./Sample-NiUserTracker
    Find user generator failed: Can't create any node of the requested type!

    ./Sample-NiHandTracker
    Unable to create GestureGenerator.Viewer init failed: Can't create any node of the requested type!

    (in NITE samples)

    ./Sample-PointViewer
    938 INFO New log started on 2012-10-13 08:51:38
    958 INFO OpenNI version is 1.5.4 (Build 0)-MacOSX (May 16 2012 10:22:59)
    963 INFO --- Filter Info --- Minimum Severity: UNKNOWN
    One or more of the following nodes could not be enumerated:

    The ./NiViewer from OpenNI Samples works fine.

    And OSCeleton ends with:
    ./osceleton -xd
    Initializing...
    [1] 3805 segmentation fault ./osceleton -xd


    I'm using OSX Mountain Lion (10.8.2) on a MBP Early 2011

    ReplyDelete
    Replies
    1. Sorry for the late reply. I was very busy these weeks. I'll try to find what's happening with you.

      Delete
    2. Did you copied all *. xml files in "NITE-Bin-Dev-MacOSX-v1.5.2.21/Data" to "avin2-SensorKinect-15f1975/Data"?

      If not, try to redo this step. If yes, some step before went wrong. I don't know what could cause this error. Sorry... If I were you, I would redo everything...

      Delete
  5. Run the command
    sudo. / install.sh

    doesn't really working for me with osxlion 10.7.5 at the starting point of installing openni

    doyou have any idea for this?

    ReplyDelete
    Replies
    1. What are you trying to install?

      Delete
    2. openni binary for sure.

      Open Terminal
      Change directory to the folder of OpenNI "OpenNI-Bin-MacOSX-Dev-v1.5.4.0"
      Run the command
      sudo. / install.sh

      it's really nice of you to give such a awesome instruction for beginners

      Delete
    3. Basically, you have to download OpenNI and browse to its folder with Terminal and type that command next. I don't know why it's not working with you...

      Delete
    4. sudo. / install.sh

      space bar usage is right..?

      Delete
    5. it's sudo(space)./install.sh

      Delete
    6. -bash: sudo.: command not found
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo./install.sh
      -bash: sudo./install.sh: No such file or directory
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo/install.sh
      -bash: sudo/install.sh: No such file or directory
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo/ install.sh
      -bash: sudo/: No such file or directory
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo / install.sh
      sudo: /: command not found
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo /install.sh
      sudo: /install.sh: command not found
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo/install.sh
      -bash: sudo/install.sh: No such file or directory
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo/ install.sh
      -bash: sudo/: No such file or directory
      seungjaeui-MacBook-Pro:kinect seungjae$
      seungjaeui-MacBook-Pro:kinect seungjae$
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo/ install.sh
      -bash: sudo/: No such file or directory
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo. / install.sh
      -bash: sudo.: command not found
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo. /install.sh
      -bash: sudo.: command not found
      seungjaeui-MacBook-Pro:kinect seungjae$ sudo. /install.sh

      Delete
    7. I think you are typing "sudo. /install.sh" but it's sudo ./install.sh

      Delete
    8. "sudo" is the command, "./install.sh" is the file address

      Delete
    9. do i have to unzip what i have downloaded, like openni nite...?

      Delete
    10. Yes, unzip and browse to the unzipped folder with terminal, then, type sudo ./install.sh.

      Delete
    11. Thanks

      Download the latest version of the Unstable SensorKinect https://github.com/avin2/SensorKinect and extract it in your kinect folder.
      Go to the "bin" folder. Extract the file "SensorKinect093-Bin-MacOSX-v5.1.2.1.tar.bz2" in the same bin folder.

      extract sensorkinect093-bin-macosx.... file twice in my kinect folder and again in the bin folder of sensorkinect093-bin-mac osx.... do i understand correctly??
      sorry for bothering... but it is really nice of you to give instructions.. thank!!

      Delete
    12. Yes, I think you're right. And you're welcome! :) I hope I have helped you anyway...

      Delete
  6. Hi and thank you for this amazing tutorial it's exactly what I need!

    I'm getting this error in Terminal when I try to run sudo port install libusb + universal:

    ---> Cleaning libusb
    Error: Port + not found

    Any idea of the fix to this? Thanks a million!

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. You've to write + and universal together:
      sudo port install libusb +universal
      That's mean you want an installation for x86 and x64.

      Delete
  7. I commented on someone else's comment below, but I just want to be sure I can get an answer from you. :)

    First off, thanks for this! Totally awesome of you.

    So everything seemed to go fine for me up until the moment when I started the Sample. I ran the sample, and it work for about 20-30 seconds, and it tracked my hand very well. But then the sample would crash. I ran it several times and every time it did the same thing. It keeps giving me a malloc error. This is what it tells me when I run Sample-Players:

    516 INFO New log started on 2012-11-10 00:59:13
    535 INFO OpenNI version is 1.5.4 (Build 0)-MacOSX (May 16 2012 10:22:59)
    538 INFO --- Filter Info --- Minimum Severity: UNKNOWN
    Look for pose
    Found pose "Psi" for user 1
    Calibration started
    Calibration done [1] successfully
    Sample-Players(4821,0x109409000) malloc: *** error for object 0x7fa4454e6c88: incorrect checksum for freed object - object was probably modified after being freed.
    *** set a breakpoint in malloc_error_break to debug
    Abort trap: 6

    It runs successfully for a couple seconds, and I can actually see it tracking me there as a player. But again it crashes after those few seconds.

    I also can't seem to get OSCeleton to work either. I made sure I'm standing at a good distance and the way the picture says to stand. But it just keeps saying it's look for a user and never finds me. I'm wondering if this has anything to do with the other errors I've been having with the crashes...

    Thanks for you're help!! :)

    ReplyDelete
    Replies
    1. That's strange. If the sampler tracked your hand, the previous steps worked. I think the error is about memory allocation, but I don't know how to solve this problem.
      If I were you, I'd try to redo the previous steps.
      Yesterday I had to follow this tutorial in order to install the Kinect in a different Macbook and I had no errors...
      I'll study what happened.
      Thank you!

      Delete
    2. I have no idea what happened to you... Sorry...

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I have the same problem with one kinect and not with another. The "xbox 360" labeled kinect works perfectly! The "kinect for windows" one crashes all the time after 20 to 30 seconds. The label is the lettering on the front, right side of the kinect.

      Delete
  8. Is the calibration pose still required? My kinect seems to complete calibration and begin tracking without me having to raise my hands. Am I missing something or was an update to Osceleton released? Thanks.

    ReplyDelete
    Replies
    1. If Osceleton recognizes you, it's ok! Maybe its not required anymore. Thank you!

      Delete
  9. I ran all of the Terminal commands properly, and everything seems to have installed. But when I open the Nite PointViewer sample, the screen is black and the Kinect light continues blinking. I tried to ignore that, and went on to download Osceleton, but I can't find the executable folder to test the samples. Sorry that I can't elaborate much further! Thanks!

    ReplyDelete
  10. Italo,

    Thank you very much for this tutorial. It is very helpful!

    I have a problem compiling OSCeleton. Apparently it has to do with some missed files that are referenced in the code but don't exist in the repo.

    src/common.h:5:21: error: GL/glut.h: No such file or directory
    src/viewer.cpp:3:19: error: GL/gl.h: No such file or directory
    src/viewer.cpp:4:20: error: GL/glu.h: No such file or directory

    I checked the gl directory in https://github.com/Sensebloom/OSCeleton/tree/master/src/gl, and there is only glut.h but not "gl.h" or "glu.h". However, they are referenced in the code. Where can I get those files?

    Looks like all the errors are related with those files. Any idea?

    Regards,
    OSCar

    P.d: Here (https://gist.github.com/4348632) is the output when I run "make"

    ReplyDelete
  11. This was super helpful. Thanks! Could you fix the small typos in your bash commands?

    sudo port install libusb + universal ------> sudo port install libusb +universal
    sudo. / install.sh ------> sudo ./install.sh

    ReplyDelete
  12. Thanks Brad! Using libusb(space)+(space)universal worked for me months ago. But, if it worked now without space, I corrected it.

    ReplyDelete
    Replies
    1. Quick response! I appreciate that.

      Your install.sh commands still have spacing problems though. :) Note that some of the comments above concern errors from copying and pasting the install.sh commands as they are currently written in your post.

      Delete
  13. Thanks for the Tutorial. Sadly I can't get it to work on my MountainLion...
    - MacPorts, Libtool, libusb successfull installed
    - OpenNi installed. Old version 1, NOT OpenNI 2 (took some time till I realized the wrong version 2 that I installed first)
    - SensorKinect installed
    - NITE installed (same errors as discussed above, but this seams to be ok)

    >>To test the demos, copy all *. xml files that are in "NITE-Bin-Dev-MacOSX-v1.5.2.21/Data" to "avin2-SensorKinect-15f1975/Data"<<
    I don't know what you mean by that. Copy the xml files - ok. But I don't habe the avin2...-Folder. There ist a sernsorkinect-unstable-Folder or an Sensor-Bin-MacOSX-v5.1.2.1-folder (That dosn't habe a Data subfolder). Maby I'm stuck because I'm trying to get this to work since at least 6h...

    I tryed to start the libfreenect demos (after doing the cmake&xcode stuff). The glview programms says:
    Kinect camera test
    Number of devices found: 1
    Could not open device
    logout

    The NITE Demos say
    InitFromXmlFile failed: File not found!

    That might be because I didn't get the copy XML part of the Tutorial.

    I guess (or hope) it's a simle stupid mistake I made. Maby someone can help!

    ReplyDelete
    Replies
    1. Addition: I tried SimpleOpenNI with Processing (using the OpenNI installer and the SimpleOpenNI library/presets). The pointcloud example won't work, all I see is a distorded Image (seams to be my desktop). Log:

      Exception in thread "Animation Thread" java.lang.NullPointerException
      at org.openkinect.processing.Kinect.enableDepth(Kinect.java:82)
      at PointCloud.setup(PointCloud.java:44)
      at processing.core.PApplet.handleDraw(PApplet.java:2117)
      at processing.opengl.PGL$PGLListener.display(PGL.java:2472)
      at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:548)
      at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:533)
      at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280)
      at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:904)
      at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:822)
      at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543)
      at processing.opengl.PGL.requestDraw(PGL.java:814)
      at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1566)
      at processing.core.PApplet.run(PApplet.java:2020)
      at java.lang.Thread.run(Thread.java:680)

      Delete
    2. I found out that the problem was my kinect camera. Looks like there are different models... I tried a different model fom university and it worked just fine. Both are "Kinect for Xbox" (not the for Windows Edition) so I don't get the difference..

      Delete
  14. I did all the steps above, but still get this terminal message:

    ./Sample-PointViewer
    734 INFO New log started on 2013-02-08 14:18:26
    752 INFO OpenNI version is 1.5.4 (Build 0)-MacOSX (May 16 2012 10:22:59)
    756 INFO --- Filter Info --- Minimum Severity: UNKNOWN
    One or more of the following nodes could not be enumerated:

    Device: PrimeSense/SensorKinect/5.1.2.1: The device is not connected!

    ReplyDelete
    Replies
    1. Is it because of this:

      Installing NITE
      ***************

      Copying shared libraries... OK
      Copying includes... OK
      Installing java bindings... OK
      Installing module 'Features_1_3_0'...
      ls: Features_1_3_0/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_3_1'...
      ls: Features_1_3_1/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_4_1'...
      ls: Features_1_4_1/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_4_2'...
      ls: Features_1_4_2/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_5_2'...
      Registering module 'libXnVFeatures_1_5_2.dylib'... OK
      Copying XnVSceneServer... OK
      Installing module 'Features_1_5_2'
      ls: Hands_1_3_0/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_5_2'
      ls: Hands_1_3_1/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_5_2'
      ls: Hands_1_4_1/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_5_2'
      ls: Hands_1_4_2/Bin/lib*dylib: No such file or directory
      Installing module 'Features_1_5_2'
      registering module 'libXnVHandGenerator_1_5_2.dylib'...OK
      Adding license.. OK

      *** DONE ***

      But I red it's doesn't matter, does it?

      Delete
    2. Did you solved your problem? Same as you, does it mean we cannot use 1517 on Mac os

      Delete
    3. Kinect for windows 1517

      Delete
  15. Hi there. When I run sudo ./install.sh I get command not found in the Terminal... any idea why this is happening? I installed Command Line Tools in Xcode and everything else. I'm running Lion osx

    ReplyDelete
  16. I can find my way to the install.sh file and execute it just fine, but I think as of OpenNI 2.1.0 the included install.sh file doesn't actually install anything on OS X. I've posted to the support forum in the hopes of getting this working:

    http://community.openni.org/openni/topics/install_sh_in_openni_2_1_0_for_os_x_doesnt_install_anything


    ReplyDelete
  17. Hey Italo, thank you so much for your tutorial!
    I have some problem understanding the "Installing Osceleton" part.
    Is "Sensebloom-OSCeleton-7307683" a folder that I should find in the osceleton-master.zip file from your link?
    Could you please explain a little more in detail?
    Thank you!

    ReplyDelete
  18. Matthew Lynch4/15/2013 6:30 AM

    Hi,

    I'm getting this error when installing SensorKinect:
    Installing PrimeSense Sensor
    ****************************

    creating config dir /usr/etc/primesense...OK
    copying shared libraries...OK
    copying executables...OK
    registering module 'libXnDeviceSensorV2KM.dylib' with OpenNI..../install.sh: line 111: /usr/bin/niReg: No such file or directory

    Can anyone help please ?

    Thanks,
    Matt

    ReplyDelete
  19. Hi! Thank you for this amazing tutorial. I'm having a problem tho. When I try to run the "Sample-PointViewer", it works for like 10 sec then it crashes. Then I try to re-run it and it gives me errors like these :

    iMac-de-Stephane:x64-Release Stouf$ ./Sample-Players
    5736 INFO New log started on 2013-05-05 19:59:46
    5754 INFO OpenNI version is 1.5.4 (Build 0)-MacOSX (May 16 2012 10:22:59)
    5758 INFO --- Filter Info --- Minimum Severity: UNKNOWN
    InitFromXml failed: USB device not found!
    iMac-de-Stephane:x64-Release Stouf$ ./Sample-Players
    573 INFO New log started on 2013-05-05 20:00:16
    590 INFO OpenNI version is 1.5.4 (Build 0)-MacOSX (May 16 2012 10:22:59)
    594 INFO --- Filter Info --- Minimum Severity: UNKNOWN
    One or more of the following nodes could not be enumerated:

    Device: PrimeSense/SensorKinect/5.1.2.1: The device is not connected!
    Device: PrimeSense/SensorV2/5.1.2.1: The device is not connected!
    Device: PrimeSense/SensorV2/5.1.2.1: The device is not connected!

    Seems like there are a few problems with the USB ports. I tried to re-installed them but it still doesn't work. Any ideas ?

    Thanks

    ReplyDelete
  20. Excellent! Tks! Greetings From Colombia

    ReplyDelete
    Replies
    1. Setup
      Kinect XBOX 360 (didn`t run with Kinect4Windows)
      OSX Mavericks

      Delete
    2. Alquiler, thanks for the advice! I forgot to put this information. I'll put it in the title. ;)

      Delete
  21. Hi Thank-you for posting this. Amazing.

    Just some minor errors in the copy that included an extra space before the forward slash for these commands in these sections posted that prevented it from working initially:

    Install SensorKinect and Install PrimeSense NITE

    sudo ./install.sh

    and

    For "Run one of the examples of NITE."

    ./Sample-PointViewer

    ReplyDelete
  22. OSCeleton installed ok but got "MotionCapture3D" in Processing error. "Cannot find class or type named "hashtable"

    ReplyDelete