So you have a MacBook (or something else that runs OSX) and you want to play with the Kinect sensor, but you’re having trouble because there are about 1 billion sets of wrong instructions on the internet on how to connect this Kinect. Let me save you a little grief.
Hardware
I have the Kinect “v2”, aka Kinect for Xbox One, aka Kinect for Windows, aka (in my case) Model 1520. The instructions below work for my version. The only serious difference if you have the older Kinect should be that you use a different version of libfreenect, but I haven’t tested that.
Software
You have more than one option as far as software goes. If you’re a commercial developer, you might consider trying out Zigfu’s ZDK, which has an OSX-ready image and integrates with several modern packages, including Unity3d, out of the box.
If you’re more of a hobbyist (as I am at the moment) and don’t have the $200 for a Zigfu license, the lovely folks behind the Structure Sensor have taken on maintenance of the OpenNI2 library, including a macOS build. Your first step should be to download the latest version of that library and unzip it somewhere.
Unfortunately, their package isn’t quite complete, and you’ll also need a driver to connect the Kinect (I know, it’s getting old to me too). This is where our ways may diverge, gentle reader, for in my case I discovered that I needed OpenKinect’s libfreenect2, whereas an older sensor would require libfreenect.
Assuming that you’re using the XBox One sensor, you’ll want to read the README.md that comes with your copy of libfreenect2. It contains all the necessary instructions for getting the right tools + dependencies and building all the things.
There are two additional things that are currently left out of their readme file. The first is that when you want to use the OpenNI2 tools, you’ll need to copy the drivers from
libfreenect2/build/lib
into
{bin-folder}/OpenNI2/Drivers
for whatever you’re running. So to run NiViewer, which is in the Tools folder, you’d copy it to
{openni-base-folder}/Tools/OpenNI2/Drivers
I expected the “make install-openni2” command from libfreenect2’s readme would take care of that stuff, but it does not.
The second omission is the troubleshooting stuff on their wiki. In particular, for my specific MacBook, I had to plug the Kinect adapter into the USB port on the left-hand side, NOT the right-hand side, as the device requires USB3, and I had to run Protonect and NiViewer using the “cl” pipeline. The default pipeline setting can be changed by doing this:
export LIBFREENECT2_PIPELINE=cl
You can also pass in the pipeline for Protonect:
bin/Protonect cl
With that setting in place, you should see a window with 2 (NiViewer) or 4 (Protonect) windows, each capturing different parts of the raw Kinect stream:
From here you’re on your own, but I hope you found this at least a bit helpful!
Thanks for sharing your knowledge. Really st8 forward. I have one question. I am buying the kinect 1520 model. Do i have to buy anything else regarding hardware ( kinect adapter?)
Thank you in advance
Hi Alex, you will indeed need to buy the Kinect adapter in order to connect to a Mac or PC. Good luck with your projects!
I’ve followed all instructions and Protonect works as it should, but NiViewer and all the sameples always exit with this error message:
dyld: Library not loaded: libOpenNI2.dylib
Referenced from: /Applications/OpenNI-MacOSX-x64-2.2/Tools/NiViewer
Reason: image not found
Abort trap: 6
I’ve looked at github.com/OpenKinect/libfreenect2/wiki/Troubleshooting where it says that’s a known problem whith Macs running nVidia cards, but mine is running with an AMD GPU.
Hey Daniel,
Sorry for the long lag. Hopefully you’ve solved your issue, but have you tried creating a /Applications/OpenNI-MacOSX-x64-2.2/Tools/NiViewer/Drivers folder and put the libOpenNI2.dylib file inside?
Thanks for sharing. I have a question: when i digit
cmake ..
In the terminal, it return
“User/my-pc-name” does not appear ti contain CMakeLists.txt”
Can you help me please?
Hi, i’m solved the previous problem by typing:
cmake .
then i install openni2 and i used the cl pipeline, but the result is:
MBP-di-Roberta:libfreenect2 robibba$ make install-openni2
[ 5%] Built target generate_resources_tool
[ 75%] Built target freenect2
[100%] Built target freenect2-openni2
Scanning dependencies of target install-openni
[100%] Built target install-openni2
MBP-di-Roberta:libfreenect2 robibba$ ./bin/NiViewer
-bash: ./bin/NiViewer: No such file or directory
MBP-di-Roberta:libfreenect2 robibba$ NiViewer
-bash: NiViewer: command not found
MBP-di-Roberta:libfreenect2 robibba$ export LIBFREENECT2_PIPELINE = cl
-bash: export: `=’: not a valid identifier
MBP-di-Roberta:libfreenect2 robibba$ export LIBFREENECT2_PIPELINE=cl
MBP-di-Roberta:libfreenect2 robibba$ bin/Protonect cl
Version: 0.2.0
Environment variables: LOGFILE=
Usage: bin/Protonect [-gpu=] [gl | cl | clkde | cuda | cudakde | cpu] []
[-noviewer] [-norgb | -nodepth] [-help] [-version]
[-frames ]
To pause and unpause: pkill -USR1 Protonect
[Info] [OpenCLDepthPacketProcessorImpl] devices:
[Info] [OpenCLDepthPacketProcessorImpl] 0: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (CPU)[Intel]
[Info] [OpenCLDepthPacketProcessorImpl] 1: Iris Pro (GPU)[Intel]
[Info] [OpenCLDepthPacketProcessorImpl] selected device: Iris Pro (GPU)[Intel]
[Info] [OpenCLDepthPacketProcessorImpl] building OpenCL program…
[Info] [OpenCLDepthPacketProcessorImpl] OpenCL program built successfully
[Info] [Freenect2Impl] enumerating devices…
[Info] [Freenect2Impl] 5 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @20:14 with serial 038487534347
[Info] [Freenect2Impl] found 1 devices
[Info] [Freenect2DeviceImpl] opening…
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 4*128*33792
[Info] [Freenect2DeviceImpl] opened
[Info] [Freenect2DeviceImpl] starting…
[Debug] [Freenect2DeviceImpl] status 0x090000: 9729
[Debug] [Freenect2DeviceImpl] status 0x090000: 9731
[Info] [Freenect2DeviceImpl] submitting rgb transfers…
[Info] [Freenect2DeviceImpl] submitting depth transfers…
[Info] [Freenect2DeviceImpl] started
device serial: 038487534347
device firmware: 4.0.3917.0
Can you help me please?
I’m not sure what exactly you’re having trouble with. This part:
appears to be caused by a simple missing file. Create a folder called “bin” in the run location and then copy the NiViewer executable into it. Protonect appears to have started correctly. I’ll need more details to help out.