Tuesday, February 8, 2011

Running Dominant Orientation Templates on MAC OS X

Update: Recently, ESM library is released for Mac OS X platform. But I didn't apply it to my XCODE project yet. You can find it on the ESM tracking library web page.

"Dominant Orientation Template" (DOT) proposed by Stefan Hinterstoisser et al.  is a very robust approach to detect object in an image. One of interesting part of DOT is that it does not use any feature point detections, which are commonly used for object detection / tracking in computer vision.  The authors released the source code here .

The source code provides MS VS2008 solution and it works well if some dependencies are satisfied (OpenCV, Intel IPP, and ESM tracking library). Running DOT on Mac OS X is not difficult. What we have to do is installing dependencies and creating an XCODE project.
  • OpenCV : available in source code or can be installed via MacPorts
  • Intel IPP: On Mac OS X, IPP is included in Intel C++ Composer XE 2011 for Mac. You can download an evaluation version from Intel's website. Installation is straightforward and just follow the instructions. 
  • ESM tracking library: Actually, the ESM library is not really necessary for DOT but the authors use it for template verification and pose estimation of the patch in case of a 2D planar target.  Unfortunately, ESM library is not released for Mac OS X currently so that we need to remove ESM-related codes from the DOT source code later. 
Once dependencies are installed, we have to make an XCODE project. Open XCODE and create a command line project. Then add DOT source codes and library files of dependencies as shown in below.

I installed OpenCV 2.2 from MacPorts and added .dylib files. For IPP, I added static library builds (.a) instead of dynamic linking library files (.dylib).  Both of them are in /opt/intel/composerxe-2011.x.xxx/ipp/lib. Make sure that search paths for IPP headers and libraries are set in the XCODE project settings if XCODE cannot find them.

Refer the screenshot to see files required for DOT. The cv_camera class in DOT source code works well with the built-in iSight. But the image is captured as 1280x1024 by default. To make the size 640x480, I modified the cv_camera.cc file as follows.

bool cv_camera_usb::set_capture_data( int a_width, int a_height, double a_fps )
#ifdef WIN32

mp_cam = cvCaptureFromCAM(0);
    cvSetCaptureProperty( mp_cam, CV_CAP_PROP_FRAME_WIDTH, 640 );
    cvSetCaptureProperty( mp_cam, CV_CAP_PROP_FRAME_HEIGHT, 480 );

 if( mp_cam != NULL )
      m_run = true;
      m_run = false;

return m_run;


Another modification I made is removing all the parts related to ESM library and it is not that much difficult. Finally DOT runs well on my Mac. 


  1. Hi,
    Have you managed to add the ESM library yet? Because I tried, but kept on getting this error "ld: warning in resources/ESM/ESMkit/lib/ESMlib.a, file is not of required architecture", I tried the -m64, -arch x86_64 flag, but they didn't work.

    1. No need esm library, just a little modification in main function.

  2. Hello Irwandi.

    At last time I checked, it was not clear how the ESM library released for MAC OS is built (32/64 bits, universal binary or not..). I just tried a sample code included in the ESM library release and didn't try it with DOT yet.

  3. Hi,

    Have you managed to make it works for main_dot3D.cc as well?
    Mind sharing changes to code?


  4. Hello, Wandasana.

    I haven't tried main_dot3D.cc yet. But maybe it's not that difficult.

  5. Hello Wonwoo,

    I am a student who studies HCI in University of Michigan. Currently, I am playing around image object recognition on my iphone and tried several methods such as SIFT/SURF, Haar-like feature. I bumped into you blog and found this post very useful. I have followed your instruction and try to port this project on my mac, but I got a bunch of error, such as "ld: warning: ignoring file /Users/xxxxx/Documents/iOSDev/DOT/OpenCV.framework/OpenCV, missing required architecture x86_64 in file".

    Can you give me any advice about how to get rid of those errors, or if it is possible that you can share me your project file? Thank you.


    1. Hello Yujen.
      It seems that your OpenCV.framework does not contain libraries built for OSX-64bit.
      Did you build the target for MacOS or iOS ?

    2. I build the target for MacOS, but will plan to implement it on iOS later.

    3. The OpenCV.framework you are using is just built for iOS, I guess.
      If you use a pre-built OpenCV.framework for iOS, you need to build the OpenCV library for Mac OS X-64 bit and link it with the target.

    4. It's link error, it works now, thank you.

  6. Have you tried to run it on Windows? I'm getting this run-time error:The application was unable to start correctly (0xc000007b). I know that there is something wrong with the way that I'm using IPP but so far I couldn't figure it out.

    1. Yes, the code worked well on my Windows machine. But I didn't try the recent code included in OpenCV.

    2. Thank you for your answer. Well, I am using the original code provided by the author as well. Did you run the code on Windows 64bit? cause I'm running it on 64bit version.
      Can you briefly explain how you are including and linking all necessary IPP files in the program? Right now I,m running an empty main function but it keeps giving me that error. I deleted all functions in cv_utilities.cc file and surprisingly It ran! So, I think there is something wrong with functions which are using IPP (maybe they are written for 32bit windows, sorry I have no idea about have IPP works).
      I'm running the program in Visual Studio 2010 and in 32bit Platform (because ESM library works only for 32bit).
      I really need it to make it run. I appreciate your help.

    3. Unfortunately I didn't try it on a 64-bit machine.

  7. I am run the DOT in MS VS2015 solution.There have some problem,like this "LINK : fatal error LNK1104: 无法打开文件“cv200.lib”!
    What's the reason for that?