用pmvs生成密集点云

下载CMVS-PMVS点击打开链接

一。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

CMVS-PMVS的配置:

         Yasutaka Furukama网站上提供的CMVS是基于Linux上的比较。好在有个人将它转成了可以在Windows下运行的文件,见http://francemapping.free.fr/Portfolio/Prog3D/CMVS.html
(1)  下载CMVS-PMVS并解压缩。发现里面有一个binariesWin-Linux文件夹,里面有配置好的基于Linux,Win32,和Win64的可执行程序(多么的人性化呀)。
(2)  进入/Win64-vs2010文件夹,建一个文件夹叫ET。将上面配置好的文件夹/pmvs考到这个ET里面。下面执行3行命令行就可以生成我们最后想要得到的稠密网格模型啦(坚持就是胜利)。可以参考/Win64-vs2010里面的Readme.txt。
>cmvs.exe ET/pmvs/ maximage[=100] CPU[=4]
>genOption.exe ET/pmvs/       
>pmvs2.exe ET/pmvs/ option-0000

(注意地址后面要加/)
这样,我们发现/pmvs/models/文件夹多了几个文件,其中*.ply文件为3D模型文件用下面的软件可以查看。


稠密网格的显示:

      强烈建议使用MeshLab:http://meshlab.sourceforge.net/,GUI做的很好。非常方便使用。
(1) 创建一个新的New Empty Project。
(2) File->InputMesh,进入/ET/pmvs/models(没有忘记这个文件夹怎么来的吧?),读入里面的模型文件就大功告成啦!

发一张结果图:
由这几张图片
用pmvs生成密集点云_第1张图片
生成
用pmvs生成密集点云_第2张图片

二。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

. CMVS

Clustering Views for Multi-view Stereo (CMVS)也是 Yasutaka Furukawa (博士后时期)写的,它包含了PMVS2的内容,提升的地方在于:更高的性能,更好的效果。CMVS将SFM的输出分成一个个小的图片簇,然后独立并行的重建。几者的关系的关系:

Bundler->CMVS->PMVS2

5.1 输出

  • ske.dat:包含集群信息;

  • vis.dat:可见性信息;

  • centers-%04d.ply:各个图片簇的相机位置;

  • centers-all.ply:所有的相机位置信息;

  • option-%04d:PMVS2配置文件;

  • pmvs.sh or pmvs.bat:用于执行PMVS2;

5.2 编译(Windows & VS2013)

这里以 Pierre Moulon 开发的Windows版本 CMVS + genOption + PMVS2 为例说明(链接,github)。
首先,代码中包含自带的已经编译好的程序,目录:./binariesWin-Linux/Win64-VS2010。以下是自己编译的过程:

  • 使用CMake生成VS工程,CMake文件是 ./program/CMakeLists.txt,打开CMake GUI,选择源码路径为program,配置好,点击生成,最后会生成一个叫做 CMVS-PMVS2.sln 的VS工程。

  • 打开工程,使用VS编译,当然,一般都会报几个错误:

    • 命令行 error D8016: “/O1”和“/RTC1”命令行选项不兼容:将 项目->C/C++->代码生成->基本运行时检查设置为default,问题解决(参考)。

解决了这个问题之后就没有遇到其他问题了!接下来就是将要用到的输出copy出来运行(在main的Debug目录下)。

5.3 运行

  1. 运行bundler:cd到example下的ET或者kermit目录下,运行 ../../RunBundler.sh,参数默认的就行,成功后会生成./bundle目录,成功的话会有 bundle_XXX.out 和 pointsXXX.ply 文件;

  2. 转换bundler输出为PMVS所需格式:cd 到 kermit 目录下,运行:../../bin/Bundle2PMVS.exe prepare/list.txt bundle/bundle.out,得到结果如下(可见的结果就是生成了一个pmvs的目录):

    [ReadBundleFile] Bundle version: 0.300
    [ReadBundleFile] Reading 11 images and 671 points...
    [GetJPEGDimensions] File ./kermit000.jpg: ( 640 , 480 )
    ......
    @@ Conversion complete, execute "sh pmvs/prep_pmvs.sh" to finalize
    @@ (you will first need to edit prep_pmvs.sh to specify your bundler path,
    @@  so that the script knows where to find your
    @@  RadialUndistort and Bundle2Vis binaries)
  3. 运行pmvs目录下的prep_pmvs.sh校正和生成vis.dat文件:先修改prep_pmvs.shBUNDLER_BIN_PATH的值,我是在kermit路径下运行的,所以改为:"../../bin"

    > 这里遇到一个bug:提示无法找到“XXXXX.rd.jpg”,实际pmvs目录下生成的图像不带“rd”。看了哈源代码,是**RadialUndistort.cpp**中出的问题,大概是C字符串和string转换造成的吧,将`file[i].rfint('.')`改成`file[i].fint('.',1)`,**file[i]**为list.txt下的一行,后面带的数字中有小数点,导致源代码提取basename出错。
    
  4. 执行CMVS:先执行CMVS prefix 20 2,这里已经到了cmvs的部分了,需要先把编译好的三个文件copy过来(cmvs.exe,genOption.exe,pmvs2.exe),参数的含义可以看cmvs自带的release路径下的readme。

  5. 生成pmvs的参数文件:经过cmvs之后,原来的图片被分成一个个的图片簇(如果你的图片较少则只会有一个簇),所以相应的pmvs参数也要改变,这正是这一步的意义。命令:genOption path,这里的path建议和上一步的path一致。

  6. 生成稠密点云:最后执行pmvs.bat生成稠密点云,运行前可能需要修改路径


三。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

At first, you need install bundler and cmvs correctly, the install reference as follow:

(a) http://www.cnblogs.com/weizhoupan/archive/2011/03/08/1977366.html----(bundler setup)
(b) https://github.com/pmoulon/CMVS-PMVS----(download cmvs-pmvs and build it,there is need install gsl)

Then, the follow step is for run:
1) mkdir a directory "result"
   (a) copy the execute file "cmvs","genOption","pmvs2" to this "result" directory
   (b) change current directory to "result" in terminal
2) $ ../RunBundler.sh  [dataset path]    //for example: ../RunBundler.sh ../examples/ET
   $ ../bin/Bundle2PMVS list.txt bundle/bundle.out
3) there is generate a folder "pmvs" and a file "prep_pmvs.sh", edit "prep_pmvs.sh" as follow:
   (a) change the BUNDLER_BIN_PATH as "../bin"
   (b) and change the move image source filename as follow:
           mv pmvs/../examples/Kermit/kermit000.rd.jpgpmvs/visualize/00000000.jpg
                  -->mv pmvs/kermit000.rd.jpgpmvs/visualize/00000000.jpg
4) $ pmvs/prep_pmvs.sh
5) change the options.txt as follow:    (optional)
     --match_table matches.init.txt
     --output bundle2.out          //change
     --output_all bundle_
     --output_dir bundle
     --variable_focal_length
     --use_focal_estimate
     --constrain_focal
     --constrain_focal_weight 0.0001
     --estimate_distortion
     --rerun_bundle
     --bundle bundle/bundle.out    //add
6) $ ../bin/bundler list.txt --options_file options.txt    (optional)
7) $ ./cmvs pmvs/
   $ ./genOption pmvs/
   $ ./pmvs2 pmvs/ option-0000

文件夹中.ply是重构后的图像,可用meshlab打开。
另外说一句,我在gcc4.9版本下无法编译通过,是切换到gcc4.8下编译通过的(如果后续有人编译时有问题,可能需要先检查下gcc版本)。 如果你安装了多个gcc版本,可用以下指令来方便地切换当前的gcc版本: sudo update-alternatives --config gcc

四。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

三.PMVS(CMVS)的下载与安装

1.PMVS(CMVS)下载
Bundler官网上提供的PMVS链接已经失效,PMVS2和CMVS的官网地址分别为:http://www.di.ens.fr/pmvs/ ,http://www.di.ens.fr/cmvs , 我们可以在上面下载PMVS和CMVS。
PMVS2的下载包为:pmvs-2-fix0.tar.gz(http://www.di.ens.fr/pmvs/pmvs-2-fix0.tar.gz)
CMVS的下载包为:cmvs-fix2.tar.gz (243Mb)(http://www.di.ens.fr/cmvs/cmvs-fix2.tar.gz)
2.PMVS(CMVS)安装
(1) PMVS2安装
安装可以参考官网的官方说明(http://www.di.ens.fr/pmvs/documentation.html)
Compilation
We suggest on using the binary distribution, but if you choose to compile the source codes, try the following.Make sure you have all the libraries listed above in your system.
Go to directory "program/main"
Add INCLUDE and LDLIBRARY paths to Makefile
make depend
make
按照官方这个说明一步步进行。需要注意的是我们可能需要安装一些依赖包:
sudo apt-get install libgtk2.0-dev libdevil-dev libboost-all-dev libatlas-cpp-0.6-dev libatlas-dev imagemagick libcminpack-dev libgfortran3 libmetis-edf-dev libparmetis-dev freeglut3-dev libgsl0-dev
sudo apt-get install libgsl0-dev libblas-dev libatlas-dev liblapack-dev liblapacke-dev
此外还需要一个编译过的目标文件 mylapack.o (该文件貌似在老版本里,新版本里不知为何移除了?)
编译过程中可能出现的错误:
g++ -c -O2 -Wall -Wno-deprecated -I/usr/include ../base/numeric/mylapack.cc
../base/numeric/mylapack.cc:6:25: fatal error: clapack/f2c.h: No such file or directory
compilation terminated.
Makefile:39: recipe for target 'mylapack.o' failed
修改方法:
Update ../base/numeric/mylapack.cc
From:
extern "C" {
#include
#include };
To:
extern "C" {
//#include
//#include
#include };
#define integer int
Update ../base/numeric/mylapack.h
From:
static void lls(std::vector& A, std::vector& b, long int width, long int height);
static void lls(std::vector& A, std::vector& b, long int width, long int height);
To:
static void lls(std::vector& A, std::vector& b, int width, int height);
static void lls(std::vector& A, std::vector& b, int width, int height);
(2) CMVS安装
安装可以参考官网的官方说明(http://www.di.ens.fr/cmvs/documentation.html)
1)安装依赖软件和库
Bundler
PMVS2
Graclus(http://userweb.cs.utexas.edu/users/dml/Software/graclus.html)。下载完后需要根据个人系统是32位还是64位修改下编译配置文件Makefile.in中的option项即
COPTIONS = -DNUMBITS=32#32位机器
COPTIONS = -DNUMBITS=64#64位机器
修改完成后在终端执行make即可。
2)安装CMVS
cd ./pmvs-2// Go to PMVS2 directory
mv program/main/Makefile program/main/Makefile.bak  // Back-up Makefile
然后讲下载的CMVS包解压并将文件(夹)覆盖PMVS的文件夹。然后修改Makefile文件,只要是要将前面安装的Graclus的目录包括进去。
YOUR_INCLUDE_METIS_PATH = -I/path/to/your/graclus1.2/metisLib
注意前面要加上“-I"。同时需要将graclus1.2下的ibmetis.a、libmultilevel.a两个文件放置到Makefile里设置的YOUR_LDLIB_PATH路径下。另外值得注意的是,下载的cmvs中的Makefile文件里有两行(10,13行)说明内容没有注释掉,需要手动注释(前面加#号即可)。
修改完Makefile文件后make即可。
如果出现下面错误:
../base/cmvs/bundle.cc:1134:52: error: ‘accumulate’ was not declared in this scope
修改方法:
Add this to ../base/cmvs/bundle.cc
#include
如果出现下面错误:
用pmvs生成密集点云_第3张图片
修改方法:
Add this to genOption.cc
#include
按照上面方法修改之后重新make即可。
安装成功后将会得到 pmvs2、cmvs、genOption三个二进制文件。
3.PMVS使用
以PMVS工具包里自带的data/hall为例:
默认指令
./pmvs2 ../../data/hall/ option.txt
如果你的机器内存不是很大的话, 可以分成两步执行
./pmvs2 ../../data/hall/ option.txt-0000
./pmvs2 ../../data/hall/ option.txt-0001
如果你的机器内存足够的话,可以常识下面指令获得稠密点云
./pmvs2 ../../data/hall/ option-highres.txt
结果将会保存在文件夹hall/models/下,如果采用的是默认指定,那么将会得到以下三个文件:
outputs.option.txt.ply (colored 3d points for visualization)
option.txt.patch (full reconstruction information)
option.txt.pset (input file for PoissonSurfaceRecon by Michael Misha Kazhdan and Matthew Bolitho)
这几个文件中保存的就是稠密重建点云信息。
4.CMVS使用
使用可以参考官方文档(http://www.di.ens.fr/cmvs/documentation.html)
Command specifications
cmvs
Usage: ./cmvs prefix maximage[=100] CPU[=4]
Example: If you want to specify maximage=70 and CPU=6 with the data directory located at ./pmvs, try the following command
./cmvs ./pmvs/ 70 6
You should choose maximage based on the amount of memory in your machine.
CPU should be the number of (virtual) CPUs or cores in your machine.
If you want more control of the program, look into the comments inside program/main/cmvs.cc
genOption
Usage: ./genOption prefix level[=1] csize[=2] threshold[=0.7] wsize[=7] minImageNum[=3] CPU[=8]
Parameters are for PMVS2 option files.
5.稠密点云的可视化
上面利用PMVS进行稠密重建得到的结果outputs.option.txt.ply可以用一些可视化软件进行显示,这里我们可以采用MeshLab。

你可能感兴趣的:(3D,reconstruction)