Esempio n. 1
0
    def update_filter_page(self, index):
        name     = str(self.cb_filter_group.itemText(index))
        fr       = engine.get_component("filter_rack")
        page     = fr.get_page(name)
        layout   = self.filter_rack_contents.layout()

        try:
            if get_app().user_options["filter_group"] is not None:
                cur_page = fr.get_page(get_app().user_options["filter_group"])
                length   = len(cur_page)
                # Clear the Layout
                while length > 0:
                    i = layout.takeAt(1).widget()
                    i.setParent(None)
                    i.deleteLater()
                    length -= 1
        except:
            log.error("Error when cleaning the Rack UI", exc_info=True)

        get_app().user_options["filter_group"] = name
        # Add the filters contained in the filter page
        for f in page:
            self.add_filter_gui(f.fid, engine.get_plugin(f.fid))

        self.update_filter_uis()
        self.lbl_page_in.setText(page.in_color)
        self.lbl_page_out.setText(page.out_color)
Esempio n. 2
0
    def _update_gui(self, pos=0):
        mw = get_app().get_ui("main_window")
        vs = engine.get_component("video_source")

        mw.frm_playback.setEnabled(True)
        mw.scb_pos.setRange(0, vs.get_length() - 1)
        mw.lbl_total.setText(self._format_pos(mw.scb_pos.maximum(), vs.get_fps()))
Esempio n. 3
0
    def __init__(self, fid, name, title, page_name, parent=None):
        super(FilterUI, self).__init__(parent)
        app = get_app()
        app.load_ui("", "ICFilterUI.ui", self)

        self.parameters = {}
        self.lbl_fid.setNum(fid)
        self.title.setText(title)
        self.title.setToolTip(title)

        self.pb_up.setEnabled(False)
        self.pb_down.setEnabled(False)
        self.name = name
        self.fid = fid
        self.frm_parameters.setVisible(False)
        self.populate_parameters()

        self.pb_up.clicked.connect(self.pb_up_clicked)
        self.pb_down.clicked.connect(self.pb_down_clicked)
        self.pb_remove.clicked.connect(self.pb_remove_clicked)
        self.pb_ignore.clicked.connect(self.pb_ignore_clicked)

        self.page_name = page_name

        page = engine.get_component("filter_rack").get_page(page_name)
        filter_ = page.get_filter(fid)

        self.filter_in.setText(filter_.in_color)
        self.filter_out.setText(filter_.out_color)
Esempio n. 4
0
    def prompt_filter_plugin(self, checked):
        ret, selected = PluginDialog.select_type(engine.PLUGIN_TYPE_FILTER)
        app = get_app()
        vs = engine.get_component("video_source")
        fs = engine.get_component("frame_stream")
        if ret:
            try:
                pid, plugin = engine.load_plugin(selected)
                engine.get_component("filter_rack").get_page(get_app().user_options["filter_group"]).add(pid)
                # Create the GUI
                self.add_filter_gui(pid, plugin)
            except:
                log.exception("")
                QMessageBox.warning(None, tr("MainWindow", "Plugin Load Error"),
                tr("MainWindow", "Got an error when trying to load the filter plugin"))

        return
Esempio n. 5
0
    def pb_play_clicked(self, checked):
        app = get_app()
        fs = engine.get_component("frame_stream")

        if checked:
            fs.start()
            self._play()
        else:
            fs.stop()
            self._pause()
Esempio n. 6
0
    def prompt_input_plugin(self, checked):
        ret, selected = PluginDialog.select_type(engine.PLUGIN_TYPE_VIDEO_INPUT)
        app = get_app()

        if ret:
            try:
                pid, plugin = engine.load_plugin(selected)
                engine.init_input_plugin(pid)
                vs = engine.get_component("video_source")
                fr = engine.get_component("filter_rack")
                color_space = vs.color_space
                page = fr.get_page("Raw")
                page.in_color  = color_space
                page.out_color = color_space
                self.update_filter_uis()
            except:
                log.exception("")
                QMessageBox.warning(None, tr("MainWindow", "Plugin Load Error"),
                tr("MainWindow", "Got an error when trying to load the input plugin"))

        return
Esempio n. 7
0
    def _reset_gui(self):
        mw = get_app().get_ui("main_window")

        mw.frm_playback.setEnabled(False)

        mw.lbl_current.setText(self._format_pos(0))
        mw.lbl_total.setText(self._format_pos(0))

        mw.scb_pos.setRange(0, 0)

        mw.pb_play.setChecked(False)
        mw.pb_play.setIcon(QIcon(":icon/play"))

        fs = engine.get_component("frame_stream")
        fs.start(True)
        self.wait_to_seek = True
        self.preview_timer.start()
Esempio n. 8
0
    def apply_filters(self, frame):
        if self.get_flow_errors():
            raise FilterPageFlowError()

        if frame.color_space != self.in_color:
            raise WrongColorSpace("Frame should be {} and not {}".format(self.in_color, frame.color_space))

        for i in range(0, len(self.flist)):
            if self.flist[i].ignore:
                continue
            p = engine.get_plugin(self.flist[i].fid)
            frame = p.instance.apply_filter(frame)

        if get_app().user_options["preview_source"] == get_app().OPT_PREVIEW_FILTER_PAGE:
            if self.name == get_app().user_options["filter_group"]:
                fs = engine.get_component("frame_stream")
                fs.preview_queue.put(frame.copy())
        return frame
Esempio n. 9
0
    def update_filter_uis(self):
        layout = self.filter_rack_contents.layout()
        self.lbl_page_in.setStyleSheet("color: green;")
        self.lbl_page_out.setStyleSheet("color: green;")
        # Update buttons of the ui's
        for i in range(0, layout.count()):
            item = layout.itemAt(i)
            if isinstance(item.widget(), FilterUI):
                w = item.widget()
                w.update_buttons()
                w.filter_in.setStyleSheet("color: green;")
                w.filter_out.setStyleSheet("color: green;")

        try:
            # Get Flow Errors to correct the label colors
            page   = engine.get_component("filter_rack").get_page(get_app().user_options["filter_group"])
            self.lbl_page_in.setStyleSheet("color: green;")
            self.lbl_page_out.setStyleSheet("color: green;")
            self.lbl_page_in.setText(page.in_color)
            self.lbl_page_out.setText(page.out_color)

            errors = page.get_flow_errors()
            for err in errors:
                if err[0] is None:
                    self.lbl_page_in.setStyleSheet("color: red;")
                    i = layout.itemAt(err[1]+1)
                    if i is not None and i.widget() is not None:
                        i.widget().filter_in.setStyleSheet("color: red;")
                elif err[1] is None:
                    self.lbl_page_out.setStyleSheet("color: red;")
                    i = layout.itemAt(err[0]+1)
                    if i is not None and i.widget() is not None:
                        i.widget().filter_out.setStyleSheet("color: red;")
                else:
                    out_error = layout.itemAt(err[0]+1).widget()
                    in_error  = layout.itemAt(err[1]+1).widget()
                    out_error.filter_out.setStyleSheet("color: red;")
                    in_error.filter_in.setStyleSheet("color: red;")
        except:
            log.error("Error when checking for flow errors", exc_info=True)
Esempio n. 10
0
    def update_preview(self):
        interval = 0
        try:
            mw = get_app().get_ui("main_window")
            fs = engine.get_component("frame_stream")
            preview_queue = fs.preview_queue

            # Don't get frames from the queueif the user is moving the time
            # scroll bar
            if not mw.scb_pos.isSliderDown():
                frame = preview_queue.get(False)
                self._set_pos(frame.pos)
                # If the current tab isn't the preview, don't bother converting
                # the frames.
                if mw.maintab.currentIndex() == mw.maintab.indexOf(mw.tab_preview):
                    # Generate COLOR CONVERTION CONSTANT to RGB based on the
                    # frame color space
                    color = "COLOR_" + frame.color_space + "2RGB"
                    # Check if it is valid
                    if not color in COLORS and frame.color_space != "RGB":
                        log.error("Can't convert {} to RGB".format(frame.color_space))
                    else:
                        rgb = None
                        # Convert the frame if it isn't at RGB format yet
                        if frame.color_space == "RGB":
                            rgb = frame.data
                        else:
                            rgb = cv2.cvtColor(frame.data, getattr(cv2, color))
                        # Create a QImage with the frame data
                        img = QImage(rgb.tostring(), rgb.shape[1], rgb.shape[0], QImage.Format_RGB888)
                        # Create and show the Pixmap
                        pixmap = QPixmap(img)
                        get_app().get_ui("main_window").lbl_preview.setPixmap(pixmap)
                        self.wait_to_seek = False
        except Empty:
            interval = 0

        if get_app().get_ui("main_window").pb_play.isChecked() or self.wait_to_seek:
            self.preview_timer.start(interval)
Esempio n. 11
0
 def set_loop(self, loop):
     engine.get_component("frame_stream").loop = loop
Esempio n. 12
0
 def pb_ignore_clicked(self, checked):
     engine.get_component("filter_rack").get_page(self.page_name).ignore(self.fid, checked)
Esempio n. 13
0
 def pb_remove_clicked(self):
     engine.get_component("filter_rack").get_page(self.page_name).remove(self.fid)
     engine.unload_plugin(self.fid)
Esempio n. 14
0
 def pb_down_clicked(self):
     engine.get_component("filter_rack").get_page(self.page_name).down(self.fid)
Esempio n. 15
0
 def _format_pos(self, pos, fps=None):
     vs = engine.get_component("video_source")
     length = vs.get_length()
     str_size = len(str(length))
     format_str = "{:0" + str(str_size) + "d}"
     return format_str.format(pos)
Esempio n. 16
0
 def seek(self):
     fs = engine.get_component("frame_stream")
     fs.seek(get_app().get_ui("main_window").scb_pos.sliderPosition())
     self.wait_to_seek = True
     self.preview_timer.start()
Esempio n. 17
0
 def update_buttons(self):
     page = engine.get_component("filter_rack").get_page(self.page_name)
     self.pb_up.setEnabled(not page.is_first(self.fid))
     self.pb_down.setEnabled(not page.is_last(self.fid))
     self.pb_ignore.setChecked(page.is_ignored(self.fid))
Esempio n. 18
0
 def _set_pos(self, pos):
     mw = get_app().get_ui("main_window")
     mw.scb_pos.setValue(pos)
     mw.lbl_current.setText(self._format_pos(pos, engine.get_component("video_source").get_fps()))