ozendelait / rvc_devkit

Robust Vision Challenge Devkits
http://www.robustvision.net/
MIT License
107 stars 13 forks source link

How to write depth into .pfm file (VIPER)? #35

Closed KexianHust closed 4 years ago

KexianHust commented 4 years ago

Hi, is there any example for saving the predicted depth? Thank you!

srrichter commented 4 years ago

Depth maps are expected to be of size 1080x1920 and in .pfm format. An example function for saving pfm-files can be found e.g. here: MiDaS/utils.py:write_pfm

Using that function, you could convert your predicted depth maps stored as png files like that:

import pathlib
from imageio import imread
import numpy as np
from utils import write_pfm

for f in pathlib.Path('./predictions/').glob('**/*.png'):
    d = imread(f).astype(np.float32)
    write_pfm(f.with_suffix('.pfm'), d)
KexianHust commented 4 years ago

Thanks for your reply! One more question: are these uint16 or uint8 png files? Do I need to multiple 256.0 when saving the depth maps?

Thank you!

srrichter commented 4 years ago

Apart from the precision (16bit vs 8bit), this should not make a difference as depth predictions are (robustly, i.e. using median) scaled to match the ground truth scale before evaluating.