def process(runner):
    spatial_vectors = dict()
    for side in ['left', 'right']:
        frame = runner.output_queues[(side + '_cam')].get().getCvFrame()
        nn_current_output = runner.output_queues[('nn_' + side)].get()
        heatmaps = np.array(nn_current_output.getLayerFp16('Mconv7_stage2_L2')).reshape((1, 19, 32, 57)).astype('float32')
        pafs = np.array(nn_current_output.getLayerFp16('Mconv7_stage2_L1')).reshape((1, 38, 32, 57)).astype('float32')
        outputs = np.concatenate((heatmaps, pafs), axis=1)
        spatial_vectors[side] = []
        landmarks = []
        for i in range(nb_points):
            probMap = outputs[0, i, :, :]
            probMap = cv2.resize(probMap, (frame_width, frame_height))
            keypoints = getKeypoints(probMap, threshold)
            if ((len(keypoints) > 0) and (len(keypoints[0]) > 1)):
                spatial_vectors[side].append(np.array(get_landmark_3d(((keypoints[0][0] / frame_width), (keypoints[0][1] / frame_height)), focal_length=runner.custom_arguments[('focal_length_' + side)], size=runner.custom_arguments[('size_' + side)])))
                landmarks.append([keypoints[0][0], keypoints[0][1]])
                cv2.circle(frame, (keypoints[0][0], keypoints[0][1]), 5, (colors[i][2], colors[i][1], colors[i][0]), (- 1), cv2.LINE_AA)
            else:
                spatial_vectors[side].append(keypoints)
                landmarks.append(keypoints)
        for pair in pairs:
            if np.alltrue([(len(landmarks[i]) == 2) for i in pair]):
                color = [0, 0, 0]
                for i in range(3):
                    color[i] += (colors[pair[0]][i] / 2)
                    color[i] += (colors[pair[1]][i] / 2)
                cv2.line(frame, (landmarks[pair[0]][0], landmarks[pair[0]][1]), (landmarks[pair[1]][0], landmarks[pair[1]][1]), (color[2], color[1], color[0]), 3, cv2.LINE_AA)
        displayFPS(frame, runner.getFPS())
        cv2.imshow(side, frame)
    landmark_spatial_locations = []
    for i in range(nb_points):
        landmark_spatial_locations.append(np.array(get_vector_intersection(spatial_vectors['left'][i], runner.left_camera_location, spatial_vectors['right'][i], runner.right_camera_location)))
    runner.custom_arguments['visualizer'].setLandmarks(landmark_spatial_locations)
def process(runner):
    spatial_vectors = dict()
    for side in ['left', 'right']:
        frame = runner.output_queues[(side + '_cam')].get().getCvFrame()
        nn_current_output = runner.output_queues[('nn_' + side)].get()
        heatmaps = np.array(nn_current_output.getLayerFp16('Mconv7_stage2_L2')).reshape((1, 19, 32, 57)).astype('float32')
        pafs = np.array(nn_current_output.getLayerFp16('Mconv7_stage2_L1')).reshape((1, 38, 32, 57)).astype('float32')
        outputs = np.concatenate((heatmaps, pafs), axis=1)
        spatial_vectors[side] = []
        landmarks = []
        for i in range(nb_points):
            probMap = outputs[0, i, :, :]
            probMap = cv2.resize(probMap, (frame_width, frame_height))
            keypoints = getKeypoints(probMap, threshold)
            if ((len(keypoints) > 0) and (len(keypoints[0]) > 1)):
                spatial_vectors[side].append(np.array(get_landmark_3d(((keypoints[0][0] / frame_width), (keypoints[0][1] / frame_height)), focal_length=runner.custom_arguments[('focal_length_' + side)], size=runner.custom_arguments[('size_' + side)])))
                landmarks.append([keypoints[0][0], keypoints[0][1]])
                cv2.circle(frame, (keypoints[0][0], keypoints[0][1]), 5, (colors[i][2], colors[i][1], colors[i][0]), (- 1), cv2.LINE_AA)
            else:
                spatial_vectors[side].append(keypoints)
                landmarks.append(keypoints)
        for pair in pairs:
            if np.alltrue([(len(landmarks[i]) == 2) for i in pair]):
                color = [0, 0, 0]
                for i in range(3):
                    color[i] += (colors[pair[0]][i] / 2)
                    color[i] += (colors[pair[1]][i] / 2)
                cv2.line(frame, (landmarks[pair[0]][0], landmarks[pair[0]][1]), (landmarks[pair[1]][0], landmarks[pair[1]][1]), (color[2], color[1], color[0]), 3, cv2.LINE_AA)
        displayFPS(frame, runner.getFPS())
        cv2.imshow(side, frame)
    landmark_spatial_locations = []
    for i in range(nb_points):
        landmark_spatial_locations.append(np.array(get_vector_intersection(spatial_vectors['left'][i], runner.left_camera_location, spatial_vectors['right'][i], runner.right_camera_location)))
    runner.custom_arguments['visualizer'].setLandmarks(landmark_spatial_locations)