Visual SFM

From The World according to Vissie
Jump to navigation Jump to search

Build a full 3D model

Take pics

All I can say here, is your pictures have to be perfect! Don't kid yourself. I did. Trust me, pictures need to be perfect. What I find works, is flash. Make sure all your pictures is in focus, and are clear, ie with a flash. - [1 hour]

Visual SFM

  • Open multiple images (60 Photo's) - [1 min]
  • Compute missing matches (4 arrows, looks like a X) - [5 min]
    • "Failed to find two images for initialization" Seems to be not a "negative" error as such. If the dots on the screen looks like the object that you took, do continue. Look at every photo, delete when there is not sufficient light or that is blurred. Go back and take more if needed.
  • Compute 3D Reconstruction (3 arrows pointing right) - [14 Min]
    • Next, if you have multiple models, go and delete the cameras that is "wrong".
  • Run Dense Reconstruction - [7 min]
    • Then hit tab to see the magic
  • Done! Now to open MeshLab


  • Use middle button to move your object in space, left to rotate it.
  • Open project the bundle.out file. Mine was in: "/home/vissie/Pictures/3D/Sherlock dog/Dense.nvm.cmvs/00/bundle.rd.out"
  • then you will get prompted for the list.txt file, same location.
  • Top menu, looks like a stack of papers, show layer view.
  • On the left, right click on your model, Delete current mesh.
  • Then, File, Import Mesh and open the *.ply file. Funny, mine was in the root directory this time. "/home/vissie/Pictures/3D/Sherlock dog/Dense.0.ply"
  • Now clean out the mesh by selecting the Select Vertexes icon and delete the noise in the out side. The delete button is a down arrow with a cross over it. Move that whole menu down one line to see more options.
  • Remember to save! Do this by "Export Mesh as..." and give it a nice name. U can leave all the default option when promoted.
  • Next, Filers, Point Set, Surface reconstruct: Poison. I was told to use 12,10 in the first 2 boxes. I Don't know any better.
  • U will then have 2 meshed (left panel). Delete the first one. In mine that is 1 Dense, keeping 2 Poisson.
  • Remember to also save the project from time to time.
  • Do some cleanup again if needed.
  • BIG NB! We have to remove the non-something edges else we will get errors and this thing will not work.
  • Filers, Selection, Select non-Manifold edges (Third from the bottom). Then delete them as normal.
  • Now for the textures.
  • Filters, Textures, Predetermination + texturing from registered rasters.
    • Texture size: 4096 (nice and big)
    • Texture Name: give_it_a_name.png
    • And from the bottom 5 option, tick all but the middle one (Use image alpha weight.
  • look at the log window to see when it is done. You can also browse to go look at your texture file. "/home/vissie/Pictures/3D/Sherlock dog/Dense.0.ply\MyTexture.png"
  • Export it a final time to a *.obj file.
  • And that is it! Onward to Blender.


  • Like always, delete the square.
  • File, import, Import *.obj
  • I then normal move the object to the centre.
  • Now apply the texture to it.
  • On the left menu, maybe pull it out a bit to see more options.
  • Select the one that looks like a checker board, red and white squares.
  • Texture
    • New
    • Image or Movie
    • open ( your texture file)
    • Make sure that you have UV as the mapping source
  • PLs make sure, under Material (the round rd and white ball), u select
    • Shadeless
  • Then far left bottom, by the square, change the view to UV editor.
  • Then from the bottom menu, select your texture map.
  • Change your view back to 3D view .
  • Change Texture from solid to Texture.
  • ctl up will take you into full screen view.

ctl down, back out of full screen view.

Install/Compile Visual SFM on Debian

(My notes and all over the show. I'll clean them up when I do another install, sorry)

Preparation of VisualSFM

Make sure you have libgtk2.0-dev / gtk2-devel (2.18 or higher)

apt-get install libgtk2.0-dev freeglut3-dev libdevil-dev libglew-dev

Compiling SiftGPU (without CUDA and DevIL)

Next you have to download and unzip SiftGPU.

If you don’t have a GPU with CUDA and don’t want to use DevIL, change the makefile in the unzipped folder as follows:

siftgpu_prefer_glut = 1
siftgpu_disable_devil = 1

Now run the following commands:

cd /path/to/unzipped/SiftGPU_folder

After the ‘make’ command has finished (there might be some warnings, that are unimportant for us) search for the file ‘’ in the folder of SiftGPU. Copy it to the folder ‘vsfm/bin’.

Compiling PBA (Multicore Bundle Adjustment) (without CUDA)

cd /path/to/unzipped/PBA_folder
make -f makefile_no_gpu

Search for the file ‘’ and copy it to the folder ‘vsfm/bin’.

Compile Graclus


If you run a 64bit version of Linux, go to the unzipped folder, open the ‘Makefile.ini’ with some text editor (e.g. gedit) and change the corresponding line to the following:


Afterwards go to the terminal and run:

cd /path/to/unzipped/GRACLUS_folder

Compile CMVS/PMVS2

apt-get install libboost-dev  (or -all? I'm not sure yet) Now, go to and download the files ‘clapack.h’ and ‘f2c.h’ to a new folder you call ‘clapack’.


wget (not this one I think)

Go to the unzipped folder, serach the ‘makefile’ in ‘cmvs/program/main’ and change the corresponding lines to the following:

YOURINCLUDEPATH = -I/path/to/clapack
YOUR_INCLUDE_METIS_PATH = -I/path/to/graclus1.2/metisLib (for Graclus1.2)
YOUR_LDLIB_PATH = -L/path/to/graclus1.2 (for Graclus1.2)

Again, if you run a 64bit system change the corresponding line to:


Next, go to ‘cmvs/program/base/numeric’ open the file ‘’ with some text editor and change lines 6 and 7 as follows

YOURINCLUDEPATH = -I/path/to/clapack
YOUR_INCLUDE_METIS_PATH = -I/path/to/graclus1.2/metisLib (for Graclus1.2)
YOUR_LDLIB_PATH = -L/path/to/graclus1.2 (for Graclus1.2)

If you on 64 Bit, make sure that DNUMBITS is set to 64

Next, go to ‘cmvs/program/base/numeric’ open the file ‘’ with some text editor and change lines 6 and 7 as follows:

// #include
// #include

Next thing might be to run the ‘make’ command in ‘cmvs/program/main’ the same way as described above. Due to some compatibility problems, this may cause an error that looks similar to this:

./pmvs2: error while loading shared libraries: 
cannot open shared object file: No such file or directory

Luckily there is a simple way to get rid of this error. Just run the following commands:

cd cmvs/program/main/
cp mylapack.o mylapack.o.backup
make clean
cp mylapack.o.backup mylapack.o
make depend
apt-get install freeglut3-dev libgsl0-dev


ln -s /home/vissie/Downloads/source/SiftGPU/bin/ /usr/lib/

or, lets try again!!! Follow:

apt-get install libgtk2.0-dev libglew-dev glew-utils libdevil-dev libboost-all-dev libatlas-cpp-0.6-dev libatlas-dev imagemagick libatlas3gf-base libcminpack-dev libgfortran3 libmetis-edf-dev libparmetis-dev freeglut3-dev libgsl0-dev
apt-get install liblapack-dev

This SAVED me from all my errors!