Monthly Archives: January 2012

Installing OpenKinect and OpenCV the easy way on a Mac

Edit: I now have a new slightly polished cocoa-freenect wrapper for use in your Kinect-Cocoa projects! Check out the postΒ here. On the repo there also new and improved installation instructions!

For ages I tried to find an easy way to install both libfreenect (OpenKinect) and OpenCV on my mac without having to follow loads of lines of instructions and getting lots of errors in the process.

So, after quite a while of searching around for an easy install, which didn’t involve me installing loads of different package managers, I came across these methods which work really nicely πŸ™‚

First, Install Homebrew, if you don’t have it already:

  • It’s super easy… just follow the instruction… GO!
  • That was crazy fast, now do one of these, or both, or none…


  • If you still have your terminal open type in (or copy and paste) these commands one at a time and press enter.
cd /usr/local/Library/Formula


curl --insecure -O ""
curl --insecure -O ""
brew install libfreenect
  • Then, once all thats finished you’re done for OpenKinect πŸ™‚ you can give it a test by typing this into the terminal (as long as your still in the install directory..)

OpenCV (2.3.1a):

  • Now, OpenCV is even easier again! Just type in (or copy and paste again) this command:
brew install opencv
  • This one takes a bit longer than OpenKinect…
  • And then, You’re all done!
  • You can close terminal now πŸ™‚

Now the last task. If you want to use these libraries in Xcode just follow these steps:

  • These instructions are for Xcode 4 by the way. Sorry Xcode 3 people, I started using Xcode from version 4.. But don’t worry Xcode 3 people, if you know what you’re doing then this is pretty much the same process as using the built in Mac libraries.
  • If your creating a Cocoa application it’s a little simpler:
    • Open your YourApp.xcodeproj file
    • Select the target you want to add it to, there will usually only be one
    • Then click “Summary”
    • And under “Linked Frameworks and Libraries” press the plus button
    • In the search field that shows up type in “libfreenect”
    • You will see all the libraries that begin with libfreenect. So now you can choose one πŸ™‚ I usually use libfreenect_sync because it is easier to use this in objective-c programs, from what I have seen so far. So select the latest version of it that shows up.
    • That’s it for that. Now to include it in your application code just type this #import <libfreenect/libfreenect_sync.h>
  • Now, if it isn’t a Cocoa application but a Console application do these things:
    • Open your YourApp.xcodeproj file
    • Select the target you want to add it to
    • Click on the “Build Phases” tab
    • Then under “Link Binary With Libraries” press the plus button
    • In the search field that shows up type in “libfreenect”
    • Now you can select which library you would like to use as I discussed in the second to last point of the Cocoa app method.
    • All done!

So now you should be all sorted with OpenKinect and OpenCV (the libraries when searching are called libopencv… there are quite a few tho, don’t really wanna go into what does what and what you need and all that… I don’t really know that myself just yet..)

Anyways, bye bye everyone

Tagged , ,

Making little bits of progress :)

So, at the moment I’m in the middle of my January exams 😦 so work on the project is taking a very far back seat. But I decided to a have a little go at making a few things tidier and do a little experimenting.

Firstly, I came up with a name! I decided on “KinectiCopter”. I thought Helicopter and Kinect and stuck the two together (if you didn’t realise).

I then thought up a few ideas for a logo/icon for my project/application and finally came up with (after a lot of time staring at the screen) the following logo πŸ™‚

KinectiCopter Icon Version 3

KinectiCopter Icon Version 3

After sorting a new icon for my KinectiCopter application I hadn’t made yet I was itching to do something, so I decided to put off revision a little more and began to make a new project which may well be the final one. I copied over all the work I had previously done on the Kinect into this project. So, I had my KCKinectController class which took care of the interface between the libfreenect_sync library and my objective-c program, and previous work where I had got the video and depth data to display using OpenGL/OpenCV.

I then couldn’t resist to get another OpenGLView class made, which instead of showing the user 2D images of video and depth, it showed the user a Point Cloud view of the scene. There was an example of this in the OpenKinect examples, so I had a long hard look at this to try and work out what it did and how and then I recreated it in my own program πŸ™‚

When building it it seemed to work fine except that the view seemed really zoomed out compared to the example and when I did zoom in things looked a bit like they were overlapping… I had a quick think and then decided instead of using my own KCKinectController class to get the depth and video data I would just go straight to libfreenct_sync and get the data from that. This seemed to fix everything! But why? No idea. But I do have a feeling that it has something to do with me converting the depth/video data to an IplImage for OpenCV and then converting it back to data.

So, I’m now thinking that instead of getting the controller to convert to IplImage and then to data, just get the controller to give the user the data it collected in the first place and then have some over methods for converting for when I want to use OpenCV.

Thats what I’ll try next πŸ™‚

Tagged , ,