예제 #1
0
def demo_confmaps(confmaps,
                  video,
                  scale=None,
                  standalone=False,
                  callback=None):
    """Demo function."""
    from PySide2 import QtWidgets
    from sleap.gui.widgets.video import QtVideoPlayer

    if standalone:
        app = QtWidgets.QApplication([])

    win = QtVideoPlayer(video=video)
    win.setWindowTitle("confmaps")
    win.show()

    def plot_confmaps(parent, frame_idx):
        if frame_idx < confmaps.shape[0]:
            frame_conf_map = ConfMapsPlot(confmaps[frame_idx, ...],
                                          show_box=not scale)
            if scale:
                frame_conf_map.setScale(scale)
            win.view.scene.addItem(frame_conf_map)

    win.changedPlot.connect(plot_confmaps)
    if callback:
        win.changedPlot.connect(callback)
    win.plot()

    if standalone:
        app.exec_()

    return win
예제 #2
0
파일: pafs.py 프로젝트: stallam-unb/sleap
def demo_pafs(pafs, video, decimation=4, scale=None, standalone=False):
    from sleap.gui.widgets.video import QtVideoPlayer

    if standalone:
        app = QtWidgets.QApplication([])

    win = QtVideoPlayer(video=video)
    win.setWindowTitle("pafs")

    decimation_size_bar = QtWidgets.QSlider(QtCore.Qt.Horizontal)
    decimation_size_bar.valueChanged.connect(lambda e: win.plot())
    decimation_size_bar.setValue(decimation)
    decimation_size_bar.setMinimum(1)
    decimation_size_bar.setMaximum(10)
    decimation_size_bar.setEnabled(True)
    win.layout.addWidget(decimation_size_bar)

    win.show()

    def plot_fields(parent, frame_idx):
        if frame_idx < pafs.shape[0]:
            frame_pafs = pafs[frame_idx, ...]
            decimation = decimation_size_bar.value()
            aff_fields_item = MultiQuiverPlot(
                frame_pafs, show=None, decimation=decimation
            )
            if scale:
                aff_fields_item.setScale(scale)
            win.view.scene.addItem(aff_fields_item)

    win.changedPlot.connect(plot_fields)
    win.plot()

    if standalone:
        app.exec_()

    return win