P.hD Diary - PCL Installation and Configuration on OSX
As a part of my investigatory phase right now I was looking for good libraries that work good with Kinect. My personal computer is an old pacman Macbook Pro that is been very good thru all these years. In this post I’ll explain how to setup a Mac properly to use PCL libraries ( no nostalgic posts right now ). For more information about the library itself visit http://pointclouds.org/. This tutorial was done in a machine with OSX 10.10 ( Yosemite ), 4GB DDR3 memory and a Core2Duo Processor. Differences for different configurations may happen.
PCL Kinect Example
My biggest challenge here was to see which of the (old) tutorials [ 1, 2, 3, 4, 5, among others… ] I’ve found was technically right. Before anyone say that solve this in other way, I’d say that this was the simpler one that choose. I do love free libraries and collaborative softwares, but I prefer to get a very good closed and tested package with all the dependencies configured rather then compile all in a hard way. This solution tries to rely as much as possible in brew ( a package manager for OSX ), and cmake. There are other solutions that use macports and/or manual compilation. I found these harder than using brew.
Assumptions
I assume that everyone here has a Mac with Xcode installed and configured. Also, you must ( If you haven’t already ) have the Command Line Tools installed. If you don’t, download Xcode via App Store, then create a developer account at Apple Developer Website, go to the download section and get the pkg to install. Its installation is purely straightforward.
Brew Packages
Installing Brew
First things first, lets install brew. It pretty simple, just open a terminal window and type:
This will automatically get and install all the necessary binaries to run the package. After installing, I’ve made a simple config to use sudo with brew because of some permission errors I was having in my machine. This is totally optional, but if you face these problems just type:
Installing PCL Dependencies
Before installing PCL, there are some dependencies that you must install ( and make sure that they are properly linked ). They are:
- Boost 1.57
- Flann 1.8.4
- Qt 4.8.6
- GLEW 1.11
- VTK 6.1.0
- Openni 1.5.8 and 2
One of the good things of using a package manager is that is easy to find and trigger an installation of all these dependencies. In brew, you must “tap” two repositories and before installing these packages. The commands are:
It will download some git repositories with information about those packages. Finally, to install the dependencies just type:
It will take a long time, enjoy a good book in the middle time =)
PCL Install
Similar to the previous step, now we just have to tell brew to install PCL with the command:
Just a little parentheses here. The option “—HEAD” says that it gonna get the HEAD of PCL repository, which is now PCL 1.8. In their website, the downloadable version is 1.6. I had a lot of trouble using the 1.6 under Yosemite, so I do not recommend using it. The “–with-openni” option will assume that you’re gonna use this library with PCL ( which is optional, but mandatory if you’d like to use Kinect Viewer ).
Again, grab a good book and wait for a long compile time.
Post Configs
If everything went well ( and I hope it did ), there’s some post configs you must do. For OpenNi 2 libs you must export some environments vars using:
You might want to put these commands on your ~/.bash_profile as well to avoid doing this command again.
Building and Testing
Following the Kinect Example found in their site, and making some few modifications, lets make a simple test just to show Kinect’s video. Create a file called open_viewer_simple.cpp with the following code:
And also, a CMakeLists.txt in the same folder with the following content:
Another parentheses here. I added the IF(APPLE) section because somehow make was getting a different configuration for GLEW which broke the compilation. This block is to make sure the the flag “-lGLEW” is called instead of “-framework GLEW”. Since we’ve installed everything via brew, this is the right way to call GLEW library
Now let’s build everything. In a terminal type:
In the build folder you may have an executable called “openni_grabber”. Just execute it typing:
Conclusions
After a week of building PCL in many different ways, this was the one that worked and was easiest to reproduce. Since this is not clearly found in one tutorial, I thought it was worth of a blog post. I still have some issues related to the library, but I’ll may write it down in a future opportunity.
If you read until here, thanks! Leave a feedback in the comments, and see ya!