NerfingMVS实践步骤记录

  1. https://github.com/weiyithu/NerfingMVS

  2. https://colmap.github.io/install.html

  3. 升级cmake

    • 下载cmake源码包 wget https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4-linux-x86_64.tar.gz
    • 建立软链接
      sudo ln -sf /opt/cmake-3.21.4/bin/* /usr/bin/
    • cmake --version
  4. 注意下载使用NerfingMVS指定的colmap

  5. bash: /usr/bin/cmake: Permission denied。使用 chmod -R 777 cmake-3.21.4-linux-x86_64/

  6. Compiler: CMAKE_CUDA_COMPILER-NOTFOUND export PATH=/usr/local/cuda-10.1/bin/:$PATH

  7. cmake … -GNinja -DCMAKE_CUDA_ARCHITECTURES=‘61’

  8. no such file xxx/xxx/cameras.bin 修改colmap.sh中colmap路径

  9. mogrify: not found 安装命令 apt install imagemagick imageio-ffmpeg

待解决问题

  1. 有深度图但缺乏相机内参,导致无法转换为点云。
    深度图像和 3D 点云互转只涉及相机内参矩阵,其中
  • fx,fy 分别为镜头 x,y 方向的焦距(成像平面到镜头的距离)
  • cx,cy 分别是光心(镜头中心点在成像平面的投影)在图像坐标系(原点位于图像左上角,水平为 x,垂直为 y)下的坐标。在这里插入图片描述
import numpy as np
 
# 加载深度数据
img = np.genfromtxt('img_dep_640x480.csv', delimiter=',').astype(np.float32)
 
# 参数
CAM_WID, CAM_HGT = 640, 480
CAM_FX, CAM_FY = 795.209, 793.957
CAM_CX, CAM_CY = 332.031, 231.308
 
# 转换
x, y = np.meshgrid(range(CAM_WID), range(CAM_HGT))
x = x.astype(np.float32) - CAM_CX
y = y.astype(np.float32) - CAM_CY
 
img_z = img.copy()
if False:  # 如果需要矫正视线到Z的转换的话使能
    f = (CAM_FX + CAM_FY) / 2.0
    img_z *= f / np.sqrt(x ** 2 + y ** 2 + f ** 2)
 
pc_x = img_z * x / CAM_FX  # X=Z*(u-cx)/fx
pc_y = img_z * y / CAM_FY  # Y=Z*(v-cy)/fy
 
pc = np.array([pc_x.ravel(), pc_y.ravel(), img_z.ravel()]).T
 
# 结果保存
np.savetxt('pc.csv', pc, fmt='%.18e', delimiter=',', newline='\n')
 
# 从CSV文件加载点云并显示
pc = np.genfromtxt('pc.csv', delimiter=',').astype(np.float32)
 
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
 
ax = plt.figure(1).gca(projection='3d')
ax.plot(pc[:, 0], pc[:, 1], pc[:, 2], 'b.', markersize=0.5)
plt.title('point cloud')
plt.show()
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

AICVer

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

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

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

打赏作者

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

抵扣说明:

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

余额充值