def preprocess_sequence(self, seq, isValid, isDiff):
    '\n        dataset id (0)\n        object id (1)\n        target pose (2~3)\n        neighbor pose (4~63)\n        '
    seq_len = seq.shape[0]
    seq_tpose = np.copy(seq[:, 2:4])
    seq_npose = np.copy(seq[:, 4:64]).reshape(seq_len, 30, 2)
    dataset_index = int(seq[(0, 0)])
    map = self.map[dataset_index]
    (x_max, y_max, scale) = self.map_info[dataset_index]
    seq_map = []
    for i in range(seq_tpose.shape[0]):
        x = seq_tpose[(i, 0)]
        y = seq_tpose[(i, 1)]
        corr_map = map_roi_extract(map, x, y, x_max, y_max, scale, int((self.map_size / 2)))
        seq_map.append(corr_map)
        " \n            map_ = np.copy(np.copy(map_roi[i]))\n            map_row_cnt = map_.shape[0] / 2\n            map_col_cnt = map_.shape[1] / 2\n\n            pose_start_x = seq_tpose[i, 0]\n            pose_start_y = seq_tpose[i, 1]\n\n            for kappa in range(0, seq_tpose.shape[0]-i):\n\n                pose_x = int(3 * (seq_tpose[i+kappa, 0] - pose_start_x) + map_row_cnt)\n                pose_y = int(3 * (seq_tpose[i+kappa, 1] - pose_start_y) + map_col_cnt)\n\n                pose_x = _min(_max(pose_x, 0), map_.shape[0] - 1)\n                pose_y = _min(_max(pose_y, 0), map_.shape[1] - 1)\n\n                map_[pose_x, pose_y, 0] = 0\n                map_[pose_x, pose_y, 1] = int(255.0 * float(i+kappa) / float(seq_tpose.shape[0]-1))\n                map_[pose_x, pose_y, 2] = 255\n\n            cv2.imshow('test', map_)\n            cv2.waitKey(0)\n            "
    if isValid:
        donothing = 0
    elif (self.data_augmentation == 1):
        (seq_tpose, seq_npose, seq_map) = random_flip(seq_tpose, seq_npose, seq_map)
    elif (self.data_augmentation == 2):
        (seq_tpose, seq_npose) = random_rotate(seq_tpose, seq_npose)
    " \n        for i in range(seq_tpose.shape[0]):\n            map_ = np.copy(np.copy(map_roi[i]))\n            map_row_cnt = map_.shape[0] / 2\n            map_col_cnt = map_.shape[1] / 2\n\n            pose_start_x = seq_tpose[i, 0]\n            pose_start_y = seq_tpose[i, 1]\n\n            for kappa in range(0, seq_tpose.shape[0]-i):\n\n                pose_x = int(3 * (seq_tpose[i+kappa, 0] - pose_start_x) + map_row_cnt)\n                pose_y = int(3 * (seq_tpose[i+kappa, 1] - pose_start_y) + map_col_cnt)\n\n                pose_x = _min(_max(pose_x, 0), map_.shape[0] - 1)\n                pose_y = _min(_max(pose_y, 0), map_.shape[1] - 1)\n\n                map_[pose_x, pose_y, 0] = 0\n                map_[pose_x, pose_y, 1] = int(255.0 * float(i+kappa) / float(seq_tpose.shape[0]-1))\n                map_[pose_x, pose_y, 2] = 255\n\n            cv2.imshow('test', map_)\n            cv2.waitKey(0)\n        "
    "' \n        ego = np.copy(seq_tpose)\n        plt.plot(ego[:, 0], ego[:, 1], 'o')\n        for i in range(30):\n            ngh = np.squeeze(seq_npose[:, i, :]) # seq_len x 2\n            ngh_ = ngh[ngh[:, 0]>-1000, :]\n            if (len(ngh_) > 1):\n                plt.plot(ngh_[:, 0], ngh[:, 1], '+')\n        plt.show()\n        "
    num_grid = int((self.social_range / self.social_grid_size))
    seq_sgrid = np.zeros(shape=(seq_len, (num_grid * num_grid)))
    for i in range(seq_len):
        social_grid = np.zeros(shape=(num_grid, num_grid))
        target_pose = seq_tpose[i, :].reshape(1, 2)
        neighbors_pose = seq_npose[i, :]
        for j in range(30):
            if ((neighbors_pose[(j, 0)] == (- 1000)) or (neighbors_pose[(j, 0)] == 1000)):
                continue
            else:
                neighbor_pose = neighbors_pose[j, :].reshape(1, 2)
                social_grid = getSocialMatrix(social_grid, target_pose, neighbor_pose, self.social_range, self.social_grid_size)
        seq_sgrid[i, :] = social_grid.reshape(1, (num_grid * num_grid))
    seq_tpose_cur = np.copy(seq_tpose[1:, :])
    seq_tpose_pre = np.copy(seq_tpose[:(- 1), :])
    seq_tpose_diff = (seq_tpose_cur - seq_tpose_pre)
    if isDiff:
        return ((seq_tpose_diff / self.scale_factor), np.copy(seq_sgrid[1:, :]), np.array(seq_map[1:]))
    else:
        return (seq_tpose_cur, np.copy(seq_sgrid[1:, :]), np.array(seq_map[1:]))
dataset id (0)
object id (1)
target pose (2~3)
neighbor pose (4~63)
def preprocess_sequence(self, seq, isValid, isDiff):
    '\n        dataset id (0)\n        object id (1)\n        target pose (2~3)\n        neighbor pose (4~63)\n        '
    seq_len = seq.shape[0]
    seq_tpose = np.copy(seq[:, 2:4])
    seq_npose = np.copy(seq[:, 4:64]).reshape(seq_len, 30, 2)
    dataset_index = int(seq[(0, 0)])
    map = self.map[dataset_index]
    (x_max, y_max, scale) = self.map_info[dataset_index]
    seq_map = []
    for i in range(seq_tpose.shape[0]):
        x = seq_tpose[(i, 0)]
        y = seq_tpose[(i, 1)]
        corr_map = map_roi_extract(map, x, y, x_max, y_max, scale, int((self.map_size / 2)))
        seq_map.append(corr_map)
        " \n            map_ = np.copy(np.copy(map_roi[i]))\n            map_row_cnt = map_.shape[0] / 2\n            map_col_cnt = map_.shape[1] / 2\n\n            pose_start_x = seq_tpose[i, 0]\n            pose_start_y = seq_tpose[i, 1]\n\n            for kappa in range(0, seq_tpose.shape[0]-i):\n\n                pose_x = int(3 * (seq_tpose[i+kappa, 0] - pose_start_x) + map_row_cnt)\n                pose_y = int(3 * (seq_tpose[i+kappa, 1] - pose_start_y) + map_col_cnt)\n\n                pose_x = _min(_max(pose_x, 0), map_.shape[0] - 1)\n                pose_y = _min(_max(pose_y, 0), map_.shape[1] - 1)\n\n                map_[pose_x, pose_y, 0] = 0\n                map_[pose_x, pose_y, 1] = int(255.0 * float(i+kappa) / float(seq_tpose.shape[0]-1))\n                map_[pose_x, pose_y, 2] = 255\n\n            cv2.imshow('test', map_)\n            cv2.waitKey(0)\n            "
    if isValid:
        donothing = 0
    elif (self.data_augmentation == 1):
        (seq_tpose, seq_npose, seq_map) = random_flip(seq_tpose, seq_npose, seq_map)
    elif (self.data_augmentation == 2):
        (seq_tpose, seq_npose) = random_rotate(seq_tpose, seq_npose)
    " \n        for i in range(seq_tpose.shape[0]):\n            map_ = np.copy(np.copy(map_roi[i]))\n            map_row_cnt = map_.shape[0] / 2\n            map_col_cnt = map_.shape[1] / 2\n\n            pose_start_x = seq_tpose[i, 0]\n            pose_start_y = seq_tpose[i, 1]\n\n            for kappa in range(0, seq_tpose.shape[0]-i):\n\n                pose_x = int(3 * (seq_tpose[i+kappa, 0] - pose_start_x) + map_row_cnt)\n                pose_y = int(3 * (seq_tpose[i+kappa, 1] - pose_start_y) + map_col_cnt)\n\n                pose_x = _min(_max(pose_x, 0), map_.shape[0] - 1)\n                pose_y = _min(_max(pose_y, 0), map_.shape[1] - 1)\n\n                map_[pose_x, pose_y, 0] = 0\n                map_[pose_x, pose_y, 1] = int(255.0 * float(i+kappa) / float(seq_tpose.shape[0]-1))\n                map_[pose_x, pose_y, 2] = 255\n\n            cv2.imshow('test', map_)\n            cv2.waitKey(0)\n        "
    "' \n        ego = np.copy(seq_tpose)\n        plt.plot(ego[:, 0], ego[:, 1], 'o')\n        for i in range(30):\n            ngh = np.squeeze(seq_npose[:, i, :]) # seq_len x 2\n            ngh_ = ngh[ngh[:, 0]>-1000, :]\n            if (len(ngh_) > 1):\n                plt.plot(ngh_[:, 0], ngh[:, 1], '+')\n        plt.show()\n        "
    num_grid = int((self.social_range / self.social_grid_size))
    seq_sgrid = np.zeros(shape=(seq_len, (num_grid * num_grid)))
    for i in range(seq_len):
        social_grid = np.zeros(shape=(num_grid, num_grid))
        target_pose = seq_tpose[i, :].reshape(1, 2)
        neighbors_pose = seq_npose[i, :]
        for j in range(30):
            if ((neighbors_pose[(j, 0)] == (- 1000)) or (neighbors_pose[(j, 0)] == 1000)):
                continue
            else:
                neighbor_pose = neighbors_pose[j, :].reshape(1, 2)
                social_grid = getSocialMatrix(social_grid, target_pose, neighbor_pose, self.social_range, self.social_grid_size)
        seq_sgrid[i, :] = social_grid.reshape(1, (num_grid * num_grid))
    seq_tpose_cur = np.copy(seq_tpose[1:, :])
    seq_tpose_pre = np.copy(seq_tpose[:(- 1), :])
    seq_tpose_diff = (seq_tpose_cur - seq_tpose_pre)
    if isDiff:
        return ((seq_tpose_diff / self.scale_factor), np.copy(seq_sgrid[1:, :]), np.array(seq_map[1:]))
    else:
        return (seq_tpose_cur, np.copy(seq_sgrid[1:, :]), np.array(seq_map[1:]))