(self)
| 39 | self.is_view_face_mask: bool = False |
| 40 | |
| 41 | def run(self): |
| 42 | try: |
| 43 | # Update parameters from markers (if exists) without concurrent access from other threads |
| 44 | with self.main_window.models_processor.model_lock: |
| 45 | video_control_actions.update_parameters_and_control_from_marker(self.main_window, self.frame_number) |
| 46 | self.parameters = self.main_window.parameters.copy() |
| 47 | # Check if view mask or face compare checkboxes are checked |
| 48 | self.is_view_face_compare = self.main_window.faceCompareCheckBox.isChecked() |
| 49 | self.is_view_face_mask = self.main_window.faceMaskCheckBox.isChecked() |
| 50 | |
| 51 | # Process the frame with model inference |
| 52 | # print(f"Processing frame {self.frame_number}") |
| 53 | if self.main_window.swapfacesButton.isChecked() or self.main_window.editFacesButton.isChecked() or self.main_window.control['FrameEnhancerEnableToggle']: |
| 54 | self.frame = self.process_frame() |
| 55 | else: |
| 56 | # Img must be in BGR format |
| 57 | self.frame = self.frame[..., ::-1] # Swap the channels from RGB to BGR |
| 58 | self.frame = np.ascontiguousarray(self.frame) |
| 59 | |
| 60 | # Display the frame if processing is still active |
| 61 | |
| 62 | pixmap = common_widget_actions.get_pixmap_from_frame(self.main_window, self.frame) |
| 63 | |
| 64 | # Output processed Webcam frame |
| 65 | if self.video_processor.file_type=='webcam' and not self.is_single_frame: |
| 66 | self.video_processor.webcam_frame_processed_signal.emit(pixmap, self.frame) |
| 67 | |
| 68 | #Output Video frame (while playing) |
| 69 | elif not self.is_single_frame: |
| 70 | self.video_processor.frame_processed_signal.emit(self.frame_number, pixmap, self.frame) |
| 71 | # Output Image/Video frame (Single frame) |
| 72 | else: |
| 73 | # print('Emitted single_frame_processed_signal') |
| 74 | self.video_processor.single_frame_processed_signal.emit(self.frame_number, pixmap, self.frame) |
| 75 | |
| 76 | |
| 77 | # Mark the frame as done in the queue |
| 78 | self.video_processor.frame_queue.get() |
| 79 | self.video_processor.frame_queue.task_done() |
| 80 | |
| 81 | # Check if playback is complete |
| 82 | if self.video_processor.frame_queue.empty() and not self.video_processor.processing and self.video_processor.next_frame_to_display >= self.video_processor.max_frame_number: |
| 83 | self.video_processor.stop_processing() |
| 84 | |
| 85 | except Exception as e: # pylint: disable=broad-exception-caught |
| 86 | print(f"Error in FrameWorker: {e}") |
| 87 | traceback.print_exc() |
| 88 | |
| 89 | # @misc_helpers.benchmark |
| 90 | def process_frame(self): |
no test coverage detected