Beispiel #1
0
def main():
    # Parse command-line arguments.
    args = parse_args()

    Hfile = os.path.join(args.datadir, "H.txt")
    obsfile = os.path.join(args.datadir, "obsmat.txt")

    # Parse homography matrix.
    H = np.loadtxt(Hfile)
    Hinv = np.linalg.inv(H)
    # Parse pedestrian annotations.
    frames, timeframes, timesteps, agents = ewap.parse_annotations(
        Hinv, obsfile)

    # Agents 319-338
    timeline = range(11205, 11554)

    print 'Running experiment...'
    util.reset_timer()

    num_samples = 100
    variances = np.array([0.1, 0.3, 1, 3, 10, 30, 100])
    entropies = np.zeros_like(variances)
    for i, sigma2 in enumerate(variances):
        M = np.zeros((2, 2))
        total_samples = 0
        for frame in timeline:
            t = frames[frame]
            if t == -1: continue

            T = len(timeline)
            print '{:.1%} complete'.format(
                (T * i + frame - timeline[0]) / (T * len(variances)))

            for _ in range(num_samples):
                # 			predictions = util.make_predictions(t, timesteps, agents)
                predictions = util.fake_predictions(t, timesteps, agents,
                                                    sigma2)
                for a, plan in enumerate(predictions.plan):
                    if plan.shape[0] > 1:
                        error = predictions.true_paths[a][1, 0:2] - plan[1,
                                                                         0:2]
                        M += np.outer(error, error)
                        total_samples += 1

        M /= total_samples
        entropies[i] = 0.5 * np.log((2 * np.pi * np.e)**2 * np.linalg.det(M))


# 		print 'entropy is', entropy
# 		print 'variance:'
# 		print M

    print 'EXPERIMENT COMPLETE.'
    util.report_time()
    results = np.column_stack((variances, entropies))
    print results
    np.savetxt('experiments/entropy_vs_variance.txt', results)
Beispiel #2
0
def main():
	# Parse command-line arguments.
	args = parse_args()
	
	Hfile = os.path.join(args.datadir, "H.txt")
	obsfile = os.path.join(args.datadir, "obsmat.txt")

	# Parse homography matrix.
	H = np.loadtxt(Hfile)
	Hinv = np.linalg.inv(H)
	# Parse pedestrian annotations.
	frames, timeframes, timesteps, agents = ewap.parse_annotations(Hinv, obsfile)
	
	# Agents 319-338
	timeline = range(11205, 11554)
	
	print 'Running experiment...'
	util.reset_timer()
	
	num_samples = 100
	variances = np.array([0.1, 0.3, 1, 3, 10, 30, 100])
	entropies = np.zeros_like(variances)
	for i, sigma2 in enumerate(variances):
		M = np.zeros((2,2))
		total_samples = 0
		for frame in timeline:
			t = frames[frame]
			if t == -1: continue
			
			T = len(timeline)
			print '{:.1%} complete'.format((T*i+frame-timeline[0])/(T*len(variances)))
			
			for _ in range(num_samples):
	# 			predictions = util.make_predictions(t, timesteps, agents)
				predictions = util.fake_predictions(t, timesteps, agents, sigma2)
				for a,plan in enumerate(predictions.plan):
					if plan.shape[0] > 1:
						error = predictions.true_paths[a][1,0:2] - plan[1,0:2]
						M += np.outer(error, error)
						total_samples += 1
		
		M /= total_samples
		entropies[i] = 0.5*np.log((2*np.pi*np.e)**2 * np.linalg.det(M))
# 		print 'entropy is', entropy
# 		print 'variance:'
# 		print M
	
	print 'EXPERIMENT COMPLETE.'
	util.report_time()
	results = np.column_stack((variances, entropies))
	print results
	np.savetxt('experiments/entropy_vs_variance.txt', results)
Beispiel #3
0
def main():
    # Parse command-line arguments.
    args = parse_args()

    Hfile = os.path.join(args.datadir, "H.txt")
    mapfile = os.path.join(args.datadir, "map.png")
    obsfile = os.path.join(args.datadir, "obsmat.txt")
    destfile = os.path.join(args.datadir, "destinations.txt")

    # Parse homography matrix.
    H = np.loadtxt(Hfile)
    Hinv = np.linalg.inv(H)
    # Parse obstacle map.
    obs_map = ewap.create_obstacle_map(mapfile)
    # Parse pedestrian annotations.
    frames, timeframes, timesteps, agents = ewap.parse_annotations(
        Hinv, obsfile)
    # Parse destinations.
    destinations = np.loadtxt(destfile)

    # Play the video
    seqname = os.path.basename(args.datadir)
    cap = cv2.VideoCapture(os.path.join(args.datadir, seqname + ".avi"))
    disp = display.Display(cap, Hinv, obs_map, frames, timesteps, agents,
                           destinations)
    disp.model = models.model21

    # We can set the exact frame we want to look at:
    # 	disp.set_frame(780) # ETH sequence, beginning
    # 	disp.set_frame(2238) # ETH sequence, agent #48 (1 v 1)
    disp.set_frame(11301)  # ETH sequence, big crowds both ways
    # 	disp.set_frame(8289) # ETH sequence, agent #175 (1 v crowd)
    # 	disp.set_frame(9867) # ETH sequence, agent #236 (1 v crowd)
    # 	disp.set_frame(8859) # ETH sequence, agent #194 (1 v 1, choosing non-optimal avoidance)
    # 	disp.set_frame(9261) # Hotel sequence, agent #175

    # We can also go by minutes & seconds:
    # 	seekpos = 7.5 * 60 * 1000 # About 7 mins 30 secs
    # 	endpos = 8.7 * 60 * 1000 # About 8 mins 40 secs
    # 	cap.set(POS_MSEC, seekpos)

    # Alternatively, we can search for a particular agent we're interested in:
    # 	agent_to_search = 194
    # 	ped_path = agents[agent_to_search]
    # 	frame_num = timeframes[int(ped_path[0,0])]
    # 	disp.set_frame(frame_num)
    # 	disp.agent_num = agent_to_search
    # 	disp.do_predictions = False

    pl.ion()
    display.plot_prediction_metrics([], [], [])

    while cap.isOpened():

        disp.do_frame()

        key = cv2.waitKey(0) & 0xFF
        if key == ord('e'):
            run_experiment(cap, disp, timeframes, timesteps, agents)
        elif key == ord('q') or key == ESC:
            break
        elif key == ord('r'):
            disp.redo_prediction()
        elif key == ord(' '):
            disp.toggle_prediction()
        elif key == LEFT:
            disp.back_one_frame()
        elif key == UP:
            if disp.draw_all_agents: disp.next_sample()
            else: disp.next_agent()
        elif key == DOWN:
            if disp.draw_all_agents: disp.prev_sample()
            else: disp.prev_agent()
        elif key == ord('a'):
            disp.draw_all_agents = not disp.draw_all_agents
            disp.draw_all_samples = not disp.draw_all_samples
            disp.reset_frame()
        elif key == ord('t'):
            disp.draw_truth = not disp.draw_truth
            disp.reset_frame()
        elif key == ord('f'):
            disp.draw_plan = not disp.draw_plan
            disp.reset_frame()
        elif key == ord('p'):
            disp.draw_past = not disp.draw_past
            disp.reset_frame()
        elif key == ord('s'):
            disp.draw_samples = (disp.draw_samples +
                                 1) % display.SAMPLE_CHOICES
            disp.reset_frame()

    cap.release()
    cv2.destroyAllWindows()
    pl.close('all')
Beispiel #4
0
def main():
	# Parse command-line arguments.
	args = parse_args()
	
	Hfile = os.path.join(args.datadir, "H.txt")
	obsfile = os.path.join(args.datadir, "obsmat.txt")

	# Parse homography matrix.
	H = np.loadtxt(Hfile)
	Hinv = np.linalg.inv(H)
	# Parse pedestrian annotations.
	frames, timeframes, timesteps, agents = ewap.parse_annotations(Hinv, obsfile)
	
	test_sequences = np.array([
		range(2112, 2395),
		range(3648, 3769),
		range(4163, 4374),
		range(6797, 7164),
		range(7301, 7608),
		range(8373, 8620),
		range(8859, 9544),
		range(9603, 10096),
		range(10101, 10528),
		range(11205, 11500),
		range(11835, 12172),
		range(12201, 12382),
	])
	total_t = 0
	for s in test_sequences: total_t += len(s)
	model = models.model16
	
	print 'Running experiment...'
	util.reset_timer()
	
	num_samples = 5
	iters = 0
	total_samples = 0
	entropies = np.zeros(test_sequences.shape[0])
	for i,timeline in enumerate(test_sequences):
		M = np.zeros((2,2))
		for frame in timeline:
			iters += 1
			t = frames[frame]
			if t == -1: continue
			
			for _ in range(num_samples):
				predictions = util.make_predictions(t, timesteps, agents, model)
				for a,plan in enumerate(predictions.plan):
					if plan.shape[0] > 1:
						error = predictions.true_paths[a][1,0:2] - plan[1,0:2]
						M += np.outer(error, error)
						total_samples += 1
			
			print 'frame {}: {:.1%} complete'.format(frame, iters/total_t)
		
		M /= total_samples
		entropies[i] = 0.5*np.log((2*np.pi*np.e)**2 * np.linalg.det(M))
# 		print 'entropy is', entropy
# 		print 'variance:'
# 		print M
	
	print 'EXPERIMENT COMPLETE.'
	util.report_time()
	np.savetxt('experiments/hyperparam-test-194-202-joint-2.txt', entropies)
Beispiel #5
0
def main():
	# Parse command-line arguments.
	args = parse_args()
	
	Hfile = os.path.join(args.datadir, "H.txt")
	mapfile = os.path.join(args.datadir, "map.png")
	obsfile = os.path.join(args.datadir, "obsmat.txt")
	destfile = os.path.join(args.datadir, "destinations.txt")

	# Parse homography matrix.
	H = np.loadtxt(Hfile)
	Hinv = np.linalg.inv(H)
	# Parse obstacle map.
	obs_map = ewap.create_obstacle_map(mapfile)
	# Parse pedestrian annotations.
	frames, timeframes, timesteps, agents = ewap.parse_annotations(Hinv, obsfile)
	# Parse destinations.
	destinations = np.loadtxt(destfile)
	
	# Play the video
	seqname = os.path.basename(args.datadir)
	cap = cv2.VideoCapture(os.path.join(args.datadir, seqname+".avi"))
	disp = display.Display(cap, Hinv, obs_map, frames, timesteps, agents, destinations)
	disp.model = models.model21
	
	# We can set the exact frame we want to look at:
# 	disp.set_frame(780) # ETH sequence, beginning
# 	disp.set_frame(2238) # ETH sequence, agent #48 (1 v 1)
	disp.set_frame(11301) # ETH sequence, big crowds both ways
# 	disp.set_frame(8289) # ETH sequence, agent #175 (1 v crowd)
# 	disp.set_frame(9867) # ETH sequence, agent #236 (1 v crowd)
# 	disp.set_frame(8859) # ETH sequence, agent #194 (1 v 1, choosing non-optimal avoidance)
# 	disp.set_frame(9261) # Hotel sequence, agent #175

	# We can also go by minutes & seconds:
# 	seekpos = 7.5 * 60 * 1000 # About 7 mins 30 secs
# 	endpos = 8.7 * 60 * 1000 # About 8 mins 40 secs
# 	cap.set(POS_MSEC, seekpos)

	# Alternatively, we can search for a particular agent we're interested in:
# 	agent_to_search = 194
# 	ped_path = agents[agent_to_search]
# 	frame_num = timeframes[int(ped_path[0,0])]
# 	disp.set_frame(frame_num)
# 	disp.agent_num = agent_to_search
# 	disp.do_predictions = False
	
	pl.ion()
	display.plot_prediction_metrics([], [], [])
	
	while cap.isOpened():
		
		disp.do_frame()
		
		key = cv2.waitKey(0) & 0xFF
		if key == ord('e'):
			run_experiment(cap, disp, timeframes, timesteps, agents)
		elif key == ord('q') or key == ESC:
			break
		elif key == ord('r'):
			disp.redo_prediction()
		elif key == ord(' '):
			disp.toggle_prediction()
		elif key == LEFT:
			disp.back_one_frame()
		elif key == UP:
			if disp.draw_all_agents: disp.next_sample()
			else: disp.next_agent()
		elif key == DOWN:
			if disp.draw_all_agents: disp.prev_sample()
			else: disp.prev_agent()
		elif key == ord('a'):
			disp.draw_all_agents = not disp.draw_all_agents
			disp.draw_all_samples = not disp.draw_all_samples
			disp.reset_frame()
		elif key == ord('t'):
			disp.draw_truth = not disp.draw_truth
			disp.reset_frame()
		elif key == ord('f'):
			disp.draw_plan = not disp.draw_plan
			disp.reset_frame()
		elif key == ord('p'):
			disp.draw_past = not disp.draw_past
			disp.reset_frame()
		elif key == ord('s'):
			disp.draw_samples = (disp.draw_samples + 1) % display.SAMPLE_CHOICES
			disp.reset_frame()
	
	cap.release()
	cv2.destroyAllWindows()
	pl.close('all')