Getting OpenMVG set up on Bash for Windows

OpenMVG is a pipeline for structure from motion.  I’ll go through the basics of downloading, installing, and running it on Windows 10.

 

It does actually compile on Windows, but it can be a royal pain in the rear to get everything set up properly (requiring Visual Studio, Python, and a lot of luck).  Far easier to do in Linux.  But who wants to install a whole new OS just to run some photogrammetry software? Well, fear not, because just the other day I posted on how to get a Bash terminal in windows, allowing you to natively run linux programs without having to install a whole new OS, virtual Machine, or Cygwin.

So, let’s start….

 

Downloading and building.

All I’m going to do here is run through the official Build Instructions, wording it a little differently.  I highly recommend you go there for details.  I’m only writing it up here so that all the information needed for a later post is in one place.

Prerequisites:

Install the required tools cmake, Git, and a c++ compiler by typing the following into Bash:

sudo apt-get install cmake git gcc make g++ python

(enter your password if you previously set one up)

mvg1.JPG

  • Cmake is used to create a Makefile in order to compile the source code
  • Make Will turn the source code files into executables (things that actually run)
  • Git Is the program that lets you download all the source code from github
  • GCC Is the Gnu C Compiler (and g++ is the Gnu C++ Compiler).
  • Python Is required to run the ready-to-use openMVG scripts

Now you’ll need some additional libraries, so type into bash:

sudo apt-get install libpng-dev libjpeg-dev libtiff-dev libxxf86vm1 libxxf86vm-dev libxi-dev libxrandr-dev

Downloading

Now we’re going to download the repository:

git clone --recursive https://github.com/openMVG/openMVG.git

Move into that new directory:

cd openMVG

(cd stands for ‘change directory’)

ls

This should list the files in that directory (AUTHORS BUILD docs logo README src …)

cd ..

(this goes back up one directory)

Building/Compiling

Now we create a new directory to put the compiled code in (to keep it separate from the source)

mkdir openMVG_Build

Then go into that directory:

cd openMVG_Build

And run cmake:

cmake -DCMAKE_BUILD_TYPE=RELEASE -DOpenMVG_BUILD_TESTS=ON -DOpenMVG_BUILD_EXAMPLES=ON . ../openMVG/src/

Now we’ve created the necessary configuration files to make the binaries, we just run:

make

 

Running OpenMVG

Ok, hopefully that’s built without errors.

If so, let’s test it out.  (If not, I leave the troubleshooting to you!)

One thing to note before we go any further: the home directory for bash, is located in windows space at

C:\Users\<yourUserName>\AppData\Local\lxss\home

Navigate there in Windows explorer, and you’ll see a folder with your username.  Go inside there and you’ll see folders called openMVG and openMVG_Build.

Full instructions are available on the OpenMVG docs page, including how to download tutorial data: http://openmvg.readthedocs.io/en/latest/software/SfM/SfM/

There are two pipelines – sequential and global.  I’ll let you read up on what the difference is.  Both are invoked more-or-less the same way, and I’ve generally found Sequential to be a little more robust.

 (I’m going to assume now that your username is ‘Peter’ and that [using windows explorer] you’ve put all your images in a folder called ‘images’ in your linux home directory (next to openMVG and openMVGBuild). You will want to slightly alter the commands accordingly.)

mvg2.jpg

To run the sequential pipeline on your images in your home directory, and output the results into a new folder called ‘MVGOutput’ in your home directory, type the following (capitalization matters in linux):

 

python /home/Peter/openMVG_Build/software/SfM/SfM_SequentialPipeline.py /home/Peter/images /home/Peter/MVGOutput

That’s it.  Let it run, and inside MVGOutput, you’ll find several PLY files of the camera positions and a sparse point cloud.

You’ll need another package to make a dense cloud and subsequent mesh, and I’ll detail those later.

 

 

Advertisements

2 thoughts on “Getting OpenMVG set up on Bash for Windows

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