openmvg1.6编译与使用

12 篇文章 0 订阅
11 篇文章 4 订阅

写在前面

1、openmvg是一个用于实现structure from motion的开源库,实现了完整的sfm pipeline,并有说明文档:
https://openmvg.readthedocs.io/en/latest/
2、本文内容
openmvg v1.6的编译
openmvg v1.6的使用
3、平台
windows10, visual studio 2019
4、转载请注明出处:
https://blog.csdn.net/qq_41102371/article/details/123031709

获取代码

mkdir openmvg
cd openmvg
git clone --recursive https://github.com/openMVG/openMVG.git

clone下来的OpenMVG文件夹复制并将副本重命名为openMVG_v16

v1.6编译

cd openMVG_v16
# 将版本切换至v1.6
git checkout v1.6
cd ..

修改代码

使用vs2019编译会报错,issue里面已经解决,需要将v1.6的代码改一下
https://github.com/openMVG/openMVG/issues/1765

在src/openMVG/matching/kvld/algorithm.h里面,将anglefrom函数改成

inline bool anglefrom( const float& x, const float& y, float& angle )
{
  float ang = 0.f;
  if (x != 0 )
    ang = atan( y / x );
  else if (y > 0 )
    ang = PI_ / 2;
  else if (y < 0 )
    ang =- PI_ / 2;
  else return false;

  if (x < 0 )
    ang += PI_;
  while (ang < 0)
    ang += 2 * PI_;
  while (ang >= 2 * PI_)
    ang -= 2 * PI_;
  angle = ang;
  assert( angle >= 0 && angle < 2 * PI_ );
  return true;
}

编译Debug

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="./install_v16d" -S .\openMVG_v16\src\ -B .\build_v16d

如果出现了下面的warning
在这里插入图片描述
请换成

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="./install_v16d" -DOpenMVG_BUILD_GUI_SOFTWARES=OFF -S .\openMVG_v16\src\ -B .\build_v16d

不然后面会编译不通过

开始编译
可以使用以下命令编译,也可以用visual studio打开sln进行编译

cmake --build .\build_v16d --config Debug --target install

可能出现的问题:
error C1128: 节数超过对象文件格式限制: 请使用 /bigobj 进行编译,参考
https://www.cnblogs.com/YouLing0809/p/6735731.html

Release

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="./install_v16r" -DOpenMVG_BUILD_GUI_SOFTWARES=OFF -S .\openMVG_v16\src\ -B .\build_v16r
cmake --build .\build_v16r --config Release --target install

v1.6使用

官方教程
https://openmvg.readthedocs.io/en/latest/software/SfM/SfM/
下面提供两种方式

1、命令行逐步执行

新建文件夹

mkdir test

下载图像数据
https://github.com/openMVG/ImageDataset_SceauxCastle
将数据的image文件夹放在test目录下

初始化图像

mkdir .\test\matches
.\install_v16r\bin\openMVG_main_SfMInit_ImageListing.exe -i .\test\images -d .\openMVG_v16\src\openMVG\exif\sensor_width_database\sensor_width_camera_database.txt -o .\test\matches

计算特征

.\install_v16r\bin\openMVG_main_ComputeFeatures.exe -i .\test\matches\sfm_data.json -o .\test\matches

特征匹配

.\install_v16r\bin\openMVG_main_ComputeMatches.exe -i .\test\matches\sfm_data.json -o .\test\matches

增量式重建

mkdir .\test\output
.\install_v16r\bin\openMVG_main_IncrementalSfM.exe -i .\test\matches\sfm_data.json -m .\test\matches -o .\test\output

生成带颜色的点云

.\install_v16r\bin\openMVG_main_ComputeSfM_DataColor.exe -i .\test\output\sfm_data.bin -o .\test\output\sfm_data_color.ply

从已知位姿恢复结构

.\install_v16r\bin\openMVG_main_ComputeStructureFromKnownPoses.exe -i .\test\output\sfm_data.bin -m .\test\matches -o .\test\output\robustFitting.json

从已知的相机参数导出未失真的图像

.\install_v16r\bin\openMVG_main_ExportUndistortedImages -i .\test\output\sfm_data.bin -o .\test\undistortedImages

导出至openmvs进行稠密重建
https://openmvg.readthedocs.io/en/latest/software/MVS/OpenMVS/

mkdir .\test\mvs
.\install_v16r\bin\openMVG_main_openMVG2openMVS.exe -i .\test\output\robustFitting.json -d .\test\undistortedImages -o .\test\mvs\scene.mvs

2、用python

新建test_py文件夹,把images放在test_py下

python .\build_v16r\software\SfM\SfM_SequentialPipeline.py ./test_py/images ./test_py/reconstruction
mkdir .\test_py\mvs
.\install_v16r\bin\openMVG_main_openMVG2openMVS.exe -i .\test_py\reconstruction\reconstruction_sequential\sfm_data.bin -d .\test_py\undistortedImages -o .\test_py\mvs\scene.mvs

稠密重建

见:
openmvs编译与使用 https://blog.csdn.net/qq_41102371/article/details/123054992

参考

https://github.com/openMVG/openMVG/blob/develop/BUILD.md
https://www.cnblogs.com/YouLing0809/p/6735731.html

如有错漏,敬请指正
--------------------------------------------------------------------------------------------诺有缸的高飞鸟202202

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

诺有缸的高飞鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值