-
https://github.com/weiyithu/NerfingMVS
-
https://colmap.github.io/install.html
-
升级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
-
注意下载使用NerfingMVS指定的colmap
-
bash: /usr/bin/cmake: Permission denied。使用 chmod -R 777 cmake-3.21.4-linux-x86_64/
-
Compiler: CMAKE_CUDA_COMPILER-NOTFOUND export PATH=/usr/local/cuda-10.1/bin/:$PATH
-
cmake … -GNinja -DCMAKE_CUDA_ARCHITECTURES=‘61’
-
no such file xxx/xxx/cameras.bin 修改colmap.sh中colmap路径
-
mogrify: not found 安装命令 apt install imagemagick imageio-ffmpeg
待解决问题
- 有深度图但缺乏相机内参,导致无法转换为点云。
深度图像和 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()