Sample frames among the corresponding clip. Args: center_idx (int): center frame idx for current clip half_len (int): half of the clip length sample_rate (int): sampling rate for sampling frames inside of the clip num_frames (int): number of expected sampled
(center_idx, half_len, sample_rate, num_frames)
| 48 | |
| 49 | |
| 50 | def get_sequence(center_idx, half_len, sample_rate, num_frames): |
| 51 | """ |
| 52 | Sample frames among the corresponding clip. |
| 53 | |
| 54 | Args: |
| 55 | center_idx (int): center frame idx for current clip |
| 56 | half_len (int): half of the clip length |
| 57 | sample_rate (int): sampling rate for sampling frames inside of the clip |
| 58 | num_frames (int): number of expected sampled frames |
| 59 | |
| 60 | Returns: |
| 61 | seq (list): list of indexes of sampled frames in this clip. |
| 62 | """ |
| 63 | seq = list(range(center_idx - half_len, center_idx + half_len, sample_rate)) |
| 64 | |
| 65 | for seq_idx in range(len(seq)): |
| 66 | if seq[seq_idx] < 0: |
| 67 | seq[seq_idx] = 0 |
| 68 | elif seq[seq_idx] >= num_frames: |
| 69 | seq[seq_idx] = num_frames - 1 |
| 70 | return seq |
| 71 | |
| 72 | |
| 73 | def pack_pathway_output(cfg, frames): |