| 80 | |
| 81 | |
| 82 | class ExtractFrames(DefaultTab): |
| 83 | def __init__(self, root, parent, h1_description): |
| 84 | super().__init__(root, parent, h1_description) |
| 85 | self.worker = None |
| 86 | self.thread = None |
| 87 | self._set_page() |
| 88 | |
| 89 | def _set_page(self): |
| 90 | self.main_layout.addWidget(_create_label_widget("Attributes", "font:bold")) |
| 91 | self.layout_attributes = _create_grid_layout(margins=(0, 0, 0, 0)) |
| 92 | self._generate_layout_attributes(self.layout_attributes) |
| 93 | self.main_layout.addLayout(self.layout_attributes) |
| 94 | |
| 95 | self.main_layout.addWidget( |
| 96 | _create_label_widget( |
| 97 | "Frame extraction from a video subset (optional for automatic extraction)", |
| 98 | "font:bold", |
| 99 | ) |
| 100 | ) |
| 101 | self.video_selection_widget = VideoSelectionWidget(self.root, self) |
| 102 | self.main_layout.addWidget(self.video_selection_widget) |
| 103 | |
| 104 | self.ok_button = QtWidgets.QPushButton("Extract Frames") |
| 105 | self.ok_button.clicked.connect(self.extract_frames) |
| 106 | self.main_layout.addWidget(self.ok_button, alignment=Qt.AlignRight) |
| 107 | |
| 108 | self.help_button = QtWidgets.QPushButton("Help") |
| 109 | self.help_button.clicked.connect(self.show_help_dialog) |
| 110 | self.main_layout.addWidget(self.help_button, alignment=Qt.AlignLeft) |
| 111 | |
| 112 | def show_help_dialog(self): |
| 113 | dialog = QtWidgets.QDialog(self) |
| 114 | layout = QtWidgets.QVBoxLayout() |
| 115 | label = QtWidgets.QLabel(extract_frames.__doc__, self) |
| 116 | scroll = QtWidgets.QScrollArea() |
| 117 | scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) |
| 118 | scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) |
| 119 | scroll.setWidgetResizable(True) |
| 120 | scroll.setWidget(label) |
| 121 | layout.addWidget(scroll) |
| 122 | dialog.setLayout(layout) |
| 123 | dialog.exec_() |
| 124 | |
| 125 | def _generate_layout_attributes(self, layout): |
| 126 | layout.setColumnMinimumWidth(1, 300) |
| 127 | # Extraction method |
| 128 | ext_method_label = QtWidgets.QLabel("Extraction method") |
| 129 | self.extraction_method_widget = QtWidgets.QComboBox() |
| 130 | options = ["automatic", "manual"] |
| 131 | self.extraction_method_widget.addItems(options) |
| 132 | self.extraction_method_widget.currentTextChanged.connect(self.log_extraction_method) |
| 133 | |
| 134 | # Frame extraction algorithm |
| 135 | ext_algo_label = QtWidgets.QLabel("Extraction algorithm") |
| 136 | self.extraction_algorithm_widget = QtWidgets.QComboBox() |
| 137 | self.extraction_algorithm_widget.addItems(DLCParams.FRAME_EXTRACTION_ALGORITHMS) |
| 138 | self.extraction_algorithm_widget.currentTextChanged.connect(self.log_extraction_algorithm) |
| 139 | |