参考博客:
https://blog.csdn.net/qq_39615622/article/details/80967378
代码下载地址:
MVS:
https://github.com/cdcseacave/openMVS
文档:
http://cdcseacave.github.io/openMVS/
Required tools:
Visual Studio 2008 or newer are supported. Please note that the development is done mainly on Windows, so this platform build is well tested. The latest pre-built binaries for fast testing can be download from here. Visual Studio 2017 and dependencies automation tool vcpkg are used in this example.
#Make a toplevel directory for deps & build & src somewhere:
mkdir OpenMVS
cd OpenMVS
#Get and install dependencies using vcpkg;
#choose the desired triplet, like "x64-windows", by setting the VCPKG_DEFAULT_TRIPLET environment variable or by specifying it after each package:
vcpkg install zlib boost eigen3 ceres opencv cgal glew glfw3
#Get VCGLib (Required):
git clone https://github.com/cdcseacave/VCG.git
#Get and unpack OpenMVS in OpenMVS/src:
git clone https://github.com/cdcseacave/openMVS.git src
#Make build directory:
mkdir build
cd build
#Run CMake, where VCPKG_ROOT environment variable points to the root of vcpkg installation:
cmake . ..\src -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DVCG_ROOT="..\VCG"
#Open the solution in MSVC and build it
通过vcpkg编译好我们需要的的库:
.\vcpkg.exe install zlib:x64-windows boost:x64-windows eigen3:x64-windows ceres:x64-windows opencv:x64-windows cgal:x64-windows glew:x64-windows glfw3:x64-windows
然后新建OpenMVS文件夹
在里面git
git clone https://github.com/cdcseacave/VCG.git
git clone https://github.com/cdcseacave/openMVS.git src
然后再OpenMVS文件夹下新建一个build
打开build
输入命令:
cmake . ..\src -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE=G:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DVCG_ROOT=G:\VS2017code\OpenMVS\VCG
打开sln工程文件
会出现错误,因为由于CGAL版本过高,和OpenMVS不一致导致
15>LINK : fatal error LNK1181: cannot open input file '....\lib\x64\Release\MVS.lib'
16>LINK : fatal error LNK1181: cannot open input file '....\lib\x64\Release\MVS.lib'
15>Done building project "TextureMesh.vcxproj" -- FAILED.
16>Done building project "Viewer.vcxproj" -- FAILED.
13>LINK : fatal error LNK1181: cannot open input file '....\lib\x64\Release\MVS.lib'
13>Done building project "ReconstructMesh.vcxproj" -- FAILED.
14>LINK : fatal error LNK1181: cannot open input file '....\lib\x64\Release\MVS.lib'
14>Done building project "RefineMesh.vcxproj" -- FAILED.
17>------ Build started: Project: ALL_BUILD, Configuration: Release x64 ------
18>------ Skipped Build: Project: INSTALL, Configuration: Release x64 ------
18>Project not selected to build for this solution configuration
========== Build: 5 succeeded, 7 failed, 0 up-to-date, 6 skipped ==========
这里我们列出以下我们的版本:
CGAL 4.13.2
在一个issues中有同样的问题:
https://github.com/cdcseacave/openMVS/issues/374
最后的答案是:
卸载现有的CGAL,并重新安装CGAL 4.7
.\vcpkg.exe remove cgal:x64-windows
在vcpkg文件夹下找到CGAL
G:\vcpkg\ports\cgal
打开.cmake文件
这里我们主要修改REF和SHA512即可
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO CGAL/cgal
#REF releases/CGAL-4.13
REF releases/CGAL-4.7
#SHA512 3a12d7f567487c282928a162a47737c41c22258556ca0083b9cf492fc8f0a7c334b491b14dbfd6a62e71feeeb1b4995769c13a604e0882548f21c41b996d4eaf
SHA512 A1F9079D056CA162CC0B181CBBAD06B44CEDE2B835861EF76BF86B7A01F8ABF1C0E36E6129249CF8A63EE2C4383059B252F4E28251317C9812F63B80CE0DE4A5
HEAD_REF master
)
然后输入
.\vcpkg.exe install cgal:x64-windows
我们需要修改一下:
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO CGAL/cgal
#REF releases/CGAL-4.13
REF releases/CGAL-4.7
#SHA512 3a12d7f567487c282928a162a47737c41c22258556ca0083b9cf492fc8f0a7c334b491b14dbfd6a62e71feeeb1b4995769c13a604e0882548f21c41b996d4eaf
#SHA512 A1F9079D056CA162CC0B181CBBAD06B44CEDE2B835861EF76BF86B7A01F8ABF1C0E36E6129249CF8A63EE2C4383059B252F4E28251317C9812F63B80CE0DE4A5
SHA512 a1f9079d056ca162cc0b181cbbad06b44cede2b835861ef76bf86b7a01f8abf1c0e36e6129249cf8a63ee2c4383059b252f4e28251317c9812f63b80ce0de4a5
HEAD_REF master
)
然后把地址
G:\vcpkg\buildtrees\cgal
删除干净
又出现新的问题:
可能依赖的问题,我们放弃这种方式
把所有的CGAL信息全部换回原来的版本
编译CGAL4.13
重新下载MVS的代码进行编译
这次我们下载其他版本的代码
顺便记录一下时间段
选择develop,这是会不停更新的代码分支
作者说已经在这个分支里面解决了错误
修改一下命令,重新编译:
cmake . ..\openMVS-develop -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE=G:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DVCG_ROOT=G:\VS2017code\OpenMVS\VCG
笔记:下面的和本主题无关
打开GitHub,找到CGAL4.7
https://github.com/CGAL/cgal/releases?after=releases%2FCGAL-4.8.2