Tag Archive: XCode


3 days learning and we have an iPhone App!

It didn’t take anywhere near as long as I thought.  I have two versions at the moment.  One which doesn’t work and crashes a lot but has pretty graphics/labels and one which implements OpenCV stuff but is still using place holders.  The crashes aren’t related, I started from scratch again today because  the OpenCV libraries needed testing.  So here’s a screen capture:

iPhoneSimulator

What’s happening here is that I can’t use the camera as the code is not signed and the iPhone Simulator is exactly that.  It’s not an emulator and thus cannot do all sorts of things, like say use a Mac’s built in camera.  So we select an existing photo (which I downloaded into the simulator using safari and browsing the local file system), what happens next is that the subsequent page does all of the processing whilst it loads the view.  This explains the minor delay.  What is also happening here so I can test things is that the initial image is displayed in the view but also added as the first frame of an animation.  Each subsequent processing step is added as another frame.  When the view is loaded the place holder button in the top right fires off a function that plays the animation over 5 seconds so I can get an overview of the image processing before progressing the application.  Simple?

It’s been frustrating but I really don’t think it’s bad to go from buying a Mac on Wednesday to having working iPhone code using external C++ based libraries in 3 days.  That includes learning Objective C, the iPhone API and a bit more of XCode although I have used it before.  Also gdb, which I ♥.  If I had to thank all the people who wrote tutorials and made video examples this would be a rather long article but I’ve thanked people on their blogs where they’ve given me major insight.

Setting up OpenCV for Xcode + iPhone

** This post will be updated as I progress **
*** This will be updated when I’ve actually got an application to the point where OpenCV is necessary. It currently links and builds fine but I haven’t tested it so I’m loathe to update these instructions until I have. ***

CMake

You need this to compile the newer versions of OpenCV.  Download it here:

http://www.cmake.org/cmake/resources/software.html

Extract and simply run ./configure.  In snow leopard this works and boot straps cmake.  I then simply ran:


Paul-Downss-MacBook-Pro:Programming diziet$ cd cmake-2.8.2/
Paul-Downss-MacBook-Pro:cmake-2.8.2 diziet$ ./configure
Paul-Downss-MacBook-Pro:cmake-2.8.2 diziet$ make && sudo make install

I did this as I don’t mind cmake installing into /usr/local/.

OpenCV

This is the doozy.  I believe that in order for this to work under the iPhone I need it built as a static library with as much as possible turned off  or built as a framework.  I have no idea how to do this and the online docs are out of date with the current cmake based build process.  Here goes…

I bet you’re glad you can’t see all the mistakes. I had to give up on getting the 2.1+ versions of opencv to compile. The CMake process, despite spitting out an XCode project, just would not happily cross compile and threw up countless QTKit/QuickTime framework and other errors involving carbon and all sorts.

So this is stealing some scripts etc. from:

http://niw.at/articles/2009/03/14/using-opencv-on-iphone/en

and adapting it to work with the latest iPhone dev and xcode. I hope using 2.0 opencv means I don’t have to change too much of my old code. In other words, you don’t need the CMake utility mentioned above any more.

Powered by WordPress | Theme: KLG based on Motion by 85ideas.