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

Class TrackletVisualizer

deeplabcut/gui/tracklet_toolbox.py:288–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286
287
288class TrackletVisualizer:
289 def __init__(self, manager, videoname, trail_len=50):
290 self.manager = manager
291 self.cmap = plt.cm.get_cmap(manager.cfg["colormap"], len(set(manager.tracklet2id)))
292 self.videoname = videoname
293 self.video = VideoReader(videoname)
294 self.nframes = len(self.video)
295 # Take into consideration imprecise OpenCV estimation of total number of frames
296 if abs(self.nframes - manager.nframes) >= 0.05 * manager.nframes:
297 print("Video duration and data length do not match. Continuing nonetheless...")
298 self.trail_len = trail_len
299 self.help_text = ""
300 self.draggable = False
301 self._curr_frame = 0
302 self.curr_frame = 0
303
304 self.picked = []
305 self.picked_pair = []
306 self.cuts = []
307
308 self.mutex = QMutex()
309 self.player = BackgroundPlayer(self)
310 self.worker, self.thread_player = move_to_separate_thread(self.player.run)
311 self.thread_player.start()
312
313 self.dps = []
314
315 self.swap_id1 = None
316 self.swap_id2 = None
317
318 def _prepare_canvas(self, manager, fig):
319 params = {
320 "keymap.save": "s",
321 "keymap.back": "left",
322 "keymap.forward": "right",
323 "keymap.yscale": "l",
324 }
325 for k, v in params.items():
326 if v in plt.rcParams[k]:
327 plt.rcParams[k].remove(v)
328
329 self.dotsize = manager.cfg["dotsize"]
330 self.alpha = manager.cfg["alphavalue"]
331
332 if fig is None:
333 self.fig = plt.figure(figsize=(13, 8))
334 else:
335 self.fig = fig
336 gs = self.fig.add_gridspec(2, 2)
337 self.ax1 = self.fig.add_subplot(gs[:, 0])
338 self.ax2 = self.fig.add_subplot(gs[0, 1])
339 self.ax3 = self.fig.add_subplot(gs[1, 1], sharex=self.ax2)
340 plt.subplots_adjust(bottom=0.2)
341 for ax in self.ax1, self.ax2, self.ax3:
342 ax.axis("off")
343
344 self.colors = self.cmap(manager.tracklet2id)
345 self.colors[:, -1] = self.alpha

Callers 1

refine_trackletsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected