Ejemplo n.º 1
0
    def __init__(
        self,
        backed_weak_heap: backend.BackendWeakHeap,
        bc: backend.BackendConnection,
        preview_width=256,
    ):
        self._preview_width = preview_width
        self._timer = qtx.QXTimer(interval=16,
                                  timeout=self._on_timer_16ms,
                                  start=True)

        self._backed_weak_heap = backed_weak_heap
        self._bc = bc
        self._bcd_id = None

        layered_images = self._layered_images = qtx.QXFixedLayeredImages(
            preview_width, preview_width)
        info_label = self._info_label = qtx.QXLabel(
            font=QXFontDB.get_fixedwidth_font(size=7))

        main_l = qtx.QXVBoxLayout([(layered_images, qtx.AlignCenter),
                                   (info_label, qtx.AlignCenter)])

        super().__init__(title=L('@QBCFaceSwapViewer.title'),
                         content_layout=main_l)
Ejemplo n.º 2
0
    def __init__(self, label: str = None, popup_info_text=None):
        """
        text label with optional popup info on click
        """
        super().__init__()

        self._has_info_text = False

        self._label = qtx.QXLabel(text='', hided=True)

        wnd_text_label = self._popup_wnd_text_label = qtx.QXLabel(
            text='', font=QXFontDB.get_default_font())

        wnd = self._popup_wnd = qtx.QXPopupWindow(
            layout=qtx.QXHBoxLayout([
                qtx
                .QXFrame(bg_color=qtx.Qt.GlobalColor.black,
                         layout=qtx.QXHBoxLayout([
                             qtx.QXFrame(
                                 layout=qtx.QXHBoxLayout([
                                     qtx.QXLabel(image=QXImageDB
                                                 .information_circle_outline(
                                                     'yellow'),
                                                 scaled_contents=True,
                                                 fixed_size=(24, 24
                                                             )), wnd_text_label
                                 ],
                                                         contents_margins=2,
                                                         spacing=2)),
                         ],
                                                 contents_margins=2,
                                                 spacing=2),
                         size_policy=('fixed', 'fixed'))
            ],
                                    contents_margins=0))

        info_btn = self._info_btn = qtx.QXPushButton(
            image=QXImageDB.information_circle_outline('light gray'),
            released=self._on_info_btn_released,
            fixed_size=(24, 22),
            hided=True)

        self.setLayout(qtx.QXHBoxLayout([self._label, info_btn]))

        self.set_label(label)
        self.set_popup_info(popup_info_text)
Ejemplo n.º 3
0
    def __init__(
        self,
        csw_idx: lib_csw.Number.Client,
        csw_idx_count: lib_csw.Number.Client,
    ):
        """
        Implements controlable Slider with lib_csw.Number controls
        """
        if not isinstance(csw_idx, lib_csw.Number.Client):
            raise ValueError('csw_idx must be an instance of Number.Client')
        if not isinstance(csw_idx_count, lib_csw.Number.Client):
            raise ValueError(
                'csw_idx_count must be an instance of Number.Client')

        self._csw_idx = csw_idx
        self._csw_idx_count = csw_idx_count

        csw_idx.call_on_number(self._on_csw_idx)
        csw_idx_count.call_on_number(self._on_csw_idx_count)

        slider = self._slider = qtx.QXSlider(
            orientation=qtx.Qt.Orientation.Horizontal,
            min=0,
            max=0,
            tick_position=qtx.QSlider.TickPosition.NoTicks,
            tick_interval=1,
            valueChanged=self._on_slider_valueChanged)

        spinbox_font = QXFontDB.Digital7_Mono(11, italic=True)
        spinbox_index = self._spinbox_index = qtx.QXSpinBox(
            font=spinbox_font,
            min=0,
            max=0,
            step=1,
            alignment=qtx.AlignRight,
            button_symbols=qtx.QAbstractSpinBox.ButtonSymbols.NoButtons,
            editingFinished=self._on_spinbox_index_editingFinished)
        spinbox_count = self._spinbox_count = qtx.QXSpinBox(
            font=spinbox_font,
            min=0,
            max=0,
            step=1,
            alignment=qtx.AlignRight,
            button_symbols=qtx.QAbstractSpinBox.ButtonSymbols.NoButtons,
            readonly=True)

        super().__init__(
            csw_control=csw_idx,
            layout=qtx.QXVBoxLayout([
                slider,
                (qtx.QXFrameHBox(
                    [spinbox_index,
                     qtx.QXLabel(text='/'), spinbox_count],
                    size_policy=('fixed', 'fixed')), qtx.AlignCenter),
            ]))
Ejemplo n.º 4
0
    def __init__(self, backend : BackendHost, name : str, layout, content_align_top=False):
        super().__init__()
        if not isinstance(backend, BackendHost):
            raise ValueError('backend must be an instance of BackendHost')

        self._backend = backend
        self._name = name

        backend.call_on_state_change(self._on_backend_state_change)
        backend.call_on_profile_timing(self._on_backend_profile_timing)

        btn_on_off = self._btn_on_off = qtx.QXPushButton(tooltip_text=L('@QBackendPanel.start'),
                                                         released=self._on_btn_on_off_released,
                                                         fixed_width=20)

        btn_reset_state = self._btn_reset_state = qtx.QXPushButton(image=QXImageDB.settings_reset_outline('gray'),
                                                                   released=self._on_btn_reset_state_released, tooltip_text=L('@QBackendPanel.reset_settings'),
                                                                   fixed_width=20)

        fps_label = self._fps_label = qtx.QXLabel()

        bar_widget = self._bar_widget = \
            qtx.QXFrameHBox(widgets=[btn_on_off, 1, btn_reset_state, 2,
                                     qtx.QXLabel(name, font=QXFontDB.get_default_font(10)),
                                     (fps_label, qtx.AlignRight), 2],
                            size_policy=('expanding', 'fixed'), fixed_height=24)

        content_widget = self._content_widget = qtx.QXFrameHBox([layout], contents_margins=2, enabled=False)

        l_widgets = [bar_widget, 1]

        if not content_align_top:
            l_widgets += [ qtx.QXFrame(size_policy=('expanding','expanding') ) ]

        l_widgets += [content_widget]
        l_widgets += [ qtx.QXFrame(size_policy=('expanding', 'expanding') ) ]

        self.setLayout(qtx.QXVBoxLayout(l_widgets))

        btn_on_off.set_image( QXImageDB.power_outline('red') )
Ejemplo n.º 5
0
    def __init__(self,  csw_error : lib_csw.Error.Client):
        if not isinstance(csw_error, lib_csw.Error.Client):
            raise ValueError('csw_error must be an instance of Error.Client')

        self._csw_error = csw_error
        csw_error.call_on_error(self._on_csw_error)

        self._label_warning = qtx.QXLabel(image=QXImageDB.warning_outline('red'),
                                          scaled_contents=True,
                                          size_policy=('fixed', 'fixed'),
                                          fixed_size=(32,32) )

        self._label = qtx.QXTextEdit( font=QXFontDB.get_default_font(size=7), read_only=True, fixed_height=80)

        super().__init__(csw_control=csw_error,
                         layout=qtx.QXHBoxLayout([self._label_warning, self._label]) )
Ejemplo n.º 6
0
    def __init__(self, csw_progress: lib_csw.Progress.Client):
        if not isinstance(csw_progress, lib_csw.Progress.Client):
            raise ValueError(
                'csw_progress must be an instance of Progress.Client')

        self._csw_progress = csw_progress

        csw_progress.call_on_progress(self._on_csw_progress)
        csw_progress.call_on_config(self._on_csw_config)

        label_title = self._label_title = qtx.QXLabel('',
                                                      word_wrap=True,
                                                      hided=True)
        progressbar = self._progressbar = qtx.QXProgressBar(
            min=0, max=100, font=QXFontDB.Digital7_Mono(11, italic=True))

        super().__init__(csw_control=csw_progress,
                         layout=qtx.QXVBoxLayout([label_title, progressbar]))
Ejemplo n.º 7
0
    def __init__(self,
                 csw_number: lib_csw.Number.Client,
                 reflect_state_widgets=None):

        if not isinstance(csw_number, lib_csw.Number.Client):
            raise ValueError('csw_number must be an instance of Number.Client')

        self._csw_number = csw_number
        self._decimals = 0

        csw_number.call_on_number(self._on_csw_number)
        csw_number.call_on_config(self._on_csw_config)

        label = self._label = qtx.QXLabel(
            font=QXFontDB.Digital7_Mono(11, italic=True))

        super().__init__(csw_control=csw_number,
                         reflect_state_widgets=reflect_state_widgets,
                         layout=qtx.QXHBoxLayout([label]))
Ejemplo n.º 8
0
    def __init__(self, userdata_path):
        self.userdata_path = userdata_path
        settings_dirpath = self.settings_dirpath = userdata_path / 'settings'
        if not settings_dirpath.exists():
            settings_dirpath.mkdir(parents=True)
        super().__init__(app_name='DeepFaceLive',
                         settings_dirpath=settings_dirpath)

        self.setFont(QXFontDB.get_default_font())
        self.setWindowIcon(QXImageDB.app_icon().as_QIcon())

        splash_wnd = self.splash_wnd =\
            qtx.QXSplashWindow(layout=qtx.QXVBoxLayout([ (qtx.QXLabel(image=QXImageDB.splash_deepfacelive()), qtx.AlignCenter)
                                                       ], contents_margins=20))
        splash_wnd.show()
        splash_wnd.center_on_screen()

        self._dfl_wnd = None
        self._t = qtx.QXTimer(interval=1666,
                              timeout=self._on_splash_wnd_expired,
                              single_shot=True,
                              start=True)
        self.initialize()
Ejemplo n.º 9
0
    def __init__(self, backend: FaceDetector):
        if not isinstance(backend, FaceDetector):
            raise ValueError('backend must be an instance of FaceDetector')

        self._backend = backend
        self._bc_out = backend.get_bc_out()
        self._weak_heap = backend.get_weak_heap()
        self._bcd_id = None
        self._timer = qtx.QXTimer(interval=10,
                                  timeout=self._on_timer_10ms,
                                  start=True)

        face_coords_label = self._q_face_coords_label = qtx.QXLabel(
            font=QXFontDB.get_fixedwidth_font(size=7), word_wrap=False)
        q_detected_faces = self._q_detected_faces = qtx.QXCollapsibleSection(
            title=L('@QFaceDetector.detected_faces'),
            content_layout=qtx.QXVBoxLayout([face_coords_label]),
            is_opened=True)

        cs = backend.get_control_sheet()

        q_detector_type_label = QLabelPopupInfo(
            label=L('@QFaceDetector.detector_type'),
            popup_info_text=L('@QFaceDetector.help.detector_type'))
        q_detector_type = QComboBoxCSWDynamicSingleSwitch(
            cs.detector_type, reflect_state_widgets=[q_detector_type_label])

        q_device_label = QLabelPopupInfo(
            label=L('@common.device'),
            popup_info_text=L('@common.help.device'))
        q_device = QComboBoxCSWDynamicSingleSwitch(
            cs.device, reflect_state_widgets=[q_device_label])

        q_fixed_window_size_label = QLabelPopupInfo(
            label=L('@QFaceDetector.window_size'),
            popup_info_text=L('@QFaceDetector.help.window_size'))
        q_fixed_window_size = QSpinBoxCSWNumber(cs.fixed_window_size,
                                                reflect_state_widgets=[
                                                    q_fixed_window_size_label,
                                                    q_detected_faces
                                                ])

        q_threshold_label = QLabelPopupInfo(
            label=L('@QFaceDetector.threshold'),
            popup_info_text=L('@QFaceDetector.help.threshold'))
        q_threshold = QSpinBoxCSWNumber(
            cs.threshold, reflect_state_widgets=[q_threshold_label])

        q_max_faces_label = QLabelPopupInfo(
            label=L('@QFaceDetector.max_faces'),
            popup_info_text=L('@QFaceDetector.help.max_faces'))
        q_max_faces = QSpinBoxCSWNumber(
            cs.max_faces, reflect_state_widgets=[q_max_faces_label])

        q_sort_by_label = QLabelPopupInfo(
            label=L('@QFaceDetector.sort_by'),
            popup_info_text=L('@QFaceDetector.help.sort_by'))
        q_sort_by = QComboBoxCSWDynamicSingleSwitch(
            cs.sort_by, reflect_state_widgets=[q_sort_by_label])

        q_temporal_smoothing_label = QLabelPopupInfo(
            label=L('@QFaceDetector.temporal_smoothing'),
            popup_info_text=L('@QFaceDetector.help.temporal_smoothing'))
        q_temporal_smoothing = QSpinBoxCSWNumber(
            cs.temporal_smoothing,
            reflect_state_widgets=[q_temporal_smoothing_label])

        grid_l = qtx.QXGridLayout(vertical_spacing=5, horizontal_spacing=5)
        row = 0
        grid_l.addWidget(q_detector_type_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_detector_type, row, 1, 1, 3)
        row += 1
        grid_l.addWidget(q_device_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_device, row, 1, 1, 3)
        row += 1
        grid_l.addWidget(q_fixed_window_size_label,
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_fixed_window_size,
                         row,
                         2,
                         1,
                         2,
                         alignment=qtx.AlignLeft)
        row += 1
        grid_l.addWidget(q_threshold_label,
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_threshold, row, 2, 1, 2, alignment=qtx.AlignLeft)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout([q_max_faces_label, 5, q_max_faces]),
                         row,
                         0,
                         1,
                         2,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(qtx.QXHBoxLayout([q_sort_by_label, 5, q_sort_by]),
                         row,
                         2,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_temporal_smoothing_label, 5, q_temporal_smoothing]),
                         row,
                         0,
                         1,
                         4,
                         alignment=qtx.AlignCenter)
        row += 1
        grid_l.addWidget(q_detected_faces, row, 0, 1, 4)
        row += 1
        super().__init__(backend,
                         L('@QFaceDetector.module_title'),
                         layout=qtx.QXVBoxLayout([grid_l]))
Ejemplo n.º 10
0
    def __init__(self, backend: StreamOutput):
        cs = backend.get_control_sheet()

        q_average_fps_label = QLabelPopupInfo(
            label=L('@QStreamOutput.avg_fps'),
            popup_info_text=L('@QStreamOutput.help.avg_fps'))
        q_average_fps = QLabelCSWNumber(
            cs.avg_fps, reflect_state_widgets=[q_average_fps_label])

        q_source_type_label = QLabelPopupInfo(
            label=L('@QStreamOutput.source_type'))
        q_source_type = QComboBoxCSWDynamicSingleSwitch(
            cs.source_type, reflect_state_widgets=[q_source_type_label])

        q_show_hide_window = QXPushButtonCSWSignal(
            cs.show_hide_window,
            text=L('@QStreamOutput.show_hide_window'),
            button_size=(None, 22))

        q_aligned_face_id_label = QLabelPopupInfo(
            label=L('@QStreamOutput.aligned_face_id'),
            popup_info_text=L('@QStreamOutput.help.aligned_face_id'))
        q_aligned_face_id = QSpinBoxCSWNumber(
            cs.aligned_face_id,
            reflect_state_widgets=[q_aligned_face_id_label])

        q_target_delay_label = QLabelPopupInfo(
            label=L('@QStreamOutput.target_delay'),
            popup_info_text=L('@QStreamOutput.help.target_delay'))
        q_target_delay = QSpinBoxCSWNumber(
            cs.target_delay, reflect_state_widgets=[q_target_delay_label])

        q_save_sequence_path_label = QLabelPopupInfo(
            label=L('@QStreamOutput.save_sequence_path'),
            popup_info_text=L('@QStreamOutput.help.save_sequence_path'))
        q_save_sequence_path = QPathEditCSWPaths(cs.save_sequence_path,
                                                 reflect_state_widgets=[
                                                     q_target_delay_label,
                                                     q_save_sequence_path_label
                                                 ])
        q_save_sequence_path_error = QErrorCSWError(
            cs.save_sequence_path_error)

        q_save_fill_frame_gap_label = QLabelPopupInfo(
            label=L('@QStreamOutput.save_fill_frame_gap'),
            popup_info_text=L('@QStreamOutput.help.save_fill_frame_gap'))
        q_save_fill_frame_gap = QCheckBoxCSWFlag(
            cs.save_fill_frame_gap,
            reflect_state_widgets=[q_save_fill_frame_gap_label])

        q_is_streaming_label = QLabelPopupInfo(label='mpegts udp://')
        q_is_streaming = QCheckBoxCSWFlag(
            cs.is_streaming, reflect_state_widgets=[q_is_streaming_label])

        q_stream_addr = QLineEditCSWText(cs.stream_addr,
                                         font=QXFontDB.get_fixedwidth_font())
        q_stream_port = QSpinBoxCSWNumber(cs.stream_port)

        grid_l = qtx.QXGridLayout(spacing=5)
        row = 0
        grid_l.addWidget(q_average_fps_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_average_fps,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addWidget(q_source_type_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_source_type,
                         row,
                         1,
                         1,
                         1,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        grid_l.addWidget(q_show_hide_window, row, 2, 1, 1)

        row += 1
        grid_l.addWidget(q_aligned_face_id_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_aligned_face_id,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addWidget(q_target_delay_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_target_delay,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1

        grid_l.addWidget(q_save_sequence_path_label,
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addWidget(q_save_sequence_path,
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_save_fill_frame_gap, 4, q_save_fill_frame_gap_label]),
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1
        grid_l.addWidget(q_save_sequence_path_error, row, 0, 1, 3)
        row += 1
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_is_streaming, 4, q_is_streaming_label]),
                         row,
                         0,
                         1,
                         1,
                         alignment=qtx.AlignRight | qtx.AlignVCenter)
        grid_l.addLayout(qtx.QXHBoxLayout(
            [q_stream_addr,
             qtx.QXLabel(text=':'), q_stream_port]),
                         row,
                         1,
                         1,
                         2,
                         alignment=qtx.AlignLeft | qtx.AlignVCenter)
        row += 1

        super().__init__(backend,
                         L('@QStreamOutput.module_title'),
                         layout=grid_l)