FACEBOOK SURROUND360 源码解析 第二篇 源码编译

经过第一篇我们成功的配置了surround360的编译环境,下面我们将进行编译工作。
(1)通过查看官方说明首先需要进行cmake设置
在surround360_render目录下打开终端并输入:
cmake -DCMAKE_BUILD_TYPE=Release
make
make之后等到运行到100%表示表示make成功,上述命令同时支持Release和Debug模式
(2)测试编译是否能欧运行
运行以下命令:
./bin/TestRenderStereoPanorama –help
如果能够显示帮助信息则表明程序能够运行
(3)准备数据
运行整个的开源项目需要提前准备三个数据文件,分别是内参/筒形畸变标定结果,矫正结果,鱼眼光学中心结果,详细信息可参考/surround360_render/CALIBRATION.md。具体流程如下:
step1:获取Rectification参数
在/surround360_render/bin目录下运行一下命令:
./TestRingRectification \
–logbuflevel -1 –stderrthreshold 0 –v 0 \
–rig_json_file ./res/config/17cmosis_default.json \
–src_intrinsic_param_file ./res/config/sunex_intrinsic.xml \
–output_transforms_file ~/Desktop/new_rectify_test/rectify.yml \
–root_dir ~/Desktop/new_rectify_test \
–frames_list 000000 \
–visualization_dir ~/Desktop/new_rectify_test/rectify_vis
注意:上述命令第五行,第六行,需要在桌面新建 new_rectify_test目录,或者选择自己想要设置的目录,
不用更改文件名 rectify.yml(需要传递的参数),命令执行完成后,将 rectify.yml文件复制到/surround360_render/res/config目录下。
step2:光学中心Optical Centering
该步骤专为鱼眼图像设置,由于一些不可控因素如相机精度等,鱼眼图像的中心一般会偏离大约40个像素,因此需要进行中心的重定位。在开始鱼眼中心定位之前需要用鱼眼相机采集图像,用镜头清洁布覆盖镜头获取图像,在surround360_render/res/example_data/test_fisheye_diffuse.png位置可以看到例子。
在桌面新建目录optical_center_calib,将/surround360_render/res/example_data/test_fisheye_diffuse.png和/surround360_render/res/config/17cmosis_default.json文件分别复制到该目录下,然后cd到/surround360_render目录下,运行以下命令:
./bin/TestIntrinsicCalibration \
–logbuflevel -1 –stderrthreshold 0 –v 0 \
–mode fisheye_optical_center \
–fisheye_optical_center_threshold 128 \
–fisheye_optical_center_src_image ~/Desktop/optical_center_calib/test_fisheye_diffuse.png \
–vis_output_dir ~/Desktop/optical_center_calib
运行完别关掉终端!
命令运行完成后在optical_center_calib目录下会得到一个白色的圆形位于黑色背景上的mask.png,十分接近标准圆,在上述命令运行完成时会出现:
I0711 15:14:01.539598 2031423488 IntrinsicCalibration.cpp:386] radius = 810.065
I0711 15:14:01.540668 2031423488 IntrinsicCalibration.cpp:387] centerOfMassX = 1021.78
I0711 15:14:01.540685 2031423488 IntrinsicCalibration.cpp:388] centerOfMassY = 1010.87
分别表示矫正后的半径和光学中心的坐标,找到17cmosis_default.json文件并将cam0,cam15和cam16的光学中心都改为上述的坐标值并另存为17cmosis_calibrated.json(需要传递的参数),记住不要改变半径的大小!!说明文档中有测试光学中心矫正结果的例子,有兴趣的可以自行查看,博主先行跳过。
step3:Intrinsic / Barrel Distortion内参筒形畸变
如果需要使用新的镜头采集图像则需要进行该步骤,否则下载的目录中已经包含了计算好的内参
/surround360_render/res/config/sunex_intrinsic.xml(需要传递的参数),如果大家需要重新计算内参请查看文档,操作类似之前的部分,简单易懂,不在赘述。

(4)运行程序
运行整个surround360项目需要找到surround360_render/scripts/run_all.py,大家不用阅读该python文件,博主将直接给出运行py文件所需的参数列表。
cd到surround360_render/scripts目录,运行一下命令:
python run_all.py –data_dir /home/dfy/software/Surround360-master/surround360_render –dest_dir /home/dfy/software/sample_dataset –enable_top –enable_bottom –enable_pole_removal –enable_render_coloradjust –save_debug_images –flow_alg pixflow_low –cam_to_isp_config_file /home/dfy/software/Surround360-master/surround360_render/res/config/isp/cam_to_isp_config.json –pole_masks_dir /home/dfy/software/Surround360-master/surround360_render/res/pole_masks –src_intrinsic_param_file /home/dfy/software/Surround360-master/surround360_render/res/config/sunex_intrinsic.xml –rectify_file /home/dfy/software/Surround360-master/surround360_render/res/config/rectify.yml –rig_json_file /home/dfy/software/optical_center_calib/17cmosis_calibrated.json

其中
–data_dir /home/dfy/software/Surround360-master/surround360_render表示原始数据的文件
–dest_dir /home/dfy/software/sample_dataset 目标目录,直接用下载数据集作为目标目录即可
–cam_to_isp_config_file /home/dfy/software/Surround360-master/surround360_render/res/config/isp/cam_to_isp_config.json 填写cam_to_isp_config.json 的路径(之前需要传递的参数之一)
下面几个参数同理。修改好相应的目录后运行命令,等待完成。运行时间比较长,博主一般需要半个小时,大家耐心等候。完成之后大家可以看到一些很有意思的图片,博主就先不剧透了。

本期博客到此结束,谢谢阅读!
下次将会解读其中比较感兴趣的部分源码,欢迎收看!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值