lioryariv / idr

MIT License
701 stars 85 forks source link

cameras.npz file #29

Closed derrick-xwp closed 2 years ago

derrick-xwp commented 2 years ago

In order to run IDR on new data [DIR PATH], you need to supply image and mask directories, as well as cameras.npz file containing the appropriate camera projection matrices.

Dear authors,

Do we need to convert camera projection matrices in DTU dataset from txt to npy files?

Thanks

teachyourselfcoding commented 2 years ago

+1. Any chance of how to obtain the .npz file? Been searching around everywhere for a solution for this.

lioryariv commented 2 years ago

Hi, Yes, the normalization code of the cameras is acting on cameras.npz file. For DTU, this npz file is a simple parsing of the txt files, meaning:

cameras = {}
n_cameras = 49 # or 64
scan_folder = 'DTU_preprocessed/scan65'
path_to_dtu_cameras = 'DTU/SampleSet/MVS Data/Calibration/cal18'
for i in range(n_cameras):
    filename = '{0}/pos_{1}.txt'.format(path_to_dtu_cameras, '%03d' % (i + 1))
    lines = open(filename).read().splitlines()
    lines = [[x[0], x[1], x[2], x[3]] for x in (x.split(" ") for x in lines)]
    P = np.asarray(lines).astype(np.float32).squeeze()
    P = np.concatenate([P, [[0, 0, 0, 1]]], 0)
    cameras['world_mat_%d' % i] = P
np.savez('{0}/cameras.npz'.format(scan_folder), **cameras)

And maybe you'll need to make this code compatible with your pathnames.

derrick-xwp commented 2 years ago

Do we need to process the downloaded camera parameters in DTU dataset first before converting them to npz files?

lioryariv commented 2 years ago

As can be seen in the code in the previous comment, the only thing that needs to do to the camera parameters is to make them 4x4 instead of 3x4.

teachyourselfcoding commented 2 years ago

Hi, thank you for your work. Currently, I have these three files: cameras.bin/txt, cameras.bin/txt, poses3D.bin/txt. These 3 files contain all the data for my images. It seems from your previous reply that you are using individual.txt file for each image (/pos_{1}.txt'), can you provide me with any advice on how to obtain cameras.npz file? Thanks for you time~!

siyangbing commented 2 years ago

嗨,谢谢你的工作。目前,我有这三个文件:cameras.bin/txt、cameras.bin/txt、poses3D.bin/txt。这 3 个文件包含我的图像的所有数据。从您之前的回复看来,您对每张图片都使用了 individual.txt 文件(/pos_{1}.txt'),您能给我提供有关如何获取 camera.npz 文件的任何建议吗?谢谢你的时间~!

I have the same question , can you help me