PTAM on Ubuntu 14.04

This post is for compiling PTAM (Parallel Tracking and Mapping) on Ubuntu 14.04. As mentioned on the web, a cool guy published a set of script, patch, etc for PTAM easy-compile on Ubuntu and the files are available on this github. However, some of the file contains typo and therefore the compilation with the original files failed on my computer (Ubuntu 14.04).

I wrote a script and a patch file to enable the compilation. Save the following script as PTAM-linux-yuji.bash and the following patch file as YujiPTAM-r114-linux.patch in the same directory as README is saved. Then, type bash PTAM-linux-yuji.bash.

The script file is

#!/bin/bash

targettopdir=`pwd`/PTAM-work
pwdinfo=`pwd`

sudo apt-get update
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install liblapack-dev freeglut3-dev libdc1394-22-dev
sudo apt-get install liblapack-dev libblas-dev
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libv4l-dev 
sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev libpostproc-dev libswscale-dev libavdevice-dev libsdl-dev
sudo apt-get install libgtk2.0-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev 
sudo apt-get install mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev

mkdir -p $targettopdir

# TooN
pushd $targettopdir
git clone git://github.com/edrosten/TooN.git
cd TooN
./configure
make
sudo make install
popd

# libcvd
pushd $targettopdir
git clone git://github.com/edrosten/libcvd.git
cd libcvd
mv cvd_src/convolution.cc cvd_src/convolution.cc-original
cp $pwdinfo/hack/libcvd/convolution.cc cvd_src/convolution.cc
export CXXFLAGS=-D_REENTRANT
./configure --without-ffmpeg --without-v4l1buffer --without-dc1394v1 --without-dc1394v2
make
sudo make install
popd

# gvars3
pushd $targettopdir
git clone git://github.com/edrosten/gvars.git
cd gvars
mv gvars/serialize.h gvars/serialize.h-original
cp $pwdinfo/hack/gvars3/serialize.h gvars/serialize.h
./configure --disable-widgets
make
sudo make install
popd

# before you go further, re-arrange the dynamic libraries
sudo ldconfig

# PTAM main
pushd $targettopdir
unzip $pwdinfo/PTAM-r114-2010129.zip
patch -p0 -d . < $pwdinfo/hack/PTAM/PTAM-r114-linux.patch
patch -p0 -d . < $pwdinfo/YujiPTAM-r114-linux.patch
cd PTAM
cp Build/Linux/* .
make

exit 0

and the patch file is

--- PTAM/Build/LinuxMakefile	2014-09-23 16:44:15.979478461 +0900
+++ /home/charmie/PTAM-work/PTAM/Makefile	2014-09-23 16:41:31.574663222 +0900
@@ -6,8 +6,8 @@
 CC = g++
 # COMPILEFLAGS = -I MY_CUSTOM_INCLUDE_PATH -D_LINUX -D_REENTRANT -Wall  -O3 -march=nocona -msse3
 # LINKFLAGS = -L MY_CUSTOM_LINK_PATH -lGVars3 -lcvd
-COMPILEFLAGS = -D_LINUX -D_REENTRANT -Wall  -O3 -march=nocona -msse3 -I/usr/include/opencv-2.3.1
-LINKFLAGS = -L/usr/local/lib -lGVars3 -lcvd -lopencv_legacy -lopencv_core -lopencv_video -lopencv_highgui
+COMPILEFLAGS = -D_LINUX -D_REENTRANT -Wall  -O3 -march=nocona -msse3 -I/usr/include
+LINKFLAGS = -L/usr/local/lib -lGVars3 -lcvd -lopencv_legacy -lopencv_core -lopencv_video -lopencv_highgui -lGLU -lGL -llapack -lblas -lgfortran 
 
 # Edit this line to change video source
 VIDEOSOURCE = VideoSource_Linux_OpenCV.o
--- PTAM/Tracker.cc	2014-09-23 16:44:15.971478422 +0900
+++ /home/charmie/PTAM-work/PTAM/Tracker.cc	2014-09-23 16:06:21.312198996 +0900
@@ -19,6 +19,10 @@
 #include <fcntl.h>
 
 
+#ifndef WIN32
+  #include <unistd.h>
+#endif
+
 using namespace CVD;
 using namespace std;
 using namespace GVars3;
--- PTAM/Build/Linux/VideoSource_Linux_OpenCV.cc	2014-09-23 16:44:15.979478461 +0900
+++ /home/charmie/PTAM-work/PTAM/VideoSource_Linux_OpenCV.cc	2014-09-23 15:02:10.909105878 +0900
@@ -105,3 +105,4 @@
 *cap >> frame;
   conversionNB(frame, imBW);
   conversionRGB(frame, imRGB);
+}
\ No newline at end of file
Advertisements

14 thoughts on “PTAM on Ubuntu 14.04

  1. Thank you for this!
    But I have a question.
    During procedure, terminal says “File to patch: ”
    and terminal stoped.
    Do I have to type “YujiPTAM-r114-linux.patch”

  2. My comments looks information shortage

    the terminal says :
    patching file PTAM/Build/Linux/Makefile
    patching file PTAM/Build/Linux/Makefile.r114
    patching file PTAM/Build/Linux/VideoSource_Linux_OpenCV.cc
    patching file PTAM/CHANGELOG_kmd.txt
    patching file PTAM/CalibImage.cc
    patching file PTAM/CalibImage.h
    patching file PTAM/CameraCalibrator.cc
    patching file PTAM/EyeGame.cc
    patching file PTAM/System.cc
    patching file PTAM/Tracker.cc
    patching file PTAM/Tracker.h
    patching file PTAM/main.cc
    can’t find file to patch at input line 3
    Perhaps you used the wrong -p or –strip option?
    The text leading up to this was:
    ————————–
    |— PTAM/Build/LinuxMakefile 2014-09-23 16:44:15.979478461 +0900
    |+++ /home/charmie/PTAM-work/PTAM/Makefile 2014-09-23 16:41:31.574663222 +0900
    ————————–
    File to patch:

    I don’t know what to do next..
    If I skip this process, error comes up

    • Thanks for the feedback and yes it’s a bug due to my bad patch. As you reported, the patch file specifies the output file name by absolute path such as /home/charmie/… and this may be the cause of the error. It can be solved by changing the file name to relative path.

  3. Hi,I’m trying to install PTAM on ubuntu 14.04 and I have this error :

    /usr/bin/ld: GLWindow2.o: référence au symbole non défini «glColorMask» //usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [PTAM] Erreur 1

    Any suggestion please? And, thank you

      • Hi, Thank you for your feedback, I found the solution,I just had to add : LINKFLAGS = -L/usr/local/lib -lGVars3 -lcvd -lopencv_legacy -lopencv_core -lopencv_video -lopencv_highgui -lGLU -lGL -llapack -lblas
        to the Makefile,but I encounter another error : g++ VideoSource_Linux_DV.cc -o VideoSource_Linux_DV.o -c -I MY_CUSTOM_INCLUDE_PATH -D_LINUX -D_REENTRANT -Wall -O3 -march=nocona -msse3
        g++ -o PTAM main.o GLWindow2.o GLWindowMenu.o VideoSource_Linux_DV.o System.o ATANCamera.o KeyFrame.o MapPoint.o Map.o SmallBlurryImage.o ShiTomasi.o HomographyInit.o MapMaker.o Bundle.o PatchFinder.o Relocaliser.o MiniPatch.o MapViewer.o ARDriver.o EyeGame.o Tracker.o -L/usr/local/lib -lGVars3 -lcvd -lopencv_legacy -lopencv_core -lopencv_video -lopencv_highgui -lGLU -lGL -llapack -lblas
        VideoSource_Linux_DV.o: dans la fonction « VideoSource::VideoSource() »:
        VideoSource_Linux_DV.cc:(.text+0xcf): référence indéfinie vers « CVD::DV3::RawDVBuffer3::RawDVBuffer3(CVD::DV3::DV3ColourSpace, int, unsigned long, int, bool, bool, CVD::ImageRef, float, CVD::ImageRef, int) »
        VideoSource_Linux_DV.o: dans la fonction « CVD::DVBuffer3::frame_pending() »:
        VideoSource_Linux_DV.cc:(.text._ZN3CVD9DVBuffer3INS_6yuv411EE13frame_pendingEv[_ZN3CVD9DVBuffer3INS_6yuv411EE13frame_pendingEv]+0x5): référence indéfinie vers « CVD::DV3::RawDVBuffer3::frame_pending() »
        VideoSource_Linux_DV.o: dans la fonction « CVD::DVBuffer3::get_frame() »:
        VideoSource_Linux_DV.cc:(.text._ZN3CVD9DVBuffer3INS_6yuv411EE9get_frameEv[_ZN3CVD9DVBuffer3INS_6yuv411EE9get_frameEv]+0x5): référence indéfinie vers « CVD::DV3::RawDVBuffer3::get_frame() »
        VideoSource_Linux_DV.o: dans la fonction « CVD::DVBuffer3::put_frame(CVD::VideoFrame*) »:
        VideoSource_Linux_DV.cc:(.text._ZN3CVD9DVBuffer3INS_6yuv411EE9put_frameEPNS_10VideoFrameIS1_EE[_ZN3CVD9DVBuffer3INS_6yuv411EE9put_frameEPNS_10VideoFrameIS1_EE]+0x5): référence indéfinie vers « CVD::DV3::RawDVBuffer3::put_frame(CVD::VideoFrame*) »
        VideoSource_Linux_DV.o: dans la fonction « CVD::DVBuffer3::~DVBuffer3() »:
        VideoSource_Linux_DV.cc:(.text._ZN3CVD9DVBuffer3INS_6yuv411EED1Ev[_ZN3CVD9DVBuffer3INS_6yuv411EED1Ev]+0x1d): référence indéfinie vers « CVD::DV3::RawDVBuffer3::~RawDVBuffer3() »
        VideoSource_Linux_DV.o: dans la fonction « CVD::DVBuffer3::~DVBuffer3() »:
        VideoSource_Linux_DV.cc:(.text._ZN3CVD9DVBuffer3INS_6yuv411EED0Ev[_ZN3CVD9DVBuffer3INS_6yuv411EED0Ev]+0x1d): référence indéfinie vers « CVD::DV3::RawDVBuffer3::~RawDVBuffer3() »
        VideoSource_Linux_DV.o:(.rodata._ZTIN3CVD9DVBuffer3INS_6yuv411EEE[_ZTIN3CVD9DVBuffer3INS_6yuv411EEE]+0x28): référence indéfinie vers « typeinfo for CVD::DV3::RawDVBuffer3 »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0x48): référence indéfinie vers « typeinfo for CVD::DV3::RawDVBuffer3 »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0x58): référence indéfinie vers « CVD::DV3::RawDVBuffer3::~RawDVBuffer3() »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0x60): référence indéfinie vers « CVD::DV3::RawDVBuffer3::~RawDVBuffer3() »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0x70): référence indéfinie vers « CVD::DV3::RawDVBuffer3::frame_pending() »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0xd0): référence indéfinie vers « typeinfo for CVD::DV3::RawDVBuffer3 »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0xe0): référence indéfinie vers « virtual thunk to CVD::DV3::RawDVBuffer3::~RawDVBuffer3() »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0xe8): référence indéfinie vers « virtual thunk to CVD::DV3::RawDVBuffer3::~RawDVBuffer3() »
        VideoSource_Linux_DV.o:(.rodata._ZTCN3CVD9DVBuffer3INS_6yuv411EEE16_NS_3DV312RawDVBuffer3E[_ZTVN3CVD9DVBuffer3INS_6yuv411EEE]+0xf8): référence indéfinie vers « virtual thunk to CVD::DV3::RawDVBuffer3::frame_pending() »
        collect2: error: ld returned 1 exit status
        make: *** [PTAM] Erreur 1
        I found the solution here : http://forum.ubuntu-fr.org/viewtopic.php?pid=3478792 , it’s by activating raw1394 , that I don’t find in ubuntu 14.04 and I don’t even know how to activate it.
        Any suggestion please?

      • Hi, I think that the compilation is done know , without errors , but when I did “./CameraCalibrator”,I encounter this problem :
        Welcome to CameraCalibrator
        ————————————–
        Parallel tracking and mapping for Small AR workspaces
        Copyright (C) Isis Innovation Limited 2008

        Parsing calibrator_settings.cfg ….
        VideoSource_Linux: Opening video source…
        >
        !! Failed to run CameraCalibrator; got exception.
        Exception was:
        DVBuffer3: No cameras found.
        and after reading lot of tutorials, I think that the problem is that I’m using a USB camera and that I’ve to change something in the code,but I don’t really know what to do to fix it.

        My USB camera : Logitech USB Camera (QuickCam S5500)

        thank you very much for your help.

  4. Hello, i need help with the following error:

    Archive: /home/juan/PTAM/PTAM-r114-2010129.zip
    replace PTAM/GLWindow2.cc? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
    inflating: PTAM/GLWindow2.cc
    inflating: PTAM/CameraCalibrator.cc
    inflating: PTAM/OpenGL.h
    extracting: PTAM/OSX_resource_file.r
    inflating: PTAM/MapMaker.h
    inflating: PTAM/EyeGame.cc
    inflating: PTAM/Bundle.h
    inflating: PTAM/MapMaker.cc
    inflating: PTAM/HomographyInit.cc
    inflating: PTAM/Tracker.cc
    inflating: PTAM/CameraCalibrator.h
    inflating: PTAM/ARDriver.cc
    inflating: PTAM/Relocaliser.cc
    inflating: PTAM/MiniPatch.h
    inflating: PTAM/CalibCornerPatch.cc
    inflating: PTAM/MapPoint.cc
    inflating: PTAM/PatchFinder.h
    inflating: PTAM/README.txt
    inflating: PTAM/Map.cc
    inflating: PTAM/System.cc
    inflating: PTAM/MEstimator.h
    inflating: PTAM/SmallMatrixOpts.h
    inflating: PTAM/KeyFrame.cc
    inflating: PTAM/settings.cfg
    inflating: PTAM/CalibCornerPatch.h
    inflating: PTAM/GLWindowMenu.cc
    inflating: PTAM/Build/Linux/VideoSource_Linux_DV.cc
    inflating: PTAM/Build/Linux/VideoSource_Linux_V4L.cc
    inflating: PTAM/Build/Linux/Makefile
    inflating: PTAM/Build/Win32/PTAM.vcproj
    inflating: PTAM/Build/Win32/PTAM.sln
    inflating: PTAM/Build/Win32/VideoSource_Win32_CMU1394.cc
    inflating: PTAM/Build/Win32/CameraCalibrator.vcproj
    inflating: PTAM/Build/OSX/VideoSource_OSX.cc
    inflating: PTAM/Build/OSX/Makefile
    inflating: PTAM/GLWindowMenu.h
    inflating: PTAM/LICENSE.txt
    inflating: PTAM/Tracker.h
    inflating: PTAM/ShiTomasi.h
    inflating: PTAM/ATANCamera.h
    inflating: PTAM/Relocaliser.h
    inflating: PTAM/CHANGELOG.txt
    inflating: PTAM/calibrator_settings.cfg
    inflating: PTAM/main.cc
    inflating: PTAM/TrackerData.h
    inflating: PTAM/EyeGame.h
    inflating: PTAM/KeyFrame.h
    inflating: PTAM/VideoSource.h
    inflating: PTAM/Bundle.cc
    inflating: PTAM/GLWindow2.h
    inflating: PTAM/calib_pattern.pdf
    inflating: PTAM/System.h
    inflating: PTAM/CalibImage.cc
    inflating: PTAM/MapViewer.h
    inflating: PTAM/Map.h
    inflating: PTAM/LevelHelpers.h
    inflating: PTAM/MiniPatch.cc
    inflating: PTAM/SmallBlurryImage.cc
    inflating: PTAM/CalibImage.h
    inflating: PTAM/MapViewer.cc
    inflating: PTAM/PatchFinder.cc
    inflating: PTAM/SmallBlurryImage.h
    inflating: PTAM/ARDriver.h
    inflating: PTAM/ATANCamera.cc
    inflating: PTAM/MapPoint.h
    inflating: PTAM/ShiTomasi.cc
    inflating: PTAM/HomographyInit.h
    PTAM-linux-yuji.bash: line 55: /home/juan/PTAM/hack/PTAM/PTAM-r114-linux.patch: No such file or directory
    can’t find file to patch at input line 3
    Perhaps you used the wrong -p or –strip option?
    The text leading up to this was:
    ————————–
    |— PTAM/Build/LinuxMakefile 2014-09-23 16:44:15.979478461 +0900
    |+++ /home/charmie/PTAM-work/PTAM/Makefile 2014-09-23 16:41:31.574663222 +0900

    as you can notice it says it cant patch…ive been trying to install this for a while.
    Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s