Grabbing frames from VideoCapture.
(self)
| 227 | return self |
| 228 | |
| 229 | def put_fn(self): |
| 230 | """ |
| 231 | Grabbing frames from VideoCapture. |
| 232 | """ |
| 233 | was_read = True |
| 234 | while was_read and not self.stopped: |
| 235 | task = TaskInfo() |
| 236 | |
| 237 | task.img_height = self.display_height |
| 238 | task.img_width = self.display_width |
| 239 | task.crop_size = self.test_crop_size |
| 240 | task.clip_vis_size = self.clip_vis_size |
| 241 | frames = [] |
| 242 | if len(self.buffer) != 0: |
| 243 | frames = self.buffer |
| 244 | self.input_lock.acquire() |
| 245 | while was_read and len(frames) < self.seq_length: |
| 246 | was_read, frame = self.cap.read() |
| 247 | if was_read: |
| 248 | frames.append(frame) |
| 249 | self.input_lock.release() |
| 250 | if was_read: |
| 251 | self.buffer = frames[-self.buffer_size :] |
| 252 | |
| 253 | task.add_frames(self.put_id + 1, frames) |
| 254 | task.num_buffer_frames = ( |
| 255 | 0 if self.put_id == -1 else self.buffer_size |
| 256 | ) |
| 257 | with self.put_id_lock: |
| 258 | self.put_id += 1 |
| 259 | self.not_end = was_read |
| 260 | # If mode is to read the most recent clip or we reach task |
| 261 | # index that is not supposed to be skipped. |
| 262 | if self.num_skip == 0 or self.put_id % self.num_skip == 0: |
| 263 | self.read_queue.put((was_read, copy.deepcopy(task))) |
| 264 | else: |
| 265 | with self.write_lock: |
| 266 | self.write_queue[task.id] = (was_read, copy.deepcopy(task)) |
| 267 | |
| 268 | def __next__(self): |
| 269 | # If there is nothing in the task queue. |
nothing calls this directly
no test coverage detected