How to compile PTAMM on MacXOS

Doing some research I stumble upon PTAM libraries developed by Georg Klein. It´s a camera tracking system for augmented reality that don´t requires markers, pre-made maps, known templates, or inertial sensors. Nice isn´t it?

In order to install on MacOSX you need to following the next steps.
Start by geting some basic stuff you are going to need.


sudo port install cvs git-core libpng lib3ds libdc1394 +universal

Then let´s get a copy of the last TooN, libcvd and gvars3 libraries.

cvs -z3 -d:pserver:anoncvs@cvs.savannah.nongnu.org:/cvsroot/toon co TooN
git clone git://git.savannah.nongnu.org/libcvd.git
cvs -z3 -d:pserver:anoncvs@cvs.savannah.nongnu.org:/cvsroot/libcvd co gvars3

Then download the PTAM libraries from http://www.robots.ox.ac.uk/~gk/PTAM/ and unzip it on the same directory you are using for the other three libraries.
On your libcvd directory you will find a script call configure_osx_32bit . Copy it on gvars3 directory

cd libcvd
cp configure_osx_32bit ../gvars3

Install TooN by:

cd ../TooN
./configure
sudo make install

Open libcvd/progs/video_play_source.cc with an editor. In line 173 change GL_TEXTURE_RECTANGLE_NV for texTarget . It should look like this:

        // ... bla bla
        new_frame=1;
        glTexImage2D(*frame, 0, texTarget);
    }
    // ... bla bla

Open PTAM/Build/OSX/Makefile with an editor and change you COMPILEFLAGS an LINKFLAGS to look like this ones:

COMPILEFLAGS = -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -L /usr/local/include -m32 -D_OSX -D_REENTRANT                                                  
LINKFLAGS = -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -L /usr/local/lib -m32 -framework OpenGL -framework VecLib -lGVars3 -lcvd

Configure and libcvd, gvars3 and PTAM directory.

cd libcvd
./configure-10.5-32bit
make -j3 
sudo make install
cd ../gvars3
./configure-10.5-32bit
make -j3
sudo make install
cd ../PTAM
cp Build/OSX/* .
make -j3

Before runing ./PTAM you probably want to calibrate te camera. In order to that print the calibration pattern, run the ./CameraCalibrator. Take some sanpshoots, optimize and save.

That will see that a file call camera.cfg it´s going to apear. That will le you run PTAM correctly and smoothly.

Once you start playing with PTAM you probably want more stuff. What´s next? Robert Castle make some nice advances to PTAM on a librarie call PTAMM. The sources and nice videos could be found at http://www.robots.ox.ac.uk/~bob/software/index.html .
Once you download and unzip ptamm.zip you have to open once againg PTAMM/Build/OSX/Makefile with an editor and change you COMPILEFLAGS an LINKFLAGS to look like this ones:


COMPILEFLAGS = -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -L /usr/local/include -D_OSX -D_REENTRANT -m32
LINKFLAGS = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -L /usr/local/lib -framework OpenGL -framework VecLib -lGVars3 -lcvd $(3DSLIB) -m32

Then copy the Makefile to the main directory of PTAMM and compile

cd ../PTAM
cp Build/OSX/* .
make -j3

Share

8 thoughts on “How to compile PTAMM on MacXOS

  1. Thanks a lot for the article!

    I tried to compile PTAM on mac 10.6 but I keep getting this error.

    
    GLWindow2.cc: In member function ‘void GLWindow2::SetupWindowOrtho()’:
    GLWindow2.cc:117: error: cannot convert ‘CVD::ImageRef’ to ‘GLdouble’ for argument ‘1’ to ‘void glOrtho(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)’
    

    Tried to rebuild libcvd as in this troubleshoot guide, but still no luck.

    Any idea on how to solve this?

    Thanks!!

  2. Hola Patricio como andas? Te hago una consulta, estoy compilando las librerias PTAM & PTAMM en osx 10.6 y cuando estoy en el paso de:

    cd libcvd
    ./configure-10.5-32bit
    make -j3

    no logra terminar el proceso y me tira este error:

    cvd_src/OSX/qtbuffer.cpp:148: error: ‘vector’ was not declared in this scope
    cvd_src/OSX/qtbuffer.cpp:148: error: expected primary-expression before ‘int’
    cvd_src/OSX/qtbuffer.cpp:148: error: expected `;’ before ‘int’
    cvd_src/OSX/qtbuffer.cpp:151: error: ‘allowedDevices’ was not declared in this scope
    cvd_src/OSX/qtbuffer.cpp:156: error: ‘allowedDevices’ was not declared in this scope
    cvd_src/OSX/qtbuffer.cpp:159: error: ‘allowedDevices’ was not declared in this scope
    cvd_src/OSX/qtbuffer.cpp:191: warning: array subscript has type ‘char’
    make: *** [cvd_src/OSX/qtbuffer.o] Error 1
    make: *** Waiting for unfinished jobs….

    Tenes idea que puede ser?

  3. Patricio,

    Great guide! It’s working perfectly.

    There’s something wrong though: there is an error in the makefile’s COMPILEFLAGS edition… should be like this:

    COMPILEFLAGS = -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -I /usr/local/include -D_OSX -D_REENTRANT -m32
    LINKFLAGS = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -L /usr/local/lib -framework OpenGL -framework VecLib -lGVars3 -lcvd $(3DSLIB) -m32

    Also, after doing this, camera calibrator was not working yet. I had to open VideoSource_OSX.cc and edit line 24 in order to make it work:

    pvb= new QTBuffer(ImageRef(640,480), 0, true);

    this line should be like:

    pvb= new QTBuffer(ImageRef(640,480), 0, false);

    Thanks and I hope you all get lucky and make it work!!!

  4. This tutorial is really helpful. However, I am using Lion 10.7.4. Following the steps I got the error

    ignoring file /Developer/SDKs/MacOSX10.6.sdk/usr/local/lib/libstdc++.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

    Seems there is no i386 support in 10.7.0 in libstdc++.dylib. Has anybody built PTAM on 10.7 already? How to fix this?

    Thank you!
    Ben

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>