Kinect Test
<< Kinect Resource
This page list the steps I took to test Kinect on Mac OS X. The aim is to make it work on Mac OS X in a programmer-friendly way to quicken the development in higher level (HCI, gesture recognition, and image processing). I combined sources from various open source projects (see Acknowledgement section). This page is currently maintained by Chat.
Framework is available in the internal git:
git clone ssh://oliver.informatik.rwth-aachen.de/Public/Research%20Projects/Kinect/Code/KinectFramework.git
Relatively Stable Stuff
- 14.11.10: KinectFramework (32-bit, 64-bit, Source) Changed depth image to RGB to cover 16-bit data of the depth.
- 14.11.10: KinectFramework example (64-bit App Bundle, Source) Changed display to NSImageView which is faster than IKImageView.
Latest Hackaround
- 14.11.10: KinectFramework (32-bit, 64-bit, Source) Changed depth image to RGB to cover 16-bit data of the depth.
- 14.11.10: KinectFramework example (64-bit App Bundle, Source) Changed display to NSImageView which is faster than IKImageView.
* 14.11.10: KinectFramework—the first attempt to create a newbie-friendly OS X flavor framework. The framework connects to one Kinect and feed CGImageRef of depth and RGB to the designated delegate. (Framework, Example Project, Source) (x86_64 only, for i386 use the source project and change libusb1.0.dylib to the 32-bit version)
* 13.11.10: qdot published a patch for Mac OS X to improve USB buffering. It runs nicely now. (video)
* 12.11.10: I tried to be independent of cmake and libusb, because I don't like the fact that the developer have to go though painful steps of installing and making. The immediate result is a hacked-around Xcode project that include libusb.dylib and OpenKinect. Note that all codes belongs to the respective contributor, I just try to pack it up such that it is less painful for academic mac developers. Please don't sue me. Xcode Project.
** Usage: Open Xcode project, build, and run. If you are on Mac OS X 10.5, replace the libusb.dylib with libusb.dylib-32bit. You don't need to install CMake or libusb on your system.
A Hard, But Legal Way
Software
- CMake
- libusb 1.0.8 get it by: git clone git://git.libusb.org/libusb.git (downloading the zip from Sourceforge won't work)
- OpenKinect project (reference commit: a676d10a8a01fcbff8d2)
All software are cached on oliver/Software/Device Dependent Software/Kinect
Compiling
Below libusb stands for the root of LIBUSBPATH source, and OKPATH stands for the root of OpenKinect source
- Install CMake. (I use the binary version.)
- patch libusb
cd LIBUSBPATH
patch -p0 < OKPATH/platform/osx/libusb-osx-kinect.diff
- compile and install libusb
cd LIBUSBPATH
./autogen.sh
make
sudo make install
- Since the previous step doesn't install the header files. (I don't know how to do so.) I have to manually tell cmake where the header file is. Also note that I chose to generate Xcode project by passing "Xcode" after -G. If you want to generate a UNIX Makefiles, you can pass "Unix Makefiles" instead.
cd OKPATH/c
mkdir build
cd build
cmake -D USB_INCLUDE_DIR=LIBUSBPATH/libusb -G Xcode ..
- The interactive screen of ccmake will appear. Press "c" once to start configure. Then, press "c" again when it prompt you for some reason. Lastly, you will be able to press "g" to generate.
- At this stage, you should have either Xcode project or makefiles in build folder.
- Xcode: open the project in the Xcode, go to the Project properties, change Base SDK to Current Mac OSX. Select glview as a target, run. :)
- Make file: use "make all" to build the project. You will get the binary in some subfolders inside. You can run it by ./glview (for example)
Readings
- How You Become the Controller a less technical introduction to Kinect.
Acknowledgement
- Thanks to OpenKinect and its ancestor projects (libfreenect).
- Thanks to libusb for relatively painless USB communication.
- Thanks Alireza Sahami for helping in late-night hacking.
TODO
Clean up this important note about libusb linking in framework
• change dylib id to the path you plan to put it
install_name_tool -id @loader_path/Libraries/libusb-i386.dylib libusb-i386.dylib
Here: @loader_path is referred to the path where binary resides. If you are embedding the library in the framework, @loader_path is the path of framework binary, e.g., "xxx.framework/Versions/A/". If you are embedding the libaray in the application, this will looks like "xxx.app/Content/MacOS"
• add the dylib to "Link Binary With Libraries" build phase
• add the dylib to a new "Copy Files" build phase. Configure the subdirectory to where inside the bundle you want to put dylib in.
Useful tools:
otool -L: for listing the linked library paths
install_name_tool: for modifying the id and paths referred to by a binary
References:
- http://qin.laya.com/tech_coding_help/dylib_linking.html
- http://www.codeshorts.ca/2007/nov/01/leopard-linking-making-relocatable-libraries-movin
- New: A great tutorial on setting up Kinect for Mac OS X (Mavericks and newer): http://blog.nelga.com/setup-microsoft-kinect-on-mac-os-x-10-9-mavericks/. If you are following the instructions on this page, you will run into issues when installing OpenNI SDK. To overcome the issue, you need to disable System Integrity Protection, which was added in El Capitan. More details here: https://creativevreality.wordpress.com/2016/01/26/setting-up-the-kinect-on-osx-el-capitan/