Example #1
0
 def _test_blendswapdata(self, data):
     normal_tensor = ops.warp2d(normalized=True,
                                border_mode='value',
                                border_value=-1,
                                input=data['image_pair'][:, 3:, :, :],
                                displacements=data['flow'])
     warped = normal_tensor.eval()
     if (warped.dtype == np.float32):
         import ijremote
         ijremote.setImage("image_pair", data['image_pair'][:, 0:3, :, :])
         ijremote.setImage("warped_image", warped)
Example #2
0
def testing_ds_api(dataset):

    dataset = dataset.make_initializable_iterator()
    sess = tf.InteractiveSession()
    sess.run(dataset.initializer)

    next_batch = dataset.get_next()

    final_img_batch, final_lbl_batch = combine_batches_from_datasets(next_batch)

    next_batch_forward = final_img_batch[:,0,:,:,:]
    next_batch_backward = final_img_batch[:,1,:,:,:]

    forward, backward = sess.run([next_batch_forward,next_batch_backward])
    ij.setHost('tcp://linus:13463')
    ij.setImage('myimage_f',np.transpose(forward,[0,3,1,2]))
    ij.setImage('myimage_b',np.transpose(backward,[0,3,1,2]))
Example #3
0
 def _test_blendswapdata(self, data):
     depth_tensor = ops.flow_to_depth(inverse_depth=True,
                                      normalized_flow=True,
                                      flow=data['flow'],
                                      intrinsics=data['intrinsics'],
                                      rotation=data['motion'][:, 0:3],
                                      translation=data['motion'][:, 3:])
     depth = depth_tensor.eval()
     import ijremote
     ijremote.setImage("image_pair", data['image_pair'])
     ijremote.setImage("depth", depth)
     ijremote.setImage("depth_gt", data['depth'])
     self.assertAllClose(depth, data['depth'])
Example #4
0
    def _test_blendswapdata(self, data):
        flow_tensor = ops.depth_to_flow(inverse_depth=True,
                                        normalize_flow=True,
                                        depth=data['depth'],
                                        intrinsics=data['intrinsics'],
                                        rotation=data['motion'][:, 0:3],
                                        translation=data['motion'][:, 3:])
        flow = flow_tensor.eval()
        if data['depth'].dtype == np.float32:
            import ijremote
            #ijremote.setHost('tcp://clancy:13463')
            ijremote.setImage("image_pair", data['image_pair'])
            ijremote.setImage("flow", flow)
            ijremote.setImage("flow_gt", data['flow'])

        self.assertAllClose(flow, data['flow'])
Example #5
0
    def _test_blendswapdata(self, data):
        normal_tensor = ops.depth_to_normals(inverse_depth=True,
                                             depth=data['depth'],
                                             intrinsics=data['intrinsics'])
        normal = normal_tensor.eval()
        if (normal.dtype == np.float32):
            import ijremote
            ijremote.setImage("image_pair", data['image_pair'])
            ijremote.setImage("normal", normal)
            ijremote.setImage("normal_gt", data['normal'])

            import vis
            img1, _ = vis.numpy_imagepair_to_PIL_images(data['image_pair'][1])
            visualize_points_with_normals('points', data['depth'][1],
                                          data['intrinsics'][1], img1,
                                          normal[1])
            visualize_points_with_normals('points_gt', data['depth'][1],
                                          data['intrinsics'][1], img1,
                                          data['normal'][1])
        normal_no_nan = normal.copy()
        normal_no_nan[np.isnan(normal)] = 0
        normal_gt_no_nan = data['normal'].copy()
        normal_gt_no_nan[np.isnan(data['normal'])] = 0
Example #6
0
	gt_flow = predictor.optical_floww
else:
	predictor.preprocess()
	gt_flow, gt_depth_change = predictor.read_gt(FLAGS.FLOW,FLAGS.DISPARITY_CHNG)


pr_flow, loss = predictor.predict()
print(pr_flow.shape)

if not loss is None:
	print(loss)

if FLAGS.PARSING_PTB == False:
	# show gt flows
	if FLAGS.SHOW_GT_FLOWS == True:
		ij.setImage('gt_flow_uv',np.transpose(gt_flow,[2,0,1]))

	# warp with gt predited flow values
	if FLAGS.SHOW_GT_WARPED_RESULT == True:
		# gt_flow = np.pad(gt_flow,((4,4),(0,0),(0,0)),'constant')

		flow = predictor.warp(predictor.img2_arr,gt_flow)
		result = flow.eval()[0].astype(np.uint8)
		predictor.show_image(result,'warped_img_gt')

	# show inv depth values for both images
	if FLAGS.SHOW_GT_DEPTHS == True:
		ij.setImage('gt_inv_depth1',predictor.inv_depth1)
		ij.setImage('gt_inv_depth2',predictor.inv_depth2)

Example #7
0
predictor = FlowPredictor()
predictor.preprocess(FLAGS.IMG1, FLAGS.IMG2, FLAGS.DISPARITY1,
                     FLAGS.DISPARITY2)

gt_flow, gt_depth_change = predictor.read_gt(FLAGS.FLOW, FLAGS.DISPARITY_CHNG)
pr_flow, pr_depth_change = predictor.predict()

# show gt images
if FLAGS.SHOW_GT_IMGS == True:
    predictor.init_img1.show()
    predictor.init_img2.show()

# show gt flows
if FLAGS.SHOW_GT_FLOWS == True:
    ij.setImage('gt_flow_u', gt_flow[:, :, 0])
    ij.setImage('gt_flow_v', gt_flow[:, :, 1])

# warp with gt predited flow values
if FLAGS.SHOW_GT_WARPED_RESULT == True:
    gt_flow = np.pad(gt_flow, ((4, 4), (0, 0), (0, 0)), 'constant')
    flow = predictor.warp(predictor.img2_arr, gt_flow)
    result = flow.eval()[0].astype(np.uint8)
    predictor.show_image(result, 'warped_img_gt')

# show inv depth values for both images
if FLAGS.SHOW_GT_DEPTHS == True:
    ij.setImage('gt_inv_depth1', predictor.inv_depth1)
    ij.setImage('gt_inv_depth2', predictor.inv_depth2)

# show predicted depth change