nyudepth v2数据集

毕设是单目深度估计。。。开始搞吧,一言难尽。。。


数据集地址:https://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html
数据集包括:

  • 1449张处理好的有标签和补全深度的。
  • Raw: The raw rgb, depth and accelerometer data as provided by the Kinect. 原始数据,Kinect拍的rgb和depth和加速度计的数据。
  • Toolbox: Useful functions for manipulating the data and labels.用于处理数据的常用函数。

Labeled Dataset

文件名是nyu_depth_v2_labeled.mat,可以用matlab打开。
我需要的是原图还有深度图。找了个脚本把图片提取出来了。
https://github.com/xmojiao/deeplab_v2/blob/master/nyu/mat_image.py
提取原图:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio
import h5py
import os 
f=h5py.File("nyu_depth_v2_labeled.mat")
images=f["images"]
images=np.array(images)
# images = images.transpose((0,1,3,2))

path_converted='./nyu_images'
if not os.path.isdir(path_converted):
    os.makedirs(path_converted)

from PIL import Image
images_number=[]
for i in range(len(images)):
    images_number.append(images[i])
    a=np.array(images_number[i])
#    print len(img)
    #img=img.reshape(3,480,640)
 #   print img.shape
    r = Image.fromarray(a[0]).convert('L')
    g = Image.fromarray(a[1]).convert('L')
    b = Image.fromarray(a[2]).convert('L')
    img = Image.merge("RGB", (r, g, b))
    img = img.transpose(Image.ROTATE_270)
    #img = img.rotate(270) 
    # plt.imshow(img)
    # plt.axis('off')
    # plt.show()
    iconpath='./nyu_images/'+str(i)+'.jpg'
    img.save(iconpath,optimize=True)

提取深度图:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio
import h5py
import os
from PIL import Image

f=h5py.File("nyu_depth_v2_labeled.mat")
depths=f["depths"]
depths=np.array(depths)

path_converted='./nyu_depths/'
if not os.path.isdir(path_converted):
    os.makedirs(path_converted)

max = depths.max()
print depths.shape
print depths.max()
print depths.min()

depths = depths / max * 255
depths = depths.transpose((0,2,1))

print depths.max()
print depths.min()

for i in range(len(depths)):
    # labels_number.append(labels[i])
    # labels_0=np.array(labels_number[i])
    # print labels_0.shape
    # print type(labels_0)
    print str(i) + '.png'
    depths_img= Image.fromarray(np.uint8(depths[i]))
    depths_img = depths_img.transpose(Image.FLIP_LEFT_RIGHT)
    #depths_img = depths_img.transpose((1,0,2));
    # depths_img = depths_img.rotate(270)
    iconpath=path_converted+str(i)+'.png'
    depths_img.save(iconpath, 'PNG', optimize=True)
0.jpg 原图

0.jpg 深度图

你可能感兴趣的:(nyudepth v2数据集)