Exemplo n.º 1
0
    def createHoughLinesLayer(self):
        layerContent = Layers([])
        layerContent.name = 'HoughLines'
        layerContent.children = []
        layerContent.enable = 1

        tempChildren = Layers([])
        tempChildren.name = 'rho'
        tempChildren.value = 0.8
        tempChildren.note = 'Distance resolution'
        layerContent.children.append(tempChildren)

        tempChildren = Layers([])
        tempChildren.name = 'theta'
        tempChildren.value = 0.01
        tempChildren.note = 'Angle resolution'
        layerContent.children.append(tempChildren)

        tempChildren = Layers([])
        tempChildren.name = 'threshold'
        tempChildren.value = 100
        tempChildren.note = 'Accumulator threshold parameter'
        layerContent.children.append(tempChildren)

        self.layerContents.append(layerContent)
        self.TreeHandler.buildEntitiesTree(self.layerContents)
Exemplo n.º 2
0
    def createHoughLinesPLayer(self):
        layerContent = Layers([])
        layerContent.name = 'HoughLinesP'
        layerContent.children = []
        tempChildren = Layers([])
        layerContent.enable = 1

        tempChildren.name = 'rho'
        tempChildren.value = 0.8
        tempChildren.note = 'Distance resolution'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'theta'
        tempChildren.value = 0.01
        tempChildren.note = 'Angle resolution'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'threshold'
        tempChildren.value = 100
        tempChildren.note = 'Accumulator threshold parameter'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'minLineLength'
        tempChildren.value = 10
        tempChildren.note = 'Minimum line length'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'maxLineGap'
        tempChildren.value = 500
        tempChildren.note = 'Maximum allowed gap'
        layerContent.children.append(deepcopy(tempChildren))

        self.layerContents.append(layerContent)
        self.TreeHandler.buildEntitiesTree(self.layerContents)
Exemplo n.º 3
0
    def createGaussianBlurLayer(self):
        layerContent = Layers([])
        layerContent.name = 'GaussianBlur'
        layerContent.children = []
        layerContent.enable = 1

        tempChildren = Layers([])
        tempChildren.name = 'width'
        tempChildren.value = 3
        tempChildren.note = 'ksize.width'
        layerContent.children.append(tempChildren)

        tempChildren = Layers([])
        tempChildren.name = 'height'
        tempChildren.value = 3
        tempChildren.note = 'ksize.height'
        layerContent.children.append(tempChildren)

        tempChildren = Layers([])
        tempChildren.name = 'sigmaX'
        tempChildren.value = 0
        tempChildren.note = 'sigmaX'
        layerContent.children.append(tempChildren)

        tempChildren = Layers([])
        tempChildren.name = 'sigmaY'
        tempChildren.value = 0
        tempChildren.note = 'sigmaY'
        layerContent.children.append(tempChildren)

        self.layerContents.append(layerContent)
        self.TreeHandler.buildEntitiesTree(self.layerContents)
Exemplo n.º 4
0
    def createcvtColorLayer(self):
        layerContent = Layers([])
        layerContent.name = 'cvtColor'
        layerContent.children = []
        layerContent.enable = 1

        tempChildren = Layers([])
        tempChildren.name = 'low'
        tempChildren.value = 50
        tempChildren.note = 'threshold1'
        layerContent.children.append(tempChildren)

        self.layerContents.append(layerContent)
        self.TreeHandler.buildEntitiesTree(self.layerContents)
Exemplo n.º 5
0
    def createfindContoursLayer(self):
        layerContent = Layers([])
        layerContent.name = 'findContours'
        layerContent.children = []
        layerContent.enable = 1

        tempChildren = Layers([])
        tempChildren.name = 'RM'
        tempChildren.value = cv2.RETR_TREE
        tempChildren.note = 'RetrievalModes'
        layerContent.children.append(tempChildren)

        tempChildren = Layers([])
        tempChildren.name = 'CAM'
        tempChildren.value = cv2.CHAIN_APPROX_SIMPLE
        tempChildren.note = 'ContourApproximationModes'
        layerContent.children.append(tempChildren)

        self.layerContents.append(layerContent)
        self.TreeHandler.buildEntitiesTree(self.layerContents)
Exemplo n.º 6
0
    def createHoughCirclesLayer(self):
        layerContent = Layers([])
        layerContent.name = 'HoughCircles'
        layerContent.children = []
        tempChildren = Layers([])

        tempChildren.name = 'dp'
        tempChildren.value = 1.5
        tempChildren.note = 'Inverse ratio'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'minDist'
        tempChildren.value = 100
        tempChildren.note = 'Minimum distance between two circles'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'param1'
        tempChildren.value = 100
        tempChildren.note = 'do not change'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'param2'
        tempChildren.value = 30
        tempChildren.note = 'do not change'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'minRadius'
        tempChildren.value = 10
        tempChildren.note = 'Minimum circle radius'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'maxRadius'
        tempChildren.value = 0
        tempChildren.note = 'Maximum circle radius'
        layerContent.children.append(deepcopy(tempChildren))

        self.layerContents.append(layerContent)
        self.TreeHandler.buildEntitiesTree(self.layerContents)
Exemplo n.º 7
0
    def load(self, content, compleet=True):
        match = re.match(
            Project.header.replace('+', '\+') % r'(\d+\.\d+)', content)
        if not match:
            raise Exception('Incorrect project file')
        version = float(match.groups()[0])
        if version not in Project.supported_versions:
            raise VersionMismatchError(match.group(), Project.version)

        execute(self, content)

        if compleet:
            self.parent.filename = self.file

            self.parent.connectToolbarToConfig(True)
            if not self.parent.load(False):
                self.parent.unsetCursor()
                return

        layers = []
        layer = Layers([])
        for parent_layer in self.layers:
            layer.name = parent_layer['name']
            layer.enable = parent_layer['enable']
            layer.children = []

            tempLayer = Layers([])
            for shape in parent_layer['shapes']:
                tempLayer.clear()
                tempLayer.name = shape['name']
                tempLayer.value = shape['value']
                tempLayer.note = shape['note']
                layer.children.append(deepcopy(tempLayer))

            layers.append(deepcopy(layer))

        self.parent.layerContents = Layers(layers)  # overwrite original
        self.parent.load()
Exemplo n.º 8
0
    def createthresholdLayer(self):
        layerContent = Layers([])
        layerContent.name = 'threshold'
        layerContent.children = []
        tempChildren = Layers([])
        layerContent.enable = 1

        tempChildren.name = 'thresh'
        tempChildren.value = 0
        tempChildren.note = 'thresh'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'maxval'
        tempChildren.value = 255
        tempChildren.note = 'maxval'
        layerContent.children.append(deepcopy(tempChildren))

        tempChildren.name = 'triangle'
        tempChildren.value = 0
        tempChildren.note = '0=otsu,1=triangle'
        layerContent.children.append(deepcopy(tempChildren))

        self.layerContents.append(layerContent)
        self.TreeHandler.buildEntitiesTree(self.layerContents)
Exemplo n.º 9
0
    def __init__(self, app):
        """
        Initialization of the Main window. This is directly called after the
        Logger has been initialized. The Function loads the GUI, creates the
        used Classes and connects the actions to the GUI.
        """
        QMainWindow.__init__(self)

        # Build the configuration window
        self.config_window = ConfigWindow(g.config.makeConfigWidgets(),
                                          g.config.var_dict,
                                          g.config.var_dict.configspec, self)
        self.config_window.finished.connect(self.updateConfiguration)

        self.app = app
        self.settings = QtCore.QSettings("py2cv", "py2cv")

        self.ui = Ui_MainWindow()

        self.ui.setupUi(self)
        self.showMaximized()

        self.cameraEnable = False

        self.canvas = self.ui.canvas
        self.canvas_scene = None

        self.TreeHandler = TreeHandler(self.ui)
        self.configuration_changed.connect(
            self.TreeHandler.updateConfiguration)

        if sys.version_info[0] == 2:
            error_message = QMessageBox(
                QMessageBox.Critical, 'ERROR',
                self.
                tr("Python version 2 is not supported, please use it with python version 3."
                   ))
            sys.exit(error_message.exec_())

        self.d2g = Project(self)

        self.createActions()
        self.connectToolbarToConfig()

        self.filename = ""

        # TCP Server
        if g.config.vars.Trigger.tcp_server_enable:
            self.server = QTcpServer()
            self.server.listen(QHostAddress.Any,
                               int(g.config.vars.Trigger.tcp_server_port))
            # Connection connect
            self.server.newConnection.connect(self.on_newConnection)
        self.entityRoot = None
        self.layerContents = Layers([])

        self.cont_dx = 0.0
        self.cont_dy = 0.0
        self.cont_rotate = 0.0
        self.cont_scale = 1.0

        self.restoreWindowState()

        if g.config.vars.AutoStart.autostart_enable:
            self.filename = qstr_encode(g.config.vars.AutoStart.autostart_dir)
            if len(self.filename) > 0:
                self.load()