From fb3ab1e8f8027408694229580c2084032e0cb485 Mon Sep 17 00:00:00 2001 From: hesuicong Date: Mon, 21 Jul 2025 09:48:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.md | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 BUILD.md diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 0000000..ffc29be --- /dev/null +++ b/BUILD.md @@ -0,0 +1,108 @@ +------------ +Dependencies +------------ + +*OpenMVS* relies on a number of open source libraries, some optional, which are managed automatically by [vcpkg](https://github.com/Microsoft/vcpkg). For details on customizing the build process, see the build instructions. +* [Eigen](http://eigen.tuxfamily.org) version 3.4 or higher +* [OpenCV](http://opencv.org) version 2.4 or higher +* [Ceres](http://ceres-solver.org) version 1.10 or higher (optional) +* [CGAL](http://www.cgal.org) version 4.2 or higher +* [Boost](http://www.boost.org) version 1.56 or higher +* [VCG](http://vcg.isti.cnr.it/vcglib) +* [CUDA](https://developer.nvidia.com/cuda-downloads) (optional) +* [GLFW](http://www.glfw.org) (optional) + +------------------ +Build instructions +------------------ + +Required tools: +* [CMake](http://www.cmake.org) +* [git](https://git-scm.com) +* C/C++ compiler like Visual Studio 2019, GCC or Clang + +The dependencies can be fetched and built automatically using `vcpkg` on all major platform, by setting the environment variable `VCPKG_ROOT` to point to its path or by using the `cmake` parameter `-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake`. + +The latest pre-built stable binaries can be download from [here](https://github.com/cdcseacave/openMVS_sample/releases/latest). + +``` +#Clone OpenMVS +git clone --recurse-submodules https://github.com/cdcseacave/openMVS.git + +#Make build directory: +cd openMVS +mkdir make +cd make + +#Run CMake: +cmake .. + +#Build: +cmake --build . -j4 + +#Install OpenMVS library (optional): +cmake --install . +``` + +------------------- +Library usage +------------------- + +In order to use *OpenMVS* as a third-party library in your project, first compile it as described above or simply use `vcpgk`: +``` +vcpkg install openmvs +``` + +Inside your project CMake script, use: +``` +find_package(OpenMVS) +if(OpenMVS_FOUND) + include_directories(${OpenMVS_INCLUDE_DIRS}) + add_definitions(${OpenMVS_DEFINITIONS}) +endif() + +add_executable(your_project source_code.cpp) +target_link_libraries(your_project PRIVATE OpenMVS::MVS) +``` + +------------------- +Python API +------------------- + +The Python API can be enable by setting the `OpenMVS_USE_PYTHON` option to `ON` when running `cmake`. The Python API is built as a shared library and can be used in any Python project. Example: +``` +import pyOpenMVS + +def run_mvs(): + # set the working folder; all files used next are relative to this folder (optional) + pyOpenMVS.set_working_folder("folder/containing/the/scene") + # create an empty scene + scene = pyOpenMVS.Scene() + # load a MVS scene from a file + if not scene.load("scene.mvs"): + print("ERROR: scene could not be loaded") + return + # estimate depth-maps and fuse them into a point-cloud + if not scene.dense_reconstruction(): + print("ERROR: could not dense reconstruct the scene") + return + scene.save_pointcloud("pointcloud.ply") + # reconstruct a mesh from the point-cloud + if not scene.reconstruct_mesh(): + print("ERROR: could not reconstruct the mesh for this scene") + return + scene.save_mesh("mesh.ply") + # refine the mesh using gradient descent optimization (optional) + if not scene.refine_mesh(): + print("ERROR: could not refine the mesh for this scene") + return + scene.save_mesh("refined_mesh.ply") + # texture the mesh using the input images + if not scene.texture_mesh(): + print("ERROR: could not texture the mesh for this scene") + return + scene.save_mesh("textured_mesh.ply") + +if __name__ == "__main__": + run_mvs() +```