. Bundler简介

1. Bundler简介

Bundler是一个采用C和C++开发的称为sfm(struct-from-motion)的系统,它能够利用无序的图片集合(例如来自网络的图片)重建出3D的模型。最早的版本被用在Photo Tourism的项目上。项目的官方网站在此:http://phototour.cs.washington.edu/

Bundler的输入是一些图像、图像特征以及图像匹配信息,输出则是一个根据这些图像反应的场景的3D重建模型,伴有少量识别得到的相机以及场景几何信息。系统借用一个由Lourakis 和Argyros提供的称为Sparse Bundle Adjustment的开发包的修改版,一点一点递增地重建出图像场景。Bundler已经成功的应用在许多网络相册系统,尤其是一些建筑相册里。

Bundler 的源代码可以在这里下载:http://phototour.cs.washington.edu/bundler/。其最新的版本为bundler-v0.4-source.zip

2. Bundler的编译

下载到Bundler的源代码之后,我们首先要对其进行编译。在bundler-v0.4-source\vc++\文件夹下有Visual Studio2005创建的工程Bundler.sln,当然我们也可以使用更高的版本进行编译。

在编译过程中,我们会遇到以下问题,解决方法转自:http://blog.csdn.net/lxiaoxiaot/article/details/6721247

编译f2c时,会给出无法找到#include"sysdep1.h"文件的错误。进入f2c的目录,将sysdep1.h0文件名修改为sysdep1.h即可。

同时将signal1.h0文件名修改为signal1.h。再次编译f2c库时,会提示无法找到#include"arith.h"文件的错误,同时在f2c目录下并没有名字为arith.h的文件,这时可以新建一个arith.h文件,在文件里添加如下内容即可:

#define IEEE_8087
#define Arith_Kind_ASL 1
#define Long int
#define Intcast (int)(long)
#define Double_Align
#define X64_bit_pointers
#define QNaN0 0x0
#define QNaN1 0xfff80000

这时,编译f2c,便成功了。

接下来编译keyMatchFull和Bundler项目,一切顺利。

为了进行获得稠密的三围重建效果,利用Bundler提供的Bundle2PMVS和RadialUndistort工具,生成稠密重建PMVS软件所需的参数。

编译Bundlr2PMVS时,在Bundle2PMVS.cpp文件中会出现“未知的标识符mkdir”的错误。在文件的开头添加#include<direct.h>,

同时将mkdir替换为_mkdir,如下所示:

//mkdir(output_path,0770);

_mkdir(output_path);

至此,Bundle2PMVS编译成功。

编译RadialUndistort时,在RadialUndistort.cpp文件中会出现“无法识别的标识符index”。

原先的代码如下所示:

//char *space = index(buf, ' ');
//if (space) *space = 0;

将其替换为:

std::string str(buf);
int space_pos = str.find(' ');
str.at(space_pos) = 0;

files.push_back(str);

还会出现can't open  jpeglib.h jconfig.h jmorecfg.h的错误

解决:到bundler-v0.4-source\lib\jpeg\src目录下找到相应的头文件,拷贝到bundler-v0.4-source\include即可

至此,RadialUndistort编译成功。

3. Bundler的运行

编译完成后,需要将bundler-v0.4-source\vc++\Debug\目录下的Bundler.exe,KeyMatchFull.exe, RadialUndistort.exe, Bundle2PMVS.exe, jpeg.dll,ann_1.1_char.dll文件统统考到bundler-v0.4-source\bin\目录下。

在成功执行Bundler前,我们需要做几步准备工作:

(转自http://www.cnblogs.com/weizhoupan/archive/2011/03/05/Intro_on_Bundler.html

1.下载和安装Cygwin。Cygwin是许多自由软件的集合,最初由Cygnus Solutions开发,用于各种版本的Microsoft Windows上,运行UNIX类系统。由于Bundler默认是通过在Unix环境下执行shell脚本来启动Bundler的,因为在Windows环境下需要安装Cygwin以执行shell脚本。

要下载cygwin,直接在setup.exe上点右键“另存为”即可。也可以复制右边这个地址:http://cygwin.com/setup.exe

cygwin的安装比较简单,可以参考这篇教程:http://www.programarts.com/cfree_ch/doc/help/UsingCF/CompilerSupport/Cygwin/Cygwin1.htm

北京理工大学的童鞋可以添加这个镜像进行安装:http://mirror.bitunion.org/cygwin/.

但要注意一点,Bundler程序中会使用perl、python来进行一些预处理,因此在安装过程中需要把Devel、Perl、Python三个组件库都选上。另外还有ImageMagick这个库,用来处理图片。

下载安装的时间比较久,需要等待一段时间。安装过程中一些杀毒软件(比如360)可能会提示一些安全警告,无视即可。

2.下载特征检测器。Bundler推荐使用SIFT来进行特征提取,可以到SIFT的作者David Lowe的主页上下载他提供的SIFT Demo作为我们的检测器。下载页面为:http://www.cs.ubc.ca/~lowe/keypoints/ 或者直接点击右边的下载地址下载:SIFTdemo program (Version 4, July 2005)

下载完成后,解压该文档,将目录下的siftWin32.exe文件拷贝到BASE_PATH\bin目录中。

3.准备图片。将要进行分析处理的图片放到一个目录里,比如BASE_PATH\Pictures\中(下面也统一以Pictures代替图片目录)。作为例子,Bundler自己也提供了两套图片,分别放在BASE_PATH\examples\ET和BASE_PATH\examples\kermit中。

4.下面对运行Bundler的脚本文件进行修改:

把RunBundler.sh文件中BASE_PATH=$(dirname $(which $0)); 一句等号后边的东西替换为Bundler的根目录,也就是RunBundler.sh文件所在的目录,记得加双引号。如BASE_PATH="E:/SDK/bundler-v0.4-source";。

然后把ToSift.sh文件中BIN_PATH设为bin目录,如BIN_PATH="E:/SDK/bundler-v0.4-source/bin"。

5.执行bundler!

打开Cygwin,cd定位到Bundler根目录下,然后输入下面的命令测试一下例子的图片:

./RunBundler.sh examples/ET

会出现以下错误:

(1)程序执行后会出现找不到extract_focal.pl、 Bundler.exe、KeyMatchFull.exe、Bundler.exe等错误,但这些程序明明就在相应的目录下

解决:打开RunBundler.sh,定位到

EXTRACT_FOCAL=$BASE_PATH/bin/extract_focal.pl
OS=`uname -o`
if [ $OS == "Cygwin" ]
then
    MATCHKEYS=$BASE_PATH/bin/KeyMatchFull.exe
    BUNDLER=$BASE_PATH/Bundler.exe
else
    MATCHKEYS=$BASE_PATH/bin/KeyMatchFull
    BUNDLER=$BASE_PATH/bin/bundler
fi
TO_SIFT=$BASE_PATH/bin/ToSift.sh

将其改为:

EXTRACT_FOCAL=E:/bundler-v0.4-source/bin/extract_focal.pl
OS=`uname -o`
if [ $OS == "Cygwin" ]
then
    MATCHKEYS=E:/bundler-v0.4-source/bin/KeyMatchFull.exe
    BUNDLER=E:/bundler-v0.4-source/bin/Bundler.exe
else
    MATCHKEYS=E:/bundler-v0.4-source/bin/KeyMatchFull
    BUNDLER=E:/bundler-v0.4-source/bin/bundler
fi
TO_SIFT=G:/bundler-v0.4-source/bin/ToSift.sh

(2)variable 'dummy'  is not initialized

打开sfm.h定位到

typedef struct {
    double R[9];     /* Rotation */
    double t[3];     /* Translation */
    double f;        /* Focal length */
    double k[2];     /* Undistortion parameters */
    double k_inv[POLY_INVERSE_DEGREE]; /* Inverse undistortion parameters */
    char constrained[NUM_CAMERA_PARAMS];
    double constraints[NUM_CAMERA_PARAMS];  /* Constraints (if used) */
    double weights[NUM_CAMERA_PARAMS];      /* Weights on the constraints */
    double K_known[9];  /* Intrinsics (if known) */
    double k_known[5];  /* Distortion params (if known) */
    char fisheye;            /* Is this a fisheye image? */
    char known_intrinsics;   /* Are the intrinsics known? */
    double f_cx, f_cy;       /* Fisheye center */
    double f_rad, f_angle;   /* Other fisheye parameters */
    double f_focal;          /* Fisheye focal length */
    double f_scale, k_scale; /* Scale on focal length, distortion params */
} camera_params_t;

将其改为

typedef struct camera_params_t{
struct camera_params_t(){};
    double R[9];     /* Rotation */
    double t[3];     /* Translation */
    double f;        /* Focal length */
    double k[2];     /* Undistortion parameters */
    double k_inv[POLY_INVERSE_DEGREE]; /* Inverse undistortion parameters */
    char constrained[NUM_CAMERA_PARAMS];
    double constraints[NUM_CAMERA_PARAMS];  /* Constraints (if used) */
    double weights[NUM_CAMERA_PARAMS];      /* Weights on the constraints */
    double K_known[9];  /* Intrinsics (if known) */
    double k_known[5];  /* Distortion params (if known) */
    char fisheye;            /* Is this a fisheye image? */
    char known_intrinsics;   /* Are the intrinsics known? */
    double f_cx, f_cy;       /* Fisheye center */
    double f_rad, f_angle;   /* Other fisheye parameters */
    double f_focal;          /* Fisheye focal length */
    double f_scale, k_scale; /* Scale on focal length, distortion params */
} camera_params_t;

然后在把sfm.c文件名改为sfm.cpp

6.再次执行bundler!成功!!

4. 后续工作

Bundler输出的文件大多以“bundle_*.out”的形式来命名,我们称之为“bundle文件”。缺省命令下,Bundler在每张图片经过分析和注册(register)后都会输出一个相应的bundle文件用来保存当前的状态信息,并以“bundle_<n>.out”的形式命名。当所有的文件都注册后,Bundler就会输出一个最终的文件“bundle.out”。另外,每一回合结束时还会紧接着生成一些后缀名为“ply”的文件,这些文件包含的是经过重建后的相机和点的信息。这些ply文件可以通过使用专用的查看器scanalyze来查看,地址为:http://graphics.stanford.edu/software/scanalyze/。当然也可以通过meshlab来查看,下载地址为:http://meshlab.sourceforge.net/

利用Bundler可以得到较为稀疏的点云(pointclouds)数据。如果需要得到更密集的点,可以使用Yasutaka Furukawa博士写的另外一个非常强大的软件包,称为PMVS2,下载:http://grail.cs.washington.edu/software/pmvs/。一种比较常见的途径是使用Bundler来得到相机参数,然后使用Bundle2PMVS程序,将生成结果转换为PMVS2的输入,然后使用PMVS2来得到更密集的点云。另外,读者们可能会对另外一个同样由Furukawa博士开发的实用工具——CMVS感兴趣,CMVS是一个场景聚类程序,在使用PMVS2前可以使用它来进行一些预处理,下载:http://grail.cs.washington.edu/software/cmvs/

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
runtime-core.esm-bundler.js:41 [Vue warn]: Unhandled error during execution of beforeMount hook at <App> warn @ runtime-core.esm-bundler.js:41 logError @ runtime-core.esm-bundler.js:216 handleError @ runtime-core.esm-bundler.js:208 callWithErrorHandling @ runtime-core.esm-bundler.js:160 callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:166 hook.__weh.hook.__weh @ runtime-core.esm-bundler.js:2655 invokeArrayFns @ shared.esm-bundler.js:77 componentUpdateFn @ runtime-core.esm-bundler.js:5657 run @ reactivity.esm-bundler.js:178 instance.update @ runtime-core.esm-bundler.js:5814 setupRenderEffect @ runtime-core.esm-bundler.js:5822 mountComponent @ runtime-core.esm-bundler.js:5612 processComponent @ runtime-core.esm-bundler.js:5565 patch @ runtime-core.esm-bundler.js:5040 render @ runtime-core.esm-bundler.js:6332 mount @ runtime-core.esm-bundler.js:3824 app.mount @ runtime-dom.esm-bundler.js:1431 eval @ main.js:7 ./src/main.js @ app.js:85 __webpack_require__ @ app.js:359 (匿名) @ app.js:1539 __webpack_require__.O @ app.js:405 (匿名) @ app.js:1540 (匿名) @ app.js:1542 app.js:362 Uncaught TypeError: (0 , _test__WEBPACK_IMPORTED_MODULE_1__.holleTest) is not a function at eval (App.vue:77:1) at eval (runtime-core.esm-bundler.js:2675:1) at callWithErrorHandling (runtime-core.esm-bundler.js:158:1) at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:166:1) at hook.__weh.hook.__weh (runtime-core.esm-bundler.js:2655:1) at invokeArrayFns (shared.esm-bundler.js:77:1) at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5657:1) at ReactiveEffect.run (reactivity.esm-bundler.js:178:1) at instance.update (runtime-core.esm-bundler.js:5814:1) at setupRenderEffect (runtime-core.esm-bundler.js:5822:1)
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值