Swiss Developer Immigrated to Germany

How to setup OpenCV with Xcode

Lately I used OpenCV with an Xcode project. Maybe someone else needs it too, so i thought I’ll write down what I had to do to get get running.

The easiest way to install OpenCV on mac os x is with homebrew.

  1. brew install opencv

    This should install all the opencv libs. I had some error coming up about a missing fortran compiler so I had to do a

    brew install gfortran

    and then

    brew install opencv


  2. Create a new Xcode project and add the paths to OpenCV to the header search paths and the library search paths. (Already configured in the attached project)
    HEADER_SEARCH_PATHS = /usr/local/Cellar/opencv/2.4.2/**
    LIBRARY_SEARCH_PATHS = /usr/local/Cellar/opencv/2.4.2/**
  3. Set the linker flags for the required libs.  (Already configured in the attached project)
    OTHER_LDFLAGS = -lopencv_core -lopencv_highgui -lopencv_imgproc
  4. If you now build the project, there will be an error in ‘lsh_table.h’. Replace the line with the error: “if (!used_speed_) buckets_…” with the following:
    buckets_space_.rehash((buckets_space_.size() + dataset.rows) * 1.2);

That’s it we’re done!

Here is an Xcode project that has step 2 and 3 already configured.

Comments are closed.