2010-12-24

libfreenectをiOS用にビルドしてみる

まずiOS SDK 4.2用にIOKitのヘッダを準備。


$ sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/IOKit.framework/Headers /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/IOKit.framework


libusbとlibfreenectのソース取得とパッチ


$ ftp -o - "http://git.libusb.org/?p=libusb.git;a=snapshot;h=7da756e09fd97efad2b35b5cee0e2b2550aac2cb;sf=tgz;js=1"|tar xzvf -
$ git clone git://github.com/OpenKinect/libfreenect.git
$ cd libusb-7da756e
$ patch -p1 < ../libfreenect/platform/osx/libusb-osx-kinect.diff


libusb configureとビルド

configure-iphone.sh をファイルに保存


$ sh autogen.sh
$ sh configure-iphone.sh
$ make


libfreenectのビルド


$ cd ../libfreenect/src
$ ln -s ../../libusb-7da756e/libusb ../include/libusb-1.0
$ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 -march=armv6 -miphoneos-version-min=3.1.3 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk -I../include -c *.c
$ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar rcu libfreenect.a *.o


libusb-7da756e/libusb/.libs/libusb-1.0.aと、libfreenect/src/libfreenect.aの出来上がり。

まだ実行ファイルとしてlinkしてませんので何か足りないかもしれません。



言うまでもないことですが、App Storeの審査には通りません。

2010.12.27 追記
iPad 4.2.1だと、Kinectは消費電力が大きすぎる、というエラーで接続できませんでした。iPad 3.2に戻すこともできず。