├── dataset_links.txt ├── README.md └── dataset_maker.py /dataset_links.txt: -------------------------------------------------------------------------------- 1 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Adirondack-perfect.zip 2 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Backpack-perfect.zip 3 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Bicycle1-perfect.zip 4 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Cable-perfect.zip 5 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Classroom1-perfect.zip 6 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Couch-perfect.zip 7 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Flowers-perfect.zip 8 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Jadeplant-perfect.zip 9 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Mask-perfect.zip 10 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Motorcycle-perfect.zip 11 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Piano-perfect.zip 12 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Pipes-perfect.zip 13 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Playroom-perfect.zip 14 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Playtable-perfect.zip 15 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Recycle-perfect.zip 16 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Shelves-perfect.zip 17 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Shopvac-perfect.zip 18 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Sticks-perfect.zip 19 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Storage-perfect.zip 20 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Sword1-perfect.zip 21 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Sword2-perfect.zip 22 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Umbrella-perfect.zip 23 | http://vision.middlebury.edu/stereo/data/scenes2014/zip/Vintage-perfect.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MiddleBury Stereo dataset manipulator 2 | Small python script that downloads middlebury stereo dataset 2014, converts PFM file to PNG. Then, it saves gray and depth into 2 pickles for later use with Tensorflow 3 | 4 | 5 | http://vision.middlebury.edu/stereo/data/ 6 | 7 | ### Prerequisites 8 | 9 | ``` 10 | Linux or Debian OS 11 | ``` 12 | 13 | ``` 14 | Pickle 15 | openCV 16 | imagemagick 17 | ``` 18 | 19 | ## Running the tests 20 | 21 | 22 | ``` 23 | python3 dataset_maker.py 24 | ``` 25 | 26 | ## References 27 | 28 | * [Middlebury dataset](http://vision.middlebury.edu/stereo/data/) - Middlebury stereo dataset 29 | * [Middlebury dataset papers](http://vision.middlebury.edu/stereo/taxonomy-IJCV.pdf) - [1] D. Scharstein and R. Szeliski. A taxonomy and evaluation of dense two-frame stereo correspondence algorithms. 30 | International Journal of Computer Vision, 47(1/2/3):7-42, April-June 2002. 31 | * [Middlebury dataset papers](http://www.cs.middlebury.edu/~schar/papers/structlight/) - [2] D. Scharstein and R. Szeliski. High-accuracy stereo depth maps using structured light. 32 | In IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR 2003), volume 1, pages 195-202, Madison, WI, June 2003. 33 | * [Middlebury dataset papers](http://www.cs.middlebury.edu/~schar/papers/LearnCRFstereo_cvpr07.pdf) - [3] D. Scharstein and C. Pal. Learning conditional random fields for stereo. 34 | In IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR 2007), Minneapolis, MN, June 2007. 35 | * [Middlebury dataset papers](http://www.cs.middlebury.edu/~schar/papers/evalCosts_cvpr07.pdf) - [4] H. Hirschmüller and D. Scharstein. Evaluation of cost functions for stereo matching. 36 | In IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR 2007), Minneapolis, MN, June 2007. 37 | * [Middlebury dataset papers](http://www.cs.middlebury.edu/~schar/papers/datasets-gcpr2014.pdf) - [5] D. Scharstein, H. Hirschmüller, Y. Kitajima, G. Krathwohl, N. Nesic, X. Wang, and P. Westling. High-resolution stereo datasets with subpixel-accurate ground truth. 38 | In German Conference on Pattern Recognition (GCPR 2014), Münster, Germany, September 2014. 39 | 40 | 41 | ## License 42 | Check [Middleburry dataset](http://vision.middlebury.edu/stereo/data/) - License 43 | -------------------------------------------------------------------------------- /dataset_maker.py: -------------------------------------------------------------------------------- 1 | import os 2 | import glob 3 | import cv2 4 | import numpy as np 5 | import pickle 6 | 7 | # Read links from txt file 8 | links_file_name = "dataset_links.txt" 9 | 10 | 11 | # Download all selected links to local drive 12 | with open(links_file_name, 'r') as links_file: 13 | 14 | link = links_file.readline() 15 | 16 | while link: 17 | print(link) 18 | # download file 19 | ret = os.system('wget -c ' + link) 20 | if ret == 0: 21 | link = links_file.readline() 22 | 23 | # unzipping all downloaded file 24 | # Getting all filenames 25 | zip_names = glob.glob('*.zip') 26 | 27 | for filename in zip_names: 28 | os.system('unzip ' + filename) # unzipping 29 | os.system('rm ' + filename) # removing zip file to save space 30 | 31 | # Converting PFM to PNG 32 | filenames = glob.glob('*-perfect') # All unzip filenames 33 | print('PFM to PNG conversion ...') 34 | for filename in filenames: 35 | 36 | # Removing -sd.pfm since I am not interested in those 37 | sd_pfm_files = glob.glob(filename + '/*-sd.pfm') 38 | for sd_pfm_file in sd_pfm_files: 39 | os.system('rm ' + sd_pfm_file) 40 | 41 | # Converting PFM to PNG 42 | pfm_files = glob.glob(filename + '/*.pfm') 43 | for pfm_file in pfm_files: 44 | png_filename = pfm_file[:-4] # removing .pfm to be replaced by PNG 45 | os.system('convert ' + pfm_file + ' ' + png_filename + '.png') 46 | os.system('rm ' + pfm_file) 47 | 48 | # removing pgm files since I am not interested in those 49 | pgm_files = glob.glob(filename + '/*.pgm') 50 | for pgm_file in pgm_files: 51 | os.system('rm ' + pgm_file) 52 | # removing lightning images (E & L) since I am not interested in those 53 | lightning_file = glob.glob(filename + '/*1L.png') 54 | os.system('rm ' + lightning_file[0]) 55 | lightning_file = glob.glob(filename + '/*1E.png') 56 | os.system('rm ' + lightning_file[0]) 57 | 58 | ## Creation of the pickle 59 | depth_imgs = [] 60 | gray_imgs = [] 61 | 62 | for filename in filenames: 63 | png_depth_files = glob.glob(filename + '/disp*.png') 64 | png_im_files = glob.glob(filename + '/im*.png') 65 | for png_depth_file, png_im_file in zip(png_depth_files, png_im_files): 66 | # Adding depth file 67 | depth = cv2.imread(png_depth_file, 0) # read as gray img 68 | depth = depth / 255.0 # normalizing 69 | depth_imgs.append(depth) 70 | # Adding im file as gray 71 | im = cv2.imread(png_im_file, 0) # read as gray image 72 | im = im / 255.0 # normalizing 73 | gray_imgs.append(im) 74 | 75 | # File lists are ready, let's save them into a pickle 76 | # Saving depth images 77 | with open('depth.pickle', "wb") as pickle_out: 78 | pickle.dump(depth_imgs, pickle_out) 79 | 80 | # Saving gray images 81 | with open('gray.pickle', "wb") as pickle_out: 82 | pickle.dump(gray_imgs, pickle_out) 83 | 84 | # Done --------------------------------------------------------------------------------