Coder Social home page Coder Social logo

dpg's Introduction

OpenMVG + OpenMVS Pipeline

Photogrammetry pipeline using OpenMVG and OpenMVS.

(Also includes CMVS and COLMAP).

Installation

Docker

You can either use spedenaave/dpg image from the docker hub or build it by yourself by first cloning the repository and then using docker build -t dpg . command.

Be adviced that the default setting of docker for windows and mac only give the container access to a very limited amount of system resources. You can increase the amount of cpu cores and memory from the advanced settings.

Linux (or Windows Subsystem for Linux)

This method will build and install required binaries directly to your linux installation. It is not recommended!

git clone https://github.com/rennu/dpg /tmp/dpg && cd /tmp/dpg
sudo ./build.sh

Example usage

Mesh Reconstruction with Textures by using Incremental Structure from Motion

In this short example we first clone an example dataset to /tmp/example, then start docker with -v argument to mount /tmp/example to /datasets inside the container, and finally we the run pipeline.

git clone https://github.com/openMVG/ImageDataset_SceauxCastle /tmp/example
docker run -v /tmp/example:/datasets --rm -it spedenaave/dpg
pipeline.py --input /datasets/images --output /datasets/output --sfm-type incremental --geomodel f --run-openmvg --run-openmvs

You should now have a reconstructed model at /tmp/example/omvs folder. Use meshlab or something similar to open it. The end result should look something like this: Example 1

Pipeline Options

General Options:

    --help
        Print this text

    --debug
        Print commands and exit

    --input [directory]
        Image input directory

    --output [directory]
        Output directory

    --sfm-type [string]
        Select SfM mode from Global SfM or Incremental SfM. Possible values:
        incremental
        global
    
    --run-openmvg
        Run OpenMVG SfM pipeline

    --run-openmvs
        Run OpenMVS MVS pipeline
    
Optional settings:

    --recompute
        Recompute everything

    --openmvg [path]
        Set OpenMVG install location
    
    --openmvs [path]
        Set OpenMVS install location

OpenMVG

    Image Listing:

        --cgroup
            Each view have it's own camera intrinsic parameters

        --flength [float]
            If your camera is not listed in the camera sensor database, you can set pixel focal length here.
            The value can be calculated by max(width-pixels, height-pixels) * focal length(mm) / Sensor width

        --cmodel [int]
            Camera model:
            1: Pinhole
            2: Pinhole Radial 1
            3: Pinhole Radial 3 (default)
            4: Pinhole brown
            5: Pinhole with a simple Fish-eye distortion

    Compute Features:

        --descmethod [string]
            Method to describe an image:
                SIFT (default)
                AKAZE_FLOAT
                AKAZE_MLDB

        --dpreset [string]
            Used to control the Image_describer configuration
                NORMAL
                HIGH
                ULTRA

    Compute Matches:

        --ratio [float]
            Nearest Neighbor distance ratio (smaller is more restrictive => Less false positives)
            Default: 0.8

        --geomodel [char]
            Compute Matches geometric model:
            f: Fundamental matrix filtering (default)
                For Incremental SfM
            e: Essential matrix filtering
                For Global SfM
            h: Homography matrix filtering
                For datasets that have same point of projection
    
        --matching [string]
            Compute Matches Nearest Matching Method:
            BRUTEFORCEL2: BruteForce L2 matching for Scalar based regions descriptor,
            ANNL2: Approximate Nearest Neighbor L2 matching for Scalar based regions descriptor,
            CASCADEHASHINGL2: L2 Cascade Hashing matching,
            FASTCASCADEHASHINGL2: (default)
                * L2 Cascade Hashing with precomputed hashed regions, (faster than CASCADEHASHINGL2 but use more memory).

    Incremental SfM:

        --icmodel [int]
            The camera model type that will be used for views with unknown intrinsic
            1: Pinhole
            2: Pinhole radial 1
            3: Pinhole radial 3 (default)
            4: Pinhole radial 3 + tangential 2
            5: Pinhole fisheye

    Global SfM:

        --grotavg [int]
            1: L1 rotation averaging [Chatterjee]
            2: L2 rotation averaging [Martinec] (default)

        --gtransavg [int]
            1: L1 translation averaging [GlobalACSfM]
            2: L2 translation averaging [Kyle2014]
            3: SoftL1 minimization [GlobalACSfM] (default)


OpenMVS

    --output-obj
        Make OpenMVS output obj instead of ply (default)

    DensifyPointCloud:

        --densify
            Enable dense reconstruction
            Default: Off
        
        --densify-only
            Only densify (duh)

        --dnumviews [int]
            Number of views used for depth-map estimation
            0 all neighbor views available
            Default: 4
    
        --dnumviewsfuse [int]
            Minimum number of images that agrees with an estimate during fusion in order to consider it
            inliner
            Default: 3

        --dreslevel [int]
            How many times to scale down the images before point cloud computation. For better accuracy/speed width
            high resolution images use 2 or even 3
            Default: 1
    
    ReconstructMesh:

        --rcthickness [int]
            ReconstructMesh Thickness Factor
            Default: 2
        
        --rcdistance [int]
            Minimum distance in pixels between the projection of two 3D points to consider them different while
            triangulating (0 to disable). Use to reduce amount of memory used with a penalty of lost detail
            Default: 2
    
    RefineMesh:

        --rmiterations [int]
            Number of RefineMesh iterations
            Default: 3

        --rmlevel [int]
            Times to scale down the images before mesh refinement
            Default: 0

        --rmcuda
            Use CUDA version of RefineMesh binary (will fall back the executable is not found)
    
    Texture Mesh:

        --txemptycolor [int]
            Color of surfaces OpenMVS TextureMesh is unable to texture.
            Default: 0 (black)

dpg's People

Contributors

colspan avatar coord-e avatar rennu avatar scoopr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dpg's Issues

Warning message when building docker image

Got some warning when building the docker image:

tmp/build/vcglib/vcg/complex/algorithms/create/platonic.h:566:41: warning: typedef 'ScalarType' locally defined but not used [-Wunused-local-typedefs]
   typedef typename MeshType::ScalarType ScalarType;
                                         ^
/tmp/build/vcglib/vcg/complex/algorithms/create/platonic.h:570:45: warning: typedef 'FaceIterator' locally defined but not used [-Wunused-local-typedefs]
   typedef typename MeshType::FaceIterator   FaceIterator;
                                             ^
/tmp/build/vcglib/vcg/complex/algorithms/create/platonic.h: In function 'void vcg::tri::Grid(MeshType&, int, int, float, float, float*)':
/tmp/build/vcglib/vcg/complex/algorithms/create/platonic.h:630:45: warning: typedef 'VertexPointer' locally defined but not used [-Wunused-local-typedefs]
   typedef typename MeshType::VertexPointer  VertexPointer;
                                             ^
/tmp/build/vcglib/vcg/complex/algorithms/create/platonic.h:631:45: warning: typedef 'VertexIterator' locally defined but not used [-Wunused-local-typedefs]
   typedef typename MeshType::VertexIterator VertexIterator;
                                             ^
/tmp/build/vcglib/vcg/complex/algorithms/create/platonic.h:632:45: warning: typedef 'FaceIterator' locally defined but not used [-Wunused-local-typedefs]
   typedef typename MeshType::FaceIterator   FaceIterator;
                                             ^
/tmp/build/openmvs/libs/MVS/Mesh.cpp: In member function 'bool MVS::Mesh::ProjectOrtho(const MVS::Camera&, MVS::DepthMap&) const::RasterMesh::ProjectVertex(const Vertex&, int)':
/tmp/build/openmvs/libs/MVS/Mesh.cpp:3593:76: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
    pti[v] = camera.TransformPointC2I(reinterpret_cast<const Point2&>(ptc[v]));
                                                                            ^
/tmp/build/openmvs/libs/MVS/Mesh.cpp: In member function 'bool MVS::Mesh::ProjectOrtho(const MVS::Camera&, MVS::DepthMap&, SEACAVE::Image8U3&) const::RasterMesh::ProjectVertex(const Vertex&, int)':
/tmp/build/openmvs/libs/MVS/Mesh.cpp:3629:76: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
    pti[v] = camera.TransformPointC2I(reinterpret_cast<const Point2&>(ptc[v]));
                                                                            ^
In file included from /tmp/build/openmvs/libs/MVS/../Common/Types.h:2638:0,
                 from /tmp/build/openmvs/libs/MVS/../Common/Common.h:176,
                 from /tmp/build/openmvs/libs/MVS/Common.h:42,
                 from /tmp/build/openmvs/libs/MVS/Mesh.cpp:32:
/tmp/build/openmvs/libs/MVS/../Common/Types.inl: In instantiation of 'bool SEACAVE::TImage<TYPE>::Save(const SEACAVE::String&) const [with TYPE = SEACAVE::TPixel<unsigned char>]':
/tmp/build/openmvs/libs/MVS/Mesh.cpp:1516:39:   required from here
/tmp/build/openmvs/libs/MVS/../Common/Types.inl:2763:54: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   static const bool is_little_endian = (*((float*)b) < 1.f);
                                                      ^
In file included from /tmp/build/openmvs/libs/MVS/Mesh.cpp:49:0:
/tmp/build/vcglib/vcg/complex/algorithms/hole.h: In instantiation of 'bool vcg::tri::SelfIntersectionEar<MESH>::Close(vcg::tri::SelfIntersectionEar<MESH>::PosType&, vcg::tri::SelfIntersectionEar<MESH>::PosType&, vcg::tri::SelfIntersectionEar<MESH>::FacePointer) [with MESH = CLEAN::Mesh; vcg::tri::SelfIntersectionEar<MESH>::PosType = vcg::face::Pos<CLEAN::Face>; typename MeshType::FaceType = CLEAN::Face; vcg::tri::SelfIntersectionEar<MESH>::FacePointer = CLEAN::Face*]':
/tmp/build/vcglib/vcg/complex/algorithms/hole.h:464:11:   required from 'static void vcg::tri::Hole<MESH>::FillHoleEar(MESH&, vcg::tri::Hole<MESH>::Info&, std::vector<typename MeshType::FacePointer*>&) [with EAR = vcg::tri::SelfIntersectionEar<CLEAN::Mesh>; MESH = CLEAN::Mesh; typename MeshType::FacePointer = CLEAN::Face*]'

Docker running without result

when running "docker run -v /tmp/example:/datasets --rm -it spedenaave/dpg"
it returns "Missing some of mandatory parameters: --type, --input and --output". What's wrong with this?

Raise meaningful error messages?

Hello,

Thank you for this great piece of work, I never tried OpenMVG/MVS before but I was able to start using them in a few hours!

Depending on the dataset used I got some errors at different stages of the pipeline, some during the features matching and others during the mesh refinement or texture generation.

I was wondering if there was a plan to catch and raise more meaningful error messages, for now one can only see "Failed at step XXX".

Thanks!

Failed while executing: /opt/openmvs/bin/OpenMVS/RefineMesh scene_mesh.mvs -v 0

Why failed. how to fix it.
/opt/openmvs/bin/OpenMVS/RefineMesh scene_mesh.mvs -v 0

07:59:49 [App ] Build date: Jan 4 2022, 12:26:30
07:59:49 [App ] CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (4 cores)
07:59:49 [App ] RAM: 1.94GB Physical Memory 1024.00MB Virtual Memory
07:59:49 [App ] OS: Linux 5.10.47-linuxkit (x86_64)
07:59:49 [App ] SSE & AVX compatible CPU & OS detected
07:59:49 [App ] Command line: scene_mesh.mvs -v 0
Processed iterations 45 (100%, 1m4s627ms)
Processed iterations 22 (100%, 2m6s119ms)
Failed while executing:
/opt/openmvs/bin/OpenMVS/RefineMesh scene_mesh.mvs -v 0

Missing type at icmodel argument

Hello.

There is missing type at icmodel argument.

line 84-86 in pipeline.py

    incrementalSfm.add_argument('--icmodel',
        help='The camera model type that will be used for views with unknown intrinsic: 1. Pinhole 2. Pinhole radial 1 3. Pinhole radial 3 (default) 4. Pinhole radial 3 + tangential 2 5. Pinhole fisheye',
        choices=[1, 2, 3, 4, 5])

Is the following correct?

    incrementalSfm.add_argument('--icmodel',
        type=int,
        help='The camera model type that will be used for views with unknown intrinsic: 1. Pinhole 2. Pinhole radial 1 3. Pinhole radial 3 (default) 4. Pinhole radial 3 + tangential 2 5. Pinhole fisheye',
        choices=[1, 2, 3, 4, 5])

Thank you.

Error while executing OpenMVS.

Environment : Mac OS 10.14 / Installed by Docker

When I try to run the pipeline, it always fails at the same time while executing mesh reconstruction like ...

  • UNDISTORT IMAGES -
    0% 10 20 30 40 50 60 70 80 90 100%
    |----|----|----|----|----|----|----|----|----|----|

Scene saved to OpenMVS interface format:
#platforms: 1
platform ( 0 ) #cameras: 1
11 images (11 calibrated)
6068 Landmarks
Reconstruct mesh

/opt/openmvs/bin/OpenMVS/ReconstructMesh scene.mvs -w /datasets/output_castle/densified/omvs -v 0

Could not find executable: /opt/openmvs/bin/OpenMVS/ReconstructMesh - Have you installed all the requirements?
Failed while executing:
/opt/openmvs/bin/OpenMVS/ReconstructMesh scene.mvs -w /datasets/output_castle/densified/omvs -v 0

When I run the pipeline without using OpenMVS (only using OpenMVG), it creates files without error.
Does some other things should be installed to run OpenMVS ?

Failed while executing: /opt/openmvs/bin/OpenMVS/RefineMesh scene_dense_mesh.mvs -v 3

I can't make RefineMesh working. stdout and stderr are empty and return code is 01. Compiled it without CUDA.

14:23:27 [App     ] OpenMVS x64 v2.2.0
14:23:27 [App     ] Build date: Nov  2 2023, 11:12:02
14:23:27 [App     ] CPU: Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz (16 cores)
14:23:27 [App     ] RAM: 31.13GB Physical Memory 3.81GB Virtual Memory
14:23:27 [App     ] OS: Linux 5.4.0-166-generic (x86_64)
14:23:27 [App     ] Disk: 278.20GB (463.22GB) space
14:23:27 [App     ] SSE & AVX compatible CPU & OS detected
14:23:27 [App     ] Command line: RefineMesh scene_dense_mesh.mvs -v 3
Failed while executing:
/opt/openmvs/bin/OpenMVS/RefineMesh scene_dense_mesh.mvs -v 3

My pipeline:

ptools@5558b86da298:/$ pipeline.py --input ~/datasets/images/ --output ~/openMVS_output/temple/ --sfm-type incremental --geomodel f --run-openmvg --run-openmvs --intrinsics "1520.4;0;302.32;0;1525.9;246.87;0;0;1" --densify --debug
Instrics analysis
=========================================================================
/opt/openmvg/bin/openMVG_main_SfMInit_ImageListing -i /home/ptools/datasets/images/ -o /home/ptools/openMVS_output/temple/matches -d /opt/openmvg/share/openMVG/sensor_width_camera_database.txt -k 1520.4;0;302.32;0;1525.9;246.87;0;0;1

Compute features
=========================================================================
/opt/openmvg/bin/openMVG_main_ComputeFeatures -i /home/ptools/openMVS_output/temple/matches/sfm_data.json -o /home/ptools/openMVS_output/temple/matches -m SIFT

Compute matching pairs
=========================================================================
/opt/openmvg/bin/openMVG_main_PairGenerator -i /home/ptools/openMVS_output/temple/matches/sfm_data.json -o /home/ptools/openMVS_output/temple/matches/pairs.bin

Compute matches
=========================================================================
/opt/openmvg/bin/openMVG_main_ComputeMatches -i /home/ptools/openMVS_output/temple/matches/sfm_data.json -p /home/ptools/openMVS_output/temple/matches/pairs.bin -o /home/ptools/openMVS_output/temple/matches/matches.putative.bin

Filter matches
=========================================================================
/opt/openmvg/bin/openMVG_main_GeometricFilter -i /home/ptools/openMVS_output/temple/matches/sfm_data.json -m /home/ptools/openMVS_output/temple/matches/matches.putative.bin -o /home/ptools/openMVS_output/temple/matches/matches.f.bin -g f

Do incremental/sequential reconstruction
=========================================================================
/opt/openmvg/bin/openMVG_main_SfM -s INCREMENTAL -i /home/ptools/openMVS_output/temple/matches/sfm_data.json -m /home/ptools/openMVS_output/temple/matches -o /home/ptools/openMVS_output/temple/reconstruction_global

Convert OpenMVG project to OpenMVS
=========================================================================
/opt/openmvg/bin/openMVG_main_openMVG2openMVS -i /home/ptools/openMVS_output/temple/reconstruction_global/sfm_data.bin -o /home/ptools/openMVS_output/temple/omvs/scene.mvs -d /home/ptools/openMVS_output/temple/omvs

Densify point cloud
=========================================================================
/opt/openmvs/bin/OpenMVS/DensifyPointCloud scene.mvs -v 0

Reconstruct mesh
=========================================================================
/opt/openmvs/bin/OpenMVS/ReconstructMesh scene_dense.mvs -v 0

Refine mesh
=========================================================================
/opt/openmvs/bin/OpenMVS/RefineMesh scene_dense_mesh.mvs -v 3

Texture mesh
=========================================================================
/opt/openmvs/bin/OpenMVS/TextureMesh scene_dense_mesh_refine.mvs -v 0 --empty-color 0 --resolution-level 0

OSError: [Errno 2] No such file or directory while running pipeline.

Hi, I'm trying to create .ply file by using example image set.

By using terminal on mac, when I run this pipeline,
"
/opt/dpg/pipeline.py --input /datasets/images --output /datasets/output_dense --sfm-type incremental --geomodel f --run-openmvg --run-openmvs --densify
"

I get
"
Traceback (most recent call last):
File "/opt/dpg/pipeline.py", line 387, in
runCommands(commands)
File "/opt/dpg/pipeline.py", line 368, in runCommands
rc = runCommand(map(str, instruction['command']))
File "/opt/dpg/pipeline.py", line 357, in runCommand
p = subprocess.Popen(cmd)
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
"

Can I get some advice to solve this issue?

I this repo useful for Run mvg and mvs faster ?

I want to use mvs and mvg for dense and sparse ply reconstruction, so i have to go through mvs and mvg, but in between these two i had to write my data down then import it to another that this take so long time, so i should somehow make these progress in ram(without reading and writing)
These repo can do this ?

Error running the densify command in docker image

On linux machine:

/opt/dpg/pipeline.py --input /datasets/images --output /datasets/output  --sfm-type incremental --geomodel f --run-openmvg --run-openmvs --densify        
Instrics analysis
=========================================================================
/opt/openmvg/bin/openMVG_main_SfMInit_ImageListing -i /datasets/images -o /datasets/output/matches -d /opt/openmvg/share/openMVG/sensor_width_camera_database.txt

Failed while executing: 
/opt/openmvg/bin/openMVG_main_SfMInit_ImageListing -i /datasets/images -o /datasets/output/matches -d /opt/openmvg/share/openMVG/sensor_width_camera_database.txt

/opt/openmvg/bin/openMVG_main_SfMInit_ImageListing -i /datasets/images -o /datasets/output/matches -d /opt/openmvg/share/openMVG/sensor_width_camera_database.txt
Illegal instruction (core dumped)

new feature:colmap support

Hi, I would like to use colmap instead of OpenMVG for SFM operations so that I can benefit from using the GPU and multi-threading support for faster processing. To achieve this, I added some code into the pipeline.py file to enable colmap. Now, I'm wondering if it would make sense to merge these changes into your repository. If you believe this feature would be useful for other users as well, I'd be willing to create a pull request.

Error in constructing the dense point cloud

I created my own data set which are a sequence of images and run the pipeline. The error I got is

46      3
       47      4
       48      1
       49      2
       50      1
       51      1
       52      1
There is no defined intrinsic data in order to compute an essential matrix for the initial pair.

However, using the castle example images, it worked just fine. The only difference between my data set and the castle one is that I don't have the file k.txt. Does anyone know how to popular the k.txt file? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.