def do_post( self, lcost, rcost, save_path, display, interpolate=False, # added by CCJ; isLocalExp=True): imgl = self.imgl.astype(np.float32) imgr = self.imgr.astype(np.float32) imgl = (imgl - np.mean(imgl)) / np.std(imgl) imgr = (imgr - np.mean(imgr)) / np.std(imgr) #**************** # added by CCJ; if (isLocalExp): print 'running local expansion ...' displ = self.__postprocessing_localExp(lcost.astype(np.float32), display) elif (interpolate): displ = self.__postprocessing_mem_interp(imgl, imgr, lcost, -1, display) else: displ = self.__postprocessing_mem(imgl, imgr, lcost, -1, display) pfm.save(save_path, displ.astype(np.float32)) print("Saved {}".format(save_path))
def do_post(self, lcost, rcost, save_path, display, interpolate=False): imgl = self.imgl.astype(np.float32) imgr = self.imgr.astype(np.float32) imgl = (imgl - np.mean(imgl)) / np.std(imgl) imgr = (imgr - np.mean(imgr)) / np.std(imgr) if (interpolate): displ = self.__postprocessing_mem_interp(imgl, imgr, lcost, -1, display) else: displ = self.__postprocessing_mem(imgl, imgr, lcost, -1, display) print "Saving" pfm.save(save_path, displ.astype(np.float32))
from __future__ import division import numpy as np import matplotlib.pyplot as plt import sys import math import random import os sys.path.insert(0, '../pylibs') sys.path.insert(0, '../src') import cpputils import pfmutil as pfm l_gt_p = "..../Freiburg/driving/disparity/15mm_focallength/scene_forwards/slow/left/" r_gt_p = "..../Freiburg/driving/disparity/15mm_focallength/scene_forwards/slow/right/" save_p = ".../Freiburg/driving/disparity/15mm_focallength/scene_forwards/slow/left_nonocc/" ims = os.listdir(l_gt_p) for im in ims: l_gt = pfm.load(l_gt_p + im)[0] r_gt = pfm.load(r_gt_p + im)[0] occ = cpputils.make_occ(l_gt, r_gt) pfm.save(save_p + im, occ)
if __name__ == "__main__": if 0: fname = "/mnt/interns/changjiang/PatientPositioning/Datasets/surreal/cmu/train/run0/01_01/01_01_c0001_depth.mat" dataroot = "/mnt/interns/changjiang/PatientPositioning/Datasets/surreal/small-data/depth" dep = load_anno_mat(fname) #print ("type : ", type(dep), "keys : %s" % sorted(dep.keys())) #for i in range(1,101): for i in range(0,4): dep_key_name = 'depth_%d' % (i+1) dep_name = 'depth_%03d' % i depth = dep[dep_key_name] depth[depth == 1e+10] = np.inf #depth[depth == 1e+10] = 0 cv2.imwrite(dataroot + '/' + dep_name + ".png", depth.astype(np.uint16)) pfm.save(dataroot + '/' + dep_name + ".pfm", 1000.0*depth.astype(np.float32)) #dep_names = ['depth_1', 'depth_10', 'depth_100', 'depth_11', 'depth_12', 'depth_13', 'depth_14', 'depth_15', 'depth_16', 'depth_17', 'depth_18', 'depth_19', 'depth_2', 'depth_20', 'depth_21', 'depth_22', 'depth_23', 'depth_24', 'depth_25', 'depth_26', 'depth_27', 'depth_28', 'depth_29', 'depth_3', 'depth_30', 'depth_31', 'depth_32', 'depth_33', 'depth_34', 'depth_35', 'depth_36', 'depth_37', 'depth_38', 'depth_39', 'depth_4', 'depth_40', 'depth_41', 'depth_42', 'depth_43', 'depth_44', 'depth_45', 'depth_46', 'depth_47', 'depth_48', 'depth_49', 'depth_5', 'depth_50', 'depth_51', 'depth_52', 'depth_53', 'depth_54', 'depth_55', 'depth_56', 'depth_57', 'depth_58', 'depth_59', 'depth_6', 'depth_60', 'depth_61', 'depth_62', 'depth_63', 'depth_64', 'depth_65', 'depth_66', 'depth_67', 'depth_68', 'depth_69', 'depth_7', 'depth_70', 'depth_71', 'depth_72', 'depth_73', 'depth_74', 'depth_75', 'depth_76', 'depth_77', 'depth_78', 'depth_79', 'depth_8', 'depth_80', 'depth_81', 'depth_82', 'depth_83', 'depth_84', 'depth_85', 'depth_86', 'depth_87', 'depth_88', 'depth_89', 'depth_9', 'depth_90', 'depth_91', 'depth_92', 'depth_93', 'depth_94', 'depth_95', 'depth_96', 'depth_97', 'depth_98', 'depth_99'] #print ("depth images : %d" % len(dep_names)) if 0: video_fname = "/mnt/interns/changjiang/PatientPositioning/Datasets/surreal/cmu/train/run0/01_01/01_01_c0001.mp4" dataroot = "/mnt/interns/changjiang/PatientPositioning/Datasets/surreal/small-data/images" vidcap = cv2.VideoCapture(video_fname) info_fname = "/mnt/interns/changjiang/PatientPositioning/Datasets/surreal/cmu/train/run0/01_01/01_01_c0001_info.mat" joints2D = load_anno_mat(info_fname)["joints2D"] jnames = joint_names() success, image = vidcap.read() for i in range(0, 4): key_name = 'frame_%03d' % i joints = joints2D[:,:,i] for j in range(0, 14):