| 287 | return was_read, task |
| 288 | |
| 289 | def get_fn(self): |
| 290 | while not self.stopped: |
| 291 | with self.put_id_lock: |
| 292 | put_id = self.put_id |
| 293 | not_end = self.not_end |
| 294 | |
| 295 | with self.write_lock: |
| 296 | # If video ended and we have display all frames. |
| 297 | if not not_end and self.get_id == put_id: |
| 298 | break |
| 299 | # If the next frames are not available, wait. |
| 300 | if ( |
| 301 | len(self.write_queue) == 0 |
| 302 | or self.write_queue.get(self.get_id + 1) is None |
| 303 | ): |
| 304 | time.sleep(0.02) |
| 305 | continue |
| 306 | else: |
| 307 | self.get_id += 1 |
| 308 | was_read, task = self.write_queue[self.get_id] |
| 309 | del self.write_queue[self.get_id] |
| 310 | |
| 311 | with self.output_lock: |
| 312 | for frame in task.frames[task.num_buffer_frames :]: |
| 313 | if self.output_file is None: |
| 314 | cv2.imshow("SlowFast", frame) |
| 315 | time.sleep(1 / self.output_fps) |
| 316 | else: |
| 317 | self.output_file.write(frame) |
| 318 | |
| 319 | def display(self, task): |
| 320 | """ |