Tuesday, July 26, 2011

Building Bundler, CMVS and PMVS2 on Kubuntu 11.04 64bit

I've had some minor trouble getting the SFM combo to compile and run properly on linux these days.

I started out first by getting bundler v0.4 and installing the requirements described in INSTALL.txt (mainly apt-getting LAPACK, BLAS, MINPACK). Hitting make in the source directory went through part of the compilation, but gcc complained that line 620 of BundlerApp.h was giving trouble. It actually suggested to replace
    SkeletalApp() {
        BundlerApp::BundlerApp();
        m_start_camera = -1;
    }
with
    SkeletalApp() {
        BundlerApp();
        m_start_camera = -1;
    }
which solved the problem and got through the compilation successfully.

The second issue I stumbled across was quite more difficult to gleam:
the jhead, sift and other executables that are provided with the source code would not run and tell me the command was "not found" even though the file was indeed there. This turned out to be a 32-bit/64-bit issue: installing the ia32 libraries (sudo apt-get install ia32-libsfixed the problem. For some reason this worked right away on another install on a Toshiba laptop. On the main machine I had been playing around with uninstalling/reinstalling Nvidia drivers to get CUDA up and running, so this might be the reason...

For CMVS/PMVS, I gitted the CMVS-PMVS package from TheFrenchLeaf. I installed CMAKE and used it on the CMVS-PMVS/program/ folder to generate the makefiles. Compile went without problems and I had everything I wanted.

Finally, I came back and modified Bundle2PMVS.cpp to replace line 160 from
fprintf(f_scr, "BUNDLER_BIN_PATH=" # Edit this line before running\n");
to
fprintf(f_scr, "BUNDLER_BIN_PATH=$1\n");
so that I won't have to manually modify the prep_pmvs.sh script every time I use Bundle2PMVS. Since I was there, I also modified the RunBatch.sh script to run both Bundle2PMVS and prep_pmvs.sh by addingsleep 1
echo "[- Running Bundle2PMVS -]"
$BASE_PATH/bin/Bundle2PMVS list.txt bundle/bundle.out
sleep 1
sh pmvs/prep_pmvs.sh $BASE_PATH/bin

at the end of the file.
This has taken care of basically all my requirements. Next up will be getting siftGPU to replace the original sift.

PMVS2 Memory Usage

I've been playing with the excellent PMVS2 dense scene reconstruction from Furukawa and Ponce.
In reality I've been playing with the whole Bundler+CMVS+PMVS2 sequence, provided very kindly by Henri Astre as a single toolkit (for Windows 64bit), there is a Mac OSX version lurking around somewhere in his blog, to which I can't find a link right now.

The very modest tests I've made all come from a Canon 5d MarkII with a 16mm lens (20 Mpixels = 3744x5616) in an indoors environment. I took ~360 pictures of which bundler selected roughly 260. I then ran CMVS to cluster it up using different values for maximages. This is what it took (roughly) to process them (all default settings from genOption/PMVS2):
  • 14-images clusters: 2.5GB of RAM | ~1000 sec* (Macbook Pro 2.8GHz dual, 4GB)
  • 40-images clusters: 7.2GB of RAM | ~6000 sec(Xeon 3.4GHz quad, 16GB)
  • 80-images clusters: 16GB of RAM  | ~13600 sec* (Xeon 3.4GHz quad, 16GB)
*per patch expansions
I can imagine that the large time for the 80-images clusters comes from the need to use swapping, but then again the time for each step seems to be quite exponential depending on the number of images used. I will make some more serious tests later on, but this should give you a rough idea.