Read the next frame and add it to the queue for processing.
(self)
| 224 | |
| 225 | |
| 226 | def process_next_frame(self): |
| 227 | """Read the next frame and add it to the queue for processing.""" |
| 228 | |
| 229 | if self.current_frame_number > self.max_frame_number: |
| 230 | # print("Stopping frame_read_timer as all frames have been read!") |
| 231 | self.frame_read_timer.stop() |
| 232 | return |
| 233 | |
| 234 | if self.frame_queue.qsize() >= self.num_threads: |
| 235 | # print(f"Queue is full ({self.frame_queue.qsize()} frames). Throttling frame reading.") |
| 236 | return |
| 237 | |
| 238 | if self.file_type == 'video' and self.media_capture: |
| 239 | ret, frame = misc_helpers.read_frame(self.media_capture, preview_mode = not self.recording) |
| 240 | if ret: |
| 241 | frame = frame[..., ::-1] # Convert BGR to RGB |
| 242 | # print(f"Enqueuing frame {self.current_frame_number}") |
| 243 | self.frame_queue.put(self.current_frame_number) |
| 244 | self.start_frame_worker(self.current_frame_number, frame) |
| 245 | self.current_frame_number += 1 |
| 246 | else: |
| 247 | print("Cannot read frame!", self.current_frame_number) |
| 248 | self.stop_processing() |
| 249 | self.main_window.display_messagebox_signal.emit('Error Reading Frame', f'Error Reading Frame {self.current_frame_number}.\n Stopped Processing...!', self.main_window) |
| 250 | |
| 251 | def start_frame_worker(self, frame_number, frame, is_single_frame=False): |
| 252 | """Start a FrameWorker to process the given frame.""" |
nothing calls this directly
no test coverage detected