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 , ,

21 thoughts on “Installing OpenKinect and OpenCV the easy way on a Mac

  1. Matt Perkins says:

    Thanks for posting this! I’m thinking about a project to start learning Objective-C and working with a Kinect seems like a good project.

  2. jamesreuss says:

    Nice 🙂 I have to say though, if you are beginning to learn Objective-C I don’t recommend learning to interface it with the Kinect yet, it’s proper tricky! I practiced learning Objective-C for a few months first before I tackled the Kinect. But I suppose it does depend on your experience with other programming languages like C and C++ (these will help lots). Good luck with all this anyways.
    I think once I have completed this project and learnt how to properly use the Kinect drivers, OpenCV and PCL I will create a few Mac Objective-C classes for other people to quickly include the Kinect in their projects.

  3. aem says:

    Thanks for the simple post on this — Quick question:
    I’m running OSX 10.7.3, have installed OpenKinect via HomeBrew but am having a linking problem in Xcode 4; both Cocoa and Command Line Applications fail to find the libfreenect library. I have tried a couple different configurations of linking directives, trying to force Xcode to see the files in the HomeBrew Cellar, to no avail. Any suggestions?
    Thanks in advance,

  4. cory says:

    Each time I try to run I get an error saying that it “could not open kinect”. Any ideas??

    • jamesreuss says:

      Have you definitely attached the external power supply and turned it on? Also USB3 can cause problems if you’re using one of them ports.

      Also, is this using the glview program?

      • cory says:

        I have it all powered up correctly. I am running it on a retina MBP so maybe it’s the usb3 causing the issue?

        It is using your example program from github, not the glview one.

      • jamesreuss says:

        Hmm ok, I’ve had problems with my mac desktop + USB3 + Kinect before too, but other times it worked ok.

        How did you install it by the way? I’ve just looked through the libfreenect files and found out that the install process here is now out of date! But they have got the libfreenect formula in homebrew now!

      • cory says:

        I went back in to try and reinstall everything which I think some things may have been done wrong because now I am getting an error that “#import ” cannot be found. I have the library added to the project however, when I go to add libfreenect.dylib, it auto adds libfreenect.0.1.2.dylib instead. Is this correct?

      • jamesreuss says:

        Oh ok. Does `glview` work properly now?
        Which project is this by the way? I think I may know what it is.

      • cory says:

        ‘glview’ does not work properly now. I can’t get it to compile correctly. I’m just going install everything on a Windows machine. Seems so much easier, thank you for the help though!

      • jamesreuss says:

        Nooo! That is not nice to hear haha.
        This should install libfreenect for you:
        brew install

        If you have MacPorts install then this can cause serious problems.
        The above command should work as long as you have Xcode installed and the Xcode command line tools.

        Hope you get it working!

        Also the #import problem is due to header search paths. In your Xcode project, click on the project in the navigation bar, then Build Settings, click All and search for “Header Search Paths”. In this field type “/usr/local/include”. If you have the .dylib library file added to the project too then this should all work fine now.

      • Cory says:

        Haha I was trying to avoid Windows out of pure laziness. I’ve become complacent in only using obj-c/c++ for work and haven’t wanted to learn anything else. I’m going to give C# the good ole “collage try” and see if I can pick it up. If not ill jump back to OS X.

        Your tutorials were extremely helpful and the most well documented ones I could find for installing on Mac. Your example project is really well do also, thank you for taking the time to document/opensource it. I’ll keep you updated on my progress if I jump back over to Mac. Thank you again for the help and quick responses!!!

  5. Cory says:

    “college** try”, stupid auto type on iOS 😡

  6. fraco87 says:

    Hi, real thanks for these instructions. However, when I’m about to install OpenCV, the terminal gives me an error:

    Error: No available formula for opencv

    Any thoughts on why it isn’t recognizing this?

    • jamesreuss says:

      Hey fraco, I think that is probably because brew has had a bit of a shuffle since I did that post, and OpenCV is now in a different brew repository called homebrew-science.

      So, to get this working, you wanna tap into the science repo first. Like this:
      brew tap homebrew/science
      brew install opencv

  7. Diego Olalde says:

    Hi James! I really liked your post! Its simple and right on point. But I am having the following error message when I type glview:
    -bash: glview: command not found
    And according to terminal I have libfreenect installed. Do you know what could be causing this problem?

    • jamesreuss says:

      Hi Diego, thanks!
      Which instructions did you follow to install libfreenect? The ones on this page, the ones on my github page or the some others?
      To me it sounds like a PATH problem.
      What command did you use to confirm that you have libfreenect installed?
      Also try which glview in the terminal (but this will probably also fail)

      • Diego says:

        I used your github tutorial and libfreenect is definitely installed. Now I suspect the problem might be the kinect itself. Is it okay for the green light to be flashing? How do I connect it so that it isnt flashing?

        Thanks! Diego Olalde

  8. Diego says:

    Hi James! I was able to solve my issue! Thanks for the help!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: