MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / extract_frames

Method extract_frames

deeplabcut/gui/tabs/extract_frames.py:189–239  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

187 self.root.logger.info(f"Cropping set to '{cropping_option}'")
188
189 def extract_frames(self):
190 config = self.root.config
191 mode = self.extraction_method_widget.currentText()
192 if mode == "manual":
193 videos = list(self.video_selection_widget.files)
194 if not videos:
195 QtWidgets.QMessageBox.critical(
196 self,
197 "Error",
198 "Please select exactly one video to extract frames from.",
199 )
200 return
201 first_video = videos[0]
202 if len(videos) > 1:
203 self.root.writer.write(f"Only the first video ({first_video}) will be opened.")
204 video_path_in_folder = self._check_symlink(first_video)
205 _ = launch_napari(str(video_path_in_folder))
206 return
207
208 algo = self.extraction_algorithm_widget.currentText()
209 clusterstep = self.cluster_step_widget.value()
210 slider_width = self.slider_width_widget.value()
211
212 crop = False # default value
213 if self.frame_cropping_widget.currentText() == "GUI":
214 _ = select_cropping_area(config)
215 crop = True
216 elif self.frame_cropping_widget.currentText() == "read from config":
217 crop = True
218
219 func = partial(
220 extract_frames,
221 config,
222 mode,
223 algo,
224 crop=crop,
225 cluster_step=clusterstep,
226 cluster_resizewidth=30,
227 cluster_color=False,
228 slider_width=slider_width,
229 userfeedback=False,
230 videos_list=self.video_selection_widget.files or None,
231 )
232
233 self.worker, self.thread = move_to_separate_thread(func, capture_outputs=True)
234 self.worker.finished.connect(lambda: self.ok_button.setEnabled(True))
235 self.worker.finished.connect(lambda: self.root._progress_bar.hide())
236 self.thread.finished.connect(self._show_success_message)
237 self.thread.start()
238 self.ok_button.setEnabled(False)
239 self.root._progress_bar.show()
240
241 def _show_success_message(self):
242 message = "Failed to create worker: it is None"

Calls 8

_check_symlinkMethod · 0.95
launch_napariFunction · 0.90
move_to_separate_threadFunction · 0.90
writeMethod · 0.80
connectMethod · 0.80
startMethod · 0.80
showMethod · 0.80
select_cropping_areaFunction · 0.70

Tested by

no test coverage detected