def get_orientation(): ''' Send a POST request to this URL. Input: a JSON object as follows: { camera: [x, y, z] screenSpaceA: [x, y] screenSpaceB: [x, y] personA: [x, y, z] personB: [x, y, z] fov: [x, y] numTargets: 1 or 2 } Returns: a JSON object as follows: { 'w': w 'x': x 'y': y 'z': z } ''' parsed_json = request.get_json() if parsed_json is None: return abort(400) camera_list = parsed_json['camera'] screenA_list = parsed_json['screenSpaceA'] screenB_list = parsed_json['screenSpaceB'] personA_list = parsed_json['personA'] personB_list = parsed_json['personB'] fov_list = parsed_json['fov'] numTargets_list = parsed_json['numTargets'] print "get_toric_trajectory: Calling trajectoryAPI now..." # toric interpolation numTargets = numTargets_list[0] C = toric.Vector3(camera_list[0],camera_list[1],camera_list[2]) SA = toric.Vector2(screenA_list[0],screenA_list[1]) PA = toric.Vector3(personA_list[0],personA_list[1],personA_list[2]) SB = toric.Vector2(screenB_list[0],screenB_list[1]) PB = toric.Vector3(personB_list[0],personB_list[1],personB_list[2]) fovX = toric.RadianPi(fov_list[0]) fovY = toric.RadianPi(fov_list[1]) q = toricinterpolation.toric_orientation(C, SA, SB, PA, PB, fovX, fovY, numTargets) print "get_orientation: Response from trajectoryAPI [w: ", q['w'], ", x: ", q['x'], ", y: ", q['y'], ", z: ", q['z'] data = { 'w': q['w'], 'x': q['x'], 'y': q['y'], 'z': q['z'] } return jsonify(data)
def get_orientation(): ''' Send a POST request to this URL. Input: a JSON object as follows: { camera: [x, y, z] screenSpaceA: [x, y] screenSpaceB: [x, y] personA: [x, y, z] personB: [x, y, z] fov: [x, y] numTargets: 1 or 2 } Returns: a JSON object as follows: { 'w': w 'x': x 'y': y 'z': z } ''' parsed_json = request.get_json() if parsed_json is None: return abort(400) camera_list = parsed_json['camera'] screenA_list = parsed_json['screenSpaceA'] screenB_list = parsed_json['screenSpaceB'] personA_list = parsed_json['personA'] personB_list = parsed_json['personB'] fov_list = parsed_json['fov'] numTargets_list = parsed_json['numTargets'] print "get_toric_trajectory: Calling trajectoryAPI now..." # toric interpolation numTargets = numTargets_list[0] C = toric.Vector3(camera_list[0], camera_list[1], camera_list[2]) SA = toric.Vector2(screenA_list[0], screenA_list[1]) PA = toric.Vector3(personA_list[0], personA_list[1], personA_list[2]) SB = toric.Vector2(screenB_list[0], screenB_list[1]) PB = toric.Vector3(personB_list[0], personB_list[1], personB_list[2]) fovX = toric.RadianPi(fov_list[0]) fovY = toric.RadianPi(fov_list[1]) q = toricinterpolation.toric_orientation(C, SA, SB, PA, PB, fovX, fovY, numTargets) print "get_orientation: Response from trajectoryAPI [w: ", q[ 'w'], ", x: ", q['x'], ", y: ", q['y'], ", z: ", q['z'] data = {'w': q['w'], 'x': q['x'], 'y': q['y'], 'z': q['z']} return jsonify(data)
def get_orientation(): ''' Send a POST request to this URL. Input: a JSON object as follows: { cameraPoseN: [0, ...], cameraPoseE: [0, ...], cameraPoseD: [0, ...], screenSpaceX: [0, ...], screenSpaceY: [0, ...], personN: [0, ...], personE: [0, ...], personD: [0, ...], fovX: [0, ...], fovY: [0, ...], } Returns: a JSON object as follows: { 'w': w 'x': x 'y': y 'z': z } ''' parsed_json = request.get_json() if parsed_json is None: return abort(400) # camera_list = parsed_json['camera'] # screenA_list = parsed_json['screenSpaceA'] # screenB_list = parsed_json['screenSpaceB'] # personA_list = parsed_json['personA'] # personB_list = parsed_json['personB'] # fov_list = parsed_json['fov'] cameraPose_n_list = parsed_json['cameraPoseN'] #y cameraPose_e_list = parsed_json['cameraPoseE'] #x cameraPose_d_list = parsed_json['cameraPoseD'] #z screen_x_list = parsed_json['screenSpaceX'] screen_y_list = parsed_json['screenSpaceY'] person_n_list = parsed_json['personN'] person_e_list = parsed_json['personE'] person_d_list = parsed_json['personD'] fov_x_list = parsed_json['fovX'] fov_y_list = parsed_json['fovY'] print "get_toric_trajectory: Calling trajectoryAPI now..." # toric interpolation C = toric.Vector3(cameraPose_n_list[0],cameraPose_e_list[0],cameraPose_d_list[0]) SA = toric.Vector2(screen_x_list[0],screen_y_list[0]) PA = toric.Vector3(person_n_list[0],person_e_list[0],person_d_list[0]) numTargets = len(screen_x_list) SB = toric.Vector2(0,0) PB = toric.Vector3(0,0,0) if (numTargets > 1): SB = toric.Vector2(screen_x_list[1],screen_y_list[1]) PB = toric.Vector3(person_n_list[1],person_e_list[1],person_d_list[1]) fovX = toric.RadianPi(fov_x_list[0]) fovY = toric.RadianPi(fov_y_list[0]) print "numTargets", numTargets q = toricinterpolation.toric_orientation(C, SA, SB, PA, PB, fovX, fovY, numTargets) print "get_orientation: Response from trajectoryAPI [w: ", q['w'], ", x: ", q['x'], ", y: ", q['y'], ", z: ", q['z'] data = { 'w': q['w'], 'x': q['x'], 'y': q['y'], 'z': q['z'] } return jsonify(data)