DTU训练集:
Cameras:
eg:00000000_cam.txt
extrinsic
0.970263 0.00747983 0.241939 -191.02
-0.0147429 0.999493 0.0282234 3.28832
-0.241605 -0.030951 0.969881 22.5401
0.0 0.0 0.0 1.0
intrinsic
361.54125 0.0 82.900625
0.0 360.3975 66.383875
0.0 0.0 1.0
425.0 2.5
其中extrinsic为相机外参数,intrinsic为相机内参数,最后一行为:DEPTH_MIN
DEPTH_INTERVAL
DEPTH_NUM
max_d
DEPTH_NUM
interval_scale
请注意,深度范围和深度分辨率由最小深度、两个深度样本之间的间隔以及深度样本数量(如果未提供,则在训练/测试脚本中)确定。我们还保留了用于控制深度分辨率的选项。然后,最大深度计算为:
DEPTH_MAX = DEPTH_MIN + (interval_scale * DEPTH_INTERVAL) * (max_d - 1)
pair.txr
第一行为数据集中包含的源图像的数目
之后的没两行为一小组,举例第二行和第三行
第二行:0为源图像的标号
第三行:第一个为10是参考图像的标号,第二个为参考图像的标号,第三个为参考图像和原图像的相似度;自此开始到最后,重复第二个和第三个的含义。
49
0
10 10 2346.41 1 2036.53 9 1243.89 12 1052.87 11 1000.84 13 703.583 2 604.456 8 439.759 14 327.419 27 249.278
1
10 9 2850.87 10 2583.94 2 2105.59 0 2052.84 8 1868.24 13 1184.23 14 1017.51 12 961.966 7 670.208 15 657.218
2
10 8 2501.24 1 2106.88 7 1856.5 9 1782.34 3 1141.77 15 1061.76 14 815.457 16 762.153 6 709.789 10 699.921
3
10 7 1294.39 6 1159.13 2 1134.27 4 905.717 8 687.32 5 600.015 17 496.958 16 481.969 1 379.011 15 307.45
Depths
存储的为pfm为一种深度图存储方式,可通过如下方式转换为png:
# -*- coding: UTF-8 -*-
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import os
import re
import cv2
def pfm_png_file_name(pfm_file_path, png_file_path):
# png_file_path = {}
save_path = png_file_path
for root, dirs, files in os.walk(pfm_file_path):
for file in files:
png_file_path = save_path
file = os.path.splitext(file)[0] + ".png"
files = os.path.splitext(file)[0] + ".pfm"
png_file_path = os.path.join(png_file_path, file)
pfm_file_path = os.path.join(root, files)
pfm_png(pfm_file_path, png_file_path)
def pfm_png(pfm_file_path, png_file_path):
print(pfm_file_path, png_file_path)
with open(pfm_file_path, 'rb') as pfm_file:
header = pfm_file.readline().decode().rstrip()
channel = 3 if header == 'PF' else 1
dim_match = re.match(r'^(\d+)\s(\d+)\s$', pfm_file.readline().decode('utf-8'))
if dim_match:
width, height = map(int, dim_match.groups())
else:
raise Exception("Malformed PFM header.")
scale = float(pfm_file.readline().decode().strip())
if scale < 0:
endian = '<' # little endlian
scale = -scale
else:
endian = '>' # big endlian
disparity = np.fromfile(pfm_file, endian + 'f')
img = np.reshape(disparity, newshape=(height, width))
img = np.flipud(img)
plt.imsave(os.path.join(png_file_path), img)
def main():
# E:\SFM\dtu_testing_output\scan1\depth_est
pfm_file_dir = 'E:/SFM/dtu_testing_output/scan1/depth_est/'
png_file_dir = 'E:/SFM/dtu_testing_output/scan1/depth_est/'
pfm_png_file_name(pfm_file_dir, png_file_dir)
if __name__ == '__main__':
main()
Rectified
rect_048_1_r5000.png:rect代表参考图像,048代表训练的组,1是在训练组中的参考图像的标号。
训练集中的类似