Monday, February 11, 2013

Installing Bundler on Linux: A Tutorial

This is a mix of all the steps necessary to install Bundler + CMVS + PMVS2 on Ubuntu 11.10. I think other versions of Ubuntu work the same.

Edit: If you're interested in doing this, do yourself a favor and download the necessary files that I've modified form here (64-bit Ubuntu compatible) or from my GitHub repo here. The steps outlined below are actually not enough, you need to add the necessary flags to tell your compiler that you're compiling 32-bit compatible code.
I'd love to know if this helped, so let me know in the comments.

0.1 Pre-Install

These are the libraries you need to install before proceeding with the instalation. I've used Synaptic to install these on my system.
Install LAPACK, BLAS, CBLAS, MINPACK, f2c, libjpeg, libzip and imagemagick.
Optionally, also install gfortran and libmagicwand-dev (I installed them because it wasn't clear what I was supposed to install, so you might need them too).

0.2. Download

These are all the things you need to download (and unzip/untar). Also perform the steps in parenthesis.

0.3. Directory Structure

I've created a folder called Installs in my home directory.
Move the folders created above (bundler, pmvs2, clapack, cmvs, graclus1.2) to this Installs folder.

Edit your .bashrc file so that you set the library path correctly:

LD_LIBRARY_PATH=~/Installs/bundler/lib
export LD_LIBRARY_PATH

1. Installing Bundler 

> cd  Installs/bundler/src

Edit the Makefile such that the second line of code says:

OPTFLAGS=-O3 -Wall -fpermissive

The -fpermissive makes sure that warnings from previous versions of gcc are not treated as errors in the newer versions.

> make all

2. Installing PMVS2

> cd Installs/pmvs-2/program/base/numeric

Edit mylapac.cc lines 6 and 7 say:

#include <f2c.h>
#include <clapack.h>


(instead of clapack/*.h)

> cd Installs/pmvs-2/program/main

Edit the MakeFile so that you have

YOURINCLUDEPATH = -I/home/user/Installs/clapack/
and
YOURLDLIBPATH = -L/home/user/Installs/graclus1.2/

> make clean
> make depend
> make

3. Installing Graclus

My system is a 32-bit system. If you're installing on a 64-bit system, make sure you change 32 to 64 everywhere below.

> cd Installs/graclus1.2

Edit MakeFile.in. Make sure

COPTIONS = -DNUMBITS=32

> make

4. Installing CMVS

My system is a 32-bit system. If you're installing on a 64-bit system, make sure you change 32 to 64 everywhere below.

> cd Installs/cmvs/program/main


Edit MakeFile such that you have set the numbits appropriately in this line (there are 2 instances)

CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=32 \
        ${YOUR_INCLUDE_PATH} ${YOUR_INCLUDE_METIS_PATH} \
        -fopenmp -DNUMBITS=32 ${OPENMP_FLAG}



Copy mylapack.o from pmvs2 to the cmvs directory.

> cd Installs
> cp pmvs-2/program/main/mylapack.o cmvs/program/main/


> cd cmvs/program/base/cmvs

Edit bundle.cc such that it includes the following libraries:

#include <vector>
#include <numeric>


> cd cmvs/program/main/


Edit genOption.cc such that it includes

#include <stdlib.h>

> cd cmvs/program/main/

Edit the MakeFile to set the dependencies (and comment out each line above each of these):

YOUR_INCLUDE_PATH = -I/home/adina/Installs/clapack/
YOUR_INCLUDE_METIS_PATH = -I/home/adina/Installs/graclus1.2/metisLib
YOUR_LDLIB_PATH = -L/home/adina/Installs/graclus1.2/


> make depends
> make

5. Run Bundler

> cd Installs/bundler/bin

Edit extract_focal.pl so that you have the focal length of the camera you use (line 293-ish).
     "SONY DSC-W80"                     => 5.75,   # 1/2.5"
     "Apple iPhone 4"                   => 3.85,
     "KODAK EASYSHARE C653 ZOOM DIGITAL CAMERA"         => 6,
     "Panasonic DMC-FH1"                => 6.17, # 1/2.33"
     "Apple iPhone 4S"                  => 4.28, 


> cd Installs/bundler

Edit RunBundler.sh by adding these lines at the end:

sleep 1
echo "[- Running Bundle2PMVS -]"

$BASE_PATH/bin/Bundle2PMVS list.txt bundle/bundle.out


I made a script to run everything (edit the paths on the first line; to run, put it in the folder with the images)

> ./runBundler_linux