import sys, atexit, argparse, json, time
sys.path.append('..')
import ue4cv

trajectory = []

def message_handler(message):
    if message == 'clicked':
        rot = [float(v) for v in ue4cv.client.request('vget /camera/0/rotation').split(' ')]
        loc = [float(v) for v in ue4cv.client.request('vget /camera/0/location').split(' ')]
        trajectory.append(dict(rotation = rot, location = loc))

def save_to_file(filename):
    if len(trajectory) != 0:
        with open(filename, 'w') as f:
            json.dump(trajectory, f, indent = 4)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--filename', default='camera-trajectory.json')
    args = parser.parse_args()

    atexit.register(save_to_file, args.filename)
    ue4cv.client.connect()
    ue4cv.client.message_handler = message_handler
    if not ue4cv.client.isconnected():
        print 'Can not connect to the game, please run the game downloaded from http://unrealcv.github.io first'
    else:
        time.sleep(60 * 60 * 24)

Add a script to record camera trajectory.
Add a script to record camera trajectory.
