Ejemplo n.º 1
0
    def read_gt(self, opt_flow, disp_chng):
        opt_flow = hpl.readPFM(opt_flow)[0]
        disp_chng = hpl.readPFM(disp_chng)[0]

        disp_chng = Image.fromarray(disp_chng)

        _, _, resized_inv_depth = self.get_resized_inverse_depth(
            None, None, disp_chng, self.input_size)

        opt_flow = self.downsample_opt_flow(opt_flow, self.input_size)

        return opt_flow * 0.4, resized_inv_depth
Ejemplo n.º 2
0
    def preprocess(self, img1, img2, disparity1, disparity2):

        factor = 0.4
        self.input_size = int(960 * factor), int(540 * factor)
        # self.driving_disp_chng_max = 7.5552e+08
        # self.driving_disp_max = 30.7278
        self.max_depth_driving = 9.98134
        self.max_depth_driving_chng = 6.75619

        # read resized images to network standards
        self.init_img1, self.init_img2 = self.read_image(img1, img2)

        self.img1_arr = np.array(self.init_img1, dtype=np.float32)[:, :, 0:3]
        self.img2_arr = np.array(self.init_img2, dtype=np.float32)[:, :, 0:3]

        # normalize images
        self.img1 = self.img1_arr / 255
        self.img2 = self.img2_arr / 255

        # read disparity values from matrices
        disp1 = hpl.readPFM(disparity1)[0]
        disp2 = hpl.readPFM(disparity2)[0]

        disp1 = Image.fromarray(disp1)
        disp2 = Image.fromarray(disp2)

        self.inv_depth1, self.inv_depth2, _ = self.get_resized_inverse_depth(
            disp1, disp2, None, self.input_size)

        # normalize disp values
        self.depth1 = self.inv_depth1 / self.max_depth_driving
        self.depth2 = self.inv_depth2 / self.max_depth_driving

        rgbd1 = self.combine_depth_values(self.img1, self.depth1)
        rgbd2 = self.combine_depth_values(self.img2, self.depth2)

        # # combine images to 8 channel rgbd-rgbd
        img_pair = np.concatenate((rgbd1, rgbd2), axis=2)

        # # add padding to axis=0 to make the input image (224,384,8)
        self.img_pair = np.pad(img_pair, ((4, 4), (0, 0), (0, 0)), 'constant')

        # # change dimension from (224,384,8) to (1,224,384,8)
        self.img_pair = np.expand_dims(self.img_pair, 0)
        self.initialize_network()

        self.sess = tf.InteractiveSession()
        self.load_model_ckpt(self.sess, FLAGS.CKPT_FOLDER)
Ejemplo n.º 3
0
	def read_gt(self,opt_flow,disp_chng):
		opt_flow = hpl.readPFM(opt_flow)[0]
		disp_chng = hpl.readPFM(disp_chng)[0]

		disp_chng = Image.fromarray(disp_chng)

		_ ,_ , resized_inv_depth = self.get_resized_inverse_depth(None,None,disp_chng,self.input_size)


		opt_flow = self.downsample_opt_flow(opt_flow,self.input_size)

		opt_flow_u = opt_flow[:,:,0] * self.u_factor_1
		opt_flow_v = opt_flow[:,:,1] * self.v_factor_1

		opt_flow_u = opt_flow[:,:,0] * self.u_factor_2
		opt_flow_v = opt_flow[:,:,1] * self.v_factor_2

		return np.stack((opt_flow_u,opt_flow_v),axis=2), resized_inv_depth
Ejemplo n.º 4
0
def parse_input(img1, img2, disp1, disp2):
    img1 = Image.open(img1)
    img2 = Image.open(img2)

    disp1 = hpl.readPFM(disp1)[0]
    disp2 = hpl.readPFM(disp2)[0]

    disp1 = Image.fromarray(disp1, mode='F')
    disp2 = Image.fromarray(disp2, mode='F')

    img1 = img1.resize(input_size, Image.BILINEAR)
    img2 = img2.resize(input_size, Image.BILINEAR)

    disp1 = disp1.resize(input_size, Image.NEAREST)
    disp2 = disp2.resize(input_size, Image.NEAREST)

    disp1 = np.array(disp1, dtype=np.float32)
    disp2 = np.array(disp2, dtype=np.float32)

    depth1 = get_depth_from_disp(disp1)
    depth2 = get_depth_from_disp(disp2)

    # normalize
    depth1 = depth1 / np.max(depth1)
    depth2 = depth2 / np.max(depth1)

    img1_orig = np.array(img1)
    img2_orig = np.array(img2)

    img1 = img1_orig / 255
    img2 = img1_orig / 255

    rgbd1 = combine_depth_values(img1, depth1)
    rgbd2 = combine_depth_values(img2, depth2)

    img_pair = np.concatenate((rgbd1, rgbd2), axis=2)

    # optical_flow
    return img_pair, img2_orig
Ejemplo n.º 5
0
def read_gt(opt_flow, input_size):
    opt_flow = hpl.readPFM(opt_flow)[0]
    opt_flow = downsample_opt_flow(opt_flow, input_size)
    return opt_flow