Esempio n. 1
0
    args = parser.parse_args()
    depth_dir = args.depth_dir

    for filename in os.listdir(depth_dir):
        if not re.match(r'^\d{8}_init.pfm$', filename):
            continue

        depth_path = os.path.join(depth_dir, filename)
        if depth_path.endswith('npy'):
            depth_image = np.load(depth_path)
            depth_image = np.squeeze(depth_image)
            print('value range: ', depth_image.min(), depth_image.max())
            plt.imshow(depth_image, 'rainbow')
            # plt.show()
        elif depth_path.endswith('pfm'):
            depth_image = load_pfm(open(depth_path, 'rb'))
            ma = np.ma.masked_equal(depth_image, 0.0, copy=False)
            print('value range: ', ma.min(), ma.max())
            plt.imshow(depth_image, 'rainbow')
            # plt.show()
        elif depth_path.endswith('dmb'):
            depth_image = read_gipuma_dmb(depth_path)
            ma = np.ma.masked_equal(depth_image, 0.0, copy=False)
            print('value range: ', ma.min(), ma.max())
            plt.imshow(depth_image, 'rainbow')
            # plt.show()
        else:
            depth_image = cv2.imread(depth_path)
            ma = np.ma.masked_equal(depth_image, 0.0, copy=False)
            print('value range: ', ma.min(), ma.max())
            plt.imshow(depth_image)
Esempio n. 2
0
from preprocess import load_pfm
from preprocess import get_normal_from_depth
import os

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('depth_path')
    args = parser.parse_args()
    path = args.depth_path
    depth_files = os.listdir(os.path.join(path, 'depth'))
    mask_files = os.listdir(os.path.join(path, 'ground_truth'))
    depth_init_files = os.listdir(os.path.join(path, 'init'))
    prob_files = os.listdir(os.path.join(path, 'prob'))
    for i in range(0, len(depth_files)):
        if depth_files[i].endswith('.pfm'):
            depth_image = load_pfm(
                open(os.path.join(path, 'depth', depth_files[i]), 'rb'))
            #normal = get_normal_from_depth(depth_image)
            gt_image = load_pfm(
                open(os.path.join(path, 'ground_truth', mask_files[i]), 'rb'))
            #normal = get_normal_from_depth(gt_image)
            gt_image = cv2.resize(gt_image, (0, 0), None, 0.25, 0.25)
            init_image = load_pfm(
                open(os.path.join(path, 'init', depth_init_files[i]), 'rb'))
            prob_image = load_pfm(
                open(os.path.join(path, 'prob', prob_files[i]), 'rb'))
            mask = gt_image < 0
            depth_image[mask] = float('nan')

            init_image[mask] = float('nan')
            name, ext = os.path.splitext(depth_files[i])
            plt.imshow(depth_image, 'rainbow')
Esempio n. 3
0
    enable_prob_filter = True
    prob_threshold = 0.8

    errors = []
    if enable_median_scaling:
        ratios = []

    for scan in os.listdir(pred_dir):
        if scan != 'scan10':
            continue
        pred_depth_dir = os.path.join(pred_dir, scan, 'depths_mvsnet')
        gt_depth_dir = os.path.join(gt_dir, scan + '_train')
        for pred_depth_filename in os.listdir(pred_depth_dir):
            if not pred_depth_filename.endswith('_init.pfm'):
                continue
            pred_depth = load_pfm(
                open(os.path.join(pred_depth_dir, pred_depth_filename)))
            if enable_prob_filter:
                pred_prob_filename = pred_depth_filename[:-8] + 'prob.pfm'
                pred_prob = load_pfm(
                    open(os.path.join(pred_depth_dir, pred_prob_filename)))
                pred_depth[pred_prob < prob_threshold] = 0
            gt_depth_filename = 'depth_map_' + pred_depth_filename[4:8] + '.pfm'
            gt_depth = load_pfm(
                open(os.path.join(gt_depth_dir, gt_depth_filename)))

            mask = np.logical_and(gt_depth > 0, pred_prob > 0.8)
            pred_depth = pred_depth[mask]
            gt_depth = gt_depth[mask]
            if enable_median_scaling:
                ratio = np.median(gt_depth) / np.median(pred_depth)
                ratios.append(ratio)
Esempio n. 4
0
import numpy as np
import cv2
import argparse
import matplotlib.pyplot as plt
from preprocess import load_pfm

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('depth_path')
    args = parser.parse_args()
    depth_path = args.depth_path
    if depth_path.endswith('npy'):
        depth_image = np.load(depth_path)
        depth_image = np.squeeze(depth_image)
        print('value range: ', depth_image.min(), depth_image.max())
        plt.imshow(depth_image, 'rainbow')
        plt.show()
    elif depth_path.endswith('pfm'):
        depth_image = load_pfm(open(depth_path))
        ma = np.ma.masked_equal(depth_image, 0.0, copy=False)
        print('value range: ', ma.min(), ma.max())
        plt.imshow(depth_image, 'rainbow')
        plt.show()
    else:
        depth_image = cv2.imread(depth_path)
        ma = np.ma.masked_equal(depth_image, 0.0, copy=False)
        print('value range: ', ma.min(), ma.max())
        plt.imshow(depth_image)
        plt.show()