Search code examples
pythonubuntudockerstructure-from-motion

OpenSFM setup.py file returning error after building via Docker


I am having an issue building OpenSFM. I am getting an error from running the setup.py file.

First, I am running Ubuntu 16.04 on VirtualBox. I installed Docker and ran

docker pull freakthemighty/opensfm

This image was successfully built.

Additionally, I cloned the OpenSFM repository from here into my home folder.

Next, I am supposed to build by running this in the main folder:

python setup.py build

This is the resulting error

walter@VirtualUbuntu:~$ python setup.py build
Configuring...
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    subprocess.Popen(['cmake','../opensfm/src'], cwd='cmake_build').wait()
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Here is the setup.py file in question.


Solution

  • I ended up building the Dockerfile myself. I added a last few steps to get it to work and have OpenSfM build automatically.

    I clone the repository first, then add a couple missing packages, followed by building the setup.py file automatically.

    FROM ubuntu:16.04
    
    # Install apt-getable dependencies
    RUN apt-get update \
        && apt-get install -y \
            build-essential \
            cmake \
            git \
            libatlas-base-dev \
            libboost-python-dev \
            libeigen3-dev \
            libgoogle-glog-dev \
            libopencv-dev \
            libsuitesparse-dev \ 
            python-dev \
            python-numpy \
            python-opencv \
            python-pip \
            python-pyexiv2 \
            python-pyproj \
            python-scipy \
            python-yaml \
            wget \
        && apt-get clean \
        && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
    
    
    # Install Ceres from source
    RUN \
        mkdir -p /source && cd /source && \
        wget http://ceres-solver.org/ceres-solver-1.10.0.tar.gz && \
        tar xvzf ceres-solver-1.10.0.tar.gz && \
        cd /source/ceres-solver-1.10.0 && \
        mkdir -p build && cd build && \
        cmake .. -DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF && \
        make install && \
        cd / && \
        rm -rf /source/ceres-solver-1.10.0 && \
        rm -f /source/ceres-solver-1.10.0.tar.gz
    
    
    # Install opengv from source
    RUN \
        mkdir -p /source && cd /source && \
        git clone https://github.com/paulinus/opengv.git && \
        cd /source/opengv && \
        mkdir -p build && cd build && \
        cmake .. -DBUILD_TESTS=OFF -DBUILD_PYTHON=ON && \
        make install && \
        cd / && \
        rm -rf /source/opengv
    
    #Clone the OpenSfM Repository
    RUN git clone https://github.com/mapillary/OpenSfM.git
    
    #Add additional functions that for some reason didn't come with the docker file
    Run apt-get update \ 
        && apt-get install python-networkx \ 
        python-exif \
        python-xmltodict
    
    #Automatically build OpenSfM so that its prebuilt in the docker
    Run cd OpenSfM && python setup.py build