Given the video index, return the list of sampled frame indexes. Args: index (int): the video index. temporal_sample_index (int): temporal sample index. Returns: seq (list): the indexes of frames of sampled from the video.
(self, index, temporal_sample_index)
| 131 | ) |
| 132 | |
| 133 | def get_seq_frames(self, index, temporal_sample_index): |
| 134 | """ |
| 135 | Given the video index, return the list of sampled frame indexes. |
| 136 | Args: |
| 137 | index (int): the video index. |
| 138 | temporal_sample_index (int): temporal sample index. |
| 139 | Returns: |
| 140 | seq (list): the indexes of frames of sampled from the video. |
| 141 | """ |
| 142 | num_frames = self.cfg.DATA.NUM_FRAMES |
| 143 | video_length = self._path_to_videos[index][1] |
| 144 | |
| 145 | seg_size = float(video_length - 1) / num_frames |
| 146 | seq = [] |
| 147 | # index from 1, must add 1 |
| 148 | if self.mode == "train": |
| 149 | for i in range(num_frames): |
| 150 | start = int(np.round(seg_size * i)) |
| 151 | end = int(np.round(seg_size * (i + 1))) |
| 152 | seq.append(random.randint(start, end) + 1) |
| 153 | else: |
| 154 | duration = seg_size / (self.cfg.TEST.NUM_ENSEMBLE_VIEWS + 1) |
| 155 | for i in range(num_frames): |
| 156 | start = int(np.round(seg_size * i)) |
| 157 | end = int(np.round(seg_size * (i + 1))) |
| 158 | frame_index = start + int(duration * (temporal_sample_index + 1)) |
| 159 | seq.append(frame_index + 1) |
| 160 | return seq |
| 161 | |
| 162 | def __getitem__(self, index): |
| 163 | """ |