OpenCV 2.0 on SnowLeopard 64bit via MacPorts

Updated 1/17/10: The Portfile now includes a “+disable_openmp” variant. I encountered some OpenMP related segfaults in cvCalcOpticalFlowPyrLK which can be prevented with this variant.

In case you need OpenCV 2.0 on SnowLeopard in 64bit and can live without quicktime support (OpenCV 2.0 it has FFMPEG support so you should be OK in most cases) this tutorial is for you.

In case you want OpenCV 2.0 in 32 bit on 10.5 this probably works too, but I haven’t tested it. Just download the attached “Portfile” and follow the short steps underneath:

  1. Before starting execute
    sudo port selfupdate
    so that the most recent dependencies will be installed later on. Otherwise the build might fail.

  2. Make your own port directory somewhere, e.g.
    /Users/sam/ports
  3. Let macports know about it by editing sources.conf, e.g.
    > cd /opt/local/etc/macports
    > sudo vim sources.conf
  4. Add the local port directory to the sources.conf before the rsync:// at the bottom of the file, e.g.
    file:///Users/sam/ports # That is 3 slashes after file ;)
  5. Create a graphics/OpenCV subfolder so that we have in our example
    /Users/sam/ports/graphics/OpenCV
  6. Copy the downloaded Portfile into the above directory, make sure it is called Portfile not Portfile.txt
  7. Execute portindex in your local port directory, e.g.
    > cd /Users/sam/ports
    > portindex
    You should see a message telling you that the total number of parsed ports is 1
  8. Check if OpenCV 2.0 is found
    > port search OpenCV
  9. Install OpenCV via
    > sudo port install OpenCV
    or on SnowLeopard in 64 bit but without quicktime support
    > sudo port install OpenCV +sl_64bit
  10. Enjoy the time you have saved by not having to implement the algorithms in the new MachineLearning package all by yourself ;)

Download Portfile

Simple OpenGL ES 2.0 iPhone example

I had quite a hard time to find a good starting point for OpenGL ES 2.0 development on the new iPhone 3GS. That’s why I thought it might be helpful to share the simple framework I put together here.

The application is pretty much a 1-1 port of the standard OpenGL ES 1.1 example that ships with Xcode but uses shader for transforming vertices and coloring fragments. I added a ShaderProgram interface that allows to load shader from the application bundle (they have to be included in Targets -> Copy Bundle Resources.) For setting up the projection and modelview matrix I used the code available with the OpenGL ES 2.0 Programming guide [Munshi et al. 2008] but I removed all the ESContext calls because the SDK has already its own EAGLContext. One could switch out the matrix multiplication functions and add a matrix inversion routine from the vfpmathlibrary but that’s not really necessary for this simple example.

The two main function for customization are EAGLView::initView and EAGLView::updateView.

I updated WordPress and the link should work again!
Source:   shader_example.zip