def __init__(self, parent=None):
        super(Camera, self).__init__(parent)
        self.ui = Ui_Camera()
        self.pre_id = 0
        self.cur_id = 0
        self.count = 0
        self.checked = 0
        self.audio_settime = 0
        self.allow_flag = 1
        self.check_list = []
        self.camera = None
        self.imageCapture = None
        self.isCapturingImage = False
        self.applicationExiting = False
        self.ui.setupUi(self)
        cameraDevice = QByteArray()
        videoDevicesGroup = QActionGroup(self)
        videoDevicesGroup.setExclusive(True)
        for deviceName in QCamera.availableDevices():
            description = QCamera.deviceDescription(deviceName)
            videoDeviceAction = QAction(description, videoDevicesGroup)
            videoDeviceAction.setCheckable(True)
            videoDeviceAction.setData(deviceName)
            if cameraDevice.isEmpty():
                cameraDevice = deviceName
                videoDeviceAction.setChecked(True)
            self.ui.menuDevices.addAction(videoDeviceAction)
        videoDevicesGroup.triggered.connect(self.updateCameraDevice)
        self.setCamera(cameraDevice)

        # Create and load model
        path_pretrained = "apis/models/facenet/20180402-114759.pb"
        path_SVM = "apis/models/SVM/SVM.pkl"
        self.recognizer = Recognizer()
        self.recognizer.create_graph(path_pretrained, path_SVM)
Exemple #2
0
    def __init__(self, parent=None, standalone=False):
        super(Camera, self).__init__(parent)

        # This prevents doing unneeded initialization
        # when QtDesginer loads the plugin.
        if parent is None and not standalone:
            return

        if not multimedia_available:
            return

        self.ui = uic.loadUi(os.path.join(WIDGET_PATH, "camera.ui"), self)

        self.camera = None
        self.imageCapture = None
        self.mediaRecorder = None
        self.isCapturingImage = False
        self.applicationExiting = False

        self.imageSettings = QImageEncoderSettings()
        self.audioSettings = QAudioEncoderSettings()
        self.videoSettings = QVideoEncoderSettings()
        self.videoContainerFormat = ''

        camera_device = QByteArray()

        videoDevicesGroup = QActionGroup(self)

        videoDevicesGroup.setExclusive(True)

        if not QCamera.availableDevices():
            self.ui.devicesCombo.addItem("No Device")
        else:
            for deviceName in QCamera.availableDevices():
                description = QCamera.deviceDescription(deviceName)
                self.ui.devicesCombo.addItem(description)

                videoDeviceAction = QAction(description, videoDevicesGroup)
                videoDeviceAction.setCheckable(True)
                videoDeviceAction.setData(deviceName)

                if camera_device.isEmpty():
                    cameraDevice = deviceName
                    videoDeviceAction.setChecked(True)

                self.ui.devicesCombo.addAction(videoDeviceAction)

        videoDevicesGroup.triggered.connect(self.updateCameraDevice)

        self.ui.captureWidget.currentChanged.connect(self.updateCaptureMode)

        self.ui.devicesCombo.currentIndexChanged.connect(
            self.get_device_action)

        self.ui.lockButton.hide()

        # Start camera 2s after the UI has loaded
        QTimer.singleShot(2000, lambda: self.setCamera(camera_device))
Exemple #3
0
    def __fetch_cam(self):
        for device_obj in QCamera.availableDevices():
            cam_name = QCamera.deviceDescription(device_obj)

            cam = QCamera(device_obj)
            self.cams[str(cam_name)] = cam

            cam_image_capture = QCameraImageCapture(cam)
            cam_image_capture.setEncodingSettings(QImageEncoderSettings())
            cam_image_capture.captureDestination()
            cam_image_capture.imageSaved.connect(self.on_image_saved)
            self.__cam_image_captures[str(cam_name)] = cam_image_capture
            cam.statusChanged.connect(self.set_resolution)
Exemple #4
0
    def __init__(self, parent=None):
        super(Camera, self).__init__(parent)
        global API
        API = AlgorithmAPIs(template_dir="templates",
                            threshold=0.5,
                            use_multiprocessing=False)

        self.ui = Ui_Camera()

        self.camera = None
        self.imageCapture = None
        # self.mediaRecorder = None
        self.isCapturingImage = False
        self.applicationExiting = False

        self.imageSettings = QImageEncoderSettings()
        self.audioSettings = QAudioEncoderSettings()
        self.ui.setupUi(self)
        cameraDevice = QByteArray()
        videoDevicesGroup = QActionGroup(self)
        videoDevicesGroup.setExclusive(True)

        for deviceName in QCamera.availableDevices():
            description = QCamera.deviceDescription(deviceName)
            videoDeviceAction = QAction(description, videoDevicesGroup)
            videoDeviceAction.setCheckable(True)
            videoDeviceAction.setData(deviceName)

            if cameraDevice.isEmpty():
                cameraDevice = deviceName
                videoDeviceAction.setChecked(True)

            self.ui.menuDevices.addAction(videoDeviceAction)

        videoDevicesGroup.triggered.connect(self.updateCameraDevice)

        self.ui.lcdNumber_2.display(0)

        self.ui.dial.valueChanged.connect(self.dial_display)

        global dial_value
        dial_value = 3
        self.ui.lcdNumber_2.display(dial_value)
        self.setCamera(cameraDevice)

        # Create and load model
        path_pretrained = "apis/models/facenet/20180402-114759.pb"
        path_SVM = "apis/models/SVM/SVM.pkl"
        self.recognizer = Recognizer()
        self.recognizer.create_graph(path_pretrained, path_SVM)
Exemple #5
0
    def detectDevices(self):
        cameraDevice = QByteArray()

        for name in QCamera.availableDevices():
            description = QCamera.deviceDescription(name)
            deviceAction = QAction(description, self.videoDevicesGroup)
            deviceAction.setCheckable(True)
            deviceAction.setData(name)

            if cameraDevice.isEmpty():
                cameraDevice = name
                deviceAction.setChecked(True)

            self.menuDevices.addAction(deviceAction)

        self.videoDevicesGroup.triggered.connect(self.changeCameraDevice)
        self.setCamera(cameraDevice)
Exemple #6
0
    def initUI(self):

        # ========================= MENÚ ===========================

        menu = self.menuBar()

        archivoMenu = menu.addMenu("&Archivo")
        self.accionIniciarCamara = archivoMenu.addAction(
            self.style().standardIcon(QStyle.SP_MediaPlay),
            "Iniciar la camara", self.iniciarCamara)
        self.accionDetenerCamara = archivoMenu.addAction(
            self.style().standardIcon(QStyle.SP_MediaStop),
            "Detener la camara", self.detenerCamara)
        archivoMenu.addAction(
            self.style().standardIcon(QStyle.SP_MessageBoxCritical), " Salir",
            self.close)

        dispositivosMenu = menu.addMenu("&Dispositivos")

        videoDevicesGroup = QActionGroup(self)
        videoDevicesGroup.setExclusive(True)

        dispositivoCamara = QByteArray()

        for nombreDispositivo in QCamera.availableDevices():
            descripcion = QCamera.deviceDescription(nombreDispositivo)
            videoDeviceAction = QAction(descripcion, videoDevicesGroup)
            videoDeviceAction.setCheckable(True)
            videoDeviceAction.setData(nombreDispositivo)

            if dispositivoCamara.isEmpty():
                dispositivoCamara = nombreDispositivo
                videoDeviceAction.setChecked(True)

            dispositivosMenu.addAction(videoDeviceAction)

        # Instancia del Widget central
        self.widgets = Widgets(dispositivoCamara, self)

        # Llamar función cuando se activa una Acción del Menú
        videoDevicesGroup.triggered.connect(
            self.widgets.actualizarDispositivoCamara)

        # Establecer el Widget central de la ventana
        self.setCentralWidget(self.widgets)
Exemple #7
0
    def __init__(self, arg):
        super(Camera, self).__init__(parent)
        # self.arg = arg
        # Attributes variables
        self.ui = Ui_Camera()
        self.camera = None
        self.imageCapture = None
        self.mediaRecorder = None
        self.isCapturingImage = False
        self.applicationExiting = False

        self.imageSettings = QImageEncoderSettings()
        self.audioSettings = QAudioEncoderSettings()
        self.videoSettings = QVideoEncoderSettings()
        self.videoContainerFormat = ''

        self.ui.setupUi(self)

        #get device camera
        cameraDevice = QByteArray()

        videoDevicesGroup = QActionGroup(self)
        videoDevicesGroup.setExclusive(True)

        # Get informations about available cameras
        for deviceName in QCamera.availableDevices():
            description = QCamera.deviceDescription(deviceName)
            videoDeviceAction = QAction(description, videoDevicesGroup)
            videoDeviceAction.setCheckable(True)
            videoDeviceAction.setData(deviceName)

            if cameraDevice.isEmpty():
                cameraDevice = deviceName
                videoDeviceAction.setChecked(True)

            self.ui.menuDevices.addAction(videoDeviceAction)

        videoDevicesGroup.triggered.connect(self.updateCameraDevice)
        self.ui.captureWidget.currentChanged.connect(self.updateCaptureMode)

        self.ui.lockButton.hide()

        self.setCamera(cameraDevice)
Exemple #8
0
    def __init__(self, parent=None):
        super(Camera, self).__init__(parent)

        self.ui = Ui_Camera()
        self.camera = None
        self.imageCapture = None
        self.mediaRecorder = None
        self.isCapturingImage = False
        self.applicationExiting = False

        self.imageSettings = QImageEncoderSettings()
        self.audioSettings = QAudioEncoderSettings()
        self.videoSettings = QVideoEncoderSettings()
        self.videoContainerFormat = ''

        self.ui.setupUi(self)

        cameraDevice = QByteArray()

        videoDevicesGroup = QActionGroup(self)
        videoDevicesGroup.setExclusive(True)

#for multiple cameras ata

        for deviceName in QCamera.availableDevices():
            description = QCamera.deviceDescription(deviceName)
            videoDeviceAction = QAction(description, videoDevicesGroup)
            videoDeviceAction.setCheckable(True)
            videoDeviceAction.setData(deviceName)

            if cameraDevice.isEmpty():
                cameraDevice = deviceName
                videoDeviceAction.setChecked(True)

            self.ui.menuDevices.addAction(videoDeviceAction)

        videoDevicesGroup.triggered.connect(self.updateCameraDevice)
        self.ui.captureWidget.currentChanged.connect(self.updateCaptureMode)

        self.ui.lockButton.hide()

        self.setCamera(cameraDevice)
Exemple #9
0
    def __init__(self):
        super().__init__()

        self.setupUi()
        cameraDevice = ''
        videoDevicesGroup = QActionGroup(self)
        videoDevicesGroup.setExclusive(True)

        for deviceName in QCamera.availableDevices():
            description = QCamera.deviceDescription(deviceName)
            videoDeviceAction = QAction(description, videoDevicesGroup)
            videoDeviceAction.setCheckable(True)
            videoDeviceAction.setData(deviceName)

            if not cameraDevice:
                cameraDevice = deviceName
                videoDeviceAction.setChecked(True)
        print(7)
        self.setCamera(cameraDevice)
        print(8)
        self.show()
Exemple #10
0
    def setup_camera(self):
        camera_device = QByteArray()

        video_devices_group = QActionGroup(self)
        video_devices_group.setExclusive(True)

        for device in QCamera.availableDevices():
            description = QCamera.deviceDescription(device)
            video_device_action = QAction(description, video_devices_group)
            video_device_action.setCheckable(True)
            video_device_action.setData(device)

            if camera_device.isEmpty():
                camera_device = device
                video_device_action.setChecked(True)

            self.ui.menuDevices.addAction(video_device_action)
        if camera_device.isEmpty():
            self.camera = QCamera()
        else:
            self.camera = QCamera(camera_device)
        self.camera.setViewfinder(self.ui.cameraViewFinder)
Exemple #11
0
 def get_available_camera_names(cls) -> list:
     return [QCamera.deviceDescription(device_obj) for device_obj in QCamera.availableDevices()]